From nobody Sun Nov 24 09:05:34 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 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) (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 9976A3C39 for ; Wed, 6 Nov 2024 07:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879394; cv=fail; b=gNYBmDdTDCS4qt3GoenqN1YjgdK4yFiqcfppt/ZVk9We8mEF5R905gf0fNreJSKPjp4UNZ2hTtCfCwuDiJzDjWvibIVSnBdz1r3brkdcPg3YRKP3kToOhZkTDKSohyuSoanylNuiYNaRvQLzh9iNy+JEuO/hTjHwi1EU2FjCMSU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879394; c=relaxed/simple; bh=7zOXN5ztrkoonuhDdUWHZBFyAt2w3PJ5gROE2e1ki2U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QdUtpVngIEo6p87EYrfaEwWGcP9a0Yyn+Ds6010NrMrzZKLwJcEAkN2SMr7OX9grbtRP82GlgCmBwhiBJ0rSx+dSaAUnIsO6tM1HwpD9GLlX7tUnYZjDnbjCQRgykbSf/KG87dd2lNa5v8tS2zesPqJPkX/Ypnyiv49fampb4yM= 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=tJVN4RdJ; arc=fail smtp.client-ip=40.107.102.61 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="tJVN4RdJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ww4GEj9WRotAzc7ta+wfmJ2wS1ZfsggZDk6KKUmyfCqzDMzqTSP8WNd2ZlwoM+Qy72CzAfrAhmwvnJn/2NgDN1KmWSk8JpBCQNDp4lq34cp2z4yon0RVLKhFmTNDvoCuu0jxBdvPzMYeskxUx3ufIO8jcYxrj+wmsEVbRt6VXGwwJF34IrSSC7iX7v08mpg/1xxoyVxYW9cadys9BbJ89/XiKeXNXFt7aehVZq88JaaJQSfyRLvlGltYQ72YlwHhrtd107oo/lpH5gZdWFuFNCxId03Y3h6qnfvL0ckKZfw6D6st16g+Mije08Uuy9fmLlhiPqIAs0Xw6/feBMa+kA== 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=1/CWWzeaho81nHjNzYsskfRTkPS76/RWJLyDdiCa20k=; b=JLnAs4Ht35Yhr8SVLiKAI61FEGf7QdML0cSP4ocwjom/NcZVCnpQI4eDkdrsdBqyp7L1rKSwYoWKxrucKGOnh4kgD1WpzgEeUPJa/SxU8/55PaI+t6ZUkhlgmOWMfvDeHJwz9nxxs+5XedAMJZ0HV9BucUju1ceoFGsdbDD5Y68KLNNA0noqSVhB/n3HPXutYRas7e24i3WHEJPONLKnCMhpiDY3VdMMwKb1UhIVcqMNHmYJ17NXRGCh9rEuC8EEeUfpRMsnbt7mckljbr9ph3JQoR2jjxpnKX2v8HB8GAQI88Odyf06b8xxE9q2mcVpStR+QmyNEzN5J2dBayGFEg== 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=1/CWWzeaho81nHjNzYsskfRTkPS76/RWJLyDdiCa20k=; b=tJVN4RdJjvsQ/CO46dAKsYlU98s+YI2sU59bC7gMiFBKQWou4HJYd7FQ76imXsIC5HLzllzdDhNsCB6MoHd4Xsog1Gglv4Gpt+Oo+1wc5D0vPoLeEcmOVHWxi6GsFwS0LnJSih0De3BVuLV5bqM35LT5c/w3OQyIfyaklJXlAjo= Received: from CY5P221CA0015.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:b::24) by LV3PR12MB9095.namprd12.prod.outlook.com (2603:10b6:408:1a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 07:49:50 +0000 Received: from CY4PEPF0000E9D2.namprd03.prod.outlook.com (2603:10b6:930:b:cafe::6f) by CY5P221CA0015.outlook.office365.com (2603:10b6:930:b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Wed, 6 Nov 2024 07:49:49 +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 CY4PEPF0000E9D2.mail.protection.outlook.com (10.167.241.137) 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:49:49 +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:48:24 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 2/8] iommu/amd: Add debugfs support to dump IOMMU MMIO registers Date: Wed, 6 Nov 2024 13:16:33 +0530 Message-ID: <20241106074639.2039-3-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: CY4PEPF0000E9D2:EE_|LV3PR12MB9095:EE_ X-MS-Office365-Filtering-Correlation-Id: 1227fb62-e09e-4a73-0d35-08dcfe37975a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3k834RXlvUboPyO1qUr8pNxWZ1ZuEHj0Kv0SmafGCvegPd8/u4YlNyNbQVHp?= =?us-ascii?Q?5ZUoq+1zNHSLyv3fGGU1BP1aRUrNnPiAVdmE99Pi2Ua4r7IfBE05VFKb9q6J?= =?us-ascii?Q?8gwISer8MiUa0Yk+Jj0rKEPXpaz7Tbg1Afx/pHfCZY/B0uM+jBy8/+TMpQp3?= =?us-ascii?Q?EiQrI21kG+PQXpUocyjGn4RTVahTdRb6EQj1qnvAupkLqHIibcxAGzMi7KY4?= =?us-ascii?Q?FJQn0vJaGKKwmWasfepV2/RbQmsXaZXQi8Y6oLJyuSTOXByBtV/c+/eYUkoA?= =?us-ascii?Q?WZIW9LQqzp1h+WfhKIg3jlEIBZ+zkAy7O8I/DVwW0iqQHZqKSFRDTwmvht0F?= =?us-ascii?Q?kZcodnMqTtlUAyfVV+QhlnfkspPvNWYLLD4dwrgYJsE6uIHwk8sw7Ph9ruiF?= =?us-ascii?Q?gTtBAZZ5KHhSnEMqZXrMayHfFU6CH03dqI8L6FbvKQFVOfNl7Bzxfgpvgj0L?= =?us-ascii?Q?tO+gReq5r5cWMOxlC9p8Ola73qIiByc/p6z9CA+lqSi/Li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aU27rhPfwTr33jcQKvFIfPTicqBLugj5PM1v1Q=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)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:49:49.3341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1227fb62-e09e-4a73-0d35-08dcfe37975a 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: CY4PEPF0000E9D2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9095 Content-Type: text/plain; charset="utf-8" Analyzing IOMMU MMIO registers gives a view of what IOMMU is configured with on the system and is helpful to debug issues with IOMMU. eg. 1. To get mmio registers value for iommu # echo "0x18" > /sys/kernel/debug/iommu/amd/iommu00/mmio # cat /sys/kernel/debug/iommu/amd/iommu00/mmio_dump Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/debugfs.c | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index ff9520e002be..e56c050eb7c8 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -15,6 +15,59 @@ static struct dentry *amd_iommu_debugfs; =20 #define MAX_NAME_LEN 20 +#define OFS_IN_SZ 8 + +static int mmio_offset =3D -1; + +static ssize_t iommu_mmio_write(struct file *filp, const char __user *ubuf, + size_t cnt, loff_t *ppos) +{ + struct seq_file *m =3D filp->private_data; + struct amd_iommu *iommu =3D m->private; + int ret; + + if (cnt > OFS_IN_SZ) + return -EINVAL; + + ret =3D kstrtou32_from_user(ubuf, cnt, 0, &mmio_offset); + if (ret) + return ret; + + if (mmio_offset > iommu->mmio_phys_end - 4) { + mmio_offset =3D -1; + return -EINVAL; + } + + return cnt; +} + +static int iommu_mmio_show(struct seq_file *m, void *unused) +{ + if (mmio_offset >=3D 0) + seq_printf(m, "0x%x\n", mmio_offset); + else + seq_puts(m, "No or invalid input provided\n"); + + return 0; +} +DEFINE_SHOW_STORE_ATTRIBUTE(iommu_mmio); + +static int iommu_mmio_dump_show(struct seq_file *m, void *unused) +{ + struct amd_iommu *iommu =3D m->private; + u32 value; + + if (mmio_offset < 0) { + seq_puts(m, "Please provide mmio register's offset\n"); + return 0; + } + + value =3D readl(iommu->mmio_base + mmio_offset); + seq_printf(m, "0x%08x\n", value); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(iommu_mmio_dump); =20 void amd_iommu_debugfs_setup(void) { @@ -26,5 +79,10 @@ void amd_iommu_debugfs_setup(void) for_each_iommu(iommu) { snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index); iommu->debugfs =3D debugfs_create_dir(name, amd_iommu_debugfs); + + debugfs_create_file("mmio", 0644, iommu->debugfs, iommu, + &iommu_mmio_fops); + debugfs_create_file("mmio_dump", 0444, iommu->debugfs, iommu, + &iommu_mmio_dump_fops); } } --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2044.outbound.protection.outlook.com [40.107.212.44]) (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 F11AB3C39 for ; Wed, 6 Nov 2024 07:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879434; cv=fail; b=fPJycqGaB9ProUKIWgLKI+OFdCwBEhZ6ri3VzR2BvK70ZyD7IXKqdvN47Y8+SqmCDM8SzaCCG02LeVz86RnZrapWaKrC5wMM93i0c0+QqAouWE3adl5esg29iC9B4M5Uu0yRMWSFKymrlFpYSTaNXMXCKuFIT3MZUB38OV4Bd8k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879434; c=relaxed/simple; bh=BQ2J9COjiYSpe8tcV4yuwpvF2XtyuT6iau+YFDIV+lE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fG6OpnyPqsOn3XfaB3Kg0u0gp90WMqTfS4nonYPUecsaN3uFLV8VG8eUj/OPGsQdcvQ4RgFFAlWhXndoT0pypTSC0v1ylHYiCK3TZVck11szi2X1BW8G0tL9oyedfRTsFqTlMrLzuf8iNzOzO8YWQshp0Z5Va5J/o1bP0erJGGw= 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=Jxl4ecwr; arc=fail smtp.client-ip=40.107.212.44 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="Jxl4ecwr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I09nR5bcubhNNXPe4WmOeanWa/cpDP8AyWxzFFiOfCasoxFUMFQ+EnUDrv4cTtSfERYoBxw1knHsBzbQ74EkxjB8ELG7yLWOqAoUz+Cp4XtMBrEoiFVvvXsuV+joaPlRNvuSbnm6KqA/f5Zxa6R9QtjqHG7fXEeELuSoVU4TgSQYTNYl1dMuZ5TqagRpXrXI+6S2vVRfms/SaEkc7jt977V+ndBrHHJZRfdhOdYrytxUg9ZgzagPWTFNc48ukZVfoJ26/TJALMN/Wpn4kVmeOWx0K0vQQuUreAVR5Kc7tPW4toI1dT3FW6RB012499kUTPnFWGmQoUVqK/q5pO/IiQ== 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=s9Zo8f7Rlb9XgiIbe1Raf5YJ92b31m7BGHGh6v690aM=; b=Ev/C6EcpTLL4YJ29rDGGIJPLAf2YdOIMZcGgJ49dBqAYw1Wkdcsl4u0WYhEjzrq0pRlWactSucG0S7bX2cuM9l/PfPwtcMlBelY0x7Jwi586ZLjdVEyBVamVtoU03MfelA8diiqG5v+UgR+w5zTYqWtaJ5MAnhhUL48i8Fz7YAr9Bl0tHvzLaJ4NM30yHe7wJxtG+fXz150ZItn2ZwFNrdsZiBfgsd/jsCgU/e4qAn8cp4Ll+ReS1VOfuv6HB0GrcP2w0R6eK/khNVJqoTct9qF/QY/48D7I9VlGwtJJBkVAALBMmUE4n1dEtr0u2LChDjwN+0lP2haABuJXjuaL3w== 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=s9Zo8f7Rlb9XgiIbe1Raf5YJ92b31m7BGHGh6v690aM=; b=Jxl4ecwrVPn1GVNm8uAx5U7wqBNWv6at7bKXE4rE4EW/0hMEqesup6PBkEjtGrwm4VUF6zA3VBy0tHNUyHMEXzQeTuRlplKb9CgZEwqtSk8wBTCu+mYJ9FV3KaPnWMhTqMxmVoYbGEqgPw0J5CftCMb4YiLq6Z4ChwEJPf0o86o= Received: from CY5P221CA0024.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:b::27) by DM6PR12MB4235.namprd12.prod.outlook.com (2603:10b6:5:220::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Wed, 6 Nov 2024 07:50:29 +0000 Received: from CY4PEPF0000E9D2.namprd03.prod.outlook.com (2603:10b6:930:b:cafe::f2) by CY5P221CA0024.outlook.office365.com (2603:10b6:930:b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Wed, 6 Nov 2024 07:50:29 +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 CY4PEPF0000E9D2.mail.protection.outlook.com (10.167.241.137) 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:50:29 +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:49:49 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 3/8] iommu/amd: Add debugfs support to dump IOMMU Capability registers Date: Wed, 6 Nov 2024 13:16:34 +0530 Message-ID: <20241106074639.2039-4-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: CY4PEPF0000E9D2:EE_|DM6PR12MB4235:EE_ X-MS-Office365-Filtering-Correlation-Id: 97d4d38b-4e6c-43f5-5b4b-08dcfe37af55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wFzfUXTajB/CoKKRKHG+F/q6T9xAS2475nGRekPemqMB+PxCkQOhvujIEp7L?= =?us-ascii?Q?QK2QopS/8S1GuCsrm6hzAwsb+pZG+Fb72jHere1QA21TmBDGVa0/MiM5NcoN?= =?us-ascii?Q?+Q1GpXS0kcOJdG3mhnCSmMksLNAbu4j+uavzRUYRQZ+QIvqg6Tp2HR6WSfj/?= =?us-ascii?Q?Tvhb/9bPr7Q3CQE2WPGSlK+s6djIuulBkbq5VZXOSY+8HfjBxmjdYva3l1KX?= =?us-ascii?Q?EyHzSEEGGQYotsWbir5Z19Xx8BQgIwCI9eqyP5775UAFGUQYPE8HeEj+ZTG/?= =?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FIWCMBzO5rmIKOdU+tAF5c3wl?= =?us-ascii?Q?3Wwf6rl2dGUvEOJ0IIcwURoHmt3oTwvSm2pMmo3yizZ7rbMEUWc/CpuqAM12?= =?us-ascii?Q?WjEkUYt/puBn0AasHItcBlXPAy3tf/iimKiPPXEuSrlHeasRmiAlfgd59U1W?= =?us-ascii?Q?UAqJ48s7F/yBQ/m8/JRkt7UPkV/bqX1SmhHl+z/CN3DX5ywh8L36Q6QawYUH?= =?us-ascii?Q?NDRyJK7l1Zaxh4x6YddIC3bUyQgcdMwY0kNadi3WwrFzcp/Q7Q=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)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:50:29.5374 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97d4d38b-4e6c-43f5-5b4b-08dcfe37af55 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: CY4PEPF0000E9D2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4235 Content-Type: text/plain; charset="utf-8" IOMMU Capability registers defines capabilities of IOMMU and information needed for initialising MMIO registers and device table. This is useful to dump these registers for debugging IOMMU related issues. e.g.To get capability registers value for iommu # echo "0x10" > /sys/kernel/debug/iommu/amd/iommu00/capability # cat /sys/kernel/debug/iommu/amd/iommu00/capability_dump Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/debugfs.c | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index e56c050eb7c8..25a4e738d067 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -18,6 +18,7 @@ static struct dentry *amd_iommu_debugfs; #define OFS_IN_SZ 8 =20 static int mmio_offset =3D -1; +static int cap_offset =3D -1; =20 static ssize_t iommu_mmio_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) @@ -69,6 +70,61 @@ static int iommu_mmio_dump_show(struct seq_file *m, void= *unused) } DEFINE_SHOW_ATTRIBUTE(iommu_mmio_dump); =20 +static ssize_t iommu_capability_write(struct file *filp, const char __user= *ubuf, + size_t cnt, loff_t *ppos) +{ + int ret; + + if (cnt > OFS_IN_SZ) + return -EINVAL; + + ret =3D kstrtou32_from_user(ubuf, cnt, 0, &cap_offset); + if (ret) + return ret; + + /* Capability register at offset 0x14 is the last IOMMU capability regist= er. */ + if (cap_offset > 0x14) { + cap_offset =3D -1; + return -EINVAL; + } + + return cnt; +} + +static int iommu_capability_show(struct seq_file *m, void *unused) +{ + if (cap_offset >=3D 0) + seq_printf(m, "0x%x\n", cap_offset); + else + seq_puts(m, "No or invalid input provided\n"); + + return 0; +} +DEFINE_SHOW_STORE_ATTRIBUTE(iommu_capability); + +static int iommu_capability_dump_show(struct seq_file *m, void *unused) +{ + struct amd_iommu *iommu =3D m->private; + u32 value; + int err; + + if (cap_offset < 0) { + seq_puts(m, "Please provide capability register's offset\n"); + return 0; + } + + err =3D pci_read_config_dword(iommu->dev, iommu->cap_ptr + cap_offset, &v= alue); + if (err) { + seq_printf(m, "Not able to read capability register at 0x%x\n", cap_offs= et); + return 0; + } + + seq_printf(m, "0x%08x\n", value); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(iommu_capability_dump); + void amd_iommu_debugfs_setup(void) { struct amd_iommu *iommu; @@ -84,5 +140,9 @@ void amd_iommu_debugfs_setup(void) &iommu_mmio_fops); debugfs_create_file("mmio_dump", 0444, iommu->debugfs, iommu, &iommu_mmio_dump_fops); + debugfs_create_file("capability", 0644, iommu->debugfs, iommu, + &iommu_capability_fops); + debugfs_create_file("capability_dump", 0444, iommu->debugfs, + iommu, &iommu_capability_dump_fops); } } --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2082.outbound.protection.outlook.com [40.107.243.82]) (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 6E1691990A2 for ; Wed, 6 Nov 2024 07:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879436; cv=fail; b=dUUJ5dQdQQG6l8ogKdG410kj/B1vzNjG9dPBjVKu3Gf4CK8W+p7jEvF9ShLFrY5SkgGV4/lWFVxyMUHKWm781Pz0xilObMSn+pZ61Z5DbQJ9sgQxBtHqk0YiTMy3YRJilaswJbL/F5+R+fxHjd6iiidpvqFT6icUfk9rNGjxE3k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879436; c=relaxed/simple; bh=qMsHQ37gVCNsoHAb8W+RedTFXV/HyVp1USok4xZS1Pc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WKMcRzXqvys04wym9IcV8K8fzKtAm5tY+AWdNIkH8Bu9KYWAGHrOEnwHcR8AHqxdX2zOUC2YlB0vE68B55N9RK3WxwxHAgwuDjGGkOWXY7nAf9QDRwve7q16mIoN5wM5+esMX1yyMAlQyEE72MUDWmF9w2TcfKDCxDLnDauqNOw= 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=qB9+99x7; arc=fail smtp.client-ip=40.107.243.82 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="qB9+99x7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o4nWjto0upwY/SXp4Xb7XktEYCCuGLPbZvTk9VI+OfrbL+cZd9HHDqk4o+u8tEPiXvTF3lhIbkYyAvn8fBKuJoHkX34fA/I86NOEUuhTDT1UUvyRvo++lAcqL0CadylD/+dnEpJ2XwygeiOxL59AyAlS7PJdxEDZ8anl+JlobTXPKn81Y3Y12B/7/hIECGCpdzZFSLG/abABbIU/QjZyU5OOwthkha/+wqcZCBPAfhMUYq+QCSP14aA9c+PEytTqgAixxd8WkO+QN9gv1L9c3ZeELtRlsxhBY3+dIdf9lfYbjw+XEcJrv9WbL1jrcYNmMEYzaMYmUe3ItY8MvfUitA== 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=kcDFi2rcHi7bfboOa5cidGxOzLO+zzqDN1TYuxgUSTw=; b=emATzknFp0hsBcRcJbqT3jbBPqb9q/qg6taQd94NThdMpM/pddj1L3qPBJTWqB5LLNvjXgKfhGo8XOGSyJzwj9wDHjC7iMRlCew6RwOgcsbEWp1xfVlgNIVwukPcq8t5Dbr4z5Z+ox53IX7qt/2WJYOsOfhh13rYGkM5Fz9/zFDaIqrHngm2tJzRjKyqZAYNqms/r+J8C2Sf8eqz20zl9hfLOGusEfxZVGM60iOaLmSoZfZA+qjld7pSqgJ8cVZEycbgi+4OxY5CdYrHAPhFo+tpJDjhefKFEYzB/fKoNtImz5v+xQYFbyQbW49dUqhHSb6ekV5nhu+6iZnJNmd4sg== 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=kcDFi2rcHi7bfboOa5cidGxOzLO+zzqDN1TYuxgUSTw=; b=qB9+99x7guRdVmgaEwwZov6/FJ3IxWmumTO1XTP0G1v38ZxtZp8ZQioj3OjgvplsgoWlVZYKyKNQL2woPR1Fy5f+VE+DOJe6836HGqu0cPt9Jw/ESPrGuiJh7akt+ZvP4Yypuh8d8l5cOFikFQil3XYj8pd9oChEPG3uvwVlG/o= Received: from BN0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:408:e6::14) by MN0PR12MB5715.namprd12.prod.outlook.com (2603:10b6:208:372::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.33; Wed, 6 Nov 2024 07:50:32 +0000 Received: from BL6PEPF0001AB74.namprd02.prod.outlook.com (2603:10b6:408:e6:cafe::6b) by BN0PR03CA0009.outlook.office365.com (2603:10b6:408:e6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29 via Frontend Transport; Wed, 6 Nov 2024 07:50:31 +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 BL6PEPF0001AB74.mail.protection.outlook.com (10.167.242.167) 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:50:31 +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:50:28 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 4/8] iommu/amd: Add debugfs support to dump IOMMU command buffer Date: Wed, 6 Nov 2024 13:16:35 +0530 Message-ID: <20241106074639.2039-5-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: BL6PEPF0001AB74:EE_|MN0PR12MB5715:EE_ X-MS-Office365-Filtering-Correlation-Id: e283a586-7720-4e5e-3a93-08dcfe37b09e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KCUEdxQ+P97caq07M4SLKx2JHfVoYdzdEyt1HE6ZUU7LtVPU0YHk0CIZW3ra?= =?us-ascii?Q?D22W4hnySsmWUCiYDJO5g4Eb4AUniJHO2vqmTuZYwQdHaIFPOKQhZxMf9Gw6?= =?us-ascii?Q?Lrc/OcxE53F5Qd5re6heiQlCGgFX0t+itje7EbaMyNKMsv2ie3Npl0TdBLBb?= =?us-ascii?Q?qZ9T3XBCFV3uzPZhkQg6rMo0j0LJomeNyj4NFTHeUCmgGk0Hv5ovFk9fyd+u?= =?us-ascii?Q?ps9n5eJSE3GgS7RStE72R3/Q5nAxCoH5Kioptd+U4BAAxLG1zF7GqMjq01VN?= =?us-ascii?Q?TA9LrZE9f82u7Jn2pwmkJDwB+BMbzwT2uRN2HGSymjODLaSgxviyMKo+LSyd?= =?us-ascii?Q?H3NTwIgZXjDVSoJLD0QLYqkA7Lg872FLQKrxU7VyKPYDhc28Qh58g8HUKHDX?= =?us-ascii?Q?TLjmCtUNdFTf4sq8HdJ612j8yuqVSraov/PthI8p2Y8DZhBDwCNz4eIZDMWo?= =?us-ascii?Q?oL8vA4Hoq0YzbNDOecGs826PEiDzSp+j6EChIrSLCMjYeNROuYizChMgXkQi?= =?us-ascii?Q?W8VF72meUJEd0iG73frse/JK8r8go8nduYMG6pYtNWV0ejj3LLb/YOm55XW7?= =?us-ascii?Q?HkboRRd85zXlMmablFbkPzS64xGCSeoUQdXDgmAHifRlLKKjMRh2bxjoln2S?= =?us-ascii?Q?T6jUWkEmda6wQ5pfPU+qRRHuALN4emKzw7o8mKJs/ht0jYKo9iaQ/S/J9fyP?= =?us-ascii?Q?hByL4pBy4xbGHSi9T7RlJogXgWxCXng6CtwBLKDWEblgLdZsf5qRGgi5Ruze?= =?us-ascii?Q?DqiLn+riwnpgXok4TjqlGeFdK40Xt8ZNzOu8jqOqfaLU9vqz4hcP9OPvp0ih?= =?us-ascii?Q?TtEzIwnxZzOUoegdip5kfuPKks25zz60zKF6jVwBeES3KTrglB+phUkN96Al?= =?us-ascii?Q?H5fluW4TR0YhI/2LJyCmY6AvRL2m67PFbqNVffnilIxcHzBvfv7Jud/hA3C6?= =?us-ascii?Q?TjJcW5FOaDaNfWs0D/nRFzEmqo8dtIcZQDdR6zfAPX9OQ31tXIvibThbFZkm?= =?us-ascii?Q?7XbPtl7/cDTiAgkIH9wZW8RGitL7yqVCUETtXM2YTSp22jk/GEUxvsUyrnbU?= =?us-ascii?Q?yZEbeTtT2FgnVEvfJjXWZ8V7rkeqCmC0CWvtLWOUC7uCN95nv5W6J8ADETiQ?= =?us-ascii?Q?qWOvZW2N2tuPcnSbnUt14C8rlJ+t68jPJMt1LjxyvVTXCPyk0L9WehAjg/y+?= =?us-ascii?Q?CjGkbIoGmdO1lxrco0WsojLfjjfb2l3ccPv19rae3n7E0xRH82c4ixZqHeEG?= =?us-ascii?Q?6jAgHaoewEk0gPM8N51zGCy5sIKQsUuPsLsCwR/duKCyRBzjTyGznJn90Lqz?= =?us-ascii?Q?lwd/k4Tb9/LTPcdyiVKmqv+H2eOdlJeXEklllQhXPHSg7ClJsJV2cXIFAktk?= =?us-ascii?Q?ECbNoBgQ1kXyZDdglmBl9pHqcEKNvHma+wJg4sgLdkYly79Kbg=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)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:50:31.8490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e283a586-7720-4e5e-3a93-08dcfe37b09e 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: BL6PEPF0001AB74.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5715 Content-Type: text/plain; charset="utf-8" IOMMU driver sends command to IOMMU hardware via command buffer. In cases where IOMMU hardware fails to process commands in command buffer, dumping it is a valuable input to debug the issue. IOMMU hardware processes command buffer entry at offset equals to the head pointer. Dumping just the entry at the head pointer may not always be useful. The current head may not be pointing to the entry of the command buffer which is causing the issue. IOMMU Hardware may have processed the entry and updated the head pointer. So dumping the entire command buffer gives a broad understanding of what hardware was/is doing. The command buffer dump will have all entries from start to end of the command buffer. Along with that, it will have a head and tail command buffer pointer register dump to facilitate where the IOMMU driver and hardware are in the command buffer for injecting and processing the entries respectively. Command buffer is a per IOMMU data structure. So dumping on per IOMMU basis. eg. To get command buffer dump for iommu #cat /sys/kernel/debug/iommu/amd/iommu/cmdbuf Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/amd_iommu_types.h | 7 +++++++ drivers/iommu/amd/debugfs.c | 26 ++++++++++++++++++++++++++ drivers/iommu/amd/iommu.c | 7 ------- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_io= mmu_types.h index 601fb4ee6900..876fa671ef91 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -878,6 +878,13 @@ extern struct list_head amd_iommu_list; */ extern struct amd_iommu *amd_iommus[MAX_IOMMUS]; =20 +/* + * Structure defining one entry in the command buffer + */ +struct iommu_cmd { + u32 data[4]; +}; + /* * Structure defining one entry in the device table */ diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index 25a4e738d067..1b989d45257f 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -125,6 +125,30 @@ static int iommu_capability_dump_show(struct seq_file = *m, void *unused) } DEFINE_SHOW_ATTRIBUTE(iommu_capability_dump); =20 +static int iommu_cmdbuf_show(struct seq_file *m, void *unused) +{ + struct amd_iommu *iommu =3D m->private; + struct iommu_cmd *cmd; + unsigned long flag; + u32 head, tail; + int i; + + raw_spin_lock_irqsave(&iommu->lock, flag); + head =3D readl(iommu->mmio_base + MMIO_CMD_HEAD_OFFSET); + tail =3D readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET); + seq_printf(m, "CMD Buffer Head Offset:%d Tail Offset:%d\n", + (head >> 4) & 0x7fff, (tail >> 4) & 0x7fff); + for (i =3D 0; i < CMD_BUFFER_ENTRIES; i++) { + cmd =3D (struct iommu_cmd *)(iommu->cmd_buf + i * sizeof(*cmd)); + seq_printf(m, "%3d: %08x%08x%08x%08x\n", i, cmd->data[0], + cmd->data[1], cmd->data[2], cmd->data[3]); + } + raw_spin_unlock_irqrestore(&iommu->lock, flag); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(iommu_cmdbuf); + void amd_iommu_debugfs_setup(void) { struct amd_iommu *iommu; @@ -144,5 +168,7 @@ void amd_iommu_debugfs_setup(void) &iommu_capability_fops); debugfs_create_file("capability_dump", 0444, iommu->debugfs, iommu, &iommu_capability_dump_fops); + debugfs_create_file("cmdbuf", 0444, iommu->debugfs, iommu, + &iommu_cmdbuf_fops); } } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 8364cd6fa47d..efc2d1ddd7cc 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -63,13 +63,6 @@ static const struct iommu_dirty_ops amd_dirty_ops; =20 int amd_iommu_max_glx_val =3D -1; =20 -/* - * general struct to manage commands send to an IOMMU - */ -struct iommu_cmd { - u32 data[4]; -}; - struct kmem_cache *amd_iommu_irq_cache; =20 static void detach_device(struct device *dev); --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2056.outbound.protection.outlook.com [40.107.95.56]) (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 BD8583C39 for ; Wed, 6 Nov 2024 07:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879496; cv=fail; b=qmsbFrQPU99fclJG7CLByOg9thuSHHxkwGnrSBOnqNJ+AWewNM9hbYJ93xdqDLmhH2sDs4rbMLs8WUGjGEx0nU/Poi2tjfIH8UcUsD4qzgamBFCEx5RnCMPKn+4X7pAu/voKhitzak1XH3un2cP5A0H0BHtqKpesjKYPEVll/vY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879496; c=relaxed/simple; bh=/LDZyGGxEELIJZQm7PbfxUb4DWbeld4CFr5E9aG3AEw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GeMs/R0O6VOv/coQEEzBRQppi4ZpwxFuJnpiStFX5u+SoYOcLmDsdQhLf7a6IpauGvjv/cyX+YffP5aEcFdzk7ZNh4MZEwldnAr+o0uahH1xz0ty5w521i0FhP1DSD8a3HUXfMrdmG74Eux/WMXBPh69s6BtYZE+QohU0Rk6Yk0= 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=MCnJ1Ueu; arc=fail smtp.client-ip=40.107.95.56 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="MCnJ1Ueu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=exms6EvIKAxW5Tux2BvbZEmgOuD9jAviwcar6r9vl+9M/aRS1++KKiL1bpsqwXpAhQ3xuGxdWifjYaicsZhD9J7s9q2W1Kuhd0t9lNdOxKHxVDPEwqbnkyi1926j5GJYYWMi39jK0iyofdN9oC61EEcIx8De1kUQ+5/mS+01K/pUT3x7ZzIZSmY4O1op8mAlgiS4rXRWKnplvOmg/Sa417kQ6sWls6tk6+Y0UPGIu5qkwuijehN6toinMExNG7s8fyU2eoakXxoYp5bDFe2194sneTkwawknrP3IRcncgnAQGqKGwT0xI0WbYnl1ZNzRIcvxvb+uB6YkZd4UDO0hhg== 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=sVlORpGaMUil+yRrsDcvB3yKWK4DNSB2t7wEeFQ1fPY=; b=ly3NIBeDSKpPIq7adYEyKPRj9EOorE2er4U764K2L2W/I1LlINZ0Ghit2t+kN4Zx8N+jps1xXMH2qqu30vgJvE55g53XO+HErgCZvp9ChqYd6Ahdlc4a9PfL5DdpaiVuiVr2eEG5RGfoZAVK1yJeMlfCGqr6JhNQFLznvCBwMAdVVuW0SkUHvOdcqhpGiUGI0tSThteWI8JuUBEK3gpUQee4jR7CLNH3DDm1S67F7VnJBAmCD+2masiNPJ9k5vNR5t4gu5FcufCvNr1B1C80z34JWAKDQ7d5bRHqZmDD44HDcLWZCleogDOQeywHkLmhbX97SSzaBRGGOrPgAeyURg== 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=sVlORpGaMUil+yRrsDcvB3yKWK4DNSB2t7wEeFQ1fPY=; b=MCnJ1UeuIv6NJgYYHjsXTgPf4IG+cAkBOIYpoLXA/poEVgPV4Piq2EKUnFNlJv4F9mbDjAUCYDlhzSK0sKwqvhD3tmsKTpzkSvWRn+XeHH73h9f/JrPtlJnmtSWGpvOd5i+JLFBKRINLfjAyfDAEjWvrlyC4gevcr7PO7J0p1CU= Received: from BN9PR03CA0654.namprd03.prod.outlook.com (2603:10b6:408:13b::29) by IA1PR12MB6601.namprd12.prod.outlook.com (2603:10b6:208:3a3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Wed, 6 Nov 2024 07:51:32 +0000 Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:408:13b:cafe::3d) by BN9PR03CA0654.outlook.office365.com (2603:10b6:408:13b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Wed, 6 Nov 2024 07:51:31 +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 BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) 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:51:31 +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:50:56 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 5/8] iommu/amd: Add support for device id user input Date: Wed, 6 Nov 2024 13:16:36 +0530 Message-ID: <20241106074639.2039-6-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: BL6PEPF0001AB73:EE_|IA1PR12MB6601:EE_ X-MS-Office365-Filtering-Correlation-Id: 8455d040-4b24-4b8c-6a3e-08dcfe37d440 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HN1BLcZUaZVDyZULG+1F2VYv+v4i6wHJyPy2OelR1d3fM9eLHz5oAqkU517L?= =?us-ascii?Q?cT7vgfvad2WizwL+KaxWNZUYpTIhV1D4sdr/7BQkDrq+V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FXAPOyaskGBVP283qGHvVSg2CwfqhwLXr5fQMyB?= =?us-ascii?Q?HvS/JYEfPUU2wtoMtlyO2UlOduw+JNDE+z6oZMkib1s3XJB7bPQzuXddl7CV?= =?us-ascii?Q?T5VOETfsUpspbnqhvReZqcOtolZ1kqEYGejw8f7uDhOiHsIm9E9+tvZFxF/R?= =?us-ascii?Q?H2z/eQkcJ3il6/r3k2+O1GA6tyJ+jG8ad/qv0DmT5EwMbil3ZzlOF3UNhAFi?= =?us-ascii?Q?D3EsWIXWHKpA3+MVd/sk/NGwa9Ab4w00glBNB+UR7xoguWEBuYsnuIJUtX5t?= =?us-ascii?Q?OUfUfps5tAZmEIx7/YyGMAX2wb3h2yhN8c3AuQmc9DqZWOMtHobpkjqah8dU?= =?us-ascii?Q?ehoH5w9ktf7WIzGze6tZ6zma53tvmnZRarY0t82/CArrauADlqroBE/eYAf9?= =?us-ascii?Q?y9OkA5xEMjnOA/3YeC+wIsGzS8X9Cj1QVM+fbh9N2xA1EgGNGw=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)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:51:31.5540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8455d040-4b24-4b8c-6a3e-08dcfe37d440 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: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6601 Content-Type: text/plain; charset="utf-8" Device id user input is needed for dumping IOMMU data structures like device table, IRT etc in AMD IOMMU debugfs. eg. 1. # echo 0000:01:00.0 > /sys/kernel/debug/iommu/amd/devid # cat /sys/kernel/debug/iommu/amd/devid Output : 0000:01:00.0 2. # echo 01:00.0 > /sys/kernel/debug/iommu/amd/devid # cat /sys/kernel/debug/iommu/amd/devid Output : 0000:01:00.0 Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/debugfs.c | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index 1b989d45257f..74c88a80c6d0 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -16,9 +16,11 @@ static struct dentry *amd_iommu_debugfs; =20 #define MAX_NAME_LEN 20 #define OFS_IN_SZ 8 +#define DEVID_IN_SZ 16 =20 static int mmio_offset =3D -1; static int cap_offset =3D -1; +static int sbdf =3D -1; =20 static ssize_t iommu_mmio_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) @@ -149,6 +151,80 @@ static int iommu_cmdbuf_show(struct seq_file *m, void = *unused) } DEFINE_SHOW_ATTRIBUTE(iommu_cmdbuf); =20 +static ssize_t devid_write(struct file *filp, const char __user *ubuf, + size_t cnt, loff_t *ppos) +{ + struct amd_iommu_pci_seg *pci_seg; + int seg, bus, slot, func; + struct amd_iommu *iommu; + char *srcid_ptr; + u16 devid; + int i; + + sbdf =3D -1; + + if (cnt >=3D DEVID_IN_SZ) + return -EINVAL; + + srcid_ptr =3D memdup_user_nul(ubuf, cnt); + if (IS_ERR(srcid_ptr)) + return PTR_ERR(srcid_ptr); + + i =3D sscanf(srcid_ptr, "%x:%x:%x.%x", &seg, &bus, &slot, &func); + if (i !=3D 4) { + i =3D sscanf(srcid_ptr, "%x:%x.%x", &bus, &slot, &func); + if (i !=3D 3) { + kfree(srcid_ptr); + return -EINVAL; + } + seg =3D 0; + } + + devid =3D PCI_DEVID(bus, PCI_DEVFN(slot, func)); + + /* Check if user device id input is a valid input */ + for_each_pci_segment(pci_seg) { + if (pci_seg->id !=3D seg) + continue; + if (devid > pci_seg->last_bdf) { + kfree(srcid_ptr); + return -EINVAL; + } + iommu =3D pci_seg->rlookup_table[devid]; + if (!iommu) { + kfree(srcid_ptr); + return -ENODEV; + } + break; + } + + if (pci_seg->id !=3D seg) { + kfree(srcid_ptr); + return -EINVAL; + } + + sbdf =3D PCI_SEG_DEVID_TO_SBDF(seg, devid); + + kfree(srcid_ptr); + + return cnt; +} + +static int devid_show(struct seq_file *m, void *unused) +{ + u16 devid; + + if (sbdf >=3D 0) { + devid =3D PCI_SBDF_TO_DEVID(sbdf); + seq_printf(m, "%04x:%02x:%02x:%x\n", PCI_SBDF_TO_SEGID(sbdf), + PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid)); + } else + seq_puts(m, "No or Invalid input provided\n"); + + return 0; +} +DEFINE_SHOW_STORE_ATTRIBUTE(devid); + void amd_iommu_debugfs_setup(void) { struct amd_iommu *iommu; @@ -171,4 +247,6 @@ void amd_iommu_debugfs_setup(void) debugfs_create_file("cmdbuf", 0444, iommu->debugfs, iommu, &iommu_cmdbuf_fops); } + debugfs_create_file("devid", 0644, amd_iommu_debugfs, NULL, + &devid_fops); } --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2044.outbound.protection.outlook.com [40.107.220.44]) (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 421F11D0E38 for ; Wed, 6 Nov 2024 07:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879498; cv=fail; b=boKe/+Ub0pAuF64XqPZbXcf1KWGCsiFII6LmHWZmln39PytG4qYuuzOw8YP7KW8BnIP0fWuaGPgn8l9ozYER02WVARvyYE2s4NnlDKKzSvdJx+w1m7wKCL+XQnVycSd20PAAM2BNrusdU3yBmPVKM5fT2rp5gbrpTFK6BRkodSs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879498; c=relaxed/simple; bh=nxgnb9yCQ1RXJXxl34G2WP+nDz/AAFmusQ0gskGE0wI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sNj45RebAA49IV4IU+kty8A21uUdkQS6OGJ/z9fzaQYW5kRyfA7r9A99mZaqnwTFguuHTBm7rq9/fKrr8rGhM6IvHgk5Sg+ss6xSWbXlVSkpCVyooQNdbDThBpPMeO0cUVQajcT9ifb4N9mHwbJX+uErtlKlvomNLBzWY7SZKAg= 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=VfeTIWoT; arc=fail smtp.client-ip=40.107.220.44 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="VfeTIWoT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YlYRvM4/JcU79idJ6IUaZfEXuBWWqGgnYgvtHKz2ZCE5e6AJE3LfTqnbpZ6I9cMAZUjaHdKEBSQ/1PRUBXnv/PnWyd4RWyUUGEOcglRaVX70b0Sb/USYhVcX7zHlNue2RDLdViOK8ReuB7cRvXGx/DiOCCTN21iA4vsafNv3VJxF1f8LQzbZqcnoYz8eURTUULo1bGdjzgIedQ3I9sW8qjF1695hwNRUWTy+ViMNibjwsP2b+r+YbZoUKwPzxZGSIzF/BUd4tnm5MyXCVLOAgPhrhbm++4tQ3OEEb46KCesDiDmjDu7cbZ2vSD6xCDseO5ygRlIiQNC/of+tqt03Bg== 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=APxTADBWUXFYxjwQGcAyGrl2qCnfeGqLMX+IP5aAPAk=; b=uJMkBc70ZoixNhsrtgI1woRTdw5zH+KXhuZVvYhfe2A8QgIvLE02u3qRLRQHcyLalKsBF2gmpmbjD+cYycmbBEvulOlogUboX6jExHDfesRhSZ/EEMo6F1hSj2L5LKfeoeG+uvlfNk0dbcE1IW++M7Vk/2aHoRk8V0Qn1RfP+C4DooyLxEGR8TdguLWRHxPDKrZ6+i7we6pNZXy70pQYN8jj1/tPZ5ahs5Po47zXRMlA9QuqZtFQ0DBdNMajW47n3VP5xutFUyicmKAN7UzuBSJxcw8TcFO7fCia/jRxBlfBzV+LB9HLMhcd2CAhbvqhDqQc53tw1B/CJNK61wbKEw== 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=APxTADBWUXFYxjwQGcAyGrl2qCnfeGqLMX+IP5aAPAk=; b=VfeTIWoTD21BsH/n77kQlwykSymOYpnWTJ8CPUyPk4KCUvI2fKR566yrko4cHVnPEdKnnrpGDhaE4lABhgQiQxMDfGORZ8yBwRRt1WeszeaGzblGFBJkZD0MWIb6S+twYf2Dueu/Li86uPXqXSlOvIK1BBfBMxeBmMUUezO18y0= Received: from BL1PR13CA0023.namprd13.prod.outlook.com (2603:10b6:208:256::28) by IA0PR12MB8280.namprd12.prod.outlook.com (2603:10b6:208:3df::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Wed, 6 Nov 2024 07:51:33 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:256:cafe::61) by BL1PR13CA0023.outlook.office365.com (2603:10b6:208:256::28) 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:51:33 +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 BL6PEPF0001AB75.mail.protection.outlook.com (10.167.242.168) 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:51:33 +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:51:30 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 6/8] iommu/amd: Add debugfs support to dump device table Date: Wed, 6 Nov 2024 13:16:37 +0530 Message-ID: <20241106074639.2039-7-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: BL6PEPF0001AB75:EE_|IA0PR12MB8280:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bd80049-e89b-4c8d-1e62-08dcfe37d572 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?SbjjDDyoJhD4PIBT7W+UlvTZJpFlpSxVewDz9VabTqCVKx77STEW9ddMQHDg?= =?us-ascii?Q?ODt6PwdckR/StrfUhTOGGYHT1kXMBlO6VHwqqdAzKoTfn/6POd2OoMsKekDZ?= =?us-ascii?Q?PWftpFJldQ5jSFu2qZqUUiscusxFe65owkCx8lGNw71DqtXBJFd/p+ZOYLeI?= =?us-ascii?Q?QQLrP+lS6QvkMMbJ61x/LVEqKeFYI2dwKJPH8pYPGy6HoR6AXb1EPxkZywlB?= =?us-ascii?Q?s/0ffWsxVQl9qnEN7YLrDWBTkCPjo2MNQcpMT7+d+fwFchPTywi7kjCeOYtk?= =?us-ascii?Q?LOHcWjhuxq1piQxBzJWMw1cErXwf1hup2iJlIEIvKWtMY6l6JifAFODwMk8F?= =?us-ascii?Q?K0BPWw0Y2EOUMl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91mFL?= =?us-ascii?Q?22vUlVbX3lRA4i2Q5hzMyKlxry/I/9BkcOoaLDsVxKiGbZv8wVMrRohH2ZcG?= =?us-ascii?Q?IbHW4uGkYNgprX83c4uolhvEgIz2PWBQTC6tTVSIyFdjlXqrfDV7XtKekqxD?= =?us-ascii?Q?lKyRxbAwv2p4HSymwLojv+S7OCZHB5JvcoLHF9Ebl6URktcpNg=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:51:33.6356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bd80049-e89b-4c8d-1e62-08dcfe37d572 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: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8280 Content-Type: text/plain; charset="utf-8" IOMMU uses device table data structure to get per-device information for DMA remapping, interrupt remapping, and other functionalities. It's a valuable data structure to visualize for debugging issues related to IOMMU. eg. To dump device table entry for a particular device #echo 0000:c4:00.0 > /sys/kernel/debug/iommu/amd/devid #cat /sys/kernel/debug/iommu/amd/devtbl or #echo c4:00.0 > /sys/kernel/debug/iommu/amd/devid #cat /sys/kernel/debug/iommu/amd/devtbl Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/debugfs.c | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index 74c88a80c6d0..bba65848ef60 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -225,6 +225,53 @@ static int devid_show(struct seq_file *m, void *unused) } DEFINE_SHOW_STORE_ATTRIBUTE(devid); =20 +static void dump_dte(struct seq_file *m, struct amd_iommu_pci_seg *pci_seg= , u16 devid) +{ + struct dev_table_entry *dev_table; + struct amd_iommu *iommu; + + iommu =3D pci_seg->rlookup_table[devid]; + if (!iommu) + return; + + dev_table =3D get_dev_table(iommu); + if (!dev_table) { + seq_puts(m, "Device table not found"); + return; + } + + seq_printf(m, "%-12s %16s %16s %16s %16s iommu\n", "DeviceId", + "QWORD[3]", "QWORD[2]", "QWORD[1]", "QWORD[0]"); + seq_printf(m, "%04x:%02x:%02x:%x ", pci_seg->id, PCI_BUS_NUM(devid), + PCI_SLOT(devid), PCI_FUNC(devid)); + for (int i =3D 3; i >=3D 0; --i) + seq_printf(m, "%016llx ", dev_table[devid].data[i]); + seq_printf(m, "iommu%d\n", iommu->index); +} + +static int iommu_devtbl_show(struct seq_file *m, void *unused) +{ + struct amd_iommu_pci_seg *pci_seg; + u16 seg, devid; + + if (sbdf < 0) { + seq_puts(m, "Please provide valid device id input\n"); + return 0; + } + seg =3D PCI_SBDF_TO_SEGID(sbdf); + devid =3D PCI_SBDF_TO_DEVID(sbdf); + + for_each_pci_segment(pci_seg) { + if (pci_seg->id !=3D seg) + continue; + dump_dte(m, pci_seg, devid); + break; + } + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(iommu_devtbl); + void amd_iommu_debugfs_setup(void) { struct amd_iommu *iommu; @@ -249,4 +296,6 @@ void amd_iommu_debugfs_setup(void) } debugfs_create_file("devid", 0644, amd_iommu_debugfs, NULL, &devid_fops); + debugfs_create_file("devtbl", 0444, amd_iommu_debugfs, NULL, + &iommu_devtbl_fops); } --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) (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 5255A3C39 for ; Wed, 6 Nov 2024 07:54:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879651; cv=fail; b=eKwyVFV1L4Dxfh4lxDCXFrDeQXXgSU1XTsp08NUBISEEI9591MXD30m/mNYR9e698GDi0UN3UyM9sZfeRtwlOwi+vtdpmxG76SjuRSbQnm8OFLXUimF4YIpvwHW3F8nTRKpw0IIN+/XW98SeMFRK9EFqf/QvDJmh8AYWjXYx7lM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879651; c=relaxed/simple; bh=KTZDJjT7C9WUQu8RtXEYMJI1AY0DlkgbawuzN7ENRrk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I+zeHzVb9cttijoAL288kRuiOjsHqMVBnLQy6cmCW5653ZDMf58vVpXixk//OhOsldrTmCg8pZADABTUtYNRBJemmPkpttAU7Gak6dDd0UgyquYQkwMgXz6SZr9cK1htOP228Uom73dczN81jjJii2TJpxx8bsSX9zLUv4ORaIk= 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=joqn2CJZ; arc=fail smtp.client-ip=40.107.92.57 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="joqn2CJZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w0g19x72WBxUFgdp7QpNbfryjBgqJwEkw0elmNv6ClcLq5G3ZdJcsVG0O2P/umcZQpptOGQZWzjsRtmZM9GshJny/iGLazGvarvbR5C0uXeIhlL/+Fi6LtRj4CXxRriDsvpSkqx9VJiV1Zjbpy8uYW45uF39r2WHxVN9rKfcV0fG0vCn34+ImK7NpAnMoICBBE2IZV0A1LkQMncDYEZ7TmU+EycpUcTA0oZgsf4SI8hUCRiurN+lzDWYo95lCi95eL8eJ/B7LvEQNgWeJ9pm1AW33v+mhCHvkjmh9F+dkZbbvCnLOKOXPcpNILiO/JI07QgtCUZYMfIafn94diNfmA== 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=eIZlCUmTgeonMtf5MUFALfDH76g0hNzaNZpFiAGUtAw=; b=msTVVfRp63kJaWlLHV12kLLmPk7cdtCe9SgnKgQu5pCqs/zYFFyujltsZz3htF7/rXAEMqTAEcCeoyto3JDXgJ2E22+n/wCQJlEPLyXo6Ho3P3OrGopf/culhDO7sOY/E3RIagzPFsAnfYwzxC/BRsEXBJpzDYxdAzYFc9SMyc6Iy/tmMmg1Kojfqb/kY/K1RcLzIKp7uchYHsR561pPZQ5+R1FUzdUKZBEceNOEmuHhAt5nIAXJEC+9JQwzdXbJIWL6jLWYKWUBkKjzAVaA8lCNlX4PjSpgU6bqSkfu+HTcPCp9crOIUac8VRVrHWikv/GXcLM2bIK2SudFovg4zg== 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=eIZlCUmTgeonMtf5MUFALfDH76g0hNzaNZpFiAGUtAw=; b=joqn2CJZ7ivUJ42zl+Y1iwoEYtIF0/tJnYfMej4Zr2csm8jMl3XeOqQE19tVkJWnzHmobVE2io6sTX97QSb6gjD9LAgotuKcjpYmLBWT9qibxLwGull0cMv7lVOUv5IrnDdpJLzO1d8Qa+zqtl+PPo+M2NSsUQEsBC2xE8keqD0= Received: from LV3P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:234::34) by MN0PR12MB5763.namprd12.prod.outlook.com (2603:10b6:208:376::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.27; Wed, 6 Nov 2024 07:54:07 +0000 Received: from BL6PEPF0001AB77.namprd02.prod.outlook.com (2603:10b6:408:234:cafe::6f) by LV3P220CA0013.outlook.office365.com (2603:10b6:408:234::34) 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:54:07 +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 BL6PEPF0001AB77.mail.protection.outlook.com (10.167.242.170) 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:54:07 +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:52:15 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 7/8] iommu/amd: Add debugfs support to dump IRT Table Date: Wed, 6 Nov 2024 13:16:38 +0530 Message-ID: <20241106074639.2039-8-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: BL6PEPF0001AB77:EE_|MN0PR12MB5763:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e701ba0-330d-4749-2225-08dcfe3830f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FzLypvNvP9wPYa3hWSbC6w5GJwZlh7BmWbeJwKLdx8ZKS6YDtnVZhpVpmM7M?= =?us-ascii?Q?xgtKudm3dK2z89i8U6hsbaQLj2IeC0snF6mp8M3vHCqPWawPv+v/kbRSSvBh?= =?us-ascii?Q?8B95NyDrOdBaFt4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SRYJMcKvh/jwte?= =?us-ascii?Q?MqjlSRSgZSgtajRNVgEFS8uMASmQr0bIPZshdBO3/0GdU9geI9NnzcOKUu7n?= =?us-ascii?Q?As2pyg9gjWR0QWB7mWMugaBuh47c9FZpi2ElSi5ZxKVvSgpzjA1ch+9wWSGD?= =?us-ascii?Q?VOVZNiNCKQsPqlIcyKLGGqqhcdLxoSJhf2io4Peb4QpALKqDLTd3B9n0JtJ6?= =?us-ascii?Q?ova9MJWJ196S+xfFJxTNLsR2jvWeGKCmInZkb09iCUQ+IZ5zh8cNlO8Z0Yq6?= =?us-ascii?Q?8M1B2PPK5BDJCUHrsKREnxHqdBGhQuFC3TgQ6l7qkAZGTK5RHHBxIQ1DTe1g?= =?us-ascii?Q?w3seQNWVgx0V+lSOWN1iNSCech4LZvDLsdvC4c7pB7uXYGIFNc+Dsqd8zrv4?= =?us-ascii?Q?Iz9cJcYxO9dxTPebyVkue/ts4QP3lM21uSuQkcUpmLtqm+ThjQ=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)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:54:07.1734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e701ba0-330d-4749-2225-08dcfe3830f6 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: BL6PEPF0001AB77.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5763 Content-Type: text/plain; charset="utf-8" In cases where we have an issue in the device interrupt path with IOMMU interrupt remapping enabled, dumping valid IRT table entries for the device is very useful and good input for debugging the issue. eg. To dump irte entries for a particular device #echo "c4:00.0" > /sys/kernel/debug/iommu/amd/devid #cat /sys/kernel/debug/iommu/amd/irqtbl | less or #echo "0000:c4:00.0" > /sys/kernel/debug/iommu/amd/devid #cat /sys/kernel/debug/iommu/amd/irqtbl | less Signed-off-by: Dheeraj Kumar Srivastava --- drivers/iommu/amd/debugfs.c | 89 +++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c index bba65848ef60..3da3385a7d5d 100644 --- a/drivers/iommu/amd/debugfs.c +++ b/drivers/iommu/amd/debugfs.c @@ -11,6 +11,7 @@ #include =20 #include "amd_iommu.h" +#include "../irq_remapping.h" =20 static struct dentry *amd_iommu_debugfs; =20 @@ -272,6 +273,92 @@ static int iommu_devtbl_show(struct seq_file *m, void = *unused) } DEFINE_SHOW_ATTRIBUTE(iommu_devtbl); =20 +static void dump_128_irte(struct seq_file *m, struct irq_remap_table *tabl= e) +{ + struct irte_ga *ptr, *irte; + int index; + + for (index =3D 0; index < MAX_IRQS_PER_TABLE; index++) { + ptr =3D (struct irte_ga *)table->table; + irte =3D &ptr[index]; + + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) && + !irte->lo.fields_vapic.valid) + continue; + else if (!irte->lo.fields_remap.valid) + continue; + seq_printf(m, "IRT[%04d] %016llx%016llx\n", index, irte->hi.val, irte->l= o.val); + } +} + +static void dump_32_irte(struct seq_file *m, struct irq_remap_table *table) +{ + union irte *ptr, *irte; + int index; + + for (index =3D 0; index < MAX_IRQS_PER_TABLE; index++) { + ptr =3D (union irte *)table->table; + irte =3D &ptr[index]; + + if (!irte->fields.valid) + continue; + seq_printf(m, "IRT[%04d] %08x\n", index, irte->val); + } +} + +static void dump_irte(struct seq_file *m, u16 devid, struct amd_iommu_pci_= seg *pci_seg) +{ + struct irq_remap_table *table; + unsigned long flags; + + table =3D pci_seg->irq_lookup_table[devid]; + if (!table) { + seq_printf(m, "IRQ lookup table not set for %04x:%02x:%02x:%x\n", + pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid)); + return; + } + + seq_printf(m, "DeviceId %04x:%02x:%02x:%x\n", pci_seg->id, PCI_BUS_NUM(de= vid), + PCI_SLOT(devid), PCI_FUNC(devid)); + + raw_spin_lock_irqsave(&table->lock, flags); + if (AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir)) + dump_128_irte(m, table); + else + dump_32_irte(m, table); + seq_puts(m, "\n"); + raw_spin_unlock_irqrestore(&table->lock, flags); +} + +static int iommu_irqtbl_show(struct seq_file *m, void *unused) +{ + struct amd_iommu_pci_seg *pci_seg; + u16 devid, seg; + + if (!irq_remapping_enabled) { + seq_puts(m, "Interrupt remapping is disabled\n"); + return 0; + } + + if (sbdf < 0) { + seq_puts(m, "Please provide valid device id input\n"); + return 0; + } + + seg =3D PCI_SBDF_TO_SEGID(sbdf); + devid =3D PCI_SBDF_TO_DEVID(sbdf); + + for_each_pci_segment(pci_seg) { + if (pci_seg->id !=3D seg) + continue; + dump_irte(m, devid, pci_seg); + break; + } + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(iommu_irqtbl); + void amd_iommu_debugfs_setup(void) { struct amd_iommu *iommu; @@ -298,4 +385,6 @@ void amd_iommu_debugfs_setup(void) &devid_fops); debugfs_create_file("devtbl", 0444, amd_iommu_debugfs, NULL, &iommu_devtbl_fops); + debugfs_create_file("irqtbl", 0444, amd_iommu_debugfs, NULL, + &iommu_irqtbl_fops); } --=20 2.25.1 From nobody Sun Nov 24 09:05:34 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) (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 B42CA1D1E62 for ; Wed, 6 Nov 2024 07:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879704; cv=fail; b=DT4LlGsOZ5wPL5VW2b5Lt+rxx8Z9dFnKKB274YPF6BvGLZHheCUCJI0kOdUmcsYMmC83Q248dWVSqci88qIKeGNWQSVH3qXx1RrxWjAuATUcYRjwBA6405aClotUky8x//cUQmpmEeQ60f59nVPQ+l+IbmPopnlo3KvJGWJ6+Eg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730879704; c=relaxed/simple; bh=zgW/WA/0HRq3U5JUbW90ya/nCzPsgbcMjdW07MqsHX4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QOsDtVs2MLWiL8bwUKxJPnoTBNPC8cBm3bcTKI7oX1qEXgqimgzZwYRsudJgV49bb2BliIfQKp+cqS3VWcr7aa1d6PGxgg0lIdNPf4drlCBKycUGkDT7ga87xYZHCANCi0G2QFswflT+qKEY7Q+LU3eRPC4VwtH/YrC5amBCHnk= 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=kAsUOKQv; arc=fail smtp.client-ip=40.107.92.84 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="kAsUOKQv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZDvXAJXgVCsFKL/A++4ur6hZO8hUcw/k1KhZkziQ6bcSdLSIVAL2NTG7APYfq9GvVE1rWZlxFJeG7grwi3D1V9bXg/FZFi92EiC+nApcE4UaKZHRshal6X8fpzC+YpyRN73SeCw/0VO6UZAos/VEPtPXvH+yiV7IFIiIwNNGJtvHnZHJD0pYFZOa+Ruqr9ViyWdUdzc4Ev/G15C+c+XDgDtote1hZoFVQW+1Hc1EBfezzH1AK6GO96B5cEKU54qJzSaTjt+TRpsH3OTVJiyQdvwbS5Ih9fXhCS+fZ7OLNAWLU6Anz41TaO+yEgLUxcE4uF36Mm+prY/RdppmXYFwFQ== 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=+ARFf25kJpv4NqyfZyZtLT7RekhZqR3rK6YmDLrHYkY=; b=pnYP7OrqinGJh1Dt5mtn7zyMwi3DGUoxMh1O0M0pBq6DD9Ml29zLsrk4Ly+N7Ay7OeP8yHs1QBZnP4T260Vg6w09CQTBVe6zwnXfMPVatuc0ubFzVqQY1DLj+03cdTJ64q6WeSqRD5ADnIkTngNEkCX4CRGhSJO+QZL56VKaEnjpDPZ/P6mMjGWb96v/XH+I9Z1YR+0r8iRlY9HiVIqVPSQLf6VuG+7Bq9vudwM5oJyPgWgYYJtMJH7rULrVt12tc8Xk1Uit49SB9sHSbsDwOF6o2JD6cvvwLGnTw2Qfib8Xdzv2wmmtMZhK4MsK/7/p9GNme1KJSrC2aECYpuO+yw== 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=+ARFf25kJpv4NqyfZyZtLT7RekhZqR3rK6YmDLrHYkY=; b=kAsUOKQvDh7k4u116zYYaGzdXqpMSpHwVkoX4yyMRiIfj8YOKo6073py61aaEQJmZzzRxtJwgqPICQqEkAEEOryfkYGzq6fK7uxwMBNG2+97FxZoxn7uF3Po3rx8UEfwmp4kD4zY/owJR/8BHQFfV+XwjG3pFEn7k8Q4MnsPNx8= Received: from BN9PR03CA0433.namprd03.prod.outlook.com (2603:10b6:408:113::18) by PH8PR12MB8608.namprd12.prod.outlook.com (2603:10b6:510:1bc::9) 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:54:58 +0000 Received: from MN1PEPF0000F0DE.namprd04.prod.outlook.com (2603:10b6:408:113:cafe::b1) by BN9PR03CA0433.outlook.office365.com (2603:10b6:408:113::18) 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:54:58 +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 MN1PEPF0000F0DE.mail.protection.outlook.com (10.167.242.36) 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:54:58 +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:53:38 -0600 From: Dheeraj Kumar Srivastava To: , , , , , CC: Subject: [PATCH v2 8/8] iommu/amd: Add documentation for AMD IOMMU debugfs support Date: Wed, 6 Nov 2024 13:16:39 +0530 Message-ID: <20241106074639.2039-9-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: MN1PEPF0000F0DE:EE_|PH8PR12MB8608:EE_ X-MS-Office365-Filtering-Correlation-Id: adfabb37-154e-4f8f-d4f2-08dcfe384f84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?94CbQbzOVZCJLfnXh5tAVd3CHlX7F/Co7WU+hlyxkRQ5ta4tDKmeOU4v+C2U?= =?us-ascii?Q?mxqGnLUTdEowhMsl/LugfV9vv99hTtIosNMYr/s2xOBleQdd78lxxn51lnUh?= =?us-ascii?Q?ZrzhwN/Wu1Tr2fuUcCpr6v44qk4AXtHHC1EDhvnhLDY/HblTb8qzGkEwFw/M?= =?us-ascii?Q?9i1N+xthFX1jOrYHrylbwCoLcDZ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?Q?gB9FWezsdSAGOQ7c1rishjp5qN5YdhSG1xmHhfEF8LSftkLvCj3RbR+OhP08?= =?us-ascii?Q?P5IhrIfsSEqUnYvI/9iu+ENr/aBEpKDjchu/rkVjwTw2Qha+SBZGyoumigVu?= =?us-ascii?Q?+cZ5d+NyjFh6RS3Twuyv5gVPD8A0iM9F/zaLOESh0CQiNc6cIx3/LO+OjBYH?= =?us-ascii?Q?ZD5EN+yiIktnmayjl0CZFJUrB7ucLpWYRNqupbFGfxXO5y/xf/MYu3KIslNv?= =?us-ascii?Q?RMkDcDsDlfCx/Jh2h2sQm1mLcEs09xF/2qax4WetYweZMjL1i8urhrKj611F?= =?us-ascii?Q?aTe2GF9t9ugNEFS+i/JyWtT2bsqaZza0mVX8hoAC37GfLKjKNw=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)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 07:54:58.3465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adfabb37-154e-4f8f-d4f2-08dcfe384f84 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: MN1PEPF0000F0DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB8608 Content-Type: text/plain; charset="utf-8" Add documentation describing how to use AMD IOMMU debugfs support to dump IOMMU data structures - IRT table, Device table, Registers (MMIO and Capability) and command buffer. Signed-off-by: Dheeraj Kumar Srivastava --- Documentation/ABI/testing/debugfs-amd-iommu | 140 ++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-amd-iommu diff --git a/Documentation/ABI/testing/debugfs-amd-iommu b/Documentation/AB= I/testing/debugfs-amd-iommu new file mode 100644 index 000000000000..9f7741e05217 --- /dev/null +++ b/Documentation/ABI/testing/debugfs-amd-iommu @@ -0,0 +1,140 @@ +What: /sys/kernel/debug/iommu/amd/iommu/mmio +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an input read/write access file. In this file, the user input + mmio register offset for iommu to print corresponding mmio register + of iommu. + + Example: + $ echo "0x18" > /sys/kernel/debug/iommu/amd/iommu00/mmio + $ cat /sys/kernel/debug/iommu/amd/iommu00/mmio + + Output: + 0x18 + +What: /sys/kernel/debug/iommu/amd/iommu/mmio_dump +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an output read only file that contains mmio register + value at offset "/sys/kernel/debug/iommu/amd/iommu/mmio". + + Example: + $ cat /sys/kernel/debug/iommu/amd/iommu00/mmio_dump + + Output: + 0x0003f48d + +What: /sys/kernel/debug/iommu/amd/iommu/capability +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an input read/write access file. In this file, the user input + capability register offset for iommu to print correspon= ding capability + register of iommu. + + Example: + $ echo "0x10" > /sys/kernel/debug/iommu/amd/iommu00/capability + $ cat /sys/kernel/debug/iommu/amd/iommu00/capability + + Output: + 0x10 + +What: /sys/kernel/debug/iommu/amd/iommu/capability_dump +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an output read only file that contains capability register + value at offset "/sys/kernel/debug/iommu/amd/iommu/capa= bility". + + Example: + $ cat /sys/kernel/debug/iommu/amd/iommu00/capability_dump + + Output: + 0x00203040 + +What: /sys/kernel/debug/iommu/amd/iommu/cmdbuf +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This file is an output read only file that contains iommu command + buffer entries. + + Examples: + $ cat /sys/kernel/debug/iommu/amd/iommu/cmdbuf + + Output: + CMD Buffer Head Offset:339 Tail Offset:339 + 0: 008350011000000100003c0000000000 + 1: 0000000030000005fffff0037fffffff + 2: 008350011000000100003c0100000000 + 3: 0000000030000005fffff0037fffffff + 4: 008350011000000100003c0200000000 + 5: 0000000030000005fffff0037fffffff + 6: 008350011000000100003c0300000000 + 7: 0000000030000005fffff0037fffffff + 8: 008350011000000100003c0400000000 + 9: 0000000030000005fffff0037fffffff + 10: 008350011000000100003c0500000000 + 11: 0000000030000005fffff0037fffffff + [...] + +What: /sys/kernel/debug/iommu/amd/devid +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an input read/write file that takes device id user input. + This input can be used for dumping iommu data structures like + interrupt remapping table, device table etc. + + Example: + 1. + $ echo 0000:01:00.0 > /sys/kernel/debug/iommu/amd/devid + $ cat /sys/kernel/debug/iommu/amd/devid + + Output: + 0000:01:00.0 + + 2. + $ echo 01:00.0 > /sys/kernel/debug/iommu/amd/devid + $ cat /sys/kernel/debug/iommu/amd/devid + + Output: + 0000:01:00.0 + +What: /sys/kernel/debug/iommu/devtbl +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an output read only file that contains device table entry for + the device id input given in /sys/kernel/debug/iommu/amd/devid. + + Example: + $ cat /sys/kernel/debug/iommu/amd/devtbl + + Output: + DeviceId QWORD[3] QWORD[2] QWORD[1] = QWORD[0] iommu + 0000:01:00.0 0000000000000000 20000001373b8013 0000000000000038 60000001= 14d7b603 iommu3 + +What: /sys/kernel/debug/iommu/irqtbl +Date: September 2024 +Contact: Dheeraj Kumar Srivastava +Description: + This is an output read only file that contains IRT table valid entries + for the device id input given in /sys/kernel/debug/iommu/amd/devid. + + Example: + $ cat /sys/kernel/debug/iommu/amd/irqtbl + + Output: + DeviceId 0000:01:00.0 + IRT[0000] 00000000000000200000000000000241 + IRT[0001] 00000000000000200000000000000841 + IRT[0002] 00000000000000200000000000002041 + IRT[0003] 00000000000000200000000000008041 + IRT[0004] 00000000000000200000000000020041 + IRT[0005] 00000000000000200000000000080041 + IRT[0006] 00000000000000200000000000200041 + IRT[0007] 00000000000000200000000000800041 + [...] --=20 2.25.1