Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2232997pxb; Mon, 18 Jan 2021 11:48:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJydkfdYKSTSIWsae+J+0WgI+TQzCntbusWIlGHUaIMPpAVhs0AdU6NgY77Hqc+X1KYTlgWd X-Received: by 2002:a17:907:3e02:: with SMTP id hp2mr772703ejc.411.1610999329762; Mon, 18 Jan 2021 11:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610999329; cv=none; d=google.com; s=arc-20160816; b=jnvVCtFF/XP6nM8AvSrzPrUGIbancY/7m0kQO+aCYdmcifR6dT7TWaXC1EiZlaVP+6 AndFvR4g96nVC+Avw/CPppaM7OP1F31+8Ro3JzyQzN+rVv5lEsQZN6S4D+nvzokIr/C5 sNkw1jJcegVNibXfGaeAOWkc4kHxgbqsnxGJbFB1tK5/qHSlBZ+hUvN43ZspIcymY0Dv icTOcLszWy2ZKngmcroSwOeqG7PJCDYtHuBKj5B9yNeSB+P7r9cq8SpFlrGA0jkGGh/f 5ge2UYotvCYt41Ed8hv1eYbszdUGwMM3EMsq5x0j6rYRqKxiGHrezOPoSpB9BFCUPa0j CC/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=zEJ22T1F3C1ubeY5/smo9KBx7Q8j3vhMGHt2WDHCSaU=; b=XL8KLgX0WqPxuT29vxA09ta4oSLSfSlO0aFTtjBFztlQYlWDuNde/ZgevjKWamIOYD IsJrWKSfZX09E9f9m5z6oEsUpF92oYcEGZwzl2NUWaw4EI+cuGZk5WzKSPZ+SyEgQOZI hP1MP/G39WOS1cCQLs3/eoubCug7T/Nl4sq+xCcHycD2eiQm9N3pRuchSUomagPOAcao YsAOEs0VX4bjbSTNoJAQpX+37IdAoIS52xflrhhIBBjcyxRCj53hhRp+A9SSGTEwdmuF TAfVawg/51jqhGVggSgQIwEZTjJapEnEHyFOL5F8BMlzvn2b92CoPNJ9F3psOaxh7PlS BYLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=cUK7zXfa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca23si8960579edb.262.2021.01.18.11.48.17; Mon, 18 Jan 2021 11:48:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=cUK7zXfa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437510AbhARTnP (ORCPT + 99 others); Mon, 18 Jan 2021 14:43:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390365AbhARTm5 (ORCPT ); Mon, 18 Jan 2021 14:42:57 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098D3C061573 for ; Mon, 18 Jan 2021 11:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description; bh=zEJ22T1F3C1ubeY5/smo9KBx7Q8j3vhMGHt2WDHCSaU=; b=cUK7zXfaMBn25pUSZdxNvgLj0O uBg6xKKhdWyrtkQsCeMm3Kn2EP3pjEcLEaJlRAIQGlRZqIMSlXBjMmiDq24QOgwRdcAixbOQIeRtB JtLV8PvHMSm/mPAOJXRVgeZX6U0Q6qbvFkONMl5WP2fuSOx/lWFaATpxT0mg0x72l5aED38rusqNm PC/v95/FvgmYcdZcV9FeBgB9fGW8ClMfBV3xeztFJtFb3VIaZhB78qb/W5j+cev6r61SnFFs2L8EU NYb/JsL9GsKhYVBmOpAziNtG+Gzi+wus9dZqfq3pWQ5I/RztgB1hrXnEqf13vDoRTdC6gkeIhTt4q Enu8wHBA==; Received: from [2601:1c0:6280:3f0::9abc] by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1aPk-0007XE-C8; Mon, 18 Jan 2021 19:42:12 +0000 Subject: Re: [PATCH] drm/syncobj: make lockdep complain on WAIT_FOR_SUBMIT v2 To: =?UTF-8?Q?Christian_K=c3=b6nig?= , daniel@ffwll.ch, peterz@infradead.org, mingo@redhat.com, will@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20210118180334.43714-1-christian.koenig@amd.com> <20210118180334.43714-2-christian.koenig@amd.com> From: Randy Dunlap Message-ID: <3ebc7345-1b3f-8e7f-dc12-eacfd3a993d9@infradead.org> Date: Mon, 18 Jan 2021 11:42:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20210118180334.43714-2-christian.koenig@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Just a comment about the comments: On 1/18/21 10:03 AM, Christian König wrote: > DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT can't be used when we hold locks > since we are basically waiting for userspace to do something. > > Holding a lock while doing so can trivial deadlock with page faults > etc... > > So make lockdep complain when a driver tries to do this. > > v2: Add lockdep_assert_none_held() macro. > > Signed-off-by: Christian König > --- > drivers/gpu/drm/drm_syncobj.c | 7 +++++++ > include/linux/lockdep.h | 5 +++++ > 2 files changed, 12 insertions(+) > > diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c > index 6e74e6745eca..f51458615158 100644 > --- a/drivers/gpu/drm/drm_syncobj.c > +++ b/drivers/gpu/drm/drm_syncobj.c > @@ -387,6 +387,13 @@ int drm_syncobj_find_fence(struct drm_file *file_private, > if (!syncobj) > return -ENOENT; > > + /* Waiting for userspace with locks help is illegal cause that can held because > + * trivial deadlock with page faults for example. Make lockdep complain trivially > + * about it early on. > + */ > + if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) > + lockdep_assert_none_held_once(); > + > *fence = drm_syncobj_fence_get(syncobj); > drm_syncobj_put(syncobj); > thanks. -- ~Randy You can't do anything without having to do something else first. -- Belefant's Law