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

Jani Nikula jani.nikula at intel.com
Wed May 22 13:26:44 UTC 2024


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.
>
> 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.

An alternative is a pure bash or Python script to run something like:

	lspci -d 8086::0300 -nn

and annotate/filter the results based on the PCI IDs from:

	modinfo -F alias i915
	modinfo -F alias xe

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