* [PATCH RFC 1/4] pci: disable msi/msix at probe time
2015-03-16 17:20 [PATCH RFC 0/4] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin
@ 2015-03-16 17:20 ` Michael S. Tsirkin
2015-03-16 17:59 ` Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 2/4] pci: don't disable msi/msix at shutdown Michael S. Tsirkin
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2015-03-16 17:20 UTC (permalink / raw)
To: linux-kernel
Cc: Bjorn Helgaas, linux-pci, Fam Zheng, Yinghai Lu, Ulrich Obergfell,
Rusty Russell
commit d52877c7b1afb8c37ebe17e2005040b79cb618b0
pci/irq: let pci_device_shutdown to call pci_msi_shutdown v2
attempted to address the problem of kexec getting
started after linux enabled msi/msix for a device,
and drivers being confused by msi being enabled,
by disabling msi at shutdown.
But arguably, it's better to disable msi/msix when kexec
starts - for example, kexec might run after a crash (kdump)
and shutdown callbacks are not always invoked in that case.
Cc: Yinghai Lu <yhlu.kernel.send@gmail.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Cc: Fam Zheng <famz@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/pci/pci-driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 3cb2210..dac6d47 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -305,6 +305,12 @@ static long local_pci_probe(void *_ddi)
*/
pm_runtime_get_sync(dev);
pci_dev->driver = pci_drv;
+ /*
+ * When using kexec, msi might be left enabled by the previous kernel,
+ * this breaks things as some drivers assume msi/msi-x is off at boot.
+ * Fix this by forcing msi off at startup.
+ */
+ pci_msi_off(dev);
rc = pci_drv->probe(pci_dev, ddi->id);
if (!rc)
return rc;
--
MST
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH RFC 1/4] pci: disable msi/msix at probe time
2015-03-16 17:20 ` [PATCH RFC 1/4] pci: disable msi/msix at probe time Michael S. Tsirkin
@ 2015-03-16 17:59 ` Michael S. Tsirkin
0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2015-03-16 17:59 UTC (permalink / raw)
To: linux-kernel
Cc: Bjorn Helgaas, linux-pci, Fam Zheng, Yinghai Lu, Ulrich Obergfell,
Rusty Russell
On Mon, Mar 16, 2015 at 06:20:27PM +0100, Michael S. Tsirkin wrote:
> commit d52877c7b1afb8c37ebe17e2005040b79cb618b0
> pci/irq: let pci_device_shutdown to call pci_msi_shutdown v2
>
> attempted to address the problem of kexec getting
> started after linux enabled msi/msix for a device,
> and drivers being confused by msi being enabled,
> by disabling msi at shutdown.
>
> But arguably, it's better to disable msi/msix when kexec
> starts - for example, kexec might run after a crash (kdump)
> and shutdown callbacks are not always invoked in that case.
>
> Cc: Yinghai Lu <yhlu.kernel.send@gmail.com>
> Cc: Ulrich Obergfell <uobergfe@redhat.com>
> Cc: Fam Zheng <famz@redhat.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/pci/pci-driver.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 3cb2210..dac6d47 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -305,6 +305,12 @@ static long local_pci_probe(void *_ddi)
> */
> pm_runtime_get_sync(dev);
> pci_dev->driver = pci_drv;
> + /*
> + * When using kexec, msi might be left enabled by the previous kernel,
> + * this breaks things as some drivers assume msi/msi-x is off at boot.
> + * Fix this by forcing msi off at startup.
> + */
> + pci_msi_off(dev);
should be
pci_msi_off(pci_dev);
obviously.
Which likely means I pushed a wrong tree
to the test machine again, so this wasn't
tested as I thought it is :(
I'll re-test and repost day after tomorrow,
Fam, can you tweak this manually when you are testing?
I don't want to spam the list.
> rc = pci_drv->probe(pci_dev, ddi->id);
> if (!rc)
> return rc;
> --
> MST
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RFC 2/4] pci: don't disable msi/msix at shutdown
2015-03-16 17:20 [PATCH RFC 0/4] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 1/4] pci: disable msi/msix at probe time Michael S. Tsirkin
@ 2015-03-16 17:20 ` Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 3/4] pci: make msi/msix shutdown functions static Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 4/4] virtio_pci: drop msi_off on probe Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2015-03-16 17:20 UTC (permalink / raw)
To: linux-kernel
Cc: Bjorn Helgaas, linux-pci, Fam Zheng, Yinghai Lu, Ulrich Obergfell,
Rusty Russell
This partially reverts commit d52877c7b1afb8c37ebe17e2005040b79cb618b0:
"pci/irq: let pci_device_shutdown to call pci_msi_shutdown v2"
It's un-necessary now that we disable msi at start, and it actually
turns out to cause problems: some device drivers don't register a level
interrupt handler when they detect msi/msix capability, switching off
msi while device is going causes device to assert a level interrupt
which is never de-asserted, causing a kernel hang.
In particular, this was observed with virtio.
Cc: Yinghai Lu <yhlu.kernel.send@gmail.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Reported-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/pci/pci-driver.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index dac6d47..4746f93 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -456,8 +456,6 @@ static void pci_device_shutdown(struct device *dev)
if (drv && drv->shutdown)
drv->shutdown(pci_dev);
- pci_msi_shutdown(pci_dev);
- pci_msix_shutdown(pci_dev);
#ifdef CONFIG_KEXEC
/*
--
MST
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC 3/4] pci: make msi/msix shutdown functions static
2015-03-16 17:20 [PATCH RFC 0/4] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 1/4] pci: disable msi/msix at probe time Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 2/4] pci: don't disable msi/msix at shutdown Michael S. Tsirkin
@ 2015-03-16 17:20 ` Michael S. Tsirkin
2015-03-16 17:20 ` [PATCH RFC 4/4] virtio_pci: drop msi_off on probe Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2015-03-16 17:20 UTC (permalink / raw)
To: linux-kernel; +Cc: Bjorn Helgaas, linux-pci, Fam Zheng, Yinghai Lu
pci_msi_shutdown and pci_msix_shutdown are now internal to msi.c, drop
them from header and make them static.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/linux/pci.h | 4 ----
drivers/pci/msi.c | 4 ++--
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 211e9da..a34df45 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1209,11 +1209,9 @@ struct msix_entry {
#ifdef CONFIG_PCI_MSI
int pci_msi_vec_count(struct pci_dev *dev);
-void pci_msi_shutdown(struct pci_dev *dev);
void pci_disable_msi(struct pci_dev *dev);
int pci_msix_vec_count(struct pci_dev *dev);
int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
-void pci_msix_shutdown(struct pci_dev *dev);
void pci_disable_msix(struct pci_dev *dev);
void pci_restore_msi_state(struct pci_dev *dev);
int pci_msi_enabled(void);
@@ -1237,13 +1235,11 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev,
}
#else
static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
-static inline void pci_msi_shutdown(struct pci_dev *dev) { }
static inline void pci_disable_msi(struct pci_dev *dev) { }
static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
static inline int pci_enable_msix(struct pci_dev *dev,
struct msix_entry *entries, int nvec)
{ return -ENOSYS; }
-static inline void pci_msix_shutdown(struct pci_dev *dev) { }
static inline void pci_disable_msix(struct pci_dev *dev) { }
static inline void pci_restore_msi_state(struct pci_dev *dev) { }
static inline int pci_msi_enabled(void) { return 0; }
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index c3e7dfc..0e037af 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -908,7 +908,7 @@ int pci_msi_vec_count(struct pci_dev *dev)
}
EXPORT_SYMBOL(pci_msi_vec_count);
-void pci_msi_shutdown(struct pci_dev *dev)
+static void pci_msi_shutdown(struct pci_dev *dev)
{
struct msi_desc *desc;
u32 mask;
@@ -1014,7 +1014,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
}
EXPORT_SYMBOL(pci_enable_msix);
-void pci_msix_shutdown(struct pci_dev *dev)
+static void pci_msix_shutdown(struct pci_dev *dev)
{
struct msi_desc *entry;
--
MST
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC 4/4] virtio_pci: drop msi_off on probe
2015-03-16 17:20 [PATCH RFC 0/4] pci: fix unhandled interrupt on shutdown Michael S. Tsirkin
` (2 preceding siblings ...)
2015-03-16 17:20 ` [PATCH RFC 3/4] pci: make msi/msix shutdown functions static Michael S. Tsirkin
@ 2015-03-16 17:20 ` Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2015-03-16 17:20 UTC (permalink / raw)
To: linux-kernel
Cc: Bjorn Helgaas, linux-pci, Fam Zheng, Yinghai Lu, Rusty Russell,
virtualization
pci core now disables msi on probe automatically,
drop this from device-specific code.
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/virtio/virtio_pci_common.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index a0723d1..f506571 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -501,9 +501,6 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
INIT_LIST_HEAD(&vp_dev->virtqueues);
spin_lock_init(&vp_dev->lock);
- /* Disable MSI/MSIX to bring device to a known good state. */
- pci_msi_off(pci_dev);
-
/* enable the device */
rc = pci_enable_device(pci_dev);
if (rc)
--
MST
^ permalink raw reply related [flat|nested] 6+ messages in thread