diff mbox series

[3/8] soc: renesas: rzn1-sysc: Export function to set dmamux

Message ID 20220218181226.431098-4-miquel.raynal@bootlin.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series RZN1 DMA support | expand

Commit Message

Miquel Raynal Feb. 18, 2022, 6:12 p.m. UTC
The dmamux register is located within the system controller.

Without syscon, we need an extra helper in order to give write access to
this register to a dmamux driver.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/clk/renesas/r9a06g032-clocks.c        | 27 +++++++++++++++++++
 include/dt-bindings/clock/r9a06g032-sysctrl.h |  2 ++
 include/linux/soc/renesas/r9a06g032-syscon.h  | 11 ++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 include/linux/soc/renesas/r9a06g032-syscon.h

Comments

kernel test robot Feb. 20, 2022, 6:16 p.m. UTC | #1
Hi Miquel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on geert-renesas-devel/next]
[also build test WARNING on geert-renesas-drivers/renesas-clk robh/for-next linus/master v5.17-rc4 next-20220217]
[cannot apply to vkoul-dmaengine/next]
[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]

url:    https://github.com/0day-ci/linux/commits/Miquel-Raynal/RZN1-DMA-support/20220220-182519
base:   https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-devel.git next
config: arc-randconfig-r043-20220220 (https://download.01.org/0day-ci/archive/20220221/202202210247.Ul5J6pwr-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ed9b880ea7f2b23b42feeed7a6ed898cd09ae2f1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miquel-Raynal/RZN1-DMA-support/20220220-182519
        git checkout ed9b880ea7f2b23b42feeed7a6ed898cd09ae2f1
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/clk/renesas/ drivers/mtd/spi-nor/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/clk/renesas/r9a06g032-clocks.c:320:5: warning: no previous prototype for 'r9a06g032_syscon_set_dmamux' [-Wmissing-prototypes]
     320 | int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/r9a06g032_syscon_set_dmamux +320 drivers/clk/renesas/r9a06g032-clocks.c

   317	
   318	/* Exported helper to access the DMAMUX register */
   319	static struct r9a06g032_priv *syscon_priv;
 > 320	int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
   321	{
   322		u32 dmamux;
   323	
   324		if (!syscon_priv)
   325			return -EPROBE_DEFER;
   326	
   327		spin_lock(&syscon_priv->lock);
   328	
   329		dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
   330		dmamux &= ~mask;
   331		dmamux |= val & mask;
   332		writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
   333	
   334		spin_unlock(&syscon_priv->lock);
   335	
   336		return 0;
   337	}
   338	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Feb. 20, 2022, 7:28 p.m. UTC | #2
Hi Miquel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on geert-renesas-devel/next]
[also build test WARNING on geert-renesas-drivers/renesas-clk robh/for-next linus/master v5.17-rc4 next-20220217]
[cannot apply to vkoul-dmaengine/next]
[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]

