Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F5E6606A331 for ; Mon, 30 Nov 2026 15:05:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GQnA9xxr Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12F6A10E8FE; Mon, 30 Nov 2026 15:05:41 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DB4A10E8FE for ; Mon, 30 Nov 2026 15:05:35 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 11D13620A9; Mon, 30 Nov 2026 15:05:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A83211F000C1; Mon, 30 Nov 2026 15:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796051133; bh=cL4EX+sDwxldtZputQUVTCNI8NfSMuNFJI7EPlgG1PE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=GQnA9xxrqlEmueM299ItiCith9H+KPpFb7g15z0PcGKODi5aD0fhOaasBqNIdNFrT pBINW9LiDzkcKkNYJG/wvGIcaFxx78/5hmMySeMJ50ICpZvlEUr7B5X3acuUG0WcU4 czpO1kGWtOycBwHqz2d33tZ7tzJzAjTR5W9yTRRAGkOj9YIi7pNVAsMh5d9gnpoNE6 Yord/LBFzaEEIhlS+PTZbzz5DvSzZ93FFWh8hhZm4b1VTc//t6w6gAK8xNuwEveMom 2PhG4H252VZRAG9QDe6/G6eQpTMVvdIVKnG7Lz6iE1kH+nrxF+eSgPisS4CHlZs22C 5NQABX+LY9GXw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7] drm/tiny: trigger5: Add MCT Trigger 5 USB display driver To: "Ho Jie Feng" , dri-devel@lists.freedesktop.org In-Reply-To: <20261130144114.910972-1-hjf3108@gmail.com> References: <20261130144114.910972-1-hjf3108@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 15:05:33 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] drm/tiny: trigger5: broken USB reset lifecycle in trigger5_reset() - [Medium] drm/tiny: trigger5: bulk stream desync on mid-frame trigger5_submit_urb() error - [Medium] drm/tiny: trigger5: unclipped src_rect in trigger5_plane_atomic_update() - [Medium] drm/tiny: trigger5: unchecked state allocation in trigger5_usb_probe() - [Medium] drm/tiny: trigger5: merged damage clips in trigger5_plane_atomic_update() -- commit df9c157b7b3d2d1f7206fd2ab41385fa827a0335 Author: Ho Jie Feng drm/tiny: trigger5: Add MCT Trigger 5 USB display driver This commit adds a DRM driver for MCT Trigger 5 USB 3 to HDMI/VGA display adapters, implementing modesetting, EDID retrieval, connector status polling, and chunked USB bulk framebuffer updates. > diff --git a/drivers/gpu/drm/tiny/trigger5.c b/drivers/gpu/drm/tiny/trigg= er5.c > new file mode 100644 > index 0000000000000..bae616e6daac2 > --- /dev/null > +++ b/drivers/gpu/drm/tiny/trigger5.c [ ... ] > +static void trigger5_reset(struct trigger5_device *trigger5, int err) > +{ > + if (!atomic_xchg(&trigger5->needs_reset, 1)) > + usb_queue_reset_device(trigger5->intf); > + > + drm_err(&trigger5->drm, "USB transfer failed: %d, resetting adapter\n", > + err); > +} > + > +static void trigger5_urb_complete(struct urb *urb) > +{ > + struct trigger5_transfer *transfer =3D urb->context; > + struct trigger5_device *trigger5 =3D transfer->trigger5; > + > + switch (urb->status) { > + case -ENOENT: > + case -ECONNRESET: > + case -ESHUTDOWN: > + break; > + case 0: > + if (urb->actual_length =3D=3D urb->transfer_buffer_length) > + break; > + fallthrough; > + default: > + trigger5_reset(trigger5, urb->status); > + break; > + } > + > + complete(&transfer->done); > +} > + > +static struct trigger5_transfer * > +trigger5_get_next_urb(struct trigger5_device *trigger5) > +{ > + struct trigger5_transfer *transfer =3D > + &trigger5->transfers[trigger5->next_transfer]; > + > + if (atomic_read(&trigger5->needs_reset)) > + return ERR_PTR(-EIO); > + > + if (!wait_for_completion_timeout(&transfer->done, > + msecs_to_jiffies(TRIGGER5_BULK_TIMEOUT_MS))) { > + trigger5_reset(trigger5, -ETIMEDOUT); > + return ERR_PTR(-ETIMEDOUT); > + } > + > + trigger5->next_transfer =3D > + (trigger5->next_transfer + 1) % TRIGGER5_NUM_URBS; > + > + return transfer; > +} [Severity: High] Does trigger5_reset() cause usb_reset_device() to unbind the driver and unplug the active DRM device, or leave trigger5->needs_reset permanently set? Because trigger5_driver does not define pre_reset and post_reset callbacks (reset_resume is only used when resuming a suspended device), usb_reset_device() forces an unbind via trigger5_usb_disconnect() -> drm_dev_unplug() instead of resetting the adapter in place. Even if the device stays bound (for example, if usb_lock_device_for_reset() fails or after a reset/resume), nothing in the driver ever clears trigger5->needs_reset, so trigger5_get_next_urb() rejects all subsequent display updates with -EIO. In addition, trigger5_get_next_urb() only checks trigger5->needs_reset before wait_for_completion_timeout(), so if an in-flight URB fails while a caller is waiting, it still returns the transfer and allows the rest of the frame to be submitted. Finally, when trigger5_urb_complete() hits a short transfer with urb->status =3D=3D 0, falling through to default passes err = =3D 0 to trigger5_reset(). [ ... ] > +static void trigger5_plane_atomic_update(struct drm_plane *plane, > + struct drm_atomic_commit *atomic_state) > +{ > + struct drm_plane_state *old_state =3D > + drm_atomic_get_old_plane_state(atomic_state, plane); > + struct drm_plane_state *state =3D > + drm_atomic_get_new_plane_state(atomic_state, plane); > + struct drm_shadow_plane_state *shadow_plane_state =3D > + to_drm_shadow_plane_state(state); > + struct trigger5_device *trigger5 =3D to_trigger5(plane->dev); > + struct trigger5_transfer *transfer; > + struct trigger5_bulk_header *header; > + struct drm_rect current_rect, src_rect, clip; > + struct iosys_map data_map; > + size_t payload_len; > + int width, height, lines_per_urb; > + int idx, y; > + > + /* So far, no way to send a batch of rects atomically is found */ > + if (!drm_atomic_helper_damage_merged(old_state, state, ¤t_rect)) > + return; [Severity: Medium] As reported by Thomas Zimmermann on v6 [1], should trigger5_plane_atomic_update() iterate over individual damage rectangles with drm_atomic_helper_damage_iter_init() and drm_atomic_for_each_plane_damage() instead of calling drm_atomic_helper_damage_merged()? Merging disjoint damage clips into a single bounding box forces the driver to convert and transmit the entire unchanged region between them over USB. > + > + if (!drm_dev_enter(plane->dev, &idx)) > + return; > + > + src_rect =3D drm_plane_state_src(state); > + > + /* Match drm_atomic_helper_damage_iter_init() rounding. */ > + src_rect.x1 >>=3D 16; > + src_rect.y1 >>=3D 16; > + src_rect.x2 =3D (src_rect.x2 >> 16) + !!(src_rect.x2 & 0xffff); > + src_rect.y2 =3D (src_rect.y2 >> 16) + !!(src_rect.y2 & 0xffff); > + > + /* Clip merged damage to the new resolution. */ > + if (!drm_rect_intersect(¤t_rect, &src_rect)) > + goto exit; > + > + width =3D drm_rect_width(¤t_rect); > + height =3D drm_rect_height(¤t_rect); > + payload_len =3D array3_size(width, height, 3); > + lines_per_urb =3D TRIGGER5_URB_BUF_SIZE / (width * 3); > + > + if (drm_gem_fb_begin_cpu_access(state->fb, DMA_FROM_DEVICE) < 0) > + goto exit; > + > + transfer =3D trigger5_get_next_urb(trigger5); > + if (IS_ERR(transfer)) > + goto exit_end_cpu_access; > + > + header =3D transfer->urb->transfer_buffer; > + header->magic =3D 0xfb; > + header->length =3D 0x14; > + /* flags 0: uncompressed 24-bit RGB888. */ > + header->counter =3D > + cpu_to_le16((trigger5->frame_counter++) & 0xfff); > + header->horizontal_offset =3D cpu_to_le16(current_rect.x1 - src_rect.x1= ); > + header->vertical_offset =3D cpu_to_le16(current_rect.y1 - src_rect.y1); > + header->width =3D cpu_to_le16(width); > + header->height =3D cpu_to_le16(height); > + header->payload_length =3D cpu_to_le32((u32)payload_len); [Severity: Medium] Should src_rect be derived from the clipped state->src (via drm_rect_fp_to_int(&src_rect, &state->src)) rather than the unclipped drm_plane_state_src(state)? When a plane scans out from a framebuffer larger than the active CRTC mode, drm_atomic_helper_check_plane_state() clips state->src and state->dst to the CRTC dimensions while leaving state->src_{x,y,w,h} unclipped. Using drm_plane_state_src(state) here (along with outward rounding of fractional fixed-point coordinates) fails to clip current_rect to the active mode, producing off-screen horizontal/vertical offsets and sending frame payloads larger than the CRTC mode and TRIGGER5_MAX_FRAME_SIZE. > + header->flags =3D 0x1; > + header->unknown1 =3D 0; > + header->unknown2 =3D 0; > + header->checksum =3D trigger5_bulk_header_checksum(header); > + > + if (trigger5_submit_urb(transfer, sizeof(*header))) > + goto exit_end_cpu_access; > + > + clip =3D current_rect; > + for (y =3D current_rect.y1; y < current_rect.y2; y +=3D lines_per_urb) { > + clip.y1 =3D y; > + clip.y2 =3D min(y + lines_per_urb, current_rect.y2); > + > + transfer =3D trigger5_get_next_urb(trigger5); > + if (IS_ERR(transfer)) > + break; > + > + iosys_map_set_vaddr(&data_map, transfer->urb->transfer_buffer); > + drm_fb_xrgb8888_to_rgb888(&data_map, NULL, > + &shadow_plane_state->data[0], > + state->fb, &clip, > + &shadow_plane_state->fmtcnv_state); > + > + if (trigger5_submit_urb(transfer, > + width * 3 * drm_rect_height(&clip))) > + break; > + } [Severity: Medium] What happens to the bulk stream framing if trigger5_submit_urb() fails on a scanline chunk after the trigger5_bulk_header URB has already been submitted? Unlike trigger5_urb_complete() and trigger5_get_next_urb(), trigger5_submit_urb() does not call trigger5_reset() on error. Breaking out of this loop after submitting fewer than payload_len bytes leaves the device waiting for the remaining bytes of the aborted frame, so the next frame's trigger5_bulk_header and pixels will be misinterpreted as payload data. [ ... ] > + ret =3D trigger5_alloc_urbs(trigger5); > + if (ret) > + goto err_free_urbs; > + > + drm_mode_config_reset(dev); > + > + usb_set_intfdata(interface, trigger5); [Severity: Medium] Should trigger5_usb_probe() call drm_mode_config_create_initial_state(dev) and unwind to err_free_urbs on failure instead of calling drm_mode_config_reset(dev)? Because the plane, CRTC, and connector use .atomic_create_state callbacks, drm_mode_config_reset() silently discards -ENOMEM if state allocation fails and leaves the object's ->state pointer NULL, which can cause NULL pointer dereferences or permanent atomic commit failures after the DRM device is registered. [1] https://lore.kernel.org/r/55c2f09b-71b7-4aba-8f87-58f98aaf9e13@suse.de --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130144114.9109= 72-1-hjf3108@gmail.com?part=3D1