public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
@ 2026-03-20 20:12 Pratap Nirujogi
  2026-03-20 20:25 ` Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Pratap Nirujogi @ 2026-03-20 20:12 UTC (permalink / raw)
  To: andi.shyti, andriy.shevchenko, mlimonci, mika.westerberg, jsd
  Cc: rafael.j.wysocki, benjamin.chan, bin.du, king.li, linux-i2c,
	linux-kernel, Pratap Nirujogi

Identified resume-probe race condition in kernel v7.0 with the commit
38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
issue existed from the beginning though not detected.

The amdisp i2c device requires ISP to be in power-on state for probe
to succeed. To meet this requirement, this device is added to genpd
to control ISP power using runtime PM. The pm_runtime_get_sync() called
before i2c_dw_probe() triggers PM resume, which powers on ISP and also
invokes the amdisp i2c runtime resume before the probe completes resulting
in this race condition and a NULL dereferencing issue in v7.0

Fix this race condition by using the genpd APIs directly during probe:
  - Call dev_pm_genpd_resume() to Power ON ISP before probe
  - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
  - Set the device to suspended state with pm_runtime_set_suspended()
  - Enable runtime PM only after the device is fully initialized

Fixes: d6263c468a761 ("i2c: amd-isp: Add ISP i2c-designware driver")
Co-developed-by: Bin Du <bin.du@amd.com>
Signed-off-by: Bin Du <bin.du@amd.com>
Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
---
Changes v1 -> v2:

* Fixed resume-probe race condition issue
* Removed NULL check in runtime_resume
* Updated Fixes tag with appropriate commit
* Added Signed-off-by for Co-developed-by tag

 drivers/i2c/busses/i2c-designware-amdisp.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-amdisp.c b/drivers/i2c/busses/i2c-designware-amdisp.c
index c48728ad9f6f2..9f0ec0fae6f23 100644
--- a/drivers/i2c/busses/i2c-designware-amdisp.c
+++ b/drivers/i2c/busses/i2c-designware-amdisp.c
@@ -7,6 +7,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/soc/amd/isp4_misc.h>
 
@@ -76,22 +77,20 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
 
 	device_enable_async_suspend(&pdev->dev);
 
-	pm_runtime_enable(&pdev->dev);
-	pm_runtime_get_sync(&pdev->dev);
-
+	dev_pm_genpd_resume(&pdev->dev);
 	ret = i2c_dw_probe(isp_i2c_dev);
 	if (ret) {
 		dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n");
 		goto error_release_rpm;
 	}
-
-	pm_runtime_put_sync(&pdev->dev);
+	dev_pm_genpd_suspend(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
 
 	return 0;
 
 error_release_rpm:
 	amd_isp_dw_i2c_plat_pm_cleanup(isp_i2c_dev);
-	pm_runtime_put_sync(&pdev->dev);
 	return ret;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
  2026-03-20 20:12 [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue Pratap Nirujogi
@ 2026-03-20 20:25 ` Andy Shevchenko
  2026-03-20 20:32 ` Mario Limonciello (AMD) (kernel.org)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-03-20 20:25 UTC (permalink / raw)
  To: Pratap Nirujogi
  Cc: andi.shyti, mlimonci, mika.westerberg, jsd, rafael.j.wysocki,
	benjamin.chan, bin.du, king.li, linux-i2c, linux-kernel

On Fri, Mar 20, 2026 at 04:12:22PM -0400, Pratap Nirujogi wrote:
> Identified resume-probe race condition in kernel v7.0 with the commit
> 38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
> issue existed from the beginning though not detected.
> 
> The amdisp i2c device requires ISP to be in power-on state for probe
> to succeed. To meet this requirement, this device is added to genpd
> to control ISP power using runtime PM. The pm_runtime_get_sync() called
> before i2c_dw_probe() triggers PM resume, which powers on ISP and also
> invokes the amdisp i2c runtime resume before the probe completes resulting
> in this race condition and a NULL dereferencing issue in v7.0
> 
> Fix this race condition by using the genpd APIs directly during probe:
>   - Call dev_pm_genpd_resume() to Power ON ISP before probe
>   - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
>   - Set the device to suspended state with pm_runtime_set_suspended()
>   - Enable runtime PM only after the device is fully initialized

LGTM, assuming that genpd calls are okay,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
  2026-03-20 20:12 [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue Pratap Nirujogi
  2026-03-20 20:25 ` Andy Shevchenko
