[igt-dev] [PATCH i-g-t 2/2] lib/igt_device_scan: Select intel as default vendor for intel_gpu_top

Ayaz A Siddiqui ayaz.siddiqui at intel.com
Fri Oct 23 17:51:58 UTC 2020


intel_gpu_top is selecting first discrete device as default drm subsystem.
In case of multi-gpu system if the first device is not intel gpu
then it will lead to an error while running intel_gpu_top.

Signed-off-by: Ayaz A Siddiqui <ayaz.siddiqui at intel.com>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Zbigniew Kempczynski <zbigniew.kempczynski at intel.com>
Cc: Dixit Ashutosh <ashutosh.dixit at intel.com>
---
 lib/igt_device_scan.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 55aa8159d..0967c6450 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -426,6 +426,25 @@ static struct igt_device *igt_device_find(const char *subsystem,
 	return NULL;
 }
 
+static bool is_vendor_matched(struct igt_device *dev, const char *vendor)
+{
+	const char *vendor_id;
+
+	if (!dev->vendor || !vendor)
+		return false;
+
+	/* First we compare vendor id, like 8086 */
+	if (!strcasecmp(dev->vendor, vendor))
+		return true;
+
+	/* Likely we have vendor string instead of id */
+	vendor_id = get_pci_vendor_id_by_name(vendor);
+	if (!vendor_id)
+		return false;
+
+	return !strcasecmp(dev->vendor, vendor_id);
+}
+
 static void
 __copy_dev_to_card(struct igt_device *dev, struct igt_device_card *card)
 {
@@ -457,7 +476,7 @@ bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
 
 	igt_list_for_each_entry(dev, &igt_devs.all, link) {
 
-		if (!is_pci_subsystem(dev))
+		if (!is_pci_subsystem(dev) || !is_vendor_matched(dev, "intel"))
 			continue;
 
 		if ((strncmp(dev->pci_slot_name, INTEGRATED_I915_GPU_PCI_ID, PCI_SLOT_NAME_SIZE)) != 0) {
@@ -893,25 +912,6 @@ static bool parse_filter(const char *fstr, struct filter *filter)
 	return false;
 }
 
-static bool is_vendor_matched(struct igt_device *dev, const char *vendor)
-{
-	const char *vendor_id;
-
-	if (!dev->vendor || !vendor)
-		return false;
-
-	/* First we compare vendor id, like 8086 */
-	if (!strcasecmp(dev->vendor, vendor))
-		return true;
-
-	/* Likely we have vendor string instead of id */
-	vendor_id = get_pci_vendor_id_by_name(vendor);
-	if (!vendor_id)
-		return false;
-
-	return !strcasecmp(dev->vendor, vendor_id);
-}
-
 /* Filter which matches subsystem:/sys/... path.
  * Used as first filter in chain.
  */
-- 
2.26.2



More information about the igt-dev mailing list