Received: by 10.213.65.68 with SMTP id h4csp622838imn; Fri, 6 Apr 2018 06:19:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+AK+LCxt9kvtdflJuuBIGNtY633AVRCkDgGiNGscKowRl9Z5qP76vJ4Bv9Rw+8PR4iZkO3 X-Received: by 10.99.52.135 with SMTP id b129mr17989551pga.308.1523020788151; Fri, 06 Apr 2018 06:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523020788; cv=none; d=google.com; s=arc-20160816; b=FlHmQxZe5mifZSOifH1vlr/N1gYVQb4LTcizY4D1MB9d28UK31E/Baii8q4MAfjsfO 5YHWb8kr2hXUpG0QuX6CRa6opkIBNU0RXO2FsOkZViODKi+pIsvvkjd0ULYuBtMgTGxW W76Ar3J3o1/xGk+cp4ExSRDfD2GUj0eqVn0+pnaTEn5D9O/PCgGwx5qU927IoKXe3Zax OXV1ok0rfUaGTZCQEPyIWWgQdoeSpSYtsoGt8ZTcyp8moRRl/7cMMmlYxoqVb7yp8Met Zb9lhmyTpYaKmtX/TsStWV72ZnQv6K2mO2fjU1U/+ckg3hZfI23ArORMoRtfeZRGodi4 XuvQ== 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=aYo1oB0U7PetfOwpY5SyJREpWdGcuMlMVBpuvJj7I9I=; b=syNGGnSBv4N880WMh84TjjAhyR95mUJW7OsKWR1m2V+crwOY89dcCV2ppZmFUWZeBX VfGuU0NkeLm9EzSNGv9kzSAAAT9CS0C50PNNYzCS9hEDDzFKrgE4Dgc1HUS4F0dfmAmH 5/TCBMPSxD3rw9BlPP6fAx3o3aSUbawbnPf+zrqQpkd1MKWR+Ig+zCnAPFSADKTUcZ0t aV3k3BttLdGTn1Qe8Y6YJGYmkYQ4ANpdmCuUGPT1kLFK5UIMbXcwO4UxV16KtrZ6e+bp 5GkXXlA7hYQs2tkzHOGQaLmzpw+wHojNx5jS30WR1D02y9IdKdW8OX8sYSHt9l7CHE6o /E6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=NrSDi/AZ; 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 v13-v6si8782030plk.153.2018.04.06.06.19.34; Fri, 06 Apr 2018 06:19:48 -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=NrSDi/AZ; 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 S1753174AbeDFNSE (ORCPT + 99 others); Fri, 6 Apr 2018 09:18:04 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:31187 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753149AbeDFNSA (ORCPT ); Fri, 6 Apr 2018 09:18:00 -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=aYo1oB0U7PetfOwpY5SyJREpWdGcuMlMVBpuvJj7I9I=; b=NrSDi/AZNOISyVRYCUC0L8Mu10qOLytTrkd7XDKXtAnSoZtUQT9rZ+SuB8UsYr36B/2UIltDKNhLdhw1Y24g75d10Q4vxNLz4mbWlVMBOQlkBAhZObP0mcxnv0iZol1vu2/MUcQcq6510YyKPCPwcPa8FzVkXT+SE9Q4W1yE3Bg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from sosxen2.amd.com (165.204.78.1) by BY2PR12MB0694.namprd12.prod.outlook.com (2a01:111:e400:52df::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Fri, 6 Apr 2018 13:17:57 +0000 Subject: [PATCH v3 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: Fri, 06 Apr 2018 08:17:53 -0500 Message-ID: <152302067362.47565.628887796165116844.stgit@sosxen2.amd.com> In-Reply-To: <152302042701.47565.17954813724758433858.stgit@sosxen2.amd.com> References: <152302042701.47565.17954813724758433858.stgit@sosxen2.amd.com> 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: DM5PR1101CA0006.namprd11.prod.outlook.com (2603:10b6:4:4c::16) To BY2PR12MB0694.namprd12.prod.outlook.com (2a01:111:e400:52df::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 75641174-3a37-45bb-40b4-08d59bc0d06c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BY2PR12MB0694; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0694;3:fFkei7YO4fkf9QruXZA+p+Uo1JdcVrSIzCfvwoLLPZhYtQcAifv4vV6fz5a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/+bLZ+z40iyxSMCmyL0jtx9mDZjTxNU7CblQg+rFDssxk0GEzohal3xydoJ/Vkp3CW5KZh+JQUbOKYUrS7TMF8v2SOjIJbsgDxsuCQtjxyI2M/XyymMeTmaWkzNW+cLjlJ2abN+XNzk8cU5vYBtkRGKzTX9k9wZK/8tqYV5mt9vGV8vKi2lhQlokN5h6snRiEx/hXUG98aakrZYT3Nm/Y9Fb842P0EL45+kLB5Di5qzgCaQC1699QvZ/QmoanNsUstyeRJYdGghhmNFVn/VznbSybFSJ1;4:G4bKcMvvp9BDhLQYjL180bGPmipbjSrgIxW6dQOmQhkpy7xsdQQqr/hztsGh9J5lBMQDOZvuyAvppzb1zoJWMVxyT+9QG9/rB+L85ZMYjCBcZLdj+3aZUxqNw6EMKrUiLSLrtpHd5rucnR1uXNQXGRqW69YltBCinLUaCgTfNMNnFFvPK1h9fXMkTdy/VeDnuZ0dTtyMPfn/mYSzQF8FCshSu68y1yBSIOwRgm9mrTkaJ5K0ByBDZgt59kg89EkAUd7Ek7yTjtBF6+ixXdPDteMmZWy3RhLuX4AhQrCTMTqYlgJcBiJU/LVfCrR54lVG 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)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011);SRVR:BY2PR12MB0694;BCL:0;PCL:0;RULEID:;SRVR:BY2PR12MB0694; X-Forefront-PRVS: 0634F37BFF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(346002)(366004)(396003)(39380400002)(376002)(189003)(199004)(486006)(956004)(11346002)(50466002)(58126008)(446003)(16526019)(476003)(186003)(316002)(52116002)(47776003)(76176011)(7696005)(23676004)(2486003)(53416004)(55016002)(53936002)(66066001)(106356001)(6916009)(6666003)(478600001)(4326008)(25786009)(8936002)(86362001)(59450400001)(305945005)(105586002)(386003)(68736007)(575784001)(103116003)(2906002)(6116002)(3846002)(2351001)(97736004)(26005)(5660300001)(2361001)(230700001)(8676002)(7736002)(81166006)(72206003)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0694;H:sosxen2.amd.com;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?MTtCWTJQUjEyTUIwNjk0OzIzOjJlWHo0VUVLWXR4K2FKVXc4TmN3cDJFeVdH?= =?utf-8?B?SE1qeVNkR2ZtZDVORWU1eUJpMmRlN01Tdnk5TEt3VEgvTGpBK1M5STArMDYy?= =?utf-8?B?aHdEaGNybkFvWllFSEdNa2t3QnAyTU5KeEI1MWdpbTJUOW4xNk80QXFtZWhJ?= =?utf-8?B?VnZEM2sxN1c0dExUUi81VzJNalVlMW8rWS9ERGw0S0ZNYVVCbnBZOTJxUGll?= =?utf-8?B?UjhHbldPalFTcHBCa1Jhc1pYUGNQMVlBWTY3ckpXY21tbmo2MTc2ZVI5blc0?= =?utf-8?B?TVBmV2VTUGQvUE9GUlVBaktFa0FUMU9oWWR0SkZ2L2pva1hhQStUK250eW00?= =?utf-8?B?c2ZCWXZhaDZmSU5ERkFpSEhnaVVCam52WjU5MG1ndVBHL0RNakptdXJHK0dR?= =?utf-8?B?aTA1bFVyNHhNM3JCa09FdjB4T0RxL1lQVHdKM0RKbjFaVmRLZXhIZXE5ajBV?= =?utf-8?B?QmFnVVJ3UGp3M3NrWmsvZEg2K2ZRb2ZnMnVYSSsxcVpwSnlKVzdqY1FsaDNl?= =?utf-8?B?R0d2TGpqSjJXWXR5bis1dHg5NGNMeTBTd2tWOVFUbGhvdHN6L0JCRmlwOUUy?= =?utf-8?B?aHJCVV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+nAIUqknJofcZqyHxXMQT1fZirGmFR+4wkGq2tkr3T3rZC8SpxjFMEtWFiNwmnHVMvaF69NDXhj364jAY6D666io8=;24:4wC9AaSW3Rt6OxIVOKj4J+Zy//DJIGfHELZZN9SAFmKr2edZUG2OWEeABjYviCq32vz1vsR1q4yxlx9MbhOJLenKxxOPhvlgjoPrzp0lWYE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0694;7:3TTY19QzgSQ4BHaEVbtTqHJIgg9Q2THwujE7kSPMWbW+MMqShUaAOT59wHBXw3p0OxciAeXBhVpCW1/RZSHnpLCWt4wYt18ZsnXIar5QAZceGhlHyJDB3YNOl6OzQ1c/XcFvVCNQqroybtGvnpDMsTLIJW+0XPfHNkrE/r59PhMuYj1c1WKg8MFXQCY/Oru5mksB4AAGAQuJsUXovoSCbN+ESImt5ltDn7ktIernAWopyiA0Tk3+uXjwmC7IL5Sl;20:jqX8Zo5o63v+66KcRpPS9MIjKV2o7UAB3XfKnhDmQ8M7K5/5Kyz0ZjoFTKsazWs+/aA3N2A9l56FwqVUbkNax6S8dVpq2Q7JLsbgJh6dIpXSGyYdXJDs87GCz4d1q/M8iHLFzuFvqJ2lPpkhzpJUl6+JMbEu+SXzzBAeyDyEqmSWljf35AKQzXqNtrGhucatvmbh6YdstHaEb/eje2uT/HmAXj+fXL8rr39l3nSFsJxlq+wSGdilM5cTwCy8g/dt X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2018 13:17:57.1043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75641174-3a37-45bb-40b4-08d59bc0d06c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0694 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 | 6 +++-- drivers/iommu/amd_iommu_proto.h | 6 +++++ drivers/iommu/amd_iommu_types.h | 3 ++ 5 files changed, 59 insertions(+), 2 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 904c575d1677..031e6dbb8345 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -2721,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); @@ -2730,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..daf7f38531f9 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); diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 1c9b080276c9..2ca0959ae9e6 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -593,6 +593,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)