Re: [PATCH xf86-video-ati v2 1/3] Use root window (pixmap) instead of screen pixmap for scanout updates

2017-08-01 Thread Alex Deucher
On Tue, Aug 1, 2017 at 5:19 AM, Michel Dänzer  wrote:
> From: Michel Dänzer 
>
> Preparation for following changes, no functional change intended yet.
>
> Reviewed-by: Alex Deucher  # v1
> Signed-off-by: Michel Dänzer 
> ---
>
> v2: Add drmmode_screen_damage_destroy to prevent use-after-free on
> server shutdown

Reviewed-by: Alex Deucher 

>
>  src/drmmode_display.c | 21 ++---
>  src/radeon_kms.c  |  2 +-
>  2 files changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 245a92fb0..309ccbd6d 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -529,11 +529,8 @@ drmmode_crtc_scanout_free(drmmode_crtc_private_ptr 
> drmmode_crtc)
>  _crtc->scanout[1]);
> }
>
> -   if (drmmode_crtc->scanout_damage) {
> +   if (drmmode_crtc->scanout_damage)
> DamageDestroy(drmmode_crtc->scanout_damage);
> -   drmmode_crtc->scanout_damage = NULL;
> -   RegionUninit(_crtc->scanout_last_region);
> -   }
>  }
>
>  void
> @@ -605,6 +602,15 @@ radeon_screen_damage_report(DamagePtr damage, RegionPtr 
> region, void *closure)
> damage->damage.data = NULL;
>  }
>
> +static void
> +drmmode_screen_damage_destroy(DamagePtr damage, void *closure)
> +{
> +   drmmode_crtc_private_ptr drmmode_crtc = closure;
> +
> +   drmmode_crtc->scanout_damage = NULL;
> +   RegionUninit(_crtc->scanout_last_region);
> +}
> +
>  static Bool
>  drmmode_can_use_hw_cursor(xf86CrtcPtr crtc)
>  {
> @@ -793,9 +799,10 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, 
> DisplayModePtr mode,
> if (!drmmode_crtc->scanout_damage) {
> drmmode_crtc->scanout_damage =
> DamageCreate(radeon_screen_damage_report,
> -NULL, DamageReportRawRegion,
> -TRUE, screen, NULL);
> -   
> DamageRegister(>GetScreenPixmap(screen)->drawable,
> +drmmode_screen_damage_destroy,
> +DamageReportRawRegion,
> +TRUE, screen, drmmode_crtc);
> +   DamageRegister(>root->drawable,
>drmmode_crtc->scanout_damage);
> }
>
> diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> index b22c98406..f76d76a91 100644
> --- a/src/radeon_kms.c
> +++ b/src/radeon_kms.c
> @@ -981,7 +981,7 @@ radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int 
> scanout_id)
> GCPtr gc = GetScratchGC(pDraw->depth, pScreen);
>
> ValidateGC(pDraw, gc);
> -   (*gc->ops->CopyArea)(>GetScreenPixmap(pScreen)->drawable,
> +   
> (*gc->ops->CopyArea)(>GetWindowPixmap(pScreen->root)->drawable,
>  pDraw, gc,
>  xf86_crtc->x + extents.x1, xf86_crtc->y + 
> extents.y1,
>  extents.x2 - extents.x1, extents.y2 - extents.y1,
> --
> 2.13.3
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH xf86-video-ati v2 1/3] Use root window (pixmap) instead of screen pixmap for scanout updates

2017-08-01 Thread Michel Dänzer
From: Michel Dänzer 

Preparation for following changes, no functional change intended yet.

Reviewed-by: Alex Deucher  # v1
Signed-off-by: Michel Dänzer 
---

v2: Add drmmode_screen_damage_destroy to prevent use-after-free on
server shutdown

 src/drmmode_display.c | 21 ++---
 src/radeon_kms.c  |  2 +-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 245a92fb0..309ccbd6d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -529,11 +529,8 @@ drmmode_crtc_scanout_free(drmmode_crtc_private_ptr 
drmmode_crtc)
 _crtc->scanout[1]);
}
 
-   if (drmmode_crtc->scanout_damage) {
+   if (drmmode_crtc->scanout_damage)
DamageDestroy(drmmode_crtc->scanout_damage);
-   drmmode_crtc->scanout_damage = NULL;
-   RegionUninit(_crtc->scanout_last_region);
-   }
 }
 
 void
@@ -605,6 +602,15 @@ radeon_screen_damage_report(DamagePtr damage, RegionPtr 
region, void *closure)
damage->damage.data = NULL;
 }
 
+static void
+drmmode_screen_damage_destroy(DamagePtr damage, void *closure)
+{
+   drmmode_crtc_private_ptr drmmode_crtc = closure;
+
+   drmmode_crtc->scanout_damage = NULL;
+   RegionUninit(_crtc->scanout_last_region);
+}
+
 static Bool
 drmmode_can_use_hw_cursor(xf86CrtcPtr crtc)
 {
@@ -793,9 +799,10 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, 
DisplayModePtr mode,
if (!drmmode_crtc->scanout_damage) {
drmmode_crtc->scanout_damage =
DamageCreate(radeon_screen_damage_report,
-NULL, DamageReportRawRegion,
-TRUE, screen, NULL);
-   
DamageRegister(>GetScreenPixmap(screen)->drawable,
+drmmode_screen_damage_destroy,
+DamageReportRawRegion,
+TRUE, screen, drmmode_crtc);
+   DamageRegister(>root->drawable,
   drmmode_crtc->scanout_damage);
}
 
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index b22c98406..f76d76a91 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -981,7 +981,7 @@ radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int 
scanout_id)
GCPtr gc = GetScratchGC(pDraw->depth, pScreen);
 
ValidateGC(pDraw, gc);
-   (*gc->ops->CopyArea)(>GetScreenPixmap(pScreen)->drawable,
+   (*gc->ops->CopyArea)(>GetWindowPixmap(pScreen->root)->drawable,
 pDraw, gc,
 xf86_crtc->x + extents.x1, xf86_crtc->y + 
extents.y1,
 extents.x2 - extents.x1, extents.y2 - extents.y1,
-- 
2.13.3

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx