diff mbox

[2/4] drm/i915/gtt: Warn if the next layer scratch dma is invalid

Message ID 1435677400-7630-2-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala June 30, 2015, 3:16 p.m. UTC
When dma page is setup, warn if we try to point the entries
to a uninitialized (zero) dma address. Like we do with gen6

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Michel Thierry June 30, 2015, 4:59 p.m. UTC | #1
On 6/30/2015 4:16 PM, Mika Kuoppala wrote:
> When dma page is setup, warn if we try to point the entries
> to a uninitialized (zero) dma address. Like we do with gen6

Reviewed-by: Michel Thierry <michel.thierry@intel.com>

[Mental note to add the same in the future pdp initialize function].

>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 23f5896..78bfb88 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -427,6 +427,8 @@ static void gen8_initialize_pt(struct i915_address_space *vm,
>   {
>   	gen8_pte_t scratch_pte;
>
> +	WARN_ON(px_dma(vm->scratch_page) == 0);
> +
>   	scratch_pte = gen8_pte_encode(px_dma(vm->scratch_page),
>   				      I915_CACHE_LLC, true);
>
> @@ -488,6 +490,8 @@ static void gen8_initialize_pd(struct i915_address_space *vm,
>   {
>   	gen8_pde_t scratch_pde;
>
> +	WARN_ON(px_dma(vm->scratch_pt) == 0);
> +
>   	scratch_pde = gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC);
>
>   	fill_px(vm->dev, pd, scratch_pde);
>
Chris Wilson June 30, 2015, 5:11 p.m. UTC | #2
On Tue, Jun 30, 2015 at 05:59:27PM +0100, Michel Thierry wrote:
> On 6/30/2015 4:16 PM, Mika Kuoppala wrote:
> >When dma page is setup, warn if we try to point the entries
> >to a uninitialized (zero) dma address. Like we do with gen6

Just a note that 0 looks only to be reserved due to a quirk of the
intel-iommu implementation. There is nothing preventing a different
iommu or future implementation using 0 as a valid dma_addr_t afaict.

This should presumably be
WARN_ON(dma_mapping_error(&dev->pdev->dev, px_dma()));
-Chris
Mika Kuoppala July 1, 2015, 10:55 a.m. UTC | #3
Chris Wilson <chris@chris-wilson.co.uk> writes:

> On Tue, Jun 30, 2015 at 05:59:27PM +0100, Michel Thierry wrote:
>> On 6/30/2015 4:16 PM, Mika Kuoppala wrote:
>> >When dma page is setup, warn if we try to point the entries
>> >to a uninitialized (zero) dma address. Like we do with gen6
>
> Just a note that 0 looks only to be reserved due to a quirk of the
> intel-iommu implementation. There is nothing preventing a different
> iommu or future implementation using 0 as a valid dma_addr_t afaict.
>
> This should presumably be
> WARN_ON(dma_mapping_error(&dev->pdev->dev, px_dma()));
> -Chris
>

Ah yes. This was my paranoia from the times we updated
execlists pdps with zero dma addresses.

Michel pointed out that we do a proper dma_mapping_error 
check when we allocate the dma page. So I think this patch
can be ignored.

-Mika

> -- 
> Chris Wilson, Intel Open Source Technology Centre
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 23f5896..78bfb88 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -427,6 +427,8 @@  static void gen8_initialize_pt(struct i915_address_space *vm,
 {
 	gen8_pte_t scratch_pte;
 
+	WARN_ON(px_dma(vm->scratch_page) == 0);
+
 	scratch_pte = gen8_pte_encode(px_dma(vm->scratch_page),
 				      I915_CACHE_LLC, true);
 
@@ -488,6 +490,8 @@  static void gen8_initialize_pd(struct i915_address_space *vm,
 {
 	gen8_pde_t scratch_pde;
 
+	WARN_ON(px_dma(vm->scratch_pt) == 0);
+
 	scratch_pde = gen8_pde_encode(px_dma(vm->scratch_pt), I915_CACHE_LLC);
 
 	fill_px(vm->dev, pd, scratch_pde);