All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 10/11] drm/udl: Allocate URBs on demand
Date: Thu, 19 Nov 2026 14:47:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-223315@kernel.org> (raw)
In-Reply-To: <20261119142114.152052-11-tzimmermann@suse.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/udl: missing size fallback and in-flight wait in
  udl_get_urb()
--

commit 2b67449c9bc54fc48767cd1733efcaed21d924b2
Author: Thomas Zimmermann <tzimmermann@suse.de>

drm/udl: Allocate URBs on demand

This commit removes the fixed upfront allocation of URBs and instead
allocates URBs on demand in udl_get_urb(), caching them for reuse across
frames.

> diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
> index d0195bd4213df..adddcf4b34518 100644
> --- a/drivers/gpu/drm/udl/udl_main.c
> +++ b/drivers/gpu/drm/udl/udl_main.c
[ ... ]
> @@ -244,71 +257,16 @@ static void udl_urb_list_release(void *data)
>  	udl_free_urb_list(udl);
>  }
>  
> -static int udl_alloc_urb_list(struct udl_device *udl, int count, size_t size)
> +static int udl_init_urb_list(struct udl_device *udl)
>  {
>  	struct drm_device *drm = &udl->drm;
> -	size_t wanted_size = count * size;
> -	int ret;
>  
>  	spin_lock_init(&udl->urbs.lock);
>  	INIT_LIST_HEAD(&udl->urbs.list);
>  	init_waitqueue_head(&udl->urbs.sleep);
> -	udl->urbs.count = 0;
>  	udl->urbs.in_flight = 0;
>  
> -retry:
> -	while (udl->urbs.count * size < wanted_size) {
> -		struct urb *urb;
> -		struct urb_node *unode;
> -
> -		urb = udl_alloc_bulk_urb(udl, size);
> -		if (IS_ERR(urb)) {
> -			if (PTR_ERR(urb) == -ENOBUFS && size > PAGE_SIZE) {
> -				size /= 2;
> -				udl_free_urb_list(udl);
> -				goto retry;
> -			}
> -			break;
> -		}
> -		unode = urb->context;
> -
> -		list_add_tail(&unode->entry, &udl->urbs.list);
> -
> -		udl->urbs.count++;
> -	}
[ ... ]
> @@ -321,9 +279,18 @@ struct urb *udl_get_urb(struct udl_device *udl)
>  			return NULL;
>  		++udl->urbs.in_flight;
>  
> -		urb = udl_get_urb_locked(udl, HZ * 2);
> -		if (!urb)
> -			--udl->urbs.in_flight;
> +		urb = __udl_get_cached_urb_locked(udl);
> +	}
> +
> +	if (!urb) {
> +		urb = udl_alloc_bulk_urb(udl, MAX_TRANSFER);
> +		if (IS_ERR(urb)) {
> +			scoped_guard(spinlock_irqsave, &udl->urbs.lock) {
> +				if (udl->urbs.in_flight)
> +					--udl->urbs.in_flight;
> +			}
> +			return NULL;
> +		}
>  	}
>  
>  	return urb;

[Severity: Medium]
Should udl_get_urb() fall back to smaller allocation sizes or wait for an
in-flight URB when udl_alloc_bulk_urb(udl, MAX_TRANSFER) fails?

MAX_TRANSFER is PAGE_SIZE * 16 - BULK_SIZE, which requires an order-4
contiguous coherent DMA allocation via usb_alloc_coherent().  Previously,
udl_alloc_urb_list() handled -ENOBUFS by halving the buffer size down to
PAGE_SIZE (added in 542bb9788a1f ("udl-kms: handle allocation failure")),
and udl_alloc_bulk_urb() still records unode->alloc_size and returns
-ENOBUFS for this purpose.

Because URBs are now allocated on demand during modesets and frame updates
when memory may be fragmented, a single order-4 allocation failure causes
udl_get_urb() to return NULL immediately (even when other URBs are already
in flight), aborting udl_crtc_helper_atomic_enable() or udl_handle_damage()
and leaving the display blank or partially updated.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119142114.152052-1-tzimmermann@suse.de?part=10

  reply	other threads:[~2026-11-19 14:47 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 ` [PATCH 03/11] drm/udl: Store per-URB allocation length in struct urb_node Thomas Zimmermann
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 [this message]
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=sashiko-outbox-223315@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzimmermann@suse.de \
    /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.