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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdaJg4wqtD5xhPVrHJHxFoVwau6jidbOuQ9xFSK_6drxPQ@mail.gmail.com>
Date:	Mon, 18 Nov 2013 14:11:32 +0100
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Prabhakar Lad <prabhakar.csengg@...il.com>
Cc:	Sekhar Nori <nsekhar@...com>,
	Grygorii Strashko <grygorii.strashko@...com>,
	LKML <linux-kernel@...r.kernel.org>,
	DLOS <davinci-linux-open-source@...ux.davincidsp.com>,
	LAK <linux-arm-kernel@...ts.infradead.org>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
	Rob Herring <rob.herring@...xeda.com>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Stephen Warren <swarren@...dotorg.org>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Rob Landley <rob@...dley.net>,
	Grant Likely <grant.likely@...aro.org>
Subject: Re: [PATCH v5 3/7] gpio: davinci: use irqdomain

On Fri, Nov 8, 2013 at 11:11 AM, Prabhakar Lad
<prabhakar.csengg@...il.com> wrote:

> From: "Lad, Prabhakar" <prabhakar.csengg@...il.com>
>
> This patch converts the davinci gpio driver to use irqdomain
> support.
>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@...il.com>

(...)
> @@ -282,8 +283,7 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc)
>         desc->irq_data.chip->irq_ack(&desc->irq_data);
>         while (1) {
>                 u32             status;
> -               int             n;
> -               int             res;
> +               int             bit;

Why is this an int? I think u8 would suffice.

>                 /* now demux them to the right lowlevel handler */
> -               n = d->irq_base;
> -               if (irq & 1) {
> -                       n += 16;
> -                       status >>= 16;
> -               }
> -
>                 while (status) {
> -                       res = ffs(status);
> -                       n += res;
> -                       generic_handle_irq(n - 1);
> -                       status >>= res;
> +                       bit = __ffs(status);
> +                       status &= ~(1 << bit);
> +                       generic_handle_irq(irq_find_mapping(d->irq_domain,
> +                                                           bit));

This is a nice hunk of the patch.

I would use <linux/bitops.h> and do:
status &= ~BIT(bit);


> @@ -313,10 +307,7 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
>  {
>         struct davinci_gpio_controller *d = chip2controller(chip);
>
> -       if (d->irq_base >= 0)
> -               return d->irq_base + offset;
> -       else
> -               return -ENODEV;
> +       return irq_create_mapping(d->irq_domain, offset);
>  }

I think we recently established that map creating cannot be done
in gpio_to_irq* functions as that will not work properly if you request
an IRQ from device tree without first obtaining the IRQ from the GPIO
number with this function.

Instead call irq_create_mapping() on *all* used IRQ lines in the
probe function and use irq_find_mapping() here too.

> +       for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) {
>                 /* disabled by default, enabled only as needed */
>                 g = gpio2regs(gpio);
>                 writel(~0, &g->clr_falling);
> @@ -467,14 +483,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>                  */
>                 irq_set_handler_data(bank_irq, &chips[gpio / 32]);

So for example here you could call iurq_create_mapping();

Also: please write a patch that marks the IRQ lines.
Call gpio_lock_as_irq(*gpio_chip, offset); in the
irqchip startup/shutdown functions. (Can be a separate
patch.)

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