mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Martin Kaiser <martin@kaiser.cx>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	rfi@lists.rocketboards.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	Jingoo Han <jingoohan1@gmail.com>,
	Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
	Toan Le <toan@os.amperecomputing.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] PCI: altera-msi: Remove irq handler and data in one go
Date: Wed, 11 Nov 2020 16:16:39 -0600	[thread overview]
Message-ID: <20201111221639.GA973514@bjorn-Precision-5520> (raw)
In-Reply-To: <20201111214355.puinncgf3aksxh73@viti.kaiser.cx>

[+cc Thomas for handler/data order question at end]

On Wed, Nov 11, 2020 at 10:43:55PM +0100, Martin Kaiser wrote:
> Thus wrote Bjorn Helgaas (helgaas@kernel.org):
> > On Tue, Nov 10, 2020 at 03:21:36PM -0600, Bjorn Helgaas wrote:
> > > 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().  
> 
> Ok, understood.
> 
> > > 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.
> 
> Thomas' commit 2cf5a03cb29d fixed a case where the handler was installed.
> We're removing the handler here so his commit message doesn't really fit.
> Anyway, I'll rewrite the commit message to clarify that this fixes a
> race condition.

Oh, right, of course, I wasn't paying attention.  The altera case is
removing and doing it in the correct order (removing handler, then
data), so there shouldn't be a race even with the current code.

> > > Looks like this should also be done in dw_pcie_free_msi() and
> 
> I'll send a patch for this.
> 
> > > xgene_msi_hwirq_alloc() at the same time?
> 
> This function uses the error status from irq_set_handler_data().
> irq_set_chained_handler_and_data() returns no such error status. Is it
> ok to drop the error handling?

I'm not an IRQ expert, but I'd say it's OK to drop it.  Of the 40 or
so callers, the only other caller that looks at the error status is
ingenic_intc_of_init().

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?

  reply	other threads:[~2020-11-11 22:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-08 19:11 Martin Kaiser
2020-11-10 21:21 ` Bjorn Helgaas
2020-11-10 21:45   ` Bjorn Helgaas
2020-11-11 21:43     ` Martin Kaiser
2020-11-11 22:16       ` Bjorn Helgaas [this message]
2020-11-12 11:28         ` Thomas Gleixner
2020-11-12 13:50           ` Thomas Gleixner
2020-11-12 14:26             ` Bjorn Helgaas
2020-11-12 18:19               ` Thomas Gleixner
2020-11-11 22:01 ` [PATCH v2 1/2] PCI: altera-msi: Fix race in removing chained IRQ handler Martin Kaiser
2020-11-11 22:01   ` [PATCH v2 2/2] PCI: dwc: " Martin Kaiser
2020-11-12 22:10 ` [PATCH v3 1/3] PCI: altera-msi: remove chained IRQ handler and data in one go Martin Kaiser
2020-11-12 22:10   ` [PATCH v3 2/3] PCI: dwc: " Martin Kaiser
2020-11-12 22:10   ` [PATCH v3 3/3] PCI: xgene-msi: Fix race in installing chained irq handler Martin Kaiser
2020-11-13 16:54   ` [PATCH v3 1/3] PCI: altera-msi: remove chained IRQ handler and data in one go Bjorn Helgaas
2021-01-15 21:24 ` [PATCH v4 1/3] PCI: altera-msi: Remove " Martin Kaiser
2021-01-15 21:24   ` [PATCH v4 2/3] PCI: dwc: " Martin Kaiser
2021-01-15 21:24   ` [PATCH v4 3/3] PCI: xgene-msi: Fix race in installing chained irq handler Martin Kaiser
2021-01-18 15:49   ` [PATCH v4 1/3] PCI: altera-msi: Remove IRQ handler and data in one go Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201111221639.GA973514@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=ley.foon.tan@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=martin@kaiser.cx \
    --cc=nsaenzjulienne@suse.de \
    --cc=rfi@lists.rocketboards.org \
    --cc=tglx@linutronix.de \
    --cc=toan@os.amperecomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®