From nobody Sun Nov 24 10:54:58 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2075.outbound.protection.outlook.com [40.107.95.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DFD71925B6 for ; Wed, 6 Nov 2024 07:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879274; cv=fail; b=U60d3ApgUaY617/T6GheXByYPgEXRS1xVyCc9DYRNuetLJUDZahlywJaOAHRDZQYPtLj9C2vJgeCgngcBPcJHBa4YjlrFLYP9FkM9uXFUmItVwZYEhmPOhAuExwDJopWGzGTiqBKH33d+LF6zhd5VkI29pMfOzE7ZgX7xw1RuTI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879274; c=relaxed/simple; bh=Qhv7QEZi41ShZsAlkUuArsp3a9hukc/P+4M0HegnXfw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mutcfx8YYWMbJZ+7aOgxZ0/H+ppfegWix1XFCA8to6Mpy/k5jTeXJHOp03azS7jigcbj0TSOxq47tqePZ9NTNUbEY5HRbWiUWC7mflAxmqfrvGGpdpARftCe2O80LBk2Iwe+7N58niHpYV1E5bA7dXdVVzK5sMjJgtJy2y/1aNo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=cjCN+kN7; arc=fail smtp.client-ip=40.107.95.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cjCN+kN7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o6b7rIpwqMMQJJYKK2RFErxBPu1o09VcMEi0i8csmTE7GiNxcqb+fwIr2Nmc2JuuO67bybv/yfdX4en3LKXZuftnckx3u9e4ITnpGiJiHF49pvweXiAHVjDfQfziONzL+1Aq3a1rReII/jlrWoeBWHQCXyo6rGSuIpaDQFwG110VteWBoA8BYjmKQ4JuOFeTvovbmpYafc0p7+5mw/HIdtNWkXghaE78oKYE7k4DoqM9qV7LYXTg+2IN9QKcZ2Q90qxb59Hi9QL1mcxa60/Fp52hu4CH3g0CxmCQZXv5XQYu7z+4myWINGhEsBXK4F99SNw6wnXlTucVUAdYFZgMog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UfXIwCE677pqTAdMsfVZ19CO4SLVAyEkB8ZT7mdz8Qg=; b=nlnfFQCDQ79BuE/KHEWCCW+YgSFDh4BP4ZWNs0QXc35iJSW+j96T2DxOsSKucDcEN0/NwUInsPNCLU6ZGIitEk8ptv+436ZvBJsVuTLZVYdJQW49AjC35pxb5WKAm1d0KQSIo0hhTAaiLcYXzcTCfgUkb8uIMSC0F+6qfIT9V5j/i0l72Bd0G/nLSasLyHfKAPfjL2Guensdw7MuQNEarABom/rHvmzr0FwpT76ejc3JhCGH65CYlilD15ge/b6dYj7RqOpUAaLmgUs53S2x+YwGJKp/Y/+bTYUdirv6OxuxB5pUdG0uilRQikJ1M8spqdQaYv7y82r+ukFDvRmBUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=8bytes.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UfXIwCE677pqTAdMsfVZ19CO4SLVAyEkB8ZT7mdz8Qg=; b=cjCN+kN7JfIDnb5DL/ltyl5kiTVM85erkrb4zgi2HmLWP6SponuO8EQZNfpgVGwwT0u3xYDH55xv9lXDJSlIU0q3nMk9/skisWpM7w5XlM6rXPwBGdRBLdxGXKQKAKjpjScYkcofzPiED5ypjV2DBF1gK0W7YH2zJItwMRnbKN8= Received: from SJ0PR13CA0021.namprd13.prod.outlook.com (2603:10b6:a03:2c0::26) by MN2PR12MB4224.namprd12.prod.outlook.com (2603:10b6:208:1dd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Wed, 6 Nov 2024 07:47:48 +0000 Received: from CO1PEPF000042AD.namprd03.prod.outlook.com (2603:10b6:a03:2c0:cafe::69) by SJ0PR13CA0021.outlook.office365.com (2603:10b6:a03:2c0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Wed, 6 Nov 2024 07:47:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AD.mail.protection.outlook.com (10.167.243.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Wed, 6 Nov 2024 07:47:47 +0000 Received: from BLR-L-DHSRIVAS.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 6 Nov 2024 01:47:44 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 1/8] iommu/amd: Refactor AMD IOMMU debugfs initial setup Date: Wed, 6 Nov 2024 13:16:32 +0530 Message-ID: <20241106074639.2039-2-dheerajkumar.srivastava@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241106074639.2039-1-dheerajkumar.srivastava@amd.com> References: <20241106074639.2039-1-dheerajkumar.srivastava@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AD:EE_|MN2PR12MB4224:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a6bd462-ad36-4ad4-d4c2-08dcfe374e79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?u3lBCF0uR45yz40GW2ngQuE0GNzx1oszHfc8IeP+CvPLkW3x9BjFpBCifqpZ?= =?us-ascii?Q?r8tkZcxVT0xO9w66lc+CWIG0tqmjQ2AOwVx6SwhzBhor/2xVtozhFlFESMMA?= =?us-ascii?Q?bD+QmcJyG8NiMuT1vmEo+sg4pzmnL57QRUldsjikqBK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KgH94diXNXnw2WVZRWY8usU4VxuxodZ7WJc4dAkvV5Rbg?= =?us-ascii?Q?EACkF8pq11QvfZSi7l/M8X5jN4TJEeGBBkRSs4zDo+KBLco1N0Xvh/VIFtyC?= =?us-ascii?Q?n/5ey8vFVlEa50G9CEbzrABi2LHOOwQ4FDPcI/63TIVN6RmFjm7tveB2j8dB?= =?us-ascii?Q?CaZ396wfrfWiCN3xXt/Zhtwc+NAiI6AHSgTqAw3YBWzlYV/EqMFtCO5x2a1J?= =?us-ascii?Q?Jb3xjKccmYkEiN+wX2ITmg7K+qS8jFHSb2X44HJMy/+M00Ex/yNb1/NYK6L7?= =?us-ascii?Q?4wdL54UUCTKq1M8E5ncriFk8Y8LqYQqvtkuhZqSttp9ErN1u0oJJwMOmSiSx?= =?us-ascii?Q?e7KLkylJkRDz2/btccDmsdsOqODtpW5cKoa1UGlmJ++bGSiOKA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:47:47.0375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a6bd462-ad36-4ad4-d4c2-08dcfe374e79 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4224 Content-Type: text/plain; charset="utf-8" Rearrange initial setup of AMD IOMMU debugfs to segregate per IOMMU setup and setup which is common for all IOMMUs. This ensures that common debugfs paths (introduced in subsequent patches) are created only once instead of being created for each IOMMU. With the change, there is no need to use lock as amd_iommu_debugfs_setup() will be called only once during AMD IOMMU initialization. So remove lock acquisition in amd_iommu_debugfs_setup(). Signed-off-by: Dheeraj Kumar Srivastava Reviewed-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu.h | 4 ++-- drivers/iommu/amd/debugfs.c | 16 +++++++--------- drivers/iommu/amd/init.c | 5 ++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 6386fa4556d9..68821b62730c 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -29,9 +29,9 @@ void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp, size_t size); =20 #ifdef CONFIG_AMD_IOMMU_DEBUGFS -void amd_iommu_debugfs_setup(struct amd_iommu *iommu); +void amd_iommu_debugfs_setup(void); #else -static inline void amd_iommu_debugfs_setup(struct amd_iommu *iommu) {} +static inline void amd_iommu_debugfs_setup(void) {} #endif =20 /* Needed for interrupt remapping */ diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index 545372fcc72f..ff9520e002be 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -13,20 +13,18 @@ #include "amd_iommu.h" =20 static struct dentry *amd_iommu_debugfs; -static DEFINE_MUTEX(amd_iommu_debugfs_lock); =20 #define MAX_NAME_LEN 20 =20 -void amd_iommu_debugfs_setup(struct amd_iommu *iommu) +void amd_iommu_debugfs_setup(void) { + struct amd_iommu *iommu; char name[MAX_NAME_LEN + 1]; =20 - mutex_lock(&amd_iommu_debugfs_lock); - if (!amd_iommu_debugfs) - amd_iommu_debugfs =3D debugfs_create_dir("amd", - iommu_debugfs_dir); - mutex_unlock(&amd_iommu_debugfs_lock); + amd_iommu_debugfs =3D debugfs_create_dir("amd", iommu_debugfs_dir); =20 - snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index); - iommu->debugfs =3D debugfs_create_dir(name, amd_iommu_debugfs); + for_each_iommu(iommu) { + snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index); + iommu->debugfs =3D debugfs_create_dir(name, amd_iommu_debugfs); + } } diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 43131c3a2172..d78dc96bbec3 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -3377,7 +3377,6 @@ int amd_iommu_enable_faulting(unsigned int cpu) */ static int __init amd_iommu_init(void) { - struct amd_iommu *iommu; int ret; =20 ret =3D iommu_go_to_state(IOMMU_INITIALIZED); @@ -3391,8 +3390,8 @@ static int __init amd_iommu_init(void) } #endif =20 - for_each_iommu(iommu) - amd_iommu_debugfs_setup(iommu); + if (!ret) + amd_iommu_debugfs_setup(); =20 return ret; } --=20 2.25.1