All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, sean@poorly.run, tiwai@suse.com,
	patrik.r.jakobsson@gmail.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, sashiko-reviews@lists.linux.dev,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 03/11] drm/udl: Store per-URB allocation length in struct urb_node
Date: Thu, 19 Nov 2026 15:02:15 +0100	[thread overview]
Message-ID: <20261119142114.152052-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20261119142114.152052-1-tzimmermann@suse.de>

Store the length of an URB's data buffer in the URB's instance of
struct urb_node. Use the value for free'ing the buffer. Remove the
obsolete size field from struct urb_list.

With the URB cache in place, all URBs have the same buffer size. At
some point we want URBs to have an individual length for their allocated
buffer. Hence, the buffer length needs to be stored separately.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/udl/udl_drv.h  |  2 +-
 drivers/gpu/drm/udl/udl_main.c | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 68c5a5feb6f3..4736d83aec9a 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -37,6 +37,7 @@ struct urb_node {
 	struct list_head entry;
 	struct udl_device *dev;
 	struct urb *urb;
+	size_t alloc_size;
 };
 
 struct urb_list {
@@ -45,7 +46,6 @@ struct urb_list {
 	wait_queue_head_t sleep;
 	int available;
 	int count;
-	size_t size;
 };
 
 struct udl_device {
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index 77b0bc560422..67da676f0f94 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -180,7 +180,7 @@ static void udl_free_urb_list(struct udl_device *udl)
 			break;
 		unode = urb->context;
 		/* Free each separately allocated piece */
-		usb_free_coherent(urb->dev, udl->urbs.size,
+		usb_free_coherent(urb->dev, unode->alloc_size,
 				  urb->transfer_buffer, urb->transfer_dma);
 		usb_free_urb(urb);
 		kfree(unode);
@@ -204,8 +204,6 @@ static int udl_alloc_urb_list(struct udl_device *udl, int count, size_t size)
 	udl->urbs.available = 0;
 
 retry:
-	udl->urbs.size = size;
-
 	while (udl->urbs.count * size < wanted_size) {
 		unode = kzalloc_obj(struct urb_node);
 		if (!unode)
@@ -218,8 +216,9 @@ static int udl_alloc_urb_list(struct udl_device *udl, int count, size_t size)
 			break;
 		}
 		unode->urb = urb;
+		unode->alloc_size = size;
 
-		buf = usb_alloc_coherent(udev, size, GFP_KERNEL,
+		buf = usb_alloc_coherent(udev, unode->alloc_size, GFP_KERNEL,
 					 &urb->transfer_dma);
 		if (!buf) {
 			kfree(unode);
@@ -290,7 +289,7 @@ void udl_put_urb(struct urb *urb)
 	struct udl_device *udl = unode->dev;
 	unsigned long flags;
 
-	urb->transfer_buffer_length = udl->urbs.size; /* reset to actual */
+	urb->transfer_buffer_length = unode->alloc_size; /* reset to actual */
 
 	spin_lock_irqsave(&udl->urbs.lock, flags);
 	list_add_tail(&unode->entry, &udl->urbs.list);
@@ -302,9 +301,11 @@ void udl_put_urb(struct urb *urb)
 
 int udl_submit_urb(struct udl_device *udl, struct urb *urb, size_t len)
 {
+	struct drm_device *drm = &udl->drm;
+	struct urb_node *unode = urb->context;
 	int ret;
 
-	if (WARN_ON(len > udl->urbs.size)) {
+	if (drm_WARN_ON_ONCE(drm, len > unode->alloc_size)) {
 		ret = -EINVAL;
 		goto error;
 	}
-- 
2.56.0


  parent reply	other threads:[~2026-11-19 14:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:02 [PATCH 00/11] drm/udl: Rework URB allocation Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 01/11] drm/udl: Release URB in udl_put_urb() Thomas Zimmermann
2026-11-19 17:03   ` Jie Feng
2026-11-19 14:02 ` [PATCH 02/11] drm/udl: Do not use URB completion handler for error cleanup Thomas Zimmermann
2026-11-19 14:02 ` Thomas Zimmermann [this message]
2026-11-19 14:02 ` [PATCH 04/11] drm/udl: Allocate bulk URBs in helper functions Thomas Zimmermann
2026-11-19 16:38   ` Jie Feng
2026-11-20 12:49     ` Thomas Zimmermann
2026-11-20 16:15       ` Jie Feng
2026-11-19 14:02 ` [PATCH 05/11] drm/udl: Free " Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 06/11] drm/udl: Rework the error handling in udl_submit_urb() Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 07/11] drm/udl: Managed cleanup of URB cache Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 08/11] drm/udl: Track number of URBs in flight Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 09/11] drm/udl: Synchronize pending URBs on each frame Thomas Zimmermann
2026-11-20  6:50   ` Jie Feng
2026-11-20 12:52     ` Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 10/11] drm/udl: Allocate URBs on demand Thomas Zimmermann
2026-11-19 14:47   ` sashiko-bot
2026-11-19 18:05     ` Thomas Zimmermann
2026-11-20  6:54   ` Jie Feng
2026-11-20 13:01     ` Thomas Zimmermann
2026-11-19 14:02 ` [PATCH 11/11] drm/udl: Implement URB cache as LIFO stack Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119142114.152052-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.