All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] drm/udl: Convert to SHMEM
@ 2019-11-07  9:43 Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 1/4] drm/udl: Remove flags field from struct udl_gem_object Thomas Zimmermann
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-07  9:43 UTC (permalink / raw)
  To: airlied, sean, daniel, noralf, sam, emil.velikov, kraxel
  Cc: Thomas Zimmermann, dri-devel

Udl's GEM implementation is mostly SHMEM and we should attempt to
replace it with the latter.

Patches #1 and #2 update udl to simplify the conversion. In patch #3
the udl code is being replaced by SHMEM. The GEM object's mmap() and
free_object() functions are wrappers around their SHMEM counterparts.
For mmap() we fix-up the page-caching flags to distinguish between
write-combined and cached access. For free(), we have to unmap the
buffer's mapping that has been established by udl's fbdev code.
Patch #4 removes the obsolete udl code.

The patchset has been tested by running the fbdev console, X11 and
Weston on a DisplayLink adapter.

v3:
	* restore udl vmap function that enables caching
v2:
	* remove obsolete udl code in a separate patch

Thomas Zimmermann (4):
  drm/udl: Remove flags field from struct udl_gem_object
  drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
  drm/udl: Switch to SHMEM
  drm/udl: Remove struct udl_gem_object and functions

 drivers/gpu/drm/udl/Kconfig      |   1 +
 drivers/gpu/drm/udl/Makefile     |   2 +-
 drivers/gpu/drm/udl/udl_dmabuf.c | 255 ------------------------------
 drivers/gpu/drm/udl/udl_drv.c    |  30 +---
 drivers/gpu/drm/udl/udl_drv.h    |  36 +----
 drivers/gpu/drm/udl/udl_fb.c     |  66 ++++----
 drivers/gpu/drm/udl/udl_gem.c    | 263 +++++++++----------------------
 7 files changed, 122 insertions(+), 531 deletions(-)
 delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c

--
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH v3 1/4] drm/udl: Remove flags field from struct udl_gem_object
  2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
@ 2019-11-07  9:43 ` Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 2/4] drm/udl: Allocate GEM object via struct drm_driver.gem_create_object Thomas Zimmermann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-07  9:43 UTC (permalink / raw)
  To: airlied, sean, daniel, noralf, sam, emil.velikov, kraxel
  Cc: Thomas Zimmermann, dri-devel

The flags field in struct udl_gem controls mapping parameters: cached
access for local buffers, write-combined access for imported buffers.

We can drop the field and distinguish both cases by testing whether
struct drm_gem_object.import_attach is NULL.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/udl/udl_dmabuf.c |  1 -
 drivers/gpu/drm/udl/udl_drv.h    |  4 ----
 drivers/gpu/drm/udl/udl_gem.c    | 27 +++++++--------------------
 3 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_dmabuf.c b/drivers/gpu/drm/udl/udl_dmabuf.c
index 3108e9a9234b..b1c1ee64de59 100644
--- a/drivers/gpu/drm/udl/udl_dmabuf.c
+++ b/drivers/gpu/drm/udl/udl_dmabuf.c
@@ -241,7 +241,6 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
 		goto fail_unmap;
 
 	uobj->base.import_attach = attach;
-	uobj->flags = UDL_BO_WC;
 
 	return &uobj->base;
 
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 12a970fd9a87..e1306a51903c 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -29,9 +29,6 @@ struct drm_mode_create_dumb;
 #define DRIVER_MINOR		0
 #define DRIVER_PATCHLEVEL	1
 
-#define UDL_BO_CACHEABLE		(1 << 0)
-#define UDL_BO_WC		(1 << 1)
-
 struct udl_device;
 
 struct urb_node {
@@ -81,7 +78,6 @@ struct udl_gem_object {
 	struct page **pages;
 	void *vmapping;
 	struct sg_table *sg;
-	unsigned int flags;
 };
 
 #define to_udl_bo(x) container_of(x, struct udl_gem_object, base)
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index b23a5c2fcd80..7d3c1b73ea02 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -25,7 +25,6 @@ struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
 		return NULL;
 	}
 
-	obj->flags = UDL_BO_CACHEABLE;
 	return obj;
 }
 
@@ -57,23 +56,6 @@ udl_gem_create(struct drm_file *file,
 	return 0;
 }
 
-static void update_vm_cache_attr(struct udl_gem_object *obj,
-				 struct vm_area_struct *vma)
-{
-	DRM_DEBUG_KMS("flags = 0x%x\n", obj->flags);
-
-	/* non-cacheable as default. */
-	if (obj->flags & UDL_BO_CACHEABLE) {
-		vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-	} else if (obj->flags & UDL_BO_WC) {
-		vma->vm_page_prot =
-			pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
-	} else {
-		vma->vm_page_prot =
-			pgprot_noncached(vm_get_page_prot(vma->vm_flags));
-	}
-}
-
 int udl_dumb_create(struct drm_file *file,
 		    struct drm_device *dev,
 		    struct drm_mode_create_dumb *args)
@@ -86,16 +68,21 @@ int udl_dumb_create(struct drm_file *file,
 
 int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 {
+	struct drm_gem_object *obj;
 	int ret;
 
 	ret = drm_gem_mmap(filp, vma);
 	if (ret)
 		return ret;
 
+	obj = vma->vm_private_data;
+
 	vma->vm_flags &= ~VM_PFNMAP;
 	vma->vm_flags |= VM_MIXEDMAP;
 
-	update_vm_cache_attr(to_udl_bo(vma->vm_private_data), vma);
+	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+	if (obj->import_attach)
+		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
 
 	return ret;
 }
@@ -155,7 +142,7 @@ int udl_gem_vmap(struct udl_gem_object *obj)
 			return -ENOMEM;
 		return 0;
 	}
-		
+
 	ret = udl_gem_get_pages(obj);
 	if (ret)
 		return ret;
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH v3 2/4] drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
  2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 1/4] drm/udl: Remove flags field from struct udl_gem_object Thomas Zimmermann
@ 2019-11-07  9:43 ` Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 3/4] drm/udl: Switch to SHMEM Thomas Zimmermann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-07  9:43 UTC (permalink / raw)
  To: airlied, sean, daniel, noralf, sam, emil.velikov, kraxel
  Cc: Thomas Zimmermann, dri-devel

In preparation of a switch to SHMEM, udl now allocates its GEM
objects via struct drm_driver.gem_create_object. No functional
changes are made.

For SHMEM GEM objects, udl will require the use of a special mmap
function, which we set though the create-object function.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/udl/udl_drv.c |  1 +
 drivers/gpu/drm/udl/udl_drv.h |  2 ++
 drivers/gpu/drm/udl/udl_gem.c | 25 +++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 8426669433e4..778a0b652f64 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -64,6 +64,7 @@ static struct drm_driver driver = {
 
 	/* gem hooks */
 	.gem_free_object_unlocked = udl_gem_free_object,
+	.gem_create_object = udl_driver_gem_create_object,
 	.gem_vm_ops = &udl_gem_vm_ops,
 
 	.dumb_create = udl_dumb_create,
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index e1306a51903c..fc312e791d18 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -125,6 +125,8 @@ int udl_dumb_create(struct drm_file *file_priv,
 int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev,
 		 uint32_t handle, uint64_t *offset);
 
+struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
+						    size_t size);
 void udl_gem_free_object(struct drm_gem_object *gem_obj);
 struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
 					    size_t size);
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 7d3c1b73ea02..628749cc1143 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -6,26 +6,43 @@
 #include <linux/dma-buf.h>
 #include <linux/vmalloc.h>
 
+#include <drm/drm_drv.h>
 #include <drm/drm_mode.h>
 #include <drm/drm_prime.h>
 
 #include "udl_drv.h"
 
-struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
-					    size_t size)
+/*
+ * Helpers for struct drm_driver
+ */
+
+struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
+						    size_t size)
 {
 	struct udl_gem_object *obj;
 
 	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+	if (!obj)
+		return NULL;
+
+	return &obj->base;
+}
+
+struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
+					    size_t size)
+{
+	struct drm_gem_object *obj;
+
+	obj = dev->driver->gem_create_object(dev, size);
 	if (obj == NULL)
 		return NULL;
 
-	if (drm_gem_object_init(dev, &obj->base, size) != 0) {
+	if (drm_gem_object_init(dev, obj, size) != 0) {
 		kfree(obj);
 		return NULL;
 	}
 
-	return obj;
+	return to_udl_bo(obj);
 }
 
 static int
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH v3 3/4] drm/udl: Switch to SHMEM
  2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 1/4] drm/udl: Remove flags field from struct udl_gem_object Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 2/4] drm/udl: Allocate GEM object via struct drm_driver.gem_create_object Thomas Zimmermann
@ 2019-11-07  9:43 ` Thomas Zimmermann
  2019-11-07  9:43 ` [PATCH v3 4/4] drm/udl: Remove struct udl_gem_object and functions Thomas Zimmermann
  2019-11-07 15:10 ` [PATCH v3 0/4] drm/udl: Convert to SHMEM Böszörményi Zoltán
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-07  9:43 UTC (permalink / raw)
  To: airlied, sean, daniel, noralf, sam, emil.velikov, kraxel
  Cc: Thomas Zimmermann, dri-devel

Udl's GEM code and the generic SHMEM are almost identical. Replace
the former with SHMEM. The dmabuf support in udl is being replaced
with generic GEM PRIME functions.

The main difference is in the caching flags for mmap pages. By
default, SHMEM always sets (uncached) write combining. In udl's
memory management code, only imported buffers use write combining.
Memory pages of locally created buffer objects are mmap'ed with
caching enabled. To keep the optimization, udl provides its own
mmap function for GEM objects where it fixes up the mapping flags.

v3:
	- restore udl vmap that enables caching
v2:
	- remove obsolete code in a separate patch

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/udl/Kconfig   |   1 +
 drivers/gpu/drm/udl/udl_drv.c |  29 +---------
 drivers/gpu/drm/udl/udl_drv.h |   1 +
 drivers/gpu/drm/udl/udl_fb.c  |  66 ++++++++++++----------
 drivers/gpu/drm/udl/udl_gem.c | 101 ++++++++++++++++++++++++++++++++--
 5 files changed, 138 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/udl/Kconfig b/drivers/gpu/drm/udl/Kconfig
index b4d179b87f01..145b2a95ce58 100644
--- a/drivers/gpu/drm/udl/Kconfig
+++ b/drivers/gpu/drm/udl/Kconfig
@@ -5,6 +5,7 @@ config DRM_UDL
 	depends on USB_SUPPORT
 	depends on USB_ARCH_HAS_HCD
 	select USB
+	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
 	help
 	  This is a KMS driver for the USB displaylink video adapters.
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 778a0b652f64..563cc5809e56 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -8,6 +8,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
+#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_print.h>
@@ -32,23 +33,7 @@ static int udl_usb_resume(struct usb_interface *interface)
 	return 0;
 }
 
-static const struct vm_operations_struct udl_gem_vm_ops = {
-	.fault = udl_gem_fault,
-	.open = drm_gem_vm_open,
-	.close = drm_gem_vm_close,
-};
-
-static const struct file_operations udl_driver_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_open,
-	.mmap = udl_drm_gem_mmap,
-	.poll = drm_poll,
-	.read = drm_read,
-	.unlocked_ioctl	= drm_ioctl,
-	.release = drm_release,
-	.compat_ioctl = drm_compat_ioctl,
-	.llseek = noop_llseek,
-};
+DEFINE_DRM_GEM_FOPS(udl_driver_fops);
 
 static void udl_driver_release(struct drm_device *dev)
 {
@@ -63,18 +48,10 @@ static struct drm_driver driver = {
 	.release = udl_driver_release,
 
 	/* gem hooks */
-	.gem_free_object_unlocked = udl_gem_free_object,
 	.gem_create_object = udl_driver_gem_create_object,
-	.gem_vm_ops = &udl_gem_vm_ops,
 
-	.dumb_create = udl_dumb_create,
-	.dumb_map_offset = udl_gem_mmap,
 	.fops = &udl_driver_fops,
-
-	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
-	.gem_prime_export = udl_gem_prime_export,
-	.gem_prime_import = udl_gem_prime_import,
+	DRM_GEM_SHMEM_DRIVER_OPS,
 
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index fc312e791d18..630e64abc986 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -85,6 +85,7 @@ struct udl_gem_object {
 struct udl_framebuffer {
 	struct drm_framebuffer base;
 	struct udl_gem_object *obj;
+	struct drm_gem_shmem_object *shmem;
 	bool active_16; /* active on the 16-bit channel */
 };
 
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index ef3504d06343..f8153b726343 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -15,6 +15,7 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_fourcc.h>
+#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_modeset_helper.h>
 
 #include "udl_drv.h"
@@ -94,16 +95,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 	if (!fb->active_16)
 		return 0;
 
-	if (!fb->obj->vmapping) {
-		ret = udl_gem_vmap(fb->obj);
-		if (ret == -ENOMEM) {
+	if (!fb->shmem->vaddr) {
+		void *vaddr;
+
+		vaddr = drm_gem_shmem_vmap(&fb->shmem->base);
+		if (IS_ERR(vaddr)) {
 			DRM_ERROR("failed to vmap fb\n");
 			return 0;
 		}
-		if (!fb->obj->vmapping) {
-			DRM_ERROR("failed to vmapping\n");
-			return 0;
-		}
 	}
 
 	aligned_x = DL_ALIGN_DOWN(x, sizeof(unsigned long));
@@ -127,7 +126,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 		const int byte_offset = line_offset + (x << log_bpp);
 		const int dev_byte_offset = (fb->base.width * i + x) << log_bpp;
 		if (udl_render_hline(dev, log_bpp, &urb,
-				     (char *) fb->obj->vmapping,
+				     (char *) fb->shmem->vaddr,
 				     &cmd, byte_offset, dev_byte_offset,
 				     width << log_bpp,
 				     &bytes_identical, &bytes_sent))
@@ -281,6 +280,7 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 				      unsigned num_clips)
 {
 	struct udl_framebuffer *ufb = to_udl_fb(fb);
+	struct dma_buf_attachment *import_attach;
 	int i;
 	int ret = 0;
 
@@ -289,8 +289,10 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 	if (!ufb->active_16)
 		goto unlock;
 
-	if (ufb->obj->base.import_attach) {
-		ret = dma_buf_begin_cpu_access(ufb->obj->base.import_attach->dmabuf,
+	import_attach = ufb->shmem->base.import_attach;
+
+	if (import_attach) {
+		ret = dma_buf_begin_cpu_access(import_attach->dmabuf,
 					       DMA_FROM_DEVICE);
 		if (ret)
 			goto unlock;
@@ -304,10 +306,9 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 			break;
 	}
 
-	if (ufb->obj->base.import_attach) {
-		ret = dma_buf_end_cpu_access(ufb->obj->base.import_attach->dmabuf,
+	if (import_attach)
+		ret = dma_buf_end_cpu_access(import_attach->dmabuf,
 					     DMA_FROM_DEVICE);
-	}
 
  unlock:
 	drm_modeset_unlock_all(fb->dev);
@@ -319,8 +320,8 @@ static void udl_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct udl_framebuffer *ufb = to_udl_fb(fb);
 
-	if (ufb->obj)
-		drm_gem_object_put_unlocked(&ufb->obj->base);
+	if (ufb->shmem)
+		drm_gem_object_put_unlocked(&ufb->shmem->base);
 
 	drm_framebuffer_cleanup(fb);
 	kfree(ufb);
@@ -336,11 +337,11 @@ static int
 udl_framebuffer_init(struct drm_device *dev,
 		     struct udl_framebuffer *ufb,
 		     const struct drm_mode_fb_cmd2 *mode_cmd,
-		     struct udl_gem_object *obj)
+		     struct drm_gem_shmem_object *shmem)
 {
 	int ret;
 
-	ufb->obj = obj;
+	ufb->shmem = shmem;
 	drm_helper_mode_fill_fb_struct(dev, &ufb->base, mode_cmd);
 	ret = drm_framebuffer_init(dev, &ufb->base, &udlfb_funcs);
 	return ret;
@@ -356,7 +357,8 @@ static int udlfb_create(struct drm_fb_helper *helper,
 	struct fb_info *info;
 	struct drm_framebuffer *fb;
 	struct drm_mode_fb_cmd2 mode_cmd;
-	struct udl_gem_object *obj;
+	struct drm_gem_shmem_object *shmem;
+	void *vaddr;
 	uint32_t size;
 	int ret = 0;
 
@@ -373,12 +375,15 @@ static int udlfb_create(struct drm_fb_helper *helper,
 	size = mode_cmd.pitches[0] * mode_cmd.height;
 	size = ALIGN(size, PAGE_SIZE);
 
-	obj = udl_gem_alloc_object(dev, size);
-	if (!obj)
+	shmem = drm_gem_shmem_create(dev, size);
+	if (IS_ERR(shmem)) {
+		ret = PTR_ERR(shmem);
 		goto out;
+	}
 
-	ret = udl_gem_vmap(obj);
-	if (ret) {
+	vaddr = drm_gem_shmem_vmap(&shmem->base);
+	if (IS_ERR(vaddr)) {
+		ret = PTR_ERR(vaddr);
 		DRM_ERROR("failed to vmap fb\n");
 		goto out_gfree;
 	}
@@ -389,7 +394,7 @@ static int udlfb_create(struct drm_fb_helper *helper,
 		goto out_gfree;
 	}
 
-	ret = udl_framebuffer_init(dev, &ufbdev->ufb, &mode_cmd, obj);
+	ret = udl_framebuffer_init(dev, &ufbdev->ufb, &mode_cmd, shmem);
 	if (ret)
 		goto out_gfree;
 
@@ -397,20 +402,20 @@ static int udlfb_create(struct drm_fb_helper *helper,
 
 	ufbdev->helper.fb = fb;
 
-	info->screen_base = ufbdev->ufb.obj->vmapping;
+	info->screen_base = vaddr;
 	info->fix.smem_len = size;
-	info->fix.smem_start = (unsigned long)ufbdev->ufb.obj->vmapping;
+	info->fix.smem_start = (unsigned long)vaddr;
 
 	info->fbops = &udlfb_ops;
 	drm_fb_helper_fill_info(info, &ufbdev->helper, sizes);
 
 	DRM_DEBUG_KMS("allocated %dx%d vmal %p\n",
 		      fb->width, fb->height,
-		      ufbdev->ufb.obj->vmapping);
+		      ufbdev->ufb.shmem->vaddr);
 
 	return ret;
 out_gfree:
-	drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base);
+	drm_gem_object_put_unlocked(&ufbdev->ufb.shmem->base);
 out:
 	return ret;
 }
@@ -424,10 +429,10 @@ static void udl_fbdev_destroy(struct drm_device *dev,
 {
 	drm_fb_helper_unregister_fbi(&ufbdev->helper);
 	drm_fb_helper_fini(&ufbdev->helper);
-	if (ufbdev->ufb.obj) {
+	if (ufbdev->ufb.shmem) {
 		drm_framebuffer_unregister_private(&ufbdev->ufb.base);
 		drm_framebuffer_cleanup(&ufbdev->ufb.base);
-		drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base);
+		drm_gem_object_put_unlocked(&ufbdev->ufb.shmem->base);
 	}
 }
 
@@ -518,7 +523,8 @@ udl_fb_user_fb_create(struct drm_device *dev,
 	if (ufb == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	ret = udl_framebuffer_init(dev, ufb, mode_cmd, to_udl_bo(obj));
+	ret = udl_framebuffer_init(dev, ufb, mode_cmd,
+				   to_drm_gem_shmem_obj(obj));
 	if (ret) {
 		kfree(ufb);
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 628749cc1143..9762265edfcf 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -7,11 +7,100 @@
 #include <linux/vmalloc.h>
 
 #include <drm/drm_drv.h>
+#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_mode.h>
 #include <drm/drm_prime.h>
 
 #include "udl_drv.h"
 
+/*
+ * GEM object funcs
+ */
+
+static void udl_gem_object_free_object(struct drm_gem_object *obj)
+{
+	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
+
+	/* Fbdev emulation vmaps the buffer. Unmap it here for consistency
+	 * with the original udl GEM code.
+	 *
+	 * TODO: Switch to generic fbdev emulation and release the
+	 *       GEM object with drm_gem_shmem_free_object().
+	 */
+	if (shmem->vaddr)
+		drm_gem_shmem_vunmap(obj, shmem->vaddr);
+
+	drm_gem_shmem_free_object(obj);
+}
+
+static int udl_gem_object_mmap(struct drm_gem_object *obj,
+			       struct vm_area_struct *vma)
+{
+	int ret;
+
+	ret = drm_gem_shmem_mmap(obj, vma);
+	if (ret)
+		return ret;
+
+	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+	if (obj->import_attach)
+		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
+
+	return 0;
+}
+
+static void *udl_gem_object_vmap(struct drm_gem_object *obj)
+{
+	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
+	int ret;
+
+	ret = mutex_lock_interruptible(&shmem->vmap_lock);
+	if (ret)
+		return ERR_PTR(ret);
+
+	if (shmem->vmap_use_count++ > 0)
+		goto out;
+
+	ret = drm_gem_shmem_get_pages(shmem);
+	if (ret)
+		goto err_zero_use;
+
+	if (obj->import_attach)
+		shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
+	else
+		shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
+				    VM_MAP, PAGE_KERNEL);
+
+	if (!shmem->vaddr) {
+		DRM_DEBUG_KMS("Failed to vmap pages\n");
+		ret = -ENOMEM;
+		goto err_put_pages;
+	}
+
+out:
+	mutex_unlock(&shmem->vmap_lock);
+	return shmem->vaddr;
+
+err_put_pages:
+	drm_gem_shmem_put_pages(shmem);
+err_zero_use:
+	shmem->vmap_use_count = 0;
+	mutex_unlock(&shmem->vmap_lock);
+	return ERR_PTR(ret);
+}
+
+static const struct drm_gem_object_funcs udl_gem_object_funcs = {
+	.free = udl_gem_object_free_object,
+	.print_info = drm_gem_shmem_print_info,
+	.pin = drm_gem_shmem_pin,
+	.unpin = drm_gem_shmem_unpin,
+	.get_sg_table = drm_gem_shmem_get_sg_table,
+	.vmap = udl_gem_object_vmap,
+	.vunmap = drm_gem_shmem_vunmap,
+	.mmap = udl_gem_object_mmap,
+};
+
 /*
  * Helpers for struct drm_driver
  */
@@ -19,13 +108,17 @@
 struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
 						    size_t size)
 {
-	struct udl_gem_object *obj;
+	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_object *obj;
 
-	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
-	if (!obj)
+	shmem = kzalloc(sizeof(*shmem), GFP_KERNEL);
+	if (!shmem)
 		return NULL;
 
-	return &obj->base;
+	obj = &shmem->base;
+	obj->funcs = &udl_gem_object_funcs;
+
+	return obj;
 }
 
 struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH v3 4/4] drm/udl: Remove struct udl_gem_object and functions
  2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2019-11-07  9:43 ` [PATCH v3 3/4] drm/udl: Switch to SHMEM Thomas Zimmermann
@ 2019-11-07  9:43 ` Thomas Zimmermann
  2019-11-07 15:10 ` [PATCH v3 0/4] drm/udl: Convert to SHMEM Böszörményi Zoltán
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-07  9:43 UTC (permalink / raw)
  To: airlied, sean, daniel, noralf, sam, emil.velikov, kraxel
  Cc: Thomas Zimmermann, dri-devel

Simply removes all the obsolete GEM code from udl. No functional
changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/udl/Makefile     |   2 +-
 drivers/gpu/drm/udl/udl_dmabuf.c | 254 -------------------------------
 drivers/gpu/drm/udl/udl_drv.h    |  29 ----
 drivers/gpu/drm/udl/udl_gem.c    | 206 -------------------------
 4 files changed, 1 insertion(+), 490 deletions(-)
 delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c

diff --git a/drivers/gpu/drm/udl/Makefile b/drivers/gpu/drm/udl/Makefile
index e5bb6f757e11..9c42820ae33d 100644
--- a/drivers/gpu/drm/udl/Makefile
+++ b/drivers/gpu/drm/udl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_encoder.o udl_main.o udl_fb.o udl_transfer.o udl_gem.o udl_dmabuf.o
+udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_encoder.o udl_main.o udl_fb.o udl_transfer.o udl_gem.o
 
 obj-$(CONFIG_DRM_UDL) := udl.o
