Skip to content

Commit

Permalink
Merge tag 'drm-intel-gt-next-2025-02-26' of https://gitlab.freedeskto…
Browse files Browse the repository at this point in the history
…p.org/drm/i915/kernel into drm-next

UAPI Changes:

- Add sysfs for SLPC power profiles [slpc] (Vinay Belgaumkar)

Driver Changes:

Fixes/improvements/new stuff:

- Fix zero delta busyness issue [pmu] (Umesh Nerlige Ramappa)
- Fix page cleanup on DMA remap failure (Brian Geffon)
- Debug print LRC state entries only if the context is pinned [guc] (Daniele Ceraolo Spurio)
- Drop custom hotplug code [pmu] (Lucas De Marchi)
- Use spin_lock_irqsave() in interruptible context [guc] (Krzysztof Karas)
- Add wait on depth stall done bit handling [gen12] (Juha-Pekka Heikkila)

Miscellaneous:

- Change throttle criteria for rps [selftest] (Raag Jadav)
- Add debug print about hw config table size (John Harrison)
- Include requested frequency in slow firmware load messages [uc] (John Harrison)
- Remove i915_pmu_event_event_idx() [pmu] (Lucas De Marchi)
- Remove unused live_context_for_engine (Dr. David Alan Gilbert)
- Add Wa_22010465259 in its respective WA list (Ranu Maurya)
- Correct frequency handling in RPS power measurement [selftests] (Sk Anirban)
- Add helper function slpc_measure_power [guc/slpc] (Sk Anirban)
- Revert "drm/i915/gt: Log reason for setting TAINT_WARN at reset" [gt] (Sebastian Brzezinka)
- Avoid using uninitialized context [selftests] (Krzysztof Karas)
- Use struct_size() helper in kmalloc() (luoqing)
- Use prandom in selftest [selftests] (Markus Theil)
- Replace kmap with its safer kmap_local_page counterpart [gt] (Andi Shyti)

Merges:

- Merge drm/drm-next into drm-intel-gt-next (Tvrtko Ursulin)

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Tvrtko Ursulin <tursulin@igalia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/Z77NLt2mR7SqxJ4u@linux
  • Loading branch information
Dave Airlie committed Mar 12, 2025
2 parents 4e64a62 + 7ded94b commit d115a38
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 212 deletions.
38 changes: 0 additions & 38 deletions drivers/gpu/drm/i915/gem/selftests/mock_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,44 +107,6 @@ live_context(struct drm_i915_private *i915, struct file *file)
return ERR_PTR(err);
}

struct i915_gem_context *
live_context_for_engine(struct intel_engine_cs *engine, struct file *file)
{
struct i915_gem_engines *engines;
struct i915_gem_context *ctx;
struct intel_sseu null_sseu = {};
struct intel_context *ce;

engines = alloc_engines(1);
if (!engines)
return ERR_PTR(-ENOMEM);

ctx = live_context(engine->i915, file);
if (IS_ERR(ctx)) {
__free_engines(engines, 0);
return ctx;
}

ce = intel_context_create(engine);
if (IS_ERR(ce)) {
__free_engines(engines, 0);
return ERR_CAST(ce);
}

intel_context_set_gem(ce, ctx, null_sseu);
engines->engines[0] = ce;
engines->num_engines = 1;

mutex_lock(&ctx->engines_mutex);
i915_gem_context_set_user_engines(ctx);
engines = rcu_replace_pointer(ctx->engines, engines, 1);
mutex_unlock(&ctx->engines_mutex);

engines_idle_release(ctx, engines);

return ctx;
}

struct i915_gem_context *
kernel_context(struct drm_i915_private *i915,
struct i915_address_space *vm)
Expand Down
3 changes: 0 additions & 3 deletions drivers/gpu/drm/i915/gem/selftests/mock_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ void mock_context_close(struct i915_gem_context *ctx);
struct i915_gem_context *
live_context(struct drm_i915_private *i915, struct file *file);

struct i915_gem_context *
live_context_for_engine(struct intel_engine_cs *engine, struct file *file);

struct i915_gem_context *kernel_context(struct drm_i915_private *i915,
struct i915_address_space *vm);
void kernel_context_close(struct i915_gem_context *ctx);
Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ static struct dma_buf *mock_dmabuf(int npages)
struct dma_buf *dmabuf;
int i;

