Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp691819ybt; Fri, 19 Jun 2020 11:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxUBeAWIfh2S5SKTAU/ZSsmry+Ha0XF2c7tBUoB3GKWJt3Lmh+c4T2s1AZVSMvS1jyiBzG X-Received: by 2002:a17:906:d043:: with SMTP id bo3mr4596706ejb.409.1592590347025; Fri, 19 Jun 2020 11:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592590347; cv=none; d=google.com; s=arc-20160816; b=pXf3zYhEzh1+ahfQiauY2PCPoKqWyZUXMc73Ezu/KZR3mn/UB2EBFOcPoCzGQeEBmn cqwrgF8gss8awbCA9ElJfPTwIhL77yVbqxFxiPNufDgKO+2kEtAaq6jW9d14IMYDk5Zt Pm/Urx1sN6dUMGVIQ4UkZ2cWWjXkRajLR4shldAOu6UMII8kLz5fnug8hpAPmb24mkFG M32m7PTZingfeOu7ZtATsCknJJ+K95gKpiNfG55yZkNTbhmVPkRLPRRH1a0jEeBZM9a8 ivOw+I8H+XNncuu8mvzvOoCYkQQFiCGWCglnQS52rKTK0JxVUi/Pajyrqtd+onj9uf6k f0Og== 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:message-id:subject:cc:to:from:date :dkim-signature; bh=5lQCYSoi4FC78xGjLBeogrhLOaSlungd8A2lT6c416A=; b=hEjGydWkVpSfXrBpx7drr+hbFcrsHgokjwLanGYnST58cF9OGAKYTmN7nQVCO/3qVw VMguKv/JJ4+k0MMMqRbJO3B535zrlxzeDmTvQE120fdqUXCFuOmuOL7aPs31zwDVy8RD rj+JkBX0Mw9uwDISt5mSGQ0vrVPgJOCLM86H7mmyTG3se7teVvnpMxqYX/6D5tTbPoSW k3X+XWXkJ8IJW5p885nifN4tmH1DaqsVDhxc1uurWO8Qttwf1jW/NmQD7zhSEkMpFwNv 0/3gg184BxQPFgeXi7DZBowJUOBdeMOaeecFwWmoAEuLPf8doT13GX3svDtslNBkhvK6 6mIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="GpTji/yh"; 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 c22si5031301edx.584.2020.06.19.11.12.05; Fri, 19 Jun 2020 11:12:27 -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=@ziepe.ca header.s=google header.b="GpTji/yh"; 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 S1731954AbgFSLjl (ORCPT + 99 others); Fri, 19 Jun 2020 07:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731811AbgFSLjh (ORCPT ); Fri, 19 Jun 2020 07:39:37 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F660C0613EE for ; Fri, 19 Jun 2020 04:39:37 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id j68so5202905qkb.10 for ; Fri, 19 Jun 2020 04:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5lQCYSoi4FC78xGjLBeogrhLOaSlungd8A2lT6c416A=; b=GpTji/yhJTYfywss1k5am+JyELnNZlvvM8qP/Uyg3OD7x7MqDitwSWfgM3HPj0UhUM CmGRkgXfDHKjJbk/G94ThGo65HoXLKpYTHWId62kC64177gtGxTII+K1ZYz1wipOiAHJ eNgWeTmTaG/jDKlMWG2mJATpUK5rAwHHXT5FR/exkvaSA9MSXlfn3hlOUhTW2ZxS/H4F HEmI2H47vtMrMdfYBePKTzq7Q28TCNQpdwQLKytMyWVDkIDxh7YsNl1xg+jdzcXMR0cI rZrwuwfz+8JvRuJ/hZc0oTCMz+QMnazKQOTVrKsL2AkwHyGJfWycuxP+cVSimTbDO1fJ 9CVg== 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:references :mime-version:content-disposition:in-reply-to; bh=5lQCYSoi4FC78xGjLBeogrhLOaSlungd8A2lT6c416A=; b=R2oDdq4QeJJ+Bp58yqCg+2IvXfqYn8V3QN2hH5NU8dSr5zv0rWez1d3pr77dPYje+D sEQpFxoi8ux8TzB4tEGaGWY98SL/G+qzqceK7xPw2SKEgQYzQOj8Mu3Ce80dzbpfqp1r MNtX4ZBJDQWexfS0+WPsQU8HPO5tC6/2jhp8aeGvSkyA9y8gdqfgyoZ3yUxYVFfax/kl nQOo6uqod2AgOHTYJIiVe0Y9A1CTw2rF13tqvyBETjlyjRv/60z0l1uIYZOsckoLL8Sf s5hHY8gknIkELCgAMXxxbPjXYWsFKPRfqRASC2JH4zZFPlGhkELRmj4+gvla1WaO/f2s EbRw== X-Gm-Message-State: AOAM533mZFjdIK6PQKJtHhL1e36kDmdWfi5owq9ViIAmfHvKESCAjFxm mwMxdGSEILylU4Dmse9zCj9Zkw== X-Received: by 2002:a37:6191:: with SMTP id v139mr2946071qkb.213.1592566776171; Fri, 19 Jun 2020 04:39:36 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id o6sm6016053qtd.59.2020.06.19.04.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 04:39:35 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.93) (envelope-from ) id 1jmFMs-00AiVa-OZ; Fri, 19 Jun 2020 08:39:34 -0300 Date: Fri, 19 Jun 2020 08:39:34 -0300 From: Jason Gunthorpe To: Daniel Vetter Cc: Thomas =?utf-8?B?SGVsbHN0csO2bSAoSW50ZWwp?= , DRI Development , linux-rdma , Intel Graphics Development , Maarten Lankhorst , LKML , amd-gfx list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Thomas Hellstrom , Daniel Vetter , "open list:DMA BUFFER SHARING FRAMEWORK" , Christian =?utf-8?B?S8O2bmln?= , Mika Kuoppala Subject: Re: [Linaro-mm-sig] [PATCH 04/18] dma-fence: prime lockdep annotations Message-ID: <20200619113934.GN6578@ziepe.ca> References: <20200604081224.863494-5-daniel.vetter@ffwll.ch> <20200611083430.GD20149@phenom.ffwll.local> <20200611141515.GW6578@ziepe.ca> <20200616120719.GL20149@phenom.ffwll.local> <20200617152835.GF6578@ziepe.ca> <20200618150051.GS20149@phenom.ffwll.local> <20200618172338.GM6578@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 19, 2020 at 09:22:09AM +0200, Daniel Vetter wrote: > > As I've understood GPU that means you need to show that the commands > > associated with the buffer have completed. This is all local stuff > > within the driver, right? Why use fence (other than it already exists) > > Because that's the end-of-dma thing. And it's cross-driver for the > above reasons, e.g. > - device A renders some stuff. Userspace gets dma_fence A out of that > (well sync_file or one of the other uapi interfaces, but you get the > idea) > - userspace (across process or just different driver) issues more > rendering for device B, which depends upon the rendering done on > device A. So dma_fence A is an dependency and will block this dma > operation. Userspace (and the kernel) gets dma_fence B out of this > - because unfortunate reasons, the same rendering on device B also > needs a userptr buffer, which means that dma_fence B is also the one > that the mmu_range_notifier needs to wait on before it can tell core > mm that it can go ahead and release those pages I was afraid you'd say this - this is complete madness for other DMA devices to borrow the notifier hook of the first device! What if the first device is a page faulting device and doesn't call dma_fence?? It you are going to treat things this way then the mmu notifier really needs to be part of the some core DMA buf, and not randomly sprinkled in drivers But really this is what page pinning is supposed to be used for, the MM behavior when it blocks on a pinned page is less invasive than if it stalls inside a mmu notifier. You can mix it, use mmu notififers to keep track if the buffer is still live, but when you want to trigger DMA then pin the pages and keep them pinned until DMA is done. The pin protects things (well, fork is still a problem) Do not need to wait on dma_fence in notifiers. Jason