Skip to contentSkip to conversation

drm/i915: nuke pch type :o

RFC In review Jani Nikula 3 participants 8 messages Feb 2, 2018 – Feb 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm/i915: nuke pch type :o

I was wondering how to clean up intel_virt_detect_pch(), also in a more future compatible manner, and came up with this idea.

Is the text size increase in patch 3/3 too bad, that is the question.

BR,
Jani.

Jani Nikula (3):
drm/i915: introduce INTEL_PCH_ID() and use it drm/i915/debugfs: print PCH id instead of PCH type in i915
capabilities
drm/i915: obliterate PCH types in favour of direct PCH id use

 drivers/gpu/drm/i915/i915_debugfs.c |  2 +-
 drivers/gpu/drm/i915/i915_drv.c     | 46 +++++++----------------
 drivers/gpu/drm/i915/i915_drv.h     | 73 +++++++++++++++++++++----------------
 3 files changed, 57 insertions(+), 64 deletions(-)
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC 1/3 drm/i915: introduce INTEL_PCH_ID() and use it

Prepare for more widespread use of PCH id. No functional changes.

---
 drivers/gpu/drm/i915/i915_drv.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +6 -5
index 4e158aab36d6..a1454045629a 100644
@@ -2861,19 +2861,20 @@ intel_info(const struct drm_i915_private *dev_priv)
 #define INTEL_PCH_QEMU_DEVICE_ID_TYPE		0x2900 /* qemu q35 has 2918 */
 
 #define INTEL_PCH_TYPE(dev_priv) ((dev_priv)->pch_type)
+#define INTEL_PCH_ID(dev_priv) ((dev_priv)->pch_id)
 #define HAS_PCH_ICP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_ICP)
 #define HAS_PCH_CNP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_CNP)
 #define HAS_PCH_CNP_LP(dev_priv) \
-	((dev_priv)->pch_id == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE)
+	(INTEL_PCH_ID(dev_priv) == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE)
 #define HAS_PCH_KBP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_KBP)
 #define HAS_PCH_SPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_SPT)
 #define HAS_PCH_LPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_LPT)
 #define HAS_PCH_LPT_LP(dev_priv) \
-	((dev_priv)->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE || \
-	 (dev_priv)->pch_id == INTEL_PCH_WPT_LP_DEVICE_ID_TYPE)
+	(INTEL_PCH_ID(dev_priv) == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE || \
+	 INTEL_PCH_ID(dev_priv) == INTEL_PCH_WPT_LP_DEVICE_ID_TYPE)
 #define HAS_PCH_LPT_H(dev_priv) \
-	((dev_priv)->pch_id == INTEL_PCH_LPT_DEVICE_ID_TYPE || \
-	 (dev_priv)->pch_id == INTEL_PCH_WPT_DEVICE_ID_TYPE)
+	(INTEL_PCH_ID(dev_priv) == INTEL_PCH_LPT_DEVICE_ID_TYPE || \
+	 INTEL_PCH_ID(dev_priv) == INTEL_PCH_WPT_DEVICE_ID_TYPE)
 #define HAS_PCH_CPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_CPT)
 #define HAS_PCH_IBX(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_IBX)
 #define HAS_PCH_NOP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_NOP)
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

RFC 2/3 drm/i915/debugfs: print PCH id instead of PCH type in i915 capabilities

In reply to Jani Nikula

Preparation for future patches. Split this out to highlight the debugfs change.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 3849ded354e3..1bc7d9db0ddf 100644
@@ -45,7 +45,7 @@ static int i915_capabilities(struct seq_file *m, void *data)
 
 	seq_printf(m, "gen: %d\n", INTEL_GEN(dev_priv));
 	seq_printf(m, "platform: %s\n", intel_platform_name(info->platform));
-	seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev_priv));
+	seq_printf(m, "pch: %04x\n", INTEL_PCH_ID(dev_priv));
 
 	intel_device_info_dump_flags(info, &p);
 	intel_device_info_dump_runtime(info, &p);
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

