Message ID | 35FD53F367049845BC99AC72306C23D103CDBFBFB017@CNBJMBX05.corpusers.net |
---|---|
State | Not Applicable, archived |
Headers | show |
On Tue, Sep 9, 2014 at 9:12 AM, Wang, Yalin <Yalin.Wang@sonymobile.com> wrote: > this patch change use from irq_create_mapping to irq_alloc_descs_from, > use irq_create_mapping to alloc virq one by one is not safe, > it can't promise the allcated virqs are continuous, > in stead, we use irq_alloc_descs_from() to alloc virqs in one time, > so that the allocated virqs are in continuous bitmaps. > > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com> OK makes sense, patch applied. The patch was BASE64-mangled though. Fixed it up and applied. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Sep 9, 2014 at 9:12 AM, Wang, Yalin <Yalin.Wang@sonymobile.com> wrote: > this patch change use from irq_create_mapping to irq_alloc_descs_from, > use irq_create_mapping to alloc virq one by one is not safe, > it can't promise the allcated virqs are continuous, > in stead, we use irq_alloc_descs_from() to alloc virqs in one time, > so that the allocated virqs are in continuous bitmaps. > > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com> (...) > - for (offset = 0; offset < gpiochip->ngpio; offset++) { > - irq_base = irq_create_mapping(gpiochip->irqdomain, offset); > - if (offset == 0) > - /* > - * Store the base into the gpiochip to be used when > - * unmapping the irqs. > - */ > - gpiochip->irq_base = irq_base; > + if (first_irq > 0) { > + gpiochip->irq_base = first_irq; Wait is this safe? Now you assume all descriptors are pre-allocated and associated in this case, atleast explain what is going on. > + } else { > + gpiochip->irq_base = irq_alloc_descs_from(1, gpiochip->ngpio, > + of_node_to_nid(of_node)); > + irq_domain_associate_many(gpiochip->irqdomain, > + gpiochip->irq_base, 0, gpiochip->ngpio); This part looks OK. I'm holding this patch back until the above is clarified. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
hi this is because , here: gpiochip->irqdomain = irq_domain_add_simple(of_node, gpiochip->ngpio, first_irq, &gpiochip_domain_ops, gpiochip); irq_domain_add_simple() in this function, if (first_irq > 0) { if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { /* attempt to allocated irq_descs */ int rc = irq_alloc_descs(first_irq, first_irq, size, of_node_to_nid(of_node)); if (rc < 0) pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", first_irq); } irq_domain_associate_many(domain, first_irq, 0, size); } if first_irq > 0 , it will allocate it , and make sure the return virq is equal to first_irq . so we don't need allocate it again .
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 15cc0bb..2b6c441 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -566,7 +566,6 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip, unsigned int type) { struct device_node *of_node; - unsigned int offset; unsigned irq_base = 0; if (!gpiochip || !irqchip) @@ -604,14 +603,13 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip, * any gpiochip calls. If the first_irq was zero, this is * necessary to allocate descriptors for all IRQs. */ - for (offset = 0; offset < gpiochip->ngpio; offset++) { - irq_base = irq_create_mapping(gpiochip->irqdomain, offset); - if (offset == 0) - /* - * Store the base into the gpiochip to be used when - * unmapping the irqs. - */ - gpiochip->irq_base = irq_base; + if (first_irq > 0) { + gpiochip->irq_base = first_irq; + } else { + gpiochip->irq_base = irq_alloc_descs_from(1, gpiochip->ngpio, + of_node_to_nid(of_node)); + irq_domain_associate_many(gpiochip->irqdomain, + gpiochip->irq_base, 0, gpiochip->ngpio); } acpi_gpiochip_request_interrupts(gpiochip);
this patch change use from irq_create_mapping to irq_alloc_descs_from, use irq_create_mapping to alloc virq one by one is not safe, it can't promise the allcated virqs are continuous, in stead, we use irq_alloc_descs_from() to alloc virqs in one time, so that the allocated virqs are in continuous bitmaps. Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com> --- drivers/gpio/gpiolib.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)