From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Peter Yin <peteryin.openbmc@gmail.com>,
Frank Li <Frank.Li@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Sasha Levin <sashal@kernel.org>,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.12] i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter
Date: Tue, 17 Mar 2026 07:32:46 -0400 [thread overview]
Message-ID: <20260317113249.117771-15-sashal@kernel.org> (raw)
In-Reply-To: <20260317113249.117771-1-sashal@kernel.org>
From: Peter Yin <peteryin.openbmc@gmail.com>
[ Upstream commit f26ecaa0f0abfe5db173416214098a00d3b7db79 ]
The DesignWare I3C master driver creates a virtual I2C adapter to
provide backward compatibility with I2C devices. However, the current
implementation does not associate this virtual adapter with any
Device Tree node.
Propagate the of_node from the I3C master platform device to the
virtual I2C adapter's device structure. This ensures that standard
I2C aliases are correctly resolved and bus numbering remains consistent.
Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260302075645.1492766-1-peteryin.openbmc@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
Now I have the complete picture.
## Analysis
### What the commit fixes
The DesignWare I3C master driver creates a virtual I2C adapter
(`master->base.i2c`) for backward compatibility. When this adapter is
registered via `i3c_master_register()` ->
`i3c_master_i2c_adapter_init()` -> `i2c_add_adapter()`, the I2C core
calls `of_i2c_register_devices(adap)` (at `i2c-core-base.c:1593`).
The critical code in `of_i2c_register_devices()` at `i2c-core-of.c:90`:
```c
if (!adap->dev.of_node)
return;
```
**Without this fix**, `adap->dev.of_node` is NULL, so
`of_i2c_register_devices()` returns immediately without registering any
I2C child devices described in the device tree. This means **I2C devices
under the I3C master node in the DT will never be discovered or
registered**.
### Bug severity
This is a real functional bug. On systems using Device Tree (most
ARM/embedded systems where this driver is used - OpenBMC systems, etc.),
I2C devices behind the DW I3C master won't be enumerated. The author's
email (`peteryin.openbmc@gmail.com`) confirms this is from an OpenBMC
context where DT-based I2C device discovery is essential.
### Stable criteria assessment
- **Fixes a real bug**: Yes - I2C devices behind I3C master are not
discovered from DT
- **Obviously correct**: Yes - `device_set_of_node_from_dev` is a well-
established helper, and propagating the parent's of_node to a virtual
adapter is standard practice
- **Small and contained**: Yes - single line addition in one file
- **No new features**: Correct - this restores expected functionality
(DT device discovery)
- **Reviewed**: Yes - by Frank Li at NXP (an I3C hardware vendor)
### Risk assessment
Very low risk. The change adds one call to
`device_set_of_node_from_dev()` before `i3c_master_register()`. The
function safely handles refcounting (does `of_node_put` on old,
`of_node_get` on new). If the pdev has no of_node, it's a no-op (NULL ->
NULL).
### Verification
- Read `dw-i3c-master.c:1616-1618`: confirmed the current code has no
of_node propagation before `i3c_master_register()`
- Read `drivers/i3c/master.c:2554-2574`: confirmed
`i3c_master_i2c_adapter_init()` sets `adap->dev.parent` but NOT
`adap->dev.of_node`
- Read `drivers/i2c/i2c-core-of.c:84-91`: confirmed
`of_i2c_register_devices()` returns immediately if `adap->dev.of_node`
is NULL - this is the concrete bug mechanism
- Read `drivers/i2c/i2c-core-base.c:1593`: confirmed
`of_i2c_register_devices()` is called during adapter registration
- git log confirmed the dw-i3c-master.c has existed for a long time and
this code path is established
- The fix pattern (propagating of_node to virtual/child devices) is
standard across the kernel
### Concerns
- The commit doesn't have a `Fixes:` tag pointing to the original commit
that created the driver, but as noted in the guidelines, this is
expected for commits under review
- No dependency on other patches - this is fully self-contained
- The `device_set_of_node_from_dev()` function has been available since
kernel 5.x, so this should apply cleanly to all active stable trees
that have the DW I3C driver
This is a clear bug fix: I2C devices described in Device Tree under an
I3C master node are silently not discovered because the virtual I2C
adapter lacks the of_node needed by the I2C core's DT enumeration. The
fix is a single, safe, well-reviewed line.
**YES**
drivers/i3c/master/dw-i3c-master.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
index 4033bc16677ff..aa683894e6de9 100644
--- a/drivers/i3c/master/dw-i3c-master.c
+++ b/drivers/i3c/master/dw-i3c-master.c
@@ -1614,6 +1614,8 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
pm_runtime_get_noresume(&pdev->dev);
INIT_WORK(&master->hj_work, dw_i3c_hj_work);
+
+ device_set_of_node_from_dev(&master->base.i2c.dev, &pdev->dev);
ret = i3c_master_register(&master->base, &pdev->dev,
&dw_mipi_i3c_ops, false);
if (ret)
--
2.51.0
next prev parent reply other threads:[~2026-03-17 11:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 11:32 [PATCH AUTOSEL 6.19-6.1] ALSA: hda/realtek: add HP Laptop 14s-dr5xxx mute LED quirk Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.6] spi: intel-pci: Add support for Nova Lake mobile SPI flash Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19] objtool: Use HOSTCFLAGS for HAVE_XXHASH test Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.18] powerpc64/ftrace: fix OOL stub count with clang Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] nvmet: move async event work off nvmet-wq Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] drm/amdgpu: fix gpu idle power consumption issue for gfx v12 Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19] objtool/klp: Disable unsupported pr_debug() usage Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19] ALSA: usb-audio: Add iface reset and delay quirk for SPACETOUCH USB Audio Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.1] usb: core: new quirk to handle devices with zero configurations Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] ALSA: hda/realtek: add quirk for ASUS UM6702RC Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.6] objtool: Handle Clang RSP musical chairs Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.12] sched_ext: Use WRITE_ONCE() for the write side of dsq->seq update Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.1] btrfs: set BTRFS_ROOT_ORPHAN_CLEANUP during subvol create Sasha Levin
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-6.18] ALSA: hda/realtek: Add quirk for Gigabyte Technology to fix headphone Sasha Levin
2026-03-17 11:32 ` Sasha Levin [this message]
2026-03-17 11:32 ` [PATCH AUTOSEL 6.19-5.10] ALSA: hda/realtek: Add headset jack quirk for Thinkpad X390 Sasha Levin
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=20260317113249.117771-15-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=peteryin.openbmc@gmail.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox