diff mbox

[igt,3/8] lib/igt_gt: has_gpu_reset(): fix failed assertion on non-i915 platforms

Message ID 1521125144-28614-4-git-send-email-ulrich.hecht+renesas@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Ulrich Hecht March 15, 2018, 2:45 p.m. UTC
Checks if we have an i915 device before using intel_get_drm_devid().

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
 lib/igt_gt.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

Comments

Ville Syrjälä March 15, 2018, 5:28 p.m. UTC | #1
On Thu, Mar 15, 2018 at 03:45:39PM +0100, Ulrich Hecht wrote:
> Checks if we have an i915 device before using intel_get_drm_devid().
> 
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> ---
>  lib/igt_gt.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_gt.c b/lib/igt_gt.c
> index e630550..9cb07c2 100644
> --- a/lib/igt_gt.c
> +++ b/lib/igt_gt.c

I would think igt_gt as a whole is pretty much i915 specific.
So feels to me like we should not have gotten this deep when
using another driver.

> @@ -59,14 +59,17 @@ static bool has_gpu_reset(int fd)
>  		struct drm_i915_getparam gp;
>  		int val = 0;
>  
> -		memset(&gp, 0, sizeof(gp));
> -		gp.param = 35; /* HAS_GPU_RESET */
> -		gp.value = &val;
> -
> -		if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
> -			once = intel_gen(intel_get_drm_devid(fd)) >= 5;
> -		else
> -			once = val > 0;
> +		if (is_i915_device(fd)) {
> +			memset(&gp, 0, sizeof(gp));
> +			gp.param = 35; /* HAS_GPU_RESET */
> +			gp.value = &val;
> +
> +			if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
> +				once = intel_gen(intel_get_drm_devid(fd)) >= 5;
> +			else
> +				once = val > 0;
> +		} else
> +			once = 0;
>  	}
>  	return once;
>  }
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter March 16, 2018, 8:46 a.m. UTC | #2
On Thu, Mar 15, 2018 at 07:28:53PM +0200, Ville Syrjälä wrote:
> On Thu, Mar 15, 2018 at 03:45:39PM +0100, Ulrich Hecht wrote:
> > Checks if we have an i915 device before using intel_get_drm_devid().
> > 
> > Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> > ---
> >  lib/igt_gt.c | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> > 
> > diff --git a/lib/igt_gt.c b/lib/igt_gt.c
> > index e630550..9cb07c2 100644
> > --- a/lib/igt_gt.c
> > +++ b/lib/igt_gt.c
> 
> I would think igt_gt as a whole is pretty much i915 specific.
> So feels to me like we should not have gotten this deep when
> using another driver.

Yeah all the gt stuff should be protected with igt_require(i915).
-Daniel

> 
> > @@ -59,14 +59,17 @@ static bool has_gpu_reset(int fd)
> >  		struct drm_i915_getparam gp;
> >  		int val = 0;
> >  
> > -		memset(&gp, 0, sizeof(gp));
> > -		gp.param = 35; /* HAS_GPU_RESET */
> > -		gp.value = &val;
> > -
> > -		if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
> > -			once = intel_gen(intel_get_drm_devid(fd)) >= 5;
> > -		else
> > -			once = val > 0;
> > +		if (is_i915_device(fd)) {
> > +			memset(&gp, 0, sizeof(gp));
> > +			gp.param = 35; /* HAS_GPU_RESET */
> > +			gp.value = &val;
> > +
> > +			if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
> > +				once = intel_gen(intel_get_drm_devid(fd)) >= 5;
> > +			else
> > +				once = val > 0;
> > +		} else
> > +			once = 0;
> >  	}
> >  	return once;
> >  }
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index e630550..9cb07c2 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -59,14 +59,17 @@  static bool has_gpu_reset(int fd)
 		struct drm_i915_getparam gp;
 		int val = 0;
 
-		memset(&gp, 0, sizeof(gp));
-		gp.param = 35; /* HAS_GPU_RESET */
-		gp.value = &val;
-
-		if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
-			once = intel_gen(intel_get_drm_devid(fd)) >= 5;
-		else
-			once = val > 0;
+		if (is_i915_device(fd)) {
+			memset(&gp, 0, sizeof(gp));
+			gp.param = 35; /* HAS_GPU_RESET */
+			gp.value = &val;
+
+			if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+				once = intel_gen(intel_get_drm_devid(fd)) >= 5;
+			else
+				once = val > 0;
+		} else
+			once = 0;
 	}
 	return once;
 }