Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp686645rwe; Wed, 24 Aug 2022 07:31:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR6m0nS+nEauinl3dqMnU3kDBcQDKIZ46BfLhWISmMawiddkmtu0yuGjupRKuzfu+2c57gMc X-Received: by 2002:a17:902:cec7:b0:172:5b09:161c with SMTP id d7-20020a170902cec700b001725b09161cmr28352211plg.60.1661351471228; Wed, 24 Aug 2022 07:31:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661351471; cv=pass; d=google.com; s=arc-20160816; b=YLnmfbwRk7tt83QS942naX5aWTP1BPb3J223WGcbow3hEkX6DKoGY5+nxaLrKe3Hvu YrAirh49Mz8Ijp4OGT4f9Pif+SHYQybYT3HC7s4s4hJbkrB9glbLdWbbqb/FGyiiPue+ VsX5sAVzvSCo/vz66uWBhbj4cZP5Snzb+/W1eoxsrq/2QpVaG3IPHcmSyr6BbRP200Nc PzF9TOWGcrI+KRJngA26QvPRByWSVIuxEo++VuVT3IcHsQCL/wBBzUNcJY2UkHx2R+ow KQ0UlwAwRp/sgU9suiuDj6d0WlQcBjxvlKgI9KTkarpYVlAGejv+G0IGc66kWcqDLMpw c9yA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=a6tnmG1zTM4ApDA7S49avmJ7v1U8WXzdIdLD1/Us1WM=; b=UBGi0SbPS2w3Fc5o4oBg7CDwOozy0ODcsKSfShtSQvUXXkrrnhhT0FJQ5mBWk8izlp yKEPoa+AAl1Ur2P92B3RGL9pjxTNTTFBYmLLy7gWiWg9SnnXKI1qKPPlOo2ur/1bObiM +5xt4rrA/mwcwME+XZ+9gH/Pzn5vwg1tgzo+hyseDUAyiNBTwa1sVNb8eRCaH1y2qCL5 Tj87FggOlxWhueQyCtpe0fIADgPeE91pmspqjiap5gp9Gr11utnq7SEfS8elMXIfGOmk NE5yZ5DF1cybOrfhn5N2/QMK/A62QAJV3xzEkq2Cx7sRSj6XFAFu35d26iOc+wxDopB4 Laag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Hej0/obO"; 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 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170902e74400b0017293d9ea92si5188244plf.41.2022.08.24.07.30.58; Wed, 24 Aug 2022 07:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Hej0/obO"; 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 2620:137:e000::1:20 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 S238037AbiHXOBp (ORCPT + 99 others); Wed, 24 Aug 2022 10:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238948AbiHXOBY (ORCPT ); Wed, 24 Aug 2022 10:01:24 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E901F8688E; Wed, 24 Aug 2022 07:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQMAWHZtg+IA+pEEQFFgW59ZdIR0TfhjmM1khYXe9ENGoDPUTRk0ic5JG633kfrHAUJTMZCt794Hfcy0+NusifMN1U/jC71vmmZaWPxW9CoD0giexkNLLwW2KYoUMNUNEXjjjFHsgpdJlNxOqwU4Z/II1Hu6KIPeera3kf9FvjOaXciEXaBRVsFcrJGqIKQ8k2yfapOGxQ8q/ycgRYoIWRQBTxKCZkYMXCTcmFSxP4bY8Njc9OqcvVULwo4e/PpQuUeWN1s+5Es/cUmu9F5KriyX6yMg+gEYtDzsQgjo5wjNEdvJxc7BDPkV7KToJ1BU/gt7W75PbsfREVbG0bVoow== 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=a6tnmG1zTM4ApDA7S49avmJ7v1U8WXzdIdLD1/Us1WM=; b=Z+mX29rP4QWE87xXy6mbqlLiO9MnFkvU45YZnwheLpZxxhTuA8MnZkQEAEorZCG6rX6EjYfGQcSy5fRcNrHIiKfuZs4Fya+I9IhPL3AHV95jXDg71ys0iri7q/sd3xoz6d5bpB8zhFA3SNqTwYZgf6Fiq3omz6ntBXHkxbuB1ZOu8TrIm0Xe9Qv9nsGY11Jpk5tSen8+pEVqPFT/miPEMfsg7s/T89e7zv5QfF4fJZ8FPijj0L+4QFW3sBFGHbm0bBwDlZIF6ltARuWUSGZLZrBBYHvxitdPRJow74gJY7CHkzLP5QHMQRg7S+i38X4PO15nUFdxqeOKP3EQOdRAoA== 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=a6tnmG1zTM4ApDA7S49avmJ7v1U8WXzdIdLD1/Us1WM=; b=Hej0/obOVZj5Zx9l59hKRiN5loPORbM4VObM1YK/8TxN3iaV7Ok1cX+oATnXfK0H+BIStPLbpESFEtIhA11POXQt8+yFtLZq+qMnKbb+rQmKQOCMLy2p6rSuB8SemVsnHiTT8MFKQnRmYlxRxTw/2EM1WcQCLHkDWm3IdtDJ5Ec= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by DM5PR12MB1305.namprd12.prod.outlook.com (2603:10b6:3:75::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 24 Aug 2022 14:01:16 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::905:1701:3b51:7e39]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::905:1701:3b51:7e39%2]) with mapi id 15.20.5546.024; Wed, 24 Aug 2022 14:01:16 +0000 Message-ID: <45dee40a-e1a9-2554-2af8-ea6b9dbbb161@amd.com> Date: Wed, 24 Aug 2022 16:01:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 5/9] dma-buf: Move dma_buf_mmap_unlocked() to dynamic locking specification Content-Language: en-US To: Dmitry Osipenko , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Clark , Sumit Semwal , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , =?UTF-8?Q?Thomas_Hellstr=c3=b6m?= , Qiang Yu Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Osipenko , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com, virtualization@lists.linux-foundation.org, linux-rdma@vger.kernel.org, linux-arm-msm@vger.kernel.org, lima@lists.freedesktop.org References: <20220824102248.91964-1-dmitry.osipenko@collabora.com> <20220824102248.91964-6-dmitry.osipenko@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220824102248.91964-6-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AS8PR04CA0152.eurprd04.prod.outlook.com (2603:10a6:20b:331::7) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18d244fd-891b-4415-1a87-08da85d91c9a X-MS-TrafficTypeDiagnostic: DM5PR12MB1305:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJaTX2fASYOjxVRoumKCysKPaCQ2jZtQEUNDWdjOd4mrDA+e6s/KEvNAP9D0IUojJex53LZ8aEJtokpzRaZw/RbDSCzyObI1NS/dtWMCpYC08fT798pKoWjAVQtLd1ZRNzKqHjhUygyGcsxijYeRbp2oapDtg5CBauxOwM+kHHAtCNxzE5P/9jAG2O3fb7nX1zgDFOgnMc1xrdZLnpEmq2Xan1xbY2g0Mqra6rBerU+v9InQ7I73ileczcG3YwdfAP844ktPdGojPYiwN+wSsLfmqkvWkPXTvBLQPtX0txDjka5YJlFtkkBoUG7PfdjaApj+e+F02y1morwp3VizTcAquRFswvk3PfqaiXzOPDlvWr/fPJ0+tz+XOiEVacXsY9ggwSdWMrKoptp7AptG9qMA8Hed3bTEwhnKJj6a1+rulBVOIux8u9LExplude3us20K7CKTXFpTJvixcJVmx87ydS2bb61YgV6ImQgq75JUcmxDRkaX3dJYR28CHXHC7EkFyYAtE7K86kSghuvFUAmeFZU0jveGIncfKEY/SCBMj3agJqoTK4+TfXM4veEAbYY8AYIvkmMH5oVHb7Es3xmU68tz+e/wbDlHxCE67CCO3q0F8T22pKkaAv0DT9P0lmX1vZf9EMmR+RrBdjjxeKiiObjnIoONsVF0fmrYzW2u5mTsr06z00m9uWi380slFnqEjOHWXuNd9tG+rWpDt/mgs7nRgakhaxcgfxnYEuc4imd0c4CEXmMJyExbmIVSqHLaHEThmpylV8Y882e9viggRQsOKvbS9dGXOdeXluZx1sWfkVO0tjRsBRe43fin X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(136003)(396003)(366004)(39860400002)(110136005)(66556008)(66476007)(8676002)(4326008)(316002)(66946007)(8936002)(5660300002)(7416002)(7406005)(2906002)(38100700002)(36756003)(86362001)(31696002)(921005)(41300700001)(6666004)(6512007)(6506007)(6486002)(66574015)(478600001)(83380400001)(2616005)(186003)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?S2YxM0JqT2p1azdnZEo5U1JJd0piSGtEYWZBU2NKb3I4TUgxSjgxY292bXpl?= =?utf-8?B?MWpBZGFTW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9LVWRTSmRw?= =?utf-8?B?SGZlM1Q0T2g1N0pWbUFWQkdvV0xIS1BQODYwNVhQbGdWOHdYeFJiVE1MbERD?= =?utf-8?B?OHhma3EyaFVPMW1TTnQxenRwMkhpeFBtVis5SWo1a1dKSXFLWHJ5Zk1rOGlV?= =?utf-8?B?UlN5VCszOXpCaEFqQWxoRTNrVkd0VE5qbkkxMjJLQStvbXgvd001NTA3dUwx?= =?utf-8?B?Y2ZuTXlncVBCdVBUdGJyWVZGZk9RYzFaKzVVaVR1Nmpjb2ZpRVdoSklJak0z?= =?utf-8?B?dFRvc3BBV3pEbU91U1NKNytLR1ZjMU9JZEZPRmlvRk53Um5oL2xYRTdUQUl1?= =?utf-8?Q?OkHNpLdnTExpDKrMoqdy67Q3ZiZx7uLLUJzCPB6JirLX?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18d244fd-891b-4415-1a87-08da85d91c9a X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2022 14:01:16.3261 (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: yIgqr06rV9pGCDGmg1lDmtmR9+TYmrXu7b/z/1OIahmSG9RUbWlHBv8OYypGN5S4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1305 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This should work, but I'm really wondering if this makes a difference for somebody. Anyway the approach is fine with me: Acked-by: Christian König Regards, Christian. Am 24.08.22 um 12:22 schrieb Dmitry Osipenko: > Move dma_buf_mmap_unlocked() function to the dynamic locking specification > by taking the reservation lock. Neither of the today's drivers take the > reservation lock within the mmap() callback, hence it's safe to enforce > the locking. > > Signed-off-by: Dmitry Osipenko > --- > drivers/dma-buf/dma-buf.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index f358af401360..4556a12bd741 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -1348,6 +1348,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_end_cpu_access, DMA_BUF); > int dma_buf_mmap_unlocked(struct dma_buf *dmabuf, struct vm_area_struct *vma, > unsigned long pgoff) > { > + int ret; > + > if (WARN_ON(!dmabuf || !vma)) > return -EINVAL; > > @@ -1368,7 +1370,11 @@ int dma_buf_mmap_unlocked(struct dma_buf *dmabuf, struct vm_area_struct *vma, > vma_set_file(vma, dmabuf->file); > vma->vm_pgoff = pgoff; > > - return dmabuf->ops->mmap(dmabuf, vma); > + dma_resv_lock(dmabuf->resv, NULL); > + ret = dmabuf->ops->mmap(dmabuf, vma); > + dma_resv_unlock(dmabuf->resv); > + > + return ret; > } > EXPORT_SYMBOL_NS_GPL(dma_buf_mmap_unlocked, DMA_BUF); >