url:    https://github.com/0day-ci/linux/commits/Miquel-Raynal/RZN1-DMA-support/20220220-182519
base:   https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-devel.git next
config: arm-randconfig-r022-20220220 (https://download.01.org/0day-ci/archive/20220221/202202210355.JzDJ9Lyz-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/ed9b880ea7f2b23b42feeed7a6ed898cd09ae2f1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miquel-Raynal/RZN1-DMA-support/20220220-182519
        git checkout ed9b880ea7f2b23b42feeed7a6ed898cd09ae2f1
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/clk/renesas/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/clk/renesas/r9a06g032-clocks.c:320:5: warning: no previous prototype for function 'r9a06g032_syscon_set_dmamux' [-Wmissing-prototypes]
   int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
       ^
   drivers/clk/renesas/r9a06g032-clocks.c:320:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
   ^
   static 
   1 warning generated.


vim +/r9a06g032_syscon_set_dmamux +320 drivers/clk/renesas/r9a06g032-clocks.c

   317	
   318	/* Exported helper to access the DMAMUX register */
   319	static struct r9a06g032_priv *syscon_priv;
 > 320	int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
   321	{
   322		u32 dmamux;
   323	
   324		if (!syscon_priv)
   325			return -EPROBE_DEFER;
   326	
   327		spin_lock(&syscon_priv->lock);
   328	
   329		dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
   330		dmamux &= ~mask;
   331		dmamux |= val & mask;
   332		writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
   333	
   334		spin_unlock(&syscon_priv->lock);
   335	
   336		return 0;
   337	}
   338	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Geert Uytterhoeven Feb. 21, 2022, 9:16 a.m. UTC | #3
Hi Miquel,

On Fri, Feb 18, 2022 at 7:12 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> The dmamux register is located within the system controller.
>
> Without syscon, we need an extra helper in order to give write access to
> this register to a dmamux driver.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks for your patch!

> --- a/drivers/clk/renesas/r9a06g032-clocks.c
> +++ b/drivers/clk/renesas/r9a06g032-clocks.c

Missing #include <linux/soc/renesas/r9a06g032-syscon.h>

> @@ -315,6 +315,27 @@ struct r9a06g032_priv {
>         void __iomem *reg;
>  };
>
> +/* Exported helper to access the DMAMUX register */
> +static struct r9a06g032_priv *syscon_priv;

I'd call this sysctrl_priv, as that matches the bindings and
binding header file name.

> +int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
> +{
> +       u32 dmamux;
> +
> +       if (!syscon_priv)
> +               return -EPROBE_DEFER;
> +
> +       spin_lock(&syscon_priv->lock);

This needs propection against interrupts => spin_lock_irqsave().

> +
> +       dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
> +       dmamux &= ~mask;
> +       dmamux |= val & mask;
> +       writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
> +
> +       spin_unlock(&syscon_priv->lock);
> +
> +       return 0;
> +}
> +
>  /* register/bit pairs are encoded as an uint16_t */
>  static void
>  clk_rdesc_set(struct r9a06g032_priv *clocks,

> --- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
> +++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> @@ -145,4 +145,6 @@
>  #define R9A06G032_CLK_UART6            152
>  #define R9A06G032_CLK_UART7            153
>
> +#define R9A06G032_SYSCON_DMAMUX                0xA0

I don't think this needs to be part of the bindings, so please move
it to the driver source file.

> --- /dev/null
> +++ b/include/linux/soc/renesas/r9a06g032-syscon.h

r9a06g032-sysctrl.h etc.

> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
> +#define __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
> +
> +#ifdef CONFIG_CLK_R9A06G032
> +int r9a06g032_syscon_set_dmamux(u32 mask, u32 val);
> +#else
> +static inline int r9a06g032_syscon_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
> +#endif
> +
> +#endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__ */
> --
> 2.27.0

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Miquel Raynal Feb. 21, 2022, 3:01 p.m. UTC | #4
Hi Geert,

geert@linux-m68k.org wrote on Mon, 21 Feb 2022 10:16:24 +0100:

> Hi Miquel,
> 
> On Fri, Feb 18, 2022 at 7:12 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> > The dmamux register is located within the system controller.
> >
> > Without syscon, we need an extra helper in order to give write access to
> > this register to a dmamux driver.
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>  
> 
> Thanks for your patch!
> 
> > --- a/drivers/clk/renesas/r9a06g032-clocks.c
> > +++ b/drivers/clk/renesas/r9a06g032-clocks.c  
> 
> Missing #include <linux/soc/renesas/r9a06g032-syscon.h>
> 
> > @@ -315,6 +315,27 @@ struct r9a06g032_priv {
> >         void __iomem *reg;
> >  };
> >
> > +/* Exported helper to access the DMAMUX register */
> > +static struct r9a06g032_priv *syscon_priv;  
> 
> I'd call this sysctrl_priv, as that matches the bindings and
> binding header file name.

Ok.

> 
> > +int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
> > +{
> > +       u32 dmamux;
> > +
> > +       if (!syscon_priv)
> > +               return -EPROBE_DEFER;
> > +
> > +       spin_lock(&syscon_priv->lock);  
> 
> This needs propection against interrupts => spin_lock_irqsave().

Yes.

> 
> > +
> > +       dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
> > +       dmamux &= ~mask;
> > +       dmamux |= val & mask;
> > +       writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
> > +
> > +       spin_unlock(&syscon_priv->lock);
> > +
> > +       return 0;
> > +}
> > +
> >  /* register/bit pairs are encoded as an uint16_t */
> >  static void
> >  clk_rdesc_set(struct r9a06g032_priv *clocks,  
> 
> > --- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
> > +++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> > @@ -145,4 +145,6 @@
> >  #define R9A06G032_CLK_UART6            152
> >  #define R9A06G032_CLK_UART7            153
> >
> > +#define R9A06G032_SYSCON_DMAMUX                0xA0  
> 
> I don't think this needs to be part of the bindings, so please move
> it to the driver source file.

I've moved it to the top of the file. There definitions are a bit mixed
with the code, I don't like this, so I kept it at the top.

> 
> > --- /dev/null
> > +++ b/include/linux/soc/renesas/r9a06g032-syscon.h  
> 
> r9a06g032-sysctrl.h etc.

Done.

> 
> > @@ -0,0 +1,11 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
> > +#define __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
> > +
> > +#ifdef CONFIG_CLK_R9A06G032
> > +int r9a06g032_syscon_set_dmamux(u32 mask, u32 val);
> > +#else
> > +static inline int r9a06g032_syscon_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
> > +#endif
> > +
> > +#endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__ */
> > --
> > 2.27.0  
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds


Thanks,
Miquèl
Rob Herring (Arm) Feb. 25, 2022, 6:32 p.m. UTC | #5
On Fri, Feb 18, 2022 at 07:12:21PM +0100, Miquel Raynal wrote:
> The dmamux register is located within the system controller.
> 
> Without syscon, we need an extra helper in order to give write access to
> this register to a dmamux driver.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/clk/renesas/r9a06g032-clocks.c        | 27 +++++++++++++++++++
>  include/dt-bindings/clock/r9a06g032-sysctrl.h |  2 ++
>  include/linux/soc/renesas/r9a06g032-syscon.h  | 11 ++++++++
>  3 files changed, 40 insertions(+)
>  create mode 100644 include/linux/soc/renesas/r9a06g032-syscon.h

> diff --git a/include/dt-bindings/clock/r9a06g032-sysctrl.h b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> index 90c0f3dc1ba1..609e7fe8fcb1 100644
> --- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
> +++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> @@ -145,4 +145,6 @@
>  #define R9A06G032_CLK_UART6		152
>  #define R9A06G032_CLK_UART7		153
>  
> +#define R9A06G032_SYSCON_DMAMUX		0xA0

That looks like a register offset? We generally don't put register 
offsets in DT.

> +
>  #endif /* __DT_BINDINGS_R9A06G032_SYSCTRL_H__ */
Miquel Raynal Feb. 27, 2022, 2:09 p.m. UTC | #6
Hi Rob,

robh@kernel.org wrote on Fri, 25 Feb 2022 12:32:51 -0600:

> On Fri, Feb 18, 2022 at 07:12:21PM +0100, Miquel Raynal wrote:
> > The dmamux register is located within the system controller.
> > 
> > Without syscon, we need an extra helper in order to give write access to
> > this register to a dmamux driver.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  drivers/clk/renesas/r9a06g032-clocks.c        | 27 +++++++++++++++++++
> >  include/dt-bindings/clock/r9a06g032-sysctrl.h |  2 ++
> >  include/linux/soc/renesas/r9a06g032-syscon.h  | 11 ++++++++
> >  3 files changed, 40 insertions(+)
> >  create mode 100644 include/linux/soc/renesas/r9a06g032-syscon.h  
> 
> > diff --git a/include/dt-bindings/clock/r9a06g032-sysctrl.h b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> > index 90c0f3dc1ba1..609e7fe8fcb1 100644
> > --- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
> > +++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
> > @@ -145,4 +145,6 @@
> >  #define R9A06G032_CLK_UART6		152
> >  #define R9A06G032_CLK_UART7		153
> >  
> > +#define R9A06G032_SYSCON_DMAMUX		0xA0  
> 
> That looks like a register offset? We generally don't put register 
> offsets in DT.

This is a leftover, the offset is defined somewhere else now, I will
fix this.

> 
> > +
> >  #endif /* __DT_BINDINGS_R9A06G032_SYSCTRL_H__ */  


Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c
index c99942f0e4d4..3bca60fac21c 100644
--- a/drivers/clk/renesas/r9a06g032-clocks.c
+++ b/drivers/clk/renesas/r9a06g032-clocks.c
@@ -315,6 +315,27 @@  struct r9a06g032_priv {
 	void __iomem *reg;
 };
 
+/* Exported helper to access the DMAMUX register */
+static struct r9a06g032_priv *syscon_priv;
+int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
+{
+	u32 dmamux;
+
+	if (!syscon_priv)
+		return -EPROBE_DEFER;
+
+	spin_lock(&syscon_priv->lock);
+
+	dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
+	dmamux &= ~mask;
+	dmamux |= val & mask;
+	writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
+
+	spin_unlock(&syscon_priv->lock);
+
+	return 0;
+}
+
 /* register/bit pairs are encoded as an uint16_t */
 static void
 clk_rdesc_set(struct r9a06g032_priv *clocks,
@@ -922,6 +943,12 @@  static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
 	clocks->reg = of_iomap(np, 0);
 	if (WARN_ON(!clocks->reg))
 		return -ENOMEM;
+
+	if (syscon_priv)
+		return -EBUSY;
+
+	syscon_priv = clocks;
+
 	for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) {
 		const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i];
 		const char *parent_name = d->source ?
diff --git a/include/dt-bindings/clock/r9a06g032-sysctrl.h b/include/dt-bindings/clock/r9a06g032-sysctrl.h
index 90c0f3dc1ba1..609e7fe8fcb1 100644
--- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
+++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
@@ -145,4 +145,6 @@ 
 #define R9A06G032_CLK_UART6		152
 #define R9A06G032_CLK_UART7		153
 
+#define R9A06G032_SYSCON_DMAMUX		0xA0
+
 #endif /* __DT_BINDINGS_R9A06G032_SYSCTRL_H__ */
diff --git a/include/linux/soc/renesas/r9a06g032-syscon.h b/include/linux/soc/renesas/r9a06g032-syscon.h
new file mode 100644
index 000000000000..d97e0e91cc6a
--- /dev/null
+++ b/include/linux/soc/renesas/r9a06g032-syscon.h
@@ -0,0 +1,11 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
+#define __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
+
+#ifdef CONFIG_CLK_R9A06G032
+int r9a06g032_syscon_set_dmamux(u32 mask, u32 val);
+#else
+static inline int r9a06g032_syscon_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
+#endif
+
+#endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__ */