Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3677601imm; Tue, 29 May 2018 11:25:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKcWfvReezCEt/IE4XuZ6fioK0n+q3Cl1mhESGrMfN8SdT141qanXtJlBpnoH6/CE7mW9tJ X-Received: by 2002:a62:18a:: with SMTP id 132-v6mr12945669pfb.62.1527618308937; Tue, 29 May 2018 11:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527618308; cv=none; d=google.com; s=arc-20160816; b=goBuWzyULRA7SRscOZH4ghG0IwyaVZVyWvwWO7nYoTGs7QviEJdNZWb3UBaYKYOvLh qNtfpboLv0YUb5mhbD7rNkfqCU3PRkUgsdjdyyTYiRh0FzNanM5ZP3AULonmVQ5tRQXY /dpkm9UDVLnfn4DjjMJnZLjH8EprcPvWK8kSvrRSxVOZx+7UApyjIZq+QQjSKQSD/UF5 AnenhNhtagjqjjTC3NBW+yX/tJ16I8MUCJGG7XuhOiXm8bz3zu78YvrCHu4b+tOlyCvl HXoMGFCw+VMP2L8ArqBzs/ZE4e8z/A3ynxeKQ4v/dAt6fxuG7fBx67URvPBn7Zmmc1Tx TlLw== 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=IBSAPcaNslFtzMYnFnSyS3cejl34uChUN2kOm5ZfsgY=; b=hE1u+H5rkHxdTm5uBf43bUNurjP7nGkcGQnd7kMdBupIVXYmGXLmjWty0c/c2gH9Qf rgE7cedg69/cne/P/kXYCkUx5IIiIOp6U0wvKSzGciV4cCZFjkDBQBvW7RS2Td7xZ3h2 V1nEHXgv6LfzWTjybe97nQsTM8TibNPUkDMuDQKjiFGqluKutC5AHmHJPwWzhX/vgQvQ Ap3zh4igPzyJ1yD7rXUWFqgfXnpaFCagrTwM/wkqjTtD6SQUiftp07n6xJ+MQCpFhFOL 2nAG700LBGdQIgpiZ9c8RimR1uwNceMFBgcfSGBm50m3ASIKf94RGGE4ZD71E8mdb+On L3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=I8lYf82v; 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 l3-v6si2172169pgp.345.2018.05.29.11.24.54; Tue, 29 May 2018 11:25:08 -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=I8lYf82v; 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 S966230AbeE2SXq (ORCPT + 99 others); Tue, 29 May 2018 14:23:46 -0400 Received: from mail-by2nam01on0071.outbound.protection.outlook.com ([104.47.34.71]:3040 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965954AbeE2SX3 (ORCPT ); Tue, 29 May 2018 14:23:29 -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:X-MS-Exchange-SenderADCheck; bh=IBSAPcaNslFtzMYnFnSyS3cejl34uChUN2kOm5ZfsgY=; b=I8lYf82vl2m3xWx7phgbhZ4Tg9GxKrriRqcgh4Ss5Ydvkw5VZLsqZ4T8O5K2Rf1HUqRGcXVZU5HWQgUq/LS4vEYnxLBRc8q4BT/8hHV7zJKz1fYwArZTBTx7yI8MxmLbRD5ox0gERJynjoHSMAaTZCaqlhkK6N4FlE2A0eayR6E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from sosgrh1.amd.com (165.204.78.1) by DM5PR12MB1452.namprd12.prod.outlook.com (2603:10b6:4:d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Tue, 29 May 2018 18:23:27 +0000 Subject: [PATCH v8 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: Tue, 29 May 2018 13:23:23 -0500 Message-ID: <152761820371.2654.4551405686504157036.stgit@sosgrh1.amd.com> In-Reply-To: <152761784341.2654.8609366076331539902.stgit@sosgrh1.amd.com> References: <152761784341.2654.8609366076331539902.stgit@sosgrh1.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: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To DM5PR12MB1452.namprd12.prod.outlook.com (2603:10b6:4:d::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DM5PR12MB1452; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1452;3:yL4Sdx4/i65KJYVUByac2qnCbpAlALvaM3fKw5raFPrAXMxV2rICajlKvAnOS8jrwwMCcmeV9rsNcoBk+996sPQlLhgBQjK/D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EgGxzWxrcWsZwRq2/iyVSlL+4LWwoEJeRau89QyTgJAobcgerXTt2Q284RDNjgwjJwsE9lsMURGaeHIwMeaIxNKjQiRTDruLA7lW5sIJaaZX0igSG5zpvPax+hzbAudDAOsWG3ONsuPUJVjuvovUVjZ7A4JftnCkV9rAO73Qcn/DSDKBj9TYKUh9y8xSdYOTpw1fqIWjFVlMl7QQBCKeP0hAiCoazpNa1CpCzXUgVwQ3HsrxKCRinsJHXX6ApXkgBz5/r0n;4:G4R7okD/p5UoUhra0+yE8AHA7VYopLO5X4BxqIFDC0OpvdK5wzy2OBF0AY2LAQcJN8VxJ2GxkocEraJl26gPO2rfu0BY0U+9RdGCKpJEUZsQYXmfZvdJWr0e9JoR+HL8hFxfKhWdpPMSiiGNpnLt6A+nH2KiAn4TxXwXJsSCTwkTtsASaZSBzpDWtyTMR/UqX8cUWClOnksGu3aEg38Khdtv4tRyFmJZVzhWTuizth661tnb8RY7RvWPIUw18Qq1l12VMGsfLs/GIBI5LWo5YMzb5cL97HjhY9o/DvJi5ZkQOxSwp23RsHinmFKTZjEs X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:DM5PR12MB1452;BCL:0;PCL:0;RULEID:;SRVR:DM5PR12MB1452; X-Forefront-PRVS: 0687389FB0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(39860400002)(39380400002)(376002)(199004)(189003)(55016002)(386003)(58126008)(316002)(50466002)(25786009)(72206003)(8936002)(81166006)(8676002)(81156014)(86362001)(66066001)(575784001)(446003)(11346002)(47776003)(4326008)(486006)(2906002)(476003)(956004)(76176011)(26005)(68736007)(2486003)(5660300001)(105586002)(103116003)(6916009)(2351001)(2361001)(478600001)(7736002)(305945005)(52116002)(7696005)(53936002)(186003)(97736004)(23676004)(53416004)(6666003)(59450400001)(106356001)(16526019)(6116002)(3846002)(230700001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1452;H:sosgrh1.amd.com;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?MTtETTVQUjEyTUIxNDUyOzIzOllUNVY5UzZPRkJyeUJPTGxRV3VIQnZMeHpM?= =?utf-8?B?NTlMYklYY3kzQmJWaGJYd2FvNEROTDVCY0NBd1JBWFlOSlkwa3hqRlMvMCtp?= =?utf-8?B?UXlDNGFXV2x3YWozYWtPbGxXQUM0QUs3N2xCVGxGdmVycGMybE9WSkRHZU9M?= =?utf-8?B?bGVXNWtZK2FZcENsZDZaMXVQbU1uRE5zWUJScm05VGlwMUVWVGEyZ1NvNDNJ?= =?utf-8?B?amwrRkpLQVVseTlKcTl2SExYbGdZdG83V3BKTnN2ZUY3MXBsR2xSWXhRcldz?= =?utf-8?B?UmNTQmdZckUrS0gyUTE1Z3lIZzlWd2t5OHEzMWs2RlF6VjBqOGZadEQ4SzJ6?= =?utf-8?B?a0dKWFFFMnk4THN6QW1oWG5rSStyc2RpU2YxbTFGZ2lkblVsZFVBbitxN0pR?= =?utf-8?B?b3NTeGRybGhwS1JVVlNSWk9DU3BySTJyK2JsaDlSQnpIWitNdHdDZ3NTaGJR?= =?utf-8?B?SGRCWUFpV0ZySWZiYUxCbXFvNlVYYko5dVpFSlBUeHBZaXFoQnNFbGNtV1Bv?= =?utf-8?B?T2lSNlFndzl2QTZPU2tHZkw5UEtQaXU0MzkzZkRrZzVaWFh6WEFudnBFK0FK?= =?utf-8?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OiYQ9t9QXHikJCufWOqxGuYeWN+rgtOiUJOSX/eEoR/M/Wx43S3TMhpiwU65smgqe6qeIl3qYQ9pDt8I469ffujmHUQftA=;24:HfE685oibynoQ0k04aqM9/YI1mxbIqmfS1rFpU224gls70g1M1y8ja30Gr3kHSDVCbK0Sjf78hbnkXAuKHyOy6uCi79qEWYEc0+1ll7nxvE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1452;7:DYRX/Zs5OA1uUX+dvJXUzS3WPqyjHKBy6+EgP4fK48e4fG6zFHcRTAX7swUAqOyBBjK4XVBHfU5Oi+rnFPhqJF2NrtvlSqs5Jn6f32Ky0p5oWpGmi7uNXKAPvZhubzpb3wwuvgSXIJ3Exk7jvXEk/vq4flJeEdSlCBLgHbXM6ejxrYu0/BzEMYC60L0AyTA2GjhGkOrV4WR0kNG8qSEgnRF6UjkaTsAf1Oqn80cSx1uNgm71xaRnr+XRTa05AZ/u;20:Fnvw4XSZKdtUIz26BBnVKOC9CYy5Mz6UPzDXPc1mPYGhWJtShUxwwlRRG/uslTbfT/iOKF3sgeREm9x8eVvr27aBdMU86jUhuCdMrgqPQ+89JSt6GuzqIEirzX2TOv68U186m7ksxfSWWoPCpJPVnI8IoIjpxjgMN1ab7BeU45gZq/NIlJO5XYGH5zxzOEAT+W20BpsbriF8N2xGQmy8Hgw3QIggPULU6U/uhuT2AEOh56jSL94MMiSxmgEg0YP1 X-MS-Office365-Filtering-Correlation-Id: b73491c1-b31f-45ed-2156-08d5c59145c1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2018 18:23:27.1039 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b73491c1-b31f-45ed-2156-08d5c59145c1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1452 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. Add a hidden boolean to Kconfig that is defined for the AMD IOMMU when general IOMMY DebugFS support is enabled. Signed-off-by: Gary R Hook --- drivers/iommu/Kconfig | 4 ++++ drivers/iommu/Makefile | 1 + drivers/iommu/amd_iommu_debugfs.c | 39 +++++++++++++++++++++++++++++++++++++ drivers/iommu/amd_iommu_init.c | 6 ++++-- drivers/iommu/amd_iommu_proto.h | 6 ++++++ drivers/iommu/amd_iommu_types.h | 5 +++++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 drivers/iommu/amd_iommu_debugfs.c diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index f9af25ac409f..ec223f6f4ad4 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -137,6 +137,10 @@ config AMD_IOMMU your BIOS for an option to enable it or if you have an IVRS ACPI table. +config AMD_IOMMU_DEBUGFS + def_bool y + depends on AMD_IOMMU && IOMMU_DEBUGFS + config AMD_IOMMU_V2 tristate "AMD IOMMU Version 2 driver" depends on AMD_IOMMU diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 74cfbc392862..47fd6ea9de2d 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_AMD_IOMMU_DEBUGFS) += 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..6dff98552969 --- /dev/null +++ b/drivers/iommu/amd_iommu_debugfs.c @@ -0,0 +1,39 @@ +// 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]; + + mutex_lock(&amd_iommu_debugfs_lock); + if (!amd_iommu_debugfs) + amd_iommu_debugfs = iommu_debugfs_new_driver_dir("amd"); + 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..a8cd0296fb16 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_AMD_IOMMU_DEBUGFS +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 986cbe0cc189..cfac9d842b0f 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -594,6 +594,11 @@ struct amd_iommu { u32 flags; volatile u64 __aligned(8) cmd_sem; + +#ifdef CONFIG_AMD_IOMMU_DEBUGFS + /* DebugFS Info */ + struct dentry *debugfs; +#endif }; static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)