lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <83c2ef58243f12f5e3fa36fb7a4e2d74faf28990.camel@linux.dev>
Date:   Sun, 18 Dec 2022 20:44:11 +0800
From:   Cixi Geng <cixi.geng@...ux.dev>
To:     Baolin Wang <baolin.wang@...ux.alibaba.com>,
        linus.walleij@...aro.org, brgl@...ev.pl, orsonzhai@...il.com,
        zhang.lyra@...il.com, gengcixi@...il.com
Cc:     linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] gpio: sprd: Make irq_chip immutable

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@...soc.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@...soc.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;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