[PATCH i-g-t v4] tools/mk_detect_intel_gpu: add a tool to detect Intel GPUs from their PCI IDs

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed May 22 14:46:27 UTC 2024


Hi Jani,
On 2024-05-22 at 16:26:44 +0300, Jani Nikula wrote:
> On Wed, 22 May 2024, Jani Nikula <jani.nikula at intel.com> wrote:
> > On Wed, 22 May 2024, Mauro Carvalho Chehab <mauro.chehab at linux.intel.com> wrote:
> >> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> >>
> >> Such tool parses the Kernel drivers for both i915 and Xe and
> >> generates a script that helps detecting Intel GPU models.
> >
> > I acknowledge the usefulness of such a tool, but to be brutally honest,
> > this implementation is horrible in so many levels.
> >
> > IGT uses meson and avoids perl.

imho this could also be a python script.

> >
> > This has a makefile with perl to generate a header that's included in a
> > C program that is built and executed to generate a perl script that's
> > then the tool, and the generated perl script runs lspci(8).
> >
> > I think there's really only one reasonable way to implement this in the
> > IGT context, and that's pure C, leveraging all the stuff in IGT, using
> > the PCI IDs listed in the IGT repo.
> >
> > Or you can turn this into a separate pet project, because what you have
> > here does not fit IGT.
> >
> > The i915_pciids.h parsing below is already stale, and you really can't
> > expect to get this merged and be kept up-to-date by folks updating
> > i915_pciids.h. IMO it's not maintainable.

This is for making a new script, after generation there will be
standalone program: intel_detect_gpu.pl and imho igt is missing
a tool like lsgpu which will work _without_ kmd gpu driver loaded,
simple enough so one can just run it.

> 
> An alternative is a pure bash or Python script to run something like:
> 
> 	lspci -d 8086::0300 -nn
> 

Looks like a good idea but this is also dependancy, btw
from man:
-nn    Show PCI vendor and device codes as both numbers and names.

imho we should not depend on names from lspci.
More from man:

-n     Show PCI vendor and device codes as numbers instead of looking them up in the PCI ID list.
-m     Dump PCI device data in a backward-compatible machine readable form.

> and annotate/filter the results based on the PCI IDs from:
> 
> 	modinfo -F alias i915
> 	modinfo -F alias xe

But this one is creating one more dependancy, one should have
modules compiled in current running kernel.

Regards,
Kamil

> 
> You get the fancy marketing names directly from lspci, supported kernel
> modules from modinfo, available on the system, with zero dependency on
> PCI ID macros or names in source code.
> 
> That's like a 100 lines of script that should need virtually zero
> maintenance.
> 
> Additionally, the script could match the modinfo PCI IDs against
> /usr/share/misc/pci.ids (see man pci.ds) to show the marketing names.
> 
> 
> BR,
> Jani.
> 
> -- 
> Jani Nikula, Intel


More information about the igt-dev mailing list