diff --git a/drivers/gpu/drm/udl/udl_dmabuf.c b/drivers/gpu/drm/udl/udl_dmabuf.c
deleted file mode 100644
index b1c1ee64de59..000000000000
--- a/drivers/gpu/drm/udl/udl_dmabuf.c
+++ /dev/null
@@ -1,254 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * udl_dmabuf.c
- *
- * Copyright (c) 2014 The Chromium OS Authors
- */
-
-#include <linux/shmem_fs.h>
-#include <linux/dma-buf.h>
-
-#include <drm/drm_prime.h>
-
-#include "udl_drv.h"
-
-struct udl_drm_dmabuf_attachment {
-	struct sg_table sgt;
-	enum dma_data_direction dir;
-	bool is_mapped;
-};
-
-static int udl_attach_dma_buf(struct dma_buf *dmabuf,
-			      struct dma_buf_attachment *attach)
-{
-	struct udl_drm_dmabuf_attachment *udl_attach;
-
-	DRM_DEBUG_PRIME("[DEV:%s] size:%zd\n", dev_name(attach->dev),
-			attach->dmabuf->size);
-
-	udl_attach = kzalloc(sizeof(*udl_attach), GFP_KERNEL);
-	if (!udl_attach)
-		return -ENOMEM;
-
-	udl_attach->dir = DMA_NONE;
-	attach->priv = udl_attach;
-
-	return 0;
-}
-
-static void udl_detach_dma_buf(struct dma_buf *dmabuf,
-			       struct dma_buf_attachment *attach)
-{
-	struct udl_drm_dmabuf_attachment *udl_attach = attach->priv;
-	struct sg_table *sgt;
-
-	if (!udl_attach)
-		return;
-
-	DRM_DEBUG_PRIME("[DEV:%s] size:%zd\n", dev_name(attach->dev),
-			attach->dmabuf->size);
-
-	sgt = &udl_attach->sgt;
-
-	if (udl_attach->dir != DMA_NONE)
-		dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents,
-				udl_attach->dir);
-
-	sg_free_table(sgt);
-	kfree(udl_attach);
-	attach->priv = NULL;
-}
-
-static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach,
-					enum dma_data_direction dir)
-{
-	struct udl_drm_dmabuf_attachment *udl_attach = attach->priv;
-	struct udl_gem_object *obj = to_udl_bo(attach->dmabuf->priv);
-	struct drm_device *dev = obj->base.dev;
-	struct udl_device *udl = dev->dev_private;
-	struct scatterlist *rd, *wr;
-	struct sg_table *sgt = NULL;
-	unsigned int i;
-	int page_count;
-	int nents, ret;
-
-	DRM_DEBUG_PRIME("[DEV:%s] size:%zd dir=%d\n", dev_name(attach->dev),
-			attach->dmabuf->size, dir);
-
-	/* just return current sgt if already requested. */
-	if (udl_attach->dir == dir && udl_attach->is_mapped)
-		return &udl_attach->sgt;
-
-	if (!obj->pages) {
-		ret = udl_gem_get_pages(obj);
-		if (ret) {
-			DRM_ERROR("failed to map pages.\n");
-			return ERR_PTR(ret);
-		}
-	}
-
-	page_count = obj->base.size / PAGE_SIZE;
-	obj->sg = drm_prime_pages_to_sg(obj->pages, page_count);
-	if (IS_ERR(obj->sg)) {
-		DRM_ERROR("failed to allocate sgt.\n");
-		return ERR_CAST(obj->sg);
-	}
-
-	sgt = &udl_attach->sgt;
-
-	ret = sg_alloc_table(sgt, obj->sg->orig_nents, GFP_KERNEL);
-	if (ret) {
-		DRM_ERROR("failed to alloc sgt.\n");
-		return ERR_PTR(-ENOMEM);
-	}
-
-	mutex_lock(&udl->gem_lock);
-
-	rd = obj->sg->sgl;
-	wr = sgt->sgl;
-	for (i = 0; i < sgt->orig_nents; ++i) {
-		sg_set_page(wr, sg_page(rd), rd->length, rd->offset);
-		rd = sg_next(rd);
-		wr = sg_next(wr);
-	}
-
-	if (dir != DMA_NONE) {
-		nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir);
-		if (!nents) {
-			DRM_ERROR("failed to map sgl with iommu.\n");
-			sg_free_table(sgt);
-			sgt = ERR_PTR(-EIO);
-			goto err_unlock;
-		}
-	}
-
-	udl_attach->is_mapped = true;
-	udl_attach->dir = dir;
-	attach->priv = udl_attach;
-
-err_unlock:
-	mutex_unlock(&udl->gem_lock);
-	return sgt;
-}
-
-static void udl_unmap_dma_buf(struct dma_buf_attachment *attach,
-			      struct sg_table *sgt,
-			      enum dma_data_direction dir)
-{
-	/* Nothing to do. */
-	DRM_DEBUG_PRIME("[DEV:%s] size:%zd dir:%d\n", dev_name(attach->dev),
-			attach->dmabuf->size, dir);
-}
-
-static void *udl_dmabuf_kmap(struct dma_buf *dma_buf, unsigned long page_num)
-{
-	/* TODO */
-
-	return NULL;
-}
-
-static void udl_dmabuf_kunmap(struct dma_buf *dma_buf,
-			      unsigned long page_num, void *addr)
-{
-	/* TODO */
-}
-
-static int udl_dmabuf_mmap(struct dma_buf *dma_buf,
-			   struct vm_area_struct *vma)
-{
-	/* TODO */
-
-	return -EINVAL;
-}
-
-static const struct dma_buf_ops udl_dmabuf_ops = {
-	.attach			= udl_attach_dma_buf,
-	.detach			= udl_detach_dma_buf,
-	.map_dma_buf		= udl_map_dma_buf,
-	.unmap_dma_buf		= udl_unmap_dma_buf,
-	.map			= udl_dmabuf_kmap,
-	.unmap			= udl_dmabuf_kunmap,
-	.mmap			= udl_dmabuf_mmap,
-	.release		= drm_gem_dmabuf_release,
-};
-
-struct dma_buf *udl_gem_prime_export(struct drm_gem_object *obj, int flags)
-{
-	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
-
-	exp_info.ops = &udl_dmabuf_ops;
-	exp_info.size = obj->size;
-	exp_info.flags = flags;
-	exp_info.priv = obj;
-
-	return drm_gem_dmabuf_export(obj->dev, &exp_info);
-}
-
-static int udl_prime_create(struct drm_device *dev,
-			    size_t size,
-			    struct sg_table *sg,
-			    struct udl_gem_object **obj_p)
-{
-	struct udl_gem_object *obj;
-	int npages;
-
-	npages = size / PAGE_SIZE;
-
-	*obj_p = NULL;
-	obj = udl_gem_alloc_object(dev, npages * PAGE_SIZE);
-	if (!obj)
-		return -ENOMEM;
-
-	obj->sg = sg;
-	obj->pages = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
-	if (obj->pages == NULL) {
-		DRM_ERROR("obj pages is NULL %d\n", npages);
-		return -ENOMEM;
-	}
-
-	drm_prime_sg_to_page_addr_arrays(sg, obj->pages, NULL, npages);
-
-	*obj_p = obj;
-	return 0;
-}
-
-struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
-				struct dma_buf *dma_buf)
-{
-	struct dma_buf_attachment *attach;
-	struct sg_table *sg;
-	struct udl_gem_object *uobj;
-	int ret;
-
-	/* need to attach */
-	get_device(dev->dev);
-	attach = dma_buf_attach(dma_buf, dev->dev);
-	if (IS_ERR(attach)) {
-		put_device(dev->dev);
-		return ERR_CAST(attach);
-	}
-
-	get_dma_buf(dma_buf);
-
-	sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
-	if (IS_ERR(sg)) {
-		ret = PTR_ERR(sg);
-		goto fail_detach;
-	}
-
-	ret = udl_prime_create(dev, dma_buf->size, sg, &uobj);
-	if (ret)
-		goto fail_unmap;
-
-	uobj->base.import_attach = attach;
-
-	return &uobj->base;
-
-fail_unmap:
-	dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
-fail_detach:
-	dma_buf_detach(dma_buf, attach);
-	dma_buf_put(dma_buf);
-	put_device(dev->dev);
-	return ERR_PTR(ret);
-}
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 630e64abc986..987d99ae2dfa 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -73,18 +73,8 @@ struct udl_device {
 
 #define to_udl(x) container_of(x, struct udl_device, drm)
 
-struct udl_gem_object {
-	struct drm_gem_object base;
-	struct page **pages;
-	void *vmapping;
-	struct sg_table *sg;
-};
-
-#define to_udl_bo(x) container_of(x, struct udl_gem_object, base)
-
 struct udl_framebuffer {
 	struct drm_framebuffer base;
-	struct udl_gem_object *obj;
 	struct drm_gem_shmem_object *shmem;
 	bool active_16; /* active on the 16-bit channel */
 };
@@ -120,27 +110,8 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
 		     u32 byte_offset, u32 device_byte_offset, u32 byte_width,
 		     int *ident_ptr, int *sent_ptr);
 
-int udl_dumb_create(struct drm_file *file_priv,
-		    struct drm_device *dev,
-		    struct drm_mode_create_dumb *args);
-int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev,
-		 uint32_t handle, uint64_t *offset);
-
 struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
 						    size_t size);
-void udl_gem_free_object(struct drm_gem_object *gem_obj);
-struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
-					    size_t size);
-struct dma_buf *udl_gem_prime_export(struct drm_gem_object *obj, int flags);
-struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
-				struct dma_buf *dma_buf);
-
-int udl_gem_get_pages(struct udl_gem_object *obj);
-void udl_gem_put_pages(struct udl_gem_object *obj);
-int udl_gem_vmap(struct udl_gem_object *obj);
-void udl_gem_vunmap(struct udl_gem_object *obj);
-int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-vm_fault_t udl_gem_fault(struct vm_fault *vmf);
 
 int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
 		      int width, int height);
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 9762265edfcf..6eade6b4b0dc 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -120,209 +120,3 @@ struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
 
 	return obj;
 }
-
-struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
-					    size_t size)
-{
-	struct drm_gem_object *obj;
-
-	obj = dev->driver->gem_create_object(dev, size);
-	if (obj == NULL)
-		return NULL;
-
-	if (drm_gem_object_init(dev, obj, size) != 0) {
-		kfree(obj);
-		return NULL;
-	}
-
-	return to_udl_bo(obj);
-}
-
-static int
-udl_gem_create(struct drm_file *file,
-	       struct drm_device *dev,
-	       uint64_t size,
-	       uint32_t *handle_p)
-{
-	struct udl_gem_object *obj;
-	int ret;
-	u32 handle;
-
-	size = roundup(size, PAGE_SIZE);
-
-	obj = udl_gem_alloc_object(dev, size);
-	if (obj == NULL)
-		return -ENOMEM;
-
-	ret = drm_gem_handle_create(file, &obj->base, &handle);
-	if (ret) {
-		drm_gem_object_release(&obj->base);
-		kfree(obj);
-		return ret;
-	}
-
-	drm_gem_object_put_unlocked(&obj->base);
-	*handle_p = handle;
-	return 0;
-}
-
-int udl_dumb_create(struct drm_file *file,
-		    struct drm_device *dev,
-		    struct drm_mode_create_dumb *args)
-{
-	args->pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
-	args->size = args->pitch * args->height;
-	return udl_gem_create(file, dev,
-			      args->size, &args->handle);
-}
-
-int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	struct drm_gem_object *obj;
-	int ret;
-
-	ret = drm_gem_mmap(filp, vma);
-	if (ret)
-		return ret;
-
-	obj = vma->vm_private_data;
-
-	vma->vm_flags &= ~VM_PFNMAP;
-	vma->vm_flags |= VM_MIXEDMAP;
-
-	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-	if (obj->import_attach)
-		vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-
-	return ret;
-}
-
-vm_fault_t udl_gem_fault(struct vm_fault *vmf)
-{
-	struct vm_area_struct *vma = vmf->vma;
-	struct udl_gem_object *obj = to_udl_bo(vma->vm_private_data);
-	struct page *page;
-	unsigned int page_offset;
-
-	page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
-
-	if (!obj->pages)
-		return VM_FAULT_SIGBUS;
-
-	page = obj->pages[page_offset];
-	return vmf_insert_page(vma, vmf->address, page);
-}
-
-int udl_gem_get_pages(struct udl_gem_object *obj)
-{
-	struct page **pages;
-
-	if (obj->pages)
-		return 0;
-
-	pages = drm_gem_get_pages(&obj->base);
-	if (IS_ERR(pages))
-		return PTR_ERR(pages);
-
-	obj->pages = pages;
-
-	return 0;
-}
-
-void udl_gem_put_pages(struct udl_gem_object *obj)
-{
-	if (obj->base.import_attach) {
-		kvfree(obj->pages);
-		obj->pages = NULL;
-		return;
-	}
-
-	drm_gem_put_pages(&obj->base, obj->pages, false, false);
-	obj->pages = NULL;
-}
-
-int udl_gem_vmap(struct udl_gem_object *obj)
-{
-	int page_count = obj->base.size / PAGE_SIZE;
-	int ret;
-
-	if (obj->base.import_attach) {
-		obj->vmapping = dma_buf_vmap(obj->base.import_attach->dmabuf);
-		if (!obj->vmapping)
-			return -ENOMEM;
-		return 0;
-	}
-
-	ret = udl_gem_get_pages(obj);
-	if (ret)
-		return ret;
-
-	obj->vmapping = vmap(obj->pages, page_count, 0, PAGE_KERNEL);
-	if (!obj->vmapping)
-		return -ENOMEM;
-	return 0;
-}
-
-void udl_gem_vunmap(struct udl_gem_object *obj)
-{
-	if (obj->base.import_attach) {
-		dma_buf_vunmap(obj->base.import_attach->dmabuf, obj->vmapping);
-		return;
-	}
-
-	vunmap(obj->vmapping);
-
-	udl_gem_put_pages(obj);
-}
-
-void udl_gem_free_object(struct drm_gem_object *gem_obj)
-{
-	struct udl_gem_object *obj = to_udl_bo(gem_obj);
-
-	if (obj->vmapping)
-		udl_gem_vunmap(obj);
-
-	if (gem_obj->import_attach) {
-		drm_prime_gem_destroy(gem_obj, obj->sg);
-		put_device(gem_obj->dev->dev);
-	}
-
-	if (obj->pages)
-		udl_gem_put_pages(obj);
-
-	drm_gem_free_mmap_offset(gem_obj);
-}
-
-/* the dumb interface doesn't work with the GEM straight MMAP
-   interface, it expects to do MMAP on the drm fd, like normal */
-int udl_gem_mmap(struct drm_file *file, struct drm_device *dev,
-		 uint32_t handle, uint64_t *offset)
-{
-	struct udl_gem_object *gobj;
-	struct drm_gem_object *obj;
-	struct udl_device *udl = to_udl(dev);
-	int ret = 0;
-
-	mutex_lock(&udl->gem_lock);
-	obj = drm_gem_object_lookup(file, handle);
-	if (obj == NULL) {
-		ret = -ENOENT;
-		goto unlock;
-	}
-	gobj = to_udl_bo(obj);
-
-	ret = udl_gem_get_pages(gobj);
-	if (ret)
-		goto out;
-	ret = drm_gem_create_mmap_offset(obj);
-	if (ret)
-		goto out;
-
-	*offset = drm_vma_node_offset_addr(&gobj->base.vma_node);
-
-out:
-	drm_gem_object_put_unlocked(&gobj->base);
-unlock:
-	mutex_unlock(&udl->gem_lock);
-	return ret;
-}
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3 0/4] drm/udl: Convert to SHMEM
  2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2019-11-07  9:43 ` [PATCH v3 4/4] drm/udl: Remove struct udl_gem_object and functions Thomas Zimmermann
@ 2019-11-07 15:10 ` Böszörményi Zoltán
  2019-11-08  5:44   ` Böszörményi Zoltán
  2019-11-08  7:36   ` Thomas Zimmermann
  4 siblings, 2 replies; 10+ messages in thread
