All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-ati 1/4] glamor: Fix radeon_glamor_share_pixmap_backing for priv->bo == NULL
@ 2016-09-13  8:55 Michel Dänzer
       [not found] ` <20160913085556.16189-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Michel Dänzer @ 2016-09-13  8:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

Fixes crash when running a compositor and DRI_PRIME client via DRI2.

Reported-by: Qiang Yu <qiang.yu@amd.com>
(Ported from amdgpu commit b36c77695ba77b59a0ccd868454e3af4fc04d5ff)

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

diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index f94e0fd..5c4191b 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -289,12 +289,17 @@ static Bool
 radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
 				   void **handle_p)
 {
-	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
+	ScreenPtr screen = pixmap->drawable.pScreen;
+	CARD16 stride;
+	CARD32 size;
+	int fd;
 
-	if (!priv)
+	fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
+	if (fd < 0)
 		return FALSE;
 
-	return radeon_share_pixmap_backing(priv->bo, handle_p);
+	*handle_p = (void *)(long)fd;
+	return TRUE;
 }
 
 static Bool
-- 
2.9.3

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

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

* [PATCH xf86-video-ati 2/4] Consolidate get_drawable_pixmap helper
       [not found] ` <20160913085556.16189-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-09-13  8:55   ` Michel Dänzer
  2016-09-13  8:55   ` [PATCH xf86-video-ati 3/4] Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo Michel Dänzer
  2016-09-13  8:55   ` [PATCH xf86-video-ati 4/4] glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME Michel Dänzer
  2 siblings, 0 replies; 5+ messages in thread
From: Michel Dänzer @ 2016-09-13  8:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

There were two static helpers for the same purpose. Consolidate them
into a single inline helper which can be used anywhere.

(Ported from amdgpu commit 641f4647b7f51dfd2da330376cd10fa9702b6423)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/radeon_bo_helper.h       | 16 ++++++++++++++++
 src/radeon_dri2.c            |  9 ---------
 src/radeon_glamor_wrappers.c | 19 +------------------
 3 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h
index d4a4ee0..f1aed55 100644
--- a/src/radeon_bo_helper.h
+++ b/src/radeon_bo_helper.h
@@ -41,4 +41,20 @@ extern Bool
 radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
 				 struct radeon_surface *surface);
 
+/**
+ * get_drawable_pixmap() returns the backing pixmap for a given drawable.
+ *
+ * @param drawable the drawable being requested.
+ *
+ * This function returns the backing pixmap for a drawable, whether it is a
+ * redirected window, unredirected window, or already a pixmap.
+ */
+static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
+{
+    if (drawable->type == DRAWABLE_PIXMAP)
+	return (PixmapPtr)drawable;
+    else
+	return drawable->pScreen->GetWindowPixmap((WindowPtr)drawable);
+}
+
 #endif /* RADEON_BO_HELPER_H */
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index c55e6ee..069e446 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -78,15 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
      dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
 
-static PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
-{
-    if (drawable->type == DRAWABLE_PIXMAP)
-	return (PixmapPtr)drawable;
-    else
-	return (*drawable->pScreen->GetWindowPixmap)((WindowPtr)drawable);
-}
-
-
 static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 {
 	PixmapPtr old = get_drawable_pixmap(drawable);
diff --git a/src/radeon_glamor_wrappers.c b/src/radeon_glamor_wrappers.c
index cd02b06..5f165eb 100644
--- a/src/radeon_glamor_wrappers.c
+++ b/src/radeon_glamor_wrappers.c
@@ -35,27 +35,10 @@
 #ifdef USE_GLAMOR
 
 #include "radeon.h"
+#include "radeon_bo_helper.h"
 #include "radeon_glamor.h"
 
 
-/**
- * get_drawable_pixmap() returns the backing pixmap for a given drawable.
- *
- * @param pDrawable the drawable being requested.
- *
- * This function returns the backing pixmap for a drawable, whether it is a
- * redirected window, unredirected window, or already a pixmap.
- */
-static PixmapPtr
-get_drawable_pixmap(DrawablePtr pDrawable)
-{
-	if (pDrawable->type == DRAWABLE_WINDOW)
-		return pDrawable->pScreen->
-		    GetWindowPixmap((WindowPtr) pDrawable);
-	else
-		return (PixmapPtr) pDrawable;
-}
-
 /* Are there any outstanding GPU operations for this pixmap? */
 static Bool
 radeon_glamor_gpu_pending(uint_fast32_t gpu_synced, uint_fast32_t gpu_access)
-- 
2.9.3

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

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

* [PATCH xf86-video-ati 3/4] Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo
       [not found] ` <20160913085556.16189-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2016-09-13  8:55   ` [PATCH xf86-video-ati 2/4] Consolidate get_drawable_pixmap helper Michel Dänzer
@ 2016-09-13  8:55   ` Michel Dänzer
  2016-09-13  8:55   ` [PATCH xf86-video-ati 4/4] glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME Michel Dänzer
  2 siblings, 0 replies; 5+ messages in thread
From: Michel Dänzer @ 2016-09-13  8:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

So it can be used outside of the DRI2 code.

(Ported from amdgpu commit 5518bf5d793439b5bab369e5fc18de9a4a3b9dd6)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/radeon_dri2.c   | 59 +++--------------------------------------------------
 src/radeon_glamor.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 src/radeon_glamor.h |  2 ++
 3 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 069e446..74d580a 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -78,60 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
      dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
 
-static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
-{
-	PixmapPtr old = get_drawable_pixmap(drawable);
-#ifdef USE_GLAMOR
-	ScreenPtr screen = drawable->pScreen;
-	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
-	GCPtr gc;
-
-	/* With a glamor pixmap, 2D pixmaps are created in texture
-	 * and without a static BO attached to it. To support DRI,
-	 * we need to create a new textured-drm pixmap and
-	 * need to copy the original content to this new textured-drm
-	 * pixmap, and then convert the old pixmap to a coherent
-	 * textured-drm pixmap which has a valid BO attached to it
-	 * and also has a valid texture, thus both glamor and DRI2
-	 * can access it.
-	 *
-	 */
-
-	/* Copy the current contents of the pixmap to the bo. */
-	gc = GetScratchGC(drawable->depth, screen);
-	if (gc) {
-		ValidateGC(&pixmap->drawable, gc);
-		gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
-				  gc,
-				  0, 0,
-				  old->drawable.width,
-				  old->drawable.height,
-				  0, 0);
-		FreeScratchGC(gc);
-	}
-
-	radeon_set_pixmap_private(pixmap, NULL);
-
-	/* And redirect the pixmap to the new bo (for 3D). */
-	glamor_egl_exchange_buffers(old, pixmap);
-	radeon_set_pixmap_private(old, priv);
-	old->refcnt++;
-
-	screen->ModifyPixmapHeader(old,
-				   old->drawable.width,
-				   old->drawable.height,
-				   0, 0,
-				   pixmap->devKind,
-				   NULL);
-	old->devPrivate.ptr = NULL;
-
-	screen->DestroyPixmap(pixmap);
-
-#endif /* USE_GLAMOR*/
-
-	return old;
-}
-
 /* Get GEM flink name for a pixmap */
 static Bool
 radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t *name)
@@ -301,10 +247,11 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 		/* this happen if pixmap is non accelerable */
 		goto error;
 	    }
+	} else if (is_glamor_pixmap) {
+	    pixmap = radeon_glamor_set_pixmap_bo(drawable, pixmap);
+	    pixmap->refcnt++;
 	}
 
-	if (is_glamor_pixmap)
-	    pixmap = fixup_glamor(drawable, pixmap);
 	if (!radeon_get_flink_name(info, pixmap, &buffers->name))
 	    goto error;
     }
diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index 5c4191b..f46e8ba 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -283,6 +283,54 @@ fallback_pixmap:
 		return fbCreatePixmap(screen, w, h, depth, usage);
 }
 
+PixmapPtr
+radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap)
+{
+	PixmapPtr old = get_drawable_pixmap(drawable);
+	ScreenPtr screen = drawable->pScreen;
+	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
+	GCPtr gc;
+
+	/* With a glamor pixmap, 2D pixmaps are created in texture
+	 * and without a static BO attached to it. To support DRI,
+	 * we need to create a new textured-drm pixmap and
+	 * need to copy the original content to this new textured-drm
+	 * pixmap, and then convert the old pixmap to a coherent
+	 * textured-drm pixmap which has a valid BO attached to it
+	 * and also has a valid texture, thus both glamor and DRI2
+	 * can access it.
+	 *
+	 */
+
+	/* Copy the current contents of the pixmap to the bo. */
+	gc = GetScratchGC(drawable->depth, screen);
+	if (gc) {
+		ValidateGC(&pixmap->drawable, gc);
+		gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
+				  gc,
+				  0, 0,
+				  old->drawable.width,
+				  old->drawable.height, 0, 0);
+		FreeScratchGC(gc);
+	}
+
+	radeon_set_pixmap_private(pixmap, NULL);
+
+	/* And redirect the pixmap to the new bo (for 3D). */
+	glamor_egl_exchange_buffers(old, pixmap);
+	radeon_set_pixmap_private(old, priv);
+
+	screen->ModifyPixmapHeader(old,
+				   old->drawable.width,
+				   old->drawable.height,
+				   0, 0, pixmap->devKind, NULL);
+	old->devPrivate.ptr = NULL;
+
+	screen->DestroyPixmap(pixmap);
+
+	return old;
+}
+
 #ifdef RADEON_PIXMAP_SHARING
 
 static Bool
diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h
index 75129f8..fdc4e57 100644
--- a/src/radeon_glamor.h
+++ b/src/radeon_glamor.h
@@ -71,6 +71,7 @@ void radeon_glamor_free_screen(int scrnIndex, int flags);
 
 Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv);
 void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
+PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
 
 XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
 
@@ -85,6 +86,7 @@ static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { }
 static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { return TRUE; }
 
 static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
+static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; }
 
 static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; }
 
-- 
2.9.3

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

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

* [PATCH xf86-video-ati 4/4] glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME
       [not found] ` <20160913085556.16189-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2016-09-13  8:55   ` [PATCH xf86-video-ati 2/4] Consolidate get_drawable_pixmap helper Michel Dänzer
  2016-09-13  8:55   ` [PATCH xf86-video-ati 3/4] Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo Michel Dänzer
