Re: [TECH TOPIC] Rust for Linux

Wedson Almeida Filho
2021-07-22T11:34:04Z

On Wed, Jul 21, 2021 at 04:19:09PM +0200, Linus Walleij wrote:
> On Wed, Jul 21, 2021 at 4:13 PM Wedson Almeida Filho
> <wedsonaf@google.com> wrote:
> > On Wed, Jul 21, 2021 at 03:54:33PM +0200, Linus Walleij wrote:
>
> > > We have something like this for GPIO but it is coded by a notoriously
> > > crappy programmer (me) in C, so there are some bugs in it pointed
> > > out by Miguel.
> > > https://lore.kernel.org/ksummit/CACRpkdasOaNgBAZVx5qpKJdU7h41jHDG2jWi2+pi9a1JBh7RTQ@mail.gmail.com/
> >
> > Would you mind sharing details of the bugs Miguel found?
>
> Nah, just me being confused. They were found by you :)
> https://lore.kernel.org/ksummit/CACRpkdb1W=M5EJkGbSS4QxObU-Gd5yZ1qE439k_D4K=jevgcrQ@mail.gmail.com/

I had two more questions from reading the code that you may be able to answer:
1. Drivers like the one for pl061 call `irq_set_irq_wake` from their
`irq_set_wake` callbacks. These are "counted", which is great because it
allows us to just call the same function for each gpio/interrupt. However,
when a gpio irq chip is removed, what ensures that these increments are
accordingly decremented?
2. `irq_domain_remove` requires that all mappings have been disposed of before
being called. I see that `gpiochip_irqchip_remove` calls
`irq_dispose_mapping` for each pin before calling `irq_domain_remove`. But
what prevents *new* mappings from being added back before `irq_domain_remove`
is called?

Thanks,
-Wedson