mock = kmalloc(sizeof(*mock) + npages * sizeof(struct page *),
GFP_KERNEL);
mock = kmalloc(struct_size(mock, pages, npages), GFP_KERNEL);
if (!mock)
return ERR_PTR(-ENOMEM);

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,15 @@ static void swizzle_page(struct page *page)
char *vaddr;
int i;

vaddr = kmap(page);
vaddr = kmap_local_page(page);

for (i = 0; i < PAGE_SIZE; i += 128) {
memcpy(temp, &vaddr[i], 64);
memcpy(&vaddr[i], &vaddr[i + 64], 64);
memcpy(&vaddr[i + 64], temp, 64);
}

kunmap(page);
kunmap_local(vaddr);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_gt_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@
#define GEN7_SO_PRIM_STORAGE_NEEDED(n) _MMIO(0x5240 + (n) * 8)
#define GEN7_SO_PRIM_STORAGE_NEEDED_UDW(n) _MMIO(0x5240 + (n) * 8 + 4)

#define GEN8_WM_CHICKEN2 MCR_REG(0x5584)
#define WAIT_ON_DEPTH_STALL_DONE_DISABLE REG_BIT(5)

#define GEN9_WM_CHICKEN3 _MMIO(0x5588)
#define GEN9_FACTOR_IN_CLR_VAL_HIZ (1 << 9)

Expand Down
47 changes: 47 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,45 @@ static ssize_t slpc_ignore_eff_freq_store(struct kobject *kobj,
return err ?: count;
}

static ssize_t slpc_power_profile_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buff)
{
struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
struct intel_guc_slpc *slpc = &gt->uc.guc.slpc;

switch (slpc->power_profile) {
case SLPC_POWER_PROFILES_BASE:
return sysfs_emit(buff, "[%s] %s\n", "base", "power_saving");
case SLPC_POWER_PROFILES_POWER_SAVING:
return sysfs_emit(buff, "%s [%s]\n", "base", "power_saving");
}

return sysfs_emit(buff, "%u\n", slpc->power_profile);
}

static ssize_t slpc_power_profile_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buff, size_t count)
{
struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
struct intel_guc_slpc *slpc = &gt->uc.guc.slpc;
char power_saving[] = "power_saving";
char base[] = "base";
int err;
u32 val;

if (!strncmp(buff, power_saving, sizeof(power_saving) - 1))
val = SLPC_POWER_PROFILES_POWER_SAVING;
else if (!strncmp(buff, base, sizeof(base) - 1))
val = SLPC_POWER_PROFILES_BASE;
else
return -EINVAL;

err = intel_guc_slpc_set_power_profile(slpc, val);
return err ?: count;
}

struct intel_gt_bool_throttle_attr {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
Expand Down Expand Up @@ -668,6 +707,7 @@ INTEL_GT_ATTR_RO(media_RP0_freq_mhz);
INTEL_GT_ATTR_RO(media_RPn_freq_mhz);

INTEL_GT_ATTR_RW(slpc_ignore_eff_freq);
INTEL_GT_ATTR_RW(slpc_power_profile);

static const struct attribute *media_perf_power_attrs[] = {
&attr_media_freq_factor.attr,
Expand Down Expand Up @@ -864,6 +904,13 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
gt_warn(gt, "failed to create ignore_eff_freq sysfs (%pe)", ERR_PTR(ret));
}

if (intel_uc_uses_guc_slpc(&gt->uc)) {
ret = sysfs_create_file(kobj, &attr_slpc_power_profile.attr);
if (ret)
gt_warn(gt, "failed to create slpc_power_profile sysfs (%pe)",
ERR_PTR(ret));
}

if (i915_mmio_reg_valid(intel_gt_perf_limit_reasons_reg(gt))) {
ret = sysfs_create_files(kobj, throttle_reason_attrs);
if (ret)
Expand Down
6 changes: 1 addition & 5 deletions drivers/gpu/drm/i915/gt/intel_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,6 @@ static bool __intel_gt_unset_wedged(struct intel_gt *gt)
* Warn CI about the unrecoverable wedged condition.
* Time for a reboot.
*/
gt_err(gt, "Unrecoverable wedged condition\n");
add_taint_for_CI(gt->i915, TAINT_WARN);
return false;
}
Expand Down Expand Up @@ -1272,10 +1271,8 @@ void intel_gt_reset(struct intel_gt *gt,
}

ret = resume(gt);
if (ret) {
gt_err(gt, "Failed to resume (%d)\n", ret);
if (ret)
goto taint;
}

finish:
reset_finish(gt, awake);
Expand Down Expand Up @@ -1641,7 +1638,6 @@ void intel_gt_set_wedged_on_init(struct intel_gt *gt)
set_bit(I915_WEDGED_ON_INIT, &gt->reset.flags);

/* Wedged on init is non-recoverable */
gt_err(gt, "Non-recoverable wedged on init\n");
add_taint_for_CI(gt->i915, TAINT_WARN);
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_rps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,10 @@ void intel_rps_boost(struct i915_request *rq)
if (rps_uses_slpc(rps)) {
slpc = rps_to_slpc(rps);

/* Waitboost should not be done with power saving profile */
if (slpc->power_profile == SLPC_POWER_PROFILES_POWER_SAVING)
return;

if (slpc->min_freq_softlimit >= slpc->boost_freq)
return;

Expand Down
19 changes: 13 additions & 6 deletions drivers/gpu/drm/i915/gt/intel_workarounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,16 +691,17 @@ static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
struct drm_i915_private *i915 = engine->i915;

/*
* Wa_1409142259:tgl,dg1,adl-p
* Wa_1409142259:tgl,dg1,adl-p,adl-n
* Wa_1409347922:tgl,dg1,adl-p
* Wa_1409252684:tgl,dg1,adl-p
* Wa_1409217633:tgl,dg1,adl-p
* Wa_1409207793:tgl,dg1,adl-p
* Wa_1409178076:tgl,dg1,adl-p
* Wa_1408979724:tgl,dg1,adl-p
* Wa_14010443199:tgl,rkl,dg1,adl-p
* Wa_14010698770:tgl,rkl,dg1,adl-s,adl-p
* Wa_1409342910:tgl,rkl,dg1,adl-s,adl-p
* Wa_1409178076:tgl,dg1,adl-p,adl-n
* Wa_1408979724:tgl,dg1,adl-p,adl-n
* Wa_14010443199:tgl,rkl,dg1,adl-p,adl-n
* Wa_14010698770:tgl,rkl,dg1,adl-s,adl-p,adl-n
* Wa_1409342910:tgl,rkl,dg1,adl-s,adl-p,adl-n
* Wa_22010465259:tgl,rkl,dg1,adl-s,adl-p,adl-n
*/
wa_masked_en(wal, GEN11_COMMON_SLICE_CHICKEN3,
GEN12_DISABLE_CPS_AWARE_COLOR_PIPE);
Expand Down Expand Up @@ -741,6 +742,12 @@ static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
/* Wa_1606376872 */
wa_masked_en(wal, COMMON_SLICE_CHICKEN4, DISABLE_TDC_LOAD_BALANCING_CALC);
}

/*
* This bit must be set to enable performance optimization for fast
* clears.
*/
wa_mcr_write_or(wal, GEN8_WM_CHICKEN2, WAIT_ON_DEPTH_STALL_DONE_DISABLE);
}

static void dg1_ctx_workarounds_init(struct intel_engine_cs *engine,
Expand Down
13 changes: 7 additions & 6 deletions drivers/gpu/drm/i915/gt/selftest_rps.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,13 @@ int live_rps_control(void *arg)
limit, intel_gpu_freq(rps, limit),
min, max, ktime_to_ns(min_dt), ktime_to_ns(max_dt));

if (limit == rps->min_freq) {
pr_err("%s: GPU throttled to minimum!\n",
engine->name);
if (limit != rps->max_freq) {
u32 throttle = intel_uncore_read(gt->uncore,
intel_gt_perf_limit_reasons_reg(gt));

pr_warn("%s: GPU throttled with reasons 0x%08x\n",
engine->name, throttle & GT0_PERF_LIMIT_REASONS_MASK);
show_pstate_limits(rps);
err = -ENODEV;
break;
}

if (igt_flush_test(gt->i915)) {
Expand Down Expand Up @@ -1115,7 +1116,7 @@ static u64 measure_power(struct intel_rps *rps, int *freq)
for (i = 0; i < 5; i++)
x[i] = __measure_power(5);

*freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2;
*freq = (*freq + read_cagf(rps)) / 2;

/* A simple triangle filter for better result stability */
sort(x, 5, sizeof(*x), cmp_u64, NULL);
Expand Down
17 changes: 16 additions & 1 deletion drivers/gpu/drm/i915/gt/selftest_slpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ static int slpc_restore_freq(struct intel_guc_slpc *slpc, u32 min, u32 max)
return 0;
}

static u64 slpc_measure_power(struct intel_rps *rps, int *freq)
{
u64 x[5];
int i;

for (i = 0; i < 5; i++)
x[i] = __measure_power(5);

*freq = (*freq + intel_rps_read_actual_frequency(rps)) / 2;

/* A simple triangle filter for better result stability */
sort(x, 5, sizeof(*x), cmp_u64, NULL);
return div_u64(x[1] + 2 * x[2] + x[3], 4);
}

static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power)
{
int err = 0;
Expand All @@ -103,7 +118,7 @@ static u64 measure_power_at_freq(struct intel_gt *gt, int *freq, u64 *power)
if (err)
return err;
*freq = intel_rps_read_actual_frequency(&gt->rps);
*power = measure_power(&gt->rps, freq);
*power = slpc_measure_power(&gt->rps, freq);

return err;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/i915/gt/shmem_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ static int __shmem_rw(struct file *file, loff_t off,
if (IS_ERR(page))
return PTR_ERR(page);

vaddr = kmap(page);
vaddr = kmap_local_page(page);
if (write) {
memcpy(vaddr + offset_in_page(off), ptr, this);
set_page_dirty(page);
} else {
memcpy(ptr, vaddr + offset_in_page(off), this);
}
mark_page_accessed(page);
kunmap(page);
kunmap_local(vaddr);
put_page(page);

len -= this;
Expand All @@ -143,11 +143,11 @@ int shmem_read_to_iosys_map(struct file *file, loff_t off,
if (IS_ERR(page))
return PTR_ERR(page);

vaddr = kmap(page);
vaddr = kmap_local_page(page);
iosys_map_memcpy_to(map, map_off, vaddr + offset_in_page(off),
this);
mark_page_accessed(page);
kunmap(page);
kunmap_local(vaddr);
put_page(page);

len -= this;
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/gt/uc/abi/guc_actions_slpc_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ struct slpc_optimized_strategies {

#define SLPC_OPTIMIZED_STRATEGY_COMPUTE REG_BIT(0)

enum slpc_power_profiles {
SLPC_POWER_PROFILES_BASE = 0x0,
SLPC_POWER_PROFILES_POWER_SAVING = 0x1
};

/**
* DOC: SLPC H2G MESSAGE FORMAT
*
Expand Down
11 changes: 6 additions & 5 deletions drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,14 @@ static int guc_wait_ucode(struct intel_guc *guc)
} else if (delta_ms > 200) {
guc_warn(guc, "excessive init time: %lldms! [status = 0x%08X, count = %d, ret = %d]\n",
delta_ms, status, count, ret);
guc_warn(guc, "excessive init time: [freq = %dMHz, before = %dMHz, perf_limit_reasons = 0x%08X]\n",
intel_rps_read_actual_frequency(&gt->rps), before_freq,
guc_warn(guc, "excessive init time: [freq = %dMHz -> %dMHz vs %dMHz, perf_limit_reasons = 0x%08X]\n",
before_freq, intel_rps_read_actual_frequency(&gt->rps),
intel_rps_get_requested_frequency(&gt->rps),
intel_uncore_read(uncore, intel_gt_perf_limit_reasons_reg(gt)));
} else {
guc_dbg(guc, "init took %lldms, freq = %dMHz, before = %dMHz, status = 0x%08X, count = %d, ret = %d\n",
delta_ms, intel_rps_read_actual_frequency(&gt->rps),
before_freq, status, count, ret);
guc_dbg(guc, "init took %lldms, freq = %dMHz -> %dMHz vs %dMHz, status = 0x%08X, count = %d, ret = %d\n",
delta_ms, before_freq, intel_rps_read_actual_frequency(&gt->rps),
intel_rps_get_requested_frequency(&gt->rps), status, count, ret);
}

return ret;
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/gt/uc/intel_guc_hwconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "gt/intel_hwconfig.h"
#include "i915_drv.h"
#include "i915_memcpy.h"
#include "intel_guc_print.h"

/*
* GuC has a blob containing hardware configuration information (HWConfig).
Expand Down Expand Up @@ -42,6 +43,8 @@ static int __guc_action_get_hwconfig(struct intel_guc *guc,
};
int ret;

guc_dbg(guc, "Querying HW config table: size = %d, offset = 0x%08X\n",
ggtt_size, ggtt_offset);
ret = intel_guc_send_mmio(guc, action, ARRAY_SIZE(action), NULL, 0);
if (ret == -ENXIO)
return -ENOENT;
Expand Down
Loading

0 comments on commit d115a38

Please sign in to comment.