linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach
@ 2021-07-19  5:19 guangming.cao
  2021-07-19 11:16 ` Christian König
  2021-07-20  9:31 ` Christian König
  0 siblings, 2 replies; 6+ messages in thread
From: guangming.cao @ 2021-07-19  5:19 UTC (permalink / raw)
  To: Sumit Semwal, Christian König, Matthias Brugger,
	open list:DMA BUFFER SHARING FRAMEWORK,
	open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream, Guangming Cao

From: Guangming Cao <Guangming.Cao@mediatek.com>

Dmabuf sysfs stat is used for dmabuf info track.
but these file maybe still use after buffer release/detach,
should clear it before buffer release/detach.

Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
---
 drivers/dma-buf/dma-buf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 510b42771974..9fa4620bd4bb 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -76,12 +76,12 @@ static void dma_buf_release(struct dentry *dentry)
 	 */
 	BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active);
 
+	dma_buf_stats_teardown(dmabuf);
 	dmabuf->ops->release(dmabuf);
 
 	if (dmabuf->resv == (struct dma_resv *)&dmabuf[1])
 		dma_resv_fini(dmabuf->resv);
 
-	dma_buf_stats_teardown(dmabuf);
 	module_put(dmabuf->owner);
 	kfree(dmabuf->name);
 	kfree(dmabuf);
@@ -875,10 +875,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
 	dma_resv_lock(dmabuf->resv, NULL);
 	list_del(&attach->node);
 	dma_resv_unlock(dmabuf->resv);
+
+	dma_buf_attach_stats_teardown(attach);
 	if (dmabuf->ops->detach)
 		dmabuf->ops->detach(dmabuf, attach);
 
