linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Joey Gouly <joey.gouly@arm.com>
Cc: <linux-gpio@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Hector Martin <marcan@marcan.st>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
	Sven Peter <sven@svenpeter.dev>, <devicetree@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Kettenis <kettenis@openbsd.org>, <nd@arm.com>
Subject: Re: [PATCH v4 0/5] pinctrl/GPIO driver for Apple SoCs
Date: Mon, 25 Oct 2021 11:28:11 +0100	[thread overview]
Message-ID: <87fsspbdqc.wl-maz@kernel.org> (raw)
In-Reply-To: <20211024101838.43107-1-joey.gouly@arm.com>

On Sun, 24 Oct 2021 11:18:33 +0100,
Joey Gouly <joey.gouly@arm.com> wrote:
> 
> Hi all,
> 
> Here is the v4 patchset for the Apple pinctrl/GPIO driver.
> 
> Changes since v3 [1]:
>   - Applied Marc Zyngier's review/patch (with exception noted below)
>   - Removed "apple,t8103-pinctrl" compatible from driver
>   - Applied Acks/Review tags
> 
> 
> With Marc's changes, the irq_chip was being shared between pinctrl
> drivers and I was getting the following warning:
> 
>   drivers/gpio/gpiolib.c:1456:
> 
>     detected irqchip that is shared with multiple gpiochips: please fix
> the driver.
> 
> 
> So I applied the following diff to Marc's change, to not share the
> irq_chips, while still being cleaner overall:
> 
> diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c
> b/drivers/pinctrl/pinctrl-apple-gpio.c
> index 732c347a2bbc..ce037a5c15c1 100644
> --- a/drivers/pinctrl/pinctrl-apple-gpio.c
> +++ b/drivers/pinctrl/pinctrl-apple-gpio.c
> @@ -35,6 +35,7 @@ struct apple_gpio_pinctrl {
> 
>         struct pinctrl_desc pinctrl_desc;
>         struct gpio_chip gpio_chip;
> +       struct irq_chip irq_chip;
>         u8 irqgrps[0];
>  };
> 
> @@ -369,6 +370,8 @@ static int apple_gpio_gpio_register(struct
> apple_gpio_pinctrl *pctl)
>                 return dev_err_probe(pctl->dev, -ENODEV,
>                                      "No gpio-controller property\n");
> 
> +       pctl->irq_chip = apple_gpio_irqchip;
> +
>         pctl->gpio_chip.label = dev_name(pctl->dev);
>         pctl->gpio_chip.request = gpiochip_generic_request;
>         pctl->gpio_chip.free = gpiochip_generic_free;
> @@ -385,7 +388,7 @@ static int apple_gpio_gpio_register(struct
> apple_gpio_pinctrl *pctl)
>         if (girq->num_parents) {
>                 int i;
> 
> -               girq->chip = &apple_gpio_irqchip;
> +               girq->chip = &pctl->irq_chip;
>                 girq->parent_handler = apple_gpio_gpio_irq_handler;
> 
>                 girq->parents = kmalloc_array(girq->num_parents,
> 
> Marc said that hierarchical IRQ domains should solve this problem, but
> I'll let him explain more on the list, maybe that should solved in a different
> patch series.

The issue I have with the gpiolib code is that it hijacks function
pointers from a structure that is not under its control, and that is
exactly what the hierarchical IRQ domains/irqchips were supposed to
prevent.

It isn't obvious to me why this cannot be fixed with a gpiolib domain
and irqchip stacked on top of the one exposed by the low-level driver,
providing the required hooks in a standard way. Yes, this is even more
indirection. It also isn't clear why gpiochip_set_irq_hooks() shouts:
if the hooks are already there, move on.

Ultimately, this sort of manipulation is what prevents the irq_chip
structure from being made 'const' everywhere (ok, there is another nit
because of the parent_device field, which I'm looking at getting rid
of). Keeping writable function pointers isn't great, overall.

Now, given that this is an issue that isn't directly related to the
driver at hand, it shouldn't be a blocker for merging it.

So for the driver itself:

Reviewed-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

      parent reply	other threads:[~2021-10-25 10:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24 10:18 [PATCH v4 0/5] pinctrl/GPIO driver for Apple SoCs Joey Gouly
2021-10-24 10:18 ` [PATCH v4 1/5] gpio: Allow per-parent interrupt data Joey Gouly
2021-10-24 10:18 ` [PATCH v4 2/5] dt-bindings: pinctrl: add #interrupt-cells to apple,pinctrl Joey Gouly
2021-10-24 10:18 ` [PATCH v4 3/5] dt-bindings: pinctrl: Add apple,npins property " Joey Gouly
2021-10-24 10:18 ` [PATCH v4 4/5] pinctrl: add pinctrl/GPIO driver for Apple SoCs Joey Gouly
2021-10-25  9:07   ` Hector Martin
2021-10-25  9:41     ` Joey Gouly
2021-10-25  9:53       ` Hector Martin
2021-10-24 10:18 ` [PATCH v4 5/5] MAINTAINERS: add pinctrl-apple-gpio to ARM/APPLE MACHINE Joey Gouly
2021-10-24 21:34 ` [PATCH v4 0/5] pinctrl/GPIO driver for Apple SoCs Linus Walleij
2021-10-25  9:12 ` Hector Martin
2021-10-25 23:26   ` Linus Walleij
2021-10-25 10:28 ` Marc Zyngier [this message]

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=87fsspbdqc.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=joey.gouly@arm.com \
    --cc=kettenis@openbsd.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=nd@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sven@svenpeter.dev \
    /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 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).