Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2987148pxb; Fri, 8 Oct 2021 21:43:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3ddgpdFKr/0+R6/gE7+ucVuGzPeyIC3w+ONjsVE81/fRpfh2bkBJu+N/fngroAX4BQBzS X-Received: by 2002:a05:6402:350c:: with SMTP id b12mr21064672edd.244.1633754580316; Fri, 08 Oct 2021 21:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633754580; cv=none; d=google.com; s=arc-20160816; b=e188YosV6FyuhQctmFRvJDjh+MOPSVwzFc9RhkIeJkAP2YmrN1vpE1m+BfprRSoVza ZYMe1KCJCRbvcDj8qMk7XDREGWJKhVW4Qh1QtfVCeMRLVA20nlgGg32v3VruVfM/s/l3 vl3FC376S60Zox/K3pjaIyczK/l8BtOTpmzg9+kEf6M3LQW5dMYUoYguES0m8qg13CKq H7/4EYzxrhJODQwKcedQNsEUAL7UIfnBpXGIYmwc+TBldbKbvCWdHeluI62a4jW7Zah6 efwizn/oQm29dvNXD/7yd3qMDKDnyXO4mW0TD9uHX3QB5JZ+gtYqb4X3g5undN8MJicq umkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=dWH4qjA33whTZ4Wx/aYp4ATOSdmZkILXTl4W7Gnaxqs=; b=CqTFwTAR5BjAxAy92CDujiH6rnBKxJNgWrSApz3qwYtbIFkmbgUQhWYWYdfmvBXgU7 CHC/+3h5YeTp7kWDvtaRdAs4mIQ4dhL83HYm9OQ231HVU9ZiO+JbZggJOjgMEnmhI18a mbkmYISEMc4CM+5I8zpDe9Fid3xZQkIg82yO/GWbglHU73HFanwGbNl9L0kkMay/hZk4 68MNipdf5h0Wdiil7VhdM74AmwDP9xWdUcydTxZFt9/4Sq3zi3bEEHuoHZZHRU0COIeq ifvJaVTvr4R7midBgn+eMldVMqisnvFgHibyqPeN0wUzte2meg+YAt1SDtMyTEkUEy0j SJ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ODVrCEaL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id br21si1969775ejb.612.2021.10.08.21.42.36; Fri, 08 Oct 2021 21:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ODVrCEaL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbhJIEnE (ORCPT + 99 others); Sat, 9 Oct 2021 00:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbhJIEnC (ORCPT ); Sat, 9 Oct 2021 00:43:02 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D055C061570; Fri, 8 Oct 2021 21:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=dWH4qjA33whTZ4Wx/aYp4ATOSdmZkILXTl4W7Gnaxqs=; b=ODVrCEaLmds1oXMb8Y0/8CUvJB DP1ABypOnb7u12aFdm96y7XFc9PVP1ZLhOr69VgJSgrX6DdNI7YyZlsIDz+9kg1w8dkGeGoYPZvB6 fBq72ccby3bMY0gjr7jYzszuoZyQfMMtQbhbmVZ6Gd/jcfl6C+HQOfQEBgSg0/DL3dAHThzNjaZd0 l5KgXLL8jmu3WZzHWjqUIFvRhdySKOgzBvcwfb+dcYnElOYLJPvMDn2gNuUvve3TkGe3N7ggw8tHX t/oqyrZbtYmZuJ0JkLmn026RJaovZa7zkPGbUcO9nI15SzLyibKrVOYucTO1qFf9fWOTZNSgnPh+z E/sc/cEw==; Received: from [2601:1c0:6280:3f0::aa0b] by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZ4AT-0058DR-3k; Sat, 09 Oct 2021 04:41:05 +0000 Subject: Re: [PATCH] dma-buf: remove restriction of IOCTL:DMA_BUF_SET_NAME To: guangming.cao@mediatek.com, Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , 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@mediatek.com References: <20211009024733.65676-1-guangming.cao@mediatek.com> From: Randy Dunlap Message-ID: Date: Fri, 8 Oct 2021 21:41:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211009024733.65676-1-guangming.cao@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/8/21 7:47 PM, guangming.cao@mediatek.com wrote: > From: Guangming Cao > > If dma-buf don't want userspace users to touch the dmabuf buffer, > it seems we should add this restriction into dma_buf_ops.mmap, > not in this IOCTL:DMA_BUF_SET_NAME. > > With this restriction, we can only know the kernel users of the dmabuf > by attachments. > However, for many userspace users, such as userpsace users of dma_heap, > they also need to mark the usage of dma-buf, and they don't care about > who attached to this dmabuf, and seems it's no meaning to waitting for to be waiting for > IOCTL:DMA_BUF_SET_NAME rather than mmap. > > Signed-off-by: Guangming Cao > --- > drivers/dma-buf/dma-buf.c | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 511fe0d217a0..afbd0a226639 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -325,10 +325,8 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) > > /** > * dma_buf_set_name - Set a name to a specific dma_buf to track the usage. > - * The name of the dma-buf buffer can only be set when the dma-buf is not > - * attached to any devices. It could theoritically support changing the > - * name of the dma-buf if the same piece of memory is used for multiple > - * purpose between different devices. > + * It could theoritically support changing the name of the dma-buf if the same theoretically (yes, it was incorrect before this change.) > + * piece of memory is used for multiple purpose between different devices. > * > * @dmabuf: [in] dmabuf buffer that will be renamed. > * @buf: [in] A piece of userspace memory that contains the name of > @@ -346,19 +344,11 @@ static long dma_buf_set_name(struct dma_buf *dmabuf, const char __user *buf) > if (IS_ERR(name)) > return PTR_ERR(name); > > - dma_resv_lock(dmabuf->resv, NULL); > - if (!list_empty(&dmabuf->attachments)) { > - ret = -EBUSY; > - kfree(name); > - goto out_unlock; > - } > spin_lock(&dmabuf->name_lock); > kfree(dmabuf->name); > dmabuf->name = name; > spin_unlock(&dmabuf->name_lock); > > -out_unlock: > - dma_resv_unlock(dmabuf->resv); > return ret; > } > > -- ~Randy