From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net>,
linux-kernel@vger.kernel.org, tom.l.nguyen@intel.com,
iss_storagedev@hp.com, jens.axboe@oracle.com,
Michael Ellerman <michael@ellerman.id.au>
Subject: Re: [PATCH] msi: Fix the ordering of msix irqs.
Date: Thu, 24 May 2007 15:36:41 -0600 [thread overview]
Message-ID: <m1d50peweu.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20070524141720.c02582db.akpm@linux-foundation.org> (Andrew Morton's message of "Thu, 24 May 2007 14:17:20 -0700")
Andrew Morton <akpm@linux-foundation.org> writes:
> On Thu, 24 May 2007 15:08:21 -0600
> ebiederm@xmission.com (Eric W. Biederman) wrote:
>
>> Yours looks more complete then my test patch so:
>>
>> From: "Mike Miller (OS Dev)" <mikem@beardog.cca.cpqcorp.net> writes:
>>
>> Found what seems the problem with our vectors being listed backward. In
>> drivers/pci/msi.c we should be using list_add_tail rather than list_add to
>> preserve the ordering across various kernels. Please consider this for
>> inclusion.
>>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>>
>> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
>> index 0e67723..d74975d 100644
>> --- a/drivers/pci/msi.c
>> +++ b/drivers/pci/msi.c
>> @@ -333,7 +333,7 @@ static int msi_capability_init(struct pci_dev *dev)
>> msi_mask_bits_reg(pos, is_64bit_address(control)),
>> maskbits);
>> }
>> - list_add(&entry->list, &dev->msi_list);
>> + list_add_tail(&entry->list, &dev->msi_list);
>>
>> /* Configure MSI capability structure */
>> ret = arch_setup_msi_irqs(dev, 1, PCI_CAP_ID_MSI);
>> @@ -404,7 +404,7 @@ static int msix_capability_init(struct pci_dev *dev,
>> entry->dev = dev;
>> entry->mask_base = base;
>>
>> - list_add(&entry->list, &dev->msi_list);
>> + list_add_tail(&entry->list, &dev->msi_list);
>> }
>>
>> ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
>
> Is this as fragile as I think it is? What happens when close+open and
> rmmod+modprobe happen? The list gets reordered then?
No this patch is not that fragile. We destroy and recreate the list
each time we call pci_disable_msix, pci_enable_msix. The order only
matters for the duration of pci_enable_msix.
Yes that silly struct msi_entries *entries vector passed into
pci_enable_msix is that fragile. The right fix is to just kill that
vector and have the driver walk the list. That is fundamentally more
robust.
> If this is important then perhaps a big-fat-comment which explains wtf is
> going on is needed?
When I get a moment I will remove the need to keep the list in any
sort of order. That will permanently remove the need for
explanations.
The truly problematic piece of code is this one below:
i = 0;
list_for_each_entry(entry, &dev->msi_list, list) {
entries[i].vector = entry->irq;
set_irq_msi(entry->irq, entry);
i++;
}
If we don't want to care about order we should really
should make it look something like:
list_for_each_entry(entry, &dev->msi_list, list) {
for (i = 0; i < nvecs; i++) {
if (entries[i].vector == entry->entry_nr)
entries[i].vector = entry->irq;
}
set_irq_msi(entry->irq, entry);
}
But that is overkill for a trivial bug fix, and under kill
for a proper fix because the drivers still need to deal with
that complexity.
Letting the drivers walk dev->msi_list should be noticeably more
maintainable long term. Especially when drivers start using a lot
of msi irqs.
Eric
next prev parent reply other threads:[~2007-05-24 21:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-24 16:07 msi_free_irqs #2 Mike Miller (OS Dev)
2007-05-24 17:27 ` Andrew Morton
2007-05-24 19:42 ` Eric W. Biederman
2007-05-24 20:59 ` Mike Miller (OS Dev)
2007-05-24 21:08 ` [PATCH] msi: Fix the ordering of msix irqs Eric W. Biederman
2007-05-24 21:17 ` Andrew Morton
2007-05-24 21:36 ` Eric W. Biederman [this message]
2007-05-25 2:32 ` Michael Ellerman
2007-05-25 3:04 ` kernel crash in timer interrupt handler gshan
2007-05-24 20:07 ` msi_free_irqs #2 Mike Miller (OS Dev)
2007-05-24 20:53 ` Eric W. Biederman
2007-05-24 21:01 ` Mike Miller (OS Dev)
2007-05-24 21:11 ` Mike Miller (OS Dev)
2007-05-25 3:16 ` [PATCH] msi: mask the msix vector before we unmap it Eric W. Biederman
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=m1d50peweu.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=iss_storagedev@hp.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@ellerman.id.au \
--cc=mikem@beardog.cca.cpqcorp.net \
--cc=tom.l.nguyen@intel.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