From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v3 2/2] lib/igt_device_scan: add card=all filter selector
Date: Wed, 9 Nov 2022 14:50:16 +0100 [thread overview]
Message-ID: <20221109135016.28889-3-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20221109135016.28889-1-kamil.konieczny@linux.intel.com>
Allow to select all discrete cards on system with the help of
card=all or card=* filter, for example:
pci:vendor=intel,device=discrete,card=all
or
pci:vendor=intel,device=discrete,card=*
This will add max of 64 cards filters with card=0..63 but will
stop adding at card index not present on system. If no card will
match only one filter for card=0 will be added.
v2: increase number of filters from 16 to 64, add stopper for
non-matching card to avoid filter splat (Petri)
v3: improve documentation
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
lib/igt_device_scan.c | 46 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 6f5b90e6..02aa5064 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -120,6 +120,15 @@
*
* It selects the second one.
*
+ * |[<!-- language="plain" -->
+ * pci:vendor=8086,device=1234,card=all
+ * pci:vendor=8086,device=1234,card=*
+ * ]|
+ *
+ * This will add 0..N card selectors, where 0 <= N <= 63. At least one
+ * filter will be added with card=0 and all incrementally matched ones
+ * up to max numbered 63 (max total 64).
+ *
* We may use device codename or pseudo-codename (integrated/discrete)
* instead of pci device id:
*
@@ -1753,6 +1762,8 @@ static bool is_filter_valid(const char *fstr)
return true;
}
+#define MAX_PCI_CARDS 64
+
/**
* igt_device_filter_add
* @filters: filter(s) to be stored in filter array
@@ -1776,14 +1787,43 @@ int igt_device_filter_add(const char *filters)
while ((filter = strsep(&dup, ";"))) {
bool is_valid = is_filter_valid(filter);
struct device_filter *df;
+ char *multi;
+
igt_warn_on(!is_valid);
if (!is_valid)
continue;
df = malloc(sizeof(*df));
- strncpy(df->filter, filter, sizeof(df->filter)-1);
- igt_list_add_tail(&df->link, &device_filters);
- count++;
+ if (!strncmp(filter, "sriov:", 6)) {
+ multi = NULL;
+ } else {
+ multi = strstr(filter, "card=all");
+ if (!multi)
+ multi = strstr(filter, "card=*");
+ }
+
+ if (!multi) {
+ strncpy(df->filter, filter, sizeof(df->filter)-1);
+ igt_list_add_tail(&df->link, &device_filters);
+ count++;
+ } else {
+ multi[5] = 0;
+ for (int i = 0; i < MAX_PCI_CARDS; ++i) {
+ if (i) {
+ struct igt_device_card card;
+
+ if (!igt_device_card_match(filter, &card))
+ break;
+
+ df = malloc(sizeof(*df));
+ }
+
+ /* add at least card=0 */
+ snprintf(df->filter, sizeof(df->filter)-1, "%s%d", filter, i);
+ igt_list_add_tail(&df->link, &device_filters);
+ count++;
+ }
+ }
}
free(dup_orig);
--
2.34.1
next prev parent reply other threads:[~2022-11-09 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 13:50 [igt-dev] [PATCH i-g-t v3 0/2] lib/igt_device_scan: add filer card=all Kamil Konieczny
2022-11-09 13:50 ` [igt-dev] [PATCH i-g-t v3 1/2] lib/igt_device_scan: refactor filter adding Kamil Konieczny
2022-11-09 13:50 ` Kamil Konieczny [this message]
2022-11-09 15:45 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_device_scan: add filer card=all (rev3) Patchwork
2022-11-09 20:18 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20221109135016.28889-3-kamil.konieczny@linux.intel.com \
--to=kamil.konieczny@linux.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