Received: by 10.213.65.68 with SMTP id h4csp1062194imn; Wed, 4 Apr 2018 11:56:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/lH0DU9wnDYto5rsSdVrRTEsHZFgIebmwF9wXfoXhy5pTmyZGfkVCI99L0fqe5EDvNdycN X-Received: by 10.99.101.66 with SMTP id z63mr2900872pgb.383.1522868212806; Wed, 04 Apr 2018 11:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522868212; cv=none; d=google.com; s=arc-20160816; b=IMDTc8aiIzpFZK+zRvlaUQq+X6j0eV/xz/KcpvqOsF/Yk5imZsmnLlgEtW2HNd6+sW nXr8xyOhRQu4A6gG1dbaqAgkpXR9IqJaTxnaNpEUixFhVZ5gPXB6zAExI5Uf2oyCfrFw sNGmgCOiPwMY+9vpVhJqIeNmj0gP5P5ZFxOsgftp1Ges6kGPmeRFmd0n/yUlIMc3Qgt3 z3h8biWjUi3BBpaWeJe4EL0HMh8odBejBcPpuiSquT6yNF7zk8qdCYUUawU0ynvXsp7t SarvyAeZpjKqbf8mwMNRospPkQXAaea90i5Bwy5pQo4kpauvunTdsrszD1IKy7O8aVGQ KEzA== 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=/I5lJprNs7EYDewAG4gAd3pWCClY2Ff1Mrs/x6rEki0=; b=JREPBp/misa8uQD1cvCroUnHhJRtAimVOIhMhxdVxmXu7O25NYOB/+y/kiodDC1z4Q StircYVlH389lxiljRPO5eGur9hSybqcR3elhkE44QAGxkYiLlk/DFLBkwJ4RvSPXXhG OLhcCDPJzX6uGZjOVau0Tdi7WQ8ZdaYPtEFuCCcMg3+3xRABvuxfsBn81H32+fkNQn9T bMORAJg1OOPRz85dSmefPDTNcbB3sMFoVHgvQlohfSaVYE6h8lZkceT0jcGM9X28sta0 CWBO3cqiUoNDqldMwRSGrwuH+0DZHrdnDXF/0mAjz629BcZGztqmGOU+aF/pDCrkonKE bzwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=4NVlO4BV; 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 e19si2689961pff.73.2018.04.04.11.56.38; Wed, 04 Apr 2018 11:56:52 -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=4NVlO4BV; 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 S1751735AbeDDSzR (ORCPT + 99 others); Wed, 4 Apr 2018 14:55:17 -0400 Received: from mail-bn3nam01on0062.outbound.protection.outlook.com ([104.47.33.62]:35248 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751693AbeDDSzO (ORCPT ); Wed, 4 Apr 2018 14:55:14 -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=/I5lJprNs7EYDewAG4gAd3pWCClY2Ff1Mrs/x6rEki0=; b=4NVlO4BV8974H+rJcFZ30KYxCXh09pMi2j6hv0mpILct+9DsRWsFswYfF35MBDTF2y8qJZvmcH875ac6lYfrl7iFxL9BJ63RfbhaGJXoIS7nunp0nKWTwXYv5Y/5RquzjWFuR8pL5rt/YF8H241kwi6yw/ena2/YfLHMgj+PAqA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [127.0.1.1] (165.204.78.1) by BY2PR12MB0695.namprd12.prod.outlook.com (2a01:111:e400:52df::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Wed, 4 Apr 2018 18:55:11 +0000 Subject: [PATCH v2 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, linux-kernel@vger.kernel.org Date: Wed, 04 Apr 2018 13:55:06 -0500 Message-ID: <152286810663.3286.1200646003836116320.stgit@taos> In-Reply-To: <152286703837.3286.11286329185822795742.stgit@taos> References: <152286703837.3286.11286329185822795742.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: MWHPR1701CA0011.namprd17.prod.outlook.com (2603:10b6:301:14::21) To BY2PR12MB0695.namprd12.prod.outlook.com (2a01:111:e400:52df::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 811483c9-57f4-4068-bac9-08d59a5d980e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BY2PR12MB0695; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0695;3:GXBUYnZSmPBNZC+YtWojWVn6pZM1t+nfnT/DzydAzMEYZg15iA1kIsN37EY66IPxGIcC595et0Jn7PpX9dUmjorZih24IIkW1DfaFNNlU0u31q0ZTb5R3kFqR5nr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SilZwDzrQveigzmctjSLXnYrtklBW3GKyNqW6rXiOvf6kNKNngcElSvlo+3wm0Y0ocAf9j/lyMna+bQc8F5ctf9zq/gI00NU7Tf8tTRebciP99HYzGFQz4A+DUrf3msAgc8W6uEnQrtFpXiPzJTtu2WKPCyGCPCf+sxvxDvWsr7HdUmFypT7CRgXBpnFPv8oOLcMeCubjSMOY/YtzckUu1iZzGm;4:Fp5+WmsAXckXnDn+fXye2hrdpdWapHmtD8I9xnk4JH3Hzc1jsuVgcCXyzyA4KBdTK8asReTeSmWGFrg7qE5ORqPJmluw862GvadZX9nJNhvYwK9GE5a1NySFPxhcOzkoLjZakT633jHJMuYhEnAoBetQuUMTabbjYAdFeDCuSNvmRl8m2dSJImvWElyJs7c2mI/py+exdux/vBRijtzWY4i06EacvbFxdpgHECWLEwCruOWDEEKC9PToEUavLg+dAEbw/j+G31rfUBi6gpMB/IjvvWxut8VadSiqXN1CwFvhWwqklZbCHH0iRuBwmhNg 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)(3002001)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:BY2PR12MB0695;BCL:0;PCL:0;RULEID:;SRVR:BY2PR12MB0695; X-Forefront-PRVS: 0632519F33 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(7916004)(346002)(39380400002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2361001)(103116003)(52116002)(53936002)(105586002)(6486002)(4326008)(23676004)(9686003)(25786009)(50466002)(2486003)(68736007)(7736002)(6666003)(2351001)(97736004)(6916009)(66066001)(230700001)(76176011)(305945005)(16576012)(5660300001)(106356001)(8676002)(386003)(33896004)(2906002)(72206003)(186003)(33716001)(16526019)(476003)(956004)(59450400001)(11346002)(77096007)(26005)(47776003)(446003)(316002)(8936002)(81166006)(81156014)(6116002)(486006)(3846002)(478600001)(575784001)(86362001)(58126008);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0695;H:[127.0.1.1];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwNjk1OzIzOlhvNFd5OFZFUWxqbko2NjJPTVlmVndpSTly?= =?utf-8?B?NktMazhZSDZaRGJYRXhiOFNOdmxYeUZBcDVYQzh6b2hpM2NPKzVtQ3h5dllV?= =?utf-8?B?WHFtemNCNzNUS1BqdVF5eUYzRFladW5qRXhZZ1Q3ZklDYVFEQlQxakRKazlB?= =?utf-8?B?bmp5MWRod016K3BuRlVBMktadHBzc0ZJdnVhTUZYWG15T3dmeGVGQkhod0Fr?= =?utf-8?B?MDI3K2xyRzJDTjY0T0R5WHA4bURubFdVYmM3ajRWOUdCN1Q0eXJDUFhjbzMz?= =?utf-8?B?cHpFaXh4M25mWkhaRk5KOEM1N0svR1lYQUlFeHNNYnowWHlIQi90ZHJPYThw?= =?utf-8?B?R0I3NjdQdlZGS0NmSzdXa05vc01BaVRKVXdSdlRpM3lpWVJ4SDVTUSs3c0FC?= =?utf-8?B?bnpJbFp6T2NLenhaYmdLUFV0WGQ1MzAyRXFndWEzOGpmN0lrK2ZkOE9jYU5r?= =?utf-8?B?MU5ieEZxWFpEMnhuV0FkMWdmNGVYd0o3OGtUNUZHcERocHcxdzVkY3g1UjNN?= =?utf-8?B?YitjTCtybnpEenB1T2FuUXlsa2gxaEhSSnZmdFJWSndmcTcweERTZ3c1eitZ?= =?utf-8?B?dHhyeHJIOFdxTDBKK0dYbDFSalprR0hlcy9HcUM0RGhjbHFtd3lHVXdSOGNs?= =?utf-8?B?QzBFWjM0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Y6f57kFIAhAqwAxablS29eheVTc0UIA==;5:VoBVETu55mBFh350ReKTmngi9Y8Vqlj72E2z8mLlVTz6eJw3cmh1t8KgTD8Hthsv8442QmQMXk0UKlYyoqC5/UjhyRVW1A96Oyw/Z+K721ZbtW6Z8EcBjNxFMwg01E1k7epTVsBs8c2IBlh9f92tn0GEqu1+jBgy3R62q/yXrLw=;24:OlQOYSDpFX2yVWGK4BgrWjyfXlr6vbEgdiIZRvmzxD+94muliGmnHK6dtHoYkqAz+LlqXrMn8ldDaDIH44VLEM/D7WG4Q62lWudw90yD+yk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0695;7:/QEszLjmqObrjQ5dJG4JmdnB4/AlFC5Yg8uoxftEVq04/KqpyJyod3UFKniCv/Ecc38yZlu6gUeQTirHj7UeyTCIn5q3OQheAHUHsav0USHcPfLlrVy8+wtYz2oxNJSftQRr7fm5lRQLVs5lQXUuA3QzDQnnjnVEUS6Av+PxZbVV6TJbtkdlj6fYy5GkmgzV2Pql5FweCK2TQ+119qn8OSivfSAC5VgF5/Ei03b/c8J14w/mnbW9qahpBz+KJXz/;20:uAFX9IAwtG9bt4ZDMX47j28l4TqNHS7/lL4vNaPZAupciCOZzB8QMdKVcROEwD0TGpI3o71kgTYH7EMOVvmw4xCa+V8v9B9UKQw+Vh2wPLAJWNkBmZaqta5QdPbmydU0FfKesffh+awF5JrPskv7sFYGb2t7BZVEA6DsrovKTQkr7GkbTJWk3xT1C+UUrMF4s8b0REIiKFOxBaDA37Qam5BdCfg2WpW67BHEEndDiNxEFDf7SKi7+OzYNiV3+lgM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2018 18:55:11.0124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 811483c9-57f4-4068-bac9-08d59a5d980e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0695 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/Makefile | 1 + drivers/iommu/amd_iommu_debugfs.c | 45 +++++++++++++++++++++++++++++++++++++ drivers/iommu/amd_iommu_init.c | 7 ++++-- drivers/iommu/amd_iommu_proto.h | 8 ++++++- drivers/iommu/amd_iommu_types.h | 3 ++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 drivers/iommu/amd_iommu_debugfs.c diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 5eb1121d54b9..0ca250f626d9 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -11,6 +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_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..282100a655b3 --- /dev/null +++ b/drivers/iommu/amd_iommu_debugfs.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD IOMMU driver + * + * Copyright (C) 2018 Advanced Micro Devices, Inc. + * + * Author: Gary R Hook + */ + +#include +#include +#include +#include "amd_iommu_proto.h" +#include "amd_iommu_types.h" + +static struct dentry *amd_iommu_debugfs; +static DEFINE_MUTEX(amd_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; + + if (!debugfs_initialized()) + return; + + mutex_lock(&amd_iommu_debugfs_lock); + if (!amd_iommu_debugfs) { + d_top = iommu_debugfs_setup(); + if (d_top) + amd_iommu_debugfs = debugfs_create_dir("amd", d_top); + } + mutex_unlock(&amd_iommu_debugfs_lock); + if (amd_iommu_debugfs) { + snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index); + iommu->debugfs = debugfs_create_dir(name, + amd_iommu_debugfs); + if (!iommu->debugfs) { + debugfs_remove_recursive(amd_iommu_debugfs); + amd_iommu_debugfs = NULL; + } + } +} diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 6fe2d0346073..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; } diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 640c286a0ab9..1cfaae28c2cd 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 +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); @@ -58,7 +64,7 @@ extern int amd_iommu_domain_clear_gcr3(struct iommu_domain *dom, int pasid); extern struct iommu_domain *amd_iommu_get_v2_domain(struct pci_dev *pdev); #ifdef CONFIG_IRQ_REMAP -extern int amd_iommu_create_irq_domain(struct amd_iommu *iommu); +int amd_iommu_create_irq_domain(struct amd_iommu *iommu); #else static inline int amd_iommu_create_irq_domain(struct amd_iommu *iommu) { diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index f6b24c7d8b70..43c52797810e 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; }; static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)