-	dma_buf_attach_stats_teardown(attach);
 	kfree(attach);
 }
 EXPORT_SYMBOL_GPL(dma_buf_detach);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach
  2021-07-19  5:19 [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach guangming.cao
@ 2021-07-19 11:16 ` Christian König
  2021-07-20  9:31 ` Christian König
  1 sibling, 0 replies; 6+ messages in thread
From: Christian König @ 2021-07-19 11:16 UTC (permalink / raw)
  To: guangming.cao, Sumit Semwal, Matthias Brugger,
	open list:DMA BUFFER SHARING FRAMEWORK,
	open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support, Hridya Valsaraju
  Cc: wsd_upstream

Hi Guangming,

Am 19.07.21 um 07:19 schrieb guangming.cao@mediatek.com:
> From: Guangming Cao <Guangming.Cao@mediatek.com>
>
> Dmabuf sysfs stat is used for dmabuf info track.
> but these file maybe still use after buffer release/detach,
> should clear it before buffer release/detach.

In general looks correct to me, but Hridya already send out a patch to 
partially revert the attachment sysfs files since they caused a bunch of 
more problems for some users.

Please wait for that to land in branch drm-misc-next and then rebase 
yours on top of it. I will give you a ping when that is done.

Thanks,
Christian.

>
> Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
> ---
>   drivers/dma-buf/dma-buf.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 510b42771974..9fa4620bd4bb 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -76,12 +76,12 @@ static void dma_buf_release(struct dentry *dentry)
>   	 */
>   	BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active);
>   
> +	dma_buf_stats_teardown(dmabuf);
>   	dmabuf->ops->release(dmabuf);
>   
>   	if (dmabuf->resv == (struct dma_resv *)&dmabuf[1])
>   		dma_resv_fini(dmabuf->resv);
>   
> -	dma_buf_stats_teardown(dmabuf);
>   	module_put(dmabuf->owner);
>   	kfree(dmabuf->name);
>   	kfree(dmabuf);
> @@ -875,10 +875,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
>   	dma_resv_lock(dmabuf->resv, NULL);
>   	list_del(&attach->node);
>   	dma_resv_unlock(dmabuf->resv);
> +
> +	dma_buf_attach_stats_teardown(attach);
>   	if (dmabuf->ops->detach)
>   		dmabuf->ops->detach(dmabuf, attach);
>   
> -	dma_buf_attach_stats_teardown(attach);
>   	kfree(attach);
>   }
>   EXPORT_SYMBOL_GPL(dma_buf_detach);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach
  2021-07-19  5:19 [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach guangming.cao
  2021-07-19 11:16 ` Christian König
@ 2021-07-20  9:31 ` Christian König
  2021-07-20 10:29   ` guangming.cao
  2021-07-20 10:31   ` [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release guangming.cao
  1 sibling, 2 replies; 6+ messages in thread
From: Christian König @ 2021-07-20  9:31 UTC (permalink / raw)
  To: guangming.cao, Sumit Semwal, Matthias Brugger,
	open list:DMA BUFFER SHARING FRAMEWORK,
	open list:DMA BUFFER SHARING FRAMEWORK,
	moderated list:DMA BUFFER SHARING FRAMEWORK, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream

Am 19.07.21 um 07:19 schrieb guangming.cao@mediatek.com:
> From: Guangming Cao <Guangming.Cao@mediatek.com>
>
> Dmabuf sysfs stat is used for dmabuf info track.
> but these file maybe still use after buffer release/detach,
> should clear it before buffer release/detach.

Please rebase on current drm-misc-next. The attachment sysfs files have 
been removed in the meantime.

Thanks,
Christian.

>
> Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
> ---
>   drivers/dma-buf/dma-buf.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 510b42771974..9fa4620bd4bb 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -76,12 +76,12 @@ static void dma_buf_release(struct dentry *dentry)
>   	 */
>   	BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active);
>   
> +	dma_buf_stats_teardown(dmabuf);
>   	dmabuf->ops->release(dmabuf);
>   
>   	if (dmabuf->resv == (struct dma_resv *)&dmabuf[1])
>   		dma_resv_fini(dmabuf->resv);
>   
> -	dma_buf_stats_teardown(dmabuf);
>   	module_put(dmabuf->owner);
>   	kfree(dmabuf->name);
>   	kfree(dmabuf);
> @@ -875,10 +875,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
>   	dma_resv_lock(dmabuf->resv, NULL);
>   	list_del(&attach->node);
>   	dma_resv_unlock(dmabuf->resv);
> +
> +	dma_buf_attach_stats_teardown(attach);
>   	if (dmabuf->ops->detach)
>   		dmabuf->ops->detach(dmabuf, attach);
>   
> -	dma_buf_attach_stats_teardown(attach);
>   	kfree(attach);
>   }
>   EXPORT_SYMBOL_GPL(dma_buf_detach);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach
  2021-07-20  9:31 ` Christian König
@ 2021-07-20 10:29   ` guangming.cao
  2021-07-20 10:31   ` [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release guangming.cao
  1 sibling, 0 replies; 6+ messages in thread
From: guangming.cao @ 2021-07-20 10:29 UTC (permalink / raw)
  To: christian.koenig
  Cc: dri-devel, guangming.cao, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, matthias.bgg,
	sumit.semwal, wsd_upstream, Guangming Cao

From: Guangming Cao <Guangming.Cao@mediatek.com>

On Tue, 2021-07-20 at 11:31 +0200, Christian König wrote:
> Am 19.07.21 um 07:19 schrieb guangming.cao@mediatek.com:
> > From: Guangming Cao <Guangming.Cao@mediatek.com>
> > 
> > Dmabuf sysfs stat is used for dmabuf info track.
> > but these file maybe still use after buffer release/detach,
> > should clear it before buffer release/detach.
> 
> Please rebase on current drm-misc-next. The attachment sysfs files
> have 
> been removed in the meantime.
> 
> Thanks,
> Christian.
> 
updated, thanks for your reminding.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release
  2021-07-20  9:31 ` Christian König
  2021-07-20 10:29   ` guangming.cao
@ 2021-07-20 10:31   ` guangming.cao
  2021-07-20 11:00     ` Christian König
  1 sibling, 1 reply; 6+ messages in thread
From: guangming.cao @ 2021-07-20 10:31 UTC (permalink / raw)
  To: christian.koenig
  Cc: dri-devel, guangming.cao, linaro-mm-sig, linux-arm-kernel,
	linux-kernel, linux-media, linux-mediatek, matthias.bgg,
	sumit.semwal, wsd_upstream, Guangming Cao

From: Guangming Cao <Guangming.Cao@mediatek.com>

Dmabuf sysfs stat is used for dmabuf info track.
But these file maybe still in use after buffer released,
should clear it before buffer release.

Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
---
 drivers/dma-buf/dma-buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index b1a6db71c656..63d32261b63f 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -76,12 +76,12 @@ static void dma_buf_release(struct dentry *dentry)
 	 */
 	BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active);
 
+	dma_buf_stats_teardown(dmabuf);
 	dmabuf->ops->release(dmabuf);
 
 	if (dmabuf->resv == (struct dma_resv *)&dmabuf[1])
 		dma_resv_fini(dmabuf->resv);
 
-	dma_buf_stats_teardown(dmabuf);
 	module_put(dmabuf->owner);
 	kfree(dmabuf->name);
 	kfree(dmabuf);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release
  2021-07-20 10:31   ` [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release guangming.cao
@ 2021-07-20 11:00     ` Christian König
  0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2021-07-20 11:00 UTC (permalink / raw)
  To: guangming.cao
  Cc: dri-devel, linaro-mm-sig, linux-arm-kernel, linux-kernel,
	linux-media, linux-mediatek, matthias.bgg, sumit.semwal,
	wsd_upstream

Am 20.07.21 um 12:31 schrieb guangming.cao@mediatek.com:
> From: Guangming Cao <Guangming.Cao@mediatek.com>
>
> Dmabuf sysfs stat is used for dmabuf info track.
> But these file maybe still in use after buffer released,
> should clear it before buffer release.
>
> Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>

Reviewed and pushed to drm-misc-next.

Thanks,
Christian.

> ---
>   drivers/dma-buf/dma-buf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index b1a6db71c656..63d32261b63f 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -76,12 +76,12 @@ static void dma_buf_release(struct dentry *dentry)
>   	 */
>   	BUG_ON(dmabuf->cb_shared.active || dmabuf->cb_excl.active);
>   
> +	dma_buf_stats_teardown(dmabuf);
>   	dmabuf->ops->release(dmabuf);
>   
>   	if (dmabuf->resv == (struct dma_resv *)&dmabuf[1])
>   		dma_resv_fini(dmabuf->resv);
>   
> -	dma_buf_stats_teardown(dmabuf);
>   	module_put(dmabuf->owner);
>   	kfree(dmabuf->name);
>   	kfree(dmabuf);


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-20 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19  5:19 [PATCH] dma_buf: remove dmabuf sysfs teardown before release/detach guangming.cao
2021-07-19 11:16 ` Christian König
2021-07-20  9:31 ` Christian König
2021-07-20 10:29   ` guangming.cao
2021-07-20 10:31   ` [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release guangming.cao
2021-07-20 11:00     ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).