From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53AD6C38145 for ; Fri, 2 Sep 2022 10:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235708AbiIBKcN (ORCPT ); Fri, 2 Sep 2022 06:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235461AbiIBKcD (ORCPT ); Fri, 2 Sep 2022 06:32:03 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ABD2AE20F; Fri, 2 Sep 2022 03:32:01 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id x10so1805728ljq.4; Fri, 02 Sep 2022 03:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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; bh=oS1FPn188GwYqcEpeAiuLHN0qFHFB655DOQwCXbqud0=; b=n3OAhLhYLpZxMnQfsFjiyUnhcv12eKqug64v55vPtpE/UCjJaNIZHCA+Wwv+6WbtT/ qWkYjCAk4Yjkuctjw0fBnbyysWH+4pCHaxR5XU+s4CKQjBA8zqhlLNk/otAC43pVbwk/ +Oxsn+VvggqMRnSHBrZ+4CWc9VjYKgT5IxVQ6II8ncEcyJrTjiDJmp2cyMJgIaGZlVbQ +Ann9KO6Y/CoglJHcaRMsiN1jERvtH9CBEqaVN6GF/whofd6gb7RHL1HfeSFl8tQ1bkZ Wfhpb2x7/mkxuV0CZPD44CTBUcnCyTj5Pbq+/Suo58ul0XAxasomkcmrFrUsPxyLaF5j 07AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=oS1FPn188GwYqcEpeAiuLHN0qFHFB655DOQwCXbqud0=; b=FA1bMzFrtY05RO1wuizXTvliyrX39Vtz0FHBlja11kxbZdnkgsfD67a3Nfr2fdlt8p aXeEMFfWrvrLWp5QU+CNdTLlIp1oz3kMzfDd+r5EvsVNARa9X+Yy5fD7gecwjgcgDF7S WXfHoMNDWw+XHObFUKmfBKvz1IBdkkyxpGAjPmTbSThvRrm9t6t9SJQTLZbs5k9sX/z7 VbW6smUW2F8rcIdadDK1widVqFAslNpEdXoqlwNe0I4Lt1bZHF4al9O6UfZYin/mL5al HkY2qfRNQXb7HvsXvjp9bsZKPRz1LFdbttwmA5hgzyHGUfOinB3h6Gb/dwiO0JINDzoS GHFA== X-Gm-Message-State: ACgBeo0ZBjKyEzkYG9XwbBs6AfJiwWJ+RD3fYxpaHbEWOZv9IQxqdKn+ aZjiGKejPNDAoAC6Q9X4JHY= X-Google-Smtp-Source: AA6agR6ou/2uO4ZwPmqiUBrbDeggu1Vc3sPE8fBViDweS453cB4ryN7X8CzDyYJrxfL2DeihrtrS8A== X-Received: by 2002:a05:651c:4cf:b0:265:3ba8:92f7 with SMTP id e15-20020a05651c04cf00b002653ba892f7mr6302546lji.105.1662114718656; Fri, 02 Sep 2022 03:31:58 -0700 (PDT) Received: from [192.168.2.145] (109-252-119-13.nat.spd-mgts.ru. [109.252.119.13]) by smtp.googlemail.com with ESMTPSA id u9-20020ac258c9000000b0048b064707ebsm205794lfo.103.2022.09.02.03.31.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Sep 2022 03:31:58 -0700 (PDT) Message-ID: <760b999f-b15d-102e-8bc7-c3e69f07f43f@gmail.com> Date: Fri, 2 Sep 2022 13:31:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v4 06/21] drm/i915: Prepare to dynamic dma-buf locking specification Content-Language: en-US To: "Ruhl, Michael J" , Dmitry Osipenko , Jani Nikula , Joonas Lahtinen , "Vivi, Rodrigo" , Tvrtko Ursulin , =?UTF-8?Q?Thomas_Hellstr=c3=b6m?= , =?UTF-8?Q?Christian_K=c3=b6nig?= , Chris Wilson Cc: "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "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" , 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 , Qiang Yu , Srinivas Kandagatla , Amol Maheshwari , Jason Gunthorpe , Leon Romanovsky , "Gross, Jurgen" , Stefano Stabellini , Oleksandr Tyshchenko , Tomi Valkeinen , Russell King , Lucas Stach , Christian Gmeiner References: <20220831153757.97381-1-dmitry.osipenko@collabora.com> <20220831153757.97381-7-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 01.09.2022 17:02, Ruhl, Michael J пишет: ... >> --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c >> @@ -331,7 +331,19 @@ static void __i915_gem_free_objects(struct >> drm_i915_private *i915, >> continue; >> } >> >> + /* >> + * dma_buf_unmap_attachment() requires reservation to be >> + * locked. The imported GEM shouldn't share reservation lock, >> + * so it's safe to take the lock. >> + */ >> + if (obj->base.import_attach) >> + i915_gem_object_lock(obj, NULL); > > There is a lot of stuff going here. Taking the lock may be premature... > >> __i915_gem_object_pages_fini(obj); > > The i915_gem_dmabuf.c:i915_gem_object_put_pages_dmabuf is where > unmap_attachment is actually called, would it make more sense to make > do the locking there? The __i915_gem_object_put_pages() is invoked with a held reservation lock, while freeing object is a special time when we know that GEM is unused. The __i915_gem_free_objects() was taking the lock two weeks ago until the change made Chris Wilson [1] reached linux-next. [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2826d447fbd60e6a05e53d5f918bceb8c04e315c I don't think we can take the lock within i915_gem_object_put_pages_dmabuf(), it may/should deadlock other code paths.