* [PATCH] soc: ti: knav_dma: remove debugfs file on teardown
@ 2026-06-15 9:12 Pengpeng Hou
2026-06-29 16:54 ` Nishanth Menon
2026-06-30 10:45 ` Hari Prasath
0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-06-15 9:12 UTC (permalink / raw)
To: Nishanth Menon, Santosh Shilimkar, linux-kernel, linux-arm-kernel
Cc: Pengpeng Hou
knav_dma_probe() creates the global knav_dma debugfs file whose show
callback walks the global kdev list. knav_dma_remove() tears down the DMA
instances and runtime PM but leaves that debugfs file and global ready
state behind.
Save the debugfs dentry, remove it before destroying the DMA state, and
clear the global ready pointer state during remove.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/soc/ti/knav_dma.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index e5f5e3142fc4..9277c525ac21 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -125,6 +125,7 @@ struct knav_dma_chan {
ch->channel : ch->flow)
static struct knav_dma_pool_device *kdev;
+static struct dentry *knav_dma_debugfs;
static bool device_ready;
bool knav_dma_device_ready(void)
@@ -740,8 +741,9 @@ static int knav_dma_probe(struct platform_device *pdev)
goto err_put_sync;
}
- debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
- &knav_dma_debug_fops);
+ knav_dma_debugfs = debugfs_create_file("knav_dma", 0444,
+ NULL, NULL,
+ &knav_dma_debug_fops);
device_ready = true;
return ret;
@@ -758,6 +760,10 @@ static void knav_dma_remove(struct platform_device *pdev)
{
struct knav_dma_device *dma;
+ device_ready = false;
+ debugfs_remove(knav_dma_debugfs);
+ knav_dma_debugfs = NULL;
+
list_for_each_entry(dma, &kdev->list, list) {
if (atomic_dec_return(&dma->ref_count) == 0)
knav_dma_hw_destroy(dma);
@@ -765,6 +771,7 @@ static void knav_dma_remove(struct platform_device *pdev)
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+ kdev = NULL;
}
static struct of_device_id of_match[] = {
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] soc: ti: knav_dma: remove debugfs file on teardown
2026-06-15 9:12 [PATCH] soc: ti: knav_dma: remove debugfs file on teardown Pengpeng Hou
@ 2026-06-29 16:54 ` Nishanth Menon
2026-06-30 10:45 ` Hari Prasath
1 sibling, 0 replies; 3+ messages in thread
From: Nishanth Menon @ 2026-06-29 16:54 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: Santosh Shilimkar, linux-kernel, linux-arm-kernel
On 17:12-20260615, Pengpeng Hou wrote:
> knav_dma_probe() creates the global knav_dma debugfs file whose show
> callback walks the global kdev list. knav_dma_remove() tears down the DMA
> instances and runtime PM but leaves that debugfs file and global ready
> state behind.
>
> Save the debugfs dentry, remove it before destroying the DMA state, and
> clear the global ready pointer state during remove.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/soc/ti/knav_dma.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
> index e5f5e3142fc4..9277c525ac21 100644
> --- a/drivers/soc/ti/knav_dma.c
> +++ b/drivers/soc/ti/knav_dma.c
> @@ -125,6 +125,7 @@ struct knav_dma_chan {
> ch->channel : ch->flow)
>
> static struct knav_dma_pool_device *kdev;
> +static struct dentry *knav_dma_debugfs;
Similar comment as previous patch to consider moving this to
knav_dma_pool_device.
>
> static bool device_ready;
> bool knav_dma_device_ready(void)
> @@ -740,8 +741,9 @@ static int knav_dma_probe(struct platform_device *pdev)
> goto err_put_sync;
> }
>
> - debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
> - &knav_dma_debug_fops);
> + knav_dma_debugfs = debugfs_create_file("knav_dma", 0444,
0444 is worth mentioning in the commit message.
> + NULL, NULL,
> + &knav_dma_debug_fops);
>
> device_ready = true;
> return ret;
> @@ -758,6 +760,10 @@ static void knav_dma_remove(struct platform_device *pdev)
> {
> struct knav_dma_device *dma;
>
> + device_ready = false;
> + debugfs_remove(knav_dma_debugfs);
> + knav_dma_debugfs = NULL;
> +
> list_for_each_entry(dma, &kdev->list, list) {
> if (atomic_dec_return(&dma->ref_count) == 0)
> knav_dma_hw_destroy(dma);
> @@ -765,6 +771,7 @@ static void knav_dma_remove(struct platform_device *pdev)
>
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> + kdev = NULL;
Also worth stating in the commit message.
> }
>
> static struct of_device_id of_match[] = {
> --
> 2.50.1 (Apple Git-155)
>
>
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
https://ti.com/opensource
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] soc: ti: knav_dma: remove debugfs file on teardown
2026-06-15 9:12 [PATCH] soc: ti: knav_dma: remove debugfs file on teardown Pengpeng Hou
2026-06-29 16:54 ` Nishanth Menon
@ 2026-06-30 10:45 ` Hari Prasath
1 sibling, 0 replies; 3+ messages in thread
From: Hari Prasath @ 2026-06-30 10:45 UTC (permalink / raw)
To: Pengpeng Hou, Nishanth Menon, Santosh Shilimkar, linux-kernel,
linux-arm-kernel
Hello,
On 15/06/26 2:42 pm, Pengpeng Hou wrote:
> knav_dma_probe() creates the global knav_dma debugfs file whose show
> callback walks the global kdev list. knav_dma_remove() tears down the DMA
> instances and runtime PM but leaves that debugfs file and global ready
> state behind.
>
> Save the debugfs dentry, remove it before destroying the DMA state, and
> clear the global ready pointer state during remove.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/soc/ti/knav_dma.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
> index e5f5e3142fc4..9277c525ac21 100644
> --- a/drivers/soc/ti/knav_dma.c
> +++ b/drivers/soc/ti/knav_dma.c
> @@ -125,6 +125,7 @@ struct knav_dma_chan {
> ch->channel : ch->flow)
>
> static struct knav_dma_pool_device *kdev;
> +static struct dentry *knav_dma_debugfs;
>
> static bool device_ready;
> bool knav_dma_device_ready(void)
> @@ -740,8 +741,9 @@ static int knav_dma_probe(struct platform_device *pdev)
> goto err_put_sync;
> }
>
> - debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
> - &knav_dma_debug_fops);
> + knav_dma_debugfs = debugfs_create_file("knav_dma", 0444,
> + NULL, NULL,
> + &knav_dma_debug_fops);
>
> device_ready = true;
> return ret;
> @@ -758,6 +760,10 @@ static void knav_dma_remove(struct platform_device *pdev)
> {
> struct knav_dma_device *dma;
>
> + device_ready = false;
> + debugfs_remove(knav_dma_debugfs);
Does this handle the case where a process already has the debugfs file
open? A concurrent read() from the userspace could still potentially
reach knav_dma_debug_show() and access kdev while it's being torn down
below. Pls check and add necessary protection around kdev access.
Regards,
Hari
> + knav_dma_debugfs = NULL;
> +
> list_for_each_entry(dma, &kdev->list, list) {
> if (atomic_dec_return(&dma->ref_count) == 0)
> knav_dma_hw_destroy(dma);
> @@ -765,6 +771,7 @@ static void knav_dma_remove(struct platform_device *pdev)
>
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> + kdev = NULL;
> }
>
> static struct of_device_id of_match[] = {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-30 10:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 9:12 [PATCH] soc: ti: knav_dma: remove debugfs file on teardown Pengpeng Hou
2026-06-29 16:54 ` Nishanth Menon
2026-06-30 10:45 ` Hari Prasath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox