Skip to contentSkip to conversation

intel: rework how we add PCI IDs

PATCH In review Lucas De Marchi 3 participants 8 messages Sep 5, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover intel: rework how we add PCI IDs

Adding PCI IDs to different projects is a boring manual task that motivated me to create this series. The idea is to centralize the IDs in the kernel header and let other projects copy it.

Initially my plan was to convert all gens, back to gen2, but that proved slightly difficult since there are some corner cases to cover and I didn't want to block the important part, i.e.: for recent gens, there's no risk of missing a PCI ID.

v2: address comments from Chris by pulling it out to a separate .c
v3: remove/add comments on first patch and rebase the rest

Discussed on v2 but left for later:
- replace intel_is_genx() with a simple check for bufmgr->gen, after making sure said variable is initialized on all code paths.
- treat unknown gen as a future gen
- convert gen < 9 to use the new header

Lucas De Marchi (5):
intel: add generic functions to check PCI ID
intel: make gen11 use generic gen macro
intel: make gen10 use generic gen macro
intel: make gen9 use generic gen macro
intel: get gen once for gen >= 9

 intel/Makefile.sources   |   1 +
 intel/i915_pciids.h      | 461 +++++++++++++++++++++++++++++++++++++++
 intel/intel_bufmgr_gem.c |   8 +-
 intel/intel_chipset.c    |  85 ++++++++
 intel/intel_chipset.h    | 253 +--------------------
 intel/intel_decode.c     |   8 +-
 intel/meson.build        |   2 +-
 7 files changed, 561 insertions(+), 257 deletions(-)
 create mode 100644 intel/i915_pciids.h
 create mode 100644 intel/intel_chipset.c
Signature · 6 lines
2.17.1

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

PATCH v3 1/5 intel: add generic functions to check PCI ID

This will allow platforms to reuse kernel IDs instead of manually keeping them in sync. In most of the cases we only need to extend IS_9XX(). Current platforms that fit this requirement can be ported over to use this macro. Right now it's a nop since it doesn't have any PCI ID added.

The i915_pciids.h header is in sync with kernel tree on drm-tip 2018y-08m-20d-21h-41m-11s.

v2: - move to a separate .c so we can have the array in a single
compilation unit
- use a single array for all gens
- add real functions to get or check gen by pciid
- define our own pci device struct rather than inherit the one kernel uses: we can throw away most of the fields

v3: - add comment to keep ids sorted by gen
- remove misleading comment about all gens

---
 intel/Makefile.sources |   1 +
 intel/i915_pciids.h    | 461 +++++++++++++++++++++++++++++++++++++++++
 intel/intel_chipset.c  |  78 +++++++
 intel/intel_chipset.h  |   9 +-
 intel/meson.build      |   2 +-
 5 files changed, 549 insertions(+), 2 deletions(-)
 create mode 100644 intel/i915_pciids.h
 create mode 100644 intel/intel_chipset.c
intel/Makefile.sources +1 -0
index 6947ab74..61f43aeb 100644
@@ -5,6 +5,7 @@ LIBDRM_INTEL_FILES := \
 	intel_bufmgr_gem.c \
 	intel_decode.c \
 	intel_chipset.h \
+	intel_chipset.c \
 	mm.c \
 	mm.h \
 	uthash.h
intel/i915_pciids.h new file +461 -0

461 lines not on this page · raw message

intel/intel_chipset.c new file +78 -0

78 lines not on this page · raw message

intel/intel_chipset.h +8 -1
index 4a34b7be..e4783d4e 100644
@@ -568,6 +568,12 @@
 
 #define IS_GEN11(devid)		(IS_ICELAKE_11(devid))
 
+/* New platforms use kernel pci ids */
+#include <stdbool.h>
+
+bool intel_is_genx(unsigned int devid, int gen);
+bool intel_get_genx(unsigned int devid, int *gen);
+
 #define IS_9XX(dev)		(IS_GEN3(dev) || \
 				 IS_GEN4(dev) || \
 				 IS_GEN5(dev) || \
@@ -576,6 +582,7 @@
 				 IS_GEN8(dev) || \
 				 IS_GEN9(dev) || \
 				 IS_GEN10(dev) || \
-				 IS_GEN11(dev))
+				 IS_GEN11(dev) || \
+				 intel_get_genx(dev, NULL))
 
 #endif /* _INTEL_CHIPSET_H */
