[3/5] drm/i915/selftests: Be explicit in ERR_PTR handling
diff mbox series

Message ID 20191114225736.616885-3-chris@chris-wilson.co.uk
State New
Headers show
Series
  • [1/5] drm/i915/gt: Wait for new requests in intel_gt_retire_requests()
Related show

Commit Message

Chris Wilson Nov. 14, 2019, 10:57 p.m. UTC
When setting up a full GGTT, we expect the next insert to fail with
-ENOSPC. Simplify the use of ERR_PTR to not confuse either the reader or
smatch.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
References: f40a7b7558ef ("drm/i915: Initial selftests for exercising eviction")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/selftest_rc6.c          | 9 +++++++--
 drivers/gpu/drm/i915/selftests/i915_gem_evict.c | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Tvrtko Ursulin Nov. 15, 2019, 12:47 p.m. UTC | #1
On 14/11/2019 22:57, Chris Wilson wrote:
> When setting up a full GGTT, we expect the next insert to fail with
> -ENOSPC. Simplify the use of ERR_PTR to not confuse either the reader or
> smatch.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> References: f40a7b7558ef ("drm/i915: Initial selftests for exercising eviction")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/gt/selftest_rc6.c          | 9 +++++++--
>   drivers/gpu/drm/i915/selftests/i915_gem_evict.c | 4 ++--
>   2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_rc6.c b/drivers/gpu/drm/i915/gt/selftest_rc6.c
> index 6b4cb5c7d446..35516d4699d2 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_rc6.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_rc6.c
> @@ -116,11 +116,16 @@ int live_rc6_ctx(void *arg)
>   				goto out;
>   			}
>   
> -			intel_gt_retire_requests(gt);
> -			intel_gt_pm_wait_for_idle(gt);
> +			if (intel_gt_wait_for_idle(gt, HZ / 5) == -ETIME) {
> +				intel_gt_set_wedged(gt);
> +				err = -ETIME;
> +				goto out;
> +			}
>   
> +			intel_gt_pm_wait_for_idle(gt);
>   			pr_debug("%s: CTX_INFO=%0x\n",
>   				 engine->name, READ_ONCE(*res));
> +

This hunk does not relate to the fix.

Regards,

Tvrtko

>   			if (resets !=
>   			    i915_reset_engine_count(&gt->i915->gpu_error,
>   						    engine)) {
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> index 5f133d177212..06ef88510209 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> @@ -198,8 +198,8 @@ static int igt_overcommit(void *arg)
>   	quirk_add(obj, &objects);
>   
>   	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
> -	if (!IS_ERR(vma) || PTR_ERR(vma) != -ENOSPC) {
> -		pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR(vma));
> +	if (vma != ERR_PTR(-ENOSPC)) {
> +		pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR_OR_ZERO(vma));
>   		err = -EINVAL;
>   		goto cleanup;
>   	}
>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/selftest_rc6.c b/drivers/gpu/drm/i915/gt/selftest_rc6.c
index 6b4cb5c7d446..35516d4699d2 100644
--- a/drivers/gpu/drm/i915/gt/selftest_rc6.c
+++ b/drivers/gpu/drm/i915/gt/selftest_rc6.c
@@ -116,11 +116,16 @@  int live_rc6_ctx(void *arg)
 				goto out;
 			}
 
-			intel_gt_retire_requests(gt);
-			intel_gt_pm_wait_for_idle(gt);
+			if (intel_gt_wait_for_idle(gt, HZ / 5) == -ETIME) {
+				intel_gt_set_wedged(gt);
+				err = -ETIME;
+				goto out;
+			}
 
+			intel_gt_pm_wait_for_idle(gt);
 			pr_debug("%s: CTX_INFO=%0x\n",
 				 engine->name, READ_ONCE(*res));
+
 			if (resets !=
 			    i915_reset_engine_count(&gt->i915->gpu_error,
 						    engine)) {
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
index 5f133d177212..06ef88510209 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
@@ -198,8 +198,8 @@  static int igt_overcommit(void *arg)
 	quirk_add(obj, &objects);
 
 	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
-	if (!IS_ERR(vma) || PTR_ERR(vma) != -ENOSPC) {
-		pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR(vma));
+	if (vma != ERR_PTR(-ENOSPC)) {
+		pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR_OR_ZERO(vma));
 		err = -EINVAL;
 		goto cleanup;
 	}