2012-04-10 21:17:01 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Ben Widawsky <ben@bwidawsk.net>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/sysfs.h>
|
2019-04-26 09:17:22 +01:00
|
|
|
|
2022-01-27 15:43:33 -08:00
|
|
|
#include "gt/intel_gt_regs.h"
|
2019-09-27 12:08:49 +01:00
|
|
|
#include "gt/intel_rc6.h"
|
2019-10-24 22:16:41 +01:00
|
|
|
#include "gt/intel_rps.h"
|
2020-02-28 13:17:10 +00:00
|
|
|
#include "gt/sysfs_engines.h"
|
2019-09-27 12:08:49 +01:00
|
|
|
|
2019-04-29 15:29:37 +03:00
|
|
|
#include "i915_drv.h"
|
2019-08-08 16:42:45 +03:00
|
|
|
#include "i915_sysfs.h"
|
2012-04-10 21:17:01 -07:00
|
|
|
|
2022-03-19 01:39:34 +02:00
|
|
|
struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
|
2016-08-22 13:32:42 +03:00
|
|
|
{
|
2016-08-22 13:32:43 +03:00
|
|
|
struct drm_minor *minor = dev_get_drvdata(kdev);
|
|
|
|
return to_i915(minor->dev);
|
2016-08-22 13:32:42 +03:00
|
|
|
}
|
2013-10-11 14:45:30 +10:00
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
static int l3_access_valid(struct drm_i915_private *i915, loff_t offset)
|
2012-05-25 16:56:25 -07:00
|
|
|
{
|
2019-10-04 11:59:58 +01:00
|
|
|
if (!HAS_L3_DPF(i915))
|
2012-05-25 16:56:25 -07:00
|
|
|
return -EPERM;
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
if (!IS_ALIGNED(offset, sizeof(u32)))
|
2012-05-25 16:56:25 -07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (offset >= GEN7_L3LOG_SIZE)
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
i915_l3_read(struct file *filp, struct kobject *kobj,
|
2024-12-16 12:34:49 +01:00
|
|
|
const struct bin_attribute *attr, char *buf,
|
2012-05-25 16:56:25 -07:00
|
|
|
loff_t offset, size_t count)
|
|
|
|
{
|
2016-08-22 13:32:42 +03:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2019-10-04 11:59:58 +01:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
2013-09-19 11:13:41 -07:00
|
|
|
int slice = (int)(uintptr_t)attr->private;
|
drm/i915: Do remaps for all contexts
On both Ivybridge and Haswell, row remapping information is saved and
restored with context. This means, we never actually properly supported
the l3 remapping because our sysfs interface is asynchronous (and not
tied to any context), and the known faulty HW would be reused by the
next context to run.
Not that due to the asynchronous nature of the sysfs entry, there is no
point modifying the registers for the existing context. Instead we set a
flag for all contexts to load the correct remapping information on the
next run. Interested clients can use debugfs to determine whether or not
the row has been remapped.
One could propose at this point that we just do the remapping in the
kernel. I guess since we have to maintain the sysfs interface anyway,
I'm not sure how useful it is, and I do like keeping the policy in
userspace; (it wasn't my original decision to make the
interface the way it is, so I'm not attached).
v2: Force a context switch when we have a remap on the next switch.
(Ville)
Don't let userspace use the interface with disabled contexts.
v3: Don't force a context switch, just let it nop
Improper context slice remap initialization, 1<<1 instead of 1<<i, but I
rewrote it to avoid a second round of confusion.
Error print moved to error path (All Ville)
Added a comment on why the slice remap initialization happens.
CC: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-18 19:03:18 -07:00
|
|
|
int ret;
|
2012-05-25 16:56:25 -07:00
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
ret = l3_access_valid(i915, offset);
|
2012-05-25 16:56:25 -07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
count = round_down(count, sizeof(u32));
|
2013-09-20 14:20:18 +03:00
|
|
|
count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count);
|
2019-10-04 11:59:58 +01:00
|
|
|
memset(buf, 0, count);
|
2013-09-12 22:28:29 -07:00
|
|
|
|
2019-10-04 14:40:09 +01:00
|
|
|
spin_lock(&i915->gem.contexts.lock);
|
2019-10-04 11:59:58 +01:00
|
|
|
if (i915->l3_parity.remap_info[slice])
|
drm/i915: Do remaps for all contexts
On both Ivybridge and Haswell, row remapping information is saved and
restored with context. This means, we never actually properly supported
the l3 remapping because our sysfs interface is asynchronous (and not
tied to any context), and the known faulty HW would be reused by the
next context to run.
Not that due to the asynchronous nature of the sysfs entry, there is no
point modifying the registers for the existing context. Instead we set a
flag for all contexts to load the correct remapping information on the
next run. Interested clients can use debugfs to determine whether or not
the row has been remapped.
One could propose at this point that we just do the remapping in the
kernel. I guess since we have to maintain the sysfs interface anyway,
I'm not sure how useful it is, and I do like keeping the policy in
userspace; (it wasn't my original decision to make the
interface the way it is, so I'm not attached).
v2: Force a context switch when we have a remap on the next switch.
(Ville)
Don't let userspace use the interface with disabled contexts.
v3: Don't force a context switch, just let it nop
Improper context slice remap initialization, 1<<1 instead of 1<<i, but I
rewrote it to avoid a second round of confusion.
Error print moved to error path (All Ville)
Added a comment on why the slice remap initialization happens.
CC: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-18 19:03:18 -07:00
|
|
|
memcpy(buf,
|
2019-10-04 11:59:58 +01:00
|
|
|
i915->l3_parity.remap_info[slice] + offset / sizeof(u32),
|
drm/i915: Do remaps for all contexts
On both Ivybridge and Haswell, row remapping information is saved and
restored with context. This means, we never actually properly supported
the l3 remapping because our sysfs interface is asynchronous (and not
tied to any context), and the known faulty HW would be reused by the
next context to run.
Not that due to the asynchronous nature of the sysfs entry, there is no
point modifying the registers for the existing context. Instead we set a
flag for all contexts to load the correct remapping information on the
next run. Interested clients can use debugfs to determine whether or not
the row has been remapped.
One could propose at this point that we just do the remapping in the
kernel. I guess since we have to maintain the sysfs interface anyway,
I'm not sure how useful it is, and I do like keeping the policy in
userspace; (it wasn't my original decision to make the
interface the way it is, so I'm not attached).
v2: Force a context switch when we have a remap on the next switch.
(Ville)
Don't let userspace use the interface with disabled contexts.
v3: Don't force a context switch, just let it nop
Improper context slice remap initialization, 1<<1 instead of 1<<i, but I
rewrote it to avoid a second round of confusion.
Error print moved to error path (All Ville)
Added a comment on why the slice remap initialization happens.
CC: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-09-18 19:03:18 -07:00
|
|
|
count);
|
2019-10-04 14:40:09 +01:00
|
|
|
spin_unlock(&i915->gem.contexts.lock);
|
2012-05-25 16:56:25 -07:00
|
|
|
|
2013-09-17 21:12:42 -07:00
|
|
|
return count;
|
2012-05-25 16:56:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
i915_l3_write(struct file *filp, struct kobject *kobj,
|
2024-12-16 12:34:49 +01:00
|
|
|
const struct bin_attribute *attr, char *buf,
|
2012-05-25 16:56:25 -07:00
|
|
|
loff_t offset, size_t count)
|
|
|
|
{
|
2016-08-22 13:32:42 +03:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2019-10-04 11:59:58 +01:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
2013-09-19 11:13:41 -07:00
|
|
|
int slice = (int)(uintptr_t)attr->private;
|
2019-10-04 14:40:09 +01:00
|
|
|
u32 *remap_info, *freeme = NULL;
|
2019-10-04 11:59:58 +01:00
|
|
|
struct i915_gem_context *ctx;
|
2012-05-25 16:56:25 -07:00
|
|
|
int ret;
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
ret = l3_access_valid(i915, offset);
|
2012-05-25 16:56:25 -07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
if (count < sizeof(u32))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-10-04 14:40:09 +01:00
|
|
|
remap_info = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL);
|
|
|
|
if (!remap_info)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock(&i915->gem.contexts.lock);
|
2012-05-25 16:56:25 -07:00
|
|
|
|
2019-10-04 14:40:09 +01:00
|
|
|
if (i915->l3_parity.remap_info[slice]) {
|
|
|
|
freeme = remap_info;
|
|
|
|
remap_info = i915->l3_parity.remap_info[slice];
|
|
|
|
} else {
|
|
|
|
i915->l3_parity.remap_info[slice] = remap_info;
|
2012-05-25 16:56:25 -07:00
|
|
|
}
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
count = round_down(count, sizeof(u32));
|
2019-10-04 14:40:09 +01:00
|
|
|
memcpy(remap_info + offset / sizeof(u32), buf, count);
|
2019-10-04 11:59:58 +01:00
|
|
|
|
|
|
|
/* NB: We defer the remapping until we switch to the context */
|
2019-10-04 14:40:09 +01:00
|
|
|
list_for_each_entry(ctx, &i915->gem.contexts.list, link)
|
2019-10-04 11:59:58 +01:00
|
|
|
ctx->remap_slice |= BIT(slice);
|
|
|
|
|
2019-10-04 14:40:09 +01:00
|
|
|
spin_unlock(&i915->gem.contexts.lock);
|
|
|
|
kfree(freeme);
|
|
|
|
|
2019-10-04 11:59:58 +01:00
|
|
|
/*
|
|
|
|
* TODO: Ideally we really want a GPU reset here to make sure errors
|
2012-05-25 16:56:25 -07:00
|
|
|
* aren't propagated. Since I cannot find a stable way to reset the GPU
|
|
|
|
* at this point it is left as a TODO.
|
|
|
|
*/
|
|
|
|
|
2019-10-04 14:40:09 +01:00
|
|
|
return count;
|
2012-05-25 16:56:25 -07:00
|
|
|
}
|
|
|
|
|
2017-08-02 22:50:47 +05:30
|
|
|
static const struct bin_attribute dpf_attrs = {
|
2012-05-25 16:56:25 -07:00
|
|
|
.attr = {.name = "l3_parity", .mode = (S_IRUSR | S_IWUSR)},
|
|
|
|
.size = GEN7_L3LOG_SIZE,
|
2025-05-30 05:54:37 +02:00
|
|
|
.read = i915_l3_read,
|
|
|
|
.write = i915_l3_write,
|
2013-09-19 11:13:41 -07:00
|
|
|
.mmap = NULL,
|
|
|
|
.private = (void *)0
|
|
|
|
};
|
|
|
|
|
2017-08-02 22:50:47 +05:30
|
|
|
static const struct bin_attribute dpf_attrs_1 = {
|
2013-09-19 11:13:41 -07:00
|
|
|
.attr = {.name = "l3_parity_slice_1", .mode = (S_IRUSR | S_IWUSR)},
|
|
|
|
.size = GEN7_L3LOG_SIZE,
|
2025-05-30 05:54:37 +02:00
|
|
|
.read = i915_l3_read,
|
|
|
|
.write = i915_l3_write,
|
2013-09-19 11:13:41 -07:00
|
|
|
.mmap = NULL,
|
|
|
|
.private = (void *)1
|
2012-05-25 16:56:25 -07:00
|
|
|
};
|
|
|
|
|
2016-08-22 13:32:43 +03:00
|
|
|
void i915_setup_sysfs(struct drm_i915_private *dev_priv)
|
2012-04-10 21:17:01 -07:00
|
|
|
{
|
2016-08-22 13:32:43 +03:00
|
|
|
struct device *kdev = dev_priv->drm.primary->kdev;
|
2012-04-10 21:17:01 -07:00
|
|
|
int ret;
|
|
|
|
|
2016-08-22 13:32:43 +03:00
|
|
|
if (HAS_L3_DPF(dev_priv)) {
|
|
|
|
ret = device_create_bin_file(kdev, &dpf_attrs);
|
2012-05-31 14:57:43 +02:00
|
|
|
if (ret)
|
drm/i915: conversion to drm_device logging macros when drm_i915_private is present.
Converts various instances of the printk drm logging macros to the
struct drm_device based logging macros in the drm/i915 folder using the
following coccinelle script that transforms based on the existence of
the struct drm_i915_private device pointer:
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Checkpatch warnings were fixed manually.
Instances of the DRM_DEBUG macro were not converted due to lack of a
consensus of an analogous struct drm_device based macro.
References: https://lists.freedesktop.org/archives/dri-devel/2020-January/253381.html
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200131093416.28431-2-wambui.karugax@gmail.com
2020-01-31 12:34:12 +03:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"l3 parity sysfs setup failed\n");
|
2013-09-19 11:13:41 -07:00
|
|
|
|
2016-08-22 13:32:43 +03:00
|
|
|
if (NUM_L3_SLICES(dev_priv) > 1) {
|
|
|
|
ret = device_create_bin_file(kdev,
|
2013-09-19 11:13:41 -07:00
|
|
|
&dpf_attrs_1);
|
|
|
|
if (ret)
|
drm/i915: conversion to drm_device logging macros when drm_i915_private is present.
Converts various instances of the printk drm logging macros to the
struct drm_device based logging macros in the drm/i915 folder using the
following coccinelle script that transforms based on the existence of
the struct drm_i915_private device pointer:
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Checkpatch warnings were fixed manually.
Instances of the DRM_DEBUG macro were not converted due to lack of a
consensus of an analogous struct drm_device based macro.
References: https://lists.freedesktop.org/archives/dri-devel/2020-January/253381.html
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200131093416.28431-2-wambui.karugax@gmail.com
2020-01-31 12:34:12 +03:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"l3 parity slice 1 setup failed\n");
|
2013-09-19 11:13:41 -07:00
|
|
|
}
|
2012-05-31 14:57:43 +02:00
|
|
|
}
|
2012-09-07 19:43:40 -07:00
|
|
|
|
2022-03-19 01:39:34 +02:00
|
|
|
dev_priv->sysfs_gt = kobject_create_and_add("gt", &kdev->kobj);
|
|
|
|
if (!dev_priv->sysfs_gt)
|
|
|
|
drm_warn(&dev_priv->drm,
|
|
|
|
"failed to register GT sysfs directory\n");
|
|
|
|
|
2023-10-31 14:45:02 +02:00
|
|
|
i915_gpu_error_sysfs_setup(dev_priv);
|
2020-02-28 13:17:10 +00:00
|
|
|
|
|
|
|
intel_engines_add_sysfs(dev_priv);
|
2012-04-10 21:17:01 -07:00
|
|
|
}
|
|
|
|
|
2016-08-22 13:32:43 +03:00
|
|
|
void i915_teardown_sysfs(struct drm_i915_private *dev_priv)
|
2012-04-10 21:17:01 -07:00
|
|
|
{
|
2016-08-22 13:32:43 +03:00
|
|
|
struct device *kdev = dev_priv->drm.primary->kdev;
|
|
|
|
|
2023-10-31 14:45:02 +02:00
|
|
|
i915_gpu_error_sysfs_teardown(dev_priv);
|
2016-10-12 10:05:18 +01:00
|
|
|
|
2024-08-07 14:05:16 +01:00
|
|
|
device_remove_bin_file(kdev, &dpf_attrs_1);
|
|
|
|
device_remove_bin_file(kdev, &dpf_attrs);
|
2022-05-25 06:19:20 -07:00
|
|
|
|
|
|
|
kobject_put(dev_priv->sysfs_gt);
|
2012-04-10 21:17:01 -07:00
|
|
|
}
|