@ 2016-09-13  8:55   ` Michel Dänzer
       [not found]     ` <20160913085556.16189-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
  2 siblings, 1 reply; 5+ messages in thread
From: Michel Dänzer @ 2016-09-13  8:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

Fixes corruption when using DRI2 PRIME render offloading with the master
screen using this driver.

(Ported from amdgpu commit 0007c2f018ba663303d91d847e7c085269a23062)

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

diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index f46e8ba..7a6bf53 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -342,6 +342,26 @@ radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
 	CARD32 size;
 	int fd;
 
+	if ((radeon_get_pixmap_tiling_flags(pixmap) &
+	     RADEON_TILING_MASK) != RADEON_TILING_LINEAR) {
+		PixmapPtr linear;
+
+		/* We don't want to re-allocate the screen pixmap as
+		 * linear, to avoid trouble with page flipping
+		 */
+		if (screen->GetScreenPixmap(screen) == pixmap)
+			return FALSE;
+
+		linear = screen->CreatePixmap(screen, pixmap->drawable.width,
+					      pixmap->drawable.height,
+					      pixmap->drawable.depth,
+					      CREATE_PIXMAP_USAGE_SHARED);
+		if (!linear)
+			return FALSE;
+
+		radeon_glamor_set_pixmap_bo(&pixmap->drawable, linear);
+	}
+
 	fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
 	if (fd < 0)
 		return FALSE;
