[igt-dev] [PATCH i-g-t] lib/igt_device_scan: Add slot selector

Laguna, Lukasz lukasz.laguna at intel.com
Tue Jan 5 13:43:12 UTC 2021


> -----Original Message-----
> From: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Sent: poniedziałek, 4 stycznia 2021 14:33
> To: Laguna, Lukasz <lukasz.laguna at intel.com>
> Cc: igt-dev at lists.freedesktop.org
> Subject: Re: [PATCH i-g-t] lib/igt_device_scan: Add slot selector
> 
> On Mon, Jan 04, 2021 at 10:34:41AM +0100, Łukasz Łaguna wrote:
> > Add selector for direct device selection, based on hardware (PCIe) path.
> > It allows to choose device in specified domain, bus, slot and function.
> >
> > Example:
> > gem_exec_basic --device "pci:slot=0000:01:00.0"
> >
> > Signed-off-by: Łukasz Łaguna <lukasz.laguna at intel.com>
> > ---
> >  lib/igt_device_scan.c | 18 +++++++++++++++---
> >  1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index
> > b3b2bf4d..4704ba6f 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/lib/igt_device_scan.c
> > @@ -83,9 +83,9 @@
> >   *   device selection, e.g. in automated execution setting. In such scenarios
> >   *   please consider using sys, pci or platform filters instead.
> >   *
> > - * - pci: select device using PCI vendor and device properties
> > + * - pci: select device using PCI slot or vendor and device
> > + properties
> >   *   |[<!-- language="plain" -->
> > - *   pci:[vendor=%04x/name][,device=%04x][,card=%d]
> > + *   pci:[vendor=%04x/name][,device=%04x][,card=%d] |
> [slot=%04x:%02x:%02x.%x]
> >   *   ]|
> >   *
> >   *   Filter allows device selection using vendor (hex or name), device id
> > @@ -117,6 +117,12 @@
> >   *
> >   *   It selects the second one.
> >   *
> > + *   Another possibility is to select device using a PCI slot:
> > + *
> > + *   |[<!-- language="plain" -->
> > + *   pci:slot=0000:01:00.0
> > + *   ]|
> > + *
> >   *   As order the on PCI bus doesn't change (unless you'll add new device or
> >   *   reorder existing one) device selection using this filter will always
> >   *   return you same device regardless the order of enumeration.
> > @@ -1138,6 +1144,7 @@ struct filter {
> >  		char *vendor;
> >  		char *device;
> >  		char *card;
> > +		char *slot;
> >  		char *drm;
> >  		char *driver;
> >  	} data;
> > @@ -1154,6 +1161,7 @@ static void fill_filter_data(struct filter *filter, const
> char *key, const char
> >  	__fill_key(vendor);
> >  	__fill_key(device);
> >  	__fill_key(card);
> > +	__fill_key(slot);
> >  	__fill_key(drm);
> >  	__fill_key(driver);
> >  #undef __fill_key
> > @@ -1271,6 +1279,10 @@ static struct igt_list_head *filter_pci(const struct
> filter_class *fcls,
> >  		if (!is_pci_subsystem(dev))
> >  			continue;
> >
> > +		/* Skip if 'slot' doesn't match */
> > +		if (filter->data.slot && !strequal(filter->data.slot, dev-
> >pci_slot_name))
> > +			continue;
> > +
> 
> selector - pci:[vendor=%04x/name][,device=%04x][,card=%d] |
> [slot=%04x:%02x:%02x.%x]
> 
> According to pci selector I assume you want to have:
> 
> 1. pci:vendor=...,device=...
> 
> or
> 
> 2. pci:slot=xxxx:xx:xx.x
> 
> So slot should be exclusive and no vendor/device/card parameters should be
> allowed and vice versa.
> 
> Now I'm able to pass:
> 
> pci:slot=0000:00:02.0,vendor=8081
> 
> but I expect vendor check shouldn't be processed here (passing slot gives
> you explicit device and according to selector description these two are
> exclusive).
> 
> So - disable vendor/device/card if slot is used and slot when
> vendor/device/card are used. I think you even should exit with an error in
> such case.

Thanks for comments. I've fixed it and sent next revision.

--
Łukasz
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Sowackiego 173 | 80-298 Gdask | Sd Rejonowy Gdask Pnoc | VII Wydzia Gospodarczy Krajowego Rejestru Sdowego - KRS 101882 | NIP 957-07-52-316 | Kapita zakadowy 200.000 PLN.
Ta wiadomo wraz z zacznikami jest przeznaczona dla okrelonego adresata i moe zawiera informacje poufne. W razie przypadkowego otrzymania tej wiadomoci, prosimy o powiadomienie nadawcy oraz trwae jej usunicie; jakiekolwiek przegldanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
 


More information about the igt-dev mailing list