@ 2026-03-20 20:32 ` Mario Limonciello (AMD) (kernel.org)
  2026-03-23  5:54 ` Mika Westerberg
  2026-03-25 20:17 ` Andi Shyti
  3 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello (AMD) (kernel.org) @ 2026-03-20 20:32 UTC (permalink / raw)
  To: Pratap Nirujogi, andi.shyti, andriy.shevchenko, mlimonci,
	mika.westerberg, jsd
  Cc: rafael.j.wysocki, benjamin.chan, bin.du, king.li, linux-i2c,
	linux-kernel



On 3/20/2026 3:12 PM, Pratap Nirujogi wrote:
> Identified resume-probe race condition in kernel v7.0 with the commit
> 38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
> issue existed from the beginning though not detected.
> 
> The amdisp i2c device requires ISP to be in power-on state for probe
> to succeed. To meet this requirement, this device is added to genpd
> to control ISP power using runtime PM. The pm_runtime_get_sync() called
> before i2c_dw_probe() triggers PM resume, which powers on ISP and also
> invokes the amdisp i2c runtime resume before the probe completes resulting
> in this race condition and a NULL dereferencing issue in v7.0
> 
> Fix this race condition by using the genpd APIs directly during probe:
>    - Call dev_pm_genpd_resume() to Power ON ISP before probe
>    - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
>    - Set the device to suspended state with pm_runtime_set_suspended()
>    - Enable runtime PM only after the device is fully initialized
> 
> Fixes: d6263c468a761 ("i2c: amd-isp: Add ISP i2c-designware driver")
> Co-developed-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> Changes v1 -> v2:
> 
> * Fixed resume-probe race condition issue
> * Removed NULL check in runtime_resume
> * Updated Fixes tag with appropriate commit
> * Added Signed-off-by for Co-developed-by tag
> 
>   drivers/i2c/busses/i2c-designware-amdisp.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-amdisp.c b/drivers/i2c/busses/i2c-designware-amdisp.c
> index c48728ad9f6f2..9f0ec0fae6f23 100644
> --- a/drivers/i2c/busses/i2c-designware-amdisp.c
> +++ b/drivers/i2c/busses/i2c-designware-amdisp.c
> @@ -7,6 +7,7 @@
>   
>   #include <linux/module.h>
>   #include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
>   #include <linux/pm_runtime.h>
>   #include <linux/soc/amd/isp4_misc.h>
>   
> @@ -76,22 +77,20 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
>   
>   	device_enable_async_suspend(&pdev->dev);
>   
> -	pm_runtime_enable(&pdev->dev);
> -	pm_runtime_get_sync(&pdev->dev);
> -
> +	dev_pm_genpd_resume(&pdev->dev);
>   	ret = i2c_dw_probe(isp_i2c_dev);
>   	if (ret) {
>   		dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n");
>   		goto error_release_rpm;
>   	}
> -
> -	pm_runtime_put_sync(&pdev->dev);
> +	dev_pm_genpd_suspend(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
>   
>   	return 0;
>   
>   error_release_rpm:
>   	amd_isp_dw_i2c_plat_pm_cleanup(isp_i2c_dev);
> -	pm_runtime_put_sync(&pdev->dev);
>   	return ret;
>   }
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
  2026-03-20 20:12 [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue Pratap Nirujogi
  2026-03-20 20:25 ` Andy Shevchenko
  2026-03-20 20:32 ` Mario Limonciello (AMD) (kernel.org)
@ 2026-03-23  5:54 ` Mika Westerberg
  2026-03-25 20:17 ` Andi Shyti
  3 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2026-03-23  5:54 UTC (permalink / raw)
  To: Pratap Nirujogi
  Cc: andi.shyti, andriy.shevchenko, mlimonci, jsd, rafael.j.wysocki,
	benjamin.chan, bin.du, king.li, linux-i2c, linux-kernel

On Fri, Mar 20, 2026 at 04:12:22PM -0400, Pratap Nirujogi wrote:
> Identified resume-probe race condition in kernel v7.0 with the commit
> 38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
> issue existed from the beginning though not detected.
> 
> The amdisp i2c device requires ISP to be in power-on state for probe
> to succeed. To meet this requirement, this device is added to genpd
> to control ISP power using runtime PM. The pm_runtime_get_sync() called
> before i2c_dw_probe() triggers PM resume, which powers on ISP and also
> invokes the amdisp i2c runtime resume before the probe completes resulting
> in this race condition and a NULL dereferencing issue in v7.0
> 
> Fix this race condition by using the genpd APIs directly during probe:
>   - Call dev_pm_genpd_resume() to Power ON ISP before probe
>   - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
>   - Set the device to suspended state with pm_runtime_set_suspended()
>   - Enable runtime PM only after the device is fully initialized
> 
> Fixes: d6263c468a761 ("i2c: amd-isp: Add ISP i2c-designware driver")
> Co-developed-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
  2026-03-20 20:12 [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue Pratap Nirujogi
                   ` (2 preceding siblings ...)
  2026-03-23  5:54 ` Mika Westerberg
@ 2026-03-25 20:17 ` Andi Shyti
  2026-03-25 20:36   ` Nirujogi, Pratap
  3 siblings, 1 reply; 6+ messages in thread
From: Andi Shyti @ 2026-03-25 20:17 UTC (permalink / raw)
  To: Pratap Nirujogi
  Cc: andriy.shevchenko, mlimonci, mika.westerberg, jsd,
	rafael.j.wysocki, benjamin.chan, bin.du, king.li, linux-i2c,
	linux-kernel

Hi Pratap,

On Fri, Mar 20, 2026 at 04:12:22PM -0400, Pratap Nirujogi wrote:
> Identified resume-probe race condition in kernel v7.0 with the commit
> 38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
> issue existed from the beginning though not detected.
> 
> The amdisp i2c device requires ISP to be in power-on state for probe
> to succeed. To meet this requirement, this device is added to genpd
> to control ISP power using runtime PM. The pm_runtime_get_sync() called
> before i2c_dw_probe() triggers PM resume, which powers on ISP and also
> invokes the amdisp i2c runtime resume before the probe completes resulting
> in this race condition and a NULL dereferencing issue in v7.0
> 
> Fix this race condition by using the genpd APIs directly during probe:
>   - Call dev_pm_genpd_resume() to Power ON ISP before probe
>   - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
>   - Set the device to suspended state with pm_runtime_set_suspended()
>   - Enable runtime PM only after the device is fully initialized
> 
> Fixes: d6263c468a761 ("i2c: amd-isp: Add ISP i2c-designware driver")
> Co-developed-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Bin Du <bin.du@amd.com>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>

merged to i2c/i2c-host-fixes.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue
  2026-03-25 20:17 ` Andi Shyti
