mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: airlied@linux.ie, dri-devel@lists.freedesktop.org
Cc: alex.williamson@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] drm/nouveau: Check that the device is enabled before processing interrupt
Date: Sun, 01 May 2011 18:49:46 -0600	[thread overview]
Message-ID: <20110502004940.2307.71738.stgit@ul30vt.home> (raw)
In-Reply-To: <20110502004806.2307.34136.stgit@ul30vt.home>

We're likely to be sharing an interrupt line with other devices,
which means our handler might get called after we've turned off
the device via vga switcheroo.  This can lead to all sorts of
badness, like nv04_fifo_isr() spewing "PFIFO still angry after
100 spins, halt" to the console before the system enters a hard
hang.

We can avoid this by simply checking if the device is still
enabled before processing an interrupt.  To avoid races, flush
any inflight interrupts using synchronize_irq().  Note that
since pci_intx() is called after pci_save_state(),
pci_restore_state() will automatically re-enable INTx.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 drivers/gpu/drm/nouveau/nouveau_drv.c |    2 ++
 drivers/gpu/drm/nouveau/nouveau_irq.c |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 155ebdc..405d4f1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -230,7 +230,9 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
 	NV_INFO(dev, "And we're gone!\n");
 	pci_save_state(pdev);
 	if (pm_state.event == PM_EVENT_SUSPEND) {
+		pci_intx(pdev, 0);
 		pci_disable_device(pdev);
+		synchronize_irq(drm_dev_to_irq(dev));
 		pci_set_power_state(pdev, PCI_D3hot);
 	}
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_irq.c b/drivers/gpu/drm/nouveau/nouveau_irq.c
index 2ba7265..8fd17e6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_irq.c
+++ b/drivers/gpu/drm/nouveau/nouveau_irq.c
@@ -78,6 +78,9 @@ nouveau_irq_handler(DRM_IRQ_ARGS)
 	u32 stat;
 	int i;
 
+	if (unlikely(!pci_is_enabled(dev->pdev)))
+		return IRQ_NONE;
+
 	stat = nv_rd32(dev, NV03_PMC_INTR_0);
 	if (!stat)
 		return IRQ_NONE;


  parent reply	other threads:[~2011-05-02  0:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02  0:49 [PATCH 0/2] vga switcheroo: Prevent nouveau irq handler from kill the system Alex Williamson
2011-05-02  0:49 ` [PATCH 1/2] vga_switcheroo: Remove unbalanced pci_enable_device Alex Williamson
2011-05-04  3:49   ` Dave Airlie
2011-05-02  0:49 ` Alex Williamson [this message]
2011-05-04  3:50   ` [PATCH 2/2] drm/nouveau: Check that the device is enabled before processing interrupt Dave Airlie
2011-05-04  4:18     ` Alex Williamson
2011-05-04  4:22       ` Dave Airlie
2011-05-04  4:47         ` Alex Williamson
2011-05-04  4:55           ` Dave Airlie

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=20110502004940.2307.71738.stgit@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®