RFC 3/3 drm/i915: obliterate PCH types in favour of direct PCH id use

In reply to Jani Nikula

The PCH type is an unnecessary level of abstraction that's an extra maintenance burden. Switch to using PCH ids directly. This also simplifies the virtual PCH detection.

The downside is code size increase for conditions that match several PCH ids:

text data bss dec hex filename

-1709581	  68900	   4612	1783093	 1b3535	drivers/gpu/drm/i915/i915.ko
+1710634	  68900	   4612	1784146	 1b3952	drivers/gpu/drm/i915/i915.ko
---
 drivers/gpu/drm/i915/i915_drv.c | 46 +++++++++-------------------
 drivers/gpu/drm/i915/i915_drv.h | 68 +++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 61 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +14 -32
index e9f1daf258fe..a027d753fb6a 100644
@@ -123,9 +123,9 @@ static bool i915_error_injected(struct drm_i915_private *dev_priv)
 		      fmt, ##__VA_ARGS__)
 
 
-static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
+static unsigned int intel_virt_detect_pch(struct drm_i915_private *dev_priv)
 {
-	enum intel_pch ret = PCH_NOP;
+	unsigned int id = INTEL_PCH_NOP;
 
 	/*
 	 * In a virtualized passthrough environment we can be in a
@@ -135,27 +135,26 @@ static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
 	 */
 
 	if (IS_GEN5(dev_priv)) {
-		ret = PCH_IBX;
+		id = INTEL_PCH_IBX_DEVICE_ID_TYPE;
 		DRM_DEBUG_KMS("Assuming Ibex Peak PCH\n");
 	} else if (IS_GEN6(dev_priv) || IS_IVYBRIDGE(dev_priv)) {
-		ret = PCH_CPT;
+		id = INTEL_PCH_CPT_DEVICE_ID_TYPE;
 		DRM_DEBUG_KMS("Assuming CougarPoint PCH\n");
+	} else if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)) {
+		id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE;
+		DRM_DEBUG_KMS("Assuming LynxPoint LP PCH\n");
 	} else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
-		ret = PCH_LPT;
-		if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv))
-			dev_priv->pch_id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE;
-		else
-			dev_priv->pch_id = INTEL_PCH_LPT_DEVICE_ID_TYPE;
+		id = INTEL_PCH_LPT_DEVICE_ID_TYPE;
 		DRM_DEBUG_KMS("Assuming LynxPoint PCH\n");
 	} else if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
-		ret = PCH_SPT;
+		id = INTEL_PCH_SPT_DEVICE_ID_TYPE;
 		DRM_DEBUG_KMS("Assuming SunrisePoint PCH\n");
 	} else if (IS_COFFEELAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) {
-		ret = PCH_CNP;
+		id = INTEL_PCH_CNP_DEVICE_ID_TYPE;
 		DRM_DEBUG_KMS("Assuming CannonPoint PCH\n");
 	}
 
-	return ret;
+	return id;
 }
 
 static void intel_detect_pch(struct drm_i915_private *dev_priv)
@@ -166,7 +165,7 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
 	 * (which really amounts to a PCH but no South Display).
 	 */
 	if (INTEL_INFO(dev_priv)->num_pipes == 0) {
-		dev_priv->pch_type = PCH_NOP;
+		dev_priv->pch_id = INTEL_PCH_NOP;
 		return;
 	}
 
@@ -189,81 +188,63 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
 
 		id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
 
-		dev_priv->pch_id = id;
-
 		if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_IBX;
 			DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
 			WARN_ON(!IS_GEN5(dev_priv));
 		} else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_CPT;
 			DRM_DEBUG_KMS("Found CougarPoint PCH\n");
 			WARN_ON(!IS_GEN6(dev_priv) &&
 				!IS_IVYBRIDGE(dev_priv));
 		} else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
