From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89792378829 for ; Mon, 2 Feb 2026 15:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045146; cv=none; b=FNv5ej1xyjXGnjuiIXuLigNBy8Z2c/MgySqPoQPDDp8SA35vOzv48U8WxkeR7/llaPDk+YKuBIDfC2plRc2QjIOZkL00Wo8cn/G7UrpBudDqcbeQt9pAd4rygKL+1PgBRX8yLl4FM312LAG7Y7RhEdn0KkDWVwVmN2RyvCx7+Ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045146; c=relaxed/simple; bh=rQqYEXSh+ob8KxdPcyhxAvs4tWXZTKZFQO51kRUI59c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NE8/D4aAd6rFVYcx7KqKZP7E3WF4KVYlqRqujMWxcPncL+Ytfw7mNyuucSJYlHj0a8vOowYGEeJCETIxhIyZQnbJiP8uGT6WVIkKbq/GUtMn7l4MNrd/7P09HjPcbWMU+SXxeHr5btg6p4eT2VvTPoPxnBEXinq6ZaDyXuhvn9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=miQCLY1+; arc=none smtp.client-ip=209.85.160.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="miQCLY1+" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-5029af2b4bcso24808221cf.0 for ; Mon, 02 Feb 2026 07:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1770045143; x=1770649943; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=xO0aL+oRN74yVSsHQO79QNqtu9/dj8jxjzC/60StG/Q=; b=miQCLY1+i0kzm9WHu9ZXCe3lsby8ZnJNjVamX+cRUMDmZ5pwrNDNnRobJc/A13/S/H tUFNwf5GJ1myqwSL73s3bRBfHSa9KIJNBOh3lAFBig4niv7DBaBVBlaUvtc6f+5TuUDv i4o11P+ONa8pi9KrG0z41tne/85T78p8UC6t1Ub1j6S4F0MoECA/5aOGuyDRBPGnOTKO Yd53SYfqvyXGZuft/+O3HF4qPgVp6rvb34Xjy1Gtqm7Ut8FyR/RqOsfm3+zppSd1mrVx KL12YLX7/BziWc3R7aq0ROVcXdH1cuITbCuON665DyqvcIYBzI8kVqU9FKjgf5A52+6A 8bpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770045143; x=1770649943; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xO0aL+oRN74yVSsHQO79QNqtu9/dj8jxjzC/60StG/Q=; b=tM29/BMW4yaRXGoZhJM26iic9toZCECmml6lSD6sPnJw/2lGUtWzoh6ZF9dmU3H2VU psTgQqijjwxBu3supckGpgkowwdd6DcVbbciZ7CsDmAWfsAhopGYhrbiuFMYIenFgtMW jDxvhOpFscmd5FUiz2Av6jpPRRK6+eiuS7sFONw7cE/HFN+MFyQfqp8tqoKzqC9S5fyy zLIp4xwVK3O9aR+m5Pb1IFXDQhtmFIiCK40uQRq9PDWBkD5OKUcSbgi5qQ6bMR06Oc4b OXkoz3/T8qhn/fNcmEXHJ1nhTuQ6FU2JTUyK3vI2fWjgZmJSpiyuIDyFYnIQ43RXpq0h 7vxA== X-Forwarded-Encrypted: i=1; AJvYcCWO6vO1gK7+2hqPMrzJ+D7rc0DIPhkFewRSSM2hsBuf+TU3QUy/ACb76rmDQexa4pFpVSrBBSIdLFvNha8=@vger.kernel.org X-Gm-Message-State: AOJu0YzW48LE+CN4393sGPhjD1BguGkhulAZ/1QKPJ9NOi12DZbA4xCz QetYzl+E+qBbxn8/AqqX8Lj5EnKo8TDQTwxci5SHeMwQCWqSM9e0L+1mhtyPfDXS6ws= X-Gm-Gg: AZuq6aL9X9uyfqUkMEhaVQv2gsZ9HGZXRwJmzy1m7F/GszHPu2gReWm06yNbSCNhK7Y 37NW2kcMZvJVMi1uF3DDc6Sg00meruI9CmHUWkU5FmM9qTwwsc8HzSKpcGrWuDVM6lqSWopaFRm X5nsHe26PMtGrjk01OPb8Q/fVnPoudiXiPkbHJrMhG1jmV6CqHdDvDp1/kKi6ECpk+X813rkhSC uoLUM8jUV9WsWrJSA2S6ycsgGLtBd5Hq6E7l0LnxUCBQFgDUM5ntXf5E0WJ1EGsj1vit+M6TFFD uLbadRvYCTLpPutbBoNisScMXTUHOjrVZkF6SG07B5mOQ5I9mMKhxnSBccbeFWHNF3opU6qhDjs p2fP/c5hpbvh1FQCQE1hZAi0Su6b/d2ppWFeUsf78JFLRLw6tkYtwMYcqIeQm83FUOC9UXtyeeH cV4PMPQqZHgFCpVcXyd+u/5xa8RWj1nMiGZxd09X5wvHb4voudWL8x8+4S4aC/s942eTE= X-Received: by 2002:a05:622a:1993:b0:4ee:1903:367b with SMTP id d75a77b69052e-505d214ba65mr150834861cf.5.1770045143271; Mon, 02 Feb 2026 07:12:23 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50337bb9d21sm106856261cf.26.2026.02.02.07.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 07:12:22 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vmvbB-0000000FJuI-3Zxp; Mon, 02 Feb 2026 11:12:21 -0400 Date: Mon, 2 Feb 2026 11:12:21 -0400 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Leon Romanovsky , Sumit Semwal , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , Thomas =?utf-8?Q?Hellstr=C3=B6m?= , Rodrigo Vivi , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: Re: [PATCH v5 4/8] vfio: Wait for dma-buf invalidation to complete Message-ID: <20260202151221.GH2328995@ziepe.ca> References: <20260124-dmabuf-revoke-v5-0-f98fca917e96@nvidia.com> <20260124-dmabuf-revoke-v5-4-f98fca917e96@nvidia.com> <31872c87-5cba-4081-8196-72cc839c6122@amd.com> <20260130130131.GO10992@unreal> <20260130135618.GC2328995@ziepe.ca> <20260130144415.GE2328995@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Feb 02, 2026 at 09:42:22AM +0100, Christian König wrote: > On 1/30/26 15:44, Jason Gunthorpe wrote: > > On Fri, Jan 30, 2026 at 03:11:48PM +0100, Christian König wrote: > >> On 1/30/26 14:56, Jason Gunthorpe wrote: > >>> On Fri, Jan 30, 2026 at 02:21:08PM +0100, Christian König wrote: > >>> > >>>> That would work for me. > >>>> > >>>> Question is if you really want to do it this way? See usually > >>>> exporters try to avoid blocking such functions. > >>> > >>> Yes, it has to be this way, revoke is a synchronous user space > >>> triggered operation around things like FLR or device close. We can't > >>> defer it into some background operation like pm. > >> > >> Yeah, but you only need that in a couple of use cases and not all. > > > > Not all, that is why the dma_buf_attach_revocable() is there to > > distinguish this case from others. > > No, no that's not what I mean. > > See on the one hand you have runtime PM which automatically shuts > down your device after some time when the last user stops using it. > > Then on the other hand you have an intentional revoke triggered by > userspace. > > As far as I've read up on the code currently both are handled the > same way, and that doesn't sound correct to me. > > Runtime PM should *not* trigger automatically when there are still > mappings or even DMA-bufs in existence for the VFIO device. I'm a little confused why we are talking about runtime PM - are you pointing out an issue in VFIO today where it's PM support is not good? I admit I don't know a lot about VFIO PM support.. Though I thought in the VFIO case PM was actually under userspace control as generally the PM control is delegated to the VM. Through that lens, what is happening here is correct. If the VM requests to shut down VFIO PM (through a hypervisor vfio ioctl) then we do want to revoke the DMABUF so that the VM can't trigger a AER/etc by trying to access the sleeping PCI device. I don't think VFIO uses automatic PM on a timer, that doesn't make sense for it's programming model. Jason