All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cixi Geng <cixi.geng@linux.dev>
To: Baolin Wang <baolin.wang@linux.alibaba.com>,
	linus.walleij@linaro.org, brgl@bgdev.pl, orsonzhai@gmail.com,
	zhang.lyra@gmail.com, gengcixi@gmail.com
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio: sprd: Make irq_chip immutable
Date: Sun, 18 Dec 2022 20:44:11 +0800	[thread overview]
Message-ID: <83c2ef58243f12f5e3fa36fb7a4e2d74faf28990.camel@linux.dev> (raw)
In-Reply-To: <97e244d4-6b5c-31c9-7329-b8deef615645@linux.alibaba.com>

On Fri, 2022-12-16 at 14:50 +0800, Baolin Wang wrote:
> > 
> > 
> > On 12/16/2022 12:17 PM, Cixi Geng wrote:
> > > > From: Cixi Geng <cixi.geng1@unisoc.com>
> > > > 
> > > > Kernel warns about mutable irq_chips:
> > > > 
> > > >      "not an immutable chip, please consider fixing!"
> > > > 
> > > > Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE,
> > > > add > > the
> > > > new helper functions, and call the appropriate gpiolib
> > > > functions.
> > 
> > Please split them into 3 patches and each patch converts one
> > driver, 
> > which is easy to review.
Thanks for reviewing, I will modify the comments in the next version
> > 
> > > > 
> > > > Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
> > > > ---
> > > >   drivers/gpio/gpio-eic-sprd.c      |  4 ++--
> > > >   drivers/gpio/gpio-pmic-eic-sprd.c |  4 ++--
> > > >   drivers/gpio/gpio-sprd.c          | 11 +++++++++--
> > > >   3 files changed, 13 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpio/gpio-eic-sprd.c > >
> > > > b/drivers/gpio/gpio-eic-sprd.c
> > > > index 8d722e026e9c..07b9099f2a6d 100644
> > > > --- a/drivers/gpio/gpio-eic-sprd.c
> > > > +++ b/drivers/gpio/gpio-eic-sprd.c
> > > > @@ -631,10 +631,10 @@ static int sprd_eic_probe(struct > >
> > > > platform_device *pdev)
> > > >         sprd_eic->intc.irq_mask = sprd_eic_irq_mask;
> > > >         sprd_eic->intc.irq_unmask = sprd_eic_irq_unmask;
> > > >         sprd_eic->intc.irq_set_type = sprd_eic_irq_set_type;
> > > > -       sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
> > > > +       sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE | > >
> > > > IRQCHIP_IMMUTABLE;
> > > >   
> > > >         irq = &sprd_eic->chip.irq;
> > > > -       irq->chip = &sprd_eic->intc;
> > > > +       gpio_irq_chip_set_chip(irq, &sprd_eic->intc);
> > > >         irq->handler = handle_bad_irq;
> > > >         irq->default_type = IRQ_TYPE_NONE;
> > > >         irq->parent_handler = sprd_eic_irq_handler;
> > > > diff --git a/drivers/gpio/gpio-pmic-eic-sprd.c > >
> > > > b/drivers/gpio/gpio-pmic-eic-sprd.c
> > > > index e518490c4b68..d96604ea10e7 100644
> > > > --- a/drivers/gpio/gpio-pmic-eic-sprd.c
> > > > +++ b/drivers/gpio/gpio-pmic-eic-sprd.c
> > > > @@ -344,10 +344,10 @@ static int sprd_pmic_eic_probe(struct > >
> > > > platform_device *pdev)
> > > >         pmic_eic->intc.irq_set_type =
> > > > sprd_pmic_eic_irq_set_type;
> > > >         pmic_eic->intc.irq_bus_lock = sprd_pmic_eic_bus_lock;
> > > >         pmic_eic->intc.irq_bus_sync_unlock = > >
> > > > sprd_pmic_eic_bus_sync_unlock;
> > > > -       pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
> > > > +       pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE | > >
> > > > IRQCHIP_IMMUTABLE;
> > 
> > Why not add GPIOCHIP_IRQ_RESOURCE_HELPERS for above 2 drivers?
> > Seems > we 
> > can remove the irq_chip from pmic_eic structure, instead we can >
> > define 
> > it statically with adding GPIOCHIP_IRQ_RESOURCE_HELPERS like other
> > > patch 
> > [1] did?
> > 
> > [1] >
> > https://lore.kernel.org/all/20220419141846.598305-6-maz@kernel.org/
> > 
> > > >   
> > > >         irq = &pmic_eic->chip.irq;
> > > > -       irq->chip = &pmic_eic->intc;
> > > > +       gpio_irq_chip_set_chip(irq, &pmic_eic->intc);
> > > >         irq->threaded = true;
> > > >   
> > > >         ret = devm_gpiochip_add_data(&pdev->dev, &pmic_eic-
> > > > >chip, > > pmic_eic);
> > > > diff --git a/drivers/gpio/gpio-sprd.c b/drivers/gpio/gpio-
> > > > sprd.c
> > > > index 9bff63990eee..8398f9707ec0 100644
> > > > --- a/drivers/gpio/gpio-sprd.c
> > > > +++ b/drivers/gpio/gpio-sprd.c
> > > > @@ -64,6 +64,11 @@ static void sprd_gpio_update(struct
> > > > gpio_chip > > *chip, unsigned int offset,
> > > >   
> > > >         writel_relaxed(tmp, base + reg);
> > > >         spin_unlock_irqrestore(&sprd_gpio->lock, flags);
> > > > +
> > > > +       if (reg == SPRD_GPIO_IE && val == 1)
> > > > +               gpiochip_enable_irq(chip, offset);
> > > > +       else if (reg == SPRD_GPIO_IE && val == 0)
> > > > +               gpiochip_disable_irq(chip, offset);
> > 
> > Looks incorrect to me, IIUC you should move 
> > gpiochip_enable_irq/gpiochip_disable_irq() into
> > sprd_gpio_irq_mask() > and 
> > sprd_gpio_irq_unmask().
> > 
> > > >   }
> > > >   
> > > >   static int sprd_gpio_read(struct gpio_chip *chip, unsigned
> > > > int > > offset, u16 reg)
> > > > @@ -205,13 +210,15 @@ static void sprd_gpio_irq_handler(struct
> > > > > > irq_desc *desc)
> > > >         chained_irq_exit(ic, desc);
> > > >   }
> > > >   
> > > > -static struct irq_chip sprd_gpio_irqchip = {
> > > > +static const struct irq_chip sprd_gpio_irqchip = {
> > > >         .name = "sprd-gpio",
> > > >         .irq_ack = sprd_gpio_irq_ack,
> > > >         .irq_mask = sprd_gpio_irq_mask,
> > > >         .irq_unmask = sprd_gpio_irq_unmask,
> > > >         .irq_set_type = sprd_gpio_irq_set_type,
> > > >         .flags = IRQCHIP_SKIP_SET_WAKE,
> > > > +       .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
> > > > +       GPIOCHIP_IRQ_RESOURCE_HELPERS,
> > > >   };
> > > >   
> > > >   static int sprd_gpio_probe(struct platform_device *pdev)
> > > > @@ -245,7 +252,7 @@ static int sprd_gpio_probe(struct > >
> > > > platform_device *pdev)
> > > >         sprd_gpio->chip.direction_output = > >
> > > > sprd_gpio_direction_output;
> > > >   
> > > >         irq = &sprd_gpio->chip.irq;
> > > > -       irq->chip = &sprd_gpio_irqchip;
> > > > +       gpio_irq_chip_set_chip(irq, &sprd_gpio_irqchip);
> > > >         irq->handler = handle_bad_irq;
> > > >         irq->default_type = IRQ_TYPE_NONE;
> > > >         irq->parent_handler = sprd_gpio_irq_handler;


      reply	other threads:[~2022-12-18 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  4:17 [PATCH] gpio: sprd: Make irq_chip immutable Cixi Geng
2022-12-16  6:50 ` Baolin Wang
2022-12-18 12:44   ` Cixi Geng [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=83c2ef58243f12f5e3fa36fb7a4e2d74faf28990.camel@linux.dev \
    --to=cixi.geng@linux.dev \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=brgl@bgdev.pl \
    --cc=gengcixi@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=zhang.lyra@gmail.com \
    /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.