Skip to content

Commit e2f1ada

Browse files
Pratap NirujogiAndi Shyti
authored andcommitted
i2c: designware: amdisp: Fix resume-probe race condition issue
Identified resume-probe race condition in kernel v7.0 with the commit 38fa29b ("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: d6263c4 ("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> Cc: <stable@vger.kernel.org> # v6.16+ Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260320201302.3490570-1-pratap.nirujogi@amd.com
1 parent 13101db commit e2f1ada

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

drivers/i2c/busses/i2c-designware-amdisp.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/module.h>
99
#include <linux/platform_device.h>
10+
#include <linux/pm_domain.h>
1011
#include <linux/pm_runtime.h>
1112
#include <linux/soc/amd/isp4_misc.h>
1213

@@ -76,22 +77,20 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
7677

7778
device_enable_async_suspend(&pdev->dev);
7879

79-
pm_runtime_enable(&pdev->dev);
80-
pm_runtime_get_sync(&pdev->dev);
81-
80+
dev_pm_genpd_resume(&pdev->dev);
8281
ret = i2c_dw_probe(isp_i2c_dev);
8382
if (ret) {
8483
dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n");
8584
goto error_release_rpm;
8685
}
87-
88-
pm_runtime_put_sync(&pdev->dev);
86+
dev_pm_genpd_suspend(&pdev->dev);
87+
pm_runtime_set_suspended(&pdev->dev);
88+
pm_runtime_enable(&pdev->dev);
8989

9090
return 0;
9191

9292
error_release_rpm:
9393
amd_isp_dw_i2c_plat_pm_cleanup(isp_i2c_dev);
94-
pm_runtime_put_sync(&pdev->dev);
9594
return ret;
9695
}
9796

0 commit comments

Comments
 (0)