Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: ti-abb: don't use devm_platform_ioremap_resource_byname for shared interrupt register

We can't use devm_platform_ioremap_resource_byname() to remap the
interrupt register that can be shared between
regulator-abb-{ivahd,dspeve,gpu} drivers instances.

The combined helper introduce a call to devm_request_mem_region() that
creates a new busy resource region on PRM_IRQSTATUS_MPU register
(0x4ae06010). The first devm_request_mem_region() call succeeds for
regulator-abb-ivahd but fails for the two other regulator-abb-dspeve
and regulator-abb-gpu.

# cat /proc/iomem | grep -i 4ae06
4ae06010-4ae06013 : 4ae07e34.regulator-abb-ivahd int-address
4ae06014-4ae06017 : 4ae07ddc.regulator-abb-mpu int-address

regulator-abb-dspeve and regulator-abb-gpu are missing due to
devm_request_mem_region() failure (EBUSY):

[ 1.326660] ti_abb 4ae07e30.regulator-abb-dspeve: can't request region for resource [mem 0x4ae06010-0x4ae06013]
[ 1.326660] ti_abb: probe of 4ae07e30.regulator-abb-dspeve failed with error -16
[ 1.327239] ti_abb 4ae07de4.regulator-abb-gpu: can't request region for resource [mem 0x4ae06010-0x4ae06013]
[ 1.327270] ti_abb: probe of 4ae07de4.regulator-abb-gpu failed with error -16

>From arm/boot/dts/dra7.dtsi:

The abb_mpu is the only instance using its own interrupt register:
(0x4ae06014) PRM_IRQSTATUS_MPU_2, ABB_MPU_DONE_ST (bit 7)

The other tree instances (abb_ivahd, abb_dspeve, abb_gpu) share
PRM_IRQSTATUS_MPU register (0x4ae06010) but use different bits
ABB_IVA_DONE_ST (bit 30), ABB_DSPEVE_DONE_ST( bit 29) and
ABB_GPU_DONE_ST (but 28).

The commit b36c6b1887ff ("regulator: ti-abb: Make use of the helper
function devm_ioremap related") overlooked the following comment
implicitly explaining why devm_ioremap() is used in this case:

/*
* We may have shared interrupt register offsets which are
* write-1-to-clear between domains ensuring exclusivity.
*/

Fixes and partially reverts commit b36c6b1887ff ("regulator: ti-abb:
Make use of the helper function devm_ioremap related").

Improve the existing comment to avoid further conversion to
devm_platform_ioremap_resource_byname().

Fixes: b36c6b1887ff ("regulator: ti-abb: Make use of the helper function devm_ioremap related")
Signed-off-by: Romain Naour <romain.naour@skf.com>
Reviewed-by: Yoann Congal <yoann.congal@smile.fr>
Link: https://msgid.link/r/20240123111456.739381-1-romain.naour@smile.fr
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Romain Naour and committed by
Mark Brown
a67e1f0b b3cbdcc1

+19 -3
+19 -3
drivers/regulator/ti-abb-regulator.c
··· 726 726 return PTR_ERR(abb->setup_reg); 727 727 } 728 728 729 - abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address"); 730 - if (IS_ERR(abb->int_base)) 731 - return PTR_ERR(abb->int_base); 729 + pname = "int-address"; 730 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); 731 + if (!res) { 732 + dev_err(dev, "Missing '%s' IO resource\n", pname); 733 + return -ENODEV; 734 + } 735 + /* 736 + * The MPU interrupt status register (PRM_IRQSTATUS_MPU) is 737 + * shared between regulator-abb-{ivahd,dspeve,gpu} driver 738 + * instances. Therefore use devm_ioremap() rather than 739 + * devm_platform_ioremap_resource_byname() to avoid busy 740 + * resource region conflicts. 741 + */ 742 + abb->int_base = devm_ioremap(dev, res->start, 743 + resource_size(res)); 744 + if (!abb->int_base) { 745 + dev_err(dev, "Unable to map '%s'\n", pname); 746 + return -ENOMEM; 747 + } 732 748 733 749 /* Map Optional resources */ 734 750 pname = "efuse-address";