diff mbox

PCI: Do not enable INTx in pci_reenable_device()

Message ID 20140311174809.23257.77363.stgit@bhelgaas-glaptop.roam.corp.google.com
State Accepted
Headers show

Commit Message

Bjorn Helgaas March 11, 2014, 5:48 p.m. UTC
Andreas reported that after 1f42db786b14 ("PCI: Enable INTx if BIOS left
them disabled"), pciehp surprise removal stopped working.

This happens because pci_reenable_device() on the hotplug bridge (used in
the pciehp_configure_device() path) clears the Interrupt Disable bit, which
apparently breaks the bridge's MSI hotplug event reporting.

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.

This patch clears Interrupt Disable only when MSI/MSI-X has not been
enabled.

Fixes: 1f42db786b14 PCI: Enable INTx if BIOS left them disabled
Link: https://bugzilla.kernel.org/show_bug.cgi?id=71691
Reported-and-tested-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org
CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
---
 drivers/pci/pci.c |    3 +++
 1 file changed, 3 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Yinghai Lu March 15, 2014, 12:30 a.m. UTC | #1
On Tue, Mar 11, 2014 at 10:48 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> Andreas reported that after 1f42db786b14 ("PCI: Enable INTx if BIOS left
> them disabled"), pciehp surprise removal stopped working.
>
> This happens because pci_reenable_device() on the hotplug bridge (used in
> the pciehp_configure_device() path) clears the Interrupt Disable bit, which
> apparently breaks the bridge's MSI hotplug event reporting.
>
> 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.
>
> This patch clears Interrupt Disable only when MSI/MSI-X has not been
> enabled.
>
> Fixes: 1f42db786b14 PCI: Enable INTx if BIOS left them disabled
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=71691
> Reported-and-tested-by: Andreas Noever <andreas.noever@gmail.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> CC: stable@vger.kernel.org
> CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
> ---
>  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);

looks ugly.

We really should move out those irq handling out of pci_enable_device.

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas March 17, 2014, 4:23 p.m. UTC | #2
On Fri, Mar 14, 2014 at 6:30 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Mar 11, 2014 at 10:48 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> Andreas reported that after 1f42db786b14 ("PCI: Enable INTx if BIOS left
>> them disabled"), pciehp surprise removal stopped working.
>>
>> This happens because pci_reenable_device() on the hotplug bridge (used in
>> the pciehp_configure_device() path) clears the Interrupt Disable bit, which
>> apparently breaks the bridge's MSI hotplug event reporting.
>>
>> 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.
>>
>> This patch clears Interrupt Disable only when MSI/MSI-X has not been
>> enabled.
>>
>> Fixes: 1f42db786b14 PCI: Enable INTx if BIOS left them disabled
>> Link: https://bugzilla.kernel.org/show_bug.cgi?id=71691
>> Reported-and-tested-by: Andreas Noever <andreas.noever@gmail.com>
>> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>> CC: stable@vger.kernel.org
>> CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
>> ---
>>  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);
>
> looks ugly.
>
> We really should move out those irq handling out of pci_enable_device.

OK, I'll watch for your patch.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);