From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796268177; b=kdAT6decboo/frN0TySmGVdM9LBmZ2Pq5fOqhkzaN1dVIrK0NgMfjLYZvngjd2RrYnDw JiCHR53N0ArkCJlNprXOnxJOvxEA/d5TgeU3VLZ/4F0T9cic/b3qxik3TJtXRO1LKZhzB GBGg7CL4Yhot9S341Zl8cN3ytgnR/moVmxldd0eZPoKnAqBIUYGcPn/TNntYRFBsPCCP+ lwQ3H6+HkNWuZ5OIRFAXWkwrxrjqKTTgYGnqTVF7HoZUsRPGkJmha1tmLIBMEagUZGzvo MP96lfvBXq9AfK7cKJQ4rZdFf6Cmv8Iik6I7gen42pn3EtRtFH3CRgkq86UZ44PRwkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796268177; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Pb2Ajxq5fNY32BXQpTjMikPlawJOog+nW+yyXe98JvQ=; b=2Y7SEQYAVrucDqwFluMu66uZmE/zdlmPBk8PF64TnNDa9pPBlfvp5LrpQrF2/11weICB TMFCL1Bf0eUq65EM1/D2Zq7aVsFebjOnKVCjqNA6dc08MxoN7PusWlazvC4k4WHL30Grm oxYNau+UOl1jdRJaSllUeIFaoHbCtiCIKlefOXp5YMEx9QwOrxzDu29IKZg8YG4bSKkTC cCdmXpwAVPhtVtEo0vYQxXa+Xhzbx5Lann++nx3WnExE0Z9x/19H87iKJoq0LfBXNP0Z2 lrgiTwogELXytRny2YqxwKYNmysGSSwLgmke8lIiDtdUpucqRw0Mc43JSui9sc0/zuQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GxqMQyQ1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D7E606A339 for ; Thu, 3 Dec 2026 03:22:57 +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=GxqMQyQ1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26E7F1F00896; Thu, 3 Dec 2026 03:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796268177; bh=Pb2Ajxq5fNY32BXQpTjMikPlawJOog+nW+yyXe98JvQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GxqMQyQ1J30GemRuZPcTYEru3NpIK3tep/VFzYBQ6Jj2oVQVEPbb/UBIXdmZcxhiQ rn2rTbjL8oNmReFaijWk6VPYftGTaZDnp6644/aepnlepRwe86ol+QEMHhuMM9Zikr KW8wDKN2viC9mJbw8AzYtNrP9kN/IS0kJe3KSIo55ZWplizJgq3QCaZ0UJr9QiW85h fUfwv5UyrEyupUW9KfZRjKDaDpg5htcB8XLTNNgvaOD2NQxDLUQqy6NOFNqY/WaNYY 7/AKMUZPsvW25UdJ3Hrvw3ITK1swT3E88Mlc2Cp5LxKTAfy2fp+Ldf1y64s1lvhEbs BVhbgAHKEokhg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 07/10] i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller Reply-To: sashiko-reviews@lists.linux.dev To: "Billy Tsai" Cc: linux-i3c@lists.infradead.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org, "Alexandre Belloni" In-Reply-To: <20261203-b4-i3c-hci-ast2700-v3-7-e8b9553560ed@aspeedtech.com> References: <20261203-b4-i3c-hci-ast2700-v3-0-e8b9553560ed@aspeedtech.com> <20261203-b4-i3c-hci-ast2700-v3-7-e8b9553560ed@aspeedtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 03:22:56 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] i3c: mipi-i3c-hci: aspeed: unclamped 11-bit PHY SCL counters in aspeed_i3c_phy_init() -- commit 0be57fae36882fda6191e1917476e0f3fd47ef61 Author: Billy Tsai i3c: mipi-i3c-hci: Add support for the AST2700 I3C controller This commit adds vendor extended capability handling, PHY timing configuration, interrupt summary dispatch, and DAA index setup for the ASPEED AST2700 MIPI I3C HCI controller. > diff --git a/drivers/i3c/master/mipi-i3c-hci/aspeed.c b/drivers/i3c/maste= r/mipi-i3c-hci/aspeed.c > new file mode 100644 > index 0000000000000..c7abce4f2f990 > --- /dev/null > +++ b/drivers/i3c/master/mipi-i3c-hci/aspeed.c > @@ -0,0 +1,357 @@ [ ... ] > +static u16 aspeed_i3c_ns_to_cnt(unsigned int ns, unsigned long period_ns) > +{ > + unsigned long cycles =3D DIV_ROUND_CLOSEST(ns, period_ns); > + > + /* All PHY counter fields are 11 bits wide */ > + return min(max(cycles, 1) - 1, ASPEED_I3C_PHY_CNT_MAX); > +} [ ... ] > +int aspeed_i3c_phy_init(struct i3c_hci *hci) > +{ > + u16 hcnt, lcnt, total_cnt, min_tbit_cnt, cas_lcnt, cas_cnt, cbp_cnt; > + u32 pp_sda_hold =3D 0, cas_ns =3D 0, cbp_ns =3D 0, sr_p_low =3D 0; > + struct i3c_bus *bus =3D i3c_master_get_bus(&hci->master); > + u32 pp_high =3D 0, pp_low =3D 0, od_high =3D 0, od_low =3D 0; > + struct device_node *np =3D hci->master.dev.of_node; > + u32 sdr_ctrl0_reg, ctrl0, ctrl1, ctrl2; > + unsigned long core_rate, period_ns; [ ... ] > + of_property_read_u32(np, "i3c-pp-scl-high-period-ns", &pp_high); > + of_property_read_u32(np, "i3c-pp-scl-low-period-ns", &pp_low); > + if (pp_high && pp_low) { > + hcnt =3D aspeed_i3c_ns_to_cnt(pp_high, period_ns); > + lcnt =3D aspeed_i3c_ns_to_cnt(pp_low, period_ns); > + } else { > + /* > + * Each of hcnt/lcnt is programmed as N-1 (the PHY counts N > + * cycles for a stored value of N-1), so pre-subtract 2 here > + * to cancel the two implicit +1s and match the requested SCL > + * period exactly. Clamp the pre-subtraction value so > + * total_cnt cannot underflow when an unrealistically high > + * scl_rate leaves less than 3 cycles per period. > + */ > + unsigned long cycles_per_scl =3D DIV_ROUND_UP(core_rate, bus->scl_rate= .i3c); > + > + total_cnt =3D max_t(unsigned long, cycles_per_scl, 3) - 2; > + if (hci->master.bus.mode =3D=3D I3C_BUS_MODE_PURE) { > + hcnt =3D DIV_ROUND_DOWN_ULL(total_cnt * 2, 5); > + lcnt =3D total_cnt - hcnt; > + } else { > + hcnt =3D DIV_ROUND_UP(I3C_BUS_THIGH_MIXED_MAX_NS, > + period_ns) - 1; > + lcnt =3D total_cnt - hcnt; > + } > + } > + > + ctrl0 =3D FIELD_PREP(ASPEED_I3C_PHY_I3C_CTRL0_SCL_H, hcnt) | > + FIELD_PREP(ASPEED_I3C_PHY_I3C_CTRL0_SCL_L, lcnt); [Severity: Low] Can lcnt and hcnt exceed the 11-bit ASPEED_I3C_PHY_CNT_MAX limit when derived from bus->scl_rate.i3c? Unlike aspeed_i3c_ns_to_cnt(), the fallback branch does not clamp hcnt or lcnt to ASPEED_I3C_PHY_CNT_MAX (2047) and stores cycles_per_scl - 2 in a u16 total_cnt. For example, a 100 kHz I2C bus in I3C_BUS_MODE_MIXED_SLOW sets bus->scl_rate.i3c to 100 kHz; at a 250 MHz core clock, lcnt is 2488, which FIELD_PREP() truncates to 440, driving SCL at roughly 555 kHz instead of 100 kHz. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-b4-i3c-hci= -ast2700-v3-0-e8b9553560ed@aspeedtech.com?part=3D7