Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lyude <lyude@redhat.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 2/2] lib/igt_device_scan: Return true from igt_device_find_first_i915_discrete_card()
Date: Fri,  9 Oct 2020 13:50:57 -0400	[thread overview]
Message-ID: <20201009175057.3336447-2-lyude@redhat.com> (raw)
In-Reply-To: <20201009175057.3336447-1-lyude@redhat.com>

From: Lyude Paul <lyude@redhat.com>

So that we can also print a relevant error message when failing to find any devices in
intel_gpu_top.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 lib/igt_device_scan.c |  6 ++++--
 lib/igt_device_scan.h |  2 +-
 tools/intel_gpu_top.c | 15 +++++++++------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index d77311a4..f4d43c73 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -449,7 +449,7 @@ __copy_dev_to_card(struct igt_device *dev, struct igt_device_card *card)
  * Iterate over all igt_devices array and find first discrete card.
  * card->pci_slot_name will be updated only if a discrete card is present.
  */
-void igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
+bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
 {
 	struct igt_device *dev;
 
@@ -462,9 +462,11 @@ void igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
 
 		if ((strncmp(dev->pci_slot_name, INTEGRATED_I915_GPU_PCI_ID, PCI_SLOT_NAME_SIZE)) != 0) {
 			__copy_dev_to_card(dev, card);
-			break;
+			return true;
 		}
 	}
+
+	return false;
 }
 
 static struct igt_device *igt_device_from_syspath(const char *syspath)
diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
index 9ed73958..bd937d22 100644
--- a/lib/igt_device_scan.h
+++ b/lib/igt_device_scan.h
@@ -68,7 +68,7 @@ const char *igt_device_filter_get(int num);
 
 /* Use filter to match the device and fill card structure */
 bool igt_device_card_match(const char *filter, struct igt_device_card *card);
-void igt_device_find_first_i915_discrete_card(struct igt_device_card *card);
+bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card);
 int igt_open_card(struct igt_device_card *card);
 int igt_open_render(struct igt_device_card *card);
 
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index cae01c25..79a936ff 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -1394,15 +1394,18 @@ int main(int argc, char **argv)
 
 	if (opt_device != NULL) {
 		ret = igt_device_card_match(opt_device, &card);
-		if (!ret) {
+		if (!ret)
 			fprintf(stderr, "Requested device %s not found!\n", opt_device);
-			free(opt_device);
-			ret = EXIT_FAILURE;
-			goto exit;
-		}
 		free(opt_device);
 	} else {
-		igt_device_find_first_i915_discrete_card(&card);
+		ret = igt_device_find_first_i915_discrete_card(&card);
+		if (!ret)
+			fprintf(stderr, "No device filter specified and no discrete i915 devices found\n");
+	}
+
+	if (!ret) {
+		ret = EXIT_FAILURE;
+		goto exit;
 	}
 
 	if (card.pci_slot_name[0] && !is_igpu_pci(card.pci_slot_name))
-- 
2.26.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-10-09 17:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 17:50 [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_device_scan: init card in igt_device_find_first_i915_discrete_card() Lyude
2020-10-09 17:50 ` Lyude [this message]
2020-10-12  7:31   ` [igt-dev] [PATCH i-g-t v2 2/2] lib/igt_device_scan: Return true from igt_device_find_first_i915_discrete_card() Zbigniew Kempczyński
2020-11-03  8:01   ` Petri Latvala
2020-11-04 22:20     ` Lyude Paul
2020-10-09 18:34 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/2] lib/igt_device_scan: init card in igt_device_find_first_i915_discrete_card() Patchwork
2020-10-09 20:34 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-10-09 22:22 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/2] lib/igt_device_scan: init card in igt_device_find_first_i915_discrete_card() (rev2) Patchwork
2020-10-10  5:24 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20201009175057.3336447-2-lyude@redhat.com \
    --to=lyude@redhat.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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