From: Böszörményi Zoltán @ 2019-11-07 15:10 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied, sean, daniel, noralf, sam,
	emil.velikov, kraxel
  Cc: dri-devel

Hi,

2019. 11. 07. 10:43 keltezéssel, Thomas Zimmermann írta:
> Udl's GEM implementation is mostly SHMEM and we should attempt to
> replace it with the latter.
> 
> Patches #1 and #2 update udl to simplify the conversion. In patch #3
> the udl code is being replaced by SHMEM. The GEM object's mmap() and
> free_object() functions are wrappers around their SHMEM counterparts.
> For mmap() we fix-up the page-caching flags to distinguish between
> write-combined and cached access. For free(), we have to unmap the
> buffer's mapping that has been established by udl's fbdev code.
> Patch #4 removes the obsolete udl code.
> 
> The patchset has been tested by running the fbdev console, X11 and
> Weston on a DisplayLink adapter.

what's the trick to actually enable the UDL device?

With 5.3.8, 5.3.9 or 5.4-rc6 + drm-next and this patchset, I get this:

# DISPLAY=:0 xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x76 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload 
crtcs: 2 outputs: 3 associated providers: 0 name:modesetting
Provider 1: id: 0x41 cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 
name:modesetting

# DISPLAY=:0 xrandr --setprovideroutputsource 0x41 0x76

# DISPLAY=:0 xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x76 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload 
crtcs: 2 outputs: 3 associated providers: 1 name:modesetting
Provider 1: id: 0x41 cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 1 
name:modesetting

# DISPLAY=:0 xrandr
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
VGA-1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
    1024x768      75.03*+  60.00
    1280x1024     60.02 +
    1152x864      75.00
    832x624       74.55
    800x600       75.00    60.32
    640x480       75.00    59.94
    720x400       70.08
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm
    1024x768      60.00*+
DVI-I-1-1 connected (normal left inverted right x axis y axis)
    1024x768      75.03 +  60.00
    1920x1080     60.00 +
    1680x1050     59.88
    1280x1024     75.02    60.02
    1440x900      74.98    59.90
    1280x720      60.00
    800x600       75.00    60.32
    640x480       75.00    72.81    66.67    59.94
    720x400       70.08
   1024x768 (0x42) 78.750MHz +HSync +VSync
         h: width  1024 start 1040 end 1136 total 1312 skew    0 clock  60.02KHz
         v: height  768 start  769 end  772 total  800           clock  75.03Hz
   1280x1024 (0x46) 108.000MHz +HSync +VSync
         h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
         v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
   1024x768 (0x4a) 65.000MHz -HSync -VSync
         h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
         v: height  768 start  771 end  777 total  806           clock  60.00Hz
   800x600 (0x4b) 49.500MHz +HSync +VSync
         h: width   800 start  816 end  896 total 1056 skew    0 clock  46.88KHz
         v: height  600 start  601 end  604 total  625           clock  75.00Hz
   800x600 (0x4c) 40.000MHz +HSync +VSync
         h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
         v: height  600 start  601 end  605 total  628           clock  60.32Hz
   640x480 (0x4d) 31.500MHz -HSync -VSync
         h: width   640 start  656 end  720 total  840 skew    0 clock  37.50KHz
         v: height  480 start  481 end  484 total  500           clock  75.00Hz
   640x480 (0x50) 25.175MHz -HSync -VSync
         h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
         v: height  480 start  490 end  492 total  525           clock  59.94Hz
   720x400 (0x51) 28.320MHz -HSync +VSync
         h: width   720 start  738 end  846 total  900 skew    0 clock  31.47KHz
         v: height  400 start  412 end  414 total  449           clock  70.08Hz

# DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
xrandr: Configure crtc 2 failed

Even after the last command, my monitor say "no signal" from the UDL (DL-195)
device and dmesg has a kernel warning now:

[  133.320404] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2211840 bytes), total 32768 
(slots), used 0 (slots)
[  133.320410] udl 2-1.2:1.0: overflow 0x00000001199e4000+2211840 of DMA mask ffffffff bus 
mask 0
[  133.320424] WARNING: CPU: 0 PID: 739 at kernel/dma/direct.c:35 report_addr+0x3e/0x70
[  133.320425] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr intel_rapl_common 
x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel snd_hda_codec_hdmi kvm 
snd_hda_codec_realt
ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_hda_codec iTCO_wdt elo irqbypass 
iTCO_vendor_support intel_cstate snd_hda_core intel_uncore snd_hwdep intel_rapl_perf 
snd_pcm pcspkr
  i2c_i801 snd_timer e1000e snd joydev lpc_ich soundcore ip6t_REJECT nf_reject_ipv6 
nf_log_ipv6 ip6table_filter ip6_tables nf_log_ipv4 nf_log_common xt_LOG xt_limit 
xt_multiport xt_conntrack
  iptable_nat nf_nat xt_connmark nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c 
iptable_mangle i915 udl i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt 
fb_sys_fops drm cr
c32_pclmul crc32c_intel serio_raw video
[  133.320463] CPU: 0 PID: 739 Comm: Xorg Not tainted 5.3.8 #1
[  133.320465] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset, BIOS XBKT200 
01/04/2017
[  133.320467] EIP: report_addr+0x3e/0x70
[  133.320470] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff ff 39 ca ba 00 00 
00 00 19 da 73 17 80 3d 9c 16 14 d0 00 0f 84 24 09 00 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 
8b 90 5c 01 00 00 0b 90 58 01 00 00
[  133.320472] EAX: 00000000 EBX: 00000000 ECX: f5b89e00 EDX: 00000007
[  133.320473] ESI: ffffffff EDI: ecf3921c EBP: ec56bcf4 ESP: ec56bce8
[  133.320475] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00213286
[  133.320476] CR0: 80050033 CR2: b7236020 CR3: 2c72a000 CR4: 000406f0
[  133.320477] Call Trace:
[  133.320484]  dma_direct_map_page+0x158/0x180
[  133.320487]  dma_direct_map_sg+0x4f/0xa0
[  133.320564]  i915_gem_map_dma_buf+0x1b8/0x1d0 [i915]
[  133.320568]  dma_buf_map_attachment+0x4f/0x90
[  133.320572]  udl_gem_prime_import+0x43/0x12a [udl]
[  133.320607]  drm_gem_prime_fd_to_handle+0x97/0x180 [drm]
[  133.320625]  ? drm_gem_prime_export+0xa0/0xa0 [drm]
[  133.320642]  ? drm_gem_prime_import+0x20/0x20 [drm]
[  133.320658]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
[  133.320673]  drm_prime_fd_to_handle_ioctl+0x2f/0x50 [drm]
[  133.320689]  drm_ioctl_kernel+0x8f/0xd0 [drm]
[  133.320706]  drm_ioctl+0x21c/0x3c0 [drm]
[  133.320721]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
[  133.320726]  ? file_modified+0x30/0x30
[  133.320728]  ? file_update_time+0xfe/0x130
[  133.320731]  ? page_add_file_rmap+0x72/0xd0
[  133.320734]  ? fault_dirty_shared_page.isra.122+0x6d/0xb0
[  133.320750]  ? drm_version+0x80/0x80 [drm]
[  133.320753]  do_vfs_ioctl+0x9a/0x6c0
[  133.320757]  ksys_ioctl+0x56/0x80
[  133.320760]  sys_ioctl+0x16/0x20
[  133.320763]  do_fast_syscall_32+0x82/0x1c7
[  133.320766]  entry_SYSENTER_32+0x9f/0xf2
[  133.320768] EIP: 0xb7f84a75
[  133.320770] Code: e8 1c 00 00 00 89 d3 eb cf 8d 74 26 00 b8 40 42 0f 00 eb b5 8b 04 24 
c3 8b 1c 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 
00 58 b8 77 00 00 00 cd 80 90 8d 76
[  133.320772] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bff26be0
[  133.320773] ESI: 0221ad20 EDI: c00c642e EBP: 0000000c ESP: bff26b88
[  133.320775] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00203296
[  133.320777] ---[ end trace 18cd4f77716f2f5f ]---

With your drm-next and your patch set, the call trace is obviously different:

[   37.486584] udl 2-1.2:1.0: swiotlb buffer is full (sz: 536576 bytes), total 32768 
(slots), used 1536 (slots)
[   37.486591] udl 2-1.2:1.0: overflow 0x000000011a47d000+536576 of DMA mask ffffffff bus 
mask 0
[   37.486598] ------------[ cut here ]------------
[   37.486606] WARNING: CPU: 1 PID: 749 at kernel/dma/direct.c:35 report_addr+0x3e/0x70
[   37.486607] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr intel_rapl_common 
x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm snd_hda_codec_hdmi 
snd_hda_codec_realt
ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_nhlt snd_hda_codec iTCO_wdt 
iTCO_vendor_support elo irqbypass snd_hda_core intel_cstate intel_uncore snd_hwdep snd_pcm 
intel_r
apl_perf e1000e pcspkr joydev i2c_i801 snd_timer lpc_ich snd soundcore ip6t_REJECT 
nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables nf_log_ipv4 nf_log_common xt_LOG 
xt_limit xt_multipo
rt xt_conntrack iptable_nat nf_nat xt_connmark nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 
libcrc32c iptable_mangle i915 udl i2c_algo_bit drm_kms_helper syscopyarea sysfillrect 
crc32_pclmul
sysimgblt crc32c_intel fb_sys_fops serio_raw drm video
[   37.486647] CPU: 1 PID: 749 Comm: Xorg Tainted: G        W         5.4.0-rc4+ #1
[   37.486648] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset, BIOS XBKT200 
01/04/2017
[   37.486652] EIP: report_addr+0x3e/0x70
[   37.486655] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff ff 39 ca ba 00 00 
00 00 19 da 73 17 80 3d b0 7d 95 d2 00 0f 84 c4 08 00 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 
8b 90 5c 01 00 00 0b 90 58 01 00 00
[   37.486656] EAX: 00000000 EBX: 00000000 ECX: f68e3e00 EDX: 00000007
[   37.486657] ESI: ed77f81c EDI: ffffffff EBP: ed1e5cfc ESP: ed1e5cf0
[   37.486659] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00213286
[   37.486661] CR0: 80050033 CR2: b7223020 CR3: 2cad8000 CR4: 000406f0
[   37.486662] Call Trace:
[   37.486669]  dma_direct_map_page+0x158/0x180
[   37.486673]  dma_direct_map_sg+0x4f/0xa0
[   37.486744]  i915_gem_map_dma_buf+0x114/0x190 [i915]
[   37.486748]  dma_buf_map_attachment+0x4f/0x90
[   37.486781]  drm_gem_prime_import_dev+0x5d/0x100 [drm]
[   37.486802]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
[   37.486821]  drm_gem_prime_fd_to_handle+0x158/0x180 [drm]
[   37.486838]  ? drm_gem_prime_import+0x20/0x20 [drm]
[   37.486854]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
[   37.486871]  drm_prime_fd_to_handle_ioctl+0x21/0x30 [drm]
[   37.486888]  drm_ioctl_kernel+0x99/0xe0 [drm]
[   37.486904]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
[   37.486922]  drm_ioctl+0x21a/0x380 [drm]
[   37.486938]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
[   37.486942]  ? __send_signal+0x2a4/0x3e0
[   37.486944]  ? send_signal+0xb0/0xf0
[   37.486946]  ? do_send_sig_info+0x4b/0x80
[   37.486963]  ? drm_ioctl_kernel+0xe0/0xe0 [drm]
[   37.486967]  do_vfs_ioctl+0x3fa/0x6b0
[   37.486969]  ? kill_pid_info+0x31/0x60
[   37.486973]  ? ktime_get+0x4c/0x110
[   37.486977]  ksys_ioctl+0x5d/0x90
[   37.486980]  sys_ioctl+0x16/0x20
[   37.486983]  do_fast_syscall_32+0x82/0x1c7
[   37.486988]  entry_SYSENTER_32+0x9f/0xf2
[   37.486989] EIP: 0xb7f75b55
[   37.486992] Code: 00 00 8d 76 00 b8 40 42 0f 00 eb bb 8b 04 24 c3 8b 14 24 c3 8b 1c 24 
c3 8b 34 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 
00 58 b8 77 00 00 00 cd 80 90 8d 76
[   37.486994] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bfd13dc0
[   37.486995] ESI: 01c03520 EDI: c00c642e EBP: 0000000c ESP: bfd13d68
[   37.486997] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00203292
[   37.486999] ---[ end trace cef48717f4fbe0fa ]---

