From patchwork Fri Jan 3 00:08:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3428121 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 54BF7C02DC for ; Fri, 3 Jan 2014 00:08:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AE8E20161 for ; Fri, 3 Jan 2014 00:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A619F20171 for ; Fri, 3 Jan 2014 00:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754279AbaACAIR (ORCPT ); Thu, 2 Jan 2014 19:08:17 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:22081 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbaACAIL (ORCPT ); Thu, 2 Jan 2014 19:08:11 -0500 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s0307bTl011951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jan 2014 00:07:37 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0307alW021909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Jan 2014 00:07:37 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s0307ahb025543; Fri, 3 Jan 2014 00:07:36 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Jan 2014 16:07:36 -0800 From: Yinghai Lu To: "H. Peter Anvin" , Tony Luck , Bjorn Helgaas , "Rafael J. Wysocki" , x86 Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Yinghai Lu , David Woodhouse , iommu@lists.linux-foundation.org Subject: [PATCH v2 02/10] IOMMU: Fix tboot force iommu logic Date: Thu, 2 Jan 2014 16:08:09 -0800 Message-Id: <1388707697-16800-3-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1388707697-16800-1-git-send-email-yinghai@kernel.org> References: <1388707697-16800-1-git-send-email-yinghai@kernel.org> X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Should check dmar_disabled just after tboot_force_iommu. Otherwise when tboot is not used, and intel_iommu=off, and nointrmap still get dmar_table_init() called. that will cause some get_device calling, and it will have some device refcount leaking. Signed-off-by: Yinghai Lu Cc: David Woodhouse Cc: iommu@lists.linux-foundation.org --- drivers/iommu/intel-iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a3eb689..865a65c 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3681,6 +3681,9 @@ int __init intel_iommu_init(void) /* VT-d is required for a TXT/tboot launch, so enforce that */ force_on = tboot_force_iommu(); + if (no_iommu || dmar_disabled) + return -ENODEV; + if (dmar_table_init()) { if (force_on) panic("tboot: Failed to initialize DMAR table\n"); @@ -3707,9 +3710,6 @@ int __init intel_iommu_init(void) return -ENODEV; } - if (no_iommu || dmar_disabled) - return -ENODEV; - if (iommu_init_mempool()) { if (force_on) panic("tboot: Failed to initialize iommu memory\n");