Hi Janusz,

the code looks good, I am wondering if "fake" is appropriate
word for the descriptions below:
in a way the values are correct, but wrongly reported - they
belong to pci x1 bridge of the GPU. Maybe adding a short
sentence that the values reported always belong to pci x1
instead of the fastest active bridge would complete the message?
What do you think?

On 2026-01-27 at 10:54:18 +0100, Janusz Krzysztofik wrote:
> Users of Intel discrete graphics adapters are confused with fake
> information on PCIe link bandwidth (speed and size) of their GPU devices
> reported by tools like lspci or lsgpu.  That fake information is
> unfortunately provided by hardware, Linux PCI subsystem just exposes it
> untouched to upper layers, including userspace via sysfs, and userspace
> tools just report those fake values.
> 
> While we can't do much about the kernel side or general purpose userspace
> tools like lspci, we can try to address the issue with our lsgpu utility.
> 
> Correct link bandwidth attributes of a discrete GPU card can be obtained
> from the kernel by looking not at the PCI device of the GPU itself, only
> at a PCIe upstream port of the card's PCI bridge.  For integrity with
> content of the sysfs and with output from the other tools, we are not
> going to replace the fake information with that from the bridge upstream
> port, only show that port and its attributes themselves while listing
> devices.
> 
> Since the tool uses our udev based igt_device_scan library for identifying
> GPU devices and printing their properties and attributes, modifications
> that we need apply to that library.
> 
> As a first step, exclude the fake data from being printed.
> 
> v2: Keep dump_props_and_attrs() generic: hand over decision on omitting
>     link attributes to the caller, and implementation of the check to a
>     helper (Sebastian).
> 
> Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10753
> Cc: Sebastian Brzezinka <[email protected]>
> Signed-off-by: Janusz Krzysztofik <[email protected]>
> ---
>  lib/igt_device_scan.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index abd8ca209e..7ae64375b5 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -602,7 +602,15 @@ static inline void _print_key_value(const char *k, const 
> char *v)
>       printf("%-32s: %s\n", k, v);
>  }
>  
> -static void dump_props_and_attrs(const struct igt_device *dev)
> +static bool is_link_attr(const char *name)
> +{
> +     return !strcmp(name, "max_link_speed") ||
> +            !strcmp(name, "max_link_width") ||
> +            !strcmp(name, "current_link_speed") ||
> +            !strcmp(name, "current_link_width");
> +}
> +
> +static void dump_props_and_attrs(const struct igt_device *dev, bool 
> omit_link)
>  {
>       struct igt_map_entry *entry;
>  
> @@ -613,6 +621,10 @@ static void dump_props_and_attrs(const struct igt_device 
> *dev)
>  
>       printf("\n[attributes]\n");
>       igt_map_foreach(dev->attrs_map, entry) {
> +             /* omit link bandwidth attributes if requested */
> +             if (omit_link && is_link_attr(entry->key))
> +                     continue;
> +
>               _print_key_value((char *)entry->key, (char *)entry->data);
>       }
>       printf("\n");
> @@ -1366,7 +1378,8 @@ igt_devs_print_detail(struct igt_list_head *view,
>                       _print_key_value("codename", dev->codename);
>               }
>  
> -             dump_props_and_attrs(dev);
> +             /* omit fake link bandwidth attributes if a discrete card */
> +             dump_props_and_attrs(dev, dev->dev_type == DEVTYPE_DISCRETE);
>       }
>  }
>  
> -- 
> 2.52.0
> 

-- 
Best Regards,
Krzysztof

Reply via email to