intel/meson.build +1 -1
index 53c7fce4..ff40ab91 100644
@@ -23,7 +23,7 @@ libdrm_intel = shared_library(
   [
     files(
       'intel_bufmgr.c', 'intel_bufmgr_fake.c', 'intel_bufmgr_gem.c',
-      'intel_decode.c', 'mm.c',
+      'intel_decode.c', 'mm.c', 'intel_chipset.c',
     ),
     config_file,
   ],
Signature · 6 lines
2.17.1

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

PATCH v3 2/5 intel: make gen11 use generic gen macro

In reply to Lucas De Marchi
---
 intel/intel_chipset.c |  1 +
 intel/intel_chipset.h | 27 ++-------------------------
 2 files changed, 3 insertions(+), 25 deletions(-)
intel/intel_chipset.c +1 -0
index 545819ae..a960b756 100644
@@ -35,6 +35,7 @@ static const struct pci_device {
 	uint16_t gen;
 } pciids[] = {
 	/* Keep ids sorted by gen; latest gen first */
+	INTEL_ICL_11_IDS(11),
 };
 
 bool intel_is_genx(unsigned int devid, int gen)
intel/intel_chipset.h +2 -25
index e4783d4e..db9b53b2 100644
@@ -261,16 +261,6 @@
 #define PCI_CHIP_CANNONLAKE_12		0x5A44
 #define PCI_CHIP_CANNONLAKE_13		0x5A4C
 
-#define PCI_CHIP_ICELAKE_11_0		0x8A50
-#define PCI_CHIP_ICELAKE_11_1		0x8A51
-#define PCI_CHIP_ICELAKE_11_2		0x8A5C
-#define PCI_CHIP_ICELAKE_11_3		0x8A5D
-#define PCI_CHIP_ICELAKE_11_4		0x8A52
-#define PCI_CHIP_ICELAKE_11_5		0x8A5A
-#define PCI_CHIP_ICELAKE_11_6		0x8A5B
-#define PCI_CHIP_ICELAKE_11_7		0x8A71
-#define PCI_CHIP_ICELAKE_11_8		0x8A70
-
 #define IS_MOBILE(devid)	((devid) == PCI_CHIP_I855_GM || \
 				 (devid) == PCI_CHIP_I915_GM || \
 				 (devid) == PCI_CHIP_I945_GM || \
@@ -554,26 +544,14 @@
 
 #define IS_GEN10(devid)		(IS_CANNONLAKE(devid))
 
-#define IS_ICELAKE_11(devid)	((devid) == PCI_CHIP_ICELAKE_11_0 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_1 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_2 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_3 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_4 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_5 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_6 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_7 || \
-				 (devid) == PCI_CHIP_ICELAKE_11_8)
-
-#define IS_ICELAKE(devid)	(IS_ICELAKE_11(devid))
-
-#define IS_GEN11(devid)		(IS_ICELAKE_11(devid))
-
 /* New platforms use kernel pci ids */
 #include <stdbool.h>
 
 bool intel_is_genx(unsigned int devid, int gen);
 bool intel_get_genx(unsigned int devid, int *gen);
 
+#define IS_GEN11(devid) intel_is_genx(devid, 11)
+
 #define IS_9XX(dev)		(IS_GEN3(dev) || \
 				 IS_GEN4(dev) || \
 				 IS_GEN5(dev) || \
@@ -582,7 +560,6 @@ bool intel_get_genx(unsigned int devid, int *gen);
 				 IS_GEN8(dev) || \
 				 IS_GEN9(dev) || \
 				 IS_GEN10(dev) || \
-				 IS_GEN11(dev) || \
 				 intel_get_genx(dev, NULL))
 
 #endif /* _INTEL_CHIPSET_H */
Signature · 6 lines
2.17.1

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

PATCH v3 3/5 intel: make gen10 use generic gen macro

In reply to Lucas De Marchi
---
 intel/intel_chipset.c |  1 +
 intel/intel_chipset.h | 34 +---------------------------------
 2 files changed, 2 insertions(+), 33 deletions(-)
intel/intel_chipset.c +1 -0
index a960b756..a627928e 100644
@@ -36,6 +36,7 @@ static const struct pci_device {
 } pciids[] = {
 	/* Keep ids sorted by gen; latest gen first */
 	INTEL_ICL_11_IDS(11),
+	INTEL_CNL_IDS(10),
 };
 
 bool intel_is_genx(unsigned int devid, int gen)
