From: Mario Limonciello <superm1@kernel.org>
To: Y.Vossen@beckhoff.com, Jean Delvare <jdelvare@suse.com>,
Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck
Date: Mon, 30 Nov 2026 10:04:53 -0600 [thread overview]
Message-ID: <7a7e8d26-6f3d-4b79-ade0-f68ab447fb17@kernel.org> (raw)
In-Reply-To: <20261130-piix4-fch-reset-v1-1-b19497ed5514@beckhoff.com>
On 11/30/26 08:07, Yannick Voßen via B4 Relay wrote:
> From: Yannick Voßen <Y.Vossen@beckhoff.com>
>
> 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 <Y.Vossen@beckhoff.com>
> ---
> 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 <linux/dmi.h>
> #include <linux/acpi.h>
> #include <linux/io.h>
> +#include <linux/iopoll.h>
> #include <linux/platform_data/x86/amd-fch.h>
>
> #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 <Y.Vossen@beckhoff.com>
prev parent reply other threads:[~2026-11-30 16:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 14:07 Yannick Voßen via B4 Relay
2026-11-30 16:04 ` Mario Limonciello [this message]
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=7a7e8d26-6f3d-4b79-ade0-f68ab447fb17@kernel.org \
--to=superm1@kernel.org \
--cc=Shyam-sundar.S-k@amd.com \
--cc=Y.Vossen@beckhoff.com \
--cc=andi.shyti@kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®