Am 19.11.26 um 15:47 schrieb [email protected]:
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 <[email protected]>

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?

The was deliberate to reduce complexity. I assume that we shouldn't run that display driver if these allocations fail.   But if the removal turns out to be a problem, the logic can also remain.


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.


--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)


Reply via email to