2012-04-11 11: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 15:17:22 +07:00
|
|
|
|
2019-09-27 18:08:49 +07:00
|
|
|
#include "gt/intel_rc6.h"
|
2019-10-25 04:16:41 +07:00
|
|
|
#include "gt/intel_rps.h"
|
2020-02-28 20:17:10 +07:00
|
|
|
#include "gt/sysfs_engines.h"
|
2019-09-27 18:08:49 +07:00
|
|
|
|
2019-04-29 19:29:37 +07:00
|
|
|
#include "i915_drv.h"
|
2019-08-08 20:42:45 +07:00
|
|
|
#include "i915_sysfs.h"
|
2019-04-29 19:29:37 +07:00
|
|
|
#include "intel_pm.h"
|
2019-04-26 15:17:22 +07:00
|
|
|
#include "intel_sideband.h"
|
2012-04-11 11:17:01 +07:00
|
|
|
|
2016-08-22 17:32:43 +07:00
|
|
|
static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
|
2016-08-22 17:32:42 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_minor *minor = dev_get_drvdata(kdev);
|
|
|
|
return to_i915(minor->dev);
|
2016-08-22 17:32:42 +07:00
|
|
|
}
|
2013-10-11 11:45:30 +07:00
|
|
|
|
2012-07-01 10:45:07 +07:00
|
|
|
#ifdef CONFIG_PM
|
2016-08-22 17:32:43 +07:00
|
|
|
static u32 calc_residency(struct drm_i915_private *dev_priv,
|
drm/i915: Type safe register read/write
Make I915_READ and I915_WRITE more type safe by wrapping the register
offset in a struct. This should eliminate most of the fumbles we've had
with misplaced parens.
This only takes care of normal mmio registers. We could extend the idea
to other register types and define each with its own struct. That way
you wouldn't be able to accidentally pass the wrong thing to a specific
register access function.
The gpio_reg setup is probably the ugliest thing left. But I figure I'd
just leave it for now, and wait for some divine inspiration to strike
before making it nice.
As for the generated code, it's actually a bit better sometimes. Eg.
looking at i915_irq_handler(), we can see the following change:
lea 0x70024(%rdx,%rax,1),%r9d
mov $0x1,%edx
- movslq %r9d,%r9
- mov %r9,%rsi
- mov %r9,-0x58(%rbp)
- callq *0xd8(%rbx)
+ mov %r9d,%esi
+ mov %r9d,-0x48(%rbp)
callq *0xd8(%rbx)
So previously gcc thought the register offset might be signed and
decided to sign extend it, just in case. The rest appears to be
mostly just minor shuffling of instructions.
v2: i915_mmio_reg_{offset,equal,valid}() helpers added
s/_REG/_MMIO/ in the register defines
mo more switch statements left to worry about
ring_emit stuff got sorted in a prep patch
cmd parser, lrc context and w/a batch buildup also in prep patch
vgpu stuff cleaned up and moved to a prep patch
all other unrelated changes split out
v3: Rebased due to BXT DSI/BLC, MOCS, etc.
v4: Rebased due to churn, s/i915_mmio_reg_t/i915_reg_t/
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1447853606-2751-1-git-send-email-ville.syrjala@linux.intel.com
2015-11-18 20:33:26 +07:00
|
|
|
i915_reg_t reg)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2019-01-14 21:21:13 +07:00
|
|
|
intel_wakeref_t wakeref;
|
2019-01-14 21:21:23 +07:00
|
|
|
u64 res = 0;
|
2017-11-22 01:18:51 +07:00
|
|
|
|
2019-06-14 06:21:55 +07:00
|
|
|
with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
|
2019-09-27 18:08:49 +07:00
|
|
|
res = intel_rc6_residency_us(&dev_priv->gt.rc6, reg);
|
2017-11-22 01:18:51 +07:00
|
|
|
|
|
|
|
return DIV_ROUND_CLOSEST_ULL(res, 1000);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-08 09:43:38 +07:00
|
|
|
show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2017-12-01 18:30:30 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
|
|
|
unsigned int mask;
|
|
|
|
|
|
|
|
mask = 0;
|
|
|
|
if (HAS_RC6(dev_priv))
|
|
|
|
mask |= BIT(0);
|
|
|
|
if (HAS_RC6p(dev_priv))
|
|
|
|
mask |= BIT(1);
|
|
|
|
if (HAS_RC6pp(dev_priv))
|
|
|
|
mask |= BIT(2);
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%x\n", mask);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-08 09:43:38 +07:00
|
|
|
show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
|
|
|
u32 rc6_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6);
|
2013-02-14 15:42:11 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-08 09:43:38 +07:00
|
|
|
show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
|
|
|
u32 rc6p_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6p);
|
2013-02-14 15:42:11 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%u\n", rc6p_residency);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
2012-09-08 09:43:38 +07:00
|
|
|
show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
|
|
|
u32 rc6pp_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6pp);
|
2013-02-14 15:42:11 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%u\n", rc6pp_residency);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
2015-02-26 22:40:27 +07:00
|
|
|
static ssize_t
|
|
|
|
show_media_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
|
|
|
u32 rc6_residency = calc_residency(dev_priv, VLV_GT_MEDIA_RC6);
|
2015-02-26 22:40:27 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency);
|
|
|
|
}
|
|
|
|
|
2012-04-11 11:17:01 +07:00
|
|
|
static DEVICE_ATTR(rc6_enable, S_IRUGO, show_rc6_mask, NULL);
|
|
|
|
static DEVICE_ATTR(rc6_residency_ms, S_IRUGO, show_rc6_ms, NULL);
|
|
|
|
static DEVICE_ATTR(rc6p_residency_ms, S_IRUGO, show_rc6p_ms, NULL);
|
|
|
|
static DEVICE_ATTR(rc6pp_residency_ms, S_IRUGO, show_rc6pp_ms, NULL);
|
2015-02-26 22:40:27 +07:00
|
|
|
static DEVICE_ATTR(media_rc6_residency_ms, S_IRUGO, show_media_rc6_ms, NULL);
|
2012-04-11 11:17:01 +07:00
|
|
|
|
|
|
|
static struct attribute *rc6_attrs[] = {
|
|
|
|
&dev_attr_rc6_enable.attr,
|
|
|
|
&dev_attr_rc6_residency_ms.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-07-03 18:08:25 +07:00
|
|
|
static const struct attribute_group rc6_attr_group = {
|
2012-04-11 11:17:01 +07:00
|
|
|
.name = power_group_name,
|
|
|
|
.attrs = rc6_attrs
|
|
|
|
};
|
2014-10-07 21:06:50 +07:00
|
|
|
|
|
|
|
static struct attribute *rc6p_attrs[] = {
|
|
|
|
&dev_attr_rc6p_residency_ms.attr,
|
|
|
|
&dev_attr_rc6pp_residency_ms.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-07-03 18:08:25 +07:00
|
|
|
static const struct attribute_group rc6p_attr_group = {
|
2014-10-07 21:06:50 +07:00
|
|
|
.name = power_group_name,
|
|
|
|
.attrs = rc6p_attrs
|
|
|
|
};
|
2015-02-26 22:40:27 +07:00
|
|
|
|
|
|
|
static struct attribute *media_rc6_attrs[] = {
|
|
|
|
&dev_attr_media_rc6_residency_ms.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-07-03 18:08:25 +07:00
|
|
|
static const struct attribute_group media_rc6_attr_group = {
|
2015-02-26 22:40:27 +07:00
|
|
|
.name = power_group_name,
|
|
|
|
.attrs = media_rc6_attrs
|
|
|
|
};
|
2012-09-02 14:24:40 +07:00
|
|
|
#endif
|
2012-04-11 11:17:01 +07:00
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
static int l3_access_valid(struct drm_i915_private *i915, loff_t offset)
|
2012-05-26 06:56:25 +07:00
|
|
|
{
|
2019-10-04 17:59:58 +07:00
|
|
|
if (!HAS_L3_DPF(i915))
|
2012-05-26 06:56:25 +07:00
|
|
|
return -EPERM;
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
if (!IS_ALIGNED(offset, sizeof(u32)))
|
2012-05-26 06: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,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t offset, size_t count)
|
|
|
|
{
|
2016-08-22 17:32:42 +07:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2019-10-04 17:59:58 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
2013-09-20 01: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-19 09:03:18 +07:00
|
|
|
int ret;
|
2012-05-26 06:56:25 +07:00
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
ret = l3_access_valid(i915, offset);
|
2012-05-26 06:56:25 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
count = round_down(count, sizeof(u32));
|
2013-09-20 18:20:18 +07:00
|
|
|
count = min_t(size_t, GEN7_L3LOG_SIZE - offset, count);
|
2019-10-04 17:59:58 +07:00
|
|
|
memset(buf, 0, count);
|
2013-09-13 12:28:29 +07:00
|
|
|
|
2019-10-04 20:40:09 +07:00
|
|
|
spin_lock(&i915->gem.contexts.lock);
|
2019-10-04 17:59:58 +07: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-19 09:03:18 +07:00
|
|
|
memcpy(buf,
|
2019-10-04 17:59:58 +07: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-19 09:03:18 +07:00
|
|
|
count);
|
2019-10-04 20:40:09 +07:00
|
|
|
spin_unlock(&i915->gem.contexts.lock);
|
2012-05-26 06:56:25 +07:00
|
|
|
|
2013-09-18 11:12:42 +07:00
|
|
|
return count;
|
2012-05-26 06:56:25 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
i915_l3_write(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t offset, size_t count)
|
|
|
|
{
|
2016-08-22 17:32:42 +07:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2019-10-04 17:59:58 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
2013-09-20 01:13:41 +07:00
|
|
|
int slice = (int)(uintptr_t)attr->private;
|
2019-10-04 20:40:09 +07:00
|
|
|
u32 *remap_info, *freeme = NULL;
|
2019-10-04 17:59:58 +07:00
|
|
|
struct i915_gem_context *ctx;
|
2012-05-26 06:56:25 +07:00
|
|
|
int ret;
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
ret = l3_access_valid(i915, offset);
|
2012-05-26 06:56:25 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
if (count < sizeof(u32))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-10-04 20:40:09 +07:00
|
|
|
remap_info = kzalloc(GEN7_L3LOG_SIZE, GFP_KERNEL);
|
|
|
|
if (!remap_info)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
spin_lock(&i915->gem.contexts.lock);
|
2012-05-26 06:56:25 +07:00
|
|
|
|
2019-10-04 20:40:09 +07: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-26 06:56:25 +07:00
|
|
|
}
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
count = round_down(count, sizeof(u32));
|
2019-10-04 20:40:09 +07:00
|
|
|
memcpy(remap_info + offset / sizeof(u32), buf, count);
|
2019-10-04 17:59:58 +07:00
|
|
|
|
|
|
|
/* NB: We defer the remapping until we switch to the context */
|
2019-10-04 20:40:09 +07:00
|
|
|
list_for_each_entry(ctx, &i915->gem.contexts.list, link)
|
2019-10-04 17:59:58 +07:00
|
|
|
ctx->remap_slice |= BIT(slice);
|
|
|
|
|
2019-10-04 20:40:09 +07:00
|
|
|
spin_unlock(&i915->gem.contexts.lock);
|
|
|
|
kfree(freeme);
|
|
|
|
|
2019-10-04 17:59:58 +07:00
|
|
|
/*
|
|
|
|
* TODO: Ideally we really want a GPU reset here to make sure errors
|
2012-05-26 06: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 20:40:09 +07:00
|
|
|
return count;
|
2012-05-26 06:56:25 +07:00
|
|
|
}
|
|
|
|
|
2017-08-03 00:20:47 +07:00
|
|
|
static const struct bin_attribute dpf_attrs = {
|
2012-05-26 06:56:25 +07:00
|
|
|
.attr = {.name = "l3_parity", .mode = (S_IRUSR | S_IWUSR)},
|
|
|
|
.size = GEN7_L3LOG_SIZE,
|
|
|
|
.read = i915_l3_read,
|
|
|
|
.write = i915_l3_write,
|
2013-09-20 01:13:41 +07:00
|
|
|
.mmap = NULL,
|
|
|
|
.private = (void *)0
|
|
|
|
};
|
|
|
|
|
2017-08-03 00:20:47 +07:00
|
|
|
static const struct bin_attribute dpf_attrs_1 = {
|
2013-09-20 01:13:41 +07:00
|
|
|
.attr = {.name = "l3_parity_slice_1", .mode = (S_IRUSR | S_IWUSR)},
|
|
|
|
.size = GEN7_L3LOG_SIZE,
|
|
|
|
.read = i915_l3_read,
|
|
|
|
.write = i915_l3_write,
|
|
|
|
.mmap = NULL,
|
|
|
|
.private = (void *)1
|
2012-05-26 06:56:25 +07:00
|
|
|
};
|
|
|
|
|
2015-01-24 02:04:24 +07:00
|
|
|
static ssize_t gt_act_freq_mhz_show(struct device *kdev,
|
2012-09-08 09:43:40 +07:00
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2019-12-14 01:37:35 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
|
|
|
struct intel_rps *rps = &i915->gt.rps;
|
2015-01-24 02:04:24 +07:00
|
|
|
|
2019-12-14 01:37:35 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
|
|
|
intel_rps_read_actual_frequency(rps));
|
2015-01-24 02:04:24 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t gt_cur_freq_mhz_show(struct device *kdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2019-12-14 01:37:35 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
|
|
|
struct intel_rps *rps = &i915->gt.rps;
|
2012-09-08 09:43:40 +07:00
|
|
|
|
2016-07-13 15:10:36 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, rps->cur_freq));
|
2012-09-08 09:43:40 +07:00
|
|
|
}
|
|
|
|
|
2016-07-13 15:10:35 +07:00
|
|
|
static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2019-12-14 01:37:35 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
|
|
|
struct intel_rps *rps = &i915->gt.rps;
|
2016-07-13 15:10:35 +07:00
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, rps->boost_freq));
|
2016-07-13 15:10:35 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t gt_boost_freq_mhz_store(struct device *kdev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2018-03-08 21:26:47 +07:00
|
|
|
bool boost = false;
|
2016-07-13 15:10:35 +07:00
|
|
|
ssize_t ret;
|
2018-03-08 21:26:47 +07:00
|
|
|
u32 val;
|
2016-07-13 15:10:35 +07:00
|
|
|
|
|
|
|
ret = kstrtou32(buf, 0, &val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Validate against (static) hardware limits */
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_freq_opcode(rps, val);
|
2017-10-11 04:30:06 +07:00
|
|
|
if (val < rps->min_freq || val > rps->max_freq)
|
2016-07-13 15:10:35 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2019-04-26 15:17:21 +07:00
|
|
|
mutex_lock(&rps->lock);
|
2018-03-08 21:26:47 +07:00
|
|
|
if (val != rps->boost_freq) {
|
|
|
|
rps->boost_freq = val;
|
|
|
|
boost = atomic_read(&rps->num_waiters);
|
|
|
|
}
|
2019-04-26 15:17:21 +07:00
|
|
|
mutex_unlock(&rps->lock);
|
2018-03-08 21:26:47 +07:00
|
|
|
if (boost)
|
|
|
|
schedule_work(&rps->work);
|
2016-07-13 15:10:35 +07:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2013-08-26 22:18:54 +07:00
|
|
|
static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2013-08-26 22:18:54 +07:00
|
|
|
|
2016-07-13 15:10:36 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, rps->efficient_freq));
|
2013-08-26 22:18:54 +07:00
|
|
|
}
|
|
|
|
|
2012-09-08 09:43:40 +07:00
|
|
|
static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2013-09-17 04:56:43 +07:00
|
|
|
|
2016-07-13 15:10:36 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, rps->max_freq_softlimit));
|
2012-09-08 09:43:40 +07:00
|
|
|
}
|
|
|
|
|
2012-09-13 08:12:07 +07:00
|
|
|
static ssize_t gt_max_freq_mhz_store(struct device *kdev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2012-09-13 08:12:07 +07:00
|
|
|
ssize_t ret;
|
2019-10-25 04:16:41 +07:00
|
|
|
u32 val;
|
2012-09-13 08:12:07 +07:00
|
|
|
|
|
|
|
ret = kstrtou32(buf, 0, &val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-04-26 15:17:21 +07:00
|
|
|
mutex_lock(&rps->lock);
|
2012-09-13 08:12:07 +07:00
|
|
|
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_freq_opcode(rps, val);
|
2017-10-11 04:30:06 +07:00
|
|
|
if (val < rps->min_freq ||
|
|
|
|
val > rps->max_freq ||
|
|
|
|
val < rps->min_freq_softlimit) {
|
2019-04-26 15:17:21 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto unlock;
|
2012-09-13 08:12:07 +07:00
|
|
|
}
|
|
|
|
|
2017-10-11 04:30:06 +07:00
|
|
|
if (val > rps->rp0_freq)
|
2013-04-06 04:29:22 +07:00
|
|
|
DRM_DEBUG("User requested overclocking to %d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, val));
|
2013-04-06 04:29:22 +07:00
|
|
|
|
2017-10-11 04:30:06 +07:00
|
|
|
rps->max_freq_softlimit = val;
|
2013-11-06 22:56:26 +07:00
|
|
|
|
2017-10-11 04:30:06 +07:00
|
|
|
val = clamp_t(int, rps->cur_freq,
|
|
|
|
rps->min_freq_softlimit,
|
|
|
|
rps->max_freq_softlimit);
|
2015-01-24 02:04:23 +07:00
|
|
|
|
2019-10-25 04:16:41 +07:00
|
|
|
/*
|
|
|
|
* We still need *_set_rps to process the new max_delay and
|
2015-01-24 02:04:23 +07:00
|
|
|
* update the interrupt limits and PMINTRMSK even though
|
2019-10-25 04:16:41 +07:00
|
|
|
* frequency request may be unchanged.
|
|
|
|
*/
|
|
|
|
intel_rps_set(rps, val);
|
2012-09-13 08:12:07 +07:00
|
|
|
|
2019-04-26 15:17:21 +07:00
|
|
|
unlock:
|
|
|
|
mutex_unlock(&rps->lock);
|
2016-02-09 00:17:11 +07:00
|
|
|
|
2017-01-26 17:19:19 +07:00
|
|
|
return ret ?: count;
|
2012-09-13 08:12:07 +07:00
|
|
|
}
|
|
|
|
|
2012-09-08 09:43:40 +07:00
|
|
|
static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2012-09-08 09:43:40 +07:00
|
|
|
|
2016-07-13 15:10:36 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n",
|
2019-10-25 04:16:41 +07:00
|
|
|
intel_gpu_freq(rps, rps->min_freq_softlimit));
|
2012-09-08 09:43:40 +07:00
|
|
|
}
|
|
|
|
|
2012-09-13 08:12:07 +07:00
|
|
|
static ssize_t gt_min_freq_mhz_store(struct device *kdev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
2012-09-13 08:12:07 +07:00
|
|
|
ssize_t ret;
|
2019-10-25 04:16:41 +07:00
|
|
|
u32 val;
|
2012-09-13 08:12:07 +07:00
|
|
|
|
|
|
|
ret = kstrtou32(buf, 0, &val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-04-26 15:17:21 +07:00
|
|
|
mutex_lock(&rps->lock);
|
2012-09-13 08:12:07 +07:00
|
|
|
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_freq_opcode(rps, val);
|
2017-10-11 04:30:06 +07:00
|
|
|
if (val < rps->min_freq ||
|
|
|
|
val > rps->max_freq ||
|
|
|
|
val > rps->max_freq_softlimit) {
|
2019-04-26 15:17:21 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto unlock;
|
2012-09-13 08:12:07 +07:00
|
|
|
}
|
|
|
|
|
2017-10-11 04:30:06 +07:00
|
|
|
rps->min_freq_softlimit = val;
|
2013-11-06 22:56:26 +07:00
|
|
|
|
2017-10-11 04:30:06 +07:00
|
|
|
val = clamp_t(int, rps->cur_freq,
|
|
|
|
rps->min_freq_softlimit,
|
|
|
|
rps->max_freq_softlimit);
|
2015-01-24 02:04:23 +07:00
|
|
|
|
2019-10-25 04:16:41 +07:00
|
|
|
/*
|
|
|
|
* We still need *_set_rps to process the new min_delay and
|
2015-01-24 02:04:23 +07:00
|
|
|
* update the interrupt limits and PMINTRMSK even though
|
2019-10-25 04:16:41 +07:00
|
|
|
* frequency request may be unchanged.
|
|
|
|
*/
|
|
|
|
intel_rps_set(rps, val);
|
2012-09-13 08:12:07 +07:00
|
|
|
|
2019-04-26 15:17:21 +07:00
|
|
|
unlock:
|
|
|
|
mutex_unlock(&rps->lock);
|
2016-02-09 00:17:11 +07:00
|
|
|
|
2017-01-26 17:19:19 +07:00
|
|
|
return ret ?: count;
|
2012-09-13 08:12:07 +07:00
|
|
|
}
|
|
|
|
|
2017-12-20 01:15:08 +07:00
|
|
|
static DEVICE_ATTR_RO(gt_act_freq_mhz);
|
|
|
|
static DEVICE_ATTR_RO(gt_cur_freq_mhz);
|
2017-12-20 01:15:07 +07:00
|
|
|
static DEVICE_ATTR_RW(gt_boost_freq_mhz);
|
|
|
|
static DEVICE_ATTR_RW(gt_max_freq_mhz);
|
|
|
|
static DEVICE_ATTR_RW(gt_min_freq_mhz);
|
2012-09-08 09:43:40 +07:00
|
|
|
|
2017-12-20 01:15:08 +07:00
|
|
|
static DEVICE_ATTR_RO(vlv_rpe_freq_mhz);
|
2012-09-08 09:43:44 +07:00
|
|
|
|
|
|
|
static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf);
|
|
|
|
static DEVICE_ATTR(gt_RP0_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
|
|
|
|
static DEVICE_ATTR(gt_RP1_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
|
|
|
|
static DEVICE_ATTR(gt_RPn_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
|
|
|
|
|
|
|
|
/* For now we have a static number of RP states */
|
|
|
|
static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2019-10-25 04:16:41 +07:00
|
|
|
struct intel_rps *rps = &dev_priv->gt.rps;
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
u32 val;
|
2012-09-08 09:43:44 +07:00
|
|
|
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
if (attr == &dev_attr_gt_RP0_freq_mhz)
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_gpu_freq(rps, rps->rp0_freq);
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
else if (attr == &dev_attr_gt_RP1_freq_mhz)
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_gpu_freq(rps, rps->rp1_freq);
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
else if (attr == &dev_attr_gt_RPn_freq_mhz)
|
2019-10-25 04:16:41 +07:00
|
|
|
val = intel_gpu_freq(rps, rps->min_freq);
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
else
|
2012-09-08 09:43:44 +07:00
|
|
|
BUG();
|
drm/i915: Removed the read of RP_STATE_CAP from sysfs/debugfs functions
The frequency values(Rp0, Rp1, Rpn) reported by RP_STATE_CAP register
are stored, initially by the Driver, inside the dev_priv->rps structure.
Since these values are expected to remain same throughout, there is no real
need to read this register, on dynamic basis, from certain debugfs/sysfs
functions and the values can be instead retrieved from the dev_priv->rps
structure when needed.
For the i915_frequency_info debugfs interface, the frequency values from the
RP_STATE_CAP register only should be used, to indicate the actual Hw state,
since it is principally used for the debugging purpose.
v2: Reverted the changes in i915_frequency_info function, to continue report
back the frequency values, as per the actual Hw state (Chris)
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-26 17:39:47 +07:00
|
|
|
|
2013-02-14 15:42:11 +07:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", val);
|
2012-09-08 09:43:44 +07:00
|
|
|
}
|
|
|
|
|
2018-10-04 21:37:50 +07:00
|
|
|
static const struct attribute * const gen6_attrs[] = {
|
2015-01-24 02:04:24 +07:00
|
|
|
&dev_attr_gt_act_freq_mhz.attr,
|
2012-09-08 09:43:40 +07:00
|
|
|
&dev_attr_gt_cur_freq_mhz.attr,
|
2016-07-13 15:10:35 +07:00
|
|
|
&dev_attr_gt_boost_freq_mhz.attr,
|
2012-09-08 09:43:40 +07:00
|
|
|
&dev_attr_gt_max_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_min_freq_mhz.attr,
|
2012-09-08 09:43:44 +07:00
|
|
|
&dev_attr_gt_RP0_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_RP1_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_RPn_freq_mhz.attr,
|
2012-09-08 09:43:40 +07:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2018-10-04 21:37:50 +07:00
|
|
|
static const struct attribute * const vlv_attrs[] = {
|
2015-01-24 02:04:24 +07:00
|
|
|
&dev_attr_gt_act_freq_mhz.attr,
|
2013-08-26 22:18:54 +07:00
|
|
|
&dev_attr_gt_cur_freq_mhz.attr,
|
2016-07-13 15:10:35 +07:00
|
|
|
&dev_attr_gt_boost_freq_mhz.attr,
|
2013-08-26 22:18:54 +07:00
|
|
|
&dev_attr_gt_max_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_min_freq_mhz.attr,
|
2014-07-10 14:46:22 +07:00
|
|
|
&dev_attr_gt_RP0_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_RP1_freq_mhz.attr,
|
|
|
|
&dev_attr_gt_RPn_freq_mhz.attr,
|
2013-08-26 22:18:54 +07:00
|
|
|
&dev_attr_vlv_rpe_freq_mhz.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2016-10-12 16:05:18 +07:00
|
|
|
#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)
|
|
|
|
|
2013-06-06 21:38:54 +07:00
|
|
|
static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t off, size_t count)
|
|
|
|
{
|
|
|
|
|
2016-01-13 21:48:40 +07:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2018-11-23 20:23:25 +07:00
|
|
|
struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
|
2020-01-10 19:30:56 +07:00
|
|
|
struct i915_gpu_coredump *gpu;
|
2017-02-14 23:46:11 +07:00
|
|
|
ssize_t ret;
|
2013-06-06 21:38:54 +07:00
|
|
|
|
2018-11-23 20:23:25 +07:00
|
|
|
gpu = i915_first_error_state(i915);
|
2018-12-07 18:05:54 +07:00
|
|
|
if (IS_ERR(gpu)) {
|
|
|
|
ret = PTR_ERR(gpu);
|
|
|
|
} else if (gpu) {
|
2020-01-10 19:30:56 +07:00
|
|
|
ret = i915_gpu_coredump_copy_to_buffer(gpu, buf, off, count);
|
|
|
|
i915_gpu_coredump_put(gpu);
|
2018-11-23 20:23:25 +07:00
|
|
|
} else {
|
|
|
|
const char *str = "No error state collected\n";
|
|
|
|
size_t len = strlen(str);
|
2013-06-06 21:38:54 +07:00
|
|
|
|
2018-11-23 20:23:25 +07:00
|
|
|
ret = min_t(size_t, count, len - off);
|
|
|
|
memcpy(buf, str + off, ret);
|
|
|
|
}
|
2013-06-06 21:38:54 +07:00
|
|
|
|
2017-02-14 23:46:11 +07:00
|
|
|
return ret;
|
2013-06-06 21:38:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t error_state_write(struct file *file, struct kobject *kobj,
|
|
|
|
struct bin_attribute *attr, char *buf,
|
|
|
|
loff_t off, size_t count)
|
|
|
|
{
|
2016-01-13 21:48:40 +07:00
|
|
|
struct device *kdev = kobj_to_dev(kobj);
|
2016-08-22 17:32:43 +07:00
|
|
|
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
|
2013-06-06 21:38:54 +07:00
|
|
|
|
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 16:34:12 +07:00
|
|
|
drm_dbg(&dev_priv->drm, "Resetting error state\n");
|
2017-02-14 23:46:11 +07:00
|
|
|
i915_reset_error_state(dev_priv);
|
2013-06-06 21:38:54 +07:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2017-08-03 00:20:47 +07:00
|
|
|
static const struct bin_attribute error_state_attr = {
|
2013-06-06 21:38:54 +07:00
|
|
|
.attr.name = "error",
|
|
|
|
.attr.mode = S_IRUSR | S_IWUSR,
|
|
|
|
.size = 0,
|
|
|
|
.read = error_state_read,
|
|
|
|
.write = error_state_write,
|
|
|
|
};
|
|
|
|
|
2016-10-12 16:05:18 +07:00
|
|
|
static void i915_setup_error_capture(struct device *kdev)
|
|
|
|
{
|
|
|
|
if (sysfs_create_bin_file(&kdev->kobj, &error_state_attr))
|
|
|
|
DRM_ERROR("error_state sysfs setup failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void i915_teardown_error_capture(struct device *kdev)
|
|
|
|
{
|
|
|
|
sysfs_remove_bin_file(&kdev->kobj, &error_state_attr);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void i915_setup_error_capture(struct device *kdev) {}
|
|
|
|
static void i915_teardown_error_capture(struct device *kdev) {}
|
|
|
|
#endif
|
|
|
|
|
2016-08-22 17:32:43 +07:00
|
|
|
void i915_setup_sysfs(struct drm_i915_private *dev_priv)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct device *kdev = dev_priv->drm.primary->kdev;
|
2012-04-11 11:17:01 +07:00
|
|
|
int ret;
|
|
|
|
|
2012-09-02 14:24:40 +07:00
|
|
|
#ifdef CONFIG_PM
|
2016-08-22 17:32:43 +07:00
|
|
|
if (HAS_RC6(dev_priv)) {
|
|
|
|
ret = sysfs_merge_group(&kdev->kobj,
|
2012-05-31 19:57:43 +07:00
|
|
|
&rc6_attr_group);
|
|
|
|
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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"RC6 residency sysfs setup failed\n");
|
2012-05-31 19:57:43 +07:00
|
|
|
}
|
2016-08-22 17:32:43 +07:00
|
|
|
if (HAS_RC6p(dev_priv)) {
|
|
|
|
ret = sysfs_merge_group(&kdev->kobj,
|
2014-10-07 21:06:50 +07:00
|
|
|
&rc6p_attr_group);
|
|
|
|
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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"RC6p residency sysfs setup failed\n");
|
2014-10-07 21:06:50 +07:00
|
|
|
}
|
2016-08-22 17:32:43 +07:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
|
|
|
|
ret = sysfs_merge_group(&kdev->kobj,
|
2015-02-26 22:40:27 +07:00
|
|
|
&media_rc6_attr_group);
|
|
|
|
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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"Media RC6 residency sysfs setup failed\n");
|
2015-02-26 22:40:27 +07:00
|
|
|
}
|
2012-09-02 14:24:40 +07:00
|
|
|
#endif
|
2016-08-22 17:32:43 +07:00
|
|
|
if (HAS_L3_DPF(dev_priv)) {
|
|
|
|
ret = device_create_bin_file(kdev, &dpf_attrs);
|
2012-05-31 19:57:43 +07: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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"l3 parity sysfs setup failed\n");
|
2013-09-20 01:13:41 +07:00
|
|
|
|
2016-08-22 17:32:43 +07:00
|
|
|
if (NUM_L3_SLICES(dev_priv) > 1) {
|
|
|
|
ret = device_create_bin_file(kdev,
|
2013-09-20 01: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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm,
|
|
|
|
"l3 parity slice 1 setup failed\n");
|
2013-09-20 01:13:41 +07:00
|
|
|
}
|
2012-05-31 19:57:43 +07:00
|
|
|
}
|
2012-09-08 09:43:40 +07:00
|
|
|
|
2013-08-26 22:18:54 +07:00
|
|
|
ret = 0;
|
2016-08-22 17:32:43 +07:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
ret = sysfs_create_files(&kdev->kobj, vlv_attrs);
|
|
|
|
else if (INTEL_GEN(dev_priv) >= 6)
|
|
|
|
ret = sysfs_create_files(&kdev->kobj, gen6_attrs);
|
2013-08-26 22:18:54 +07: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 16:34:12 +07:00
|
|
|
drm_err(&dev_priv->drm, "RPS sysfs setup failed\n");
|
2013-06-06 21:38:54 +07:00
|
|
|
|
2016-10-12 16:05:18 +07:00
|
|
|
i915_setup_error_capture(kdev);
|
2020-02-28 20:17:10 +07:00
|
|
|
|
|
|
|
intel_engines_add_sysfs(dev_priv);
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|
|
|
|
|
2016-08-22 17:32:43 +07:00
|
|
|
void i915_teardown_sysfs(struct drm_i915_private *dev_priv)
|
2012-04-11 11:17:01 +07:00
|
|
|
{
|
2016-08-22 17:32:43 +07:00
|
|
|
struct device *kdev = dev_priv->drm.primary->kdev;
|
|
|
|
|
2016-10-12 16:05:18 +07:00
|
|
|
i915_teardown_error_capture(kdev);
|
|
|
|
|
2016-08-22 17:32:43 +07:00
|
|
|
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
sysfs_remove_files(&kdev->kobj, vlv_attrs);
|
2013-08-26 22:18:54 +07:00
|
|
|
else
|
2016-08-22 17:32:43 +07:00
|
|
|
sysfs_remove_files(&kdev->kobj, gen6_attrs);
|
|
|
|
device_remove_bin_file(kdev, &dpf_attrs_1);
|
|
|
|
device_remove_bin_file(kdev, &dpf_attrs);
|
2012-09-20 00:50:19 +07:00
|
|
|
#ifdef CONFIG_PM
|
2016-08-22 17:32:43 +07:00
|
|
|
sysfs_unmerge_group(&kdev->kobj, &rc6_attr_group);
|
|
|
|
sysfs_unmerge_group(&kdev->kobj, &rc6p_attr_group);
|
2012-09-20 00:50:19 +07:00
|
|
|
#endif
|
2012-04-11 11:17:01 +07:00
|
|
|
}
|