It seems I get random successes with mostly failures of this kind:

# DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --below DP-1
xrandr: Configure crtc 2 failed
# DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
xrandr: Configure crtc 2 failed

These messages appear for failed attempts:

[  552.197202] udl 2-1.2:1.0: swiotlb buffer is full (sz: 360448 bytes), total 32768 
(slots), used 98 (slots)
[  552.387539] udl 2-1.2:1.0: swiotlb buffer is full (sz: 819200 bytes), total 32768 
(slots), used 210 (slots)
[  562.139080] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2723840 bytes), total 32768 
(slots), used 206 (slots)
[  709.666258] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152 bytes), total 32768 
(slots), used 20 (slots)
[  709.868665] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152 bytes), total 32768 
(slots), used 14 (slots)
[  721.728930] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3133440 bytes), total 32768 
(slots), used 6 (slots)
[  738.187591] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes), total 32768 
(slots), used 238 (slots)
[  738.373190] udl 2-1.2:1.0: swiotlb buffer is full (sz: 950272 bytes), total 32768 
(slots), used 664 (slots)
[  738.990204] udl 2-1.2:1.0: swiotlb buffer is full (sz: 983040 bytes), total 32768 
(slots), used 24 (slots)
[  743.599439] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2826240 bytes), total 32768 
(slots), used 156 (slots)

Best regards,
Zoltán Böszörményi

> 
> v3:
> 	* restore udl vmap function that enables caching
> v2:
> 	* remove obsolete udl code in a separate patch
> 
> Thomas Zimmermann (4):
>    drm/udl: Remove flags field from struct udl_gem_object
>    drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
>    drm/udl: Switch to SHMEM
>    drm/udl: Remove struct udl_gem_object and functions
> 
>   drivers/gpu/drm/udl/Kconfig      |   1 +
>   drivers/gpu/drm/udl/Makefile     |   2 +-
>   drivers/gpu/drm/udl/udl_dmabuf.c | 255 ------------------------------
>   drivers/gpu/drm/udl/udl_drv.c    |  30 +---
>   drivers/gpu/drm/udl/udl_drv.h    |  36 +----
>   drivers/gpu/drm/udl/udl_fb.c     |  66 ++++----
>   drivers/gpu/drm/udl/udl_gem.c    | 263 +++++++++----------------------
>   7 files changed, 122 insertions(+), 531 deletions(-)
>   delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c
> 
> --
> 2.23.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3 0/4] drm/udl: Convert to SHMEM
  2019-11-07 15:10 ` [PATCH v3 0/4] drm/udl: Convert to SHMEM Böszörményi Zoltán
@ 2019-11-08  5:44   ` Böszörményi Zoltán
  2019-11-08  7:36   ` Thomas Zimmermann
  1 sibling, 0 replies; 10+ messages in thread
From: Böszörményi Zoltán @ 2019-11-08  5:44 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied, sean, daniel, noralf, sam,
	emil.velikov, kraxel
  Cc: dri-devel

2019. 11. 07. 16:10 keltezéssel, Böszörményi Zoltán írta:
> what's the trick to actually enable the UDL device?
> 
> With 5.3.8, 5.3.9 or 5.4-rc6 + drm-next and this patchset, I get this:
> [long messages]

I didn't mention that the system is 32-bit, using a PAE kernel.
Is it a problem for swiotlb?

The machine has this CPU:

model name	: Intel(R) Celeron(R) CPU G540 @ 2.50GHz

Best regards,
Zoltán Böszörményi
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3 0/4] drm/udl: Convert to SHMEM
  2019-11-07 15:10 ` [PATCH v3 0/4] drm/udl: Convert to SHMEM Böszörményi Zoltán
  2019-11-08  5:44   ` Böszörményi Zoltán
@ 2019-11-08  7:36   ` Thomas Zimmermann
  2019-11-08 12:06     ` Böszörményi Zoltán
  1 sibling, 1 reply; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-08  7:36 UTC (permalink / raw)
  To: Böszörményi Zoltán, airlied, sean, daniel,
	noralf, sam, emil.velikov, kraxel
  Cc: dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 16268 bytes --]

Hi Böszörményi

Am 07.11.19 um 16:10 schrieb Böszörményi Zoltán:
> Hi,
> 
> 2019. 11. 07. 10:43 keltezéssel, Thomas Zimmermann írta:
>> Udl's GEM implementation is mostly SHMEM and we should attempt to
>> replace it with the latter.
>>
>> Patches #1 and #2 update udl to simplify the conversion. In patch #3
>> the udl code is being replaced by SHMEM. The GEM object's mmap() and
>> free_object() functions are wrappers around their SHMEM counterparts.
>> For mmap() we fix-up the page-caching flags to distinguish between
>> write-combined and cached access. For free(), we have to unmap the
>> buffer's mapping that has been established by udl's fbdev code.
>> Patch #4 removes the obsolete udl code.
>>
>> The patchset has been tested by running the fbdev console, X11 and
>> Weston on a DisplayLink adapter.
> 
> what's the trick to actually enable the UDL device?
> 
> With 5.3.8, 5.3.9 or 5.4-rc6 + drm-next and this patchset, I get this:
> 
> # DISPLAY=:0 xrandr --listproviders
> Providers: number : 2
> Provider 0: id: 0x76 cap: 0xf, Source Output, Sink Output, Source
> Offload, Sink Offload crtcs: 2 outputs: 3 associated providers: 0
> name:modesetting
> Provider 1: id: 0x41 cap: 0x2, Sink Output crtcs: 1 outputs: 1
> associated providers: 0 name:modesetting
> 
> # DISPLAY=:0 xrandr --setprovideroutputsource 0x41 0x76
> 
> # DISPLAY=:0 xrandr --listproviders
> Providers: number : 2
> Provider 0: id: 0x76 cap: 0xf, Source Output, Sink Output, Source
> Offload, Sink Offload crtcs: 2 outputs: 3 associated providers: 1
> name:modesetting
> Provider 1: id: 0x41 cap: 0x2, Sink Output crtcs: 1 outputs: 1
> associated providers: 1 name:modesetting
> 
> # DISPLAY=:0 xrandr
> Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
> VGA-1 connected primary 1024x768+0+0 (normal left inverted right x axis
> y axis) 376mm x 301mm
>    1024x768      75.03*+  60.00
>    1280x1024     60.02 +
>    1152x864      75.00
>    832x624       74.55
>    800x600       75.00    60.32
>    640x480       75.00    59.94
>    720x400       70.08
> HDMI-1 disconnected (normal left inverted right x axis y axis)
> DP-1 connected 1024x768+0+0 (normal left inverted right x axis y axis)
> 304mm x 228mm
>    1024x768      60.00*+
> DVI-I-1-1 connected (normal left inverted right x axis y axis)
>    1024x768      75.03 +  60.00
>    1920x1080     60.00 +
>    1680x1050     59.88
>    1280x1024     75.02    60.02
>    1440x900      74.98    59.90
>    1280x720      60.00
>    800x600       75.00    60.32
>    640x480       75.00    72.81    66.67    59.94
>    720x400       70.08
>   1024x768 (0x42) 78.750MHz +HSync +VSync
>         h: width  1024 start 1040 end 1136 total 1312 skew    0 clock 
> 60.02KHz
>         v: height  768 start  769 end  772 total  800           clock 
> 75.03Hz
>   1280x1024 (0x46) 108.000MHz +HSync +VSync
>         h: width  1280 start 1328 end 1440 total 1688 skew    0 clock 
> 63.98KHz
>         v: height 1024 start 1025 end 1028 total 1066           clock 
> 60.02Hz
>   1024x768 (0x4a) 65.000MHz -HSync -VSync
>         h: width  1024 start 1048 end 1184 total 1344 skew    0 clock 
> 48.36KHz
>         v: height  768 start  771 end  777 total  806           clock 
> 60.00Hz
>   800x600 (0x4b) 49.500MHz +HSync +VSync
>         h: width   800 start  816 end  896 total 1056 skew    0 clock 
> 46.88KHz
>         v: height  600 start  601 end  604 total  625           clock 
> 75.00Hz
>   800x600 (0x4c) 40.000MHz +HSync +VSync
>         h: width   800 start  840 end  968 total 1056 skew    0 clock 
> 37.88KHz
>         v: height  600 start  601 end  605 total  628           clock 
> 60.32Hz
>   640x480 (0x4d) 31.500MHz -HSync -VSync
>         h: width   640 start  656 end  720 total  840 skew    0 clock 
> 37.50KHz
>         v: height  480 start  481 end  484 total  500           clock 
> 75.00Hz
>   640x480 (0x50) 25.175MHz -HSync -VSync
>         h: width   640 start  656 end  752 total  800 skew    0 clock 
> 31.47KHz
>         v: height  480 start  490 end  492 total  525           clock 
> 59.94Hz
>   720x400 (0x51) 28.320MHz -HSync +VSync
>         h: width   720 start  738 end  846 total  900 skew    0 clock 
> 31.47KHz
>         v: height  400 start  412 end  414 total  449           clock 
> 70.08Hz
> 
> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
> xrandr: Configure crtc 2 failed
> 
> Even after the last command, my monitor say "no signal" from the UDL
> (DL-195)
> device and dmesg has a kernel warning now:
> 
> [  133.320404] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2211840
> bytes), total 32768 (slots), used 0 (slots)

Have you tried to increase the buffer size? There's a command-line
option to control this setting. [1]

Best regards
Thomas

[1] https://wiki.gentoo.org/wiki/IOMMU_SWIOTLB


> [  133.320410] udl 2-1.2:1.0: overflow 0x00000001199e4000+2211840 of DMA
> mask ffffffff bus mask 0
> [  133.320424] WARNING: CPU: 0 PID: 739 at kernel/dma/direct.c:35
> report_addr+0x3e/0x70
> [  133.320425] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
> kvm_intel snd_hda_codec_hdmi kvm snd_hda_codec_realt
> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_hda_codec
> iTCO_wdt elo irqbypass iTCO_vendor_support intel_cstate snd_hda_core
> intel_uncore snd_hwdep intel_rapl_perf snd_pcm pcspkr
>  i2c_i801 snd_timer e1000e snd joydev lpc_ich soundcore ip6t_REJECT
> nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables nf_log_ipv4
> nf_log_common xt_LOG xt_limit xt_multiport xt_conntrack
>  iptable_nat nf_nat xt_connmark nf_conntrack nf_defrag_ipv6
> nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl i2c_algo_bit
> drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm cr
> c32_pclmul crc32c_intel serio_raw video
> [  133.320463] CPU: 0 PID: 739 Comm: Xorg Not tainted 5.3.8 #1
> [  133.320465] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
> BIOS XBKT200 01/04/2017
> [  133.320467] EIP: report_addr+0x3e/0x70
> [  133.320470] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d 9c 16 14 d0 00 0f 84 24 09 00
> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
> [  133.320472] EAX: 00000000 EBX: 00000000 ECX: f5b89e00 EDX: 00000007
> [  133.320473] ESI: ffffffff EDI: ecf3921c EBP: ec56bcf4 ESP: ec56bce8
> [  133.320475] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
> 00213286
> [  133.320476] CR0: 80050033 CR2: b7236020 CR3: 2c72a000 CR4: 000406f0
> [  133.320477] Call Trace:
> [  133.320484]  dma_direct_map_page+0x158/0x180
> [  133.320487]  dma_direct_map_sg+0x4f/0xa0
> [  133.320564]  i915_gem_map_dma_buf+0x1b8/0x1d0 [i915]
> [  133.320568]  dma_buf_map_attachment+0x4f/0x90
> [  133.320572]  udl_gem_prime_import+0x43/0x12a [udl]
> [  133.320607]  drm_gem_prime_fd_to_handle+0x97/0x180 [drm]
> [  133.320625]  ? drm_gem_prime_export+0xa0/0xa0 [drm]
> [  133.320642]  ? drm_gem_prime_import+0x20/0x20 [drm]
> [  133.320658]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
> [  133.320673]  drm_prime_fd_to_handle_ioctl+0x2f/0x50 [drm]
> [  133.320689]  drm_ioctl_kernel+0x8f/0xd0 [drm]
> [  133.320706]  drm_ioctl+0x21c/0x3c0 [drm]
> [  133.320721]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
> [  133.320726]  ? file_modified+0x30/0x30
> [  133.320728]  ? file_update_time+0xfe/0x130
> [  133.320731]  ? page_add_file_rmap+0x72/0xd0
> [  133.320734]  ? fault_dirty_shared_page.isra.122+0x6d/0xb0
> [  133.320750]  ? drm_version+0x80/0x80 [drm]
> [  133.320753]  do_vfs_ioctl+0x9a/0x6c0
> [  133.320757]  ksys_ioctl+0x56/0x80
> [  133.320760]  sys_ioctl+0x16/0x20
> [  133.320763]  do_fast_syscall_32+0x82/0x1c7
> [  133.320766]  entry_SYSENTER_32+0x9f/0xf2
> [  133.320768] EIP: 0xb7f84a75
> [  133.320770] Code: e8 1c 00 00 00 89 d3 eb cf 8d 74 26 00 b8 40 42 0f
> 00 eb b5 8b 04 24 c3 8b 1c 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
> [  133.320772] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bff26be0
> [  133.320773] ESI: 0221ad20 EDI: c00c642e EBP: 0000000c ESP: bff26b88
> [  133.320775] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
> 00203296
> [  133.320777] ---[ end trace 18cd4f77716f2f5f ]---
> 
> With your drm-next and your patch set, the call trace is obviously
> different:
> 
> [   37.486584] udl 2-1.2:1.0: swiotlb buffer is full (sz: 536576 bytes),
> total 32768 (slots), used 1536 (slots)
> [   37.486591] udl 2-1.2:1.0: overflow 0x000000011a47d000+536576 of DMA
> mask ffffffff bus mask 0
> [   37.486598] ------------[ cut here ]------------
> [   37.486606] WARNING: CPU: 1 PID: 749 at kernel/dma/direct.c:35
> report_addr+0x3e/0x70
> [   37.486607] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
> kvm_intel kvm snd_hda_codec_hdmi snd_hda_codec_realt
> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_nhlt
> snd_hda_codec iTCO_wdt iTCO_vendor_support elo irqbypass snd_hda_core
> intel_cstate intel_uncore snd_hwdep snd_pcm intel_r
> apl_perf e1000e pcspkr joydev i2c_i801 snd_timer lpc_ich snd soundcore
> ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables
> nf_log_ipv4 nf_log_common xt_LOG xt_limit xt_multipo
> rt xt_conntrack iptable_nat nf_nat xt_connmark nf_conntrack
> nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl
> i2c_algo_bit drm_kms_helper syscopyarea sysfillrect crc32_pclmul
> sysimgblt crc32c_intel fb_sys_fops serio_raw drm video
> [   37.486647] CPU: 1 PID: 749 Comm: Xorg Tainted: G        W        
> 5.4.0-rc4+ #1
> [   37.486648] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
> BIOS XBKT200 01/04/2017
> [   37.486652] EIP: report_addr+0x3e/0x70
> [   37.486655] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d b0 7d 95 d2 00 0f 84 c4 08 00
> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
> [   37.486656] EAX: 00000000 EBX: 00000000 ECX: f68e3e00 EDX: 00000007
> [   37.486657] ESI: ed77f81c EDI: ffffffff EBP: ed1e5cfc ESP: ed1e5cf0
> [   37.486659] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
> 00213286
> [   37.486661] CR0: 80050033 CR2: b7223020 CR3: 2cad8000 CR4: 000406f0
> [   37.486662] Call Trace:
> [   37.486669]  dma_direct_map_page+0x158/0x180
> [   37.486673]  dma_direct_map_sg+0x4f/0xa0
> [   37.486744]  i915_gem_map_dma_buf+0x114/0x190 [i915]
> [   37.486748]  dma_buf_map_attachment+0x4f/0x90
> [   37.486781]  drm_gem_prime_import_dev+0x5d/0x100 [drm]
> [   37.486802]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
> [   37.486821]  drm_gem_prime_fd_to_handle+0x158/0x180 [drm]
> [   37.486838]  ? drm_gem_prime_import+0x20/0x20 [drm]
> [   37.486854]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
> [   37.486871]  drm_prime_fd_to_handle_ioctl+0x21/0x30 [drm]
> [   37.486888]  drm_ioctl_kernel+0x99/0xe0 [drm]
> [   37.486904]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
> [   37.486922]  drm_ioctl+0x21a/0x380 [drm]
> [   37.486938]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
> [   37.486942]  ? __send_signal+0x2a4/0x3e0
> [   37.486944]  ? send_signal+0xb0/0xf0
> [   37.486946]  ? do_send_sig_info+0x4b/0x80
> [   37.486963]  ? drm_ioctl_kernel+0xe0/0xe0 [drm]
> [   37.486967]  do_vfs_ioctl+0x3fa/0x6b0
> [   37.486969]  ? kill_pid_info+0x31/0x60
> [   37.486973]  ? ktime_get+0x4c/0x110
> [   37.486977]  ksys_ioctl+0x5d/0x90
> [   37.486980]  sys_ioctl+0x16/0x20
> [   37.486983]  do_fast_syscall_32+0x82/0x1c7
> [   37.486988]  entry_SYSENTER_32+0x9f/0xf2
> [   37.486989] EIP: 0xb7f75b55
> [   37.486992] Code: 00 00 8d 76 00 b8 40 42 0f 00 eb bb 8b 04 24 c3 8b
> 14 24 c3 8b 1c 24 c3 8b 34 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
> [   37.486994] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bfd13dc0
> [   37.486995] ESI: 01c03520 EDI: c00c642e EBP: 0000000c ESP: bfd13d68
> [   37.486997] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
> 00203292
> [   37.486999] ---[ end trace cef48717f4fbe0fa ]---
> 
> It seems I get random successes with mostly failures of this kind:
> 
> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --below DP-1
> xrandr: Configure crtc 2 failed
> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
> xrandr: Configure crtc 2 failed
> 
> These messages appear for failed attempts:
> 
> [  552.197202] udl 2-1.2:1.0: swiotlb buffer is full (sz: 360448 bytes),
> total 32768 (slots), used 98 (slots)
> [  552.387539] udl 2-1.2:1.0: swiotlb buffer is full (sz: 819200 bytes),
> total 32768 (slots), used 210 (slots)
> [  562.139080] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2723840
> bytes), total 32768 (slots), used 206 (slots)
> [  709.666258] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
> bytes), total 32768 (slots), used 20 (slots)
> [  709.868665] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
> bytes), total 32768 (slots), used 14 (slots)
> [  721.728930] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3133440
> bytes), total 32768 (slots), used 6 (slots)
> [  738.187591] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes),
> total 32768 (slots), used 238 (slots)
> [  738.373190] udl 2-1.2:1.0: swiotlb buffer is full (sz: 950272 bytes),
> total 32768 (slots), used 664 (slots)
> [  738.990204] udl 2-1.2:1.0: swiotlb buffer is full (sz: 983040 bytes),
> total 32768 (slots), used 24 (slots)
> [  743.599439] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2826240
> bytes), total 32768 (slots), used 156 (slots)
> 
> Best regards,
> Zoltán Böszörményi
> 
>>
>> v3:
>>     * restore udl vmap function that enables caching
>> v2:
>>     * remove obsolete udl code in a separate patch
>>
>> Thomas Zimmermann (4):
>>    drm/udl: Remove flags field from struct udl_gem_object
>>    drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
>>    drm/udl: Switch to SHMEM
>>    drm/udl: Remove struct udl_gem_object and functions
>>
>>   drivers/gpu/drm/udl/Kconfig      |   1 +
>>   drivers/gpu/drm/udl/Makefile     |   2 +-
>>   drivers/gpu/drm/udl/udl_dmabuf.c | 255 ------------------------------
>>   drivers/gpu/drm/udl/udl_drv.c    |  30 +---
>>   drivers/gpu/drm/udl/udl_drv.h    |  36 +----
>>   drivers/gpu/drm/udl/udl_fb.c     |  66 ++++----
>>   drivers/gpu/drm/udl/udl_gem.c    | 263 +++++++++----------------------
>>   7 files changed, 122 insertions(+), 531 deletions(-)
>>   delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c
>>
>> -- 
>> 2.23.0
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3 0/4] drm/udl: Convert to SHMEM
  2019-11-08  7:36   ` Thomas Zimmermann
@ 2019-11-08 12:06     ` Böszörményi Zoltán
  2019-11-08 12:22       ` Thomas Zimmermann
  0 siblings, 1 reply; 10+ messages in thread
From: Böszörményi Zoltán @ 2019-11-08 12:06 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied, sean, daniel, noralf, sam,
	emil.velikov, kraxel
  Cc: dri-devel

Hi!

2019. 11. 08. 8:36 keltezéssel, Thomas Zimmermann írta:
> Hi Böszörményi

FYI, it's Zoltan, as it's my first name. :-)

> Am 07.11.19 um 16:10 schrieb Böszörményi Zoltán:
> Have you tried to increase the buffer size? There's a command-line
> option to control this setting. [1]

Yes, I did, it didn't help. I used swiotlb=49152 (96MB) and
swiotlb=65536 (128MB) vs the default 32768 (64MB).

This parameter controls the _number of slab slots_ instead of
a single contiguous size as I read in the kernel sources.

With swiotlb=65536 I get the same error and dmesg lines:

[   97.671898] udl 2-1.2:1.0: swiotlb buffer is full (sz: 1978368 bytes), total 65536 
(slots), used 28 (slots)
[  107.477068] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes), total 65536 
(slots), used 584 (slots)
[  108.311947] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2080768 bytes), total 65536 
(slots), used 0 (slots)
[  110.330940] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3031040 bytes), total 65536 
(slots), used 56 (slots)
[  111.102755] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3145728 bytes), total 65536 
(slots), used 1536 (slots)

It turned out, it's the combination of IO_TLB_SEGSIZE * (1<<IO_TLB_SHIFT)
that is too small. It is currently 128 * 2KB if I'm counting right in binary.

I have just tried with these settings in swiotlb.h:

#define IO_TLB_SHIFT 12
#define IO_TLB_SEGSIZE 1024

That's 4MB, used as contiguous DMA memory. The whole swiotlb aperture
is still 64MB, it's just that there is now a smaller number of larger buffers.

The warning messages were all about buffer sizes smaller than 4MB,
so I thought it worth a try and it indeed fixed the issue.

Now I can reliably reconfigure the monitor's orientation attached
to UDL in relation to the monitors attached to the Intel device.

I remember having the same "swiotlb buffer is full" issue during the late
2.6.x kernel series, around Fedora 27 or so, with the radeon driver.

I don't know if changing the swiotlb values is the proper solution, or
to add some scatter-gather interface somewhere in UDL or PRIME or whatever.

Now, where should I post this report? Kernel bugzilla? Or is this mail thread enough?

To get back to the topic of this patchset, you can add my:

Tested-by: Zoltán Böszörményi <zboszor@pr.hu>

Best regards,
Zoltán

> 
> Best regards
> Thomas
> 
> [1] https://wiki.gentoo.org/wiki/IOMMU_SWIOTLB
> 
> 
>> [  133.320410] udl 2-1.2:1.0: overflow 0x00000001199e4000+2211840 of DMA
>> mask ffffffff bus mask 0
>> [  133.320424] WARNING: CPU: 0 PID: 739 at kernel/dma/direct.c:35
>> report_addr+0x3e/0x70
>> [  133.320425] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
>> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
>> kvm_intel snd_hda_codec_hdmi kvm snd_hda_codec_realt
>> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_hda_codec
>> iTCO_wdt elo irqbypass iTCO_vendor_support intel_cstate snd_hda_core
>> intel_uncore snd_hwdep intel_rapl_perf snd_pcm pcspkr
>>   i2c_i801 snd_timer e1000e snd joydev lpc_ich soundcore ip6t_REJECT
>> nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables nf_log_ipv4
>> nf_log_common xt_LOG xt_limit xt_multiport xt_conntrack
>>   iptable_nat nf_nat xt_connmark nf_conntrack nf_defrag_ipv6
>> nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl i2c_algo_bit
>> drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm cr
>> c32_pclmul crc32c_intel serio_raw video
>> [  133.320463] CPU: 0 PID: 739 Comm: Xorg Not tainted 5.3.8 #1
>> [  133.320465] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
>> BIOS XBKT200 01/04/2017
>> [  133.320467] EIP: report_addr+0x3e/0x70
>> [  133.320470] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
>> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d 9c 16 14 d0 00 0f 84 24 09 00
>> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
>> [  133.320472] EAX: 00000000 EBX: 00000000 ECX: f5b89e00 EDX: 00000007
>> [  133.320473] ESI: ffffffff EDI: ecf3921c EBP: ec56bcf4 ESP: ec56bce8
>> [  133.320475] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
>> 00213286
>> [  133.320476] CR0: 80050033 CR2: b7236020 CR3: 2c72a000 CR4: 000406f0
>> [  133.320477] Call Trace:
>> [  133.320484]  dma_direct_map_page+0x158/0x180
>> [  133.320487]  dma_direct_map_sg+0x4f/0xa0
>> [  133.320564]  i915_gem_map_dma_buf+0x1b8/0x1d0 [i915]
>> [  133.320568]  dma_buf_map_attachment+0x4f/0x90
>> [  133.320572]  udl_gem_prime_import+0x43/0x12a [udl]
>> [  133.320607]  drm_gem_prime_fd_to_handle+0x97/0x180 [drm]
>> [  133.320625]  ? drm_gem_prime_export+0xa0/0xa0 [drm]
>> [  133.320642]  ? drm_gem_prime_import+0x20/0x20 [drm]
>> [  133.320658]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
>> [  133.320673]  drm_prime_fd_to_handle_ioctl+0x2f/0x50 [drm]
>> [  133.320689]  drm_ioctl_kernel+0x8f/0xd0 [drm]
>> [  133.320706]  drm_ioctl+0x21c/0x3c0 [drm]
>> [  133.320721]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
>> [  133.320726]  ? file_modified+0x30/0x30
>> [  133.320728]  ? file_update_time+0xfe/0x130
>> [  133.320731]  ? page_add_file_rmap+0x72/0xd0
>> [  133.320734]  ? fault_dirty_shared_page.isra.122+0x6d/0xb0
>> [  133.320750]  ? drm_version+0x80/0x80 [drm]
>> [  133.320753]  do_vfs_ioctl+0x9a/0x6c0
>> [  133.320757]  ksys_ioctl+0x56/0x80
>> [  133.320760]  sys_ioctl+0x16/0x20
>> [  133.320763]  do_fast_syscall_32+0x82/0x1c7
>> [  133.320766]  entry_SYSENTER_32+0x9f/0xf2
>> [  133.320768] EIP: 0xb7f84a75
>> [  133.320770] Code: e8 1c 00 00 00 89 d3 eb cf 8d 74 26 00 b8 40 42 0f
>> 00 eb b5 8b 04 24 c3 8b 1c 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
>> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
>> [  133.320772] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bff26be0
>> [  133.320773] ESI: 0221ad20 EDI: c00c642e EBP: 0000000c ESP: bff26b88
>> [  133.320775] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
>> 00203296
>> [  133.320777] ---[ end trace 18cd4f77716f2f5f ]---
>>
>> With your drm-next and your patch set, the call trace is obviously
>> different:
>>
>> [   37.486584] udl 2-1.2:1.0: swiotlb buffer is full (sz: 536576 bytes),
>> total 32768 (slots), used 1536 (slots)
>> [   37.486591] udl 2-1.2:1.0: overflow 0x000000011a47d000+536576 of DMA
>> mask ffffffff bus mask 0
>> [   37.486598] ------------[ cut here ]------------
>> [   37.486606] WARNING: CPU: 1 PID: 749 at kernel/dma/direct.c:35
>> report_addr+0x3e/0x70
>> [   37.486607] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
>> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
>> kvm_intel kvm snd_hda_codec_hdmi snd_hda_codec_realt
>> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_nhlt
>> snd_hda_codec iTCO_wdt iTCO_vendor_support elo irqbypass snd_hda_core
>> intel_cstate intel_uncore snd_hwdep snd_pcm intel_r
>> apl_perf e1000e pcspkr joydev i2c_i801 snd_timer lpc_ich snd soundcore
>> ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables
>> nf_log_ipv4 nf_log_common xt_LOG xt_limit xt_multipo
>> rt xt_conntrack iptable_nat nf_nat xt_connmark nf_conntrack
>> nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl
>> i2c_algo_bit drm_kms_helper syscopyarea sysfillrect crc32_pclmul
>> sysimgblt crc32c_intel fb_sys_fops serio_raw drm video
>> [   37.486647] CPU: 1 PID: 749 Comm: Xorg Tainted: G        W
>> 5.4.0-rc4+ #1
>> [   37.486648] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
>> BIOS XBKT200 01/04/2017
>> [   37.486652] EIP: report_addr+0x3e/0x70
>> [   37.486655] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
>> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d b0 7d 95 d2 00 0f 84 c4 08 00
>> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
>> [   37.486656] EAX: 00000000 EBX: 00000000 ECX: f68e3e00 EDX: 00000007
>> [   37.486657] ESI: ed77f81c EDI: ffffffff EBP: ed1e5cfc ESP: ed1e5cf0
>> [   37.486659] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
>> 00213286
>> [   37.486661] CR0: 80050033 CR2: b7223020 CR3: 2cad8000 CR4: 000406f0
>> [   37.486662] Call Trace:
>> [   37.486669]  dma_direct_map_page+0x158/0x180
>> [   37.486673]  dma_direct_map_sg+0x4f/0xa0
>> [   37.486744]  i915_gem_map_dma_buf+0x114/0x190 [i915]
>> [   37.486748]  dma_buf_map_attachment+0x4f/0x90
>> [   37.486781]  drm_gem_prime_import_dev+0x5d/0x100 [drm]
>> [   37.486802]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>> [   37.486821]  drm_gem_prime_fd_to_handle+0x158/0x180 [drm]
>> [   37.486838]  ? drm_gem_prime_import+0x20/0x20 [drm]
>> [   37.486854]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>> [   37.486871]  drm_prime_fd_to_handle_ioctl+0x21/0x30 [drm]
>> [   37.486888]  drm_ioctl_kernel+0x99/0xe0 [drm]
>> [   37.486904]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>> [   37.486922]  drm_ioctl+0x21a/0x380 [drm]
>> [   37.486938]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>> [   37.486942]  ? __send_signal+0x2a4/0x3e0
>> [   37.486944]  ? send_signal+0xb0/0xf0
>> [   37.486946]  ? do_send_sig_info+0x4b/0x80
>> [   37.486963]  ? drm_ioctl_kernel+0xe0/0xe0 [drm]
>> [   37.486967]  do_vfs_ioctl+0x3fa/0x6b0
>> [   37.486969]  ? kill_pid_info+0x31/0x60
>> [   37.486973]  ? ktime_get+0x4c/0x110
>> [   37.486977]  ksys_ioctl+0x5d/0x90
>> [   37.486980]  sys_ioctl+0x16/0x20
>> [   37.486983]  do_fast_syscall_32+0x82/0x1c7
>> [   37.486988]  entry_SYSENTER_32+0x9f/0xf2
>> [   37.486989] EIP: 0xb7f75b55
>> [   37.486992] Code: 00 00 8d 76 00 b8 40 42 0f 00 eb bb 8b 04 24 c3 8b
>> 14 24 c3 8b 1c 24 c3 8b 34 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
>> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
>> [   37.486994] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bfd13dc0
>> [   37.486995] ESI: 01c03520 EDI: c00c642e EBP: 0000000c ESP: bfd13d68
>> [   37.486997] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
>> 00203292
>> [   37.486999] ---[ end trace cef48717f4fbe0fa ]---
>>
>> It seems I get random successes with mostly failures of this kind:
>>
>> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --below DP-1
>> xrandr: Configure crtc 2 failed
>> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
>> xrandr: Configure crtc 2 failed
>>
>> These messages appear for failed attempts:
>>
>> [  552.197202] udl 2-1.2:1.0: swiotlb buffer is full (sz: 360448 bytes),
>> total 32768 (slots), used 98 (slots)
>> [  552.387539] udl 2-1.2:1.0: swiotlb buffer is full (sz: 819200 bytes),
>> total 32768 (slots), used 210 (slots)
>> [  562.139080] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2723840
>> bytes), total 32768 (slots), used 206 (slots)
>> [  709.666258] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
>> bytes), total 32768 (slots), used 20 (slots)
>> [  709.868665] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
>> bytes), total 32768 (slots), used 14 (slots)
>> [  721.728930] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3133440
>> bytes), total 32768 (slots), used 6 (slots)
>> [  738.187591] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes),
>> total 32768 (slots), used 238 (slots)
>> [  738.373190] udl 2-1.2:1.0: swiotlb buffer is full (sz: 950272 bytes),
>> total 32768 (slots), used 664 (slots)
>> [  738.990204] udl 2-1.2:1.0: swiotlb buffer is full (sz: 983040 bytes),
>> total 32768 (slots), used 24 (slots)
>> [  743.599439] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2826240
>> bytes), total 32768 (slots), used 156 (slots)
>>
>> Best regards,
>> Zoltán Böszörményi
>>
>>>
>>> v3:
>>>      * restore udl vmap function that enables caching
>>> v2:
>>>      * remove obsolete udl code in a separate patch
>>>
>>> Thomas Zimmermann (4):
>>>     drm/udl: Remove flags field from struct udl_gem_object
>>>     drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
>>>     drm/udl: Switch to SHMEM
>>>     drm/udl: Remove struct udl_gem_object and functions
>>>
>>>    drivers/gpu/drm/udl/Kconfig      |   1 +
>>>    drivers/gpu/drm/udl/Makefile     |   2 +-
>>>    drivers/gpu/drm/udl/udl_dmabuf.c | 255 ------------------------------
>>>    drivers/gpu/drm/udl/udl_drv.c    |  30 +---
>>>    drivers/gpu/drm/udl/udl_drv.h    |  36 +----
>>>    drivers/gpu/drm/udl/udl_fb.c     |  66 ++++----
>>>    drivers/gpu/drm/udl/udl_gem.c    | 263 +++++++++----------------------
>>>    7 files changed, 122 insertions(+), 531 deletions(-)
>>>    delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c
>>>
>>> -- 
>>> 2.23.0
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3 0/4] drm/udl: Convert to SHMEM
  2019-11-08 12:06     ` Böszörményi Zoltán
@ 2019-11-08 12:22       ` Thomas Zimmermann
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2019-11-08 12:22 UTC (permalink / raw)
  To: Böszörményi Zoltán, airlied, sean, daniel,
	noralf, sam, emil.velikov, kraxel
  Cc: dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 14382 bytes --]

Hi

Am 08.11.19 um 13:06 schrieb Böszörményi Zoltán:
> Hi!
> 
> 2019. 11. 08. 8:36 keltezéssel, Thomas Zimmermann írta:
>> Hi Böszörményi
> 
> FYI, it's Zoltan, as it's my first name. :-)

Sorry.

> 
>> Am 07.11.19 um 16:10 schrieb Böszörményi Zoltán:
>> Have you tried to increase the buffer size? There's a command-line
>> option to control this setting. [1]
> 
> Yes, I did, it didn't help. I used swiotlb=49152 (96MB) and
> swiotlb=65536 (128MB) vs the default 32768 (64MB).
> 
> This parameter controls the _number of slab slots_ instead of
> a single contiguous size as I read in the kernel sources.
> 
> With swiotlb=65536 I get the same error and dmesg lines:
> 
> [   97.671898] udl 2-1.2:1.0: swiotlb buffer is full (sz: 1978368
> bytes), total 65536 (slots), used 28 (slots)
> [  107.477068] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes),
> total 65536 (slots), used 584 (slots)
> [  108.311947] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2080768
> bytes), total 65536 (slots), used 0 (slots)
> [  110.330940] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3031040
> bytes), total 65536 (slots), used 56 (slots)
> [  111.102755] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3145728
> bytes), total 65536 (slots), used 1536 (slots)
> 
> It turned out, it's the combination of IO_TLB_SEGSIZE * (1<<IO_TLB_SHIFT)
> that is too small. It is currently 128 * 2KB if I'm counting right in
> binary.
> 
> I have just tried with these settings in swiotlb.h:
> 
> #define IO_TLB_SHIFT 12
> #define IO_TLB_SEGSIZE 1024
> 
> That's 4MB, used as contiguous DMA memory. The whole swiotlb aperture
> is still 64MB, it's just that there is now a smaller number of larger
> buffers.
> 
> The warning messages were all about buffer sizes smaller than 4MB,
> so I thought it worth a try and it indeed fixed the issue.
> 
> Now I can reliably reconfigure the monitor's orientation attached
> to UDL in relation to the monitors attached to the Intel device.

Great!

> 
> I remember having the same "swiotlb buffer is full" issue during the late
> 2.6.x kernel series, around Fedora 27 or so, with the radeon driver.
> 
> I don't know if changing the swiotlb values is the proper solution, or
> to add some scatter-gather interface somewhere in UDL or PRIME or whatever.
> 
> Now, where should I post this report? Kernel bugzilla? Or is this mail
> thread enough?

There's an entry with contact info for swiotlb in MAINTAINERS.


> 
> To get back to the topic of this patchset, you can add my:
> 
> Tested-by: Zoltán Böszörményi <zboszor@pr.hu>

Thanks for testing the patchset. I push it shortly before receiving your
mail, unfortunately.

Best regards
Thomas

> 
> Best regards,
> Zoltán
> 
>>
>> Best regards
>> Thomas
>>
>> [1] https://wiki.gentoo.org/wiki/IOMMU_SWIOTLB
>>
>>
>>> [  133.320410] udl 2-1.2:1.0: overflow 0x00000001199e4000+2211840 of DMA
>>> mask ffffffff bus mask 0
>>> [  133.320424] WARNING: CPU: 0 PID: 739 at kernel/dma/direct.c:35
>>> report_addr+0x3e/0x70
>>> [  133.320425] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
>>> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
>>> kvm_intel snd_hda_codec_hdmi kvm snd_hda_codec_realt
>>> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_hda_codec
>>> iTCO_wdt elo irqbypass iTCO_vendor_support intel_cstate snd_hda_core
>>> intel_uncore snd_hwdep intel_rapl_perf snd_pcm pcspkr
>>>   i2c_i801 snd_timer e1000e snd joydev lpc_ich soundcore ip6t_REJECT
>>> nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables nf_log_ipv4
>>> nf_log_common xt_LOG xt_limit xt_multiport xt_conntrack
>>>   iptable_nat nf_nat xt_connmark nf_conntrack nf_defrag_ipv6
>>> nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl i2c_algo_bit
>>> drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm cr
>>> c32_pclmul crc32c_intel serio_raw video
>>> [  133.320463] CPU: 0 PID: 739 Comm: Xorg Not tainted 5.3.8 #1
>>> [  133.320465] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
>>> BIOS XBKT200 01/04/2017
>>> [  133.320467] EIP: report_addr+0x3e/0x70
>>> [  133.320470] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
>>> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d 9c 16 14 d0 00 0f 84 24 09 00
>>> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
>>> [  133.320472] EAX: 00000000 EBX: 00000000 ECX: f5b89e00 EDX: 00000007
>>> [  133.320473] ESI: ffffffff EDI: ecf3921c EBP: ec56bcf4 ESP: ec56bce8
>>> [  133.320475] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
>>> 00213286
>>> [  133.320476] CR0: 80050033 CR2: b7236020 CR3: 2c72a000 CR4: 000406f0
>>> [  133.320477] Call Trace:
>>> [  133.320484]  dma_direct_map_page+0x158/0x180
>>> [  133.320487]  dma_direct_map_sg+0x4f/0xa0
>>> [  133.320564]  i915_gem_map_dma_buf+0x1b8/0x1d0 [i915]
>>> [  133.320568]  dma_buf_map_attachment+0x4f/0x90
>>> [  133.320572]  udl_gem_prime_import+0x43/0x12a [udl]
>>> [  133.320607]  drm_gem_prime_fd_to_handle+0x97/0x180 [drm]
>>> [  133.320625]  ? drm_gem_prime_export+0xa0/0xa0 [drm]
>>> [  133.320642]  ? drm_gem_prime_import+0x20/0x20 [drm]
>>> [  133.320658]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
>>> [  133.320673]  drm_prime_fd_to_handle_ioctl+0x2f/0x50 [drm]
>>> [  133.320689]  drm_ioctl_kernel+0x8f/0xd0 [drm]
>>> [  133.320706]  drm_ioctl+0x21c/0x3c0 [drm]
>>> [  133.320721]  ? drm_prime_handle_to_fd_ioctl+0x70/0x70 [drm]
>>> [  133.320726]  ? file_modified+0x30/0x30
>>> [  133.320728]  ? file_update_time+0xfe/0x130
>>> [  133.320731]  ? page_add_file_rmap+0x72/0xd0
>>> [  133.320734]  ? fault_dirty_shared_page.isra.122+0x6d/0xb0
>>> [  133.320750]  ? drm_version+0x80/0x80 [drm]
>>> [  133.320753]  do_vfs_ioctl+0x9a/0x6c0
>>> [  133.320757]  ksys_ioctl+0x56/0x80
>>> [  133.320760]  sys_ioctl+0x16/0x20
>>> [  133.320763]  do_fast_syscall_32+0x82/0x1c7
>>> [  133.320766]  entry_SYSENTER_32+0x9f/0xf2
>>> [  133.320768] EIP: 0xb7f84a75
>>> [  133.320770] Code: e8 1c 00 00 00 89 d3 eb cf 8d 74 26 00 b8 40 42 0f
>>> 00 eb b5 8b 04 24 c3 8b 1c 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
>>> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
>>> [  133.320772] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bff26be0
>>> [  133.320773] ESI: 0221ad20 EDI: c00c642e EBP: 0000000c ESP: bff26b88
>>> [  133.320775] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
>>> 00203296
>>> [  133.320777] ---[ end trace 18cd4f77716f2f5f ]---
>>>
>>> With your drm-next and your patch set, the call trace is obviously
>>> different:
>>>
>>> [   37.486584] udl 2-1.2:1.0: swiotlb buffer is full (sz: 536576 bytes),
>>> total 32768 (slots), used 1536 (slots)
>>> [   37.486591] udl 2-1.2:1.0: overflow 0x000000011a47d000+536576 of DMA
>>> mask ffffffff bus mask 0
>>> [   37.486598] ------------[ cut here ]------------
>>> [   37.486606] WARNING: CPU: 1 PID: 749 at kernel/dma/direct.c:35
>>> report_addr+0x3e/0x70
>>> [   37.486607] Modules linked in: 8021q garp mrp stp llc intel_rapl_msr
>>> intel_rapl_common x86_pkg_temp_thermal intel_powerclamp coretemp
>>> kvm_intel kvm snd_hda_codec_hdmi snd_hda_codec_realt
>>> ek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_nhlt
>>> snd_hda_codec iTCO_wdt iTCO_vendor_support elo irqbypass snd_hda_core
>>> intel_cstate intel_uncore snd_hwdep snd_pcm intel_r
>>> apl_perf e1000e pcspkr joydev i2c_i801 snd_timer lpc_ich snd soundcore
>>> ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 ip6table_filter ip6_tables
>>> nf_log_ipv4 nf_log_common xt_LOG xt_limit xt_multipo
>>> rt xt_conntrack iptable_nat nf_nat xt_connmark nf_conntrack
>>> nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_mangle i915 udl
>>> i2c_algo_bit drm_kms_helper syscopyarea sysfillrect crc32_pclmul
>>> sysimgblt crc32c_intel fb_sys_fops serio_raw drm video
>>> [   37.486647] CPU: 1 PID: 749 Comm: Xorg Tainted: G        W
>>> 5.4.0-rc4+ #1
>>> [   37.486648] Hardware name: TOSHIBA 4852E70/Intel H61 Express Chipset,
>>> BIOS XBKT200 01/04/2017
>>> [   37.486652] EIP: report_addr+0x3e/0x70
>>> [   37.486655] Code: 00 89 4d f8 85 d2 74 44 8b 0a 8b 5a 04 ba fe ff ff
>>> ff 39 ca ba 00 00 00 00 19 da 73 17 80 3d b0 7d 95 d2 00 0f 84 c4 08 00
>>> 00 <0f> 0b 8b 5d fc c9 c3 8d 76 00 8b 90 5c 01 00 00 0b 90 58 01 00 00
>>> [   37.486656] EAX: 00000000 EBX: 00000000 ECX: f68e3e00 EDX: 00000007
>>> [   37.486657] ESI: ed77f81c EDI: ffffffff EBP: ed1e5cfc ESP: ed1e5cf0
>>> [   37.486659] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS:
>>> 00213286
>>> [   37.486661] CR0: 80050033 CR2: b7223020 CR3: 2cad8000 CR4: 000406f0
>>> [   37.486662] Call Trace:
>>> [   37.486669]  dma_direct_map_page+0x158/0x180
>>> [   37.486673]  dma_direct_map_sg+0x4f/0xa0
>>> [   37.486744]  i915_gem_map_dma_buf+0x114/0x190 [i915]
>>> [   37.486748]  dma_buf_map_attachment+0x4f/0x90
>>> [   37.486781]  drm_gem_prime_import_dev+0x5d/0x100 [drm]
>>> [   37.486802]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>>> [   37.486821]  drm_gem_prime_fd_to_handle+0x158/0x180 [drm]
>>> [   37.486838]  ? drm_gem_prime_import+0x20/0x20 [drm]
>>> [   37.486854]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>>> [   37.486871]  drm_prime_fd_to_handle_ioctl+0x21/0x30 [drm]
>>> [   37.486888]  drm_ioctl_kernel+0x99/0xe0 [drm]
>>> [   37.486904]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>>> [   37.486922]  drm_ioctl+0x21a/0x380 [drm]
>>> [   37.486938]  ? drm_prime_destroy_file_private+0x20/0x20 [drm]
>>> [   37.486942]  ? __send_signal+0x2a4/0x3e0
>>> [   37.486944]  ? send_signal+0xb0/0xf0
>>> [   37.486946]  ? do_send_sig_info+0x4b/0x80
>>> [   37.486963]  ? drm_ioctl_kernel+0xe0/0xe0 [drm]
>>> [   37.486967]  do_vfs_ioctl+0x3fa/0x6b0
>>> [   37.486969]  ? kill_pid_info+0x31/0x60
>>> [   37.486973]  ? ktime_get+0x4c/0x110
>>> [   37.486977]  ksys_ioctl+0x5d/0x90
>>> [   37.486980]  sys_ioctl+0x16/0x20
>>> [   37.486983]  do_fast_syscall_32+0x82/0x1c7
>>> [   37.486988]  entry_SYSENTER_32+0x9f/0xf2
>>> [   37.486989] EIP: 0xb7f75b55
>>> [   37.486992] Code: 00 00 8d 76 00 b8 40 42 0f 00 eb bb 8b 04 24 c3 8b
>>> 14 24 c3 8b 1c 24 c3 8b 34 24 c3 8b 3c 24 c3 90 51 52 55 89 e5 0f 34 cd
>>> 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76
>>> [   37.486994] EAX: ffffffda EBX: 0000000c ECX: c00c642e EDX: bfd13dc0
>>> [   37.486995] ESI: 01c03520 EDI: c00c642e EBP: 0000000c ESP: bfd13d68
>>> [   37.486997] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS:
>>> 00203292
>>> [   37.486999] ---[ end trace cef48717f4fbe0fa ]---
>>>
>>> It seems I get random successes with mostly failures of this kind:
>>>
>>> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --below DP-1
>>> xrandr: Configure crtc 2 failed
>>> # DISPLAY=:0 xrandr --output DVI-I-1-1 --mode 1024x768 --right-of DP-1
>>> xrandr: Configure crtc 2 failed
>>>
>>> These messages appear for failed attempts:
>>>
>>> [  552.197202] udl 2-1.2:1.0: swiotlb buffer is full (sz: 360448 bytes),
>>> total 32768 (slots), used 98 (slots)
>>> [  552.387539] udl 2-1.2:1.0: swiotlb buffer is full (sz: 819200 bytes),
>>> total 32768 (slots), used 210 (slots)
>>> [  562.139080] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2723840
>>> bytes), total 32768 (slots), used 206 (slots)
>>> [  709.666258] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
>>> bytes), total 32768 (slots), used 20 (slots)
>>> [  709.868665] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2097152
>>> bytes), total 32768 (slots), used 14 (slots)
>>> [  721.728930] udl 2-1.2:1.0: swiotlb buffer is full (sz: 3133440
>>> bytes), total 32768 (slots), used 6 (slots)
>>> [  738.187591] udl 2-1.2:1.0: swiotlb buffer is full (sz: 524288 bytes),
>>> total 32768 (slots), used 238 (slots)
>>> [  738.373190] udl 2-1.2:1.0: swiotlb buffer is full (sz: 950272 bytes),
>>> total 32768 (slots), used 664 (slots)
>>> [  738.990204] udl 2-1.2:1.0: swiotlb buffer is full (sz: 983040 bytes),
>>> total 32768 (slots), used 24 (slots)
>>> [  743.599439] udl 2-1.2:1.0: swiotlb buffer is full (sz: 2826240
>>> bytes), total 32768 (slots), used 156 (slots)
>>>
>>> Best regards,
>>> Zoltán Böszörményi
>>>
>>>>
>>>> v3:
>>>>      * restore udl vmap function that enables caching
>>>> v2:
>>>>      * remove obsolete udl code in a separate patch
>>>>
>>>> Thomas Zimmermann (4):
>>>>     drm/udl: Remove flags field from struct udl_gem_object
>>>>     drm/udl: Allocate GEM object via struct
>>>> drm_driver.gem_create_object
>>>>     drm/udl: Switch to SHMEM
>>>>     drm/udl: Remove struct udl_gem_object and functions
>>>>
>>>>    drivers/gpu/drm/udl/Kconfig      |   1 +
>>>>    drivers/gpu/drm/udl/Makefile     |   2 +-
>>>>    drivers/gpu/drm/udl/udl_dmabuf.c | 255
>>>> ------------------------------
>>>>    drivers/gpu/drm/udl/udl_drv.c    |  30 +---
>>>>    drivers/gpu/drm/udl/udl_drv.h    |  36 +----
>>>>    drivers/gpu/drm/udl/udl_fb.c     |  66 ++++----
>>>>    drivers/gpu/drm/udl/udl_gem.c    | 263
>>>> +++++++++----------------------
>>>>    7 files changed, 122 insertions(+), 531 deletions(-)
>>>>    delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c
>>>>
>>>> -- 
>>>> 2.23.0
>>>>
>>>> _______________________________________________
>>>> dri-devel mailing list
>>>> dri-devel@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>>
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-11-08 12:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  9:43 [PATCH v3 0/4] drm/udl: Convert to SHMEM Thomas Zimmermann
2019-11-07  9:43 ` [PATCH v3 1/4] drm/udl: Remove flags field from struct udl_gem_object Thomas Zimmermann
2019-11-07  9:43 ` [PATCH v3 2/4] drm/udl: Allocate GEM object via struct drm_driver.gem_create_object Thomas Zimmermann
2019-11-07  9:43 ` [PATCH v3 3/4] drm/udl: Switch to SHMEM Thomas Zimmermann
2019-11-07  9:43 ` [PATCH v3 4/4] drm/udl: Remove struct udl_gem_object and functions Thomas Zimmermann
2019-11-07 15:10 ` [PATCH v3 0/4] drm/udl: Convert to SHMEM Böszörményi Zoltán
2019-11-08  5:44   ` Böszörményi Zoltán
2019-11-08  7:36   ` Thomas Zimmermann
2019-11-08 12:06     ` Böszörményi Zoltán
2019-11-08 12:22       ` Thomas Zimmermann

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.