summaryrefslogtreecommitdiff
path: root/lib/igt_device_scan.c
diff options
context:
space:
mode:
authorŁukasz Łaguna <lukasz.laguna@intel.com>2021-01-05 14:35:38 +0100
committerKatarzyna Dec <katarzyna.dec@intel.com>2021-01-07 13:00:40 +0100
commit641e5545213dd9a82d80a4e065013a138afb58ff (patch)
treeb739c1d67a8c9db4f945d32d8045ec689b5d2b4e /lib/igt_device_scan.c
parentb7f4d346fc9a0a2c59e486326e07ad127c79b793 (diff)
lib/igt_device_scan: Add slot selector
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@intel.com> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Diffstat (limited to 'lib/igt_device_scan.c')
-rw-r--r--lib/igt_device_scan.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index b3b2bf4d..2b7d9a3a 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
@@ -1258,6 +1266,11 @@ static struct igt_list_head *filter_pci(const struct filter_class *fcls,
DBG("filter pci\n");
+ if (filter->data.slot && (filter->data.vendor || filter->data.device || filter->data.card)) {
+ fprintf(stderr, "Slot parameter can not be used with other parameters\n");
+ exit(EXIT_FAILURE);
+ }
+
if (filter->data.card) {
sscanf(filter->data.card, "%d", &card);
if (card < 0) {
@@ -1271,6 +1284,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;
+
/* Skip if 'vendor' doesn't match (hex or name) */
if (filter->data.vendor && !is_vendor_matched(dev, filter->data.vendor))
continue;
@@ -1325,7 +1342,7 @@ static struct filter_class filter_definition_list[] = {
{
.name = "pci",
.filter_function = filter_pci,
- .help = "pci:[vendor=%04x/name][,device=%04x][,card=%d]",
+ .help = "pci:[vendor=%04x/name][,device=%04x][,card=%d] | [slot=%04x:%02x:%02x.%x]",
.detail = "vendor is hex number or vendor name\n",
},
{