-- 
2.9.3

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

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

* Re: [PATCH xf86-video-ati 4/4] glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME
       [not found]     ` <20160913085556.16189-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2016-09-13 14:22       ` Alex Deucher
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-09-13 14:22 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: amd-gfx list

On Tue, Sep 13, 2016 at 4:55 AM, Michel Dänzer <michel@daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> Fixes corruption when using DRI2 PRIME render offloading with the master
> screen using this driver.
>
> (Ported from amdgpu commit 0007c2f018ba663303d91d847e7c085269a23062)
>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

For the series:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  src/radeon_glamor.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
> index f46e8ba..7a6bf53 100644
> --- a/src/radeon_glamor.c
> +++ b/src/radeon_glamor.c
> @@ -342,6 +342,26 @@ radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
>         CARD32 size;
>         int fd;
>
> +       if ((radeon_get_pixmap_tiling_flags(pixmap) &
> +            RADEON_TILING_MASK) != RADEON_TILING_LINEAR) {
> +               PixmapPtr linear;
> +
> +               /* We don't want to re-allocate the screen pixmap as
> +                * linear, to avoid trouble with page flipping
> +                */
> +               if (screen->GetScreenPixmap(screen) == pixmap)
> +                       return FALSE;
> +
> +               linear = screen->CreatePixmap(screen, pixmap->drawable.width,
> +                                             pixmap->drawable.height,
> +                                             pixmap->drawable.depth,
> +                                             CREATE_PIXMAP_USAGE_SHARED);
> +               if (!linear)
> +                       return FALSE;
> +
> +               radeon_glamor_set_pixmap_bo(&pixmap->drawable, linear);
> +       }
> +
>         fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
>         if (fd < 0)
>                 return FALSE;
> --
> 2.9.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

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

end of thread, other threads:[~2016-09-13 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13  8:55 [PATCH xf86-video-ati 1/4] glamor: Fix radeon_glamor_share_pixmap_backing for priv->bo == NULL Michel Dänzer
     [not found] ` <20160913085556.16189-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-13  8:55   ` [PATCH xf86-video-ati 2/4] Consolidate get_drawable_pixmap helper Michel Dänzer
2016-09-13  8:55   ` [PATCH xf86-video-ati 3/4] Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo Michel Dänzer
2016-09-13  8:55   ` [PATCH xf86-video-ati 4/4] glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME Michel Dänzer
     [not found]     ` <20160913085556.16189-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-09-13 14:22       ` 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.