From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C63AA531AF5 for ; Wed, 9 Sep 2026 11:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788951861; cv=none; b=nD9C6UeahXpYpfwDs8O+EaRZHfrXDgCGosRU09QYOrAGf94HyzPr1UZuLb1fo4tXrNpC2odWCH1+ibJ+BHG1+d+Z1Qdg1g4J4NfvwbReAtMs2qxqaFGa/M9S7ntOTNEdx7NPJ2teztkO/JEmTOWfxCFqymh3BW15LCykeHG6QIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788951861; c=relaxed/simple; bh=Rzpqksp/qKE1bDH6y39VH8pIARppCQb7o4bmXV4eju8=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=ttmZUNlSPa4F+hRdKkkQJGtphMIDiFgeKeWEr9ZH6G2PKT5n6yAK8o6CS2YbySRvf7hj5iQegW4nwuG3r1/batX/uQHQTzSBULfhBDAeKl5ROK4M95EwMzqAlbjiM4tRSTsK/oF10yyl+zdG7w5W9dfXuV/+AST9ekTcOOp97w0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j89WfArA; arc=none smtp.client-ip=74.125.224.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j89WfArA" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-66fb8a78ad2so6999509d50.2 for ; Wed, 09 Sep 2026 04:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788951852; x=1789556652; darn=vger.kernel.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=j89WfArAb4HAae1r9gERB9vbyd4lujvT4QzylaHONNA6Q2Wf4knbMbObz5i525Ut4t XkSo5AaI0HUxT0uGfAvI+gBT3QVVAT4z7Z6X1rYzRyP6/km7YtvxqHnX65Mn7Ml5+NP3 FLXjoFY5SSOpi+0C6jJBGg5LkrrudZX7/Zf17BUfr1UBkyIOoHrFH0XGMbs1s6uMTjkr 3bRpufNCdRYjhLc0hcJzyc26NKMfFU/GknUIo1ib4IvIuFNBWZSUtSqWIt6BgZjcESeL Gh26103u4O1yeaieTZtSACBZgpuK5tNWMK16x0Bs1FCT2UIk2Tms0ScjaMQ+CmRCv2hG DtdQ== 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=dBTUtbRwGBSw3q4JB0i8JeibaSjUjsD6ASbghJkDzCBpjd61hFbsUdcD6WLmTVwfeR c/JGhr6b8QBF8utA4rHg+4KAvUHrHQMo1bvFTrAi9eByaK2JT6hRE3Du57vzUCQeEKu+ 1EJFFcZHyd8iZudSCru9aebaCb16TQRuMcShwSg/yvdL/PBGEC0jGCP8pFvVmRuRCFun +517e7M9NyRQ9shrPZ5SQsMqppuHNrkVJ+FADgz/fF9JgSJqIkvqUmPRLimZgXEcrnXD IaNQokuWSKUotjC8/TTw/UMRPpZklIxkJAvL0kh2qKZqlw6cJzlRdtFtkmQfFHmoZlQs 8bZw== X-Forwarded-Encrypted: i=1; AKwUvBw3jmuvl38xp727kb2JCjSOj5FpF4yDh6+pZ1Hgr1CobjOGsy4gVk5BcOifgBSvF7tc3j3IXR58KMDAeA==@vger.kernel.org X-Gm-Message-State: AFuF++nolxQy6xhRn3Zn9e+0ccXyT8wGwS4E9o4uLhgV3EumTtkCpZBY y1hwG+CBwP3hgpJLdjt40nRIJgR5CZu9Xb959eb1ExTPbWFbkyUq0/xM X-Gm-Gg: AYBFou0JS/e5y1WM777xz+1H6pRGmj/r5PmDLa2F+RjWRN9f+4Zq8x+NBD4ec8FOilP d4q/Fa0QdLXgY/bwGPvPofOtFXNAhw2hilA9B0yeouzxbMI4tD0Z2onF2pw1z+xmCTPfF8cGhcB 9FWpzgwSdQHQWYEx0/qrx0C93L8tMxI9vyOvhthkVsESOfuLaqYlPhJ+AG0YBYzrNOJ7QGzTvC9 O8N1BvBTaI0STTT8MyjFB4344tq4Pc4+1rKQz5X1G9KaO49VTHVTiO3AhTiuO2JiM2rNA3uqNlE M9/Y6qgK2o3BWtobQKJG5kbh5pTUwLKtd8YX7LjYhmp4Efs9JO9XQwe5IICshqlksLahEB4+CGE uV3qlvfQsupLlrXBwMpT2zfHdEzMWJDnhaTVN9saDIlgfRVCTY4dFW4uB4Qea3COnD0XEESrgLx 35OvRBNoqJ7feOS+BBBZ0QK9m1wMmxe5BCJzniDSNI3dXhCNyWPj0QeFPn4HMhx9uPT8D93XBF9 8wz5HcIAQ3ai24O3ho1OeL+v3iF 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 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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. > >> }; >> >> /** >> >