-			/* PantherPoint is CPT compatible */
-			dev_priv->pch_type = PCH_CPT;
 			DRM_DEBUG_KMS("Found PantherPoint PCH\n");
 			WARN_ON(!IS_GEN6(dev_priv) &&
 				!IS_IVYBRIDGE(dev_priv));
 		} else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_LPT;
 			DRM_DEBUG_KMS("Found LynxPoint PCH\n");
 			WARN_ON(!IS_HASWELL(dev_priv) &&
 				!IS_BROADWELL(dev_priv));
 			WARN_ON(IS_HSW_ULT(dev_priv) ||
 				IS_BDW_ULT(dev_priv));
 		} else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_LPT;
 			DRM_DEBUG_KMS("Found LynxPoint LP PCH\n");
 			WARN_ON(!IS_HASWELL(dev_priv) &&
 				!IS_BROADWELL(dev_priv));
 			WARN_ON(!IS_HSW_ULT(dev_priv) &&
 				!IS_BDW_ULT(dev_priv));
 		} else if (id == INTEL_PCH_WPT_DEVICE_ID_TYPE) {
-			/* WildcatPoint is LPT compatible */
-			dev_priv->pch_type = PCH_LPT;
 			DRM_DEBUG_KMS("Found WildcatPoint PCH\n");
 			WARN_ON(!IS_HASWELL(dev_priv) &&
 				!IS_BROADWELL(dev_priv));
 			WARN_ON(IS_HSW_ULT(dev_priv) ||
 				IS_BDW_ULT(dev_priv));
 		} else if (id == INTEL_PCH_WPT_LP_DEVICE_ID_TYPE) {
-			/* WildcatPoint is LPT compatible */
-			dev_priv->pch_type = PCH_LPT;
 			DRM_DEBUG_KMS("Found WildcatPoint LP PCH\n");
 			WARN_ON(!IS_HASWELL(dev_priv) &&
 				!IS_BROADWELL(dev_priv));
 			WARN_ON(!IS_HSW_ULT(dev_priv) &&
 				!IS_BDW_ULT(dev_priv));
 		} else if (id == INTEL_PCH_SPT_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_SPT;
 			DRM_DEBUG_KMS("Found SunrisePoint PCH\n");
 			WARN_ON(!IS_SKYLAKE(dev_priv) &&
 				!IS_KABYLAKE(dev_priv));
 		} else if (id == INTEL_PCH_SPT_LP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_SPT;
 			DRM_DEBUG_KMS("Found SunrisePoint LP PCH\n");
 			WARN_ON(!IS_SKYLAKE(dev_priv) &&
 				!IS_KABYLAKE(dev_priv));
 		} else if (id == INTEL_PCH_KBP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_KBP;
 			DRM_DEBUG_KMS("Found Kaby Lake PCH (KBP)\n");
 			WARN_ON(!IS_SKYLAKE(dev_priv) &&
 				!IS_KABYLAKE(dev_priv) &&
 				!IS_COFFEELAKE(dev_priv));
 		} else if (id == INTEL_PCH_CNP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_CNP;
 			DRM_DEBUG_KMS("Found Cannon Lake PCH (CNP)\n");
 			WARN_ON(!IS_CANNONLAKE(dev_priv) &&
 				!IS_COFFEELAKE(dev_priv));
 		} else if (id == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_CNP;
 			DRM_DEBUG_KMS("Found Cannon Lake LP PCH (CNP-LP)\n");
 			WARN_ON(!IS_CANNONLAKE(dev_priv) &&
 				!IS_COFFEELAKE(dev_priv));
 		} else if (id == INTEL_PCH_ICP_DEVICE_ID_TYPE) {
-			dev_priv->pch_type = PCH_ICP;
 			DRM_DEBUG_KMS("Found Ice Lake PCH\n");
 			WARN_ON(!IS_ICELAKE(dev_priv));
 		} else if (id == INTEL_PCH_P2X_DEVICE_ID_TYPE ||
@@ -273,11 +254,12 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
 			    PCI_SUBVENDOR_ID_REDHAT_QUMRANET &&
 			    pch->subsystem_device ==
 			    PCI_SUBDEVICE_ID_QEMU)) {
-			dev_priv->pch_type = intel_virt_detect_pch(dev_priv);
+			id = intel_virt_detect_pch(dev_priv);
 		} else {
 			continue;
 		}
 