intel/intel_chipset.h +1 -33
index db9b53b2..7179b623 100644
@@ -246,21 +246,6 @@
 #define PCI_CHIP_WHISKEYLAKE_U_GT3_2     0x3EA3
 #define PCI_CHIP_WHISKEYLAKE_U_GT3_3     0x3EA4
 
-#define PCI_CHIP_CANNONLAKE_0		0x5A51
-#define PCI_CHIP_CANNONLAKE_1		0x5A59
-#define PCI_CHIP_CANNONLAKE_2		0x5A41
-#define PCI_CHIP_CANNONLAKE_3		0x5A49
-#define PCI_CHIP_CANNONLAKE_4		0x5A52
-#define PCI_CHIP_CANNONLAKE_5		0x5A5A
-#define PCI_CHIP_CANNONLAKE_6		0x5A42
-#define PCI_CHIP_CANNONLAKE_7		0x5A4A
-#define PCI_CHIP_CANNONLAKE_8		0x5A50
-#define PCI_CHIP_CANNONLAKE_9		0x5A40
-#define PCI_CHIP_CANNONLAKE_10		0x5A54
-#define PCI_CHIP_CANNONLAKE_11		0x5A5C
-#define PCI_CHIP_CANNONLAKE_12		0x5A44
-#define PCI_CHIP_CANNONLAKE_13		0x5A4C
-
 #define IS_MOBILE(devid)	((devid) == PCI_CHIP_I855_GM || \
 				 (devid) == PCI_CHIP_I915_GM || \
 				 (devid) == PCI_CHIP_I945_GM || \
@@ -527,29 +512,13 @@
 				 IS_GEMINILAKE(devid) || \
 				 IS_COFFEELAKE(devid))
 
-#define IS_CANNONLAKE(devid)	((devid) == PCI_CHIP_CANNONLAKE_0 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_1 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_2 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_3 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_4 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_5 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_6 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_7 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_8 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_9 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_10 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_11 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_12 || \
-				 (devid) == PCI_CHIP_CANNONLAKE_13)
-
-#define IS_GEN10(devid)		(IS_CANNONLAKE(devid))
-
 /* New platforms use kernel pci ids */
 #include <stdbool.h>
 
 bool intel_is_genx(unsigned int devid, int gen);
 bool intel_get_genx(unsigned int devid, int *gen);
 
+#define IS_GEN10(devid) intel_is_genx(devid, 10)
 #define IS_GEN11(devid) intel_is_genx(devid, 11)
 
 #define IS_9XX(dev)		(IS_GEN3(dev) || \
@@ -559,7 +528,6 @@ bool intel_get_genx(unsigned int devid, int *gen);
 				 IS_GEN7(dev) || \
 				 IS_GEN8(dev) || \
 				 IS_GEN9(dev) || \
-				 IS_GEN10(dev) || \
 				 intel_get_genx(dev, NULL))
 
 #endif /* _INTEL_CHIPSET_H */
Signature · 6 lines
2.17.1

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

PATCH v3 4/5 intel: make gen9 use generic gen macro

In reply to Lucas De Marchi

The 2 PCI IDs that are used for the command line overrid mechanism were left defined. The rest can be gone and then we just use the kernel defines.

---
 intel/intel_chipset.c |   5 ++
 intel/intel_chipset.h | 187 +-----------------------------------------
 2 files changed, 6 insertions(+), 186 deletions(-)
intel/intel_chipset.c +5 -0
index a627928e..d5c33cc5 100644
@@ -37,6 +37,11 @@ static const struct pci_device {
 	/* Keep ids sorted by gen; latest gen first */
 	INTEL_ICL_11_IDS(11),
 	INTEL_CNL_IDS(10),
+	INTEL_CFL_IDS(9),
+	INTEL_GLK_IDS(9),
+	INTEL_KBL_IDS(9),
+	INTEL_BXT_IDS(9),
+	INTEL_SKL_IDS(9),
 };
 
 bool intel_is_genx(unsigned int devid, int gen)
intel/intel_chipset.h +1 -186

213 lines not on this page · raw message

Signature · 6 lines
2.17.1

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

