All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cody Kang" <codykang.hk@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-phy@lists.infradead.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v3 12/17] drm/spacemit: add Innosilicon DP/eDP controller bridge driver
Date: Sat, 21 Nov 2026 08:08:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-226820@kernel.org> (raw)
In-Reply-To: <20261121-k3-display-v3-12-ec419e8e96b8@gmail.com>

Thank you for your contribution! Sashiko AI review found 13 potential
issues to consider:
- [High] drm/spacemit: missing pre-emphasis shift in
  spacemit_dp_link_apply_adjust()
- [High] drm/spacemit: reset in spacemit_dp_dev_init() desyncs cached
  PREPLL clk rate
- [Medium] drm/spacemit: broken HPD IRQ notify in
  spacemit_dp_hotplug_event_handler()
- [Medium] drm/spacemit: fallback caps in
  spacemit_dp_hw_read_sink_caps() block retry
- [Medium] drm/spacemit: missing hw disable in spacemit_dp_unregister()
  and bind()
- [Medium] drm/spacemit: missing spacemit_dp_hw_disable() on bind init
  failure
- [Medium] drm/spacemit: pixel clock truncation to MHz in TU and HBLANK
  calculation
- [Medium] drm/spacemit: unacknowledged level-high HPD IRQ in
  spacemit_dp_irq_handler()
- [Medium] drm/spacemit: unlocked dp->link and dp->dpcd reads in
  mode_valid and check
- [Medium] drm/spacemit: AUX registered before init and MPLL reset
  without hw_mutex
- [Medium] drm/spacemit: pixel PLL left powered down on untrained link
  in atomic_enable
- [Medium] drm/spacemit: nested AUX retries and fallback in
  spacemit_dp_aux_transfer()
- [Medium] drm/spacemit: spacemit_dp_remove() runs before devm AUX bus
  depopulation
--

commit a1a5915e82d2de32d9e2fe7095172a35686df3b2
Author: Cody Kang <codykang@vsit.ai>

drm/spacemit: add Innosilicon DP/eDP controller bridge driver

This commit adds the DRM bridge driver for the Innosilicon DisplayPort and
embedded DisplayPort controller downstream of the SpacemiT Saturn DPU.

> diff --git a/drivers/gpu/drm/spacemit/spacemit_inno_dp.c b/drivers/gpu/drm/spacemit/spacemit_inno_dp.c
> new file mode 100644
> index 0000000000000..436e5f15b4039
> --- /dev/null
> +++ b/drivers/gpu/drm/spacemit/spacemit_inno_dp.c
[ ... ]
> +	ret = regmap_read_poll_timeout(dp->regs, DP_GENERAL_INTERRUPT, val,
> +				       val & DP_AUX_REPLY_EVENT_INT_STA,
> +				       SPACEMIT_DP_AUX_POLL_US,
> +				       SPACEMIT_DP_AUX_TIMEOUT_US);
> +	if (ret) {
> +		if (retries < SPACEMIT_DP_AUX_MAX_RETRIES) {
> +			retries++;
> +			spacemit_dp_aux_hw_reset(dp);
> +			dev_dbg(dp->dev,
> +				"AUX timeout, cmd=0x%x addr=0x%x size=%zu retry %d/%d\n",
> +				cmd, msg->address, msg->size, retries, SPACEMIT_DP_AUX_MAX_RETRIES);
> +			goto retry_eio;
> +		}
> +
> +		dev_err_ratelimited(dp->dev,
> +				    "AUX transfer timeout, req: 0x%x, cmd: 0x%x, addr: 0x%x, size %zu\n",
> +				    msg->request, cmd, msg->address, msg->size);
> +		return ret;
> +	}

[Severity: Medium]
Does retrying timed-out transfers inside spacemit_dp_aux_transfer() compound
with the DRM DP helpers and spacemit_dp_hw_read_sink_caps() to stall for
over two minutes under dp->mode_lock?

Each timed-out spacemit_dp_aux_transfer() call waits 4 * 200 ms (~813 ms).
drm_dp_dpcd_access() retries negative errors 32 times,
drm_dp_dpcd_read_data() falls back to a second 32-retry probe via
drm_dp_dpcd_readb(), and spacemit_dp_hw_read_sink_caps() loops
SPACEMIT_DP_SINK_READY_RETRIES (3) times, multiplying a single unresponsive
sink into 768 consecutive 200 ms timeouts (~156 seconds) while holding
dp->mode_lock or component bind locks.

This is also reachable on eDP during spacemit_dp_bind(), which checks
spacemit_dp_hw_detect_hpd() and calls spacemit_dp_hw_read_sink_caps() even
though DP_HPD_IN_STATUS is not meaningful on eDP and the panel is powered
off until atomic_pre_enable; when that read fails, the non-zero fallback
limits set by spacemit_dp_hw_read_sink_caps() prevent
spacemit_dp_bridge_atomic_enable() from re-reading DPCD once the panel is
powered.

[ ... ]