+		dev_priv->pch_id = id;
 		break;
 	}
 	if (!pch)
drivers/gpu/drm/i915/i915_drv.h +39 -29

96 lines not on this page · raw message

Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

Re: [RFC 3/3] drm/i915: obliterate PCH types in favour of direct PCH id use

Quoting Jani Nikula (2018-02-02 20:01:00)

Quoted 3 lines

The PCH type is an unnecessary level of abstraction that's an extra maintenance burden. Switch to using PCH ids directly. This also simplifies the virtual PCH detection.

But you are still using the PCH type, just computing it from the id inside the conditionals. Not sure if that's a good idea, remember the long chains of devid == X || devid == Y || ... we used to have?

I guess a convincing argument that the abstraction is ill-conceived would be when it bloats the code, as that shows the abstraction's semantics do not match and are a hindrance to use. Maybe there's another transformation that improves usage?
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: [RFC 3/3] drm/i915: obliterate PCH types in favour of direct PCH id use

Quoted 8 lines · Chris Wilson

Quoting Jani Nikula (2018-02-02 20:01:00)

Quoted 3 lines

The PCH type is an unnecessary level of abstraction that's an extra maintenance burden. Switch to using PCH ids directly. This also simplifies the virtual PCH detection.

But you are still using the PCH type, just computing it from the id inside the conditionals. Not sure if that's a good idea, remember the long chains of devid == X || devid == Y || ... we used to have?

I've forgotten, maybe I didn't learn from history... but you're right I'm still using the "pch type". But the current code is using the devids in addition to the types too.

Quoted 4 lines

I guess a convincing argument that the abstraction is ill-conceived would be when it bloats the code, as that shows the abstraction's semantics do not match and are a hindrance to use. Maybe there's another transformation that improves usage?

To be honest, I wasn't happy with the end result either, but decided to post the patches as RFC as I had them written, to provoke discussion.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

✓ Fi.CI.BAT: success for drm/i915: nuke pch type :o

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/i915: nuke pch type :o
URL : https://patchwork.freedesktop.org/series/37581/
State : success

== Summary ==

Series 37581v1 drm/i915: nuke pch type :o
https://patchwork.freedesktop.org/api/1.0/series/37581/revisions/1/mbox/

Test debugfs_test:

        Subgroup read_all_entries:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713
Test gem_exec_suspend:
        Subgroup basic-s4-devices:
                pass       -> INCOMPLETE (fi-bdw-5557u) fdo#104162
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                fail       -> PASS       (fi-skl-guc) fdo#103191

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#104162 https://bugs.freedesktop.org/show_bug.cgi?id=104162
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191

fi-bdw-5557u     total:109  pass:105  dwarn:0   dfail:0   fail:0   skip:3  
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:370s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:487s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:281s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:483s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:479s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:464s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:458s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:570s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:413s
fi-gdg-551       total:288  pass:180  dwarn:0   dfail:0   fail:0   skip:108 time:280s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:508s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:393s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:397s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:412s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:458s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:413s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:459s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:496s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:452s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:499s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:587s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:427s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:507s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:526s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:484s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:487s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:414s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:428s
fi-snb-2520m     total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:391s

Blacklisted hosts:
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:467s

c051d09ed8f4b307b8d00076380e657759bd8eb5 drm-tip: 2018y-02m-02d-19h-34m-35s UTC integration manifest c9640917d438 drm/i915: obliterate PCH types in favour of direct PCH id use a42e9060d5a8 drm/i915/debugfs: print PCH id instead of PCH type in i915 capabilities 9d855e64b20d drm/i915: introduce INTEL_PCH_ID() and use it

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7869/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

✓ Fi.CI.IGT: success for drm/i915: nuke pch type :o

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/i915: nuke pch type :o
URL : https://patchwork.freedesktop.org/series/37581/
State : success

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7869/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx