Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp867344imm; Fri, 11 May 2018 07:35:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZppynRkpIAdD9+vR9kQxm9T3sYzOrHBGKfXF4uU4VzZKnthO2M50eO9/q2DC3xXHhsNR/2w X-Received: by 2002:a62:e107:: with SMTP id q7-v6mr5757721pfh.226.1526049318468; Fri, 11 May 2018 07:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526049318; cv=none; d=google.com; s=arc-20160816; b=Ajo0q7kVyBS02skwHrkvvbA1F3/Rg5BIwigfrJC5NKJuaBFBkxc6iESJzx+VWHvGzv CyxZfTk3R/j+aXmtYaJSq0Oz89s66wwIOo3VkmnHeydnSTd/GgxTQPD+O9TrRk3X+q8J Vup8nDsCci4z//6GT648QuYC+G6L6qqF50wKDXFgH2W6fO9Q7S4DF+cvperlMPbiXxvw rDYFuJi7VwE0Bbd5PACP4Mfvf7gDh4P66LjDJ8K69i5q0DZc6iC9RdYXjqIIs2RLAR0P iN1Zl9hFZXURLoCOO/3NUgbqzfpusqOsFDyYO8YbbTkAjB6sag05tojVEgVwr8Yt+5FC kNMg== 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=IMHFDkGRkZPOKvb+TyuBFhhXf70cLgb/V+WZTxYWM5I=; b=GsyDi1lPGcTz9YMFFr6mNQ8ve7SvTD2MwQFOP3A74dXKSGBVZ2wzwsHNBrLU9VgaSt oM/SL2F+Svi7bmB2K+bR4RJZKH2XCrkBt2k1GCZAw3b+/tZxhn8l0hej+Ath7nzAS7Qh ezIv5PhHCIjZ4QhnIU1KEw7GErmQ3G0kk/00kY/hH/Okb/UmU4jzEHVyoq776z7eN62S ifE6mriDaoFilOLWty9IFNykl8VxxEQSagNvYEH/QD/+1y+Z7r+s+bMwmbkwVJE7D358 B9OM70EJkTSeY3iTDqA4+lepp6iO4AqaplePiIMOhPkBJlW/wxuvzfOv+5gVaBT3k+1z rHUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=TvlTJPWz; 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 t124-v6si2647799pgc.465.2018.05.11.07.35.03; Fri, 11 May 2018 07:35:18 -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=TvlTJPWz; 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 S1753244AbeEKOe2 (ORCPT + 99 others); Fri, 11 May 2018 10:34:28 -0400 Received: from mail-bn3nam01on0040.outbound.protection.outlook.com ([104.47.33.40]:6061 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753191AbeEKOeZ (ORCPT ); Fri, 11 May 2018 10:34:25 -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=IMHFDkGRkZPOKvb+TyuBFhhXf70cLgb/V+WZTxYWM5I=; b=TvlTJPWzuK4KdfH6yJE/Dkyfpnpco/EW4G0zzyXkfCXL+62cjy9Aj1RsyJ+wbEWINVKwVQkmHKnc8cZW6Ve8IMuEBSJABRrfVZ66oSioXdEGvpFEVFI3IDCWeM0BDP0U6/mNqZTDhKX9Mb+lec2zL0CaBI9cPIzZg3DqEOTwcHQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from sosxen2.amd.com (165.204.77.1) by DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Fri, 11 May 2018 14:34:23 +0000 Subject: [PATCH v6 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, 11 May 2018 09:34:20 -0500 Message-ID: <152604926050.106201.12749369479920979102.stgit@sosxen2.amd.com> In-Reply-To: <152604905217.106201.15533883255216330970.stgit@sosxen2.amd.com> References: <152604905217.106201.15533883255216330970.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.77.1] X-ClientProxiedBy: SN4PR0501CA0054.namprd05.prod.outlook.com (2603:10b6:803:41::31) To DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:d::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020);SRVR:DM5PR12MB1449; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1449;3:o3WnzdwtmgH1tfMPROrwwlOsoPCqpxp2KFVRtOPQhHhtbgemCU2mz4K1Wn98SnlwYDm/CimGcdoWL1W69QpJLtJ7d0GVGTffuzFvv3zlvSBp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wXAFUPDBe4NDGbnsYTbtklbLPiaR00uDa7lvmDzWogAo+ukDsSJXbTGF8NnJ54zvS+6dkVoOSmnx4QXi5t63isNERh0wCDiOYB1pUdQCk1Y8M8Zy+WeN8gre7/hWHakKQUPQzwPhrhUk+los5jpjY13im3ktmYMZLkgkVv9umHUfdF6jHH2T/ScZszLnQ69aypDW/tC12ShAYmTVpDp4UvsF8IETFGxrjBDR+O9kV+JEqLjz+2;4:OYSjFal+tJa7RqqnotdNDp/6ouSoDWwWmrHkHs3gC2qM3wth5Go4OECW+Cx4PL9EoFUa6E1FctrDtaMfC7Gu2c5IxYFoJ2AtHFS1bl5UhAbi7gM6s2LbtmT/u0T7LdfBFy9ttvXwG2CtfZI40radH37A7DaawncqVfSRgSUQNCgWgtjkuZInWe/+t9i+XbKecJTiRxCDsGo9JqsWMzZKfYU9INxFO+PF2HOBDojRAV4ptLMWugV2n+gnZ9z/TLsDFHcQUvi1jEK6v5yB6ZG4HpugIsF8ucOHB6IH3szPn0Yy5w6UqsRR9A+H5dMTo8YZ 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)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR12MB1449;BCL:0;PCL:0;RULEID:;SRVR:DM5PR12MB1449; X-Forefront-PRVS: 06691A4183 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(346002)(376002)(396003)(366004)(39860400002)(39380400002)(199004)(189003)(81156014)(2906002)(8676002)(956004)(11346002)(446003)(16526019)(5660300001)(476003)(7696005)(186003)(66066001)(47776003)(53936002)(7736002)(305945005)(50466002)(316002)(386003)(8936002)(55016002)(81166006)(575784001)(486006)(76176011)(58126008)(59450400001)(23676004)(86362001)(26005)(52116002)(478600001)(4326008)(2361001)(25786009)(3846002)(6116002)(2351001)(103116003)(68736007)(106356001)(105586002)(6916009)(230700001)(97736004)(53416004)(2486003)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1449;H:sosxen2.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?MTtETTVQUjEyTUIxNDQ5OzIzOjc5V3hHTDY2SkNsdkp6eVFmSkJXbm5tOEpK?= =?utf-8?B?S3NpczlvM25PQy9Ud3RkWW96OWYzNTNlQm1yMnBMbWRsejlTc1hES2ZTcEpz?= =?utf-8?B?YnZQbDZRaklZUXJKUlEyQlp1WGhzUmhqbUsrUnhNMkk5SE5MdURKdTg0UXBO?= =?utf-8?B?bWQ3a0sxNS9hN3BwTHlhaHhVWnJXWGUwMmY2Slo5aXo2a1NOdHRzSHRTelFI?= =?utf-8?B?MW92RGpqK2Vnblc2RzhVNlFJcGNJcThrU3gzOTJ6RTRLMWE1ZUQwMmpQMkFz?= =?utf-8?B?VnM5dk9iN1BFYVhXd2dXelpBcExiOHRhR2h2cXR2b1dLOTc5bWhOVGVXQnAx?= =?utf-8?B?K1VJbkVRWmtqa3ZFcURuZEwwWVlrbGpUNzhCVmttVzZDaXJ6OHgxMmdSczhj?= =?utf-8?B?MndoR0lOTnplY0ZyRndHdFZkUlBkNndaWHRFY0FHUUxTalF3Zmx2bUFNK2lk?= =?utf-8?B?MnU3ZWQvMHRvS3doK1pabzdVSWpHQ3dFckJyVTVkVWRhbHRTLzJXUWtrZ21h?= =?utf-8?B?MXpMN21sZElaR2dsdnNWSGMxTFQ1WDdveUlyejViWk80aXU5em96enM1Ukhr?= =?utf-8?B?QlkxYThlay9YY20waDNqaGJwdWNFL2hIVm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wsJz82BBtnDrkDoSxpGF84+9R4/CO+6UbhE/3Tf7hFKXX55CpG8E=;24:wm1g9oKH1+VLsV4I7B1gsgUcDQezVDnv0bVpiW+s5g5hfuZK/osBALRPGqm6jDJvgqHCW54QTQEWleXJmuDFF457hMDW+/jBGScC5p2254o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1449;7:T9VA5isoRTIWwAQjuxA/3BEm09H8iEngNjNPrcINxvS2G0fLjQZglMsWav9QyF2H0PlTZjJppmJWVutsBoWdh3Yr4RmzEYsod+HK6OAIdwl9UeSBaBss9g3IvdkonNJzsLJ5foW5Jq1f67Ra/Cxaw4StjVeaLx7bQ5fVN/XuuWfPhD29KJEIQRkv10t8xu0AFxZFYDWErvA54QDYjKvUXDdCnPxyw83fykO3BWpOpuGvl+WtyLRYfDu9BkhN7Yn+;20:nNIvilElMhcpqOWFQnDTJBb/J1FmjWfDv4FeEABN9E9ikoVyCqX59DFF09Sf/Dj9PF8waVSRodF7Sm+u/2n4EV/mkutUOC2KbchROnisk5f4kW6mEBaI02NQJYCEpZDfz9UGrtmPydfsxNSJFjTPkGE54rTLkPpH2MAaYquRGRm9ms85nFI5DLo6dlQTmd48eE/3kCNxjcDZ2jdXKJl2PUi0dAKCsDHCjmi+fIAXQtU7WmyWoc0UP6qWRZjkDkd4 X-MS-Office365-Filtering-Correlation-Id: 4ab9433e-b432-4be9-5c72-08d5b74c4a6f X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2018 14:34:23.3721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ab9433e-b432-4be9-5c72-08d5b74c4a6f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1449 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 | 5 +++++ 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 | 3 +++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 drivers/iommu/amd_iommu_debugfs.c diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 74cfbc392862..dd980f7dd8b6 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -30,3 +30,8 @@ obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o obj-$(CONFIG_S390_IOMMU) += s390-iommu.o obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o + +# This ensures that only the required files are compiled +ifeq ($(CONFIG_IOMMU_DEBUGFS), y) +obj-$(CONFIG_AMD_IOMMU) += amd_iommu_debugfs.o +endif 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..39053f11dda3 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_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 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)