PATCH v3 5/5 intel: get gen once for gen >= 9

In reply to Lucas De Marchi

We don't need to call IS_GEN() for each gen >= 9: we can rather use the new intel_is_genx() helper to iterate the pciids array once.

---
 intel/intel_bufmgr_gem.c | 8 +-------
 intel/intel_decode.c     | 8 ++------
 2 files changed, 3 insertions(+), 13 deletions(-)
intel/intel_bufmgr_gem.c +1 -7
index 8c3a4b20..d6587b76 100644
@@ -3656,13 +3656,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size)
 		bufmgr_gem->gen = 7;
 	else if (IS_GEN8(bufmgr_gem->pci_device))
 		bufmgr_gem->gen = 8;
-	else if (IS_GEN9(bufmgr_gem->pci_device))
-		bufmgr_gem->gen = 9;
-	else if (IS_GEN10(bufmgr_gem->pci_device))
-		bufmgr_gem->gen = 10;
-	else if (IS_GEN11(bufmgr_gem->pci_device))
-		bufmgr_gem->gen = 11;
-	else {
+	else if (!intel_get_genx(bufmgr_gem->pci_device, &bufmgr_gem->gen)) {
 		free(bufmgr_gem);
 		bufmgr_gem = NULL;
 		goto exit;
intel/intel_decode.c +2 -6
index b24861b1..0ff095bc 100644
@@ -3823,12 +3823,8 @@ drm_intel_decode_context_alloc(uint32_t devid)
 	ctx->devid = devid;
 	ctx->out = stdout;
 
-	if (IS_GEN11(devid))
-		ctx->gen = 11;
-	else if (IS_GEN10(devid))
-		ctx->gen = 10;
-	else if (IS_GEN9(devid))
-		ctx->gen = 9;
+	if (intel_get_genx(devid, &ctx->gen))
+		;
 	else if (IS_GEN8(devid))
 		ctx->gen = 8;
 	else if (IS_GEN7(devid))
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on the v3 series
#6 lore raw
In reply to Lucas De Marchi

Quoting Lucas De Marchi (2018-09-05 19:31:55)

Quoted 19 lines

Adding PCI IDs to different projects is a boring manual task that motivated me to create this series. The idea is to centralize the IDs in the kernel header and let other projects copy it.

Initially my plan was to convert all gens, back to gen2, but that proved slightly difficult since there are some corner cases to cover and I didn't want to block the important part, i.e.: for recent gens, there's no risk of missing a PCI ID.

v2: address comments from Chris by pulling it out to a separate .c
v3: remove/add comments on first patch and rebase the rest

Discussed on v2 but left for later:
- replace intel_is_genx() with a simple check for bufmgr->gen, after making sure said variable is initialized on all code paths.
- treat unknown gen as a future gen
- convert gen < 9 to use the new header

Quoted 6 lines

Lucas De Marchi (5):
intel: add generic functions to check PCI ID
intel: make gen11 use generic gen macro
intel: make gen10 use generic gen macro
intel: make gen9 use generic gen macro
intel: get gen once for gen >= 9

The opens are fine and I didn't find anything else to question, so the series is

-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 27 lines · Chris Wilson

Quoting Lucas De Marchi (2018-09-05 19:31:55)

Quoted 19 lines

Adding PCI IDs to different projects is a boring manual task that motivated me to create this series. The idea is to centralize the IDs in the kernel header and let other projects copy it.

Initially my plan was to convert all gens, back to gen2, but that proved slightly difficult since there are some corner cases to cover and I didn't want to block the important part, i.e.: for recent gens, there's no risk of missing a PCI ID.

v2: address comments from Chris by pulling it out to a separate .c
v3: remove/add comments on first patch and rebase the rest

Discussed on v2 but left for later:
- replace intel_is_genx() with a simple check for bufmgr->gen, after making sure said variable is initialized on all code paths.
- treat unknown gen as a future gen
- convert gen < 9 to use the new header

Quoted 6 lines

Lucas De Marchi (5):
intel: add generic functions to check PCI ID
intel: make gen11 use generic gen macro
intel: make gen10 use generic gen macro
intel: make gen9 use generic gen macro
intel: get gen once for gen >= 9

Quoted 3 lines

The opens are fine and I didn't find anything else to question, so the series is

pushed, thanks for patches and reviews.

Quoted 5 lines

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

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