Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1402787pxb; Tue, 26 Oct 2021 08:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzlhNHR8hCO2WsKglzI/lklwBAZhMhZAAh/pJS/TF3pVKOV3OpTvbjhmRLEsauz19pJgL7 X-Received: by 2002:a05:6402:3512:: with SMTP id b18mr36058697edd.15.1635261872867; Tue, 26 Oct 2021 08:24:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635261872; cv=pass; d=google.com; s=arc-20160816; b=QF/Po2xmlXAz9+IbikSxt5u06oVSIzqE9FDwp81yppEM/RTo6mT+QTZ1Mv6mw5v4es /OIGOxW9F8szWQtGNoYEk3r5ZNsf4114BlWxlY7Ymg2YDP1zuXFe6raJv6tJoQxMaTZa 96ldFUPD8YsQ42OQx1oWKLBTOIKqOw/ipbEnGxRdtJl9witCI3x04yNkuxKrY8Oo+Tue eM99oXc4WjdLOP2snITrXpEYf1Ge76bnNPPunUIr9q1/CacggTRjalDnx68mGebcm+hf e/HUCB/t/InT2CKz4w2tgcrpTqH6+CBgS0gxtTXQofIleSBErnBf7b1GDc03Sw2Yg3zA Mx7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=mH8FxJbKNh1Zn4BwOQsGJObTEtfvnvBkY+82WJiGyhw=; b=N5C5M0cWEUx0M4/ZKHb4hUpn/74J8Qd1/PckAupJpOk9ePxPxaW+JGA0kAyxLPeNhD Q1J8vW78RzFuXxCObwXU3UtSENT9zHFE5Svkaawx7j4pgE7yqzGiFGnHT/GIyue5Wf2t fSrkw8WGXM/OWeqDMkvCodMELUB8ekaCtJSxO5KQYV/vp4WZASt/BhneEgFbQJdlueE8 hoz62u63/RFJDix3tEdA5HuRjivz0LdWPxHOd7JiaF6Hd/RXroQG/KSeQ2ZPTcsSPDmJ 9YC89gergOAozOEY3RqpssWAzN9JNQaLOXOpiStNKr8mxrbbpziwMZdOc0qyElR/f4/V f/WQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1Q75ZSsx; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb10si11173046ejc.296.2021.10.26.08.23.59; Tue, 26 Oct 2021 08:24:32 -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=@amd.com header.s=selector1 header.b=1Q75ZSsx; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235514AbhJZLVe (ORCPT + 99 others); Tue, 26 Oct 2021 07:21:34 -0400 Received: from mail-mw2nam10on2071.outbound.protection.outlook.com ([40.107.94.71]:26369 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235510AbhJZLVa (ORCPT ); Tue, 26 Oct 2021 07:21:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XEiYQ2COP0ltYpVhZI2cUJEgp7uYRVbGdiuw1E6l62tlg29QAXrNFiT/ytMnILSdincE3/L6mpTOCMSjKNSdH6pA5sSDAkw7Nvi+i+WOZa5qCKk5PUZKtN05VcOi25hsgGcM+/8Hyz+JSUr7QOJa3OTiS8EEXGRSioCJKQ1pB5PVd82Yz8rOjEtjmL6sO3UoUeC4UFau4hQmUGKszw+t4qyF8sYXu97QYJQoBJxgeq2jbwUDQzjV6IVhOGVHeXZQNAuEJklvDyA2JEZpLMZFz4RyqEOakFiJMkqFKLUG4Dmv9SlIP+evKTs+KzmzEyMVgi/AydZa/0p51PuVcStZWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mH8FxJbKNh1Zn4BwOQsGJObTEtfvnvBkY+82WJiGyhw=; b=oMNFruGXmS9ffgTG9WdV5JjDFLDcGkRTGUGPP2oCbv1QDfSMnLXsWlTkrYF0PKjGm/Il+SB4Vl+Z9Z8EdIYRZvP0Z5rzBK3smR2pTt5B2zSVQd66b6Ui8D7Er4TCL93sCC15vCEO80R4pzpQk8ZowcdugOMf2LPblj8XTTtMVtQRrjgaR1JSdt3O3d9xbknTsZahe29I5uH27WKN17aM6aJpq4WuFHrV4ZbTJbAHcwlF/0O4iW1kh4J59P5S98vWL5oTyYBnwa3ytwAGBtgxYM3Ku/dKIIEifD7v80BqZEJMuwRieFpW/qrSDAwkCzYguusbXN1VCqlZdM0SNu2uBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mH8FxJbKNh1Zn4BwOQsGJObTEtfvnvBkY+82WJiGyhw=; b=1Q75ZSsxXCuyh0qLVG7pJQV629/Xa6O+cwX6vwQXMpkZsmdUu3lU1jCTYaMim5t4ap29GEX4ryqTX35k2VxPrqv7/wLrbvzS3RBTdsCNDFkwMpB1sgRsVF928BHUxUUQdi/ZxgmVmQNj5RUIWN3nn7pY598QD9rg8HVC7rNrBXY= Authentication-Results: mediatek.com; dkim=none (message not signed) header.d=none;mediatek.com; dmarc=none action=none header.from=amd.com; Received: from MWHPR1201MB0192.namprd12.prod.outlook.com (2603:10b6:301:5a::14) by MWHPR12MB1839.namprd12.prod.outlook.com (2603:10b6:300:10b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Tue, 26 Oct 2021 11:19:03 +0000 Received: from MWHPR1201MB0192.namprd12.prod.outlook.com ([fe80::55c7:6fc9:b2b1:1e6a]) by MWHPR1201MB0192.namprd12.prod.outlook.com ([fe80::55c7:6fc9:b2b1:1e6a%10]) with mapi id 15.20.4628.020; Tue, 26 Oct 2021 11:19:02 +0000 Subject: Re: [PATCH v3] dma-buf: remove restriction of IOCTL:DMA_BUF_SET_NAME To: guangming.cao@mediatek.com, sumit.semwal@linaro.org Cc: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, rdunlap@infradead.org, wsd_upstream@mediatek.com References: <20211012084109.176542-1-guangming.cao@mediatek.com> <20211014102551.54983-1-guangming.cao@mediatek.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <0e062f12-7e79-5a05-1e7b-10dda8e353b7@amd.com> Date: Tue, 26 Oct 2021 13:18:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <20211014102551.54983-1-guangming.cao@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-ClientProxiedBy: AS9PR06CA0354.eurprd06.prod.outlook.com (2603:10a6:20b:466::9) To MWHPR1201MB0192.namprd12.prod.outlook.com (2603:10b6:301:5a::14) MIME-Version: 1.0 Received: from [IPv6:2a02:908:1252:fb60:4969:85a5:71fe:e4fa] (2a02:908:1252:fb60:4969:85a5:71fe:e4fa) by AS9PR06CA0354.eurprd06.prod.outlook.com (2603:10a6:20b:466::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13 via Frontend Transport; Tue, 26 Oct 2021 11:18:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01341e0b-2847-4214-fe21-08d998726a39 X-MS-TrafficTypeDiagnostic: MWHPR12MB1839: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X5Co4O7qV9ksZEnyrpfX7sSc9HrveIKaRc3vJc3c46DCyd9EAjR8ObgRodKG0CCwMD/60l2bgPGNZGKtMVXl8gMaxtUVhnr9Np5p1i6ruwviC2lNJzVLJCvxZwNz/adITr3YMpDqR6R9bSW01Q56wgeW1gd+esT4AGaPuiRr1u6OXl5xNhS/pPCLvrlL6z9PjZq6ulmUa3vmmbzgYs+xeVrvwtE6vcMVr7aSmB9ODlZ/cDaS+go+mis4asTslaAOaYHx62MfSgzLlOMZumCDMzv+9Y8QrJgHXM951mpMwyR5uZoadyyaMBnqR4BBbEMrcju8aObSjv6v6tFjsT7ZywNb7tA1gCLQc9GSKCkhpDzRnBsmB5wwGo79OZ4Q6+jKOMXkPGLlYvGfWM68k8hVMMv4gjyj6bPwssdlL+KcrgpBLHH14akIjWxs3xlzKKza/7xOU8zeqvgu9m7F2Rq/7OgsReWiSfv8sxEw6rOTMR7Irl9CQO3gipU4HwuZKYTyCLf+eJpce2FDdgjY09ZnOwdbYqfBvPlhXTnl5iliWXdOSTqrGUXLDsP9A7Fnyuqz6EUBzW6/foOkIw3yXErq7W5vrvsRPKLUDhhpACP8KAgpAmnxO+kgoNql6EQSwzAOWvdWcZuJC/aRnOzm+2iBYeleR8/R2T4uYgoR6/lhf3oXu585F74JEMon1di4XHKMdMEEMlExCBjtzfvNtEA86xwjHlj3Nge3UjyR65jTEDGY0CjVW7tEYQMYxhOdnVF4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1201MB0192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(186003)(66574015)(4326008)(2616005)(86362001)(31696002)(7416002)(83380400001)(38100700002)(316002)(6486002)(31686004)(66946007)(5660300002)(36756003)(2906002)(6666004)(508600001)(8936002)(66556008)(66476007)(8676002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vkc5cXdzS3Izek5iOGxaTGZzU0JwSEZ2M0lXTHQ1eGJkK2VaenhYNnFubkNF?= =?utf-8?B?MEFTZWN1amMzVjkxVy8vRnlKSUVlNGh3WXo1SE9GdGhFdmMzOGZRNzR2bk1I?= =?utf-8?B?K1pDdis2RUZFSXlld3pvL01NREJ4OU5JRjhrZExXNGZ6ZWxHQVN1b3JwUFpy?= =?utf-8?B?aEhBcG5Tc20zaHQ5OGJ5QzBHU01qVHRKdlpwRlpucUNnaEU5ZSsycGJYTWVT?= =?utf-8?B?ZUFGZm9YSkw5MnFYaGxTMmJIeGdYVTM0RWRnbi9QNUxId1UyQkwyTkRmUzNL?= =?utf-8?B?TjdLVD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TRiYXJH?= =?utf-8?B?Qm1YMjBjT003ayt5ajZqSG1uT2swa092VXhpTHVxZmQ3N1lqYlR6am5LY0ZB?= =?utf-8?Q?CgmapkGlkaEanPFOIudZgHU=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01341e0b-2847-4214-fe21-08d998726a39 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1201MB0192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2021 11:19:02.7834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jMFfbPJqt46DFs4/pSsoYY4wzJl1hISpMgtbuGKX7TQM/SIUGfjbJqn4dv6/m7Xw X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1839 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 14.10.21 um 12:25 schrieb guangming.cao@mediatek.com: > From: Guangming Cao > > In this patch(https://patchwork.freedesktop.org/patch/310349), > it add a new IOCTL to support dma-buf user to set debug name. > > But it also added a limitation of this IOCTL, it needs the > attachments of dmabuf should be empty, otherwise it will fail. > > 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(https://patchwork.freedesktop.org/patch/310387/), and any accounting > should probably use that, without relying on the name as much. > > So, removing this restriction will let dma-buf userspace users to use it > more comfortably and without any side effect. > > Signed-off-by: Guangming Cao We could now cleanup the return value from dma_buf_set_name() into a void since that function can't fail any more as far as I can see. But that isn't mandatory I think, patch is Reviewed-by: Christian König Regards, Christian. > --- > drivers/dma-buf/dma-buf.c | 17 +++-------------- > 1 file changed, 3 insertions(+), 14 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 511fe0d217a0..5fbb3a2068a3 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 support changing the name of the dma-buf if the same > + * 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 > @@ -341,25 +339,16 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll) > static long dma_buf_set_name(struct dma_buf *dmabuf, const char __user *buf) > { > char *name = strndup_user(buf, DMA_BUF_NAME_LEN); > - long ret = 0; > > 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; > + return 0; > } > > static long dma_buf_ioctl(struct file *file,