Received: by 10.213.65.68 with SMTP id h4csp2020993imn; Thu, 29 Mar 2018 15:57:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49V0jTDj/22rGEgPIa4mO67d15XLmbCeL0zAAve8JC3VJPEKavrGp9e5YEN+m6cOBqTnbtY X-Received: by 10.99.53.130 with SMTP id c124mr6753318pga.233.1522364245417; Thu, 29 Mar 2018 15:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522364245; cv=none; d=google.com; s=arc-20160816; b=xU5Qy642rsPPw1ASxLOWKeDZkgYAX7kPQ08mW17IUMce3pw5PRgmCyCH/cqeK3kDiz FIDCvAfbbI9RsXU3QXRWUMNRNz5k5rAHf6PVkDBqEEOoqp9xiC+UpJbEma7FIh19oh87 V95o30fZiORjedLkVdsAFvblqywSha3pTLbIBszlQMGqG2VY7GJ2Wpsd7DHImG8P1sr/ RPU62YRnpzJEgay2r6+KILvDlsXK6hoq6TP+lSDUPByvjuD0ncFyOesBmmAaetSt2SjL KFCZwK6XDpzHt2mxCqJfHCMUdnzmY05KzhV2Sll/Pe785FwqjGq1egmlmdLOVYr8bX1v kNgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:arc-authentication-results; bh=DAPNuMC/t91YhykX0YKcpN1iKhtKG/zS5hWJXSGh27o=; b=Q029z6soEQK4U16KQZP3O/mxa9QSCt0Tr7BB0xRCsQc1bwNI74KH7B7jtNpR9nxgpj 9v2tJUh1aHGrkJOqKQejU6r7f0cYbvb3SPO5+Qtj/opxjyX5T/VAMuH5MUDZMXOEdrM0 l/a1BZMQo2WSrZCIlnFuT8dVTHSmnuXNOWg+5fC5Y5fwT5uJUydZu2D2SxsoDkJB4xWX uDe5R5Mc9IrdDh11e0p5J2kOciy7jlPTT7XOwfRCg34o9dAOvQA+39DNMyeCRUD2kxyG R9uboviAK9ERx58xZvoAafEfJU9rWLisDuw9ahT2t06RIHoT2nYrjnVkdHupr3HZL1lj YFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=L2S76vnu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si6557248plk.672.2018.03.29.15.57.11; Thu, 29 Mar 2018 15:57:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=L2S76vnu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeC2WzI (ORCPT + 99 others); Thu, 29 Mar 2018 18:55:08 -0400 Received: from mail-by2nam01on0042.outbound.protection.outlook.com ([104.47.34.42]:63150 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752308AbeC2WzF (ORCPT ); Thu, 29 Mar 2018 18:55:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DAPNuMC/t91YhykX0YKcpN1iKhtKG/zS5hWJXSGh27o=; b=L2S76vnuWnXGvN/aM4NbeYKTBitQ9iVPteOwsqo1JC+cGKajF5x4BHwoWWi7G+Wb8xLrh32OTcqh52nKCiivQDF+gQGJdfKdn91pPXiVDL3V/RAV/dvB1PLxB16dogvBN5jWw9uz+TmWTnWrD+87OHnQna6FVIY0lVnoZ6an0hM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [127.0.1.1] (165.204.78.1) by BLUPR12MB0691.namprd12.prod.outlook.com (2a01:111:e400:5951::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.10; Thu, 29 Mar 2018 22:54:59 +0000 Subject: [PATCH 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU From: Gary R Hook To: iommu@lists.linux-foundation.org Cc: joro@8bytes.org, jacob.jun.pan@linux.intel.com, linux-kernel@vger.kernel.org Date: Thu, 29 Mar 2018 17:54:54 -0500 Message-ID: <152236409481.3266.6464716993249076762.stgit@taos> In-Reply-To: <152236384612.3266.1451709369164076985.stgit@taos> References: <152236384612.3266.1451709369164076985.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR22CA0009.namprd22.prod.outlook.com (2603:10b6:300:ef::19) To BLUPR12MB0691.namprd12.prod.outlook.com (2a01:111:e400:5951::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7e970eb1-99e6-4b53-ef88-08d595c81a1f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BLUPR12MB0691; X-Microsoft-Exchange-Diagnostics: 1;BLUPR12MB0691;3:rHmCEWHx1bF7Xlo+XO9E24A745VLZokQSFaub/o/gyEG+QRye9US9Yz58t314c9yiP4hH2RLNd1WNkG68p8sJ46qY1ZnUroGsMm2dSoOM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TVst05mI4misnFddY281KcwLqvLstzUx1+jLstkWn3kIbCqm+LmxZn+uArC0RGs7X2GeriHx+AgSGZbkvtCQ4Es5rmrD/R1FaFzvmA7H+CXl5kR2TlwHj/ILItfXMVZuPsF6r3KJrMQlDc/GgrrVP629U6MMa6EmICsgcO//YKUIZkdEDML5EAEy8Fwb9dnwSgMUfN6VoZRyv6tpoiEV4KbGkCGYFue1T9ppphhioSjHSkrBEH59fYfQHv6KAXAPSiUKa7Dr;4:Wp5lER/E3jMFsqGVj6HPFFuo+YQZnwffTGruiW6PrkL4RPjBDDTyt8FRYkRPHKHrAFSdozCZYiRkBFK+v/jAc+Q9uAFKx78uvoKr7x0CZq0B4H3XORWdxNDAybGC4rKLcqlF/nABaPC77j/26sUMK2u/u/WYyecp7o96ol2fAjMKwHOoJ8nL2doDB8Zcw3jYXeTNSEXsCGxccI20c5UXoraZnmfGOEU1swEDwXt36jRcxoHikwYv4DBPimKNSzoQrq2pqgDry7/LTDKd1sAt0WB0zlY7u2Eujqfi/GTVSHF/60YtoTuVH5qJSY73hoFo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BLUPR12MB0691;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0691; X-Forefront-PRVS: 0626C21B10 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(7916004)(39860400002)(376002)(396003)(39380400002)(346002)(366004)(199004)(189003)(316002)(68736007)(478600001)(59450400001)(2351001)(2906002)(486005)(476003)(72206003)(16526019)(2486003)(103116003)(23676004)(33896004)(33716001)(956004)(81166006)(5660300001)(81156014)(11346002)(16576012)(446003)(8676002)(76176011)(486005)(58126008)(66066001)(305945005)(106356001)(2361001)(47776003)(52116002)(105586002)(230700001)(86362001)(9686003)(6916009)(386003)(97736004)(3846002)(50466002)(6486002)(8936002)(6116002)(4326008)(6666003)(7736002)(25786009)(53936002)(575784001)(186003)(77096007)(26005);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR12MB0691;H:[127.0.1.1];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjEyTUIwNjkxOzIzOnJaenpxaFNWdFdUb0tBRGxzQ0NWRVltbE5I?= =?utf-8?B?NGd5N3hQR2FTZXdGL0hUcFlZUGI4L05SbVdKT3k4OVpMVXhaZDB6KzZ6cWN6?= =?utf-8?B?S3VxUlZCRXhidXU5QjdvWG42ckREMUhDQWdhOUIwRzNtZk5kM3BsS21yZXVz?= =?utf-8?B?a2lWYkhWaHlxdEJObGhrZmloMVZIaElSSVg1NWxmMHc5QTQyNUQ2Y2xBbk52?= =?utf-8?B?OHdBM2pOUVFPZHRHVDZqRVFkL2VlbzhOVFJRYVlZaGh3VGZUbUtaMlNIWUo2?= =?utf-8?B?dkdwOHRjSjJZb2ZDY0s5dEdaWnc2bFNhRStZZ3grQ094dmtqVGlZSTkxc0dE?= =?utf-8?B?NEl5eSs4N3NLN3N2bEs2Z3pya2RIZG9QU1F6akhpSE9JQjlMbjN1ZmNiS0V0?= =?utf-8?B?SS9vSFBlYXU5a3VqOExIVUhrNVRrWksvNGFIa1RxclFDY2trVjZWTjNpYnFa?= =?utf-8?B?dUJSZmdOVzZNRmFMY2ZIOVlFOTg2RXA4TlAxRFJwWkpCeTlVd2FMV0liV1do?= =?utf-8?B?MjBlOFVVclRWVmhobi9mdEx6SmQ5WGZNbGVyWE5ZQktnbWlKTDlFOEZUVW5U?= =?utf-8?B?ZFdnak1KRG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EMzISACb1y7Ilw7DKD3fhFoBi6IkYGVqz8Z3SV8ecODG1FYcVwl99rllXVhPXbhFEbjD7ex3RBleXRMCj/wAkViB/GE1WvtGwZuA1Ya6aD5BO846+N6w==;5:jacP8PfvPyiSKPNjx+kQ1ShaJdTmA1ux0tPQTIGSj9UiTDL+YLmWhrBPxlMeBcsmK2HVKissedgIKbsNaHruRN7R4NKvr0Q6i7QMoAH/tvRFDJT8hVVsaC4skEUFlA9wrbr4obs37Juu+ewoyOeYp8WDQUG6W6rbcc0A1z5Lv9w=;24:QX9UpBbUZCc/fA4TPWfeejIBtx0NYTGW4yq6tnVU6nuRaPPk4QJwjtFBJGspvJuKUixHwSpe6ZBZ/5Hb0/Hw881RjqAurePimOFOVFlOyiE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR12MB0691;7:O+0gsR6l7xBPc5APUfz5C/LDPfWymQARH9vX/aB7BZxHArRPaTsm/RnoklXU3+U6eGjHnDpJBAWgqaf87IbhgmwHdxOpF2uVxiKSuBKZQbcSJiFR9QyehNfc7W53TRCO0Z6JljglhEMNNa0s0vOOzzdeWsZTXr+wcj+ko9oaCsuNA3UvxWtlngljA/LR1l38vDMj7xb46Y8O1j0Cjqn69YoeYt70vOBjBfLJQy7T/a23n/QdFW8H5c51eXET1qw0;20:nntO/j0mXWlkXj4ygDCCFNd9gZKYWgQ/OostTVgE5MqaRndGBtEOhBNM6sMT1cp1jMSFbhkO+8Bo2CJdGinP+Msv3jLOTjPp+ChxeQQykImrpDm6oREt3w4JipidZTdwFXTyF34OWG99tJmFCc/VqecJk9Er0yNdwV8dJXYFAVe41rfoaVAfC88tWfjfRP9/ekUKCcfoiGzQ5ZaeGJZklZgXAQ+2rQA23DzVMD+J77pXY4SRLjfoZq50aMAVnHnZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2018 22:54:59.6153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e970eb1-99e6-4b53-ef88-08d595c81a1f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0691 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement a skeleton framework for debugfs support in the AMD IOMMU. Signed-off-by: Gary R Hook --- drivers/iommu/Kconfig | 6 ++--- drivers/iommu/Makefile | 2 +- drivers/iommu/amd_iommu_debugfs.c | 47 +++++++++++++++++++++++++++++++++++++ drivers/iommu/amd_iommu_init.c | 9 ++++--- drivers/iommu/amd_iommu_proto.h | 6 +++++ drivers/iommu/amd_iommu_types.h | 3 ++ include/linux/iommu.h | 8 +++--- 7 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 drivers/iommu/amd_iommu_debugfs.c diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index d40248446214..8d50151d5bf4 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -65,9 +65,9 @@ config IOMMU_DEBUG depends on DEBUG_FS default n help - Base enablement for access to any IOMMU device. Allows individual - drivers to populate debugfs for access to IOMMU registers and - data structures. + Enable exposure of IOMMU device internals. Allow devices to + populate debugfs for access to IOMMU registers and data + structures. config IOMMU_IOVA tristate diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 5e5c3339681d..0ca250f626d9 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -11,7 +11,7 @@ obj-$(CONFIG_IOMMU_IOVA) += iova.o obj-$(CONFIG_OF_IOMMU) += of_iommu.o obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o -obj-$(CONFIG_AMD_IOMMU_DEBUG) += amd_iommu_debugfs.o +obj-$(CONFIG_IOMMU_DEBUG) += amd_iommu_debugfs.o obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o obj-$(CONFIG_ARM_SMMU) += arm-smmu.o obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o diff --git a/drivers/iommu/amd_iommu_debugfs.c b/drivers/iommu/amd_iommu_debugfs.c new file mode 100644 index 000000000000..3547ad3339c1 --- /dev/null +++ b/drivers/iommu/amd_iommu_debugfs.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD IOMMU driver + * + * Copyright (C) 2018 Advanced Micro Devices, Inc. + * + * Author: Gary R Hook + */ + +#ifdef CONFIG_IOMMU_DEBUG + +#include +#include +#include +#include "amd_iommu_proto.h" +#include "amd_iommu_types.h" + +static struct dentry *iommu_debugfs_dir; +static DEFINE_RWLOCK(iommu_debugfs_lock); + +#define MAX_NAME_LEN 20 + +void amd_iommu_debugfs_setup(struct amd_iommu *iommu) +{ + char name[MAX_NAME_LEN + 1]; + struct dentry *d_top; + unsigned long flags; + + if (!debugfs_initialized()) + return; + + write_lock_irqsave(&iommu_debugfs_lock, flags); + if (!iommu_debugfs_dir && (d_top = iommu_debugfs_setup())) + iommu_debugfs_dir = debugfs_create_dir("amd", d_top); + write_unlock_irqrestore(&iommu_debugfs_lock, flags); + if (iommu_debugfs_dir) { + snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index); + iommu->debugfs_instance = debugfs_create_dir(name, + iommu_debugfs_dir); + if (!iommu->debugfs_instance) + debugfs_remove_recursive(iommu_debugfs_dir); + } + + return; +} + +#endif diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 99d48c42a12f..43856c7f4ea1 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -89,6 +89,7 @@ #define ACPI_DEVFLAG_ATSDIS 0x10000000 #define LOOP_TIMEOUT 100000 + /* * ACPI table definitions * @@ -2720,6 +2721,7 @@ int __init amd_iommu_enable_faulting(void) */ static int __init amd_iommu_init(void) { + struct amd_iommu *iommu; int ret; ret = iommu_go_to_state(IOMMU_INITIALIZED); @@ -2729,14 +2731,15 @@ static int __init amd_iommu_init(void) disable_iommus(); free_iommu_resources(); } else { - struct amd_iommu *iommu; - uninit_device_table_dma(); for_each_iommu(iommu) iommu_flush_all_caches(iommu); } } + for_each_iommu(iommu) + amd_iommu_debugfs_setup(iommu); + return ret; } @@ -2783,8 +2786,6 @@ int __init amd_iommu_detect(void) iommu_detected = 1; x86_init.iommu.iommu_init = amd_iommu_init; -dump_stack(); - return 1; } diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 640c286a0ab9..e19cebc5c740 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h @@ -33,6 +33,12 @@ extern void amd_iommu_uninit_devices(void); extern void amd_iommu_init_notifier(void); extern int amd_iommu_init_api(void); +#ifdef CONFIG_IOMMU_DEBUG +extern void amd_iommu_debugfs_setup(struct amd_iommu *iommu); +#else +static inline void amd_iommu_debugfs_setup(struct amd_iommu *iommu) {} +#endif + /* Needed for interrupt remapping */ extern int amd_iommu_prepare(void); extern int amd_iommu_enable(void); diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index f6b24c7d8b70..6dca9fe38518 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -591,6 +591,9 @@ struct amd_iommu { u32 flags; volatile u64 __aligned(8) cmd_sem; + + /* DebugFS Info */ + struct dentry *debugfs_instance; }; static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 98527f9b473b..dbfff811aa25 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -412,6 +412,10 @@ void iommu_fwspec_free(struct device *dev); int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids); const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode); +#ifdef CONFIG_IOMMU_DEBUG +extern struct dentry *iommu_debugfs_setup(void); +#endif + #else /* CONFIG_IOMMU_API */ struct iommu_ops {}; @@ -696,10 +700,6 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode) return NULL; } -#ifdef CONFIG_IOMMU_DEBUG -extern struct dentry *iommu_debugfs_setup(void); -#endif - #endif /* CONFIG_IOMMU_API */ #endif /* __LINUX_IOMMU_H */