> +static void spacemit_dp_hw_read_sink_caps(struct spacemit_dp_dev *dp)
> +{
[ ... ]
> +	if (ret < 0) {
> +		drm_warn_ratelimited(dp->drm,
> +				     "failed to read DPCD after %d retries: %zd\n",
> +				     SPACEMIT_DP_SINK_READY_RETRIES, ret);
> +		dp->link.revision = DP_DPCD_REV_14;
> +		dp->link.max_rate = SPACEMIT_DP_LINK_RATE_5_40;
> +		dp->link.max_num_lanes = SPACEMIT_DP_LANE_2;
> +		dp->link.enhanced_framing = 1;
> +		return;
> +	}

[Severity: Medium]
Does populating non-zero fallback values in dp->link.max_rate and
dp->link.max_num_lanes when spacemit_dp_hw_read_sink_caps() fails prevent
spacemit_dp_bridge_atomic_enable() from retrying the DPCD read?

spacemit_dp_bridge_atomic_enable() only retries spacemit_dp_hw_read_sink_caps()
when !dp->link.max_rate || !dp->link.max_num_lanes.  If an earlier DPCD read
at bind or detect time fails (for example, on eDP during spacemit_dp_bind()
when noisy DP_HPD_IN_STATUS reads high before the panel is powered, or on a
slow-waking monitor), max_rate and max_num_lanes are set to 5.4 Gbps and 2
lanes while dp->dpcd remains zeroed or stale.  The enable-time retry is then
skipped, clamping 4-lane panels or monitors to 2 lanes and running link
training without valid dp->dpcd capability bytes (such as TPS3 support).

[ ... ]

> +static int spacemit_dp_link_apply_adjust(struct spacemit_dp_dev *dp,
> +					 const u8 *link_status,
> +				    enum spacemit_dp_lane_count lanes,
> +				    u8 *training_set)
> +{
> +	union phy_configure_opts opts = {
> +		.dp = {
> +			.lanes = lanes,
> +			.set_voltages = true,
> +		},
> +	};
> +	int i, ret;
> +
> +	for (i = 0; i < lanes; i++) {
> +		u8 v = drm_dp_get_adjust_request_voltage(link_status, i);
> +		u8 p = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
> +		u8 v_bits;
> +
> +		if (v >= SPACEMIT_DP_SWING_MAX)
> +			v = SPACEMIT_DP_SWING_MAX;
> +		if (p >= SPACEMIT_DP_PREEMP_MAX)
> +			p = SPACEMIT_DP_PREEMP_MAX;
> +
> +		opts.dp.voltage[i] = v;
> +		opts.dp.pre[i] = p;
> +
> +		v_bits = v;
> +		if (v == SPACEMIT_DP_SWING_MAX)
> +			v_bits |= DP_TRAIN_MAX_SWING_REACHED;
> +		if (p == SPACEMIT_DP_PREEMP_MAX)
> +			v_bits |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> +
> +		training_set[i] = v_bits | (p << DP_TRAIN_PRE_EMPHASIS_SHIFT);
> +	}

[Severity: High]
Isn't the return value of drm_dp_get_adjust_request_pre_emphasis() already
shifted left by DP_TRAIN_PRE_EMPHASIS_SHIFT (3)?

For pre-emphasis levels 1, 2 and 3, drm_dp_get_adjust_request_pre_emphasis()
returns 8, 16 and 24.  Comparing p >= SPACEMIT_DP_PREEMP_MAX (2) without
shifting right by DP_TRAIN_PRE_EMPHASIS_SHIFT first causes any request for
pre-emphasis level 1 to be clamped to level 2, marked with
DP_TRAIN_MAX_PRE_EMPHASIS_REACHED, and shifted a second time when building
training_set[i].

[ ... ]

> +static void spacemit_dp_hw_set_msa_and_enable_video(struct spacemit_dp_dev *dp,
> +						    const struct drm_display_mode *mode,
> +						    enum spacemit_dp_link_rate rate,
> +						    enum spacemit_dp_lane_count lanes)
> +{
> +	u64 hb_num;
> +	u32 link_rate;
> +	u32 fp; /* Pixel clock in MHz */
> +	u32 tu, tu_frac, tu_int, rd_thres;
> +	u32 hsync_len, hstart, vstart;
> +
> +	/* mode->clock unit is kHz, fp unit is MHz */
> +	fp = mode->clock / 1000;
> +
> +	if (fp == 0)
> +		fp = 1; /* Prevent division by zero */
> +
> +	/*
> +	 * HBlank interval = (htotal - hactive) * (LinkSymbolClock / 4) /
> +	 * PixelClock, where LinkSymbolClock = LinkRate * 100 (1.62G -> 162MHz).
> +	 * rate is in kbit/s, so link_rate = rate / 10000 gives the 162, 270,
> +	 * 540 form used below.
> +	 */
> +	link_rate = rate / 10000;
> +
> +	/* Multiply before dividing: hb_num = hblank * (link_rate / 4) / fp */
> +	hb_num = (u64)(mode->htotal - mode->hdisplay) * link_rate;
> +	do_div(hb_num, 4 * fp);
> +
> +	/* Transfer unit: tu = fp * bpp * 640 / (8 * lanes * link_rate) */
> +	tu = div_u64((u64)fp * SPACEMIT_DP_BPP * 640, 8 * lanes * link_rate);

[Severity: Medium]
Does truncating mode->clock to integer MHz in fp underestimate the transfer
unit size for fractional-MHz pixel clocks?

spacemit_dp_set_plls() programs dp->pll_clk to mode->clock * 1000 Hz, so a
1080p60 mode runs at 148.5 MHz (and 720p60 at 74.25 MHz), whereas
fp = mode->clock / 1000 truncates those clocks to 148 MHz and 74 MHz.  For
1080p60 on 2 lanes at 2.7 Gbps, this programs a TU of 52.6 instead of 52.8,
packing fewer bytes per TU than the pixel clock delivers into the video
FIFO.  Using mode->clock in kHz and rate / 10 directly avoids the
truncation.

[ ... ]

> +static enum drm_mode_status
> +spacemit_dp_bridge_mode_valid(struct drm_bridge *bridge,
> +			      const struct drm_display_info *info,
> +			 const struct drm_display_mode *mode)
> +{
> +	struct spacemit_dp_dev *dp = container_of(bridge,
> +						  struct spacemit_dp_dev,
> +						  bridge);
> +	unsigned int max_link_rate, max_lanes;
> +	u64 max_bw, req_bw;
> +
> +	/*
> +	 * Prefer the link limits the driver maintains: they start as the
> +	 * sink's capabilities clamped to the PHY and are narrowed after a
> +	 * failed training. drm_dp_max_link_rate() is in 10 kbit/s.
> +	 */
> +	if (dp->link.max_rate && dp->link.max_num_lanes) {
> +		max_link_rate = dp->link.max_rate / 10;
> +		max_lanes = dp->link.max_num_lanes;
> +	} else {
> +		max_link_rate = min_t(unsigned int,
> +				      drm_dp_max_link_rate(dp->dpcd),
> +				      SPACEMIT_DP_SOURCE_MAX_RATE / 10);
> +		max_lanes = drm_dp_max_lane_count(dp->dpcd);
> +	}

[Severity: Medium]
Can spacemit_dp_bridge_mode_valid() and spacemit_dp_bridge_atomic_check()
race with concurrent updates to dp->link and dp->dpcd?

spacemit_dp_hw_read_sink_caps() and spacemit_dp_link_narrow() update
dp->dpcd, dp->link.max_rate and dp->link.max_num_lanes under dp->mode_lock
from the hotplug IRQ thread (spacemit_dp_hotplug_event_handler()) and from
non-blocking atomic commits (spacemit_dp_bridge_atomic_enable()), neither of
which holds the DRM modeset locks.  Reading those fields in
spacemit_dp_bridge_mode_valid() and spacemit_dp_bridge_atomic_check()
without dp->mode_lock can observe a torn rate/lane pair or partially read
dp->dpcd bytes.

[ ... ]

> +	for (trained = false, i = start;
> +	     i < ARRAY_SIZE(spacemit_dp_link_priority_table); i++) {
> +		u32 capacity;
> +
> +		cfg = &spacemit_dp_link_priority_table[i];
> +
> +		/* Source and sink limits */
> +		if (cfg->rate > dp->link.max_rate || cfg->lanes > dp->link.max_num_lanes)
> +			continue;
> +
> +		/* Bandwidth requirement */
> +		capacity = spacemit_dp_calc_link_capacity(cfg->rate,
> +							  cfg->lanes);
> +		if (capacity < req_bw)
> +			continue;
> +
> +		drm_dbg(dp->drm, "trying link config: rate %d lanes %d (capacity %d, required %d)\n",
> +			cfg->rate, cfg->lanes, capacity, req_bw);
> +
> +		spacemit_dp_link_disable(dp);
> +
> +		/* Apply Hardware Settings */
> +		if (spacemit_dp_set_plls(dp, cfg->rate, adjusted_mode->clock))
> +			continue;
> +
> +		if (spacemit_dp_phy_set_lanes(dp, cfg->lanes))
> +			continue;
> +
> +		if (spacemit_dp_phy_on(dp))
> +			continue;
[ ... ]
> +	/*
> +	 * The DPU's pixel clock comes from the PHY PLL, so scanning out into an
> +	 * untrained link never reaches CFG_RDY and wedges the CRTC on
> +	 * flip_done.
> +	 */
> +	if (!trained) {

[Severity: Medium]
Can the !trained path in spacemit_dp_bridge_atomic_enable() return with the
PHY pixel PLL powered down and stall the DPU commit?

When dp->link.max_rate or dp->link.max_num_lanes was 0 during atomic_check()
and the enable-time DPCD read yields limits below req_bw, every entry in
spacemit_dp_link_priority_table is skipped before spacemit_dp_set_plls() or
spacemit_dp_phy_on() is called, leaving the PHY powered off from
spacemit_dp_bind() or spacemit_dp_bridge_atomic_disable().  The same happens
if spacemit_dp_set_plls(), spacemit_dp_phy_set_lanes() or
spacemit_dp_phy_on() fails after spacemit_dp_link_disable().  Because the
DPU gets its pixel clock from dp->pll_clk, returning with PREPLL powered
down prevents the DPU from latching CFG_RDY and stalls
drm_atomic_helper_wait_for_flip_done() until the 3000 ms
SATURN_CFG_RDY_TIMEOUT_MS timeout expires.

[ ... ]

> +static irqreturn_t spacemit_dp_irq_handler(int irq, void *data)
> +{
> +	struct spacemit_dp_dev *dp = data;
> +	irqreturn_t ret = IRQ_NONE;
> +	int idx;
> +
> +	if (!drm_dev_enter(dp->drm, &idx))
> +		return IRQ_NONE;

[Severity: Medium]
What happens if a level-high HPD interrupt fires after drm_dev_unplug()
during master unbind?

In spacemit_drm_master_unbind(), drm_dev_unplug() runs before
drm_kms_helper_poll_fini(), drm_atomic_helper_shutdown() and
component_unbind_all().  Once drm_dev_unplug() marks the device unplugged,
drm_dev_enter() in spacemit_dp_irq_handler() returns false and the handler
exits with IRQ_NONE without calling spacemit_dp_hw_clean_hpd() to clear the
level-triggered interrupt latch, causing a hardirq storm until
spacemit_dp_unbind() calls disable_irq().

[ ... ]

> +static irqreturn_t spacemit_dp_hotplug_event_handler(int irq, void *data)
> +{
> +	struct spacemit_dp_dev *dp = data;
> +	enum drm_connector_status status;
> +	int idx;
> +
> +	if (!drm_dev_enter(dp->drm, &idx))
> +		return IRQ_HANDLED;
> +
> +	/*
> +	 * .detect() owns mode_lock and re-reads the sink caps on a fresh plug
> +	 */
> +	status = spacemit_dp_bridge_detect(&dp->bridge, dp->connector);
> +	drm_bridge_hpd_notify(&dp->bridge, status);
> +
> +	drm_dev_exit(idx);
> +	return IRQ_HANDLED;
> +}

[Severity: Medium]
Does drm_bridge_hpd_notify() ever notify DRM on external DisplayPort
hotplug interrupts?

In spacemit_dp_probe(), external DP sets dp->bridge.ops to
DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID without DRM_BRIDGE_OP_HPD.
Because drm_bridge_connector_init() only registers an HPD callback on a
bridge with DRM_BRIDGE_OP_HPD set, dp->bridge.hpd_cb is NULL and
drm_bridge_hpd_notify() is a no-op.  Moreover, calling
spacemit_dp_bridge_detect() here updates dp->connector_status without
updating dp->connector->status, so an unplug-and-replug while the pixel
clock is running between 10-second poll intervals leaves both statuses as
connector_status_connected and drops the hotplug event and EDID re-read.

[ ... ]

> +static int spacemit_dp_dev_init(struct spacemit_dp_dev *dp)
> +{
[ ... ]
> +	/* Reset Controller and PHY */
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_CONTROLLER_RESET,
> +			  FIELD_PREP(DP_CONTROLLER_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_PHY_RESET,
> +			  FIELD_PREP(DP_PHY_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_HDCP_RESET,
> +			  FIELD_PREP(DP_HDCP_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_AUX_RESET,
> +			  FIELD_PREP(DP_AUX_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_VIDEO_RESET,
> +			  FIELD_PREP(DP_VIDEO_RESET, 0x1));
> +	usleep_range(5000, 8000);
[ ... ]
> +	ret = spacemit_dp_set_plls(dp, SPACEMIT_DP_LINK_RATE_2_70, 148500);
> +	if (ret)
> +		return ret;
> +
> +	ret = spacemit_dp_phy_set_lanes(dp, SPACEMIT_DP_LANE_2);
> +	if (ret)
> +		return ret;
> +
> +	ret = spacemit_dp_phy_on(dp);
> +	if (ret)
> +		return ret;

[Severity: High]
When spacemit_dp_dev_init() runs a second time in spacemit_dp_bind() on eDP
(or on component rebind), does pulsing DP_PHY_RESET wipe the PREPLL
registers while clk_set_rate(dp->pll_clk, 148500000) short-circuits in the
clock framework?

On eDP, spacemit_dp_probe() calls spacemit_dp_dev_init(), which programs
dp->pll_clk to 148.5 MHz, and the PHY clock provider caches that rate.  When
spacemit_dp_bind() calls spacemit_dp_dev_init() again, asserting
DP_PHY_RESET resets the shared PHY PREPLL registers back to hardware
defaults, but clk_set_rate(dp->pll_clk, 148500000) sees that the requested
rate matches the cached rate and returns without calling the PHY clock's
.set_rate callback.  spacemit_dp_phy_on() (and later atomic_enable() for any
148.5 MHz mode) then tries to lock an unprogrammed PREPLL.

[ ... ]

> +static int spacemit_dp_bind(struct device *dev, struct device *master,
> +			    void *data)
> +{
> +	struct spacemit_dp_dev *dp = dev_get_drvdata(dev);
> +	struct drm_device *drm = data;
> +	struct device_node *ep;
> +	int ret;
> +
> +	dp->drm = drm;
> +	dp->aux.drm_dev = drm;
> +	ret = drm_dp_aux_register(&dp->aux);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to register DP AUX\n");
> +		goto err_drm;
> +	}
[ ... ]
> +	ret = spacemit_dp_dev_init(dp);
> +	if (ret)
> +		goto err_encoder;

[Severity: Medium]
Can userspace AUX or DDC transactions race with spacemit_dp_dev_init() and
spacemit_dp_set_plls()?

spacemit_dp_bind() calls drm_dp_aux_register(&dp->aux) before
spacemit_dp_dev_init(dp), exposing /dev/drm_dp_aux* and the I2C adapter
before the controller is initialized on external DP and while
spacemit_dp_dev_init() powers down MPLL and asserts DP_CONTROLLER_RESET,
DP_PHY_RESET and DP_AUX_RESET without holding dp->aux.hw_mutex.  Similarly,
in spacemit_dp_bridge_atomic_enable(), spacemit_dp_link_disable() releases
dp->aux.hw_mutex before spacemit_dp_set_plls() power-cycles the MPLL that
supplies the 16 MHz AUX reference clock.

[Severity: Medium]
If spacemit_dp_dev_init() fails here in spacemit_dp_bind(), should the error
path call spacemit_dp_hw_disable(dp) the way spacemit_dp_probe() does?

spacemit_dp_dev_init() enables interrupt masks and powers up the MPLL and
PREPLL in spacemit_dp_set_plls() before calling spacemit_dp_phy_set_lanes()
and spacemit_dp_phy_on().  Jumping to err_encoder on failure leaves the
PLLs powered on, and because dp->component_added is true while bind failed,
a later spacemit_dp_remove() will not run spacemit_dp_unbind() or
spacemit_dp_hw_disable() either.

[ ... ]

> +/* Leave the DRM device, or power down a controller that never joined one. */
> +static void spacemit_dp_unregister(struct spacemit_dp_dev *dp)
> +{
> +	if (dp->component_added)
> +		component_del(dp->dev, &spacemit_dp_ops);
> +	else
> +		spacemit_dp_hw_disable(dp);
> +}

[Severity: Medium]
Does spacemit_dp_unregister() leave the hardware powered on when
dp->component_added is true but the component master was never bound?

On eDP, spacemit_dp_probe() powers up the MPLL and analog TX blocks via
spacemit_dp_dev_init() and spacemit_dp_edp_link_panel() sets
dp->component_added = true.  If the driver is removed while the aggregate
DRM device is unbound (or if spacemit_dp_dev_init() failed during
spacemit_dp_bind()), component_del() does not invoke spacemit_dp_unbind(),
and the if (dp->component_added) branch skips spacemit_dp_hw_disable(dp).
Calling spacemit_dp_hw_disable(dp) unconditionally after component_del()
would ensure the PLLs and TX blocks are always powered down.

[ ... ]

> +	ret = devm_of_dp_aux_populate_bus(&dp->aux, spacemit_dp_edp_link_panel);
> +	if (ret) {
> +		spacemit_dp_unregister(dp);
> +		return dev_err_probe(dev, ret,
> +				     "eDP: failed to populate aux-bus panel\n");
> +	}
> +
> +	return 0;
> +
> +err_disable_pxclk:
> +	clk_disable_unprepare(dp->pxclk);
> +	return ret;
> +}
> +
> +static void spacemit_dp_remove(struct platform_device *pdev)
> +{
> +	spacemit_dp_unregister(platform_get_drvdata(pdev));
> +}

[Severity: Medium]
On eDP, does spacemit_dp_remove() tear down the component and power down the
controller before devres depopulates the AUX bus?

devm_of_dp_aux_populate_bus() registers of_dp_aux_depopulate_bus_void() as a
devres action, which runs during devres_release_all() after
spacemit_dp_remove() returns.  During driver unbind, spacemit_dp_remove()
powers down the controller while the AUX-bus child panel device is still
registered, and a deferred panel probe completing in that window can still
invoke spacemit_dp_edp_link_panel() -> component_add() after
spacemit_dp_unregister() has already run:

CPU0                                  CPU1 (deferred_probe_work_func)
__device_release_driver()
  spacemit_dp_remove()
    spacemit_dp_unregister()
      /* dp->component_added is false */
      spacemit_dp_hw_disable()
                                      panel_edp_probe()
                                        spacemit_dp_edp_link_panel()
                                          component_add(dp->dev, ...)
  devres_release_all()
    of_dp_aux_depopulate_bus_void()
    /* dp freed while component remains registered */

Depopulating the AUX bus in spacemit_dp_remove() before
spacemit_dp_unregister() (or registering spacemit_dp_unregister() as a devm
action prior to devm_of_dp_aux_populate_bus()) avoids this ordering
inversion.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-k3-display-v3-0-ec419e8e96b8@gmail.com?part=12

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Cody Kang" <codykang.hk@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-phy@lists.infradead.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v3 12/17] drm/spacemit: add Innosilicon DP/eDP controller bridge driver
Date: Sat, 21 Nov 2026 08:08:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-226820@kernel.org> (raw)
In-Reply-To: <20261121-k3-display-v3-12-ec419e8e96b8@gmail.com>

Thank you for your contribution! Sashiko AI review found 13 potential
issues to consider:
- [High] drm/spacemit: missing pre-emphasis shift in
  spacemit_dp_link_apply_adjust()
- [High] drm/spacemit: reset in spacemit_dp_dev_init() desyncs cached
  PREPLL clk rate
- [Medium] drm/spacemit: broken HPD IRQ notify in
  spacemit_dp_hotplug_event_handler()
- [Medium] drm/spacemit: fallback caps in
  spacemit_dp_hw_read_sink_caps() block retry
- [Medium] drm/spacemit: missing hw disable in spacemit_dp_unregister()
  and bind()
- [Medium] drm/spacemit: missing spacemit_dp_hw_disable() on bind init
  failure
- [Medium] drm/spacemit: pixel clock truncation to MHz in TU and HBLANK
  calculation
- [Medium] drm/spacemit: unacknowledged level-high HPD IRQ in
  spacemit_dp_irq_handler()
- [Medium] drm/spacemit: unlocked dp->link and dp->dpcd reads in
  mode_valid and check
- [Medium] drm/spacemit: AUX registered before init and MPLL reset
  without hw_mutex
- [Medium] drm/spacemit: pixel PLL left powered down on untrained link
  in atomic_enable
- [Medium] drm/spacemit: nested AUX retries and fallback in
  spacemit_dp_aux_transfer()
- [Medium] drm/spacemit: spacemit_dp_remove() runs before devm AUX bus
  depopulation
--

commit a1a5915e82d2de32d9e2fe7095172a35686df3b2
Author: Cody Kang <codykang@vsit.ai>

drm/spacemit: add Innosilicon DP/eDP controller bridge driver

This commit adds the DRM bridge driver for the Innosilicon DisplayPort and
embedded DisplayPort controller downstream of the SpacemiT Saturn DPU.

> diff --git a/drivers/gpu/drm/spacemit/spacemit_inno_dp.c b/drivers/gpu/drm/spacemit/spacemit_inno_dp.c
> new file mode 100644
> index 0000000000000..436e5f15b4039
> --- /dev/null
> +++ b/drivers/gpu/drm/spacemit/spacemit_inno_dp.c
[ ... ]
> +	ret = regmap_read_poll_timeout(dp->regs, DP_GENERAL_INTERRUPT, val,
> +				       val & DP_AUX_REPLY_EVENT_INT_STA,
> +				       SPACEMIT_DP_AUX_POLL_US,
> +				       SPACEMIT_DP_AUX_TIMEOUT_US);
> +	if (ret) {
> +		if (retries < SPACEMIT_DP_AUX_MAX_RETRIES) {
> +			retries++;
> +			spacemit_dp_aux_hw_reset(dp);
> +			dev_dbg(dp->dev,
> +				"AUX timeout, cmd=0x%x addr=0x%x size=%zu retry %d/%d\n",
> +				cmd, msg->address, msg->size, retries, SPACEMIT_DP_AUX_MAX_RETRIES);
> +			goto retry_eio;
> +		}
> +
> +		dev_err_ratelimited(dp->dev,
> +				    "AUX transfer timeout, req: 0x%x, cmd: 0x%x, addr: 0x%x, size %zu\n",
> +				    msg->request, cmd, msg->address, msg->size);
> +		return ret;
> +	}

[Severity: Medium]
Does retrying timed-out transfers inside spacemit_dp_aux_transfer() compound
with the DRM DP helpers and spacemit_dp_hw_read_sink_caps() to stall for
over two minutes under dp->mode_lock?

Each timed-out spacemit_dp_aux_transfer() call waits 4 * 200 ms (~813 ms).
drm_dp_dpcd_access() retries negative errors 32 times,
drm_dp_dpcd_read_data() falls back to a second 32-retry probe via
drm_dp_dpcd_readb(), and spacemit_dp_hw_read_sink_caps() loops
SPACEMIT_DP_SINK_READY_RETRIES (3) times, multiplying a single unresponsive
sink into 768 consecutive 200 ms timeouts (~156 seconds) while holding
dp->mode_lock or component bind locks.

This is also reachable on eDP during spacemit_dp_bind(), which checks
spacemit_dp_hw_detect_hpd() and calls spacemit_dp_hw_read_sink_caps() even
though DP_HPD_IN_STATUS is not meaningful on eDP and the panel is powered
off until atomic_pre_enable; when that read fails, the non-zero fallback
limits set by spacemit_dp_hw_read_sink_caps() prevent
spacemit_dp_bridge_atomic_enable() from re-reading DPCD once the panel is
powered.

[ ... ]

> +static void spacemit_dp_hw_read_sink_caps(struct spacemit_dp_dev *dp)
> +{
[ ... ]
> +	if (ret < 0) {
> +		drm_warn_ratelimited(dp->drm,
> +				     "failed to read DPCD after %d retries: %zd\n",
> +				     SPACEMIT_DP_SINK_READY_RETRIES, ret);
> +		dp->link.revision = DP_DPCD_REV_14;
> +		dp->link.max_rate = SPACEMIT_DP_LINK_RATE_5_40;
> +		dp->link.max_num_lanes = SPACEMIT_DP_LANE_2;
> +		dp->link.enhanced_framing = 1;
> +		return;
> +	}

[Severity: Medium]
Does populating non-zero fallback values in dp->link.max_rate and
dp->link.max_num_lanes when spacemit_dp_hw_read_sink_caps() fails prevent
spacemit_dp_bridge_atomic_enable() from retrying the DPCD read?

spacemit_dp_bridge_atomic_enable() only retries spacemit_dp_hw_read_sink_caps()
when !dp->link.max_rate || !dp->link.max_num_lanes.  If an earlier DPCD read
at bind or detect time fails (for example, on eDP during spacemit_dp_bind()
when noisy DP_HPD_IN_STATUS reads high before the panel is powered, or on a
slow-waking monitor), max_rate and max_num_lanes are set to 5.4 Gbps and 2
lanes while dp->dpcd remains zeroed or stale.  The enable-time retry is then
skipped, clamping 4-lane panels or monitors to 2 lanes and running link
training without valid dp->dpcd capability bytes (such as TPS3 support).

[ ... ]

> +static int spacemit_dp_link_apply_adjust(struct spacemit_dp_dev *dp,
> +					 const u8 *link_status,
> +				    enum spacemit_dp_lane_count lanes,
> +				    u8 *training_set)
> +{
> +	union phy_configure_opts opts = {
> +		.dp = {
> +			.lanes = lanes,
> +			.set_voltages = true,
> +		},
> +	};
> +	int i, ret;
> +
> +	for (i = 0; i < lanes; i++) {
> +		u8 v = drm_dp_get_adjust_request_voltage(link_status, i);
> +		u8 p = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
> +		u8 v_bits;
> +
> +		if (v >= SPACEMIT_DP_SWING_MAX)
> +			v = SPACEMIT_DP_SWING_MAX;
> +		if (p >= SPACEMIT_DP_PREEMP_MAX)
> +			p = SPACEMIT_DP_PREEMP_MAX;
> +
> +		opts.dp.voltage[i] = v;
> +		opts.dp.pre[i] = p;
> +
> +		v_bits = v;
> +		if (v == SPACEMIT_DP_SWING_MAX)
> +			v_bits |= DP_TRAIN_MAX_SWING_REACHED;
> +		if (p == SPACEMIT_DP_PREEMP_MAX)
> +			v_bits |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> +
> +		training_set[i] = v_bits | (p << DP_TRAIN_PRE_EMPHASIS_SHIFT);
> +	}

[Severity: High]
Isn't the return value of drm_dp_get_adjust_request_pre_emphasis() already
shifted left by DP_TRAIN_PRE_EMPHASIS_SHIFT (3)?

For pre-emphasis levels 1, 2 and 3, drm_dp_get_adjust_request_pre_emphasis()
returns 8, 16 and 24.  Comparing p >= SPACEMIT_DP_PREEMP_MAX (2) without
shifting right by DP_TRAIN_PRE_EMPHASIS_SHIFT first causes any request for
pre-emphasis level 1 to be clamped to level 2, marked with
DP_TRAIN_MAX_PRE_EMPHASIS_REACHED, and shifted a second time when building
training_set[i].

[ ... ]

> +static void spacemit_dp_hw_set_msa_and_enable_video(struct spacemit_dp_dev *dp,
> +						    const struct drm_display_mode *mode,
> +						    enum spacemit_dp_link_rate rate,
> +						    enum spacemit_dp_lane_count lanes)
> +{
> +	u64 hb_num;
> +	u32 link_rate;
> +	u32 fp; /* Pixel clock in MHz */
> +	u32 tu, tu_frac, tu_int, rd_thres;
> +	u32 hsync_len, hstart, vstart;
> +
> +	/* mode->clock unit is kHz, fp unit is MHz */
> +	fp = mode->clock / 1000;
> +
> +	if (fp == 0)
> +		fp = 1; /* Prevent division by zero */
> +
> +	/*
> +	 * HBlank interval = (htotal - hactive) * (LinkSymbolClock / 4) /
> +	 * PixelClock, where LinkSymbolClock = LinkRate * 100 (1.62G -> 162MHz).
> +	 * rate is in kbit/s, so link_rate = rate / 10000 gives the 162, 270,
> +	 * 540 form used below.
> +	 */
> +	link_rate = rate / 10000;
> +
> +	/* Multiply before dividing: hb_num = hblank * (link_rate / 4) / fp */
> +	hb_num = (u64)(mode->htotal - mode->hdisplay) * link_rate;
> +	do_div(hb_num, 4 * fp);
> +
> +	/* Transfer unit: tu = fp * bpp * 640 / (8 * lanes * link_rate) */
> +	tu = div_u64((u64)fp * SPACEMIT_DP_BPP * 640, 8 * lanes * link_rate);

[Severity: Medium]
Does truncating mode->clock to integer MHz in fp underestimate the transfer
unit size for fractional-MHz pixel clocks?

spacemit_dp_set_plls() programs dp->pll_clk to mode->clock * 1000 Hz, so a
1080p60 mode runs at 148.5 MHz (and 720p60 at 74.25 MHz), whereas
fp = mode->clock / 1000 truncates those clocks to 148 MHz and 74 MHz.  For
1080p60 on 2 lanes at 2.7 Gbps, this programs a TU of 52.6 instead of 52.8,
packing fewer bytes per TU than the pixel clock delivers into the video
FIFO.  Using mode->clock in kHz and rate / 10 directly avoids the
truncation.

[ ... ]

> +static enum drm_mode_status
> +spacemit_dp_bridge_mode_valid(struct drm_bridge *bridge,
> +			      const struct drm_display_info *info,
> +			 const struct drm_display_mode *mode)
> +{
> +	struct spacemit_dp_dev *dp = container_of(bridge,
> +						  struct spacemit_dp_dev,
> +						  bridge);
> +	unsigned int max_link_rate, max_lanes;
> +	u64 max_bw, req_bw;
> +
> +	/*
> +	 * Prefer the link limits the driver maintains: they start as the
> +	 * sink's capabilities clamped to the PHY and are narrowed after a
> +	 * failed training. drm_dp_max_link_rate() is in 10 kbit/s.
> +	 */
> +	if (dp->link.max_rate && dp->link.max_num_lanes) {
> +		max_link_rate = dp->link.max_rate / 10;
> +		max_lanes = dp->link.max_num_lanes;
> +	} else {
> +		max_link_rate = min_t(unsigned int,
> +				      drm_dp_max_link_rate(dp->dpcd),
> +				      SPACEMIT_DP_SOURCE_MAX_RATE / 10);
> +		max_lanes = drm_dp_max_lane_count(dp->dpcd);
> +	}

[Severity: Medium]
Can spacemit_dp_bridge_mode_valid() and spacemit_dp_bridge_atomic_check()
race with concurrent updates to dp->link and dp->dpcd?

spacemit_dp_hw_read_sink_caps() and spacemit_dp_link_narrow() update
dp->dpcd, dp->link.max_rate and dp->link.max_num_lanes under dp->mode_lock
from the hotplug IRQ thread (spacemit_dp_hotplug_event_handler()) and from
non-blocking atomic commits (spacemit_dp_bridge_atomic_enable()), neither of
which holds the DRM modeset locks.  Reading those fields in
spacemit_dp_bridge_mode_valid() and spacemit_dp_bridge_atomic_check()
without dp->mode_lock can observe a torn rate/lane pair or partially read
dp->dpcd bytes.

[ ... ]

> +	for (trained = false, i = start;
> +	     i < ARRAY_SIZE(spacemit_dp_link_priority_table); i++) {
> +		u32 capacity;
> +
> +		cfg = &spacemit_dp_link_priority_table[i];
> +
> +		/* Source and sink limits */
> +		if (cfg->rate > dp->link.max_rate || cfg->lanes > dp->link.max_num_lanes)
> +			continue;
> +
> +		/* Bandwidth requirement */
> +		capacity = spacemit_dp_calc_link_capacity(cfg->rate,
> +							  cfg->lanes);
> +		if (capacity < req_bw)
> +			continue;
> +
> +		drm_dbg(dp->drm, "trying link config: rate %d lanes %d (capacity %d, required %d)\n",
> +			cfg->rate, cfg->lanes, capacity, req_bw);
> +
> +		spacemit_dp_link_disable(dp);
> +
> +		/* Apply Hardware Settings */
> +		if (spacemit_dp_set_plls(dp, cfg->rate, adjusted_mode->clock))
> +			continue;
> +
> +		if (spacemit_dp_phy_set_lanes(dp, cfg->lanes))
> +			continue;
> +
> +		if (spacemit_dp_phy_on(dp))
> +			continue;
[ ... ]
> +	/*
> +	 * The DPU's pixel clock comes from the PHY PLL, so scanning out into an
> +	 * untrained link never reaches CFG_RDY and wedges the CRTC on
> +	 * flip_done.
> +	 */
> +	if (!trained) {

[Severity: Medium]
Can the !trained path in spacemit_dp_bridge_atomic_enable() return with the
PHY pixel PLL powered down and stall the DPU commit?

When dp->link.max_rate or dp->link.max_num_lanes was 0 during atomic_check()
and the enable-time DPCD read yields limits below req_bw, every entry in
spacemit_dp_link_priority_table is skipped before spacemit_dp_set_plls() or
spacemit_dp_phy_on() is called, leaving the PHY powered off from
spacemit_dp_bind() or spacemit_dp_bridge_atomic_disable().  The same happens
if spacemit_dp_set_plls(), spacemit_dp_phy_set_lanes() or
spacemit_dp_phy_on() fails after spacemit_dp_link_disable().  Because the
DPU gets its pixel clock from dp->pll_clk, returning with PREPLL powered
down prevents the DPU from latching CFG_RDY and stalls
drm_atomic_helper_wait_for_flip_done() until the 3000 ms
SATURN_CFG_RDY_TIMEOUT_MS timeout expires.

[ ... ]

> +static irqreturn_t spacemit_dp_irq_handler(int irq, void *data)
> +{
> +	struct spacemit_dp_dev *dp = data;
> +	irqreturn_t ret = IRQ_NONE;
> +	int idx;
> +
> +	if (!drm_dev_enter(dp->drm, &idx))
> +		return IRQ_NONE;

[Severity: Medium]
What happens if a level-high HPD interrupt fires after drm_dev_unplug()
during master unbind?

In spacemit_drm_master_unbind(), drm_dev_unplug() runs before
drm_kms_helper_poll_fini(), drm_atomic_helper_shutdown() and
component_unbind_all().  Once drm_dev_unplug() marks the device unplugged,
drm_dev_enter() in spacemit_dp_irq_handler() returns false and the handler
exits with IRQ_NONE without calling spacemit_dp_hw_clean_hpd() to clear the
level-triggered interrupt latch, causing a hardirq storm until
spacemit_dp_unbind() calls disable_irq().

[ ... ]

> +static irqreturn_t spacemit_dp_hotplug_event_handler(int irq, void *data)
> +{
> +	struct spacemit_dp_dev *dp = data;
> +	enum drm_connector_status status;
> +	int idx;
> +
> +	if (!drm_dev_enter(dp->drm, &idx))
> +		return IRQ_HANDLED;
> +
> +	/*
> +	 * .detect() owns mode_lock and re-reads the sink caps on a fresh plug
> +	 */
> +	status = spacemit_dp_bridge_detect(&dp->bridge, dp->connector);
> +	drm_bridge_hpd_notify(&dp->bridge, status);
> +
> +	drm_dev_exit(idx);
> +	return IRQ_HANDLED;
> +}

[Severity: Medium]
Does drm_bridge_hpd_notify() ever notify DRM on external DisplayPort
hotplug interrupts?

In spacemit_dp_probe(), external DP sets dp->bridge.ops to
DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID without DRM_BRIDGE_OP_HPD.
Because drm_bridge_connector_init() only registers an HPD callback on a
bridge with DRM_BRIDGE_OP_HPD set, dp->bridge.hpd_cb is NULL and
drm_bridge_hpd_notify() is a no-op.  Moreover, calling
spacemit_dp_bridge_detect() here updates dp->connector_status without
updating dp->connector->status, so an unplug-and-replug while the pixel
clock is running between 10-second poll intervals leaves both statuses as
connector_status_connected and drops the hotplug event and EDID re-read.

[ ... ]

> +static int spacemit_dp_dev_init(struct spacemit_dp_dev *dp)
> +{
[ ... ]
> +	/* Reset Controller and PHY */
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_CONTROLLER_RESET,
> +			  FIELD_PREP(DP_CONTROLLER_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_PHY_RESET,
> +			  FIELD_PREP(DP_PHY_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_HDCP_RESET,
> +			  FIELD_PREP(DP_HDCP_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_AUX_RESET,
> +			  FIELD_PREP(DP_AUX_RESET, 0x1));
> +	regmap_write_bits(dp->regs, DP_SOFT_RESET, DP_VIDEO_RESET,
> +			  FIELD_PREP(DP_VIDEO_RESET, 0x1));
> +	usleep_range(5000, 8000);
[ ... ]
> +	ret = spacemit_dp_set_plls(dp, SPACEMIT_DP_LINK_RATE_2_70, 148500);
> +	if (ret)
> +		return ret;
> +
> +	ret = spacemit_dp_phy_set_lanes(dp, SPACEMIT_DP_LANE_2);
> +	if (ret)
> +		return ret;
> +
> +	ret = spacemit_dp_phy_on(dp);
> +	if (ret)
> +		return ret;

[Severity: High]
When spacemit_dp_dev_init() runs a second time in spacemit_dp_bind() on eDP
(or on component rebind), does pulsing DP_PHY_RESET wipe the PREPLL
registers while clk_set_rate(dp->pll_clk, 148500000) short-circuits in the
clock framework?

On eDP, spacemit_dp_probe() calls spacemit_dp_dev_init(), which programs
dp->pll_clk to 148.5 MHz, and the PHY clock provider caches that rate.  When
spacemit_dp_bind() calls spacemit_dp_dev_init() again, asserting
DP_PHY_RESET resets the shared PHY PREPLL registers back to hardware
defaults, but clk_set_rate(dp->pll_clk, 148500000) sees that the requested
rate matches the cached rate and returns without calling the PHY clock's
.set_rate callback.  spacemit_dp_phy_on() (and later atomic_enable() for any
148.5 MHz mode) then tries to lock an unprogrammed PREPLL.

[ ... ]

> +static int spacemit_dp_bind(struct device *dev, struct device *master,
> +			    void *data)
> +{
> +	struct spacemit_dp_dev *dp = dev_get_drvdata(dev);
> +	struct drm_device *drm = data;
> +	struct device_node *ep;
> +	int ret;
> +
> +	dp->drm = drm;
> +	dp->aux.drm_dev = drm;
> +	ret = drm_dp_aux_register(&dp->aux);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to register DP AUX\n");
> +		goto err_drm;
> +	}
[ ... ]
> +	ret = spacemit_dp_dev_init(dp);
> +	if (ret)
> +		goto err_encoder;

[Severity: Medium]
Can userspace AUX or DDC transactions race with spacemit_dp_dev_init() and
spacemit_dp_set_plls()?

spacemit_dp_bind() calls drm_dp_aux_register(&dp->aux) before
spacemit_dp_dev_init(dp), exposing /dev/drm_dp_aux* and the I2C adapter
before the controller is initialized on external DP and while
spacemit_dp_dev_init() powers down MPLL and asserts DP_CONTROLLER_RESET,
DP_PHY_RESET and DP_AUX_RESET without holding dp->aux.hw_mutex.  Similarly,
in spacemit_dp_bridge_atomic_enable(), spacemit_dp_link_disable() releases
dp->aux.hw_mutex before spacemit_dp_set_plls() power-cycles the MPLL that
supplies the 16 MHz AUX reference clock.

[Severity: Medium]
If spacemit_dp_dev_init() fails here in spacemit_dp_bind(), should the error
path call spacemit_dp_hw_disable(dp) the way spacemit_dp_probe() does?

spacemit_dp_dev_init() enables interrupt masks and powers up the MPLL and
PREPLL in spacemit_dp_set_plls() before calling spacemit_dp_phy_set_lanes()
and spacemit_dp_phy_on().  Jumping to err_encoder on failure leaves the
PLLs powered on, and because dp->component_added is true while bind failed,
a later spacemit_dp_remove() will not run spacemit_dp_unbind() or
spacemit_dp_hw_disable() either.

[ ... ]

> +/* Leave the DRM device, or power down a controller that never joined one. */
> +static void spacemit_dp_unregister(struct spacemit_dp_dev *dp)
> +{
> +	if (dp->component_added)
> +		component_del(dp->dev, &spacemit_dp_ops);
> +	else
> +		spacemit_dp_hw_disable(dp);
> +}

[Severity: Medium]
Does spacemit_dp_unregister() leave the hardware powered on when
dp->component_added is true but the component master was never bound?

On eDP, spacemit_dp_probe() powers up the MPLL and analog TX blocks via
spacemit_dp_dev_init() and spacemit_dp_edp_link_panel() sets
dp->component_added = true.  If the driver is removed while the aggregate
DRM device is unbound (or if spacemit_dp_dev_init() failed during
spacemit_dp_bind()), component_del() does not invoke spacemit_dp_unbind(),
and the if (dp->component_added) branch skips spacemit_dp_hw_disable(dp).
Calling spacemit_dp_hw_disable(dp) unconditionally after component_del()
would ensure the PLLs and TX blocks are always powered down.

[ ... ]

> +	ret = devm_of_dp_aux_populate_bus(&dp->aux, spacemit_dp_edp_link_panel);
> +	if (ret) {
> +		spacemit_dp_unregister(dp);
> +		return dev_err_probe(dev, ret,
> +				     "eDP: failed to populate aux-bus panel\n");
> +	}
> +
> +	return 0;
> +
> +err_disable_pxclk:
> +	clk_disable_unprepare(dp->pxclk);
> +	return ret;
> +}
> +
> +static void spacemit_dp_remove(struct platform_device *pdev)
> +{
> +	spacemit_dp_unregister(platform_get_drvdata(pdev));
> +}

[Severity: Medium]
On eDP, does spacemit_dp_remove() tear down the component and power down the
controller before devres depopulates the AUX bus?

devm_of_dp_aux_populate_bus() registers of_dp_aux_depopulate_bus_void() as a
devres action, which runs during devres_release_all() after
spacemit_dp_remove() returns.  During driver unbind, spacemit_dp_remove()
powers down the controller while the AUX-bus child panel device is still
registered, and a deferred panel probe completing in that window can still
invoke spacemit_dp_edp_link_panel() -> component_add() after
spacemit_dp_unregister() has already run:

CPU0                                  CPU1 (deferred_probe_work_func)
__device_release_driver()
  spacemit_dp_remove()
    spacemit_dp_unregister()
      /* dp->component_added is false */
      spacemit_dp_hw_disable()
                                      panel_edp_probe()
                                        spacemit_dp_edp_link_panel()
                                          component_add(dp->dev, ...)
  devres_release_all()
    of_dp_aux_depopulate_bus_void()
    /* dp freed while component remains registered */

Depopulating the AUX bus in spacemit_dp_remove() before
spacemit_dp_unregister() (or registering spacemit_dp_unregister() as a devm
action prior to devm_of_dp_aux_populate_bus()) avoids this ordering
inversion.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-k3-display-v3-0-ec419e8e96b8@gmail.com?part=12

  reply	other threads:[~2026-11-21  8:08 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  7:40 [PATCH v3 00/17] drm/spacemit: add SpacemiT K3 display support Cody Kang via B4 Relay
2026-11-21  7:40 ` Cody Kang
2026-11-21  7:40 ` Cody Kang via B4 Relay
2026-11-21  7:40 ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 01/17] dt-bindings: display: spacemit: add K3 Saturn DPU controller Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:44   ` sashiko-bot
2026-11-21  7:44     ` sashiko-bot
2026-11-21  7:40 ` [PATCH v3 02/17] dt-bindings: phy: add SpacemiT K3 Innosilicon DP PHY Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 03/17] dt-bindings: display: spacemit: add K3 Innosilicon DP/eDP controller Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:45   ` sashiko-bot
2026-11-21  7:45     ` sashiko-bot
2026-11-21  7:40 ` [PATCH v3 04/17] dt-bindings: soc: spacemit: allow eDP/DP PHY PLL pixel clocks on K3 APMU Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 05/17] phy: spacemit: add Innosilicon DP TX PHY driver Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 06/17] clk: spacemit: k3: parent eDP/DP pixel clock to the PHY PLL Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 07/17] drm/spacemit: add Saturn DPU register model Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40 ` [PATCH v3 08/17] drm/spacemit: add Saturn DPU core types, cmdlist and display MMU Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 09/17] drm/spacemit: add Saturn DPU hardware backend Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  8:01   ` sashiko-bot
2026-11-21  8:01     ` sashiko-bot
2026-11-21  7:40 ` [PATCH v3 10/17] drm/spacemit: add Saturn DPU KMS pipeline Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  8:06   ` sashiko-bot
2026-11-21  8:06     ` sashiko-bot
2026-11-21  7:40 ` [PATCH v3 11/17] drm/spacemit: add Saturn DPU DRM device driver Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 12/17] drm/spacemit: add Innosilicon DP/eDP controller bridge driver Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  8:08   ` sashiko-bot [this message]
2026-11-21  8:08     ` sashiko-bot
2026-11-21  7:40 ` [PATCH v3 13/17] MAINTAINERS: add SpacemiT K3 display driver entry Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 14/17] riscv: dts: spacemit: k3: add display nodes Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 15/17] riscv: dts: spacemit: k3-pico-itx: enable the DisplayPort output Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 16/17] riscv: dts: spacemit: k3-com260-ifx: " Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40 ` [PATCH v3 17/17] riscv: defconfig: spacemit: k3: enable display driver Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang via B4 Relay
2026-11-21  7:40   ` Cody Kang
2026-11-21  7:40   ` Cody Kang via B4 Relay

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-226820@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=codykang.hk@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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.