From patchwork Tue Mar 8 11:09:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 8531821 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E594C0553 for ; Tue, 8 Mar 2016 11:16:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8AD8201C8 for ; Tue, 8 Mar 2016 11:16:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E444D201BC for ; Tue, 8 Mar 2016 11:16:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adFaE-0005Ym-Bu; Tue, 08 Mar 2016 11:13:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adFaC-0005YM-ST for xen-devel@lists.xen.org; Tue, 08 Mar 2016 11:13:44 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 31/BA-23864-8E3BED65; Tue, 08 Mar 2016 11:13:44 +0000 X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1457435622!1446837!2 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43309 invoked from network); 8 Mar 2016 11:13:43 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-6.tower-31.messagelabs.com with SMTP; 8 Mar 2016 11:13:43 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 08 Mar 2016 03:13:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,556,1449561600"; d="scan'208";a="904838925" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga001.jf.intel.com with ESMTP; 08 Mar 2016 03:13:41 -0800 From: Quan Xu To: xen-devel@lists.xen.org Date: Tue, 8 Mar 2016 19:09:16 +0800 Message-Id: <1457435357-34073-2-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1457435357-34073-1-git-send-email-quan.xu@intel.com> References: <1457435357-34073-1-git-send-email-quan.xu@intel.com> Cc: Dario Faggioli , Jan Beulich , Aravind Gopalakrishnan , Suravee Suthikulpanit , Quan Xu Subject: [Xen-devel] [PATCH 1/2] IOMMU/spinlock: Fix a bug found in AMD IOMMU initialization. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Doing what we do serves as a fix for a bug found in AMD IOMMU initialization. The current code is using spin_lock{_irqsave(), _irqrestore()} to protect pci_get_dev() in the set_iommu_interrupt_handler(). However, this can only be called during AMD IOMMU initialization, with interrupt enabled, so at least it is not necessary to disable interrupts, or save/restore interrupt flag. In order to fix this, we can use just plain spin{_lock(),_unlock()}, instead of spin_lock{_irqsave(),_irqrestore()}. Signed-off-by: Quan Xu CC: Suravee Suthikulpanit CC: Aravind Gopalakrishnan CC: Dario Faggioli CC: Jan Beulich Reviewed-by: Dario Faggioli --- xen/drivers/passthrough/amd/iommu_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c index d90a2d2..a400497 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -778,7 +778,6 @@ static bool_t __init set_iommu_interrupt_handler(struct amd_iommu *iommu) { int irq, ret; hw_irq_controller *handler; - unsigned long flags; u16 control; irq = create_irq(NUMA_NO_NODE); @@ -788,10 +787,10 @@ static bool_t __init set_iommu_interrupt_handler(struct amd_iommu *iommu) return 0; } - spin_lock_irqsave(&pcidevs_lock, flags); + spin_lock(&pcidevs_lock); iommu->msi.dev = pci_get_pdev(iommu->seg, PCI_BUS(iommu->bdf), PCI_DEVFN2(iommu->bdf)); - spin_unlock_irqrestore(&pcidevs_lock, flags); + spin_unlock(&pcidevs_lock); if ( !iommu->msi.dev ) { AMD_IOMMU_DEBUG("IOMMU: no pdev for %04x:%02x:%02x.%u\n",