From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F3B3C48291 for ; Thu, 1 Feb 2024 15:51:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 316CE10EAA7; Thu, 1 Feb 2024 15:51:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="UfPow1Go"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id E301A10EAA7 for ; Thu, 1 Feb 2024 15:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706802659; x=1738338659; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f46CR5uj2IqYo20x186XOCFldHZiGq7goV32KdXVLCo=; b=UfPow1GoxBwbJv9NLj4BPKPFY1DrMFrZecCWKKav1XFedoXHfj0niGou K7JAJZzGkgd4RcfA3JuaYQFBrOiHRvQX3qh8VodBcSp1sPErjzk7VQEfR wh6EoSzt+ybdaXZoDaHNg1ddTPQCk/SE+wuvschzBqxx2Lxx2R+sJPKJH d2thYkLZu7jB+WwTZQ2shHJeQsUCbJPI7nEGN0Y04GcRkUopBBI6JHzkX tEIATXbk8sa2Nt2bYJ2yo2NyAcVrV3aGe6d4W2H4nNg7eReVdAkuzEd+8 xXZULkEtFtEFMBxkHblyyjBrGzf59/aDeVFoCH/Jdzn7h09J4qXTQaQz8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="402768244" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="402768244" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 07:50:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="912158633" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="912158633" Received: from msterni-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.128]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 07:50:55 -0800 From: Kamil Konieczny To: igt-dev@lists.freedesktop.org Cc: =?UTF-8?q?Dominik=20Karol=20Pi=C4=85tkowski?= , Chris Wilson , Janusz Krzysztofik , Kamil Konieczny Subject: [PATCH i-g-t v6 1/8] lib/igt_device_scan: Introduce filtering out non-PCI devices Date: Thu, 1 Feb 2024 16:50:40 +0100 Message-ID: <20240201155047.48608-2-kamil.konieczny@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240201155047.48608-1-kamil.konieczny@linux.intel.com> References: <20240201155047.48608-1-kamil.konieczny@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" From: Dominik Karol PiÄ…tkowski Introduced igt_device_filter_pci function that filters out non-PCI devices from IGT devices. This will help with checking multi-GPU tests after they skip due to detected only one GPU, in that case one can verify it after printing what GPUs are really on PCI bus. Such errors can happen when using wrong env IGT_DEVICE filter. v6: extending description Cc: Chris Wilson Cc: Janusz Krzysztofik Signed-off-by: Dominik Karol PiÄ…tkowski Signed-off-by: Kamil Konieczny --- lib/igt_device_scan.c | 21 +++++++++++++++++++++ lib/igt_device_scan.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c index fbf3fa482..37ebe1964 100644 --- a/lib/igt_device_scan.c +++ b/lib/igt_device_scan.c @@ -1908,6 +1908,27 @@ const char *igt_device_filter_get(int num) return NULL; } +/** + * igt_device_filter_pci + * + * Filter devices to PCI only. + * + * Returns PCI devices count. + */ +int igt_device_filter_pci(void) +{ + int count = 0; + struct igt_device *dev, *tmp; + + igt_list_for_each_entry_safe(dev, tmp, &igt_devs.filtered, link) + if (strcmp(dev->subsystem, "pci") != 0) + igt_list_del(&dev->link); + else + count++; + + return count; +} + static bool igt_device_filter_apply(const char *fstr) { struct igt_device *dev, *tmp; diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h index 48690e236..908733745 100644 --- a/lib/igt_device_scan.h +++ b/lib/igt_device_scan.h @@ -81,6 +81,8 @@ int igt_device_filter_add(const char *filter); void igt_device_filter_free_all(void); const char *igt_device_filter_get(int num); +int igt_device_filter_pci(void); + /* 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, -- 2.42.0