* [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck
@ 2026-11-30 14:07 Yannick Voßen via B4 Relay
2026-11-30 16:04 ` Mario Limonciello
0 siblings, 1 reply; 3+ messages in thread
From: Yannick Voßen via B4 Relay @ 2026-11-30 14:07 UTC (permalink / raw)
To: Jean Delvare, Andi Shyti
Cc: linux-i2c, linux-kernel, Shyam Sundar S K, Mario Limonciello,
stable, Yannick Voßen
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.
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck
2026-11-30 14:07 [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck Yannick Voßen via B4 Relay
@ 2026-11-30 16:04 ` Mario Limonciello
2026-12-01 12:54 ` Yannick Voßen
0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2026-11-30 16:04 UTC (permalink / raw)
To: Y.Vossen, Jean Delvare, Andi Shyti
Cc: linux-i2c, linux-kernel, Shyam Sundar S K, stable
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck
2026-11-30 16:04 ` Mario Limonciello
@ 2026-12-01 12:54 ` Yannick Voßen
0 siblings, 0 replies; 3+ messages in thread
From: Yannick Voßen @ 2026-12-01 12:54 UTC (permalink / raw)
To: Mario Limonciello, Jean Delvare, Andi Shyti
Cc: linux-i2c, linux-kernel, Shyam Sundar S K, stable
Mario Limonciello wrote:
> 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?
The second master is a microcontroller on our power supply module. It
is a slave to the host, but it also talks to a battery on the same
bus, so it becomes a master for those transfers. It runs our own
firmware, so yes, we have full control over it.
> Is that master following the arbitration rules mentioned in the
> SMBUS spec (https://www.smbus.org/specs/smbus20.pdf section 4.3.2)?
Not 100%, thanks for the pointer. We will go through the firmware and
try making it fully SMBus compliant, then run a long-term test and let you
know whether the hang still shows up.
Even so, the host controller should not end up in a state it can only
leave by rebooting, even if a second master misbehaves. If our
suspicion is right, the FCH sees a collision on the bus, but instead
of aborting the transfer it stays HOST_BUSY until reboot. The patch
only adds a way to recover from that state.
Would you prefer this recovery as a quirk, e.g. DMI-matched and
limited to affected boards, instead of enabling it for all KERNCZ FCH
controllers? I'm happy to rework the patch either way.
Thanks,
Yannick
This email contains confidential information. If you have received it in error, you must not read, use, copy or pass on this e-mail or its attachments.
If you have received the e-mail in error, please inform me immediately by reply e-mail and then delete this e-mail from your system. Thank you
Diese E-Mail enthält vertrauliche Informationen. Sollten Sie sie irrtümlich erhalten haben, dürfen Sie diese E-Mail oder ihre Anhänge nicht lesen, verwenden, kopieren oder weitergeben.
Sollten Sie die Mail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per Antwort-E-Mail mit und löschen Sie diese E-Mail dann aus Ihrem System. Vielen Dank
Beckhoff Automation GmbH & Co. KG
Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany
Register court: Guetersloh HRA 7075
DisclaimerID:x9d5u140
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 12:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 14:07 [PATCH] i2c: piix4: Reset AMD FCH SMBus controller when HOST_BUSY is stuck Yannick Voßen via B4 Relay
2026-11-30 16:04 ` Mario Limonciello
2026-12-01 12:54 ` Yannick Voßen
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®