diff mbox series

[2/6] drm/i915/gt: Lock intel_engine_apply_whitelist with uncore->lock

Message ID 20201002232801.51936-3-umesh.nerlige.ramappa@intel.com (mailing list archive)
State New, archived
Headers show
Series Allow privileged user to map the OA buffer | expand

Commit Message

Umesh Nerlige Ramappa Oct. 2, 2020, 11:27 p.m. UTC
Refactor intel_engine_apply_whitelist into locked and unlocked versions
so that a caller who already has the lock can apply whitelist.

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 44 +++++++++++++++------
 1 file changed, 31 insertions(+), 13 deletions(-)

Comments

kernel test robot Oct. 3, 2020, 2:52 a.m. UTC | #1
Hi Umesh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master v5.9-rc7 next-20201002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Umesh-Nerlige-Ramappa/Allow-privileged-user-to-map-the-OA-buffer/20201003-073003
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/d8a4c73d3c843dd6cb5bb248a90e5b4e0b28953c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Umesh-Nerlige-Ramappa/Allow-privileged-user-to-map-the-OA-buffer/20201003-073003
        git checkout d8a4c73d3c843dd6cb5bb248a90e5b4e0b28953c
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gt/intel_workarounds.c:1648:6: warning: no previous prototype for 'intel_engine_apply_whitelist_locked' [-Wmissing-prototypes]
    1648 | void intel_engine_apply_whitelist_locked(struct intel_engine_cs *engine)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/intel_engine_apply_whitelist_locked +1648 drivers/gpu/drm/i915/gt/intel_workarounds.c

  1647	
> 1648	void intel_engine_apply_whitelist_locked(struct intel_engine_cs *engine)
  1649	{
  1650		const struct i915_wa_list *wal = &engine->whitelist;
  1651		struct intel_uncore *uncore = engine->uncore;
  1652		const u32 base = engine->mmio_base;
  1653		struct i915_wa *wa;
  1654		unsigned int i;
  1655		enum forcewake_domains fw;
  1656	
  1657		lockdep_assert_held(&uncore->lock);
  1658	
  1659		fw = wal_get_fw(uncore, wal, FW_REG_WRITE);
  1660		intel_uncore_forcewake_get__locked(uncore, fw);
  1661	
  1662		for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
  1663			intel_uncore_write_fw(uncore,
  1664					      RING_FORCE_TO_NONPRIV(base, i),
  1665					      i915_mmio_reg_offset(wa->reg));
  1666	
  1667		/* And clear the rest just in case of garbage */
  1668		for (; i < RING_MAX_NONPRIV_SLOTS; i++)
  1669			intel_uncore_write_fw(uncore,
  1670					      RING_FORCE_TO_NONPRIV(base, i),
  1671					      i915_mmio_reg_offset(RING_NOPID(base)));
  1672	
  1673		intel_uncore_forcewake_put__locked(uncore, fw);
  1674	}
  1675	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 6c580d0d9ea8..b7db34dc9687 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -1295,7 +1295,8 @@  void intel_gt_init_workarounds(struct drm_i915_private *i915)
 }
 
 static enum forcewake_domains
-wal_get_fw_for_rmw(struct intel_uncore *uncore, const struct i915_wa_list *wal)
+wal_get_fw(struct intel_uncore *uncore, const struct i915_wa_list *wal,
+	   unsigned int op)
 {
 	enum forcewake_domains fw = 0;
 	struct i915_wa *wa;
@@ -1304,8 +1305,7 @@  wal_get_fw_for_rmw(struct intel_uncore *uncore, const struct i915_wa_list *wal)
 	for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
 		fw |= intel_uncore_forcewake_for_reg(uncore,
 						     wa->reg,
-						     FW_REG_READ |
-						     FW_REG_WRITE);
+						     op);
 
 	return fw;
 }
@@ -1335,7 +1335,7 @@  wa_list_apply(struct intel_uncore *uncore, const struct i915_wa_list *wal)
 	if (!wal->count)
 		return;
 
-	fw = wal_get_fw_for_rmw(uncore, wal);
+	fw = wal_get_fw(uncore, wal, FW_REG_READ | FW_REG_WRITE);
 
 	spin_lock_irqsave(&uncore->lock, flags);
 	intel_uncore_forcewake_get__locked(uncore, fw);
@@ -1645,27 +1645,45 @@  void intel_engine_init_whitelist(struct intel_engine_cs *engine)
 	wa_init_finish(w);
 }
 
-void intel_engine_apply_whitelist(struct intel_engine_cs *engine)
+void intel_engine_apply_whitelist_locked(struct intel_engine_cs *engine)
 {
 	const struct i915_wa_list *wal = &engine->whitelist;
 	struct intel_uncore *uncore = engine->uncore;
 	const u32 base = engine->mmio_base;
 	struct i915_wa *wa;
 	unsigned int i;
+	enum forcewake_domains fw;
 
-	if (!wal->count)
-		return;
+	lockdep_assert_held(&uncore->lock);
+
+	fw = wal_get_fw(uncore, wal, FW_REG_WRITE);
+	intel_uncore_forcewake_get__locked(uncore, fw);
 
 	for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
-		intel_uncore_write(uncore,
-				   RING_FORCE_TO_NONPRIV(base, i),
-				   i915_mmio_reg_offset(wa->reg));
+		intel_uncore_write_fw(uncore,
+				      RING_FORCE_TO_NONPRIV(base, i),
+				      i915_mmio_reg_offset(wa->reg));
 
 	/* And clear the rest just in case of garbage */
 	for (; i < RING_MAX_NONPRIV_SLOTS; i++)
-		intel_uncore_write(uncore,
-				   RING_FORCE_TO_NONPRIV(base, i),
-				   i915_mmio_reg_offset(RING_NOPID(base)));
+		intel_uncore_write_fw(uncore,
+				      RING_FORCE_TO_NONPRIV(base, i),
+				      i915_mmio_reg_offset(RING_NOPID(base)));
+
+	intel_uncore_forcewake_put__locked(uncore, fw);
+}
+
+void intel_engine_apply_whitelist(struct intel_engine_cs *engine)
+{
+	unsigned long flags;
+	const struct i915_wa_list *wal = &engine->whitelist;
+
+	if (!wal->count)
+		return;
+
+	spin_lock_irqsave(&engine->uncore->lock, flags);
+	intel_engine_apply_whitelist_locked(engine);
+	spin_unlock_irqrestore(&engine->uncore->lock, flags);
 }
 
 static void