Skip to contentSkip to conversation

intel: rework how we add PCI IDs

PATCH Superseded Lucas De Marchi 2 participants 16 messages Aug 29, 2018 – Sep 5, 2018 Arm/Amlogic Meson SoC support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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

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    |  84 +++++++
 intel/intel_chipset.h    | 254 +--------------------
 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

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

PATCH v2 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

---
 intel/Makefile.sources |   1 +
 intel/i915_pciids.h    | 461 +++++++++++++++++++++++++++++++++++++++++
 intel/intel_chipset.c  |  77 +++++++
 intel/intel_chipset.h  |  10 +-
 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 +77 -0

77 lines not on this page · raw message

intel/intel_chipset.h +9 -1
index 4a34b7be..0e14c58f 100644
@@ -568,6 +568,13 @@
 
 #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);
+
+/* all platforms */
 #define IS_9XX(dev)		(IS_GEN3(dev) || \
 				 IS_GEN4(dev) || \
 				 IS_GEN5(dev) || \
@@ -576,6 +583,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

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

Re: [PATCH libdrm v2 1/5] intel: add generic functions to check PCI ID

Quoting Lucas De Marchi (2018-08-29 01:35:28)

intel/intel_chipset.c line 36

Quoted 4 lines
intel/intel_chipset.c new file +4 -0
+static const struct pci_device {
+       uint16_t device;
+       uint16_t gen;
+} pciids[] = {

Add a comment here as well for the ordering requirement.

/* Keep ids sorted by gen; latest gen first */

We're unlikely to notice a comment in the function later trying to impose its restriction.

intel/intel_chipset.c line 47

Quoted 11 lines
intel/intel_chipset.c new file +11 -0
+};
+
+bool intel_is_genx(unsigned int devid, int gen)
+{
+       const struct pci_device *p,
+                 *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
+
+       for (p = pciids; p < pend; p++) {
+               /* PCI IDs are sorted */
+               if (p->gen < gen)
+                       break;

If we have lots of gen with lots of subids, a binary search for gen would be sensible. However, do we need this function? Do we not just convert everyone over to a lookup of pci-id on entry?

Quoted 20 lines
intel/intel_chipset.c new file +20 -0
+
+               if (p->device != devid)
+                       continue;
+
+               if (gen == p->gen)
+                       return true;
+
+               break;
+       }
+
+       return false;
+}
+
+bool intel_get_genx(unsigned int devid, int *gen)
+{
+       const struct pci_device *p,
+                 *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
+
+       for (p = pciids; p < pend; p++) {
+               if (p->device != devid)

intel/intel_chipset.c line 77

Quoted 10 lines
intel/intel_chipset.c new file +10 -0
+                       continue;
+
+               if (gen)
+                       *gen = p->gen;
+
+               return true;
+       }
+
+       return false;
+}

Idle thought
#ifdef SELFTEST
int main(void)

{
	/* check pci-ids are ordered by gen */
}

#endif

Quoted 5 lines
intel/intel_chipset.h +0 -0
index 4a34b7be..0e14c58f 100644

intel/intel_chipset.h line 577

Quoted 10 lines
intel/intel_chipset.h +7 -0
@@ -568,6 +568,13 @@
 
 #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);
+
+/* all platforms */

Quite clearly not all platforms :-p

intel/intel_chipset.h line 580

Quoted 3 lines
intel/intel_chipset.h +0 -0
 #define IS_9XX(dev)            (IS_GEN3(dev) || \
                                 IS_GEN4(dev) || \
                                 IS_GEN5(dev) || \

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

#3 lore raw

Re: [PATCH libdrm v2 1/5] intel: add generic functions to check PCI ID

Quoted 8 lines · Chris Wilson

Quoting Lucas De Marchi (2018-08-29 01:35:28)

intel/intel_chipset.c line 36

Quoted 4 lines
intel/intel_chipset.c new file +4 -0
+static const struct pci_device {
+       uint16_t device;
+       uint16_t gen;
+} pciids[] = {

Add a comment here as well for the ordering requirement.

Quoted 4 lines

/* Keep ids sorted by gen; latest gen first */

We're unlikely to notice a comment in the function later trying to impose its restriction.

ok

Quoted 16 lines

intel/intel_chipset.c line 47

Quoted 12 lines
intel/intel_chipset.c new file +11 -0
+};
+
+bool intel_is_genx(unsigned int devid, int gen)
+{
+       const struct pci_device *p,
+                 *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
+
+       for (p = pciids; p < pend; p++) {
+               /* PCI IDs are sorted */
+               if (p->gen < gen)
+                       break;

If we have lots of gen with lots of subids, a binary search for gen would be sensible. However, do we need this function? Do we not just convert everyone over to a lookup of pci-id on entry?

in some places we need the single IS_GEN9(). The advantage of using this function rather than intel_get_genx() is that it can be faster due to stopping here, or doing a binary search as you pointed out. With intel_get_genx we don't have this. IS_GEN9() is may be called in non-initialization code paths, so IMO its worth.

What we *can* do here instead is: guarantee all codepaths will occur after the call to drm_intel_bufmgr_gem_init() then remove all macros and just implement a single function that checks the "cached value".

Quoted 35 lines
Quoted 21 lines
intel/intel_chipset.c new file +20 -0
+
+               if (p->device != devid)
+                       continue;
+
+               if (gen == p->gen)
+                       return true;
+
+               break;
+       }
+
+       return false;
+}
+
+bool intel_get_genx(unsigned int devid, int *gen)
+{
+       const struct pci_device *p,
+                 *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
+
+       for (p = pciids; p < pend; p++) {
+               if (p->device != devid)

intel/intel_chipset.c line 77

Quoted 10 lines
intel/intel_chipset.c new file +10 -0
+                       continue;
+
+               if (gen)
+                       *gen = p->gen;
+
+               return true;
+       }
+
+       return false;
+}

Idle thought
#ifdef SELFTEST
int main(void)

Quoted 4 lines
{
	/* check pci-ids are ordered by gen */
}

#endif

$ git grep SELFTEST
$

you do know this is a patch for libdrm, right?

Quoted 9 lines
Quoted 9 lines
intel/intel_chipset.h +0 -0
index 4a34b7be..0e14c58f 100644
@@ -568,6 +568,13 @@
 
 #define IS_GEN11(devid)                (IS_ICELAKE_11(devid))
 
Quoted 9 lines

intel/intel_chipset.h line 577

Quoted 7 lines
intel/intel_chipset.h +7 -0
+/* 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);
+
+/* all platforms */

Quite clearly not all platforms :-p

by some definition of "all".... the " New platforms use kernel pci ids " + the ones that don't ;)

I'm ok with just removing the comment

Lucas De Marchi

Quoted 4 lines

intel/intel_chipset.h line 580

Quoted 4 lines
intel/intel_chipset.h +0 -0
 #define IS_9XX(dev)            (IS_GEN3(dev) || \
                                 IS_GEN4(dev) || \
                                 IS_GEN5(dev) || \

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

#4 lore raw

Re: [PATCH libdrm v2 1/5] intel: add generic functions to check PCI ID

Quoting Lucas De Marchi (2018-08-31 17:06:01)

Quoted 22 lines · Chris Wilson
Quoted 14 lines

Quoting Lucas De Marchi (2018-08-29 01:35:28)

intel/intel_chipset.c line 47

