From patchwork Mon Sep 18 17:33:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "StDenis, Tom" X-Patchwork-Id: 9957219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17701601E9 for ; Mon, 18 Sep 2017 17:34:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 021E928D6F for ; Mon, 18 Sep 2017 17:34:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB4C028D78; Mon, 18 Sep 2017 17:34:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91BFC28D6F for ; Mon, 18 Sep 2017 17:34:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 226696E3C8; Mon, 18 Sep 2017 17:34:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0086.outbound.protection.outlook.com [104.47.33.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id B25BE6E3C8; Mon, 18 Sep 2017 17:34:04 +0000 (UTC) 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=WjfizdlepeWH6V9NbTVWHKapQKWTjAZMWapHfWvx//c=; b=ZmZ/zoUjCCAf5ujE885DtC5m9/Pb811sdY3QR1zUAj7gYZaNe8402SLL/0lLT01nGDDBhxz/ePhxBA8co+F863JAqif0RnAfhsoGthvrQrDWBcXw9jQaz4eGhm6ECR9vf7lg4E1yPKxB8G3jM9i+NkOVJaxMFZSo1Bny3cTV7mY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Tom.StDenis@amd.com; Received: from fx8.amd.com (165.204.55.251) by MWHPR1201MB0079.namprd12.prod.outlook.com (10.174.98.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Mon, 18 Sep 2017 17:33:58 +0000 From: Tom St Denis To: amd-gfx@lists.freedesktop.org Subject: [PATCH 1/4] drm/amd/amdgpu: Fold TTM debugfs entries into array (v2) Date: Mon, 18 Sep 2017 13:33:47 -0400 Message-Id: <20170918173350.9543-2-tom.stdenis@amd.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170918173350.9543-1-tom.stdenis@amd.com> References: <20170918173350.9543-1-tom.stdenis@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: BN6PR06CA0031.namprd06.prod.outlook.com (10.174.93.20) To MWHPR1201MB0079.namprd12.prod.outlook.com (10.174.98.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4a947d3-a612-4db0-0ab0-08d4febb7238 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR1201MB0079; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0079; 3:jJ0By6LEC24q5XQT0Nd1fV2Qn7fr1zywevDihvFz44gpvjp+rdvwMFEBbzhDxpX5OisBFBO+8LPQqvCgJhEzZfNZibm6POl9GqFu417E9ngdBb0rRttcWp+fSr1phNOmBpiwvrxhHtRVo0QuvJSFUXmWZc/QTqzMBZn+B+pnfNiLn5I9+S+nWMi6B21fSVU7YcFOnyLvEGqkOkzIN9ZLaB0SCeYDTIy3oqjkyCNz4F12pCbQxgGJZR/iYRMdADt1; 25:ftQsUvKuYlsAr787CPJaWox593XxuH9Pp/x+1nscnn8qGLvRDl2xDEBEUL++k729xR9ErR05OIKgRHIYShEg2mZ9/j6+OBCKUDXqFmkkPa6xDoZl6NuOtZpbZyHWDWu7pklFCkcNmm0vBAkwioRg6jLJ5JDZL5mHlyXQeo8Rl+7srxouiQznQXWlP/bgZFPHhnng68FFUCXYQJfINtqkNyliACpQ5NREbY14rb096Lzml9rnym+QtKdjRjc6FKcok/MAHTAAT7p8zNlApXolZHyz+3YgKmI6xRJDDWVHDs4O03fxWUJV2SJcH5R/pkI2gDl0i+3w3TY6aw6oDWhXbQ==; 31:67N1MnMWD8Ck05os92HxhVBOr7PvV3F84bFWEt1cNgWB4BLgs8WtKlGMJEZre/kG7NkTsvasHTrzjqJNgbP9ycv2rIeGtFQXTV1e7ynQ+WruPKV98psIQ3ftu6iBPaZNrm4ZMdc604116ykAAaPoiCtEzU+PasMiyCBpHZPhAG8Uc35M2aL571nMDzQQVr/BvfvFtKc2Xpf+ah+Uqk9TWlVxw85A+Zec5BkDC03cv9s= X-MS-TrafficTypeDiagnostic: MWHPR1201MB0079: X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0079; 20:dxDJc6T/gDN5lYFbugu/+H7SUY9424o4eWhqHLRqMTUG+g24HY7mj8jQRzMcFMXnSU86NqJcJKZ0lGsIKfBJrVKMy3aAkf8JdA1X28cjDgnkxb8oFKQsTo1cnRlr8cixAb5Mf89jZ8vnQQ8uIzGVj6IlqqqSs/VSumSfdySzLLPQcpikOW7dztp8CrsYHedZyBgYVmwB6ZZvWqu+mY26d/bYHEmlAezLuH7RDI5kJwUzrD9mkBiJkh6VF/Nt8n2PJ0ZGDiY6RZR0NQDJ1me8mjeHqKldUFp4Ov8qte7nH33AAM9FRte6lDipY5HIuGbnI72SU1MmFmsfA8MIRyEfG7Fouf/UEG6yh9O8MvCpekxNNiDXqZhFm1YZZ2hx+a1i4/1vWCmdvTlMSYmT3WZa8E9oGsuYaiFN36u+MbXDnTG7Z75H2K3apYJddvU4RA+xZZ0HFqnFhL7UMiQ3XvciLxwEA9g3AjmOt3Q+CwP1O6sE6FzW9e2buQzT/aMs/JzM; 4:bbCJBnkjRGADhvOWHZBsnkbT2bxCFEm9fwEvk/sbzz6RWfrAJiJco7ULhQfKe2DtKVUALNeNVRdAhy0G96qXQuNh/nbxNTiaCiDNdJOmDNSVE7B2MfP4f/gzq9VkjW9ZBsfjyI7dsOX1WpAdNNeX9E0HCoyKLDo0nB5dxd29WDoskPMeEMxORXH/Gl+nAsu8e3+R0jixxhRd4Ge4+8RkGLqFixIHtQ42N1fGmPECdBTZYsvQ8J3A2Lpdafm8qanrOOEjDN4yyhozjY7kC4DCFtCsPT8YBOEpsZOaSdtsRFY= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR1201MB0079; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR1201MB0079; X-Forefront-PRVS: 04347F8039 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(189002)(199003)(25786009)(105586002)(72206003)(68736007)(53936002)(2361001)(33646002)(76176999)(48376002)(50466002)(5660300001)(36756003)(6486002)(450100002)(110136004)(478600001)(6116002)(16526017)(66066001)(3846002)(1076002)(47776003)(16586007)(86362001)(2906002)(6666003)(50986999)(5003940100001)(305945005)(8676002)(81166006)(81156014)(106356001)(7736002)(2950100002)(316002)(6916009)(2351001)(50226002)(97736004)(4326008)(101416001)(8936002)(189998001)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0079; H:fx8.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0079; 23:fa5Vb4iem/dyP6LC/jDFFu30qiJW2dgukLkggIQ?= =?us-ascii?Q?sa2I/JVW7BYDCBP6G0CSeHx2sXBGOLyd51FbuUC75y8/Wu5Xf6podbaiVATC?= =?us-ascii?Q?nw9BmL15BxRQDQ9g2kGryHMafUgvK08HHu1L1ABWVvpXrhRaQSw6JEO8Firx?= =?us-ascii?Q?1ij1LHkJz7rD2fDhSj1syFc1rWaliFfkf16o7VHYFIoFcRMM1Yck9CjSl0QR?= =?us-ascii?Q?D6ZMYzFyhWKvNpYGI1qDCCz59IPnEfMeTcyuLmOHgk9Osycl9rMlVjXELoRm?= =?us-ascii?Q?jgYiupVG9iYparpCPX/hmAEPnXaTtcGy1MaP5BwzFDRZay4LkQFeGeqm9tYE?= =?us-ascii?Q?MTLDCw9nhvSIlBeDIsX1SzQ6Dj+UkWqpAkwBNaxaMnLawzxJmUMhSw3//Unw?= =?us-ascii?Q?7djQmKxgesdKEKUddPE4svhOmB2ViXuQ6sQYwNdBtAgzKkgtvCdcH0GNRzRr?= =?us-ascii?Q?txBgEBmd70hnZcDRO2QecA3DQ6GHNQNn9rQaJWr7zAyMKBdSd139goY7Ij3P?= =?us-ascii?Q?SJADjtZnRPK1sO/IBwquDtMDMouynY0P8Onwu8RBU01fN+0VVTCAsaJyeQtM?= =?us-ascii?Q?o4FJFy43UsznyHphm3tplp9XtGfszMCuoE9ZW9QcNmpjTsdeefKFhdWbczhn?= =?us-ascii?Q?4AVJe1e2xq6GCFP8OlvFSnFLu/xd4Waln4N205nS0unG3IWEnBucppZHVemn?= =?us-ascii?Q?aUekYnTSnBz5ebvoZqTCtUNcyWfTGz9WkdKTPhtTwoWq+Ta6KjQtnZMLKPV7?= =?us-ascii?Q?Po4v16hIUefAMhA1xyJJGY0YTeM3BpUcv2TIxx4CIoRk+DR4arE+M7NLxHbi?= =?us-ascii?Q?0t9uNnMJsjJb80BZOff3at8f3F1sAYYTawYVO5g+GQger6Na47phWpeb3+9Y?= =?us-ascii?Q?njpp+bmrTe0M87hks1xOtd5fMMvLQzrJN60b1crV4Ti+WV7XuaREr7WOFLi3?= =?us-ascii?Q?8BBkepJXlgIUV20d3c34ZKlo+g9OmmYd4vfQG320cbimrEQnGGEBfDS8KuCO?= =?us-ascii?Q?vEEf3uUGeeDZeHjngHnlqdnfMcOQpHwCQPb6JmonXcOpgi94A6MAlh5lokjq?= =?us-ascii?Q?CzMLL/7YmHc/hMI4m6cHRpmsFxJoTD99awp/EsWcz3EXAcennLF1/4qFAKDP?= =?us-ascii?Q?sw99b9aAZv8/PF7AAbBQqkSdldK78MUYmawEDfRVXdSMIgI2dKGp+lv6fAxQ?= =?us-ascii?Q?JbiToFBygEG9fKQpK/QKT9Fx/7KiUrJcOEgIY?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0079; 6:iSM1vqpx9Y1JINYpYV6J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76Q0Ex7Jdf+e7JCnrwbMSOf3GC2u61MH4r64wyzrTj/Je63OAnXuK1tXBrmtrPcDv/v+Q0u3oPE4WmwkaUQeAKWHoP6BjlhnmU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 17:33:58.8291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0079 Cc: Tom St Denis , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tom St Denis (v2): add domains and avoid strcmp Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 54 ++++++++++++++++++--------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 +-- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8ee16dfdb8af..50d20903de4f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1809,6 +1809,19 @@ static const struct file_operations amdgpu_ttm_gtt_fops = { #endif + + +static const struct { + char *name; + const struct file_operations *fops; + int domain; +} ttm_debugfs_entries[] = { + { "amdgpu_vram", &amdgpu_ttm_vram_fops, TTM_PL_VRAM }, +#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS + { "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT }, +#endif +}; + #endif static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) @@ -1819,22 +1832,21 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) struct drm_minor *minor = adev->ddev->primary; struct dentry *ent, *root = minor->debugfs_root; - ent = debugfs_create_file("amdgpu_vram", S_IFREG | S_IRUGO, root, - adev, &amdgpu_ttm_vram_fops); - if (IS_ERR(ent)) - return PTR_ERR(ent); - i_size_write(ent->d_inode, adev->mc.mc_vram_size); - adev->mman.vram = ent; - -#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS - ent = debugfs_create_file("amdgpu_gtt", S_IFREG | S_IRUGO, root, - adev, &amdgpu_ttm_gtt_fops); - if (IS_ERR(ent)) - return PTR_ERR(ent); - i_size_write(ent->d_inode, adev->mc.gart_size); - adev->mman.gtt = ent; + for (count = 0; count < ARRAY_SIZE(ttm_debugfs_entries); count++) { + ent = debugfs_create_file( + ttm_debugfs_entries[count].name, + S_IFREG | S_IRUGO, root, + adev, + ttm_debugfs_entries[count].fops); + if (IS_ERR(ent)) + return PTR_ERR(ent); + if (ttm_debugfs_entries[count].domain == TTM_PL_VRAM) + i_size_write(ent->d_inode, adev->mc.mc_vram_size); + else if (ttm_debugfs_entries[count].domain == TTM_PL_TT) + i_size_write(ent->d_inode, adev->mc.gart_size); + adev->mman.debugfs_entries[count] = ent; + } -#endif count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); #ifdef CONFIG_SWIOTLB @@ -1844,7 +1856,6 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count); #else - return 0; #endif } @@ -1852,14 +1863,9 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev) { #if defined(CONFIG_DEBUG_FS) + unsigned i; - debugfs_remove(adev->mman.vram); - adev->mman.vram = NULL; - -#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS - debugfs_remove(adev->mman.gtt); - adev->mman.gtt = NULL; -#endif - + for (i = 0; i < ARRAY_SIZE(ttm_debugfs_entries); i++) + debugfs_remove(adev->mman.debugfs_entries[i]); #endif } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 64709e041d5b..7abae6867339 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -24,6 +24,7 @@ #ifndef __AMDGPU_TTM_H__ #define __AMDGPU_TTM_H__ +#include "amdgpu.h" #include "gpu_scheduler.h" #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) @@ -45,8 +46,7 @@ struct amdgpu_mman { bool initialized; #if defined(CONFIG_DEBUG_FS) - struct dentry *vram; - struct dentry *gtt; + struct dentry *debugfs_entries[8]; #endif /* buffer handling */