From patchwork Thu Apr 7 02:56:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 12804362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51ADBC433EF for ; Thu, 7 Apr 2022 02:57:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B25FB10E6B5; Thu, 7 Apr 2022 02:57:03 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A12410E6B5 for ; Thu, 7 Apr 2022 02:57:02 +0000 (UTC) Received: from vertex.vmware.com (pool-108-36-85-85.phlapa.fios.verizon.net [108.36.85.85]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id 50BAD28A548; Thu, 7 Apr 2022 03:57:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1649300221; bh=urgAcrcSVTVzOrPatNxysr8nxX5U50eiydADAYbpzh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtZHO3o/0zOiJlAMUUPgbU+bbNj01g9onvVHfUleoPnVLLpoerVWkRPFTtXvKjhci IcXivCyDW21u4oS6/CwRmq+xQ7bok1Io/0NeAW+u5jqnOEAfr4LI1Uuau3UxpEbanB OyPVHv3ZD33kUS7Kc9MKtMd56MMpU0x5WNdFOn13cdKwZnzgXw5VAuvWVoV32zP7z9 y16PkVRG54MqWdS+nb+umADgX1nWLtr6+xQ/qA7EI9RaIjcVRQ6ULiClzzDqpdnnk6 +gqVWiHrK7zb+eOLc21FzFmgoq5MSI2Pr5sPtTIKr8Nf2JaUjx1dpbWycrVZRpIiDo OwEBqhB+Ar8HQ== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] drm/ttm: Add common debugfs code for resource managers Date: Wed, 6 Apr 2022 22:56:47 -0400 Message-Id: <20220407025652.146426-2-zack@kde.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220407025652.146426-1-zack@kde.org> References: <20220407025652.146426-1-zack@kde.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: David Airlie , krastevm@vmware.com, Huang Rui , Christian Koenig , mombasawalam@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin Drivers duplicate the code required to add debugfs entries for various ttm resource managers. To fix it add common TTM resource manager code that each driver can reuse. Because TTM resource managers can be initialized and set a lot later than TTM device initialization a seperate init function is required. Specific resource managers can overwrite ttm_resource_manager_func::debug to get more information from those debugfs entries. Signed-off-by: Zack Rusin Cc: Christian Koenig Cc: Huang Rui Cc: David Airlie Cc: Daniel Vetter --- drivers/gpu/drm/ttm/ttm_resource.c | 65 ++++++++++++++++++++++++++++++ include/drm/ttm/ttm_resource.h | 4 ++ 2 files changed, 69 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 492ba3157e75..6392ad3e9a88 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -29,6 +29,8 @@ #include #include +#include "ttm_module.h" + /** * ttm_lru_bulk_move_init - initialize a bulk move structure * @bulk: the structure to init @@ -644,3 +646,66 @@ ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io, ttm_mem_io_free(bdev, mem); } + +#if defined(CONFIG_DEBUG_FS) + +#define TTM_RES_MAN_SHOW(i) \ + static int ttm_resource_manager##i##_show(struct seq_file *m, void *unused) \ + { \ + struct ttm_device *bdev = (struct ttm_device *)m->private; \ + struct ttm_resource_manager *man = ttm_manager_type(bdev, i); \ + struct drm_printer p = drm_seq_file_printer(m); \ + ttm_resource_manager_debug(man, &p); \ + return 0; \ + }\ + DEFINE_SHOW_ATTRIBUTE(ttm_resource_manager##i) + +TTM_RES_MAN_SHOW(0); +TTM_RES_MAN_SHOW(1); +TTM_RES_MAN_SHOW(2); +TTM_RES_MAN_SHOW(3); +TTM_RES_MAN_SHOW(4); +TTM_RES_MAN_SHOW(5); +TTM_RES_MAN_SHOW(6); + +#endif + +/** + * ttm_resource_manager_debugfs_init - Setup debugfs entries for specified + * resource managers. + * @bdev: The TTM device + * @file_names: A mapping between TTM_TT placements and the debugfs file + * names + * @num_file_names: The array size of @file_names. + * + * This function setups up debugfs files that can be used to look + * at debug statistics of the specified ttm_resource_managers. + * @file_names array is used to figure out which ttm placements + * will get debugfs files created for them. + */ +void +ttm_resource_manager_debugfs_init(struct ttm_device *bdev, + const char * const file_names[], + uint32_t num_file_names) +{ +#if defined(CONFIG_DEBUG_FS) + uint32_t i; + const struct file_operations *fops[] = { + &ttm_resource_manager0_fops, + &ttm_resource_manager1_fops, + &ttm_resource_manager2_fops, + &ttm_resource_manager3_fops, + &ttm_resource_manager4_fops, + &ttm_resource_manager5_fops, + &ttm_resource_manager6_fops, + }; + + WARN_ON(num_file_names > ARRAY_SIZE(fops)); + + for (i = 0; i < num_file_names; ++i) + if (file_names[i] && fops[i]) + debugfs_create_file(file_names[i], 0444, + ttm_debugfs_root, bdev, fops[i]); +#endif +} +EXPORT_SYMBOL(ttm_resource_manager_debugfs_init); diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h index 4428a62e5f0e..3c85cdd21ca5 100644 --- a/include/drm/ttm/ttm_resource.h +++ b/include/drm/ttm/ttm_resource.h @@ -383,4 +383,8 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io, void ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io, struct ttm_device *bdev, struct ttm_resource *mem); + +void ttm_resource_manager_debugfs_init(struct ttm_device *bdev, + const char * const file_name[], + uint32_t num_file_names); #endif From patchwork Thu Apr 7 02:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 12804364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61BE3C433EF for ; Thu, 7 Apr 2022 02:57:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F1A810E6BF; Thu, 7 Apr 2022 02:57:06 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A39710E6B5 for ; Thu, 7 Apr 2022 02:57:03 +0000 (UTC) Received: from vertex.vmware.com (pool-108-36-85-85.phlapa.fios.verizon.net [108.36.85.85]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id 4964E28A5AB; Thu, 7 Apr 2022 03:57:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1649300222; bh=ab3eTJUaYGfc8Eoce+oTc8nInro20BzElLFNR62PoXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SCcskNOQnHxUFbQYVBkcM1+S/RmyT73YXWmG5qU9j4j6h9lPIiKmtNqtz9Bo3f2WA ot+6+8rkF/izq1YVGdN87rpbchHkpOmqqttWz0zejPiqVQjDkn8xoOHTniuJacQiat 9xTHFS7I8a+jZuFm1/EvviqCrpm8gTUttj7XfPhz7nI+gL0A8pApw2hDyDjgw4VMux +HDB3D5IjIgzh46J975LNn92KSy0GOICdH9H3KK4uuKMj1CaWEdhnQxO3AKBxB2HCe AZQeRtZ1OO9FcUFQxcmZlvscwVWnqACaWhXStPu44A+TXVHiO8zZNPKRs4xVscKa5s 45sphnoYIv39g== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/vmwgfx: Add debugfs entries for various ttm resource managers Date: Wed, 6 Apr 2022 22:56:48 -0400 Message-Id: <20220407025652.146426-3-zack@kde.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220407025652.146426-1-zack@kde.org> References: <20220407025652.146426-1-zack@kde.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: David Airlie , krastevm@vmware.com, Huang Rui , Christian Koenig , mombasawalam@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin Use the newly added TTM's ability to automatically create debugfs entries for specified placements. This creates entries in /sys/kernel/debug/ttm/ that can be read to get information about various TTM resource managers which are used by vmwgfx. Signed-off-by: Zack Rusin --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index decd54b8333d..59d0d1cd564b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1630,6 +1630,13 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct vmw_private *vmw; int ret; + const char * const ttm_placement_names[] = { + [TTM_PL_SYSTEM] = "system_ttm", + [TTM_PL_VRAM] = "vram_ttm", + [VMW_PL_GMR] = "gmr_ttm", + [VMW_PL_MOB] = "mob_ttm", + [VMW_PL_SYSTEM] = "system_mob_ttm" + }; ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); if (ret) @@ -1657,6 +1664,9 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_unload; vmw_debugfs_gem_init(vmw); + ttm_resource_manager_debugfs_init(&vmw->bdev, + ttm_placement_names, + ARRAY_SIZE(ttm_placement_names)); return 0; out_unload: From patchwork Thu Apr 7 02:56:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 12804367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA66CC433F5 for ; Thu, 7 Apr 2022 02:57:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5F8910E6DD; Thu, 7 Apr 2022 02:57:09 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9ED0910E6BF; Thu, 7 Apr 2022 02:57:04 +0000 (UTC) Received: from vertex.vmware.com (pool-108-36-85-85.phlapa.fios.verizon.net [108.36.85.85]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id 4967928A5AC; Thu, 7 Apr 2022 03:57:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1649300223; bh=HJUAxAxgi2odZto+GSDNmiZlLQE7sarzm8viYl7J8xA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONCY8k7b5mHo/n/w0Bn3cQ2sdjbLV2doKJygge3+6+SsVfipVbbc3ElGKOePwtWCZ 53Wci9MBo0BQmOw2ZoyKxhD0hwhY4IKFjlHIEYA3I4wbpnmR8ZGpFoZXVxFH44hwU0 jnFhrEdj7JAhl5oaeIwKsaIUmDulwowczVMnY9LH/gkKoYogWnMsCltWCJYSvyzCqg 79vvkTKY/mIWmpmC5kBhnNA0T8LUXwbXiL+qnnwxs+y7Fou228PWv60vbxW+fm58K9 rKEWzvNWzgG8oujCXEZI+WIpV2d8vfVcumV3rDa5yg+ViEcZVLObOU92CuEjJvYZcz b7kWmap0unw8w== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/amdgpu: Use TTM builtin resource manager debugfs code Date: Wed, 6 Apr 2022 22:56:49 -0400 Message-Id: <20220407025652.146426-4-zack@kde.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220407025652.146426-1-zack@kde.org> References: <20220407025652.146426-1-zack@kde.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: Thomas Zimmermann , David Airlie , Felix Kuehling , "Pan, Xinhui" , Nirmoy Das , amd-gfx@lists.freedesktop.org, krastevm@vmware.com, Huang Rui , Alex Deucher , Christian Koenig , mombasawalam@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin Switch to using the TTM resource manager debugfs helpers. It's exactly the same functionality, except that the entries live under /sys/kernel/debug/ttm/. Signed-off-by: Zack Rusin Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Felix Kuehling Cc: Nirmoy Das Cc: Thomas Zimmermann Cc: amd-gfx@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 81 ++++--------------------- 1 file changed, 11 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 57ac118fc266..9852a11a5758 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -2079,17 +2079,6 @@ int amdgpu_ttm_evict_resources(struct amdgpu_device *adev, int mem_type) #if defined(CONFIG_DEBUG_FS) -static int amdgpu_mm_vram_table_show(struct seq_file *m, void *unused) -{ - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, - TTM_PL_VRAM); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused) { struct amdgpu_device *adev = (struct amdgpu_device *)m->private; @@ -2097,55 +2086,6 @@ static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused) return ttm_pool_debugfs(&adev->mman.bdev.pool, m); } -static int amdgpu_mm_tt_table_show(struct seq_file *m, void *unused) -{ - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, - TTM_PL_TT); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - -static int amdgpu_mm_gds_table_show(struct seq_file *m, void *unused) -{ - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, - AMDGPU_PL_GDS); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - -static int amdgpu_mm_gws_table_show(struct seq_file *m, void *unused) -{ - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, - AMDGPU_PL_GWS); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - -static int amdgpu_mm_oa_table_show(struct seq_file *m, void *unused) -{ - struct amdgpu_device *adev = (struct amdgpu_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, - AMDGPU_PL_OA); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_vram_table); -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_tt_table); -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gds_table); -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gws_table); -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_oa_table); DEFINE_SHOW_ATTRIBUTE(amdgpu_ttm_page_pool); /* @@ -2350,22 +2290,23 @@ void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = adev_to_drm(adev)->primary; struct dentry *root = minor->debugfs_root; + const char * const ttm_placement_names[] = { + [TTM_PL_SYSTEM] = "system_ttm", + [TTM_PL_VRAM] = "amdgpu_vram_mm", + [TTM_PL_TT] = "amdgpu_gtt_mm", + [AMDGPU_PL_GDS] = "amdgpu_gds_mm", + [AMDGPU_PL_GWS] = "amdgpu_gws_mm", + [AMDGPU_PL_OA] = "amdgpu_oa_mm" + }; debugfs_create_file_size("amdgpu_vram", 0444, root, adev, &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size); debugfs_create_file("amdgpu_iomem", 0444, root, adev, &amdgpu_ttm_iomem_fops); - debugfs_create_file("amdgpu_vram_mm", 0444, root, adev, - &amdgpu_mm_vram_table_fops); - debugfs_create_file("amdgpu_gtt_mm", 0444, root, adev, - &amdgpu_mm_tt_table_fops); - debugfs_create_file("amdgpu_gds_mm", 0444, root, adev, - &amdgpu_mm_gds_table_fops); - debugfs_create_file("amdgpu_gws_mm", 0444, root, adev, - &amdgpu_mm_gws_table_fops); - debugfs_create_file("amdgpu_oa_mm", 0444, root, adev, - &amdgpu_mm_oa_table_fops); debugfs_create_file("ttm_page_pool", 0444, root, adev, &amdgpu_ttm_page_pool_fops); + ttm_resource_manager_debugfs_init(&adev->mman.bdev, + ttm_placement_names, + ARRAY_SIZE(ttm_placement_names)); #endif } From patchwork Thu Apr 7 02:56:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 12804365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F719C4332F for ; Thu, 7 Apr 2022 02:57:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DFCF10E6D8; Thu, 7 Apr 2022 02:57:08 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0431010E6BE; Thu, 7 Apr 2022 02:57:06 +0000 (UTC) Received: from vertex.vmware.com (pool-108-36-85-85.phlapa.fios.verizon.net [108.36.85.85]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id B80A928A5A9; Thu, 7 Apr 2022 03:57:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1649300224; bh=NV0Yn7cdHu6fJ9Gbs3jziR1myA+JbmRSPOMuY7MsD5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cz6+qMMHxVVEW49pVgxbs7Zj/Zrh76KOf2yC6fy93sEa9OY/MG9yqQWJ9Pz0bCdnc mGGUxdIOuxQREKP5ChgE23JzS7P/+izLhzvRLTdOvcpcFV3PzEZZZtHTAMCjVdbZpU U1uScfz7cWbspzfXceBYVAdozUXStPCgR4tCLjji1vM+7lhXmZFUElsKCYAzw36FuN kgvAkmWoWIEtfHNlwd36XXg6DBcn4Ebdnj0uoGbee9B37oLlKWAUdOYt53ItRUKDHm /QInuRBiAL+etNRfLXhy0ttTrb2EbpO7zx4Erew2dwuKBR4QkTZaFfshGWGk2qtPk8 s9IyzKkRTmbZQ== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm/qxl: Use TTM builtin resource manager debugfs code Date: Wed, 6 Apr 2022 22:56:50 -0400 Message-Id: <20220407025652.146426-5-zack@kde.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220407025652.146426-1-zack@kde.org> References: <20220407025652.146426-1-zack@kde.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: David Airlie , virtualization@lists.linux-foundation.org, krastevm@vmware.com, Huang Rui , spice-devel@lists.freedesktop.org, Dave Airlie , Christian Koenig , mombasawalam@vmware.com, Gerd Hoffmann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin Switch to using the TTM resource manager debugfs helpers. The functionality is largely the same, except that the entries live under /sys/kernel/debug/ttm/ and their lifetimes are managed by TTM. Signed-off-by: Zack Rusin Cc: Dave Airlie Cc: Gerd Hoffmann Cc: Daniel Vetter Cc: virtualization@lists.linux-foundation.org Cc: spice-devel@lists.freedesktop.org --- drivers/gpu/drm/qxl/qxl_ttm.c | 40 ++++++----------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 95df5750f47f..c31d4d751dc4 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -222,41 +222,15 @@ void qxl_ttm_fini(struct qxl_device *qdev) DRM_INFO("qxl: ttm finalized\n"); } -#define QXL_DEBUGFS_MEM_TYPES 2 - -#if defined(CONFIG_DEBUG_FS) -static int qxl_mm_dump_table(struct seq_file *m, void *data) -{ - struct drm_info_node *node = (struct drm_info_node *)m->private; - struct ttm_resource_manager *man = (struct ttm_resource_manager *)node->info_ent->data; - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} -#endif - void qxl_ttm_debugfs_init(struct qxl_device *qdev) { #if defined(CONFIG_DEBUG_FS) - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES]; - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32]; - unsigned int i; - - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) { - if (i == 0) - sprintf(qxl_mem_types_names[i], "qxl_mem_mm"); - else - sprintf(qxl_mem_types_names[i], "qxl_surf_mm"); - qxl_mem_types_list[i].name = qxl_mem_types_names[i]; - qxl_mem_types_list[i].show = &qxl_mm_dump_table; - qxl_mem_types_list[i].driver_features = 0; - if (i == 0) - qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_VRAM); - else - qxl_mem_types_list[i].data = ttm_manager_type(&qdev->mman.bdev, TTM_PL_PRIV); - - } - qxl_debugfs_add_files(qdev, qxl_mem_types_list, i); + const char * const ttm_placement_names[] = { + [TTM_PL_VRAM] = "qxl_mem_mm", + [TTM_PL_PRIV] = "qxl_surf_mm", + }; + ttm_resource_manager_debugfs_init(&qdev->mman.bdev, + ttm_placement_names, + ARRAY_SIZE(ttm_placement_names)); #endif } From patchwork Thu Apr 7 02:56:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 12804366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16149C433F5 for ; Thu, 7 Apr 2022 02:57:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB7BC10E6D0; Thu, 7 Apr 2022 02:57:08 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [IPv6:2001:41c9:1:41e::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A53910E6D2; Thu, 7 Apr 2022 02:57:07 +0000 (UTC) Received: from vertex.vmware.com (pool-108-36-85-85.phlapa.fios.verizon.net [108.36.85.85]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id 1BD8B28A5AD; Thu, 7 Apr 2022 03:57:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1649300226; bh=MJyVD/iMfXRk6vVc3NufqUnHwHBXkEJZwGtyTUoYVaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZfR8C/YBoyGabkpMln+bS2FtST2+FV9NVl9i8bg0cMp3Dc+UPdVW+5ya4llddewET f5Ho/zTfCUhwW34dZq7wwGyTcSBWTDRnhORRRzTZ+tJgUW08NgZ3bGSvQr8PxocBYC ADdpR4hQ+Skt4oVaiBlbSL2wW1MNa5bX6Ze/p2PqdNWFR5DsJXzCJCld8XIP9myczb AIU/3Unfp3p7oQQQwnT230oGAtKUFqjn4NZaQzh7ZK/uDDjmKc5Yfj+lfjI6Al8laM KRE+/Su+gz0MPV8Hx5sMbhbJieBWxLWjbq1tmiBDeoFJ3jYjZ+hJCRe7bkdbu3QXj+ tDVG3aspZ7xnQ== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/5] drm/radeon: Use TTM builtin resource manager debugfs code Date: Wed, 6 Apr 2022 22:56:51 -0400 Message-Id: <20220407025652.146426-6-zack@kde.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220407025652.146426-1-zack@kde.org> References: <20220407025652.146426-1-zack@kde.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: David Airlie , "Pan, Xinhui" , amd-gfx@lists.freedesktop.org, krastevm@vmware.com, Huang Rui , Alex Deucher , Christian Koenig , mombasawalam@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin Switch to using the TTM resource manager debugfs helpers. The functionality is largely the same, except that the entries live under /sys/kernel/debug/ttm/ and their lifetimes are managed by TTM. Signed-off-by: Zack Rusin Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: amd-gfx@lists.freedesktop.org --- drivers/gpu/drm/radeon/radeon_ttm.c | 37 ++++++----------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 44594d16611f..dc6250d5a9cf 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -781,17 +781,6 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size) #if defined(CONFIG_DEBUG_FS) -static int radeon_mm_vram_dump_table_show(struct seq_file *m, void *unused) -{ - struct radeon_device *rdev = (struct radeon_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&rdev->mman.bdev, - TTM_PL_VRAM); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - static int radeon_ttm_page_pool_show(struct seq_file *m, void *data) { struct radeon_device *rdev = (struct radeon_device *)m->private; @@ -799,19 +788,6 @@ static int radeon_ttm_page_pool_show(struct seq_file *m, void *data) return ttm_pool_debugfs(&rdev->mman.bdev.pool, m); } -static int radeon_mm_gtt_dump_table_show(struct seq_file *m, void *unused) -{ - struct radeon_device *rdev = (struct radeon_device *)m->private; - struct ttm_resource_manager *man = ttm_manager_type(&rdev->mman.bdev, - TTM_PL_TT); - struct drm_printer p = drm_seq_file_printer(m); - - ttm_resource_manager_debug(man, &p); - return 0; -} - -DEFINE_SHOW_ATTRIBUTE(radeon_mm_vram_dump_table); -DEFINE_SHOW_ATTRIBUTE(radeon_mm_gtt_dump_table); DEFINE_SHOW_ATTRIBUTE(radeon_ttm_page_pool); static int radeon_ttm_vram_open(struct inode *inode, struct file *filep) @@ -927,18 +903,19 @@ static void radeon_ttm_debugfs_init(struct radeon_device *rdev) #if defined(CONFIG_DEBUG_FS) struct drm_minor *minor = rdev->ddev->primary; struct dentry *root = minor->debugfs_root; + const char * const ttm_placement_names[] = { + [TTM_PL_TT] = "radeon_gtt_mm", + [TTM_PL_VRAM] = "radeon_vram_mm" + }; debugfs_create_file("radeon_vram", 0444, root, rdev, &radeon_ttm_vram_fops); - debugfs_create_file("radeon_gtt", 0444, root, rdev, &radeon_ttm_gtt_fops); - - debugfs_create_file("radeon_vram_mm", 0444, root, rdev, - &radeon_mm_vram_dump_table_fops); - debugfs_create_file("radeon_gtt_mm", 0444, root, rdev, - &radeon_mm_gtt_dump_table_fops); debugfs_create_file("ttm_page_pool", 0444, root, rdev, &radeon_ttm_page_pool_fops); + ttm_resource_manager_debugfs_init(&rdev->mman.bdev, + ttm_placement_names, + ARRAY_SIZE(ttm_placement_names)); #endif }