Skip to content

Commit 35ab4fd

Browse files
llandwerlin-intelickle
authored andcommitted
drm/i915/perf: reuse intel_lrc ctx regs macro
Abstract the context image access a bit. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1c71bc5 commit 35ab4fd

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
#include "i915_oa_cflgt3.h"
211211
#include "i915_oa_cnl.h"
212212
#include "i915_oa_icl.h"
213+
#include "intel_lrc_reg.h"
213214

214215
/* HW requires this to be a power of two, between 128k and 16M, though driver
215216
* is currently generally designed assuming the largest 16M size is used such
@@ -1636,27 +1637,25 @@ static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
16361637
u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset;
16371638
u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset;
16381639
/* The MMIO offsets for Flex EU registers aren't contiguous */
1639-
u32 flex_mmio[] = {
1640-
i915_mmio_reg_offset(EU_PERF_CNTL0),
1641-
i915_mmio_reg_offset(EU_PERF_CNTL1),
1642-
i915_mmio_reg_offset(EU_PERF_CNTL2),
1643-
i915_mmio_reg_offset(EU_PERF_CNTL3),
1644-
i915_mmio_reg_offset(EU_PERF_CNTL4),
1645-
i915_mmio_reg_offset(EU_PERF_CNTL5),
1646-
i915_mmio_reg_offset(EU_PERF_CNTL6),
1640+
i915_reg_t flex_regs[] = {
1641+
EU_PERF_CNTL0,
1642+
EU_PERF_CNTL1,
1643+
EU_PERF_CNTL2,
1644+
EU_PERF_CNTL3,
1645+
EU_PERF_CNTL4,
1646+
EU_PERF_CNTL5,
1647+
EU_PERF_CNTL6,
16471648
};
16481649
int i;
16491650

1650-
reg_state[ctx_oactxctrl] = i915_mmio_reg_offset(GEN8_OACTXCONTROL);
1651-
reg_state[ctx_oactxctrl+1] = (dev_priv->perf.oa.period_exponent <<
1652-
GEN8_OA_TIMER_PERIOD_SHIFT) |
1653-
(dev_priv->perf.oa.periodic ?
1654-
GEN8_OA_TIMER_ENABLE : 0) |
1655-
GEN8_OA_COUNTER_RESUME;
1651+
CTX_REG(reg_state, ctx_oactxctrl, GEN8_OACTXCONTROL,
1652+
(dev_priv->perf.oa.period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
1653+
(dev_priv->perf.oa.periodic ? GEN8_OA_TIMER_ENABLE : 0) |
1654+
GEN8_OA_COUNTER_RESUME);
16561655

1657-
for (i = 0; i < ARRAY_SIZE(flex_mmio); i++) {
1656+
for (i = 0; i < ARRAY_SIZE(flex_regs); i++) {
16581657
u32 state_offset = ctx_flexeu0 + i * 2;
1659-
u32 mmio = flex_mmio[i];
1658+
u32 mmio = i915_mmio_reg_offset(flex_regs[i]);
16601659

16611660
/*
16621661
* This arbitrary default will select the 'EU FPU0 Pipeline
@@ -1676,8 +1675,7 @@ static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
16761675
}
16771676
}
16781677

1679-
reg_state[state_offset] = mmio;
1680-
reg_state[state_offset+1] = value;
1678+
CTX_REG(reg_state, state_offset, flex_regs[i], value);
16811679
}
16821680
}
16831681

0 commit comments

Comments
 (0)