Quoted 9 lines
intel/intel_chipset.c new file +9 -0
+bool intel_is_genx(unsigned int devid, int gen)
+{
+       const struct pci_device *p,
+                 *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
+
+       for (p = pciids; p < pend; p++) {
+               /* PCI IDs are sorted */
+               if (p->gen < gen)
+                       break;

If we have lots of gen with lots of subids, a binary search for gen would be sensible. However, do we need this function? Do we not just convert everyone over to a lookup of pci-id on entry?

in some places we need the single IS_GEN9(). The advantage of using this function rather than intel_get_genx() is that it can be faster due to stopping here, or doing a binary search as you pointed out. With intel_get_genx we don't have this. IS_GEN9() is may be called in non-initialization code paths, so IMO its worth.

Quoted 3 lines

What we *can* do here instead is: guarantee all codepaths will occur after the call to drm_intel_bufmgr_gem_init() then remove all macros and just implement a single function that checks the "cached value".

That would be similar to how we handle elsewhere. But there's no need to jump there in one series.

Quoted 8 lines
Quoted 7 lines

Idle thought
#ifdef SELFTEST
int main(void)

{
      /* check pci-ids are ordered by gen */
}

#endif

Quoted 4 lines
$ git grep SELFTEST
$

you do know this is a patch for libdrm, right?

Wouldn't be that hard to add a check_PROGRAMS target with a -DSELFTEST. It was just an idle thought if you cared to improve the standard of a stagnant library. It might as well retire with grace ;) -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

PATCH v2 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 8af99ad9..5a549ba4 100644
@@ -34,6 +34,7 @@ static const struct pci_device {
 	uint16_t device;
 	uint16_t gen;
 } pciids[] = {
+	INTEL_ICL_11_IDS(11),
 };
 
 bool intel_is_genx(unsigned int devid, int gen)
intel/intel_chipset.h +2 -25
index 0e14c58f..2bf480d1 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)
+
 /* all platforms */
 #define IS_9XX(dev)		(IS_GEN3(dev) || \
 				 IS_GEN4(dev) || \
@@ -583,7 +561,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
#6 lore raw

PATCH v2 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 5a549ba4..0c2ba884 100644
@@ -35,6 +35,7 @@ static const struct pci_device {
 	uint16_t gen;
 } pciids[] = {
 	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 2bf480d1..6790f728 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)
 
 /* all platforms */
@@ -560,7 +529,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
#7 lore raw

PATCH v2 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 0c2ba884..c984d8ac 100644
@@ -36,6 +36,11 @@ static const struct pci_device {
 } pciids[] = {
 	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

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

Re: [PATCH libdrm v2 4/5] intel: make gen9 use generic gen macro

Quoting Lucas De Marchi (2018-08-29 01:35:31)

Quoted 2 lines

The 2 PCI IDs that are used for the command line overrid mechanism were left defined.

What makes them so special? Why not just match on the override devid? -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [PATCH libdrm v2 4/5] intel: make gen9 use generic gen macro

Quoted 5 lines · Chris Wilson

Quoting Lucas De Marchi (2018-08-29 01:35:31)

Quoted 2 lines

The 2 PCI IDs that are used for the command line overrid mechanism were left defined.

What makes them so special? Why not just match on the override devid?

because it's a name -> id mapping? It maps a short string like "skl" to a single specific PCI ID... how useful is that and if we should retain its behavior, I have dunno. But
i915_pciids.h doesn't have defines for individual PCI IDs, but groups of them.

I would either have to create an accessor/iter for gen x in intel_chipset.c or do some macros to extract the first id from the i915_pciids.h, just to get an ID that is set in stone and change the current id used :-/

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

#10 lore raw

Re: [PATCH libdrm v2 4/5] intel: make gen9 use generic gen macro

Quoting Lucas De Marchi (2018-08-29 17:01:11)

Quoted 5 lines · Chris Wilson
Quoted 4 lines

Quoting Lucas De Marchi (2018-08-29 01:35:31)

Quoted 2 lines

The 2 PCI IDs that are used for the command line overrid mechanism were left defined.

Quoted 7 lines
Quoted 1 line

What makes them so special? Why not just match on the override devid?

because it's a name -> id mapping? It maps a short string like "skl" to a single specific PCI ID... how useful is that and if we should retain its behavior, I have dunno. But
i915_pciids.h doesn't have defines for individual PCI IDs, but groups of them.

My bad, I've always used pci-id overrides as a pci-id!

Quoted 4 lines

I would either have to create an accessor/iter for gen x in intel_chipset.c or do some macros to extract the first id from the i915_pciids.h, just to get an ID that is set in stone and change the current id used :-/

Having the i915_pciids.h contain the codename (and /rough/ marketing name) was pencilled in to my plans now that it no longer appears to be a freak out. Once we have configurable macros, the extra parameters just disappear when unwanted.
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw

Re: [PATCH libdrm v2 4/5] intel: make gen9 use generic gen macro

In reply to Lucas De Marchi

Quoting Lucas De Marchi (2018-08-29 01:35:31)

Quoted 15 lines

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 +0 -0
index 0c2ba884..c984d8ac 100644

intel/intel_chipset.c static const struct pci_device { · line 43

Quoted 8 lines
intel/intel_chipset.c +5 -0
@@ -36,6 +36,11 @@ static const struct pci_device {
 } pciids[] = {
        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),

The gradual conversion lgtm. But why stop here? :) -Chris
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw

Re: [PATCH libdrm v2 4/5] intel: make gen9 use generic gen macro

Quoted 11 lines · Chris Wilson

Quoting Lucas De Marchi (2018-08-29 01:35:31)

Quoted 10 lines

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(-)
Quoted 15 lines

intel/intel_chipset.c static const struct pci_device { · line 43

Quoted 13 lines
intel/intel_chipset.c +5 -0
index 0c2ba884..c984d8ac 100644
@@ -36,6 +36,11 @@ static const struct pci_device {
 } pciids[] = {
        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),

The gradual conversion lgtm. But why stop here? :)

From cover letter:

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.

With the last approach moving the implementation to a .c file I think it will be easier to implement for older gens, but there's no point in doing the manual boring labor of converting all gens just to have to change the approach in a v2, v3 of the patch set. Like I did for v1 -> v2. I can convert the rest if we agree the current approach is okish

I'm even ok with letting older ones as is since I hope we won't add a new pci id for e.g. gen3, so I won't have to touch that.

Lucas De Marchi

Quoted 1 line

-Chris

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

#13 lore raw

PATCH v2 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

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

Re: [PATCH libdrm v2 5/5] intel: get gen once for gen >= 9

Quoting Lucas De Marchi (2018-08-29 01:35:32)

Quoted 18 lines

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 +0 -1
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))

intel/intel_bufmgr_gem.c drm_intel_bufmgr_gem_init(int fd, int batch_size) · line 3662

Quoted 10 lines
intel/intel_bufmgr_gem.c +1 -6
-               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;

And while you are here, don't exit for an unknown gen, just pretend it's a future one. i915_pciids.h should contain *all* ids, even reserved, for exactly this reason. (The same behaviour is relied on elsewhere so that we don't get caught out by some one retrospectively introducing a new chip. Don't even get started on the abuse of pci-id for sub-gen encoding...)
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [PATCH libdrm v2 5/5] intel: get gen once for gen >= 9

Quoted 28 lines · Chris Wilson

Quoting Lucas De Marchi (2018-08-29 01:35:32)

Quoted 27 lines

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;
Quoted 8 lines

intel/intel_bufmgr_gem.c drm_intel_bufmgr_gem_init(int fd, int batch_size) · line 3662

Quoted 1 line
intel/intel_bufmgr_gem.c +0 -0
                goto exit;

And while you are here, don't exit for an unknown gen, just pretend it's a future one. i915_pciids.h should contain *all* ids, even reserved, for exactly this reason. (The same behaviour is relied on elsewhere so that we don't get caught out by some one retrospectively introducing a new chip. Don't even get started on the abuse of pci-id for sub-gen encoding...)

This can be done as a separate series, otherwise we will just start shoving a lot of things on top of this series and never get it merged.

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