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=1796054696; b=x9nCs7zvLLgDD/V4e75/qNGvZxW2etKLOMf/GuqTqafJqyThMpARLNoDKVD/94e3GosF KAbZK8QpnVPcIL4jR82V+jOTV2eV1f0WHL+0IUnnndVob4Fs+y1mDXFP3qVBMQDDGgXeG CFhzgFGlmheGxh//diisAvRM9PzcCNP2PdYHjPM/4oBuVQ2I7vbwIGMwgscKxGvPe8LrG jN43u0ISAd3b9CH67UX2PU5dnJEcWqVLDVeQL1eps2vN5hbCjwZOhvklOU90iPG0hjeMc omEYB800TWDmo0U1UXl/3zqhcK/kHe3uzMH/JVN/IYxzOTFMYrbkcE1WVukf/6PC+DQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796054696; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=BJ7PUSmobJKH9KcYonnDmqXmADLp7xdQJMfttYZrmKg=; b=TLFlpjX3feFufdjNiPYR+Fr+EYnXCUBCTtspxjIEwrL2W/G1eb2dQl/4uRQttuCLowXg kL9pXyldFFTbglJocAGxy5IzWiyl9Y280vFLeKQF98AYUn7Re74YKn62k9/buxEkk1z2i oTwGGOqYGHFrpO5YV+up2xyuGN/UQCLGQ0cW/h17ldHHrwQGQhC1K9KULHy49lptTMqTt xLVkbuJBh0XHBRzDDobwa/cg0nTDAc94EBD7RJBeP6l5Q1UBxiyRG4RLut5eg90Gr5gb4 7YJjL2MsgMOgReRI0OH5Aenzi5vtrOHfuX+9YJZqx+fU3Hi1xY98B8XH5Zqr1QFQBrw== 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=RjyxUrQZ; 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 3E0BF606A325; Mon, 30 Nov 2026 16:04:56 +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=RjyxUrQZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1970B1F00897; Mon, 30 Nov 2026 16:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796054695; bh=BJ7PUSmobJKH9KcYonnDmqXmADLp7xdQJMfttYZrmKg=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=RjyxUrQZfqr1s2BYAfy5bfNRyCCcyAu6qysqYwR/Xz+mjhFRqJ0tWYmjS3i5RCFVk 3HM04F4hLAELha+E6+jzvmxfZO84j2uPg5C0YqEeTO0/QDlVoGV+IaaSe+25l4lsaP lrpS1Ao0SFFWcpDSOhRSZSA9H1ofht6jJwrn6hchZc6Et6YIBx5GMuaZFOV0fHy3TT KANLaNb0bAJRwDEqX93uG9h8aj9pt2/3KQAffxrj9z6H9TQuo/0B9LJPfKTjFiJXOg LMnD0xFPYhe38c0JTWXUYbBvcO8Nya4Tlqc9ROGXbCkf7oFs8bnX4fjTeKPo2wVPSs Db0r9VR6ctvGA== Message-ID: <7a7e8d26-6f3d-4b79-ade0-f68ab447fb17@kernel.org> Date: Mon, 30 Nov 2026 10:04:53 -0600 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck Content-Language: en-US To: Y.Vossen@beckhoff.com, Jean Delvare , Andi Shyti Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Shyam Sundar S K , stable@vger.kernel.org References: <20261130-piix4-fch-reset-v1-1-b19497ed5514@beckhoff.com> From: Mario Limonciello In-Reply-To: <20261130-piix4-fch-reset-v1-1-b19497ed5514@beckhoff.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/30/26 08:07, Yannick Voßen via B4 Relay wrote: > From: Yannick Voßen > > On AMD KERNCZ FCH SMBus controllers, HOST_BUSY can remain set after a > transaction collided with another bus master. Clearing the status > register does not recover the controller, so all following > transactions fail with -EBUSY until the next reboot. > > The FCH host control register provides a controller reset in bit 7. > Use it when a transaction failed and HOST_BUSY is still set, while the > SMBus semaphore is held and the port is still selected. Restrict this > to the KERNCZ main SMBus controller, since bit 7 is reserved on PIIX4 > and has a different meaning on the ASF controller. The reset is only > issued in this error case and holds the semaphore for at most 10 ms. > > Tested on a Beckhoff CX20x3 (AMD Ryzen Embedded V1202B, FCH SMBus > [1022:790b] rev 0x61) with a second SMBus master on the same bus that > sends a transaction every few milliseconds. Without this patch, the > first collision (presumably arbitration loss) leaves HOST_BUSY set and > the bus unusable until reboot. With this patch the controller is > reset and subsequent transactions succeed. > > Cc: stable@vger.kernel.org > Signed-off-by: Yannick Voßen > --- > On boards with an additional SMBus master on the same bus, the AMD FCH > host controller can end up with HOST_BUSY stuck after a collision. The > hang is sporadic: it may not show up for hours, or it may happen within > minutes. Once it does, the bus stays unusable until reboot, so Cc > stable for boards that already ship with such a setup. > I'll pose what I hope is the obvious question - why are there two masters on the same bus in this design? And do you have full control of the second master? Is that master following the arbitration rules mentioned in the SMBUS spec (https://www.smbus.org/specs/smbus20.pdf section 4.3.2)? > There is no Fixes: tag, as the driver never had a recovery path for > this condition. > > It would be great if someone at AMD could confirm that bit 7 is a > full controller reset on KERNCZ FCH and whether it affects any other > SMBus/ASF state. > --- > drivers/i2c/busses/i2c-piix4.c | 47 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c > index 7b6a4e201be4..f32f5ba8df22 100644 > --- a/drivers/i2c/busses/i2c-piix4.c > +++ b/drivers/i2c/busses/i2c-piix4.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include > > #include "i2c-piix4.h" > @@ -153,6 +154,7 @@ struct i2c_piix4_adapdata { > /* SB800 */ > bool sb800_main; > bool notify_imc; > + bool fch_reset; > u8 port; /* Port number, shifted */ > struct sb800_mmio_cfg mmio_cfg; > }; > @@ -769,6 +771,43 @@ int piix4_sb800_port_sel(u8 port, struct sb800_mmio_cfg *mmio_cfg) > } > EXPORT_SYMBOL_NS_GPL(piix4_sb800_port_sel, "PIIX4_SMBUS"); > > +/* > + * HOST_BUSY can get stuck on AMD FCH SMBus controllers, e.g. after a > + * collision with another bus master. Clearing the status register does > + * not recover from this, only a controller reset does. > + */ > +static void piix4_fch_reset(struct i2c_adapter *adap, > + unsigned short piix4_smba) > +{ > + int ret; > + u8 sts; > + > + dev_warn_ratelimited(&adap->dev, > + "SMBus host stuck busy, resetting controller\n"); > + > + /* > + * Bit 7 resets the controller. This is only valid on the AMD FCH main > + * SMBus controller: the bit is reserved on PIIX4 and means DataEn on > + * the AMD ASF controller. > + */ > + outb_p(0x80, SMBHSTCNT); > + > + /* > + * The reset does not generate bus traffic and is expected to complete > + * within microseconds, no value is documented. 10 ms is a generous > + * upper bound that keeps the time the SMBus semaphore is held short. > + */ > + ret = read_poll_timeout(inb_p, sts, !(sts & 0x01), > + 100, 10 * USEC_PER_MSEC, false, SMBHSTSTS); > + outb_p(0, SMBHSTCNT); > + outb_p(inb_p(SMBHSTSTS), SMBHSTSTS); > + > + if (ret) > + dev_err_ratelimited(&adap->dev, > + "SMBus controller reset failed (%02x)\n", > + inb_p(SMBHSTSTS)); > +} > + > /* > * Handles access to multiple SMBus ports on the SB800. > * The port is selected by bits 2:1 of the smb_en register (0x2c). > @@ -850,6 +889,11 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, > retval = piix4_access(adap, addr, flags, read_write, > command, size, data); > > + /* Recover while we still own the semaphore and the port is selected */ > + if (retval && adapdata->fch_reset && > + (inb_p(SMBHSTSTS) & 0x01)) > + piix4_fch_reset(adap, piix4_smba); > + > piix4_sb800_port_sel(prev_port, &adapdata->mmio_cfg); > > /* Release the semaphore */ > @@ -942,6 +986,9 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, > adapdata->sb800_main = sb800_main; > adapdata->port = port << piix4_port_shift_sb800; > adapdata->notify_imc = notify_imc; > + adapdata->fch_reset = sb800_main && > + dev->vendor == PCI_VENDOR_ID_AMD && > + dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS; > > /* set up the sysfs linkage to our parent device */ > adap->dev.parent = &dev->dev; > > --- > base-commit: 04e9bf1648f846976b543e91c1838a712433772a > change-id: 20261130-piix4-fch-reset-6bc408e51c2a > > Best regards, > -- > Yannick Voßen