Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: Ayaz A Siddiqui <ayaz.siddiqui@intel.com>
Cc: igt-dev@lists.freedesktop.org, Petri Latvala <petri.latvala@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib/igt_device_scan:Add function to get pci subsystem of requested card
Date: Mon, 26 Oct 2020 05:43:07 +0100	[thread overview]
Message-ID: <20201026044307.GA2951@zkempczy-mobl2> (raw)
In-Reply-To: <20201023175158.391450-2-ayaz.siddiqui@intel.com>

On Fri, Oct 23, 2020 at 11:21:57PM +0530, Ayaz A Siddiqui wrote:
> intel_gpu_top requires card information and PCI_SLOT_NAME for dGPU.
> Only pci subsystem contains both information.
> In case of user filter is other than pci subsystem then we need card
> information of associated pci subsystem which is stored as parent of
> requested card if available.
> 
> A new api has been added to cater intel_gpu_top requirement.
> 
> Signed-off-by: Ayaz A Siddiqui <ayaz.siddiqui@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Zbigniew Kempczynski <zbigniew.kempczynski@intel.com>
> Cc: Dixit Ashutosh <ashutosh.dixit@intel.com>
> ---
>  lib/igt_device_scan.c | 55 ++++++++++++++++++++++++++++++++-----------
>  lib/igt_device_scan.h |  2 ++
>  tools/intel_gpu_top.c |  2 +-
>  3 files changed, 44 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index f4d43c733..55aa8159d 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -1237,18 +1237,9 @@ static bool igt_device_filter_apply(const char *fstr)
>  	return true;
>  }
>  
> -/**
> - * igt_device_card_match
> - * @filter: filter string
> - * @card: pointer to igt_device_card struct
> - *
> - * Function applies filter to match device from device array.
> - *
> - * Returns:
> - * false - no card pointer was passed or card wasn't matched,
> - * true - card matched and returned.
> - */
> -bool igt_device_card_match(const char *filter, struct igt_device_card *card)
> +
> +static bool __igt_device_card_match(const char *filter,
> +			struct igt_device_card *card, bool request_pci_ss)
>  {
>  	struct igt_device *dev = NULL;
>  
> @@ -1266,10 +1257,46 @@ bool igt_device_card_match(const char *filter, struct igt_device_card *card)
>  
>  	/* We take first one if more than one card matches filter */
>  	dev = igt_list_first_entry(&igt_devs.filtered, dev, link);
> +	if (request_pci_ss && !is_pci_subsystem(dev) && dev->parent
> +		&& is_pci_subsystem(dev->parent))
> +		__copy_dev_to_card(dev->parent, card);
> +	else
> +		__copy_dev_to_card(dev, card);
> +	return true;
> +}
>  
> -	__copy_dev_to_card(dev, card);
> +/**
> + * igt_device_card_match
> + * @filter: filter string
> + * @card: pointer to igt_device_card struct
> + *
> + * Function applies filter to match device from device array.
> + *
> + * Returns:
> + * false - no card pointer was passed or card wasn't matched,
> + * true - card matched and returned.
> + */
> +bool igt_device_card_match(const char *filter, struct igt_device_card *card)
> +{
> +       return __igt_device_card_match(filter, card, false);
> +}
>  
> -	return true;
> +/**
> + * igt_device_card_match_pci
> + * @filter: filter string
> + * @card: pointer to igt_device_card struct
> + *
> + * Function applies filter to match device from device array.
> + * Populate associated pci subsystem data if available.
> + *
> + * Returns:
> + * false - no card pointer was passed or card wasn't matched,
> + * true - card matched and returned.
> + */
> +bool igt_device_card_match_pci(const char *filter,
> +			struct igt_device_card *card)
> +{
> +       return __igt_device_card_match(filter, card, true);
>  }
>  
>  /**
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index bd937d227..544e982c4 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -68,6 +68,8 @@ const char *igt_device_filter_get(int num);
>  
>  /* Use filter to match the device and fill card structure */
>  bool igt_device_card_match(const char *filter, struct igt_device_card *card);
> +bool igt_device_card_match_pci(const char *filter,
> +	struct igt_device_card *card);
>  bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card);
>  int igt_open_card(struct igt_device_card *card);
>  int igt_open_render(struct igt_device_card *card);
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 79a936ffb..1b6c8633b 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -1393,7 +1393,7 @@ int main(int argc, char **argv)
>  	}
>  
>  	if (opt_device != NULL) {
> -		ret = igt_device_card_match(opt_device, &card);
> +		ret = igt_device_card_match_pci(opt_device, &card);
>  		if (!ret)
>  			fprintf(stderr, "Requested device %s not found!\n", opt_device);
>  		free(opt_device);
> -- 
> 2.26.2
>

LGTM:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-10-26  4:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 17:51 [igt-dev] [PATCH i-g-t 0/2] tools/intel_gpu_top: Fix Device selection issues Ayaz A Siddiqui
2020-10-23 17:51 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_device_scan:Add function to get pci subsystem of requested card Ayaz A Siddiqui
2020-10-26  4:43   ` Zbigniew Kempczyński [this message]
2020-10-23 17:51 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_device_scan: Select intel as default vendor for intel_gpu_top Ayaz A Siddiqui
2020-10-26  4:43   ` Zbigniew Kempczyński
2020-10-23 18:40 ` [igt-dev] ✓ Fi.CI.BAT: success for tools/intel_gpu_top: Fix Device selection issues Patchwork
2020-10-23 22:14 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-10-24  2:03   ` Siddiqui, Ayaz A
2020-10-26  8:44 ` [igt-dev] [PATCH i-g-t 0/2] " Petri Latvala

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=20201026044307.GA2951@zkempczy-mobl2 \
    --to=zbigniew.kempczynski@intel.com \
    --cc=ayaz.siddiqui@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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