Re: [PATCH] pci: let pci_device_shutdown to call pci_disable_msi

From: Yinghai Lu
Date: Wed Apr 23 2008 - 22:11:21 EST


On Wed, Apr 23, 2008 at 6:22 PM, Yinghai Lu <yhlu.kernel@xxxxxxxxx> wrote:
>
> On Wed, Apr 23, 2008 at 5:17 PM, Michael Ellerman
> <michael@xxxxxxxxxxxxxx> wrote:
> > But does that help us? What if the device driver in the 2nd kernel
> > assumes it's using INTX, when in fact MSI is enabled on the device. In
> > that case none of the MSI code will even be called AFAIK.
>
> ok. for kdump case, if driver can not use msi (?), with pci=nomsi
> we need to call pci_intx_for_msi(dev, 1) at beginning of second kernel.
>
> will produce another patch about that case.

attached kernel should fix second kernel by kdump doesn't have msi
support problem.

anyway kexec path doesn't need attached one, because shutdown in first
kernel already did pci_msi_shutdown and it called pci_initx_for_msi

also long term should teach every driver call pci_intx_for_msi(dev, 1)?

YH
[PATCH] pci/irq: enable INTx in pci_init

in case second kernel that is used by kdump don't have MSI support.

Signed-off-by: Yinghai Lu <yhlu.kernel@xxxxxxxxx>

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 26938da..ca05726 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -269,12 +269,6 @@ static struct msi_desc* alloc_msi_entry(void)
return entry;
}

-static void pci_intx_for_msi(struct pci_dev *dev, int enable)
-{
- if (!(dev->dev_flags & PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG))
- pci_intx(dev, enable);
-}
-
static void __pci_restore_msi_state(struct pci_dev *dev)
{
int pos;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e4548ab..f5b0e50 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1381,6 +1381,13 @@ pci_intx(struct pci_dev *pdev, int enable)
}
}

+/* in case second kernel doesn't have MSI support built-in */
+void pci_intx_for_msi(struct pci_dev *dev, int enable)
+{
+ if (!(dev->dev_flags & PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG))
+ pci_intx(dev, enable);
+}
+
/**
* pci_msi_off - disables any msi or msix capabilities
* @dev: the PCI device to operate on
@@ -1637,6 +1644,7 @@ static int __devinit pci_init(void)
struct pci_dev *dev = NULL;

while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+ pci_intx_for_msi(dev, 1);
pci_fixup_device(pci_fixup_final, dev);
}
return 0;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8f53f4b..d1080d0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -592,6 +592,7 @@ int __must_check pci_set_mwi(struct pci_dev *dev);
int pci_try_set_mwi(struct pci_dev *dev);
void pci_clear_mwi(struct pci_dev *dev);
void pci_intx(struct pci_dev *dev, int enable);
+void pci_intx_for_msi(struct pci_dev *dev, int enable);
void pci_msi_off(struct pci_dev *dev);
int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);