From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 048F526738D for ; Mon, 2 Feb 2026 15:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770047715; cv=none; b=Iy9Hc6qEtqdTy+m8ActAXZi7SGyPZ9tYgJ1vZ7l3vFLQ9ZuGbqmEddRE2aZ56VxRktGTRtpG26GLan5pAUX6V4YAQIAcyIusdz+pDqWkSamUVMj1qPUHB1Ii8e8OnxEi4dvmoCvSSbcpouikfgnPJfAlEZkcTE9uiiYNfCpEif8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770047715; c=relaxed/simple; bh=kGopxFZIlz3MVRgBeMLykRwwSqchomFgyOoC00zrG+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dF7ix6upieFXOQ+YIR6ZEL2WI+Md76boFVdrkQqxeZUKn1uH+ZfWL9WIbtBT0S34nYKsTeZWfB3RDXJjy0KTX+qqNKs1igWb4eZU0q2yDklAJaczvolX00mQzuO8BB/lMprJx+tnVxxef+13ZhynPiZ71N2FuyDcre3NTBULA0c= 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=ebsv6aKA; arc=none smtp.client-ip=209.85.160.178 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="ebsv6aKA" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-5014600ad12so34293871cf.2 for ; Mon, 02 Feb 2026 07:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1770047713; x=1770652513; 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=ALEv89D4GoCyBIrWNO6jRp/YUrS6bKKk+NOOQflmefI=; b=ebsv6aKA5I95pRpilZ2kl9neu2jRU6KQp323uoomVjuawIhfJIrVhOu8I4p2kW0kBk INsDho4d219/ydEH3YlWsnrRXHQ/Xp7eQtrNjNdChGWMz9fYR9E9zKIrnRNRQHK7QZgL zDRU+CGHKtqAwTeHT54kPmSnXBkgyNmpD1sKeF3aE12aQzCbCtOpm2v1Pu4Ujz29+xiv 785VfdkMIxFblI16F49MBaLtZdFyAtiSXKWBHx+LLmke1XK+rIkYm9QHVo+SaSQbMPWb KVi8q706aJ80zP2/GPLd1yF4SU7kbLvVofsSQF1S4Iq8qrloiHR0IZb6DhBDaPyQgLII 8nsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770047713; x=1770652513; 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=ALEv89D4GoCyBIrWNO6jRp/YUrS6bKKk+NOOQflmefI=; b=u5T6sj78sASceCYLn/4j2obkPsXyKrGpDPko0Lt2cNNmFA6L3A7SvbaFv5ek+LzeiM A3S8xobo3lpf+4w2LkqS/s9l659uiBLIFk3rL9miTrMzu6RxAzD0/HEPCKxPHHbc0Tvc rTjRHGQwYMQi3/VBSRwapIuXbYPGOBAdUOYLxlHMBJ9+u8ojMm3ketoaiqg79mkzBl6V fk2ni5IxDSOKuMIXrNolQGf3rBlWAib/6wybmMXivyybELyVHv9ViSzYhzPPlo5lIB2D QF7q8GvbqXc68Psb/SKV8kpbjt0KAHEVCdVxhpdOkmo7mL6hMMbd5TelXkbFWykSPtpJ osUg== X-Forwarded-Encrypted: i=1; AJvYcCXEMAQZmiHKHPwGnJusaeHuq7UFaassT0P43FYgvk8yacTtw0ZEgTQw3VwRMca1aU7h5iP9OHgkbQWrgm1jcg==@lists.linux.dev X-Gm-Message-State: AOJu0Yyu+SOYmV1IaS/Qa5Zdqtm1V9ac+wFyTxbh3CF1oVJq5qgUmuat yDKbAV/IX5/p4ytdiTvZDGYfLF7eysXyaj9iHvLDduqGjXJ9JKufMrBluY0vZbJREDc= X-Gm-Gg: AZuq6aIEIiJ9a4EFPxfCQmPIsR1tZWRIuYRD3OAf5tbZJ75hZLTkDJQ7AUXRnvJ2HvT E8WE8x+Di8XyzESTubGkH2M6XdP1NpM+GXv0NPXKUjnFqcmU+7VZt7RukRIS31FeU8h8zb5mZjV /VvEMyCAap9hMYqs7r8S+xghH0697kJei1hlHc1OCMywS0Zlz5nuqZ+LWEfTvkfBuuWzosOvlzP qMkjY5PdrfzqS+HbsIuuG+tRKLGpGdHMKmeLJQoceUsqe1IYk8PtEbkmnJlqvXClMfeo8P5w0Ro beIdO3M7SlpEHPiIecsSxqFj7bS228d7z4GdJZVml+picod/SpGzMILKX3FZYk8rNk/f5eDEz8p ohqE4Cy3Q8AxYvAqpU7LeQUXHLuTtROlhESW1pKYV18lsyspFP4X8BnOQpqOT+yugAt9S5nfQBO XvnXWRuLPthhPSzRsXiK2tDOWLz/tFqqE9HrqFWmkGYscT82dpggCmstQi4EE6uOTGCck= X-Received: by 2002:a05:622a:1a82:b0:4f1:dfc8:50b with SMTP id d75a77b69052e-505d22b2818mr153088161cf.76.1770047712810; Mon, 02 Feb 2026 07:55:12 -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-50337ba3997sm107174411cf.17.2026.02.02.07.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 07:55:12 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1vmwGd-0000000FWiw-2z4k; Mon, 02 Feb 2026 11:55:11 -0400 Date: Mon, 2 Feb 2026 11:55:11 -0400 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= , Alex Williamson 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 , 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: <20260202155511.GI2328995@ziepe.ca> References: <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> <20260202151221.GH2328995@ziepe.ca> <44ec9689-045e-401b-b9cc-17abdd938bc7@amd.com> Precedence: bulk X-Mailing-List: virtualization@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: <44ec9689-045e-401b-b9cc-17abdd938bc7@amd.com> On Mon, Feb 02, 2026 at 04:21:50PM +0100, Christian König wrote: > > 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. > > From your description I agree that this doesn't make sense, but from > the code it looks like exactly that is done. > > Grep for pm_runtime_* on drivers/vfio/pci, but could be that I > misunderstood the functionality, e.g. didn't spend to much time on > it. > > Just keep it in the back of your mind and maybe double check if that > is actually the desired behavior. I had a small conversation with AlexW and we think VFIO is OK (bugs excluded). The use of the PM timer is still under userspace control, even though a timer is still involved. Basically there are a series of IOCTL defined in VFIO, like LOW_POWER_ENTRY that all isolate the PCI device from userspace. The mmap is blocked with SIBGUS and the DMABUFs are revoked. The VFIO uAPI contract requries userspace to stop touching the device immediately when using these IOCTLs. The PM timer may still be involved, but is an implementation detail. Effectively VFIO has a device state "isolated" meaning that userspace cannot access the MMIO, and it enters this state based on various IOCTLs from userspace. It ties mmap and DMABUF together so that if mmap SIGBUS's the DMABUF is unmapped. I understand your remarks, and this use of PM is certainly nothing that any other driver should copy, but it does make sense for VFIO. If there are bugs/issues we would continue to keep the overall property that SGIBUS==DMABUF unmapped and only adjust when that happens. TBH, I don't think people use the VFIO PM feature very much. Jason