Re: [Bug] PCI: Enable INTx if BIOS left them disabled - triggers during rescan

From: Bjorn Helgaas
Date: Mon Mar 17 2014 - 12:36:59 EST


On Tue, Mar 11, 2014 at 6:52 AM, Andreas Noever
<andreas.noever@xxxxxxxxx> wrote:
> On Tue, Mar 11, 2014 at 1:10 AM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>> On Tue, Mar 11, 2014 at 12:10:02AM +0100, Andreas Noever wrote:
>>> On Mon, Mar 10, 2014 at 9:43 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>>> > On Sat, Mar 8, 2014 at 2:55 AM, Andreas Noever <andreas.noever@xxxxxxxxx> wrote:
>>> >> On Sat, Mar 8, 2014 at 2:04 AM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>>> >
>>> >>> If we did that, INTX_DISABLE would be cleared by the first
>>> >>> pci_enable_device() and pci_reenable_device() wouldn't do anything,
>>> >>> leaving it cleared. The resulting state (cleared) would be the same,
>>> >>> but the transitions would be gone, and maybe those are important.
>>> >> Just a quick note: With pci_intx_for_msi removed no hotplug events are
>>> >> ever delivered. Everything else still works though. So it is either a
>>> >> problem specific to Thunderbolt bridges or maybe it just affects
>>> >> hotplug (and PME?) interrupts.
>>> >
>>> > Interesting. This is on a MacBook, isn't it? If you have Mac OS on
>>> > it, is there a way you can do the equivalent of lspci on it? I'm
>>> > curious about whether it sets INTx_DISABLE when it enables MSI.
>>>
>>> lspci -vv and lspci -vv -xxxx attached (yes, someone made a port).
>>>
>>> It looks like Mac OS sets DisINTx for all devices that have MSI
>>> enabled. The only exception is the Thunderbolt controller (no
>>> idea...). But the hotplug bridges all have DisINTx+.
>>
>> OK, thanks. I don't know what to make of that.
>>
>> Here's a possible patch; can you try it out?
>>
>>
>> PCI: Do not enable INTx in pci_reenable_device()
>>
>> From: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
>>
>> Previously we cleared the Interrupt Disable bit in do_pci_enable_device(),
>> which is used by both pci_enable_device() and pci_reenable_device(). But
>> we use pci_reenable_device() after the driver may have enabled MSI or
>> MSI-X, and we *set* Interrupt Disable as part of enabling MSI/MSI-X.
>>
>> The pciehp hot-plug path uses pci_reenable_device() on the hotplug bridge,
>> and clearing its Interrupt Disable bit makes its hotplug event-reporting
>> MSI stop working.
>>
>> Fixes: 1f42db786b14 PCI: Enable INTx if BIOS left them disabled
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=71691
>> Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
>> ---
>> drivers/pci/pci.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index 8dc3e701ec57..79fc89c6c3f3 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -1192,6 +1192,9 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
>> return err;
>> pci_fixup_device(pci_fixup_enable, dev);
>>
>> + if (dev->msi_enabled || dev->msix_enabled)
>> + return 0;
>> +
>> pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
>> if (pin) {
>> pci_read_config_word(dev, PCI_COMMAND, &cmd);
>
> That fixes it.

Thanks for testing this, Andreas. I merged it and it's in Linus' tree now.

Would you mind booting with "pci=earlydump" sometime and attaching the
dmesg to the bugzilla? Your lspci output shows that INTx_DISABLE is
set, and I'm curious about whether it was set by the BIOS or by Mac
OS.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/