All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <maz@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Biju Das <biju.das.jz@bp.renesas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH RFC 2/5] pinctrl: renesas: rzg2l: Fix configuring the GPIO pins as interrupts
Date: Thu, 17 Nov 2022 12:14:26 +0000	[thread overview]
Message-ID: <CA+V-a8ugHB2NqH4qa01LQm6yXaeSk2WweUX3ZP+fT3F_bU99Pg@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdW9K=gd7F-G-7v0J5Mz8jyZa_Vu3UZWsNZin76tff7f3g@mail.gmail.com>

Hi Geert,

Thank you for the review.

On Thu, Nov 17, 2022 at 11:09 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>
> Hi Prabhakar,
>
> On Mon, Nov 7, 2022 at 6:53 PM Prabhakar <prabhakar.csengg@gmail.com> wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > On the RZ/G2UL SoC we have less number of pins compared to RZ/G2L and also
> > the pin configs are completely different. This patch makes sure we use the
> > appropriate pin configs for each SoC (which is passed as part of the OF
> > data) while configuring the GPIO pin as interrupts instead of using
> > rzg2l_gpio_configs[] for all the SoCs.
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> But I do think there is room for improvement...
>
> > --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
> > +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
> > @@ -127,6 +127,7 @@ struct rzg2l_dedicated_configs {
> >  struct rzg2l_pinctrl_data {
> >         const char * const *port_pins;
> >         const u32 *port_pin_configs;
> > +       unsigned int n_port_pin_configs;
>
> n_ports?
>
Ok I will rename it to n_ports.

> >         struct rzg2l_dedicated_configs *dedicated_pins;
> >         unsigned int n_port_pins;
>
> n_port_pins is now always n_port_pin_configs * RZG2L_PINS_PER_PORT,
> right?
>
Yes, that's right. So are you suggesting to drop it and use it runtime instead?

> >         unsigned int n_dedicated_pins;
>
> > @@ -1517,6 +1518,7 @@ static int rzg2l_pinctrl_probe(struct platform_device *pdev)
> >  static struct rzg2l_pinctrl_data r9a07g043_data = {
> >         .port_pins = rzg2l_gpio_names,
> >         .port_pin_configs = r9a07g043_gpio_configs,
> > +       .n_port_pin_configs = ARRAY_SIZE(r9a07g043_gpio_configs),
> >         .dedicated_pins = rzg2l_dedicated_pins.common,
> >         .n_port_pins = ARRAY_SIZE(r9a07g043_gpio_configs) * RZG2L_PINS_PER_PORT,
> >         .n_dedicated_pins = ARRAY_SIZE(rzg2l_dedicated_pins.common),
> > @@ -1525,6 +1527,7 @@ static struct rzg2l_pinctrl_data r9a07g043_data = {
> >  static struct rzg2l_pinctrl_data r9a07g044_data = {
> >         .port_pins = rzg2l_gpio_names,
>
> .port_pins is always rzg2l_gpio_names
>
Yes to avoid the huge array to be duplicated for other SoCs but bound
checking is done by  n_port_pins.

> >         .port_pin_configs = rzg2l_gpio_configs,
> > +       .n_port_pin_configs = ARRAY_SIZE(rzg2l_gpio_configs),
> >         .dedicated_pins = rzg2l_dedicated_pins.common,
> >         .n_port_pins = ARRAY_SIZE(rzg2l_gpio_names),
>
> I think this should have become
> ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT)
> when support for r9a07g043 was introduced.
>
Agreed, I will update it as part of v2.

> To avoid overflows when adding support for more SoCs, you can add a
> bunch of checks like
>
>     BUILD_BUG_ON(ARRAY_SIZE(r9a07g043_gpio_configs) *
> RZG2L_PINS_PER_PORT > ARRAY_SIZE(rzg2l_gpio_names))
>     BUILD_BUG_ON(ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT
> > ARRAY_SIZE(rzg2l_gpio_names))
>
OK, I'll add those checks in the probe as a separate patch.

Cheers,
Prabhakar

  reply	other threads:[~2022-11-17 12:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 17:53 [PATCH RFC 0/5] Add IRQC support to RZ/G2UL SoC Prabhakar
2022-11-07 17:53 ` [PATCH RFC 1/5] dt-bindings: interrupt-controller: renesas,rzg2l-irqc: Document " Prabhakar
2022-11-07 18:39   ` Krzysztof Kozlowski
2022-11-17 10:53   ` Geert Uytterhoeven
2022-11-17 11:37     ` Lad, Prabhakar
2022-11-18 12:29     ` Lad, Prabhakar
2022-12-19 12:57       ` Lad, Prabhakar
2022-12-19 13:50         ` Geert Uytterhoeven
2022-12-19 14:25           ` Lad, Prabhakar
2022-12-19 14:46             ` Geert Uytterhoeven
2022-12-19 15:09               ` Lad, Prabhakar
2022-11-07 17:53 ` [PATCH RFC 2/5] pinctrl: renesas: rzg2l: Fix configuring the GPIO pins as interrupts Prabhakar
2022-11-08  7:14   ` Biju Das
2022-11-08  9:09     ` Lad, Prabhakar
2022-11-08  9:15       ` Biju Das
2022-11-17 11:09   ` Geert Uytterhoeven
2022-11-17 12:14     ` Lad, Prabhakar [this message]
2022-11-07 17:53 ` [PATCH RFC 3/5] arm64: dts: renesas: r9a07g043[u]: Add IRQC node Prabhakar
2022-11-17 11:13   ` Geert Uytterhoeven
2022-11-17 12:30     ` Lad, Prabhakar
2022-11-07 17:53 ` [PATCH RFC 4/5] arm64: dts: renesas: r9a07g043[u]: Update pinctrl node to handle GPIO interrupts Prabhakar
2022-11-17 11:20   ` Geert Uytterhoeven
2022-11-17 15:21     ` Lad, Prabhakar
2022-11-07 17:53 ` [PATCH RFC 5/5] arm64: dts: renesas: rzg2ul-smarc-som: Add PHY interrupt support for ETH{0/1} Prabhakar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+V-a8ugHB2NqH4qa01LQm6yXaeSk2WweUX3ZP+fT3F_bU99Pg@mail.gmail.com \
    --to=prabhakar.csengg@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=maz@kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.