* [PATCH v2] i2c: cadence: Fix regression with bus recovery
@ 2022-11-28 10:51 carsten.haitzler
2022-11-28 10:54 ` Datta, Shubhrajyoti
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: carsten.haitzler @ 2022-11-28 10:51 UTC (permalink / raw)
To: michal.simek, shubhrajyoti.datta, linux-arm-kernel, linux-i2c,
linux-kernel
From: Carsten Haitzler <carsten.haitzler@arm.com>
Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c
devices that have no pinctrl defined. There is no requirement for this
to exist in the DT. This has worked perfectly well without this before in
at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to
talk to a tda99xx phy). Adding the requirement to have pinctrl set up in
the device tree (or otherwise be found) is a regression where the whole
i2c device is lost entirely (in this case dropping entire devices which
then leads to the drm display stack unable to find the phy for display
output, thus having no drm display device and so on down the chain).
This converts the above commit to an enhancement if pinctrl can be found
for the i2c device, providing a timeout on read with recovery, but if not,
do what used to be done rather than a fatal loss of a device.
This restores the mentioned display devices to their working state again.
Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support")
Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
---
Note: This issue was discovered during the porting of the linux kernel
on Morello [1].
[1] https://git.morello-project.org/morello/kernel/linux
---
drivers/i2c/busses/i2c-cadence.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index fe0cd205502d..09acd2d399d5 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US);
if (ret) {
ret = -EAGAIN;
- i2c_recover_bus(adap);
+ if (id->adap.bus_recovery_info)
+ i2c_recover_bus(adap);
goto out;
}
@@ -1263,9 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev)
id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(id->rinfo.pinctrl)) {
+ int err = PTR_ERR(id->rinfo.pinctrl);
+
dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
- return PTR_ERR(id->rinfo.pinctrl);
- }
+ if (err != -ENODEV)
+ return err;
+ } else
+ id->adap.bus_recovery_info = &id->rinfo;
id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
if (IS_ERR(id->membase))
@@ -1283,7 +1288,6 @@ static int cdns_i2c_probe(struct platform_device *pdev)
id->adap.retries = 3; /* Default retry value. */
id->adap.algo_data = id;
id->adap.dev.parent = &pdev->dev;
- id->adap.bus_recovery_info = &id->rinfo;
init_completion(&id->xfer_done);
snprintf(id->adap.name, sizeof(id->adap.name),
"Cadence I2C at %08lx", (unsigned long)r_mem->start);
--
2.32.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v2] i2c: cadence: Fix regression with bus recovery
2022-11-28 10:51 [PATCH v2] i2c: cadence: Fix regression with bus recovery carsten.haitzler
@ 2022-11-28 10:54 ` Datta, Shubhrajyoti
2022-11-28 10:59 ` Michal Simek
2022-12-01 22:42 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Datta, Shubhrajyoti @ 2022-11-28 10:54 UTC (permalink / raw)
To: carsten.haitzler@foss.arm.com, michal.simek@xilinx.com,
shubhrajyoti.datta@xilinx.com,
linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]
[AMD Official Use Only - General]
> -----Original Message-----
> From: carsten.haitzler@foss.arm.com <carsten.haitzler@foss.arm.com>
> Sent: Monday, November 28, 2022 4:22 PM
> To: michal.simek@xilinx.com; shubhrajyoti.datta@xilinx.com; linux-arm-
> kernel@lists.infradead.org; linux-i2c@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH v2] i2c: cadence: Fix regression with bus recovery
>
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
>
>
> From: Carsten Haitzler <carsten.haitzler@arm.com>
>
> Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c
> devices that have no pinctrl defined. There is no requirement for this to exist
> in the DT. This has worked perfectly well without this before in at least 1 real
> usage case on hardware (Mali Komeda DPU, Cadence i2c to talk to a tda99xx
> phy). Adding the requirement to have pinctrl set up in the device tree (or
> otherwise be found) is a regression where the whole i2c device is lost
> entirely (in this case dropping entire devices which then leads to the drm
> display stack unable to find the phy for display output, thus having no drm
> display device and so on down the chain).
>
> This converts the above commit to an enhancement if pinctrl can be found
> for the i2c device, providing a timeout on read with recovery, but if not, do
> what used to be done rather than a fatal loss of a device.
>
> This restores the mentioned display devices to their working state again.
>
> Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support")
> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 16542 bytes --]
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] i2c: cadence: Fix regression with bus recovery
2022-11-28 10:51 [PATCH v2] i2c: cadence: Fix regression with bus recovery carsten.haitzler
2022-11-28 10:54 ` Datta, Shubhrajyoti
@ 2022-11-28 10:59 ` Michal Simek
2022-12-01 22:42 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2022-11-28 10:59 UTC (permalink / raw)
To: carsten.haitzler, michal.simek, shubhrajyoti.datta,
linux-arm-kernel, linux-i2c, linux-kernel, 'Wolfram Sang'
+Wolfram,
On 11/28/22 11:51, carsten.haitzler@foss.arm.com wrote:
> CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
>
>
> From: Carsten Haitzler <carsten.haitzler@arm.com>
>
> Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c
> devices that have no pinctrl defined. There is no requirement for this
> to exist in the DT. This has worked perfectly well without this before in
> at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to
> talk to a tda99xx phy). Adding the requirement to have pinctrl set up in
> the device tree (or otherwise be found) is a regression where the whole
> i2c device is lost entirely (in this case dropping entire devices which
> then leads to the drm display stack unable to find the phy for display
> output, thus having no drm display device and so on down the chain).
>
> This converts the above commit to an enhancement if pinctrl can be found
> for the i2c device, providing a timeout on read with recovery, but if not,
> do what used to be done rather than a fatal loss of a device.
>
> This restores the mentioned display devices to their working state again.
>
> Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support")
> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
> ---
> Note: This issue was discovered during the porting of the linux kernel
> on Morello [1].
>
> [1] https://git.morello-project.org/morello/kernel/linux
> ---
> drivers/i2c/busses/i2c-cadence.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index fe0cd205502d..09acd2d399d5 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
> CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US);
> if (ret) {
> ret = -EAGAIN;
> - i2c_recover_bus(adap);
> + if (id->adap.bus_recovery_info)
> + i2c_recover_bus(adap);
> goto out;
> }
>
> @@ -1263,9 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev)
>
> id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev);
> if (IS_ERR(id->rinfo.pinctrl)) {
> + int err = PTR_ERR(id->rinfo.pinctrl);
> +
> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
> - return PTR_ERR(id->rinfo.pinctrl);
> - }
> + if (err != -ENODEV)
> + return err;
> + } else
> + id->adap.bus_recovery_info = &id->rinfo;
>
> id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
> if (IS_ERR(id->membase))
> @@ -1283,7 +1288,6 @@ static int cdns_i2c_probe(struct platform_device *pdev)
> id->adap.retries = 3; /* Default retry value. */
> id->adap.algo_data = id;
> id->adap.dev.parent = &pdev->dev;
> - id->adap.bus_recovery_info = &id->rinfo;
> init_completion(&id->xfer_done);
> snprintf(id->adap.name, sizeof(id->adap.name),
> "Cadence I2C at %08lx", (unsigned long)r_mem->start);
> --
> 2.32.0
>
Acked-by: Michal Simek <michal.simek@amd.com>
Wolfram: up2you if you want to take it for 6.1. If it is too late I think it
should be labeled as stable material for 6.1.
Thanks,
Michal
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] i2c: cadence: Fix regression with bus recovery
2022-11-28 10:51 [PATCH v2] i2c: cadence: Fix regression with bus recovery carsten.haitzler
2022-11-28 10:54 ` Datta, Shubhrajyoti
2022-11-28 10:59 ` Michal Simek
@ 2022-12-01 22:42 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2022-12-01 22:42 UTC (permalink / raw)
To: carsten.haitzler
Cc: michal.simek, shubhrajyoti.datta, linux-arm-kernel, linux-i2c,
linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 1439 bytes --]
On Mon, Nov 28, 2022 at 10:51:58AM +0000, carsten.haitzler@foss.arm.com wrote:
> From: Carsten Haitzler <carsten.haitzler@arm.com>
>
> Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c
> devices that have no pinctrl defined. There is no requirement for this
> to exist in the DT. This has worked perfectly well without this before in
> at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to
> talk to a tda99xx phy). Adding the requirement to have pinctrl set up in
> the device tree (or otherwise be found) is a regression where the whole
> i2c device is lost entirely (in this case dropping entire devices which
> then leads to the drm display stack unable to find the phy for display
> output, thus having no drm display device and so on down the chain).
>
> This converts the above commit to an enhancement if pinctrl can be found
> for the i2c device, providing a timeout on read with recovery, but if not,
> do what used to be done rather than a fatal loss of a device.
>
> This restores the mentioned display devices to their working state again.
>
> Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support")
> Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
Fixed this checkpatch check:
CHECK: Unbalanced braces around else statement
#55: FILE: drivers/i2c/busses/i2c-cadence.c:1272:
+ } else
and applied to for-current, thanks!
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-01 23:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-28 10:51 [PATCH v2] i2c: cadence: Fix regression with bus recovery carsten.haitzler
2022-11-28 10:54 ` Datta, Shubhrajyoti
2022-11-28 10:59 ` Michal Simek
2022-12-01 22:42 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).