Skip to contentSkip to conversation

drm/udl: Convert to SHMEM

PATCH In review Thomas Zimmermann 2 participants 10 messages Nov 7, 2019 – Nov 8, 2019

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

v3 cover drm/udl: Convert to SHMEM

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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#1 lore raw

PATCH v3 1/4 drm/udl: Remove flags field from struct udl_gem_object

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.

---
 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(-)
drivers/gpu/drm/udl/udl_dmabuf.c +0 -1
index 3108e9a9234b..b1c1ee64de59 100644
@@ -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;
 
drivers/gpu/drm/udl/udl_drv.h +0 -4
index 12a970fd9a87..e1306a51903c 100644
@@ -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)
drivers/gpu/drm/udl/udl_gem.c +7 -20
index b23a5c2fcd80..7d3c1b73ea02 100644
@@ -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;
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#2 lore raw

PATCH v3 2/4 drm/udl: Allocate GEM object via struct drm_driver.gem_create_object

In reply to Thomas Zimmermann

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.

---
 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(-)
drivers/gpu/drm/udl/udl_drv.c +1 -0
index 8426669433e4..778a0b652f64 100644
@@ -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,
drivers/gpu/drm/udl/udl_drv.h +2 -0
index e1306a51903c..fc312e791d18 100644
@@ -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);
drivers/gpu/drm/udl/udl_gem.c +21 -4
index 7d3c1b73ea02..628749cc1143 100644
@@ -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
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#3 lore raw

PATCH v3 3/4 drm/udl: Switch to SHMEM

In reply to Thomas Zimmermann

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

---
 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(-)
drivers/gpu/drm/udl/Kconfig +1 -0
index b4d179b87f01..145b2a95ce58 100644
@@ -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.
drivers/gpu/drm/udl/udl_drv.c +3 -26
index 778a0b652f64..563cc5809e56 100644
@@ -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,
drivers/gpu/drm/udl/udl_drv.h +1 -0
index fc312e791d18..630e64abc986 100644
@@ -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 */
 };
 
drivers/gpu/drm/udl/udl_fb.c +36 -30

171 lines not on this page · raw message

drivers/gpu/drm/udl/udl_gem.c +97 -4

121 lines not on this page · raw message

Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#4 lore raw

PATCH v3 4/4 drm/udl: Remove struct udl_gem_object and functions

In reply to Thomas Zimmermann

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

---
 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
drivers/gpu/drm/udl/Makefile +1 -1
index e5bb6f757e11..9c42820ae33d 100644
@@ -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
drivers/gpu/drm/udl/udl_dmabuf.c deleted +0 -254

254 lines not on this page · raw message

drivers/gpu/drm/udl/udl_drv.h +0 -29
index 630e64abc986..987d99ae2dfa 100644
@@ -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);
drivers/gpu/drm/udl/udl_gem.c +0 -206

209 lines not on this page · raw message

Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
In reply to Thomas Zimmermann

Hi,

2019. 11. 07. 10:43 keltezéssel, Thomas Zimmermann írta:

Quoted 11 lines

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.

Quoted 2 lines

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

Quoted 22 lines

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

Quoted 8 lines

--
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

2019. 11. 07. 16:10 keltezéssel, Böszörményi Zoltán írta:

Quoted 4 lines

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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#7 lore raw
In reply to Böszörményi Zoltán

Hi Böszörményi

Am 07.11.19 um 16:10 schrieb Böszörményi Zoltán:

Quoted 108 lines

Hi,

2019. 11. 07. 10:43 keltezéssel, Thomas Zimmermann írta:

Quoted 11 lines

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.

Quoted 2 lines

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

Quoted 6 lines

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

Quoted 203 lines

[  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

Quoted 19 lines

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 +++++++++----------------------

Quoted 11 lines
  7 files changed, 122 insertions(+), 531 deletions(-)

  delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c

Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Hi!

2019. 11. 08. 8:36 keltezéssel, Thomas Zimmermann írta:

Quoted 1 line

Hi Böszörményi

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

Quoted 3 lines

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:

Best regards,
Zoltán

Quoted 211 lines

Best regards
Thomas

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

Quoted 203 lines

[  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

Quoted 20 lines

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(-)
Quoted 10 lines

  delete mode 100644 drivers/gpu/drm/udl/udl_dmabuf.c

Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#9 lore raw

Hi

Am 08.11.19 um 13:06 schrieb Böszörményi Zoltán:

Quoted 6 lines

Hi!

2019. 11. 08. 8:36 keltezéssel, Thomas Zimmermann írta:

Quoted 1 line

Hi Böszörményi

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

Sorry.

Quoted 37 lines
Quoted 4 lines

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.

Quoted 5 lines

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!

Quoted 9 lines

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.

Quoted 4 lines

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

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

Best regards
Thomas

Quoted 223 lines

Best regards,
Zoltán

Quoted 214 lines

Best regards
Thomas

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

Quoted 206 lines

[  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

Quoted 25 lines

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

Quoted 8 lines

--
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel