From mboxrd@z Thu Jan 1 00:00:00 1970 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 4B5BFC79FB6 for ; Wed, 9 Sep 2026 11:04:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 771A110F0C2; Wed, 9 Sep 2026 11:04:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="o1cSYkRm"; dkim-atps=neutral Received: from mail-yx1-f51.google.com (mail-yx1-f51.google.com [74.125.224.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAB1310F0C2 for ; Wed, 9 Sep 2026 11:04:13 +0000 (UTC) Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-66dbce0b639so4361640d50.1 for ; Wed, 09 Sep 2026 04:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788951852; x=1789556652; darn=lists.freedesktop.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=yu6XBq0/lXnZ7cWMkDYqnoMO3CTujhBWMHDaaEEIfu8=; b=o1cSYkRmvp9kt/6fi4SI7fcvsNbmJigbrAnEOzuj+LampMxLUtsgrERLbgXbyLyZeG UTUlG2BuMEzrPxxxKJFEAgRSxojcze2zoFjNioRO8CDwkAPftxPV3SgA4+6MHkyHbhTJ ZQpI/eU9vC/qbyQL+qpMZHRBuMriYMM4a65Er9bdt6TDDFWczK5hK78pdLKlBl4rCaA+ ygGaBjEcpPGSXr1RzxAMoPpt+1a9RLWodyLADN+a+HsTEHCvFsHq6VgmT+Vm0pmC0njv zvqkO6XQopnoqn8ulAKU33kTry81CS8xjVvKI4aR21nukYFXOWwwr31k79YUVY4T7ubM uIAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788951852; x=1789556652; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yu6XBq0/lXnZ7cWMkDYqnoMO3CTujhBWMHDaaEEIfu8=; b=TSDqnWUUi4Sftd0TDsSX2n7+j1kebWBFbqaCrWXCOmyLSV5q+Uv+uieeKAJhxAIjrQ dAiURlZuCAGIX1xPXhz8PzI7OetdJ0/k0F6QRUO8jUXOITDYc+4YvrsD3ZRD9pqi758G kcHcJ3jNSm7rzNn08kwt5hAdOXX56yGLVG6NTvVBXAvu6uagc9qZRFEnAoR9l2es/e6i YIwzzNv7Lkz2vE0yn+TjVvQ1tbe0YtdlRB2FTIoxt4Hh3M3Kgxn1oX8lYYUTt27vo+19 +N4avVLVga9NJYy3r/Ks9Sk+9ON9DP9qrQ0WqgbE2kUwhfOjw153Ub/m9EvsFb3hpA+g nhjg== X-Forwarded-Encrypted: i=1; AKwUvBxxW6su0hpGNbHclVP2T5uECpy1FQRsc2c83AKSmF+ybb5A3HLAR1mZiGVpqTpqZFOUB8DC+Y82J3Y=@lists.freedesktop.org X-Gm-Message-State: AFuF++m7SIQ5kU2p0S5643KppWiuRYQZIUebbk4IbH9BghNI2SO3vJXs mGKv8tIQSEH0xWZhk4VmBPBFFoURu9FR6KnctljIHClWRKPzrVMZCuTk X-Gm-Gg: AYBFou2o2QuGtQktDZb8V+a3cEKnHA7CIpK0/lU8Rq2+ZrmaOTkfjBMcWQroxlIDlKq INGPv5C56SeRa8qa768wxnEjUjxSYiPr9wX/1loasqvEDcsuoSgpcnwWaLD4WdrICgumXkwZNRs sLB6kaH/4rVUtGtERT+EeTBGK18sohbefz8n/LqS1F8pDKoRIm/Ks09LiODry7ShNfyxHThS2F0 s9WMl2cG4ChArG3sT1eMw0p4s4F6CcY8o4YVbeEQ+DwKu/iO9t64Cgzomh4QBbDKDwj5bGOyJAn UWn3Lym/HQ13GkFua7+EObb59oDeZkI4GNVIzfbNN4wnTSpxKXMJ4L4iDu5Yp4ufivpP3ygU+Aa ExV1EOPPvIn5EqyFmZdgYOEFyAUojRxsl/l/41XLqGBmrxtP+NSh5TwH+zzpmwUc4uyzd3D68ud JayBr/IqW5nOSIKXdYs1AqGENY8Vgickj2YdJL8FErjLbnbdABDs9e9lArkzrnGVM3aGWnOrXHt LdyJiRZs6zwdn0EiIvjzEieU8NA X-Received: by 2002:a05:690e:34f:b0:66d:2469:2518 with SMTP id 956f58d0204a3-66fb593f3e0mr8590219d50.13.1788951852153; Wed, 09 Sep 2026 04:04:12 -0700 (PDT) Received: from [10.254.153.217] (munvpn.amd.com. [165.204.72.6]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91040694c35sm140718096d6.36.2026.09.09.04.04.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2026 04:04:11 -0700 (PDT) Message-ID: <2fd989b4-06ea-42e6-b18a-bc3ef2e069f5@gmail.com> Date: Wed, 9 Sep 2026 13:04:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 08/12] dma-buf: heaps: Add debugfs support From: =?UTF-8?Q?Christian_K=C3=B6nig?= To: Thierry Reding , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Hunter , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sowjanya Komatineni , Luca Ceresoli , Mikko Perttunen , Yury Norov , Rasmus Villemoes , Russell King , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Marek Szyprowski , Robin Murphy , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Catalin Marinas , Will Deacon , Chun Ng , Mark Rutland , Saravana Kannan Cc: Thierry Reding , devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux.dev, linaro-mm-sig@lists.linaro.org, linux-trace-kernel@vger.kernel.org, Thierry Reding References: <20260904-tegra-vpr-v6-0-79042cfa8de5@nvidia.com> <20260904-tegra-vpr-v6-8-79042cfa8de5@nvidia.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Since AMDs mail servers blocked me from sending this out, here once more from my gmail account. Regards, Christian. On 9/4/26 15:00, Christian König wrote: > On 9/4/26 12:44, Thierry Reding wrote: >> From: Thierry Reding >> >> Add a callback to struct dma_heap_ops that heap providers can implement >> to show information about the state of the heap in debugfs. A top-level >> directory named "dma_heap" is created in debugfs and individual files >> will be named after the heaps. >> >> Reviewed-by: Maxime Ripard >> Signed-off-by: Thierry Reding > > One minimal nit pick below, with that taken care of Reviewed-by: Christian König . > >> --- >> Changes in v5: >> - fix failure handling during debugfs root directory creation >> - add more cleanup to the newly introduced dma_heap_exit() >> --- >> drivers/dma-buf/dma-heap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ >> include/linux/dma-heap.h | 2 ++ >> 2 files changed, 54 insertions(+) >> >> diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c >> index 8a6c2b6e0cc6..65c80dac6500 100644 >> --- a/drivers/dma-buf/dma-heap.c >> +++ b/drivers/dma-buf/dma-heap.c >> @@ -7,6 +7,7 @@ >> */ >> >> #include >> +#include >> #include >> #include >> #include >> @@ -225,6 +226,40 @@ const char *dma_heap_get_name(struct dma_heap *heap) >> } >> EXPORT_SYMBOL_NS_GPL(dma_heap_get_name, "DMA_BUF_HEAP"); >> >> +#ifdef CONFIG_DEBUG_FS >> +static int dma_heap_debug_show(struct seq_file *s, void *unused) >> +{ >> + struct dma_heap *heap = s->private; >> + int err = 0; >> + >> + if (heap->ops && heap->ops->show) >> + err = heap->ops->show(s, heap); >> + >> + return err; >> +} >> +DEFINE_SHOW_ATTRIBUTE(dma_heap_debug); >> + >> +static struct dentry *dma_heap_debugfs_dir; >> + >> +static void dma_heap_init_debugfs(void) >> +{ >> + dma_heap_debugfs_dir = debugfs_create_dir("dma_heap", NULL); >> +} >> + >> +static void dma_heap_exit_debugfs(void) >> +{ >> + debugfs_remove_recursive(dma_heap_debugfs_dir); >> +} >> +#else >> +static void dma_heap_init_debugfs(void) >> +{ >> +} >> + >> +static void dma_heap_exit_debugfs(void) >> +{ >> +} >> +#endif >> + >> /** >> * dma_heap_add - adds a heap to dmabuf heaps >> * @exp_info: information needed to register this heap >> @@ -299,6 +334,13 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) >> >> /* Add heap to the list */ >> list_add(&heap->list, &heap_list); >> + >> +#ifdef CONFIG_DEBUG_FS >> + if (heap->ops && heap->ops->show) >> + debugfs_create_file(heap->name, 0444, dma_heap_debugfs_dir, >> + heap, &dma_heap_debug_fops); >> +#endif >> + >> mutex_unlock(&heap_list_lock); >> >> return heap; >> @@ -335,6 +377,16 @@ static int dma_heap_init(void) >> } >> dma_heap_class->devnode = dma_heap_devnode; >> >> + dma_heap_init_debugfs(); >> + >> return 0; >> } >> subsys_initcall(dma_heap_init); >> + >> +static void __exit dma_heap_exit(void) >> +{ >> + dma_heap_exit_debugfs(); >> + class_destroy(dma_heap_class); >> + unregister_chrdev_region(dma_heap_devt, NUM_HEAP_MINORS); >> +} >> +__exitcall(dma_heap_exit); >> diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h >> index 648328a64b27..1c9bed1f4dde 100644 >> --- a/include/linux/dma-heap.h >> +++ b/include/linux/dma-heap.h >> @@ -12,6 +12,7 @@ >> #include >> >> struct dma_heap; >> +struct seq_file; >> >> /** >> * struct dma_heap_ops - ops to operate on a given heap >> @@ -24,6 +25,7 @@ struct dma_heap_ops { >> unsigned long len, >> u32 fd_flags, >> u64 heap_flags); >> + int (*show)(struct seq_file *s, struct dma_heap *heap); > > I found it good coding practice for objects ops pointer tables to have the object the function works with as first parameter. > > Absolutely not a must have, but just looks a little bit more consistent. > > Regards, > Christian. > >> }; >> >> /** >> >