Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() race skips aux_unregister() on detach --
commit b7015f37668416cb2e6bc1550b44c2c5d2b795c6 Author: Luo Liu <[email protected]> drm/bridge: trilinear: add the DPTX core and build glue This commit adds the Trilinear DPTX bridge core implementation, including probe, power management, hotplug handling, and stream management, along with Kconfig and Makefile build integration. > diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_core.c > b/drivers/gpu/drm/bridge/trilinear/dptx_core.c > new file mode 100644 > index 0000000000000..ff80ba42a1140 > --- /dev/null > +++ b/drivers/gpu/drm/bridge/trilinear/dptx_core.c [ ... ] > +static void dptx_deinit(struct dptx_dev *dp) > +{ > + struct device_link *link = NULL; > + > + if (!(dp->state & DPTX_STATE_CONFIGURED)) > + return; > + > + scoped_guard(mutex, &dp->lock) { > + WRITE_ONCE(dp->hpd_stopped, true); > + dp->released = true; > + dptx_irq_off(dp); > + } > + > + dptx_cancel_hpd_works(dp); > + > + scoped_guard(mutex, &dp->lock) { > + dptx_stop_streams(dp); > + dptx_host_deinit(dp); > + dp->hw->ops->aux_unregister(dp->hw); > + dp->state &= ~(DPTX_STATE_CONFIGURED); > + link = dp->link; > + dp->link = NULL; > + } > + > + if (link) > + device_link_del(link); > +} [Severity: Medium] Can dptx_bridge_detach() return while dp->hw->aux is still registered if it races with dptx_deinit()? drivers/gpu/drm/bridge/trilinear/dptx_drm.c:dptx_bridge_detach() { ... scoped_guard(mutex, &dp->lock) { dp->attached = false; if (!dp->released) dp->hw->ops->aux_unregister(dp->hw); link = dp->link; dp->link = NULL; } ... } Because the device link uses DL_FLAG_STATELESS, the bridge device and the DRM consumer device can tear down concurrently: CPU0 CPU1 dptx_deinit() dptx_bridge_detach() lock(&dp->lock) dp->released = true unlock(&dp->lock) dptx_cancel_hpd_works(dp) dptx_quiesce_hpd(dp) lock(&dp->lock) if (!dp->released) /* false */ unlock(&dp->lock) /* DRM device teardown proceeds while dp->hw->aux is still registered with aux.drm_dev */ lock(&dp->lock) dp->hw->ops->aux_unregister(dp->hw) Also, dptx_deinit() checks dp->state & DPTX_STATE_CONFIGURED without holding dp->lock, while other paths update dp->state with non-atomic read-modify-write operations under dp->lock. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4
