Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1331907iog; Sat, 25 Jun 2022 06:43:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sIkQ/FdDLoBAIApysnJjsDLT3L3h+CNEcqbwIivpL1nZt+4g+wMl3PoF5r8c8TDYRw7lDI X-Received: by 2002:a05:6402:4414:b0:434:f58c:ee2e with SMTP id y20-20020a056402441400b00434f58cee2emr5112196eda.362.1656164625941; Sat, 25 Jun 2022 06:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656164625; cv=none; d=google.com; s=arc-20160816; b=DWvRtooOG6f09oPY1I65aT/7uwR0dJ8VHntdU2UXFTmuR4qu1cERKKGY818Ukv9FK2 Mt2ykk4PNY8+vk2KbFR3v0uq7XN/uNAjJm9b4167LAfMqGhF7+6UXXdnXTAuYB6M3wQM h1uTk/msRes43udQeYy+thZ9nUIm1vxyqQLXlyl3mLZtwe6u5N0e82n/j/tL1NfdmQYA D4Q4I8LEXSlfCXlWDyDCeaCAvk7DMXmLN1INHf2+5vPJJgBmekUAptfGCYCCs9cjsrb3 5diR02gzt+2sHCjrHWNOIQJF+slT2Bm2S/N0zZFju14y/Uj7PbN59qAMnWI2c+vaTqWh EI/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bCgCyPgNcUpJ1XkDgAw9JNby2pF8t1acPORtSyXlq8Q=; b=ikdYgR1pVTGWiOJxJfd8GI3PyKfHSvV7E2v4huIF9Kk4QnXjJ7Krdv97hgC/GorD7T QB/9KZXgP9fhuZE9sMBSfqQ67DS9dQAPuYQz2NkeyCuCEgznZLDJTgGMK+2KVssb79z7 nW7/mcfWl4yQI0GbWdTaJRcF2RjjvlMG5q15vnwvMOvfySW31ex3nQo0beB1NtRCBhB8 v51sgIWSdUjON+/Mhu+29ba4FXJx1v8zL+eoB4MQVfPzqUMqcrV/xlsrquiZskK4+aa1 GObHCFKjp6f+J/ezDtDVISe1pQVVqayulpaL05aEok2CGPonvkdhDBwooK2+KoJQyDLa qhCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=etJULT9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020aa7d817000000b0043574594151si6608844edq.54.2022.06.25.06.43.19; Sat, 25 Jun 2022 06:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=etJULT9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232881AbiFYM4o (ORCPT + 99 others); Sat, 25 Jun 2022 08:56:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbiFYM4n (ORCPT ); Sat, 25 Jun 2022 08:56:43 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A553918357 for ; Sat, 25 Jun 2022 05:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656161802; x=1687697802; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K1A1BNwT+8Hbe6On1W0+Qd4OG/bxND97giqef+O4iOE=; b=etJULT9Imf7c78iqJDbBaoGforgTtyqYIoSrb0AlFsRjVIlUPJqC+QLO Rc/sdZ/YCOijdHXlfzxcnimFe+oxwPP6XqF++JmEO7khR5b7DlCJ45THV ugv01U5NWIC5nZ84Omet4TFAouzgh45SyfLydEEv0HVHfYp4jV0D/39V3 dJtzShdJCrhjmKdnSAi1NiZwbZMx0tYuQ6zbUuUY4lFwOgZIvSUMhNAo3 WSHF9a6RWE+xbZ4veJOxKYeAHioMpTX/Ujpv+WuH8rmUJXbVkLgKmEzR2 yanz7csg3kL3GQfNph3QbTTInwfss0jf+0c1uNgP5B65mJbXOz0lGVxHs w==; X-IronPort-AV: E=McAfee;i="6400,9594,10388"; a="278727983" X-IronPort-AV: E=Sophos;i="5.92,222,1650956400"; d="scan'208";a="278727983" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2022 05:56:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,222,1650956400"; d="scan'208";a="586890393" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga007.jf.intel.com with ESMTP; 25 Jun 2022 05:56:39 -0700 From: Lu Baolu To: Joerg Roedel , Steve Wahl , Kevin Tian Cc: David Woodhouse , Jerry Snitselaar , Mike Travis , Dimitri Sivanich , Russ Anderson , iommu@lists.linux.dev, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v1 4/6] iommu/vt-d: Add VTD_FLAG_IOMMU_PROBED flag Date: Sat, 25 Jun 2022 20:52:02 +0800 Message-Id: <20220625125204.2199437-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220625125204.2199437-1-baolu.lu@linux.intel.com> References: <20220625125204.2199437-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the IOMMU hot-add path, there's a need to check whether an IOMMU has been probed. Instead of checking the IOMMU pointer in the global list, it's better to allocate a flag bit in iommu->flags for this purpose. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/iommu.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 56c3d1a9e155..105a1e7c60d9 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -479,6 +479,7 @@ enum { #define VTD_FLAG_TRANS_PRE_ENABLED (1 << 0) #define VTD_FLAG_IRQ_REMAP_PRE_ENABLED (1 << 1) #define VTD_FLAG_SVM_CAPABLE (1 << 2) +#define VTD_FLAG_IOMMU_PROBED (1 << 3) extern int intel_iommu_sm; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 78b26fef685e..f6d7055cffd7 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1695,6 +1695,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu) } g_iommus[iommu->seq_id] = NULL; + iommu->flags &= ~VTD_FLAG_IOMMU_PROBED; /* free context mapping */ free_context_table(iommu); @@ -2951,6 +2952,7 @@ static int __init init_dmars(void) } g_iommus[iommu->seq_id] = iommu; + iommu->flags |= VTD_FLAG_IOMMU_PROBED; intel_iommu_init_qi(iommu); @@ -3460,7 +3462,7 @@ static int intel_iommu_add(struct dmar_drhd_unit *dmaru) int sp, ret; struct intel_iommu *iommu = dmaru->iommu; - if (g_iommus[iommu->seq_id]) + if (iommu->flags & VTD_FLAG_IOMMU_PROBED) return 0; ret = intel_cap_audit(CAP_AUDIT_HOTPLUG_DMAR, iommu); @@ -3487,6 +3489,7 @@ static int intel_iommu_add(struct dmar_drhd_unit *dmaru) iommu_disable_translation(iommu); g_iommus[iommu->seq_id] = iommu; + iommu->flags |= VTD_FLAG_IOMMU_PROBED; ret = iommu_init_domains(iommu); if (ret == 0) ret = iommu_alloc_root_entry(iommu); -- 2.25.1