Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1434909rwl; Sun, 26 Mar 2023 02:22:53 -0700 (PDT) X-Google-Smtp-Source: AKy350Z9nGUAr+xzOEQeG1iF1JrQkX2nzSoX2/3VMTRQ1lTPKgWE/kVGLM6urrvplZ/6/s64sQNX X-Received: by 2002:a17:906:7141:b0:92b:c56a:7efe with SMTP id z1-20020a170906714100b0092bc56a7efemr8862625ejj.31.1679822573209; Sun, 26 Mar 2023 02:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679822573; cv=none; d=google.com; s=arc-20160816; b=i9C2QRoUG8S4plxBdh7WAJvbr/rQSKxTeGR8pqmdurvM2XnZmjIt1wiRptGHyC4g+r AAFkFd4A+3pJ8VLhDV0vzxHRnwPdNp9jnuyImYiHghqfbvX/1qnXUqBBQHRGzOW4+4U5 Aw2o6Qm9mhz+svLIQOM5BVYV0GKPZOhU7JGuJiXGC9vFLXFJ74gx/EgdNB+fkqTN+/DX WVhOmbz3mXLIyWlVCqV/ZkMYvnu/Q70TLAxiN2dA5OlaXjwhZt0xM9BeqERSOO0YPqrS 3cq9pUBjde1Y9NCq+AK8cWr1aC2xJGZuInjbmPoSrqIsYUG7HN3CAHdsJi6s/WSKyTuI BLZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=iHZVFQkvBzOY5c4akiAgaCUw1iB4MGS8We/N4ruh3k8=; b=QTyMDpEa360X5iDP3mNPBySrH2xyVxrw/hWNqBYdF1LYvFnLw/Y8sWq6oVwTpWnqHB mVHeGTeQaWRbgbYpVo/ucxwLccMcpIiPhW+svAauVjmV4BnoXYp16QP4zh+BulOdn1gC 9zrQaWubMgxgXQDBrx6DiS0K/+FIGqmSg4abdvgpHn4c/b2xwlr8Axoi9uhnsykNUibr 1hshVJlAu/71X1GBUsIPzfambzx/wFNE1Uq/A8fVT9F6la4u5eFJDHGBZHNMeTgQ878k 2bOe3UUpzP8Esl6l36i0OhRJAd+0mnTSef9LAutdGUT6+5sI6HFS4LOogt0YRKb9ByUQ pTsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gqqvpvRZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js18-20020a17090797d200b00932f1744dcfsi26513497ejc.54.2023.03.26.02.22.28; Sun, 26 Mar 2023 02:22:53 -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=@gmail.com header.s=20210112 header.b=gqqvpvRZ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbjCZJTf (ORCPT + 99 others); Sun, 26 Mar 2023 05:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjCZJTc (ORCPT ); Sun, 26 Mar 2023 05:19:32 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB80974D for ; Sun, 26 Mar 2023 02:19:30 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id i5so24461228eda.0 for ; Sun, 26 Mar 2023 02:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679822369; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=iHZVFQkvBzOY5c4akiAgaCUw1iB4MGS8We/N4ruh3k8=; b=gqqvpvRZ0SdoxCmQqae1KSjIEjDh2PjxWE9UOelHJdAZQNfXsfpIUmhQzlSEEoqf+o mfQUctvn6msdbvoegyTomav7T+kjGRO3PRvwcyFXV0AWKAuqXbCTVILx//2bumI7cxGH KBI+kaEhRIdAt97A53YpSBEBjoJNNyonkARH4XdfaqZYtZfwdnvQNSF39wUcd7my8HKj m/Qtv/qshyPbwYZ1/LnrqlafjseLlHovhJs61rABrFLmZoZ/3APhoBnDgGLBifFPCQ5z ezjlApqFuRBYlMEJPbb34cSN6GyqZUfrFT7g8FLDS8hztVQrLVgzQQ3W+yW5jubhPOhh l8AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679822369; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iHZVFQkvBzOY5c4akiAgaCUw1iB4MGS8We/N4ruh3k8=; b=stHpo2NjEocD1eLR9jC4pSJZdOaJ/PljOn5w0KqHHe49SxC0/OJOlpW2/PLu02l5gS V2Iob9nDotgWwhVqiE+RQWAqychEZE7sLuCmCp3JJurep93Fr3WYZ4vEo+OMjGwu4bag AeHJuMJmWLqjHe7q4Bweep6eNIdsmpBhQ1TyQd3dGPMBiWmqmU/bh4OOpHBdmCFrx/P9 TnZS97k7dgfrrl/MG290c0W6V1h/h8TKyar0hg+PA0ZPwM8lIpVDaHozyQejMeHj6uzK uT5DZj845WdsFCH83VCjH8ONmTsnVkv+aLKeBLFtE64hZEo5SEP8HdU6MLTtkPR6mhh2 OyDA== X-Gm-Message-State: AAQBX9dqniI3zygtmhZ7aqZnlkfY1l5FyOCjM0vvHjqglEWO1xnHZF85 972QEGujhr+pw/bGhHr1cBs= X-Received: by 2002:a17:906:1514:b0:92b:ae6c:23e7 with SMTP id b20-20020a170906151400b0092bae6c23e7mr8926676ejd.56.1679822369040; Sun, 26 Mar 2023 02:19:29 -0700 (PDT) Received: from ?IPV6:2a02:908:1256:79a0:87fb:f6c5:5d64:ee25? ([2a02:908:1256:79a0:87fb:f6c5:5d64:ee25]) by smtp.gmail.com with ESMTPSA id c24-20020a50d658000000b00501d5432f2fsm8382000edj.60.2023.03.26.02.19.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Mar 2023 02:19:28 -0700 (PDT) Message-ID: <2631edac-a57e-638d-226c-08ea3d9b6b8d@gmail.com> Date: Sun, 26 Mar 2023 11:19:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v13 01/10] drm/shmem-helper: Switch to reservation lock Content-Language: en-US To: Dmitry Osipenko Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org, intel-gfx@lists.freedesktop.org, David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gustavo Padovan , Daniel Stone , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , Qiang Yu , Steven Price , Alyssa Rosenzweig , Rob Herring References: <20230314022659.1816246-1-dmitry.osipenko@collabora.com> <20230314022659.1816246-2-dmitry.osipenko@collabora.com> <6b5644cf-6229-f99b-d429-a45d724493ee@collabora.com> <20c88807-8513-a816-aed9-5cd67eb5c1ed@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20c88807-8513-a816-aed9-5cd67eb5c1ed@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 25.03.23 um 15:58 schrieb Dmitry Osipenko: > On 3/15/23 16:46, Dmitry Osipenko wrote: >> On 3/14/23 05:26, Dmitry Osipenko wrote: >>> @@ -633,7 +605,10 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct >>> return ret; >>> } >>> >>> + dma_resv_lock(shmem->base.resv, NULL); >>> ret = drm_gem_shmem_get_pages(shmem); >>> + dma_resv_unlock(shmem->base.resv); >> Intel CI reported locking problem [1] here. It actually was also >> reported for v12, but I missed that report because of the other noisy >> reports. >> >> [1] >> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_114671v2/shard-snb5/igt@prime_vgem@sync@rcs0.html >> >> The test does the following: >> >> 1. creates vgem >> 2. export it do dmabuf >> 3. mmaps dmabuf >> >> There is an obvious deadlock there. The DRM code assumes that mmap() is >> unlocked, while for dma-buf it's locked. I'll see how to fix it for v14. >> > Christian, there is a deadlock problem in drm_gem_shmem_mmap() once we > move drm-shmem to use resv lock. The current dma-buf locking policy > claims that importer holds the lock for mmap(), but DRM code assumes > that obj->mmap() handles the locking itself and then the same > obj->mmap() code path is used by both dma-buf DRM and a usual DRM object > paths. Hence importer -> dma_buf_mmap_internal()[takes the lock] -> > exporter -> drm_gem_shmem_mmap()[takes the lock] deadlocks. > > I was looking at how to fix it and to me the best option is to change > the dma-buf locking policy, making exporter responsible for handling the > resv lock. Changing DRM code mmap lockings might be possible too [moving > locking to drm_gem_mmap_obj()], but will be very messy and doesn't feel > intuitive. > > Want to get yours thoughts on this before sending out the dma-buf mmap() > policy-change patch. Does the new mmap() locking policy sound good to > you? Thanks! IIRC we tried that before and ran into problems. dma_buf_mmap() needs to swap the backing file of the VMA and for this calls fput() on the old file. This fput() in turn could (in theory) grab the resv lock as well and there isn't anything we could do about that. Just information from the back of my memory, probably best if you double check that. Regards, Christian.