From patchwork Mon May 2 00:49:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 746522 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p420p7tH014902 for ; Mon, 2 May 2011 00:51:27 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31FC59EB3A for ; Sun, 1 May 2011 17:51:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E8319EB0C for ; Sun, 1 May 2011 17:49:49 -0700 (PDT) Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p420nlwe009230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 1 May 2011 20:49:47 -0400 Received: from ul30vt.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p420nkfk012403; Sun, 1 May 2011 20:49:46 -0400 From: Alex Williamson Subject: [PATCH 2/2] drm/nouveau: Check that the device is enabled before processing interrupt To: airlied@linux.ie, dri-devel@lists.freedesktop.org Date: Sun, 01 May 2011 18:49:46 -0600 Message-ID: <20110502004940.2307.71738.stgit@ul30vt.home> In-Reply-To: <20110502004806.2307.34136.stgit@ul30vt.home> References: <20110502004806.2307.34136.stgit@ul30vt.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Cc: linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 02 May 2011 00:51:27 +0000 (UTC) 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 --- 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;