All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-ati 1/3] Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well
@ 2017-02-28  8:59 Michel Dänzer
       [not found] ` <20170228085939.24243-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2017-02-28  8:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Michel Dänzer <michel.daenzer@amd.com>

Calling drmmode_crtc_scanout_allocate in drmmode_crtc_shadow_allocate
resulted in drmmode_crtc_scanout_create called from
drmmode_crtc_shadow_create passing an uninitialized pitch value to
drmmode_create_bo_pixmap.

Fixes issues such as failure to allocate the scanout pixmap or visual
corruption and GPUVM faults when attempting to use rotation with Xorg
<1.19.

Bugzilla: https://bugs.freedesktop.org/99916
Fixes: ea30d856ba5e ("Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap")
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index fd22a19ba..560bfae44 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1194,14 +1194,20 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
 			 info->cursor_w, info->cursor_h);
 }
 
+/* Xorg expects a non-NULL return value from drmmode_crtc_shadow_allocate, and
+ * passes that back to drmmode_crtc_scanout_create; it doesn't use it for
+ * anything else.
+ */
 static void *
 drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	int pitch;
 
-	return drmmode_crtc_scanout_allocate(crtc, &drmmode_crtc->rotate,
-					     width, height, &pitch);
+	if (!drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, width,
+					 height))
+		return NULL;
+
+	return (void*)~0UL;
 }
 
 static PixmapPtr
@@ -1209,11 +1215,12 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-	/* Xorg passes in the return value of drmmode_crtc_shadow_allocate
-	 * for data, but that's redundant for drmmode_crtc_scanout_create.
-	 */
-	return drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, width,
-					   height);
+	if (!data) {
+		drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, width,
+					    height);
+	}
+
+	return drmmode_crtc->rotate.pixmap;
 }
 
 static void
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-ati 2/3] Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create
       [not found] ` <20170228085939.24243-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2017-02-28  8:59   ` Michel Dänzer
  2017-02-28  8:59   ` [PATCH xf86-video-ati 3/3] Handle rotation in the driver also with Xorg 1.12-1.18 Michel Dänzer
  1 sibling, 0 replies; 4+ messages in thread
From: Michel Dänzer @ 2017-02-28  8:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Michel Dänzer <michel.daenzer@amd.com>

Not used anywhere else anymore.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 65 +++++++++++++++------------------------------------
 1 file changed, 19 insertions(+), 46 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 560bfae44..38b36b244 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -550,10 +550,9 @@ drmmode_scanout_free(ScrnInfoPtr scrn)
 		drmmode_crtc_scanout_free(xf86_config->crtc[c]->driver_private);
 }
 
-static void *
-drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
-			      struct drmmode_scanout *scanout,
-			      int width, int height, int *pitch)
+static PixmapPtr
+drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
+			    int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
 	RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -561,11 +560,11 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	struct radeon_surface surface;
 	uint32_t tiling = RADEON_CREATE_PIXMAP_TILING_MACRO;
-	int ret;
+	int pitch;
 
-	if (scanout->bo) {
+	if (scanout->pixmap) {
 		if (scanout->width == width && scanout->height == height)
-			return scanout->bo->ptr;
+			return scanout->pixmap;
 
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
@@ -574,48 +573,16 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 		tiling |= RADEON_CREATE_PIXMAP_TILING_MICRO;
 	scanout->bo = radeon_alloc_pixmap_bo(pScrn, width, height, pScrn->depth,
 					     tiling, pScrn->bitsPerPixel,
-					     pitch, &surface, &tiling);
+					     &pitch, &surface, &tiling);
 	if (scanout->bo == NULL)
-		return NULL;
-
-	radeon_bo_map(scanout->bo, 1);
+		goto error;
 
-	ret = drmModeAddFB(drmmode->fd, width, height, pScrn->depth,
-			   pScrn->bitsPerPixel, *pitch,
+	if (drmModeAddFB(drmmode->fd, width, height, pScrn->depth,
+			   pScrn->bitsPerPixel, pitch,
 			   scanout->bo->handle,
-			   &scanout->fb_id);
-	if (ret) {
+			   &scanout->fb_id) != 0) {
 		ErrorF("failed to add scanout fb\n");
-		radeon_bo_unref(scanout->bo);
-		scanout->bo = NULL;
-		return NULL;
-	}
-
-	scanout->width = width;
-	scanout->height = height;
-	return scanout->bo->ptr;
-}
-
-static PixmapPtr
-drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
-			    int width, int height)
-{
-	ScrnInfoPtr pScrn = crtc->scrn;
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	int pitch;
-
-	if (scanout->pixmap) {
-		if (scanout->width == width && scanout->height == height)
-			return scanout->pixmap;
-
-		drmmode_crtc_scanout_destroy(drmmode, scanout);
-	}
-
-	if (!scanout->bo) {
-		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width, height,
-						   &pitch))
-			return NULL;
+		goto error;
 	}
 
 	scanout->pixmap = drmmode_create_bo_pixmap(pScrn,
@@ -623,9 +590,15 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 						 pScrn->depth,
 						 pScrn->bitsPerPixel,
 						 pitch, scanout->bo, NULL);
-	if (scanout->pixmap == NULL)
+	if (scanout->pixmap) {
+		scanout->width = width;
+		scanout->height = height;
+	} else {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Couldn't allocate scanout pixmap for CRTC\n");
+error:
+		drmmode_crtc_scanout_destroy(drmmode, scanout);
+	}
 
 	return scanout->pixmap;
 }
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH xf86-video-ati 3/3] Handle rotation in the driver also with Xorg 1.12-1.18
       [not found] ` <20170228085939.24243-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2017-02-28  8:59   ` [PATCH xf86-video-ati 2/3] Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create Michel Dänzer
@ 2017-02-28  8:59   ` Michel Dänzer
       [not found]     ` <20170228085939.24243-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Michel Dänzer @ 2017-02-28  8:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

From: Michel Dänzer <michel.daenzer@amd.com>

We cannot use the HW cursor in that case, but in turn we get more
efficient and less teary updates of rotated outputs.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 38b36b244..9c69b5562 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -673,23 +673,20 @@ drmmode_crtc_update_tear_free(xf86CrtcPtr crtc)
 
 #if XF86_CRTC_VERSION >= 4
 
+#if XF86_CRTC_VERSION < 7
+#define XF86DriverTransformOutput TRUE
+#define XF86DriverTransformNone FALSE
+#endif
+
 static Bool
 drmmode_handle_transform(xf86CrtcPtr crtc)
 {
 	Bool ret;
 
-#if XF86_CRTC_VERSION >= 7
 	if (crtc->transformPresent || crtc->rotation != RR_Rotate_0)
 	    crtc->driverIsPerformingTransform = XF86DriverTransformOutput;
 	else
 	    crtc->driverIsPerformingTransform = XF86DriverTransformNone;
-#else
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	RADEONInfoPtr info = RADEONPTR(crtc->scrn);
-
-	crtc->driverIsPerformingTransform = crtc->transformPresent ||
-		(drmmode_crtc->tear_free && crtc->rotation != RR_Rotate_0);
-#endif
 
 	ret = xf86CrtcRotate(crtc);
 
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH xf86-video-ati 3/3] Handle rotation in the driver also with Xorg 1.12-1.18
       [not found]     ` <20170228085939.24243-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2017-02-28 21:14       ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2017-02-28 21:14 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: amd-gfx list

On Tue, Feb 28, 2017 at 3:59 AM, Michel Dänzer <michel@daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> We cannot use the HW cursor in that case, but in turn we get more
> efficient and less teary updates of rotated outputs.
>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  src/drmmode_display.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 38b36b244..9c69b5562 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -673,23 +673,20 @@ drmmode_crtc_update_tear_free(xf86CrtcPtr crtc)
>
>  #if XF86_CRTC_VERSION >= 4
>
> +#if XF86_CRTC_VERSION < 7
> +#define XF86DriverTransformOutput TRUE
> +#define XF86DriverTransformNone FALSE
> +#endif
> +
>  static Bool
>  drmmode_handle_transform(xf86CrtcPtr crtc)
>  {
>         Bool ret;
>
> -#if XF86_CRTC_VERSION >= 7
>         if (crtc->transformPresent || crtc->rotation != RR_Rotate_0)
>             crtc->driverIsPerformingTransform = XF86DriverTransformOutput;
>         else
>             crtc->driverIsPerformingTransform = XF86DriverTransformNone;
> -#else
> -       drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -       RADEONInfoPtr info = RADEONPTR(crtc->scrn);
> -
> -       crtc->driverIsPerformingTransform = crtc->transformPresent ||
> -               (drmmode_crtc->tear_free && crtc->rotation != RR_Rotate_0);
> -#endif
>
>         ret = xf86CrtcRotate(crtc);
>
> --
> 2.11.0
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-28 21:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28  8:59 [PATCH xf86-video-ati 1/3] Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well Michel Dänzer
     [not found] ` <20170228085939.24243-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-02-28  8:59   ` [PATCH xf86-video-ati 2/3] Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create Michel Dänzer
2017-02-28  8:59   ` [PATCH xf86-video-ati 3/3] Handle rotation in the driver also with Xorg 1.12-1.18 Michel Dänzer
     [not found]     ` <20170228085939.24243-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-02-28 21:14       ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.