public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: <intel-gfx@lists.freedesktop.org>,
	<intel-xe@lists.freedesktop.org>,
	"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
	Andi Shyti <andi.shyti@linux.intel.com>,
	Krzysztof Karas <krzysztof.karas@intel.com>,
	Krzysztof Niemiec <krzysztof.niemiec@intel.com>,
	Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Subject: Re: [PATCH i-g-t v3 6/6] lib/igt_device_scan: Print GPU upstream port parent/child relations
Date: Thu, 29 Jan 2026 12:49:39 +0100	[thread overview]
Message-ID: <DG11TIYPUWHH.1SQKHOBSDKJEF@intel.com> (raw)
In-Reply-To: <20260128161041.225652-14-janusz.krzysztofik@linux.intel.com>

Hi Janusz,

On Wed Jan 28, 2026 at 5:09 PM CET, Janusz Krzysztofik wrote:
> In a short listing, lsgpu prints a sysfs path of a PCI GPU parent as a
> local attribute of a DRM device.  However, if that's a discrete GPU and
> its associated PCIe upstream bridge port has been identified, no
> information on that bridge is listed among the GPU attributes.  Follow the
> pattern used with DRM devices and also show a PCI slot of the bridge port
> as a local attribute of the discrete GPU device.
>
> Moreover, in both short and detailed listings, local attributes intended
> for providing device names of GPU associated DRM devices and the GPU
> codename are also printed as attributes of related PCIe upstream bridge
> port, however, the DRM device names are shown as (null), and the codename
> attribute provides raw vendor:device codes of the bridge itself.  Replace
> those with PCI slot and codename of the GPU device.
>
> v2: Allocate memory to local attributes of a bridge for safety (Sebastian),
>   - merge with a formerly separate patch "lib/igt_device_scan: Don't print
>     bridge not applicable attributes" (Sebastian),
>   - no need for DEVTYPE_BRIDGE, just skip attributes if NULL.
>
> Cc: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
>  lib/igt_device_scan.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index f4d2eb6568..96bf0e359d 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -249,6 +249,8 @@ struct igt_device {
>  	char *codename; /* For grouping by codename */
>  	enum dev_type dev_type; /* For grouping by integrated/discrete */
>  
> +	char *pci_gpu; /* Filled for upstream bridge ports */
> +
>  	struct igt_list_head link;
>  };
>  
> @@ -1063,6 +1065,9 @@ static void update_or_add_parent(struct udev *udev,
>  
>  	/* override DEVTYPE_INTEGRATED so link attributes won't be omitted */
>  	bridge_idev->dev_type = DEVTYPE_ALL;
> +	bridge_idev->pci_gpu = strdup(parent_idev->pci_slot_name);
> +	bridge_idev->codename = strdup(parent_idev->codename);
Releasing memory here is safer, but we must ensure
igt_device_new_from_udev hasn't already filled the codename otherwise,
the original pointer will be lost.

I’m thinking about how to refactor these functions to make them
cleaner. They’re a bit cluttered right now since the 'find' and
'update' logic are merged together. This might be outside the scope
of your current patches, but the memory management is becoming quite
confusing. Unfortunately, there isn't an easy way to move this logic
into igt_device_new_from_udev right now.

> +	parent_idev->parent = bridge_idev;
>  }
>  
>  static struct igt_device *duplicate_device(struct igt_device *dev) {
> @@ -1234,6 +1239,7 @@ static void igt_device_free(struct igt_device *dev)
>  	free(dev->device);
>  	free(dev->driver);
>  	free(dev->pci_slot_name);
> +	free(dev->pci_gpu);
It could be unalocated memory.

-- 
Best regards,
Sebastian


  reply	other threads:[~2026-01-29 11:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 16:08 [PATCH i-g-t v3 0/6] lsgpu: Report upstream port link bandwidth Janusz Krzysztofik
2026-01-28 16:08 ` [PATCH i-g-t v3 1/6] lib/igt_device_scan: Don't print fake link bandwidth attributes Janusz Krzysztofik
2026-02-02  8:45   ` Krzysztof Karas
2026-01-28 16:09 ` [PATCH i-g-t v3 2/6] lib/igt_device_scan: Split out reusable part of update_or_add_parent Janusz Krzysztofik
2026-01-28 16:09 ` [PATCH i-g-t v3 3/6] lib/igt_device_scan: Include PCIe bridge upstream port if available Janusz Krzysztofik
2026-02-02 11:08   ` Krzysztof Karas
2026-01-28 16:09 ` [PATCH i-g-t v3 4/6] lib/igt_device_scan: List PCIe bridge ports after their children Janusz Krzysztofik
2026-01-28 16:09 ` [PATCH i-g-t v3 5/6] lib/igt_device_scan: Omit AER statistics data from attributes Janusz Krzysztofik
2026-01-28 16:09 ` [PATCH i-g-t v3 6/6] lib/igt_device_scan: Print GPU upstream port parent/child relations Janusz Krzysztofik
2026-01-29 11:49   ` Sebastian Brzezinka [this message]
2026-01-30 11:09     ` Janusz Krzysztofik
2026-02-02 17:21     ` Janusz Krzysztofik
2026-01-28 18:42 ` ✗ i915.CI.BAT: failure for lsgpu: Report upstream port link bandwidth (rev6) Patchwork
2026-01-28 18:46 ` ✓ Xe.CI.BAT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DG11TIYPUWHH.1SQKHOBSDKJEF@intel.com \
    --to=sebastian.brzezinka@intel.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=janusz.krzysztofik@linux.intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=krzysztof.karas@intel.com \
    --cc=krzysztof.niemiec@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox