<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Am 13.10.21 um 01:56 schrieb Sumit Semwal:<br>
<blockquote type="cite" cite="mid:CAO_48GE_jCWY4waK-+FqVw5sbuoHddt4kWpnkpvyLDRC__yE+g@mail.gmail.com">
<div dir="auto">
<div>Hello Guangming, Christian,
<div dir="auto"><br>
</div>
<br>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, 12 Oct 2021, 14:09
, <<a href="mailto:guangming.cao@mediatek.com" rel="noreferrer noreferrer noreferrer" target="_blank" moz-do-not-send="true">guangming.cao@mediatek.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">From:
Guangming Cao <<a href="mailto:Guangming.Cao@mediatek.com" rel="noreferrer
noreferrer noreferrer noreferrer" target="_blank" moz-do-not-send="true">Guangming.Cao@mediatek.com</a>><br>
<br>
> Am 09.10.21 um 07:55 schrieb <a href="mailto:guangming.cao@mediatek.com" rel="noreferrer
noreferrer noreferrer noreferrer" target="_blank" moz-do-not-send="true">guangming.cao@mediatek.com</a>:<br>
> From: Guangming Cao <<a href="mailto:Guangming.Cao@mediatek.com" rel="noreferrer
noreferrer noreferrer noreferrer" target="_blank" moz-do-not-send="true">Guangming.Cao@mediatek.com</a>><br>
> ><br>
> > If dma-buf don't want userspace users to touch
the dmabuf buffer,<br>
> > it seems we should add this restriction into
dma_buf_ops.mmap,<br>
> > not in this IOCTL:DMA_BUF_SET_NAME.<br>
> ><br>
> > With this restriction, we can only know the
kernel users of the dmabuf<br>
> > by attachments.<br>
> > However, for many userspace users, such as
userpsace users of dma_heap,<br>
> > they also need to mark the usage of dma-buf, and
they don't care about<br>
> > who attached to this dmabuf, and seems it's no
meaning to be waiting for<br>
> > IOCTL:DMA_BUF_SET_NAME rather than mmap.<br>
> <br>
> Sounds valid to me, but I have no idea why this
restriction was added in <br>
> the first place.<br>
> <br>
> Can you double check the git history and maybe
identify when that was <br>
> added? Mentioning this change in the commit message
then might make <br>
> things a bit easier to understand.<br>
> <br>
> Thanks,<br>
> Christian.<br>
It was add in this patch: <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.freedesktop.org%2Fpatch%2F310349%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7C4149923e2b0646de82ce08d98ddbf2c2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637696798278342557%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=N49RVF4s%2BGQ4D%2Ft1MOwRsCnslFnwobSB3G86pvP9m7A%3D&reserved=0" originalsrc="https://patchwork.freedesktop.org/patch/310349/" shash="rrFLG2SGWwCOnevYntPkTBSLrAKC6N1Tqo0D7JcYApk3UgzLEy90FuuUiWQy2kK2oLh/dD822UVt+oxD14gkAVIoBSSXLllKMcWgzyFWLFnQz/hYTHy36ByjwT0X8rljdha1Zk9DL+tA28zkfSnmyWzn6ZU0mcMBBfX5Ak2SJ/A=" rel="noreferrer noreferrer noreferrer noreferrer
noreferrer" target="_blank" moz-do-not-send="true">https://patchwork.freedesktop.org/patch/310349/</a>.<br>
However, there is no illustration about it.<br>
I guess it wants users to set_name when no attachments on
the dmabuf,<br>
for case with attachments, we can find owner by device in
attachments.<br>
But just I said in commit message, this is might not a
good idea.<br>
<br>
Do you have any idea?<br>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">For the original series, the idea was that
allowing name change mid-use could confuse the users about the
dma-buf. However, the rest of the series also makes sure each
dma-buf have a unique inode, and any accounting should
probably use that, without relying on the name as much.</div>
<div dir="auto">So I don't have an objection to this change.</div>
</div>
</blockquote>
<br>
I suggest to add that explanation and the original commit id into
the commit message.<br>
<br>
With that changed the patch has my rb as well.<br>
<br>
Regards,<br>
Christian.<br>
<br>
<blockquote type="cite" cite="mid:CAO_48GE_jCWY4waK-+FqVw5sbuoHddt4kWpnkpvyLDRC__yE+g@mail.gmail.com">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">Best,</div>
<div dir="auto">Sumit.</div>
<div dir="auto">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
> <br>
> ><br>
> > Signed-off-by: Guangming Cao <<a href="mailto:Guangming.Cao@mediatek.com" rel="noreferrer
noreferrer noreferrer noreferrer" target="_blank" moz-do-not-send="true">Guangming.Cao@mediatek.com</a>><br>
> > ---<br>
> > drivers/dma-buf/dma-buf.c | 14 ++------------<br>
> > 1 file changed, 2 insertions(+), 12
deletions(-)<br>
> ><br>
> > diff --git a/drivers/dma-buf/dma-buf.c
b/drivers/dma-buf/dma-buf.c<br>
> > index 511fe0d217a0..db2f4efdec32 100644<br>
> > --- a/drivers/dma-buf/dma-buf.c<br>
> > +++ b/drivers/dma-buf/dma-buf.c<br>
> > @@ -325,10 +325,8 @@ static __poll_t
dma_buf_poll(struct file *file, poll_table *poll)<br>
> > <br>
> > /**<br>
> > * dma_buf_set_name - Set a name to a specific
dma_buf to track the usage.<br>
> > - * The name of the dma-buf buffer can only be
set when the dma-buf is not<br>
> > - * attached to any devices. It could
theoritically support changing the<br>
> > - * name of the dma-buf if the same piece of
memory is used for multiple<br>
> > - * purpose between different devices.<br>
> > + * It could theoretically support changing the
name of the dma-buf if the same<br>
> > + * piece of memory is used for multiple purpose
between different devices.<br>
> > *<br>
> > * @dmabuf: [in] dmabuf buffer that will
be renamed.<br>
> > * @buf: [in] A piece of userspace
memory that contains the name of<br>
> > @@ -346,19 +344,11 @@ static long
dma_buf_set_name(struct dma_buf *dmabuf, const char __user
*buf)<br>
> > if (IS_ERR(name))<br>
> > return PTR_ERR(name);<br>
> > <br>
> > - dma_resv_lock(dmabuf->resv, NULL);<br>
> > - if
(!list_empty(&dmabuf->attachments)) {<br>
> > - ret = -EBUSY;<br>
> > - kfree(name);<br>
> > - goto out_unlock;<br>
> > - }<br>
> > spin_lock(&dmabuf->name_lock);<br>
> > kfree(dmabuf->name);<br>
> > dmabuf->name = name;<br>
> > spin_unlock(&dmabuf->name_lock);<br>
> > <br>
> > -out_unlock:<br>
> > - dma_resv_unlock(dmabuf->resv);<br>
> > return ret;<br>
> > }<br>
> > <br>
</blockquote>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>