From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 9043E378D7D for ; Mon, 2 Feb 2026 15:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045146; cv=none; b=O7yhgEExD0Tt5gUadrWIzKbe1xN+pip3ar9fkGA4lzdBwv/frnbqCP0gtAafEqtxvt2cnde+oBpIortttJlXtRlthzdFHOT7wUyMP6GZXfL8XIFuhBYuro3ntB0As/LaOsRiBWISyyhLSYBQYS1jJHD+6xzase8vwZA7Lcr1kMo= 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=X8MTT2Pi; arc=none smtp.client-ip=209.85.160.170 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="X8MTT2Pi" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-505a1789a27so21659631cf.3 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=lists.linux.dev; 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=X8MTT2PizjjwwBAhepArmSWsKXSqcuYUfBLh1z8A6Fvk9GRmxQocJyc0CRAvinpmEo 0U+eQSnOLgdKGQS5wND7ve7psbXSGt5H1YguSCNpH006Q5e3bSR7vy9/hDFa6l+cL13j 3wbMdRI1I6jDTfX7mfANRrlLVumNfE0M7sPnkTZPqLoPUKuPUwypxjXtdfF/8CtdoTjF /bysXXbgkT+r1+Oe6xE5HMJuHqtzcSgvubZlmKMwPiRuRlUVmGLsMaiPoAYLDurr2Dn+ asbUNc0S1GR5V5lG+ZX0HV8JadxB+g8ldBB/5GD3dMu6m1VFAyVU6jwX1Qw2snHdbNsP lbBA== 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=H/TdvhagG+ICPGnIl96hIdCYTAvS2tF1PO1KKyC/6ODv7/gLWvmgYtYqU/P6/WW7hj griBNibqx97jEyz6X2fcdLrHxqE6Pybfq2KO8d8aI34ra4lneOwEwFeuv2sf7icldZRI 8lEF1MF/uPpKl66Sp0BtjdNlLjnKZR9ze6eBYnAxx92DqpPLaDt7BoZNjBt1jtPQll3q pwuRda5rJYplTJJd+eaDAf+E24jd+byFqAIJdU64gxDT9LWDYsKqhe6WeF/kfc3qHnOE MvMLnTYS2wO9Si8UrtzzGZuHpvmM5877XoImla7JAw5OVUA7uMVAUhD+S7izbdHhpNIs 1tqQ== X-Forwarded-Encrypted: i=1; AJvYcCUjzCZ6Z42+zAHLlGlBUxA+zCNcP9X0/aM8CMOc5+NcJnuQuvCcediG/+/Bwf32265aPw3l7Q==@lists.linux.dev X-Gm-Message-State: AOJu0YxvaxQ7nwYpkJKIhng1uXAJmw6k82/El0v5UGC4x/RdIeU5E6P6 11KQ4eATBaSaUP+MMNQWEktz21HGdOuzPTuKnPiZ+z9rfhD0kiSbqXh3eXCBd0j2PoM= X-Gm-Gg: AZuq6aKpV6MLDDCQr6e7x0D73MGJ+E3sQVJvSelRAzLVlWRjcSHSez6PO2E6otfveVb asQiWaKvXEPcSjfplqJIpL0bDxKGh1+SpVJIiET6ZTJujOdPreImBz0syRcJ34ZsnPA4B9oa+t9 3ioQ6lnjED8q/4fhl64khwTNmhGh1WTZ1gONLKVDrhAqhYNjUuQPfHpvZFeK+8xuu4vFgCnqjZ+ SeA/Y0HnE2D+LFYjRZqcSIwJUzgZUrfgBR5BIIXAM/NKoGqRtaosz/7T2qZ0lMIDDpSGcRot2pY zXuopvmdVHkw8pRRd8OXbJ4Td5cXdk6HDvPfk+5lp1TMx9c6ssu8ZfBEKfqc17eRs79El/nIMmG 7mDwE1T05xwv1/SmytlbyrrSJSUS39qBAuRQ+WU4r3fcYsSy2W1sT4v7YiLtHAY587YRaUhepx/ 8xuTdTIHjGXdjjpOE0Dx6+2uVVQb8E1W+xA4erO3JlHDrm4qM0TYssNPmP6c2gXjsHGHQ= 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: iommu@lists.linux.dev 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