Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2692938ybk; Tue, 12 May 2020 05:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVMSkmkTlVxBs0OPjskAZl7ff2ErEb+IsTdYRggyC93/j4iOZzjtywNf8xWcM1ntthLojG X-Received: by 2002:a50:d785:: with SMTP id w5mr2130214edi.212.1589288347692; Tue, 12 May 2020 05:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589288347; cv=none; d=google.com; s=arc-20160816; b=X6fll4IwE8vaup9nZU0TIvq8VYpEB+Ij019p99NMvGe10cUObc86aFP20pEoGX4MJO P+aX3L0Pn6Eish9RPCRLN81Ov7HsG3qHR8oD7Qc5Q/8ZVrzv/jigHZan3bdpVb+M7x0A oAq0fPD/vyx6UTwfI86glDBRsjDSdhWfZ3fnqC5lbWjMQV3G9XCyyElAsK2dguFajlxD aRL/53kgXArCqzDe8Y3kVk6hI2PmZztY5I14yG9nIRF4oX7PxA90lp1bz8yWGei/VpfG UKmdVClsyJn4hebtEmM/EGtI0nNPcrB4krU9ySf+wslx2G23B9PqjVvu0+moH9pRbYmB nM2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=YLwPnbDauSfAWxQ+40E6XOuXjM5jTgn5iCgXAVP6tHM=; b=vAqwDGywECRxSFFAFrmri5QM/d3TJ3BkrocL1NaQh3J+SewLrEQr8M5nfPYbsSjXry 9qwpb7RTF0+YXjOZWfq8RL9XB0I1wDibZkMc1mDo9dF6o4540hjIrJKj+5OQsO4OGIR8 jOV9nOU2uBE3qDjqTjQxMc4ZTX7gt0ff3dwxzqQCRse/LM9NNCwoGHux2ftAcbZ6dryk ZBzQMu6+ae4ucnn9UHl+8wmxxlcGf+aH4/ZXfYlSX9qaljPbQeBEjkhI48JaiSDWYDkf nm/mCL19VW2tsPmjI6ZDgjSJu5Yh5lK7wgkSSKZxQEAcD+RsPzxsKacKA2t8tAmjJofb jh2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=KWGRPT0N; 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 p12si7571367ejo.249.2020.05.12.05.58.44; Tue, 12 May 2020 05:59:07 -0700 (PDT) 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=@ffwll.ch header.s=google header.b=KWGRPT0N; 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 S1729750AbgELM5S (ORCPT + 99 others); Tue, 12 May 2020 08:57:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729570AbgELM5N (ORCPT ); Tue, 12 May 2020 08:57:13 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9C7C061A0F for ; Tue, 12 May 2020 05:57:13 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id m24so12034722wml.2 for ; Tue, 12 May 2020 05:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=YLwPnbDauSfAWxQ+40E6XOuXjM5jTgn5iCgXAVP6tHM=; b=KWGRPT0N+HWyZObFdaYwOoBDk6GmRygeG8bjF/Ab5wGAv3MXUGlO2Xf6a+9ZJ61BCM hxPgvmTkF+Bkvy7vlPpqhg8/t9LiQ1q0PTy/V04RetxJf4aLej2ZMhnrdUtQEP/RP/8a Z5PNDBOPNPemwJ32wYOyATJbIthvElXXJrGr0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=YLwPnbDauSfAWxQ+40E6XOuXjM5jTgn5iCgXAVP6tHM=; b=fy0nEuWfKWL/0OnSHEzSwH+GFnpUQkvPybT5VGgkRdykHHxoUSdyM7mX7t+AA9yO+Z Gf3SvBtaadQkTtZfCEHdlAR5wzuVWwxY9oigE8NYP3rf/Wzdf3dvgxri5YulajqLIx3S UL8Ke4BTBLDJ9rJntBQZgVi5zLKoz4edwEsAEconxkuSCy1jc8g/F0AueNQ/gvDF31k9 VfGIMsuCjomd91MnAsfxGtHWtJStfRzanRJCGnrU3uiAWyu93YSYwnubliDa5Moabbub HB8ZeFbpv7qb3CUGDwBloi47c9rT1ZrLr1cbf46/sY2SC5yMuTtF9erXCcJ+MUoTt7OG m55Q== X-Gm-Message-State: AGi0PuZhG8ZDKdjmAai8g2HZHi5giqMiGQRrri2745HK35gSyEuvvGxC pVekS1bz0l4Pzat6gUfj/rNVFjqn0SU= X-Received: by 2002:a7b:c5c7:: with SMTP id n7mr27041116wmk.18.1589288231721; Tue, 12 May 2020 05:57:11 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 32sm23035619wrg.19.2020.05.12.05.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 05:57:10 -0700 (PDT) Date: Tue, 12 May 2020 14:57:08 +0200 From: Daniel Vetter To: Jason Gunthorpe Cc: Daniel Vetter , DRI Development , LKML , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Chris Wilson , Maarten Lankhorst , Christian =?iso-8859-1?Q?K=F6nig?= , Daniel Vetter Subject: Re: [RFC 02/17] dma-fence: basic lockdep annotations Message-ID: <20200512125708.GG206103@phenom.ffwll.local> Mail-Followup-To: Jason Gunthorpe , DRI Development , LKML , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Chris Wilson , Maarten Lankhorst , Christian =?iso-8859-1?Q?K=F6nig?= , Daniel Vetter References: <20200512085944.222637-1-daniel.vetter@ffwll.ch> <20200512085944.222637-3-daniel.vetter@ffwll.ch> <20200512120952.GG26002@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200512120952.GG26002@ziepe.ca> X-Operating-System: Linux phenom 5.6.0-1-amd64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 09:09:52AM -0300, Jason Gunthorpe wrote: > On Tue, May 12, 2020 at 10:59:29AM +0200, Daniel Vetter wrote: > > diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c > > index 6802125349fb..d5c0fd2efc70 100644 > > +++ b/drivers/dma-buf/dma-fence.c > > @@ -110,6 +110,52 @@ u64 dma_fence_context_alloc(unsigned num) > > } > > EXPORT_SYMBOL(dma_fence_context_alloc); > > > > +#ifdef CONFIG_LOCKDEP > > +struct lockdep_map dma_fence_lockdep_map = { > > + .name = "dma_fence_map" > > +}; > > + > > +bool dma_fence_begin_signalling(void) > > +{ > > Why is this global? I would have expected it to be connected to a > single fence? It's the same rules for all fences, since they can be shared across drivers in various ways. Lockdep usually achieves that with a static variable hidden in the macro, but that doesn't work if you have lots of different ways from different drivers to create a dma_fence. Hence the unique global one that we explicitly allocate. We have similar stuff for the global dma_resv_lock ww_mutex class, just there it's a bit more standardized and hidden behind a neat macro. But really lockdep needs global lockdep_maps or it doesn't work. > It would also be alot nicer if this was some general lockdep feature, > not tied to dmabuf. This exact problem also strikes anyone using > completions, for instance, and the same solution should be > applicable?? There was: https://lwn.net/Articles/709849/ It even got merged, and seems to have worked. Unfortunately (and I'm not entirely clear on the reasons) it was thrown out again, so we can't use it. That means wait_event/wake_up dependencies need to be manually annotated, like e.g. flush_work() already is. flush_work is more or less where I've stolen this idea from, with some adjustements and tricks on top to make it work for dma_fence users. Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch