Skip to contentSkip to conversation

drm/i915: remove IS_ERR_OR_NULL check

PATCH In review Matthew Auld 4 participants 10 messages Apr 8, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/i915: remove IS_ERR_OR_NULL check

A call to i915_gem_alloc_object can only ever return NULL in the event of an error.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index b342f67..84db11a 100644
@@ -5336,7 +5336,7 @@ i915_gem_object_create_from_data(struct drm_device *dev,
 	int ret;
 
 	obj = i915_gem_alloc_object(dev, round_up(size, PAGE_SIZE));
-	if (IS_ERR_OR_NULL(obj))
+	if (!obj)
 		return obj;
 
 	ret = i915_gem_object_set_to_cpu_domain(obj, true);
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/6 drm/i915: reference ppgtt->base.dev directly

Remove dev local and use to_i915() in gen8_ppgtt_notify_vgt.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -3
index da6e3a5..066d5aead 100644
@@ -905,11 +905,10 @@ static int gen8_init_scratch(struct i915_address_space *vm)
 static int gen8_ppgtt_notify_vgt(struct i915_hw_ppgtt *ppgtt, bool create)
 {
 	enum vgt_g2v_type msg;
-	struct drm_device *dev = ppgtt->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_private *dev_priv = to_i915(ppgtt->base.dev);
 	int i;
 
-	if (USES_FULL_48BIT_PPGTT(dev)) {
+	if (USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) {
 		u64 daddr = px_dma(&ppgtt->pml4);
 
 		I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr));
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#2 lore raw

Re: [PATCH 2/6] drm/i915: reference ppgtt->base.dev directly

Quoted 21 lines · Matthew Auld

Remove dev local and use to_i915() in gen8_ppgtt_notify_vgt.

Cc Joonas Lahtinen <[email protected]>

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 5 ++---

 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -2
index da6e3a5..066d5aead 100644
@@ -905,11 +905,10 @@ static int gen8_init_scratch(struct i915_address_space *vm)
  static int gen8_ppgtt_notify_vgt(struct i915_hw_ppgtt *ppgtt, bool create)
  {
  	enum vgt_g2v_type msg;
-	struct drm_device *dev = ppgtt->base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_private *dev_priv = to_i915(ppgtt->base.dev);
  	int i;

drivers/gpu/drm/i915/i915_gem_gtt.c static int gen8_init_scratch(struct i915_address_space *vm) · line 911

Quoted 2 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
-	if (USES_FULL_48BIT_PPGTT(dev)) {
+	if (USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) {

All the QUESTION_MACROS() want dev_priv (they can figure it out from dev too), so just pass it directly when it is available.

Regards, Joonas

Quoted 3 lines

  u64 daddr = px_dma(&ppgtt->pml4);

  I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr));

Signature · 7 lines
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/6 drm/i915: combine overflow checks

In reply to Matthew Auld

Looks a little neater and ever so slightly reduces the size of the binary.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -4
index 066d5aead..180dbd8 100644
@@ -1223,10 +1223,7 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,
 	/* Wrap is never okay since we can only represent 48b, and we don't
 	 * actually use the other side of the canonical address space.
 	 */
-	if (WARN_ON(start + length < start))
-		return -ENODEV;
-
-	if (WARN_ON(start + length > vm->total))
+	if (WARN_ON(start > vm->total || length > vm->total - start))
 		return -ENODEV;
 
 	ret = alloc_gen8_temp_bitmaps(&new_page_dirs, &new_page_tables, pdpes);
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 4/6 drm/i915: handle potential overflow

In reply to Matthew Auld

Much like with the equivalent gen8_alloc_va_range.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
index 180dbd8..5589a8d 100644
@@ -1857,7 +1857,8 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,
 	uint32_t pde, temp;
 	int ret;
 
-	if (WARN_ON(start_in + length_in > ppgtt->base.total))
+	if (WARN_ON(start_in > ppgtt->base.total || length_in >
+		    ppgtt->base.total - start_in))
 		return -ENODEV;
 
 	start = start_save = start_in;
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [PATCH 4/6] drm/i915: handle potential overflow

Quoted 1 line · Matthew Auld

Much like with the equivalent gen8_alloc_va_range.

Just delete the warn and make the allocation paths stronger if you feel paranoid.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH 5/6 drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT

In reply to Matthew Auld

If we are not in FULL_48BIT_PPGTT mode then we really shouldn't continue on with our allocations, given that the call to free_dpd would bail early without freeing everything, thus leaking memory.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
index 5589a8d..b0fa166 100644
@@ -569,7 +569,8 @@ i915_page_directory_pointer *alloc_pdp(struct drm_device *dev)
 	struct i915_page_directory_pointer *pdp;
 	int ret = -ENOMEM;
 
-	WARN_ON(!USES_FULL_48BIT_PPGTT(dev));
+	if (WARN_ON(!USES_FULL_48BIT_PPGTT(dev)))
+		return ERR_PTR(-EINVAL);
 
 	pdp = kzalloc(sizeof(*pdp), GFP_KERNEL);
 	if (!pdp)
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 6/6 drm/i915: call kunmap_px on pt_vaddr

In reply to Matthew Auld

We need to kunmap pt_vadrr and not pt itself, otherwise we end up mapping a bunch of pages without ever unmapping them.

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
index b0fa166..f426a66 100644
@@ -746,7 +746,7 @@ static void gen8_ppgtt_clear_pte_range(struct i915_address_space *vm,
 			num_entries--;
 		}
 
-		kunmap_px(ppgtt, pt);
+		kunmap_px(ppgtt, pt_vaddr);
 
 		pte = 0;
 		if (++pde == I915_PDES) {
Signature · 6 lines
2.4.11

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915: remove IS_ERR_OR_NULL check

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [1/6] drm/i915: remove IS_ERR_OR_NULL check
URL : https://patchwork.freedesktop.org/series/5453/
State : failure

== Summary ==

Series 5453v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/5453/revisions/1/mbox/

Test drv_getparams_basic:

        Subgroup basic-subslice-total:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test drv_module_reload_basic:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_basic:
        Subgroup bad-close:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup create-close:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup create-fd-close:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test gem_ctx_param_basic:
        Subgroup basic:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup invalid-ctx-set:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup invalid-param-get:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup invalid-param-set:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup root-set:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test gem_ctx_switch:
        Subgroup basic-default:
                skip       -> PASS       (bsw-nuc-2)
Test gem_exec_basic:
        Subgroup basic-blt:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup gtt-bsd:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup readonly-bsd:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup readonly-render:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup readonly-vebox:
                skip       -> PASS       (bsw-nuc-2)
Test gem_exec_store:
        Subgroup basic-bsd:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup basic-default:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup basic-vebox:
                skip       -> PASS       (bsw-nuc-2)
Test gem_exec_whisper:
        Subgroup basic:
                skip       -> PASS       (bsw-nuc-2)
Test gem_mmap:
        Subgroup basic-small-bo:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test gem_mmap_gtt:
        Subgroup basic-write:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup basic-write-gtt:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test gem_ringfill:
        Subgroup basic-default-hang:
                skip       -> PASS       (bsw-nuc-2)
Test gem_sync:
        Subgroup basic-blt:
                skip       -> PASS       (bsw-nuc-2)
        Subgroup basic-vebox:
                skip       -> PASS       (bsw-nuc-2)
Test gem_tiled_pread_basic:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test kms_addfb_basic:
        Subgroup addfb25-modifier-no-flag:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup addfb25-y-tiled:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup bad-pitch-65536:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup basic-x-tiled:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup framebuffer-vs-set-tiling:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup too-wide:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test kms_flip:
        Subgroup basic-flip-vs-wf_vblank:
                dmesg-fail -> PASS       (bsw-nuc-2)
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-c-frame-sequence:
                dmesg-fail -> PASS       (bsw-nuc-2)
        Subgroup suspend-read-crc-pipe-c:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test prime_self_import:
        Subgroup basic-with_fd_dup:
                dmesg-warn -> PASS       (bsw-nuc-2)
        Subgroup basic-with_one_bo_two_files:
                dmesg-warn -> PASS       (bsw-nuc-2)
bsw-nuc-2        total:196  pass:159  dwarn:0   dfail:0   fail:0   skip:37 
byt-nuc          total:196  pass:161  dwarn:0   dfail:0   fail:0   skip:35 
hsw-brixbox      total:196  pass:174  dwarn:0   dfail:0   fail:0   skip:22 
skl-i7k-2        total:196  pass:173  dwarn:0   dfail:0   fail:0   skip:23 
skl-nuci5        total:196  pass:185  dwarn:0   dfail:0   fail:0   skip:11 

BOOT FAILED for bdw-ultra
BOOT FAILED for hsw-gt2
BOOT FAILED for ilk-hp8440p
BOOT FAILED for ivb-t430s
BOOT FAILED for snb-x220t

Results at /archive/results/CI_IGT_test/Patchwork_1841/

851708c7e97537ed618fadbe5d342eaf8fa5146d drm-intel-nightly: 2016y-04m-07d-13h-56m-00s UTC integration manifest d1c691ef8fb989054ba0741ae602b3f4a6a5c0e1 drm/i915: call kunmap_px on pt_vaddr 7d49ab2650954a18622f0a75eea234738720d779 drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT 60619f8d0cb4b5b410532ffe350f5b04f60b2120 drm/i915: handle potential overflow 7744ec046199c77939db325caa51ce222c1abcfe drm/i915: combine overflow checks 4fe9ce09e4b19212e6d9208d8abd9ded86f1c773 drm/i915: reference ppgtt->base.dev directly 34c6258df91bea31087d433cdba547206b781da6 drm/i915: remove IS_ERR_OR_NULL check

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw
In reply to Matthew Auld
Quoted 2 lines · Matthew Auld

A call to i915_gem_alloc_object can only ever return NULL in the event of an error.

We are planning to report the real error back.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx