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

From: Bjorn Helgaas
Date: Tue Nov 10 2020 - 16:21:37 EST


[+cc Nicolas, Jingoo, Gustavo, Toan]

On Sun, Nov 08, 2020 at 08:11:40PM +0100, Martin Kaiser wrote:
> Replace the two separate calls for removing the irq handler and data with a
> single irq_set_chained_handler_and_data() call.

This is similar to these:

36f024ed8fc9 ("PCI/MSI: pci-xgene-msi: Consolidate chained IRQ handler install/remove")
5168a73ce32d ("PCI/keystone: Consolidate chained IRQ handler install/remove")
2cf5a03cb29d ("PCI/keystone: Fix race in installing chained IRQ handler")

and it seems potentially important that this removes the IRQ handler
and data *atomically*, i.e., both are done while holding
irq_get_desc_buslock().

So I would use this:

PCI: altera-msi: Fix race in installing chained IRQ handler

Fix a race where a pending interrupt could be received and the handler
called before the handler's data has been setup by converting to
irq_set_chained_handler_and_data().

See also 2cf5a03cb29d ("PCI/keystone: Fix race in installing chained
IRQ handler").

to make it clear that this is actually a bug fix, not just a cleanup.

Looks like this should also be done in dw_pcie_free_msi() and
xgene_msi_hwirq_alloc() at the same time?

> Signed-off-by: Martin Kaiser <martin@xxxxxxxxx>
> ---
> drivers/pci/controller/pcie-altera-msi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
> index e1636f7714ca..42691dd8ebef 100644
> --- a/drivers/pci/controller/pcie-altera-msi.c
> +++ b/drivers/pci/controller/pcie-altera-msi.c
> @@ -204,8 +204,7 @@ static int altera_msi_remove(struct platform_device *pdev)
> struct altera_msi *msi = platform_get_drvdata(pdev);
>
> msi_writel(msi, 0, MSI_INTMASK);
> - irq_set_chained_handler(msi->irq, NULL);
> - irq_set_handler_data(msi->irq, NULL);
> + irq_set_chained_handler_and_data(msi->irq, NULL, NULL);
>
> altera_free_domains(msi);
>
> --
> 2.20.1
>