Skip to contentSkip to conversation

dma_buf: remove dmabuf sysfs teardown before release/detach

PATCH Superseded [email protected] 2 participants 6 messages Jul 19, 2021 – Jul 20, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma_buf: remove dmabuf sysfs teardown before release/detach

From: Guangming Cao <[email protected]>

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.

---
 drivers/dma-buf/dma-buf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dma-buf/dma-buf.c +3 -2
index 510b42771974..9fa4620bd4bb 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Hi Guangming,

Am 19.07.21 um 07:19 schrieb [email protected]:

Quoted 5 lines

From: Guangming Cao <[email protected]>

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.

Quoted 37 lines
---
  drivers/dma-buf/dma-buf.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dma-buf/dma-buf.c +3 -2
index 510b42771974..9fa4620bd4bb 100644
@@ -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);
maintainer
#2 lore raw
In reply to [email protected]

Am 19.07.21 um 07:19 schrieb [email protected]:

Quoted 5 lines

From: Guangming Cao <[email protected]>

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.

Quoted 37 lines
---
  drivers/dma-buf/dma-buf.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dma-buf/dma-buf.c +3 -2
index 510b42771974..9fa4620bd4bb 100644
@@ -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);
#3 lore raw

From: Guangming Cao <[email protected]>

Quoted 7 lines · Christian König

Am 19.07.21 um 07:19 schrieb [email protected]:

Quoted 5 lines

From: Guangming Cao <[email protected]>

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.

Quoted 7 lines

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

Thanks,
Christian.

updated, thanks for your reminding.

#4 lore raw

PATCH v2 1/1 dma_buf: remove dmabuf sysfs teardown before release

In reply to Christian König

From: Guangming Cao <[email protected]>

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.

---
 drivers/dma-buf/dma-buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf.c +1 -1
index b1a6db71c656..63d32261b63f 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer
#5 lore raw

Re: [PATCH v2] dma_buf: remove dmabuf sysfs teardown before release

Am 20.07.21 um 12:31 schrieb [email protected]:

Quoted 7 lines

From: Guangming Cao <[email protected]>

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.

Reviewed and pushed to drm-misc-next.

Thanks,
Christian.

Quoted 22 lines
---
  drivers/dma-buf/dma-buf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf.c +1 -1
index b1a6db71c656..63d32261b63f 100644
@@ -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);