* [PATCH v4] i2c: cadence: Add shutdown handler
@ 2026-04-30 5:30 Ajay Neeli
2026-06-09 5:12 ` Pandey, Radhey Shyam
2026-06-09 6:39 ` Andi Shyti
0 siblings, 2 replies; 4+ messages in thread
From: Ajay Neeli @ 2026-04-30 5:30 UTC (permalink / raw)
To: git, andi.shyti, linux-arm-kernel, linux-i2c, linux-kernel
Cc: michal.simek, srinivas.goud, radhey.shyam.pandey, Ajay Neeli
During system reboot or kexec, in-flight I2C transfers can cause
spurious interrupts or leave the bus in an undefined state. Add a
shutdown handler that marks the adapter suspended and resets the
controller, ensuring a clean handoff.
Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
---
Link: https://lore.kernel.org/linux-i2c/20250730122907.18909-1-ajay.neeli@amd.com/
Changes v3->v4:
- Replaced disable_irq() with cdns_i2c_master_reset() to avoid
potential deadlocks during shutdown
- Added pm_runtime_status_suspended() check to skip register access
when clocks are disabled
Changes v2->v3:
Corrected a typo that caused a build error in v2
Changes in v1->v2:
Disable interrupts
---
drivers/i2c/busses/i2c-cadence.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 0fb728ade92e..da8770182a18 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -1635,6 +1635,25 @@ static void cdns_i2c_remove(struct platform_device *pdev)
reset_control_assert(id->reset);
}
+/**
+ * cdns_i2c_shutdown - Prepare I2C controller for system shutdown
+ * @pdev: Handle to the platform device structure
+ *
+ * Mark the adapter as suspended and reset the controller to ensure a clean
+ * handoff during system reboot or kexec.
+ */
+static void cdns_i2c_shutdown(struct platform_device *pdev)
+{
+ struct cdns_i2c *id = platform_get_drvdata(pdev);
+
+ /* Mark the adapter as suspended to prevent further I2C transfers */
+ i2c_mark_adapter_suspended(&id->adap);
+
+ /* Reset the controller state if active - clocks are disabled when suspended */
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ cdns_i2c_master_reset(&id->adap);
+}
+
static struct platform_driver cdns_i2c_drv = {
.driver = {
.name = DRIVER_NAME,
@@ -1643,6 +1662,7 @@ static struct platform_driver cdns_i2c_drv = {
},
.probe = cdns_i2c_probe,
.remove = cdns_i2c_remove,
+ .shutdown = cdns_i2c_shutdown,
};
module_platform_driver(cdns_i2c_drv);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v4] i2c: cadence: Add shutdown handler
2026-04-30 5:30 [PATCH v4] i2c: cadence: Add shutdown handler Ajay Neeli
@ 2026-06-09 5:12 ` Pandey, Radhey Shyam
2026-06-09 6:39 ` Andi Shyti
1 sibling, 0 replies; 4+ messages in thread
From: Pandey, Radhey Shyam @ 2026-06-09 5:12 UTC (permalink / raw)
To: Ajay Neeli, git, andi.shyti, linux-arm-kernel, linux-i2c,
linux-kernel
Cc: michal.simek, srinivas.goud, radhey.shyam.pandey
> During system reboot or kexec, in-flight I2C transfers can cause
> spurious interrupts or leave the bus in an undefined state. Add a
> shutdown handler that marks the adapter suspended and resets the
> controller, ensuring a clean handoff.
>
> Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Thanks!
> ---
> Link: https://lore.kernel.org/linux-i2c/20250730122907.18909-1-ajay.neeli@amd.com/
>
> Changes v3->v4:
> - Replaced disable_irq() with cdns_i2c_master_reset() to avoid
> potential deadlocks during shutdown
> - Added pm_runtime_status_suspended() check to skip register access
> when clocks are disabled
>
> Changes v2->v3:
> Corrected a typo that caused a build error in v2
>
> Changes in v1->v2:
> Disable interrupts
> ---
> drivers/i2c/busses/i2c-cadence.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index 0fb728ade92e..da8770182a18 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -1635,6 +1635,25 @@ static void cdns_i2c_remove(struct platform_device *pdev)
> reset_control_assert(id->reset);
> }
>
> +/**
> + * cdns_i2c_shutdown - Prepare I2C controller for system shutdown
> + * @pdev: Handle to the platform device structure
> + *
> + * Mark the adapter as suspended and reset the controller to ensure a clean
> + * handoff during system reboot or kexec.
> + */
> +static void cdns_i2c_shutdown(struct platform_device *pdev)
> +{
> + struct cdns_i2c *id = platform_get_drvdata(pdev);
> +
> + /* Mark the adapter as suspended to prevent further I2C transfers */
> + i2c_mark_adapter_suspended(&id->adap);
> +
> + /* Reset the controller state if active - clocks are disabled when suspended */
> + if (!pm_runtime_status_suspended(&pdev->dev))
> + cdns_i2c_master_reset(&id->adap);
> +}
> +
> static struct platform_driver cdns_i2c_drv = {
> .driver = {
> .name = DRIVER_NAME,
> @@ -1643,6 +1662,7 @@ static struct platform_driver cdns_i2c_drv = {
> },
> .probe = cdns_i2c_probe,
> .remove = cdns_i2c_remove,
> + .shutdown = cdns_i2c_shutdown,
> };
>
> module_platform_driver(cdns_i2c_drv);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v4] i2c: cadence: Add shutdown handler
2026-04-30 5:30 [PATCH v4] i2c: cadence: Add shutdown handler Ajay Neeli
2026-06-09 5:12 ` Pandey, Radhey Shyam
@ 2026-06-09 6:39 ` Andi Shyti
2026-06-09 6:44 ` Michal Simek
1 sibling, 1 reply; 4+ messages in thread
From: Andi Shyti @ 2026-06-09 6:39 UTC (permalink / raw)
To: Ajay Neeli
Cc: git, linux-arm-kernel, linux-i2c, linux-kernel, michal.simek,
srinivas.goud, radhey.shyam.pandey
Hi Ajay,
On Thu, Apr 30, 2026 at 11:00:50AM +0530, Ajay Neeli wrote:
> During system reboot or kexec, in-flight I2C transfers can cause
> spurious interrupts or leave the bus in an undefined state. Add a
> shutdown handler that marks the adapter suspended and resets the
> controller, ensuring a clean handoff.
>
> Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
Michal's ack was missing here.
Merged to i2c/i2c-host.
Thanks,
Andi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] i2c: cadence: Add shutdown handler
2026-06-09 6:39 ` Andi Shyti
@ 2026-06-09 6:44 ` Michal Simek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2026-06-09 6:44 UTC (permalink / raw)
To: Andi Shyti, Ajay Neeli
Cc: git, linux-arm-kernel, linux-i2c, linux-kernel, srinivas.goud,
radhey.shyam.pandey
On 6/9/26 08:39, Andi Shyti wrote:
> Hi Ajay,
>
> On Thu, Apr 30, 2026 at 11:00:50AM +0530, Ajay Neeli wrote:
>> During system reboot or kexec, in-flight I2C transfers can cause
>> spurious interrupts or leave the bus in an undefined state. Add a
>> shutdown handler that marks the adapter suspended and resets the
>> controller, ensuring a clean handoff.
>>
>> Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
>
> Michal's ack was missing here.
>
> Merged to i2c/i2c-host.
I have reviewed this patch internally too.
Just checking why I missed it.
Anyway the patch is fine for me.
Thanks,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-09 6:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 5:30 [PATCH v4] i2c: cadence: Add shutdown handler Ajay Neeli
2026-06-09 5:12 ` Pandey, Radhey Shyam
2026-06-09 6:39 ` Andi Shyti
2026-06-09 6:44 ` Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox