Re: [PATCH] PCI: altera-msi: Remove irq handler and data in one go

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 12, 2020 at 02:50:42PM +0100, Thomas Gleixner wrote:
> On Thu, Nov 12 2020 at 12:28, Thomas Gleixner wrote:
> > On Wed, Nov 11 2020 at 16:16, Bjorn Helgaas wrote:
> >> On Wed, Nov 11, 2020 at 10:43:55PM +0100, Martin Kaiser wrote:
> >> Thomas, it looks like irq_domain_set_info() and msi_domain_ops_init()
> >> set the handler itself before setting the handler data:
> >>
> >>   irq_domain_set_info
> >>     irq_set_chip_and_handler_name(virq, chip, handler, ...)
> >>     irq_set_handler_data(virq, handler_data)
> >>
> >>   msi_domain_ops_init
> >>     __irq_set_handler(virq, info->handler, ...)
> >>     if (info->handler_data)
> >>       irq_set_handler_data(virq, info->handler_data)
> >>
> >> That looks at least superficially similar to the race you fixed with
> >> 2cf5a03cb29d ("PCI/keystone: Fix race in installing chained IRQ
> >> handler").
> >>
> >> Should irq_domain_set_info() and msi_domain_ops_init() swap the order,
> >> too?
> >
> > In theory yes. Practically it should not matter because that happens
> > during the allocation way before the interrupt can actually fire.  I'll
> > have a deeper look nevertheless.
> 
> So I had a closer look and the reason why it only matters for the
> chained handler case is that
> 
>    __irq_set_handler(..., is_chained = true, ...)
> 
> starts up the interrupt immediately. So the order for this _must_ be:
> 
>     set_handler_data() -> set_handler()
> 
> For regular interrupts it's really the mapping and allocation code which
> does this long before the interrupt is started up. So the ordering does
> not matter because the handler can't be reached before the full
> setup is finished and the interrupt is actually started up.

If the order truly doesn't matter here, maybe it's worth changing it
to "set data, set handler" to avoid the need for a closer look to
verify correctness and to make it harder to copy and paste to a place
where it *does* matter?

Bjorn



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux