Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp370182rwe; Thu, 1 Sep 2022 00:21:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ILlfvR0mO9NZH+wMPACW5YjN6Ip/n//sgaCTPOBQ216tafU/S7BHsdPwxNQhblbcooZa8 X-Received: by 2002:a63:ff5a:0:b0:42c:61f:b81 with SMTP id s26-20020a63ff5a000000b0042c061f0b81mr15934708pgk.254.1662016889334; Thu, 01 Sep 2022 00:21:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1662016889; cv=pass; d=google.com; s=arc-20160816; b=YPS8ET/1I43FC9DQ7juPK9la4nPP6g4YyM9WtyIHNx1NsXAG6qhJbxrDuUj3YuAov5 g9Dq0dC/K9dvMXpu8CXk7VCOkz6y12bBigd6ZmMJ7M1vuJQnDLYQTwBnD0NEuBBInssz BlbxshfFzLCvsHE0shY5GQTBGDnxGWVQERpDK7eMlSJxzCTekwp/d5v/r+lKJEXZQBkk ohIL+Wce4wK0QpAx/R60Yi4ftEYyZdWLGkrPDmp8ZW6lY6oIs4WH4KDvNZS9xxJbz+gG sU9iiIIjuiOmhacLdFrV7uPy8waJdSPjP18JhsdAMD89HtNIzC7u4h1yc/AJDqmsJc4V Mufg== 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=/wS6hoZqqxTAYIbFTrNeuiGnw4mq9SD4ZnSLOxh3OOo=; b=Px1BuOb7K4ExD058Pnor4UEtA4R9ryvHGHI8pYmCzmTTmrr4MtjJJxfU8EHIZFp+VL Jo0IFoczBwzCv7ifmgI7yEadmjqvYPCFL5DGF+KSbzzKIz9cEbBGF9Mu+LQwtM1lnDEG JcDPaHZO6tZj8dHtOxwprJOjZ1u6Metd1aBEVQAIehbMqQKDBQPVS1jQ/szFbZqWUFXq IwtDnNzHYdQd/NstBc/sT2KwoM4xbqeMpQo9RFPj1hc8krPyKBCPd9beWR2A6c4VmCdk /dSd/MUSJoL7elOR72M0q24ula+0z0Ji9aWNWy0IfWeTPCu54WAmkFS5Su55akJDUDLA h/KA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=aauMJWVG; 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 j17-20020a056a00131100b0052d9edab4e1si17642190pfu.86.2022.09.01.00.21.18; Thu, 01 Sep 2022 00:21:29 -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=aauMJWVG; 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 S233686AbiIAHIV (ORCPT + 99 others); Thu, 1 Sep 2022 03:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233585AbiIAHHx (ORCPT ); Thu, 1 Sep 2022 03:07:53 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2051.outbound.protection.outlook.com [40.107.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBA11243E2; Thu, 1 Sep 2022 00:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y5g0ZS9cdUzwdawSvHTk45POPngoABamcvme7l2d6A4/bCLFyavQ3bEj/OCV0QzUfhqfTV+RfKXYpoKYcDqnpwcH2eEVaKQiCkZYgTwSr5YlWzzqlYCHGJ9k5pZ3D6Xv1+UGO7nDTFgNpRWvkh48lMKupPu0VGQGnbjPoqpVklp9ug3zown95x8ZE21tZQ0NzK6hIjT/6Wa0dOoO2dSUHTvNB/n8T7NMT0vzPkNG0m4t7DscW5SeOH/0GFPj9p7NiBPkIQ1mj0Z0zgWXr673vIkaqFxSAvZP+XAswliFsVH3D8cjmPXgj0h/VIS3/A5dzWiyv55u7/Na9ySekyrVeg== 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=/wS6hoZqqxTAYIbFTrNeuiGnw4mq9SD4ZnSLOxh3OOo=; b=ReTFtTsEGBynKm0mtbQReJ3WzMDdtp/ZT+IvPmDZRlEScpWvKp042J6CFeAqlZ1nm2wGCouT7qQM2VQvaQXhWuwdClMtmGa2FibOxZ95vmct2qoHr/GkNP88tEXz4XgGOcAKL1mx64FiPuK4wuhTXUzAo9qkhHip0SJvo18gWHPzFqRa0UZj04++Y+EpNKdp5qwGoFGnG3SjbAL2xPY2pyoSN08s2GjR2se7B/DAT9Su6XTRA1TkDCHFHaoasl26eVg4UXvhXv2KQP5u4TO5WPejSvjExUBpgc3rwID6d2QiDfyi4uuT1Jm6bHxdn4rcmF8iomRCvJ4tenheyPbpNg== 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=/wS6hoZqqxTAYIbFTrNeuiGnw4mq9SD4ZnSLOxh3OOo=; b=aauMJWVGvAJCh0vXZSzbJOmK7QJxZMzEaBqIIPibKb1PQy0KYeMVmMSnDFhM+nHr0E7y7k+TTUvRwSLoI8vNph0g36SbJAjS76pej4quWHR2+OlosC/a3M7cev/glKjaiRh2AQkroTRjzQNyISAr7bXgHGBvAofoUIYCBAtA+BI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB3589.namprd12.prod.outlook.com (2603:10b6:a03:df::29) by DM6PR12MB4299.namprd12.prod.outlook.com (2603:10b6:5:223::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Thu, 1 Sep 2022 07:07:15 +0000 Received: from BYAPR12MB3589.namprd12.prod.outlook.com ([fe80::a997:c7f:aea0:764a]) by BYAPR12MB3589.namprd12.prod.outlook.com ([fe80::a997:c7f:aea0:764a%4]) with mapi id 15.20.5566.021; Thu, 1 Sep 2022 07:07:15 +0000 Message-ID: <4e82d32f-6e5f-edaf-17f4-4381f762ac21@amd.com> Date: Thu, 1 Sep 2022 09:07:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v4 16/21] dma-buf: Move dma_buf_attach() 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 , Srinivas Kandagatla , Amol Maheshwari , Jason Gunthorpe , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Tomi Valkeinen , Russell King , Lucas Stach , Christian Gmeiner 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 References: <20220831153757.97381-1-dmitry.osipenko@collabora.com> <20220831153757.97381-17-dmitry.osipenko@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220831153757.97381-17-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AM5PR0301CA0007.eurprd03.prod.outlook.com (2603:10a6:206:14::20) To BYAPR12MB3589.namprd12.prod.outlook.com (2603:10b6:a03:df::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da19bc91-840c-4876-7f25-08da8be8994b X-MS-TrafficTypeDiagnostic: DM6PR12MB4299:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jga8O1+qmXnK5URUTFGLeQXsXW8cBLVK00eGD0wz7a+W6Hvvr/9PBvfOyhSeYVJ0JXKo0lAiG3a5cmMPDbjH45hVHYovIOYGXOhOvb1YHqvGbO9x61ZYy7M362ViA7bnJyVXuYi5HFTdDdbpRkUQ2D/NPQzNEGCyOI6xC47nYPU1shjclVTMCgqYcGLdXGhtcQPvELeFwZrQv3eFEx0+Aczb0/cgRjbSGwgfk/pxD0ui1OmGIAbL1bv3k42pKPxx4iHyEAWZewCwJSgczFMeKlRrGR8dXCXGJpcdx1eLpVahBGktTbSN3d+w9LiHpR6DwGTMfmdgk3V6z4FgGWUZmPadVs8rJi1im5MRBrvWDS4e8BRlETfqLE2MW9GcXKHgpNeDMeUq+UVEhMiVt5E5CuVjkBA4+2S/GCwP0DKKmMqbG0l6I8TvuV8mbMcu1+t49CuHgI5VCrB8kt1FUwLL1HKF1OzJiRM/gIKEBGvDYbsbak6nnhRDWKxfMw+y5iFs9S2y0QZWGiVRjLeENT/IWq1l3v2v3fNZWUegWknLyxLCNPoFKUrMYkb6OjbaiphArEFlXOock2iJlfrkFykuXiAlm4bDoiVyFP2la6GykNACwIpn/3F7A2qZzbVb/e9JF18YcE+2ocQekJ+DvEe88BRFEVjrLzCmt9RUZ5h5Or2bC0s79Of6+6le5lyfqwtT7NJ9AgN5eKqDvORFNSBkGaOKpIZeNd9tpCTbmoGy/M8QAgXUFvPm3IMgB2JyxxOy26XeUttRtSlIdQjLbSm07TaluKfCb5jnKQ5PjWYszHlz2622aPwK1YravZLQscm3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3589.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(366004)(39860400002)(136003)(376002)(346002)(41300700001)(6486002)(26005)(6506007)(316002)(6512007)(6666004)(2906002)(86362001)(66476007)(36756003)(31686004)(31696002)(478600001)(110136005)(66574015)(2616005)(921005)(186003)(8676002)(66556008)(7416002)(7406005)(66946007)(38100700002)(4326008)(5660300002)(83380400001)(8936002)(43740500002)(45980500001);DIR:OUT;SFP:1101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vNW96WTNWa0VNYzEvOUIza1F6UWFY?= =?utf-8?B?alRITkZYMXdUWC9UZ1BzTERRWThtRUhnSEs4bkpWaTlSaFo5Qkx4TGpXdkZP?= =?utf-8?B?U09tMXRuSmQ5dmkyeHhzdGFFNW1BeWFMbitIWTBsTFBKcDMxK2Z5MXFTSzlj?= =?utf-8?B?WUd4SHNGWUxDMHo0Ty8wQTFFelZ5UjJYMzdxajl3YjlNeE5iV2FvUjlsWHJG?= =?utf-8?B?OGlkeDNwQnN6THhGbkpYRG5MVHo4UmFEQ2tiN2MrN2FiRXFRNDZkMDZzRzY1?= =?utf-8?B?WllQWWxQU3hNRktqWklRaHp2YmFDd0svU01WNk9nMDYra1BKRTJyTmNoSy9o?= =?utf-8?B?WG44RkV1QS9rZDE5dHcrSVN3VDRsSFEwdHRYYlY2QkxJL0RGRXd1cit3VVJ6?= =?utf-8?Q?pnLQBUsL5Virsb6FREZFrWrO8?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: da19bc91-840c-4876-7f25-08da8be8994b X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3589.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2022 07:07:15.1569 (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: PvzbArcMq3mDU8GvFplzH0g4T8J/PaOoEbUFEI2mfageRT7wPRLZ2Sx4eOa6MqWr X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4299 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 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 31.08.22 um 17:37 schrieb Dmitry Osipenko: > Move dma-buf attachment API functions to the dynamic locking specification > by taking the reservation lock around the mapping operations. The strict > locking convention prevents deadlock situations for dma-buf importers and > exporters. > > Signed-off-by: Dmitry Osipenko Reviewed-by: Christian König > --- > drivers/dma-buf/dma-buf.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index ceea4839c641..073942bf5ae9 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -858,8 +858,8 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, > dma_buf_is_dynamic(dmabuf)) { > struct sg_table *sgt; > > + dma_resv_lock(attach->dmabuf->resv, NULL); > if (dma_buf_is_dynamic(attach->dmabuf)) { > - dma_resv_lock(attach->dmabuf->resv, NULL); > ret = dmabuf->ops->pin(attach); > if (ret) > goto err_unlock; > @@ -872,8 +872,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, > ret = PTR_ERR(sgt); > goto err_unpin; > } > - if (dma_buf_is_dynamic(attach->dmabuf)) > - dma_resv_unlock(attach->dmabuf->resv); > + dma_resv_unlock(attach->dmabuf->resv); > attach->sgt = sgt; > attach->dir = DMA_BIDIRECTIONAL; > } > @@ -889,8 +888,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, > dmabuf->ops->unpin(attach); > > err_unlock: > - if (dma_buf_is_dynamic(attach->dmabuf)) > - dma_resv_unlock(attach->dmabuf->resv); > + dma_resv_unlock(attach->dmabuf->resv); > > dma_buf_detach(dmabuf, attach); > return ERR_PTR(ret); > @@ -936,21 +934,19 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) > if (WARN_ON(!dmabuf || !attach)) > return; > > + dma_resv_lock(attach->dmabuf->resv, NULL); > + > if (attach->sgt) { > - if (dma_buf_is_dynamic(attach->dmabuf)) > - dma_resv_lock(attach->dmabuf->resv, NULL); > > __unmap_dma_buf(attach, attach->sgt, attach->dir); > > - if (dma_buf_is_dynamic(attach->dmabuf)) { > + if (dma_buf_is_dynamic(attach->dmabuf)) > dmabuf->ops->unpin(attach); > - dma_resv_unlock(attach->dmabuf->resv); > - } > } > - > - dma_resv_lock(dmabuf->resv, NULL); > list_del(&attach->node); > + > dma_resv_unlock(dmabuf->resv); > + > if (dmabuf->ops->detach) > dmabuf->ops->detach(dmabuf, attach); >