[igt-dev] [PATCH i-g-t v2 2/2] lib/igt_device_scan: Return true from igt_device_find_first_i915_discrete_card()

Lyude Paul lyude at redhat.com
Wed Nov 4 22:20:58 UTC 2020


On Tue, 2020-11-03 at 10:01 +0200, Petri Latvala wrote:
> On Fri, Oct 09, 2020 at 01:50:57PM -0400, Lyude wrote:
> > From: Lyude Paul <lyude at 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 at redhat.com>
> > Cc: Zbigniew Kempczyński <zbigniew.kempczynski at 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");
> > +       }
> 
> 
> This commit has introduced a bug where intel_gpu_top no longer works
> with an integrated gpu unless you specify filters. Is this missing a
> fallback-to-integrated logic somewhere?


yes it is-sorry about that! someone submitted some patches for this so I'm going
to check it asap
> 
> 

-- 
Sincerely,
   Lyude Paul (she/her)
   Software Engineer at Red Hat
   
Note: I deal with a lot of emails and have a lot of bugs on my plate. If you've
asked me a question, are waiting for a review/merge on a patch, etc. and I
haven't responded in a while, please feel free to send me another email to check
on my status. I don't bite!



More information about the igt-dev mailing list