LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3)
@ 2007-03-30 19:03 Mitch Williams
2007-03-30 19:09 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Mitch Williams @ 2007-03-30 19:03 UTC (permalink / raw)
To: linux-pci, gregkh; +Cc: ebiederm, linux-kernel, akpm, auke-jan.h.kok
This patch fixes a kernel bug which is triggered when using the
irqbalance daemon with MSI-X hardware.
Because both MSI-X interrupt messages and MSI-X table writes are posted,
it's possible for them to cross while in-flight. This results in
interrupts being received long after the kernel thinks they're disabled,
and in interrupts being sent to stale vectors after rebalancing.
This patch performs a read flush after writes to the MSI-X table for
mask and unmask operations. Since the SMP affinity is set while
the interrupt is masked, and since it's unmasked immediately after,
no additional flushes are required in the various affinity setting
routines.
This patch has been validated with (unreleased) network hardware which
uses MSI-X.
Revised with input from Eric Biederman.
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
diff -urpN -X dontdiff linux-2.6.20.4-clean/drivers/pci/msi.c linux-2.6.20.4/drivers/pci/msi.c
--- linux-2.6.20.4-clean/drivers/pci/msi.c 2007-02-04 10:44:54.000000000 -0800
+++ linux-2.6.20.4/drivers/pci/msi.c 2007-03-30 10:51:46.000000000 -0700
@@ -40,6 +40,29 @@ static int msi_cache_init(void)
return 0;
}
+static void msix_flush_writes(unsigned int irq)
+{
+ struct msi_desc *entry;
+
+ entry = msi_desc[irq];
+ BUG_ON(!entry || !entry->dev);
+ switch (entry->msi_attrib.type) {
+ case PCI_CAP_ID_MSI:
+ /* nothing to do */
+ break;
+ case PCI_CAP_ID_MSIX:
+ {
+ int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
+ PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET;
+ readl(entry->mask_base + offset);
+ break;
+ }
+ default:
+ BUG();
+ break;
+ }
+}
+
static void msi_set_mask_bit(unsigned int irq, int flag)
{
struct msi_desc *entry;
@@ -154,11 +177,13 @@ void write_msi_msg(unsigned int irq, str
void mask_msi_irq(unsigned int irq)
{
msi_set_mask_bit(irq, 1);
+ msix_flush_writes(irq);
}
void unmask_msi_irq(unsigned int irq)
{
msi_set_mask_bit(irq, 0);
+ msix_flush_writes(irq);
}
static int msi_free_irq(struct pci_dev* dev, int irq);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3)
2007-03-30 19:03 [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3) Mitch Williams
@ 2007-03-30 19:09 ` Greg KH
2007-03-30 19:12 ` Greg KH
2007-03-30 19:33 ` Eric W. Biederman
0 siblings, 2 replies; 5+ messages in thread
From: Greg KH @ 2007-03-30 19:09 UTC (permalink / raw)
To: Mitch Williams; +Cc: linux-pci, ebiederm, linux-kernel, akpm, auke-jan.h.kok
On Fri, Mar 30, 2007 at 12:03:47PM -0700, Mitch Williams wrote:
> This patch fixes a kernel bug which is triggered when using the
> irqbalance daemon with MSI-X hardware.
>
> Because both MSI-X interrupt messages and MSI-X table writes are posted,
> it's possible for them to cross while in-flight. This results in
> interrupts being received long after the kernel thinks they're disabled,
> and in interrupts being sent to stale vectors after rebalancing.
>
> This patch performs a read flush after writes to the MSI-X table for
> mask and unmask operations. Since the SMP affinity is set while
> the interrupt is masked, and since it's unmasked immediately after,
> no additional flushes are required in the various affinity setting
> routines.
>
> This patch has been validated with (unreleased) network hardware which
> uses MSI-X.
>
> Revised with input from Eric Biederman.
>
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Sorry, but this isn't going to go into 2.6.20 any time soon as it
doesn't fit the rules for the -stable tree.
But I'll take an updated version for my pci tree to go to Linus after
2.6.21 is out.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3)
2007-03-30 19:09 ` Greg KH
@ 2007-03-30 19:12 ` Greg KH
2007-03-30 19:33 ` Eric W. Biederman
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2007-03-30 19:12 UTC (permalink / raw)
To: Mitch Williams; +Cc: linux-pci, ebiederm, linux-kernel, akpm, auke-jan.h.kok
On Fri, Mar 30, 2007 at 12:09:51PM -0700, Greg KH wrote:
> But I'll take an updated version for my pci tree to go to Linus after
> 2.6.21 is out.
Oh nevermind, you already sent me that one...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3)
2007-03-30 19:09 ` Greg KH
2007-03-30 19:12 ` Greg KH
@ 2007-03-30 19:33 ` Eric W. Biederman
2007-03-30 19:48 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2007-03-30 19:33 UTC (permalink / raw)
To: Greg KH; +Cc: Mitch Williams, linux-pci, linux-kernel, akpm, auke-jan.h.kok
Greg KH <gregkh@suse.de> writes:
>
> Sorry, but this isn't going to go into 2.6.20 any time soon as it
> doesn't fit the rules for the -stable tree.
>
> But I'll take an updated version for my pci tree to go to Linus after
> 2.6.21 is out.
Greg this does fix a bug that affects 2.6.21. We have hardware in 2.6.21 that
is affected And it at least seems to meet the obviously correct
criteria. So at least for 2.6.21 I think it is interesting.
Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3)
2007-03-30 19:33 ` Eric W. Biederman
@ 2007-03-30 19:48 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2007-03-30 19:48 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Mitch Williams, linux-pci, linux-kernel, akpm, auke-jan.h.kok
On Fri, Mar 30, 2007 at 01:33:45PM -0600, Eric W. Biederman wrote:
> Greg KH <gregkh@suse.de> writes:
> >
> > Sorry, but this isn't going to go into 2.6.20 any time soon as it
> > doesn't fit the rules for the -stable tree.
> >
> > But I'll take an updated version for my pci tree to go to Linus after
> > 2.6.21 is out.
>
> Greg this does fix a bug that affects 2.6.21. We have hardware in 2.6.21 that
> is affected And it at least seems to meet the obviously correct
> criteria. So at least for 2.6.21 I think it is interesting.
We do? What hardware has this reported problem showed up on? I haven't
seen any bug reports yet.
And I think it's way too late for something like this. If it's really
needed, I don't have a problem adding it to the 2.6.21-stable tree in a
few weeks.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-03-30 19:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 19:03 [PATCH 2.6.20.4] Flush MSI-X table writes (rev 3) Mitch Williams
2007-03-30 19:09 ` Greg KH
2007-03-30 19:12 ` Greg KH
2007-03-30 19:33 ` Eric W. Biederman
2007-03-30 19:48 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).