Skip to contentSkip to conversation

drm/xen-front: Fix mmap attributes for display buffers

PATCH In review Oleksandr Andrushchenko 3 participants 8 messages Jan 29, 2019 – Feb 4, 2019

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

PATCH 1/1 drm/xen-front: Fix mmap attributes for display buffers

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
---
 drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +2 -3
index d303a2e17f5e..9d5c03d7668d 100644
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object *xen_obj,
 	vma->vm_flags &= ~VM_PFNMAP;
 	vma->vm_flags |= VM_MIXEDMAP;
 	vma->vm_pgoff = 0;
-	vma->vm_page_prot =
-			pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 
 	/*
 	 * vm_operations_struct.fault handler will be called if CPU access
@@ -283,7 +282,7 @@ void *xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj)
 		return NULL;
 
 	return vmap(xen_obj->pages, xen_obj->num_pages,
-		    VM_MAP, pgprot_writecombine(PAGE_KERNEL));
+		    VM_MAP, PAGE_KERNEL);
 }
 
 void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw

Hi Oleksandr,

Quoted 20 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 6 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object *xen_obj,
  	vma->vm_flags &= ~VM_PFNMAP;
  	vma->vm_flags |= VM_MIXEDMAP;
  	vma->vm_pgoff = 0;
-	vma->vm_page_prot =
-			pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

With the comment updated:

Cheers,

Signature · 1 line
Julien Grall
Acked-by on v1 1/1
#7 lore raw
In reply to Oleksandr Andrushchenko

Hi Oleksandr,

Quoted 20 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 6 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object *xen_obj,
  	vma->vm_flags &= ~VM_PFNMAP;
  	vma->vm_flags |= VM_MIXEDMAP;
  	vma->vm_pgoff = 0;
-	vma->vm_page_prot =
-			pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

With the comment updated:

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
In reply to Julien Grall
Quoted 29 lines · Julien Grall

Hi Oleksandr,

Quoted 26 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Signed-off-by: Oleksandr Andrushchenko
<[email protected]>

---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---

  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object 
 *xen_obj,
       vma->vm_flags &= ~VM_PFNMAP;
       vma->vm_flags |= VM_MIXEDMAP;
Quoted 9 lines

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 4 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
       vma->vm_pgoff = 0;
-    vma->vm_page_prot =
- pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+    vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

Ok, then I'll put:

+       /*
+        * According to Xen on ARM ABI (xen/include/public/arch-arm.h):
+        * all memory which is shared with other entities in the system +        * (including the hypervisor and other guests) must reside in memory +        * which is mapped as Normal Inner Write-Back Outer Write-Back +        * Inner-Shareable.
+        */
        vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
Please let me know if this is not what you want

Quoted 6 lines

With the comment updated:

Cheers,

Thank you,
Oleksandr

#5 lore raw
In reply to Julien Grall
Quoted 29 lines · Julien Grall

Hi Oleksandr,

Quoted 26 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Signed-off-by: Oleksandr Andrushchenko
<[email protected]>

---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---

  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object 
 *xen_obj,
       vma->vm_flags &= ~VM_PFNMAP;
       vma->vm_flags |= VM_MIXEDMAP;
Quoted 9 lines

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 4 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
       vma->vm_pgoff = 0;
-    vma->vm_page_prot =
- pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+    vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

Ok, then I'll put:

+       /*
+        * According to Xen on ARM ABI (xen/include/public/arch-arm.h):
+        * all memory which is shared with other entities in the system +        * (including the hypervisor and other guests) must reside in memory +        * which is mapped as Normal Inner Write-Back Outer Write-Back +        * Inner-Shareable.
+        */
        vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
Please let me know if this is not what you want

Quoted 6 lines

With the comment updated:

Cheers,

Thank you,
Oleksandr
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Oleksandr Andrushchenko
Quoted 41 lines · Oleksandr Andrushchenko
Quoted 29 lines · Julien Grall

Hi Oleksandr,

Quoted 26 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Signed-off-by: Oleksandr Andrushchenko
<[email protected]>

---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---

  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object 
 *xen_obj,
       vma->vm_flags &= ~VM_PFNMAP;
       vma->vm_flags |= VM_MIXEDMAP;
Quoted 9 lines

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 4 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
       vma->vm_pgoff = 0;
-    vma->vm_page_prot =
- pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+    vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

Ok, then I'll put:

Quoted 14 lines

+       /*
+        * According to Xen on ARM ABI (xen/include/public/arch-arm.h):
+        * all memory which is shared with other entities in the system +        * (including the hypervisor and other guests) must reside in memory
+        * which is mapped as Normal Inner Write-Back Outer Write-Back +        * Inner-Shareable.
+        */
        vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); Please let me know if this is not what you want

Quoted 4 lines

With the comment updated:

If nobody objects I'll apply this to drm-misc-fixes next Monday

Quoted 4 lines
Quoted 2 lines

Cheers,

Thank you,
Oleksandr

#4 lore raw
In reply to Oleksandr Andrushchenko
Quoted 41 lines · Oleksandr Andrushchenko
Quoted 29 lines · Julien Grall

Hi Oleksandr,

Quoted 26 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Signed-off-by: Oleksandr Andrushchenko
<[email protected]>

---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---

  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object 
 *xen_obj,
       vma->vm_flags &= ~VM_PFNMAP;
       vma->vm_flags |= VM_MIXEDMAP;
Quoted 9 lines

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object *xen_obj, · line 238

Quoted 4 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
       vma->vm_pgoff = 0;
-    vma->vm_page_prot =
- pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+    vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

Ok, then I'll put:

Quoted 14 lines

+       /*
+        * According to Xen on ARM ABI (xen/include/public/arch-arm.h):
+        * all memory which is shared with other entities in the system +        * (including the hypervisor and other guests) must reside in memory
+        * which is mapped as Normal Inner Write-Back Outer Write-Back +        * Inner-Shareable.
+        */
        vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); Please let me know if this is not what you want

Quoted 4 lines

With the comment updated:

If nobody objects I'll apply this to drm-misc-fixes next Monday

Quoted 4 lines
Quoted 2 lines

Cheers,

Thank you,
Oleksandr

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Julien Grall
Quoted 38 lines · Julien Grall

Hi Oleksandr,

Quoted 23 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

When GEM backing storage is allocated those are normal pages, so there is no point using pgprot_writecombine while mmaping. This fixes mismatch of buffer pages' memory attributes between the frontend and backend which may cause screen artifacts.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Signed-off-by: Oleksandr Andrushchenko
<[email protected]>

---
  drivers/gpu/drm/xen/xen_drm_front_gem.c | 5 ++---

  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/xen/xen_drm_front_gem.c +0 -0
index d303a2e17f5e..9d5c03d7668d 100644

drivers/gpu/drm/xen/xen_drm_front_gem.c static int gem_mmap_obj(struct xen_gem_object · line 239

Quoted 7 lines
drivers/gpu/drm/xen/xen_drm_front_gem.c +1 -2
@@ -235,8 +235,7 @@ static int gem_mmap_obj(struct xen_gem_object 
 *xen_obj,
       vma->vm_flags &= ~VM_PFNMAP;
       vma->vm_flags |= VM_MIXEDMAP;
       vma->vm_pgoff = 0;
-    vma->vm_page_prot =
- pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+    vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);

The patch looks good to me. It would be worth expanding the comment a bit before to explain that we overwrite vm_page_prot to use cacheable attribute as required by the Xen ABI.

Quoted 6 lines

With the comment updated:

Cheers,

Applied to drm-misc-next
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel