Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5244658imw; Wed, 20 Jul 2022 01:46:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqWagllEoRqMd+sgJdEanB46D7woz3vSQnRlqdE79nsenuTtIflfACgKeVFoRySJRhNA7/ X-Received: by 2002:a17:907:8687:b0:72e:e524:1803 with SMTP id qa7-20020a170907868700b0072ee5241803mr26639118ejc.411.1658306787916; Wed, 20 Jul 2022 01:46:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658306787; cv=pass; d=google.com; s=arc-20160816; b=uEP48crDlMWNSUbtkPWpzPcYTRxx/MeOwFMVJN5/+CXsDFq6EuTuamDqIGAePN3Ckc A0t4sP8xjsP8cosyDfAUoVdJNWuY3gUl43n09Xij2c8zDY3wUm9IexODCprKAjPT4rD7 bOqGUT35gG5HsmX13htmCT0JtvqNAzOFsLOiT2C+HQPDY7BIy5/4FV7buqhPzp8o84gJ BQ+wRQXBpImihy9XGBfYH4++gmGLAwc7Mm8eMJkRu2rmRgXUICQLQijZzk59/4mjCdrd 1aaNbURgJAVzB37y2XUvv/FNmTiTTMxgsp5BmK838eoBcyYS4OmkMabxxuaiZ0/x0ELs Uk0Q== 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=R+ZOJLZtqxPg1pMKZukdF3e/qzybtcdNG02Xi0IndsA=; b=LIUp/+sbVONzH9GreaoIfXxmoD1qTuURV2YOE0Nmi8lxK4iXnpplp5U1f4XxR9MJiF 7RwqTHfpjcoINgZI4pC5oH5b6OWgUcVvOnDzzTE4h8c0rl9x9sdhGYajNXf/aA5Com10 ytKub+Hou4O3TL+brPnKrbYibZzQaeF80X6OcjPq1tvq0BRYvczQIVP2aY7lYi+rvLos o7VuYbv/fyTQzazsJyo3Nn4ud4BsYdKF4IelhbkT8KbhJrCEciT+1DXOz81jhZEcvNoo RHoy+QvNjkOy8uTj3t1CXeoVzF+zVHi+UXuFvYbAmrfr9AitzInAKmbx9i6551fnY2fv 0LFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ADuMcQCg; 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 sb38-20020a1709076da600b0072a6c18f1fasi22903462ejc.639.2022.07.20.01.46.02; Wed, 20 Jul 2022 01:46:27 -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=ADuMcQCg; 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 S240408AbiGTIaB (ORCPT + 99 others); Wed, 20 Jul 2022 04:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230320AbiGTI37 (ORCPT ); Wed, 20 Jul 2022 04:29:59 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2043.outbound.protection.outlook.com [40.107.102.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFDE6C130; Wed, 20 Jul 2022 01:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N2Qfr7yrz4ZNI4Tv/Vm9Yoet+KTUlfiZ7vB/3n5izmvXi1PMw4tPohUlNr5rdIhqa7beNUBfr6rUv+9CYCuRVLfKMunZvVTIgVN0BMCw2ePP9klYiXREbU4xQeC9yn9Rg2XQeNURFQ+4yfQN8aYr5os1Z282ppLQSikcOg9eSh8mw7JKDjvtlOUtqvv4guF4iou4KPFrImNIDYS5BILp+Ir95wqfD1tnJc11uXLmzDiGAXtgbStl0Jg7MWHXa9Zcu63oOjiwffkI9myJGh1J2ADXizzA2TjO/nwcoUnZD2w8RFgdzTtUiVlDPg26Y3zw1D7GYZyHIYfdkieX7EupcA== 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=R+ZOJLZtqxPg1pMKZukdF3e/qzybtcdNG02Xi0IndsA=; b=Rdp3sREUzHQhdbqiADy25PQ15CbljVab9atASFDilskxVKSv7J5dzqWmJraSFWpJaLxGeNu0c+WvUiV6mDoYqvGAZg5HuyXT3BYLiZ4l2ToZ/uJWjoP+w6Y93W3RLwZ65LgEsSAFuEKrJf8mu1hJ0mSp0711N2GijrXjcWkXStDKKveUdAldBzGG/UxsaFJaEBhEK5zys/Mz0BGvq6XBCBGCW+WAd/Ii3EnEp3OL02p+PgSM1o/ls2fIj5mGzVE6Nys2+5nScsMMPGjJmNaTZYtfOoLqoxOWXuBr9oxPHjRleMkO/P9PehlxZHfLgQGkmNBVV7O/loWZRVovsJu0EQ== 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=R+ZOJLZtqxPg1pMKZukdF3e/qzybtcdNG02Xi0IndsA=; b=ADuMcQCg9r8K0Kayf42S4fpPCiMvBRE3UQSLwC6J7+6+pNCAd/8NyRw+ANofQYVmiFepVq2s2wKiPM4WJGgnIkIJhNtQHbZp5yuuMwFcfNJxENbI8UcVxBIPxymAFUoJX0xs9X+zhJQcD6BraMHxFCg/lfkaDzSAHuzVb29j2X0= 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 MN2PR12MB3198.namprd12.prod.outlook.com (2603:10b6:208:101::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.21; Wed, 20 Jul 2022 08:29:52 +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.5458.018; Wed, 20 Jul 2022 08:29:52 +0000 Message-ID: <163d3271-e1e9-c325-185d-adb4391023e1@amd.com> Date: Wed, 20 Jul 2022 10:29:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v1 4/6] dma-buf: Acquire wait-wound context on attachment 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?= 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, spice-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20220715005244.42198-1-dmitry.osipenko@collabora.com> <20220715005244.42198-5-dmitry.osipenko@collabora.com> <5ec9313e-8498-2838-0320-331c347ce905@amd.com> <1ce233a2-36c9-3698-59f0-c4ff902bec60@collabora.com> <43446124-b99a-32d8-f797-7ec0cdca9ee4@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <43446124-b99a-32d8-f797-7ec0cdca9ee4@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AS9PR06CA0476.eurprd06.prod.outlook.com (2603:10a6:20b:49a::35) 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: 1e2450bb-1041-4e85-d769-08da6a2a0467 X-MS-TrafficTypeDiagnostic: MN2PR12MB3198:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WLvv5dP8RX2F4lqe+h5iJ3G2SHZCHO6d7SRIuKh4MEqbRbRxkjSsj56o/ajbJm4mD/8EZrB140gYOBXfgxn98IuXinhvonVCLVNpreHygwKho9I78XHN4SS1qsM3/1Ynfcvlyqt3LrKJKoLlez9KJ1YsURf7wPA0oq1X/Kv1qH8QNdPlkyGq9mzcpEV1WEAj64xqyyeNkbOnQByl/AvR0dGt8Dd+uViv6gJCpip4I9zl39uJzmMWkhyzL3LEYFG16ecL1CQqAYSOoJVyb6aVThGIvSyvY2pH2Ki2V1X3BlfhX3mR5xRohhmOONsRRCtaeUVoonGqBRbivWdMLs7fbHNwRyOF2iiyMoS8PQcPxuLjRXjQXMRiHHVAzOHZvrCxGfG2vI/rRSlenip4lWuV26v1txCIsQP+9O9mrueomS92c9yfiJ5YJtf8bQOUKJJ4hQnXUVrN4UnTgc0myIT6qpS5YjWElsX9zOEluYUTB1fI0Bhhae0CUVzVzObunps21ixHkgJjSGDjbwhrNbALRo0fG4tsU2RGKidgezn3Ea6g1qtlVxgOqgq9YElF18IJrhu1bCKPYGpV3HHUkcY8yGJgqX5JdAfKdopdeFYID1Fan6YvOh3EcVLu6j5fr5dhFH1IuEq98/nW4yrizSOyGVN/xKfoAVrMhRkqQn+f4KxpK6w+M0dpZSpjOZQ5Gg+knFbzw7qW+xJROnZQS5/0ssQXVZg7w9ZQ7F+/PsJ8JL42nSvxSRROzuM2FM0Rk/NzVxhPy9/jX3hQ3ju/aAamqMZoW+1xj1E6msOSMEbyV2ONPITKagnZ4swDiFJrvJjNqXTlygzxq1sYXye6g5GUa+mC81kuS3MqwZ4n+4xiKOQ= 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)(366004)(376002)(396003)(136003)(39860400002)(6506007)(53546011)(83380400001)(2906002)(41300700001)(8936002)(66574015)(5660300002)(7416002)(7406005)(6666004)(6486002)(478600001)(2616005)(316002)(6512007)(186003)(36756003)(38100700002)(31686004)(66476007)(66556008)(66946007)(4326008)(8676002)(110136005)(31696002)(86362001)(921005)(45980500001)(43740500002);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uNmZqaHl5VUhCTXdFM2Z6YXk4NWsyZHY3QTFoRlRTaVdKT0UxOUU1?= =?utf-8?B?QURDUkVvS21RZmpZS0h4dG9HUXRFT1Z6UG1VV01VNlFhZi82L2VHS3htOExq?= =?utf-8?B?cVhGVTNlWUNyZUtXNFJ3T3IvaGowdFBkeHlOMzlKTFYycWQ3bTE2S0w4U2lU?= =?utf-8?B?Q0ZRbHM1VlB3cUNEZTNDNXZvZ0xXTU45a1N2Z1QyQW9Qdk5ieHhRRXRETFln?= =?utf-8?B?VEVNQzdMbit1Y2RZQnFIRnJrT3RBQmI4NGo3WlFhTzFRaGV2d2dGTkRtMGZY?= =?utf-8?B?QzhNUWV0NDJIelJpNHNmdDZKNEJhYVg4ZmlnNTlQaVZ5WGs5N2EzSngrSEVj?= =?utf-8?B?QkV6cGZ5ZGc1d0pHaGxxbk5QMmR5Rm1MdzIrSGpTQjU1d051TXpVeVFIaml3?= =?utf-8?B?RHRRRkgwZEVhdEJVMkpNNmoxMUJPUEtQc1ZaYXRrRTVHR25sQndkT1pIeEdv?= =?utf-8?Q?PuNHWYQ8aDFAsTw+mMIzPtFioocfS0aCF6/g2yMs33Nn?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2450bb-1041-4e85-d769-08da6a2a0467 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 08:29:52.3462 (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: wda2XqT0St5yc2qZ9a2h3AeB9JVXAmOHLXJDcCOg7+F1X68iVqAMI68HcQ0xlQBO X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3198 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 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 Am 19.07.22 um 22:05 schrieb Dmitry Osipenko: > On 7/15/22 09:59, Dmitry Osipenko wrote: >> On 7/15/22 09:50, Christian König wrote: >>> Am 15.07.22 um 02:52 schrieb Dmitry Osipenko: >>>> Intel i915 GPU driver uses wait-wound mutex to lock multiple GEMs on the >>>> attachment to the i915 dma-buf. In order to let all drivers utilize >>>> shared >>>> wait-wound context during attachment in a general way, make dma-buf >>>> core to >>>> acquire the ww context internally for the attachment operation and update >>>> i915 driver to use the importer's ww context instead of the internal one. >>>> >>>>  From now on all dma-buf exporters shall use the importer's ww context >>>> for >>>> the attachment operation. >>>> >>>> Signed-off-by: Dmitry Osipenko >>>> --- >>>>   drivers/dma-buf/dma-buf.c                     |  8 +++++- >>>>   drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |  2 +- >>>>   .../gpu/drm/i915/gem/i915_gem_execbuffer.c    |  2 +- >>>>   drivers/gpu/drm/i915/gem/i915_gem_object.h    |  6 ++--- >>>>   drivers/gpu/drm/i915/i915_gem_evict.c         |  2 +- >>>>   drivers/gpu/drm/i915/i915_gem_ww.c            | 26 +++++++++++++++---- >>>>   drivers/gpu/drm/i915/i915_gem_ww.h            | 15 +++++++++-- >>>>   7 files changed, 47 insertions(+), 14 deletions(-) >>>> >>>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c >>>> index 0ee588276534..37545ecb845a 100644 >>>> --- a/drivers/dma-buf/dma-buf.c >>>> +++ b/drivers/dma-buf/dma-buf.c >>>> @@ -807,6 +807,8 @@ static struct sg_table * __map_dma_buf(struct >>>> dma_buf_attachment *attach, >>>>    * Optionally this calls &dma_buf_ops.attach to allow >>>> device-specific attach >>>>    * functionality. >>>>    * >>>> + * Exporters shall use ww_ctx acquired by this function. >>>> + * >>>>    * Returns: >>>>    * >>>>    * A pointer to newly created &dma_buf_attachment on success, or a >>>> negative >>>> @@ -822,6 +824,7 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf >>>> *dmabuf, struct device *dev, >>>>                   void *importer_priv) >>>>   { >>>>       struct dma_buf_attachment *attach; >>>> +    struct ww_acquire_ctx ww_ctx; >>>>       int ret; >>>>         if (WARN_ON(!dmabuf || !dev)) >>>> @@ -841,7 +844,8 @@ dma_buf_dynamic_attach_unlocked(struct dma_buf >>>> *dmabuf, struct device *dev, >>>>       attach->importer_ops = importer_ops; >>>>       attach->importer_priv = importer_priv; >>>>   -    dma_resv_lock(dmabuf->resv, NULL); >>>> +    ww_acquire_init(&ww_ctx, &reservation_ww_class); >>>> +    dma_resv_lock(dmabuf->resv, &ww_ctx); >>> That won't work like this. The core property of a WW context is that you >>> need to unwind all the locks and re-quire them with the contended one >>> first. >>> >>> When you statically lock the imported one here you can't do that any more. >> You're right. I felt that something is missing here, but couldn't >> notice. I'll think more about this and enable >> CONFIG_DEBUG_WW_MUTEX_SLOWPATH. Thank you! >> > Christian, do you think we could make an excuse for the attach() > callback and make the exporter responsible for taking the resv lock? It > will be inconsistent with the rest of the callbacks, where importer > takes the lock, but it will be the simplest and least invasive solution. > It's very messy to do a cross-driver ww locking, I don't think it's the > right approach. So to summarize the following calls will require that the caller hold the resv lock: 1. dma_buf_pin()/dma_buf_unpin() 2. dma_buf_map_attachment()/dma_buf_unmap_attachment() 3. dma_buf_vmap()/dma_buf_vunmap() 4. dma_buf_move_notify() The following calls require that caller does not held the resv lock: 1. dma_buf_attach()/dma_buf_dynamic_attach()/dma_buf_detach() 2. dma_buf_export()/dma_buf_fd() 3. dma_buf_get()/dma_buf_put() 4. dma_buf_begin_cpu_access()/dma_buf_end_cpu_access() If that's correct than that would work for me as well, but we should probably document this. Or let me ask the other way around: What calls exactly do you need to change to solve your original issue? That was vmap/vunmap, wasn't it? If yes then let's concentrate on those for the moment. Regards, Christian.