From: sashiko-bot@kernel.org
To: "Billy Tsai" <billy_tsai@aspeedtech.com>
Cc: linux-i3c@lists.infradead.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v2 6/9] i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller
Date: Wed, 11 Nov 2026 04:22:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-208274@kernel.org> (raw)
In-Reply-To: <20261111-b4-i3c-hci-ast2700-v2-6-4d8fff5c5196@aspeedtech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] i3c: mipi-i3c-hci: NULL deref and missing offset check in
hci_extcap_vendor_ASPEED()
- [Medium] i3c: mipi-i3c-hci: ACK_L programmed with hcnt instead of lcnt
in aspeed_i3c_phy_init()
--
commit adcbd5aae214cefb55e76d2928d998852108ffaf
Author: Billy Tsai <billy_tsai@aspeedtech.com>
i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller
This commit adds vendor capability parsing, resource management, interrupt
summary handling, PHY timing setup, and DAA index configuration for the
ASPEED AST2700 I3C controller.
> diff --git a/drivers/i3c/master/mipi-i3c-hci/aspeed.c b/drivers/i3c/master/mipi-i3c-hci/aspeed.c
> new file mode 100644
> index 0000000000000..3aa910e786f8e
> --- /dev/null
> +++ b/drivers/i3c/master/mipi-i3c-hci/aspeed.c
> @@ -0,0 +1,351 @@
[ ... ]
> +int hci_extcap_vendor_ASPEED(struct i3c_hci *hci, void __iomem *base)
> +{
> + struct aspeed_i3c_vendor_data *vd = to_aspeed_vendor_data(hci);
> +
> + vd->inhouse_regs = hci->base_regs + readl(base + 0x04);
> + vd->phy_regs = hci->base_regs + readl(base + 0x08);
> +
> + return 0;
> +}
> +
> +bool aspeed_i3c_vendor_cap_found(struct i3c_hci *hci)
> +{
> + struct aspeed_i3c_vendor_data *vd = to_aspeed_vendor_data(hci);
> +
> + return vd->inhouse_regs && vd->phy_regs;
> +}
[Severity: Medium]
Can hci_extcap_vendor_ASPEED() dereference a NULL vd pointer or populate
non-NULL register pointers from zero offsets?
EXT_CAP_VENDOR(ASPEED, 0xc0, 0x08) is registered unconditionally in
vendor_ext_caps[], whereas hci->vendor_data is only allocated in
i3c_hci_probe() when HCI_QUIRK_VENDOR_RESOURCES is set. If an ASPEED
controller is bound without HCI_QUIRK_VENDOR_RESOURCES (for example via the
generic "mipi-i3c-hci" compatible), i3c_hci_parse_ext_caps() calls
hci_extcap_vendor_ASPEED() with hci->vendor_data == NULL and crashes.
Similarly, the other four vendor quirks (HCI_QUIRK_VENDOR_BUS_SETUP,
HCI_QUIRK_BOARD_PHY_TIMINGS, HCI_QUIRK_VENDOR_INTR_SUMMARY, and
HCI_QUIRK_VENDOR_DAA_INDEX) dereference hci->vendor_data without checking
that HCI_QUIRK_VENDOR_RESOURCES allocated it or verified
aspeed_i3c_vendor_cap_found().
In addition, unlike the section parsers in i3c_hci_init() that check
"offset ? hci->base_regs + offset : NULL", hci_extcap_vendor_ASPEED() adds
readl(base + 0x04) and readl(base + 0x08) directly to hci->base_regs. A
zero offset in either register yields hci->base_regs rather than NULL, so
aspeed_i3c_vendor_cap_found() returns true and later vendor or PHY writes
overwrite the core HCI registers at hci->base_regs.
[ ... ]
> + hcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FM_SCL_H_NS, period_ns);
> + lcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FM_SCL_L_NS, period_ns);
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FM_CTRL1,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FM_CTRL1_SCL_H, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_PHY_I2C_FM_CTRL1_SCL_L, lcnt));
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FM_CTRL2,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FM_CTRL2_ACK_H, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FM_CTRL2_ACK_L, hcnt));
> +
> + hcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FM_HD_DAT_NS, period_ns);
> + lcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FM_AHD_DAT_NS, period_ns);
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FM_CTRL3,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FM_CTRL3_HD_DAT, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FM_CTRL3_AHD_DAT, lcnt));
> +
> + hcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FMP_CAS_NS, period_ns);
> + lcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FMP_SU_STO_NS, period_ns);
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FMP_CTRL0,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL0_CAS, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL0_SU_STO, lcnt));
> +
> + hcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FMP_SCL_H_NS, period_ns);
> + lcnt = aspeed_i3c_ns_to_cnt(ASPEED_I3C_PHY_I2C_FMP_SCL_L_NS, period_ns);
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FMP_CTRL1,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL1_SCL_H, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL1_SCL_L, lcnt));
> + aspeed_i3c_phy_write(hci, ASPEED_I3C_PHY_I2C_FMP_CTRL2,
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL2_ACK_H, hcnt) |
> + FIELD_PREP(ASPEED_I3C_PHY_I2C_FMP_CTRL2_ACK_L, hcnt));
[Severity: Medium]
Should ASPEED_I3C_PHY_I2C_FM_CTRL2_ACK_L and
ASPEED_I3C_PHY_I2C_FMP_CTRL2_ACK_L be programmed with lcnt instead of hcnt,
matching ASPEED_I3C_PHY_I3C_OD_CTRL2_ACK_L further down? Passing hcnt sets
the I2C ACK SCL low period to 1130 ns in Fast Mode (below the 1300 ns I2C
minimum tLOW) and 380 ns in Fast Mode Plus (below the 500 ns minimum).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111-b4-i3c-hci-ast2700-v2-0-4d8fff5c5196@aspeedtech.com?part=6
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2026-11-11 4:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 3:16 [PATCH v2 0/9] i3c: mipi-i3c-hci: Add Aspeed AST2700 support Billy Tsai
2026-11-11 3:16 ` [PATCH v2 1/9] dt-bindings: i3c: Document generic bus timing properties Billy Tsai
2026-11-11 16:50 ` Frank Li
2026-11-11 3:16 ` [PATCH v2 2/9] dt-bindings: i3c: Document the AST2700 I3C controller Billy Tsai
2026-11-11 3:16 ` [PATCH v2 3/9] i3c: mipi-i3c-hci: Support address-indexed DAT slots Billy Tsai
2026-11-11 3:16 ` [PATCH v2 4/9] i3c: mipi-i3c-hci: Add a quirk for 64-bit DMA addressing Billy Tsai
2026-11-11 3:16 ` [PATCH v2 5/9] i3c: mipi-i3c-hci: Add a quirk to clear the TX start threshold Billy Tsai
2026-11-11 3:16 ` [PATCH v2 6/9] i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller Billy Tsai
2026-11-11 4:22 ` sashiko-bot [this message]
2026-11-11 16:57 ` Frank Li
2026-11-11 17:11 ` Frank Li
2026-11-11 3:16 ` [PATCH v2 7/9] i3c: mipi-i3c-hci: Program AST2700 IBI termination threshold Billy Tsai
2026-11-11 4:35 ` sashiko-bot
2026-11-11 17:21 ` Frank Li
2026-11-11 3:16 ` [PATCH v2 8/9] i3c: mipi-i3c-hci: Improve AST2700 PIO TX queue utilization Billy Tsai
2026-11-11 3:16 ` [PATCH v2 9/9] i3c: mipi-i3c-hci: Support the AST2700 internal pull-ups Billy Tsai
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-208274@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=billy_tsai@aspeedtech.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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