From patchwork Fri Aug 5 09:22:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 108626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 01E5CB6F70 for ; Fri, 5 Aug 2011 19:22:24 +1000 (EST) Received: from localhost ([::1]:46834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpGbk-0003vO-Eu for incoming@patchwork.ozlabs.org; Fri, 05 Aug 2011 05:22:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpGbc-0003uy-JN for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpGbY-0000xN-MW for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:22:12 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:53493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpGbY-0000x9-7X for qemu-devel@nongnu.org; Fri, 05 Aug 2011 05:22:08 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 9F5BA48F36; Fri, 5 Aug 2011 18:22:03 +0900 (JST) Received: (nullmailer pid 12292 invoked by uid 1000); Fri, 05 Aug 2011 09:22:03 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Fri, 5 Aug 2011 18:22:03 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 210.128.90.3 Cc: yamahata@valinux.co.jp, mst@redhat.com Subject: [Qemu-devel] [PATCH] pcie/slot: fix hotplug event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When slot status register is cleared, PCIDevice::exp.hpev_notify needs to be cleared. Otherwise, PCIDevice::exp.hpev_notify is never set to false resulting in no more hot plug event once it's raised. Signed-off-by: Isaku Yamahata --- hw/pcie.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/hw/pcie.c b/hw/pcie.c index 39607bf..5c9eb2f 100644 --- a/hw/pcie.c +++ b/hw/pcie.c @@ -175,6 +175,14 @@ static void hotplug_event_notify(PCIDevice *dev) } } +static void hotplug_event_clear(PCIDevice *dev) +{ + hotplug_event_update_event_status(dev); + if (!msix_enabled(dev) && !msi_enabled(dev) && !dev->exp.hpev_notified) { + qemu_set_irq(dev->irq[dev->exp.hpev_intx], 0); + } +} + /* * A PCI Express Hot-Plug Event has occurred, so update slot status register * and notify OS of the event if necessary. @@ -320,6 +328,10 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint8_t *exp_cap = dev->config + pos; uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA); + if (ranges_overlap(addr, len, pos + PCI_EXP_SLTSTA, 2)) { + hotplug_event_clear(dev); + } + if (!ranges_overlap(addr, len, pos + PCI_EXP_SLTCTL, 2)) { return; }