Re: [PATCH igt] lib: Avoid actually throttling from igt_require_gem()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Chris Wilson (2017-08-18 11:46:19)
> igt_require_gem() checks whether we can use the i915 fd for submitting
> requests by detecting a wedged driver. It was intended to be used just
> after opening DRIVER_INTEL for a gem test to provide an early skip if
> the device was unusable. However, it is also used at the start of
> library functions like igt_spin_batch_new() which may be called after
> the test has setup some state, and importantly submitted some batches.
> igt_require_gem() has the risk of then waiting on those batches, unless
> we tell it to use a clean fd.
> 
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
> ---
>  lib/drmtest.c        | 37 +++++++++++++++++++++++++++++++++++++
>  lib/ioctl_wrappers.c |  8 ++++++++
>  2 files changed, 45 insertions(+)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 158af682..0f8bd604 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -318,6 +318,43 @@ static int __drm_open_driver_render(int chipset)
>         return fd;
>  }
>  
> +int __drm_reopen_driver(int fd)
> +{
> +       struct stat target;
> +       const char *base;
> +       int offset;
> +
> +       if (fstat(fd, &target))
> +               return -errno;
> +
> +       if (target.st_rdev & 0x80) { /* render node */
> +               base = "/dev/dri/renderD%d";
> +               offset = 0x80;
> +       } else {
> +               base = "/dev/dri/card%d";
> +               offset = 0;
> +       }
> +
> +       for (int i = 0; i < 16; i++) {
> +               struct stat st;
> +               char buf[256];
> +
> +               snprintf(buf, sizeof(buf), base, i + offset);
> +               fd = open(buf, O_RDWR);
> +               if (fd < 0)
> +                       continue;
> +
> +               if (fstat(fd, &st) == 0 &&
> +                   st.st_mode == target.st_mode &&
> +                   st.st_rdev == target.st_rdev)
> +                       return fd;

Or should we try a readlink of /proc/self/fd/$fd?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux