From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Introduce `pin_requested` API to check if a pin is currently requested.
This API allows pinctrl drivers to verify whether a pin is requested or
not by checking if the pin is owned by either `gpio_owner` or `mux_owner`.
GPIO pins used as interrupts through the `interrupts` DT property do not
follow the usual `gpio_request`/`pin_request` path, unlike GPIO pins used
as interrupts via the `gpios` property. As a result, such pins were
reported as `UNCLAIMED` in the `pinmux-pins` sysfs file, even though they
were in use as interrupts.
With the newly introduced API, pinctrl drivers can check if a pin is
already requested by the pinctrl core and ensure that pin is requested
during when using as irq. This helps to ensure that the `pinmux-pins`
sysfs file reflects the correct status of the pin.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/pinctrl/pinmux.c | 14 ++++++++++++++
drivers/pinctrl/pinmux.h | 5 +++++
2 files changed, 19 insertions(+)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 02033ea1c643..6c3d18b162ad 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -99,6 +99,20 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin)
return !(ops->strict && !!desc->gpio_owner);
}
+bool pin_requested(struct pinctrl_dev *pctldev, int pin)
+{
+ struct pin_desc *desc;
+
+ desc = pin_desc_get(pctldev, pin);
+ if (!desc)
+ return false;
+
+ if (!desc->gpio_owner && !desc->mux_owner)
+ return false;
+
+ return true;
+}
+
/**
* pin_request() - request a single pin to be muxed in, typically for GPIO
* @pctldev: the associated pin controller device
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 2965ec20b77f..6d854eebaad4 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -42,6 +42,7 @@ int pinmux_map_to_setting(const struct pinctrl_map *map,
void pinmux_free_setting(const struct pinctrl_setting *setting);
int pinmux_enable_setting(const struct pinctrl_setting *setting);
void pinmux_disable_setting(const struct pinctrl_setting *setting);
+bool pin_requested(struct pinctrl_dev *pctldev, int pin);
#else
@@ -100,6 +101,10 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
{
}
+bool pin_requested(struct pinctrl_dev *pctldev, int pin)
+{
+ return false;
+}
#endif
#if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
--
2.43.0
Hi Prabhakar, kernel test robot noticed the following build warnings: [auto build test WARNING on geert-renesas-drivers/renesas-pinctrl] [also build test WARNING on linusw-pinctrl/devel linusw-pinctrl/for-next geert-renesas-devel/next linus/master v6.12-rc4 next-20241018] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Prabhakar/arm64-dts-renesas-rzg3s-smarc-Drop-hogging-of-GPIO-pins/20241017-194200 base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git renesas-pinctrl patch link: https://lore.kernel.org/r/20241017113942.139712-7-prabhakar.mahadev-lad.rj%40bp.renesas.com patch subject: [PATCH 6/7] pinctrl: pinmux: Introduce API to check if a pin is requested config: hexagon-randconfig-001-20241021 (https://download.01.org/0day-ci/archive/20241021/202410211007.sFKERNFY-lkp@intel.com/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bfe84f7085d82d06d61c632a7bad1e692fd159e4) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241021/202410211007.sFKERNFY-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410211007.sFKERNFY-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/pinctrl/core.c:28: In file included from include/linux/gpio/driver.h:8: In file included from include/linux/irqchip/chained_irq.h:10: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:14: In file included from arch/hexagon/include/asm/io.h:328: include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 548 | val = __raw_readb(PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu' 37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) | ^ In file included from drivers/pinctrl/core.c:28: In file included from include/linux/gpio/driver.h:8: In file included from include/linux/irqchip/chained_irq.h:10: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:14: In file included from arch/hexagon/include/asm/io.h:328: include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); | ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu' 35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) | ^ In file included from drivers/pinctrl/core.c:28: In file included from include/linux/gpio/driver.h:8: In file included from include/linux/irqchip/chained_irq.h:10: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:14: In file included from arch/hexagon/include/asm/io.h:328: include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 585 | __raw_writeb(value, PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] 605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); | ~~~~~~~~~~ ^ In file included from drivers/pinctrl/core.c:38: >> drivers/pinctrl/pinmux.h:104:6: warning: no previous prototype for function 'pin_requested' [-Wmissing-prototypes] 104 | bool pin_requested(struct pinctrl_dev *pctldev, int pin) | ^ drivers/pinctrl/pinmux.h:104:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 104 | bool pin_requested(struct pinctrl_dev *pctldev, int pin) | ^ | static 7 warnings generated. Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for MODVERSIONS Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y] Selected by [y]: - RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y] vim +/pin_requested +104 drivers/pinctrl/pinmux.h 103 > 104 bool pin_requested(struct pinctrl_dev *pctldev, int pin) 105 { 106 return false; 107 } 108 #endif 109 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Thu, Oct 17, 2024 at 1:39 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > @@ -100,6 +101,10 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting) > { > } > > +bool pin_requested(struct pinctrl_dev *pctldev, int pin) > +{ > + return false; > +} > #endif You need "static inline" in front of the stub, that's why the robot is complaining. Yours, Linus Walleij
Hi Linus, On Sat, Oct 19, 2024 at 7:22 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > On Thu, Oct 17, 2024 at 1:39 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > > @@ -100,6 +101,10 @@ static inline void pinmux_disable_setting(const struct pinctrl_setting *setting) > > { > > } > > > > +bool pin_requested(struct pinctrl_dev *pctldev, int pin) > > +{ > > + return false; > > +} > > #endif > > You need "static inline" in front of the stub, that's why the robot is > complaining. > Agreed, If there are no other comments for the rest of the patches I'll just send an updated patch for this or include it as part of the whole series. Cheers, Prabhakar
Hi Prabhakar, kernel test robot noticed the following build warnings: [auto build test WARNING on geert-renesas-drivers/renesas-pinctrl] [also build test WARNING on linusw-pinctrl/devel linusw-pinctrl/for-next geert-renesas-devel/next linus/master v6.12-rc3 next-20241018] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Prabhakar/arm64-dts-renesas-rzg3s-smarc-Drop-hogging-of-GPIO-pins/20241017-194200 base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git renesas-pinctrl patch link: https://lore.kernel.org/r/20241017113942.139712-7-prabhakar.mahadev-lad.rj%40bp.renesas.com patch subject: [PATCH 6/7] pinctrl: pinmux: Introduce API to check if a pin is requested config: arm-pxa3xx_defconfig (https://download.01.org/0day-ci/archive/20241019/202410190448.yDDAKyxt-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241019/202410190448.yDDAKyxt-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410190448.yDDAKyxt-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/pinctrl/core.c:38: >> drivers/pinctrl/pinmux.h:104:6: warning: no previous prototype for 'pin_requested' [-Wmissing-prototypes] 104 | bool pin_requested(struct pinctrl_dev *pctldev, int pin) | ^~~~~~~~~~~~~ vim +/pin_requested +104 drivers/pinctrl/pinmux.h 103 > 104 bool pin_requested(struct pinctrl_dev *pctldev, int pin) 105 { 106 return false; 107 } 108 #endif 109 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Thu, Oct 17, 2024 at 1:39 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce `pin_requested` API to check if a pin is currently requested. > This API allows pinctrl drivers to verify whether a pin is requested or > not by checking if the pin is owned by either `gpio_owner` or `mux_owner`. > > GPIO pins used as interrupts through the `interrupts` DT property do not > follow the usual `gpio_request`/`pin_request` path, unlike GPIO pins used > as interrupts via the `gpios` property. As a result, such pins were > reported as `UNCLAIMED` in the `pinmux-pins` sysfs file, even though they > were in use as interrupts. > > With the newly introduced API, pinctrl drivers can check if a pin is > already requested by the pinctrl core and ensure that pin is requested > during when using as irq. This helps to ensure that the `pinmux-pins` > sysfs file reflects the correct status of the pin. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Provided that Geert applies 7/7: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
© 2016 - 2024 Red Hat, Inc.