@ 2026-03-25 20:36   ` Nirujogi, Pratap
  0 siblings, 0 replies; 6+ messages in thread
From: Nirujogi, Pratap @ 2026-03-25 20:36 UTC (permalink / raw)
  To: Andi Shyti, Pratap Nirujogi
  Cc: andriy.shevchenko, mlimonci, mika.westerberg, jsd,
	rafael.j.wysocki, benjamin.chan, bin.du, king.li, linux-i2c,
	linux-kernel



On 3/25/2026 4:17 PM, Andi Shyti wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> Hi Pratap,
> 
> On Fri, Mar 20, 2026 at 04:12:22PM -0400, Pratap Nirujogi wrote:
>> Identified resume-probe race condition in kernel v7.0 with the commit
>> 38fa29b01a6a ("i2c: designware: Combine the init functions"),but this
>> issue existed from the beginning though not detected.
>>
>> The amdisp i2c device requires ISP to be in power-on state for probe
>> to succeed. To meet this requirement, this device is added to genpd
>> to control ISP power using runtime PM. The pm_runtime_get_sync() called
>> before i2c_dw_probe() triggers PM resume, which powers on ISP and also
>> invokes the amdisp i2c runtime resume before the probe completes resulting
>> in this race condition and a NULL dereferencing issue in v7.0
>>
>> Fix this race condition by using the genpd APIs directly during probe:
>>    - Call dev_pm_genpd_resume() to Power ON ISP before probe
>>    - Call dev_pm_genpd_suspend() to Power OFF ISP after probe
>>    - Set the device to suspended state with pm_runtime_set_suspended()
>>    - Enable runtime PM only after the device is fully initialized
>>
>> Fixes: d6263c468a761 ("i2c: amd-isp: Add ISP i2c-designware driver")
>> Co-developed-by: Bin Du <bin.du@amd.com>
>> Signed-off-by: Bin Du <bin.du@amd.com>
>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> 
> merged to i2c/i2c-host-fixes.
> 
Thanks Andi.

> Thanks,
> Andi


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-25 20:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 20:12 [PATCH v2] i2c: designware: amdisp: Fix resume-probe race condition issue Pratap Nirujogi
2026-03-20 20:25 ` Andy Shevchenko
2026-03-20 20:32 ` Mario Limonciello (AMD) (kernel.org)
2026-03-23  5:54 ` Mika Westerberg
2026-03-25 20:17 ` Andi Shyti
2026-03-25 20:36   ` Nirujogi, Pratap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox