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 00B292571A5 for ; Mon, 2 Feb 2026 15:55:13 +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=1770047715; cv=none; b=mD6RqSDw4Q703djV/Vxn1o2pB2/QAagf+BA1OpFKA62NFTkwrXXj8wbYVtFt6udjuN8oARvMcEeIGj1JpgjqLJ7OF1FHiA6qKqxfFOHLiDZzvZ1BjwC7bQ7bG5bxf3vxb+mnLDn49xDpos/JQUGLNQ+mgV9sFrIAMbl+wU6oDYs= 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=cc9sz5lo; 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="cc9sz5lo" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-5014600ad12so34293851cf.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=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=ALEv89D4GoCyBIrWNO6jRp/YUrS6bKKk+NOOQflmefI=; b=cc9sz5loG5+85psAhMPsZpMcj5wll6NsIJR0nz3trS1TSKRBQCVs/8zKA0AQb862mB Hip6EjCC8qyYGazpS517/dsxEKQUL9YRGo2+UlHIx7Bw3/Y2TtJ6VZFeO6lZhNQRwjNJ qFSvOrbH1I8RdRdSOnwIdkKnzl+Viut72ZJ0fouAuB0PZsu7IXYhy1LhYYO1asqZSmlF yVNq/NGrj2Jm4/AZyheEgc/vkvEdcZJdHbkqW5x/akbImqkrDYwyQ65wPk+HYQydkj0L zk00gpIj8T2z6N/LDfmJdQht3voEmNvroqmXEp27Ii3Xyq27u2n0cyLmmoBWP1P9ncqD JoHQ== 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=BPugADJ6G5/MH4tebAjO5VjoEy70u77hQFig1+w5Aljwz1ZzU+QRknmsVPV1C2Y05d ig8SJ7O+wqQ4uHn9wVrl1dPTH8nMGzJjdPAmdcNcvE+0tyWIoX3mzndo3gVkY8AHv+s1 jebF+UfZF4hB3xEHH1I4wq5oAgVwQQ+bKt/tSfL/kDomS8BIqAzHEUS+tikLDX3iLOsm BdVoX70VZ2DcS3w+WCZUfKYktDhL8Vn11CLCcLsM0iO96mMQELzcvpZzBWU6tgc//J4t +6EaCn4LWR6uZCx4+r+lqqsvFZLComALojEN3jw+tEGVBaC/6nQitsN+XAqe4UJD3yny GK1A== X-Forwarded-Encrypted: i=1; AJvYcCWSmthW0Dw+ov3meKBf4JEXbZyBbqY0QFQxGS/HBLOF74hHS1NOXBLVi4jcI6f8KNteDXtayDKfsqMhjw==@vger.kernel.org X-Gm-Message-State: AOJu0YwT6yv6jL07doiQhbHww3wdFC2MKEOLKkS+39YimnULcForFIVR jP932oiYCt8CFHvquZCcsVhr7IU7Nuo1Wz6g1t1Cm+kATiXBKaqZAb9KlrdYon0sIdE= X-Gm-Gg: AZuq6aK2MnWve19XXei4mo9LJrDlniDyh3bgQYwY3nR7r28ETHNqzcKKVV2zTZEYWED lPkQxOD7JJcSSjr9hEs0QeXBmpLqGkE7q/sH4cQQRyYLkH2ljv/Pmmx3iw2pLwRrql5pieD4zth CWe7vyCxT+yAjCw60xTLnf8Eg2F43/dLtLSmIYx8wsQG3vCXw6z4VPROWEj9fDRS74xCwhdUIC/ Syaf5MTk8TcZnSm1FIt/Unh0MhBrqPzDqeAIW/qHPO0/f9PTCxoHIogUMJsjTyw7YmDx1LPFytI Y10I5Tw5yq+w7hYVZeW6VB25oGl+5qshZiFLOvpukTZVUtF/Qiuh6adxVjVuMEDxmRIK1xbWIOi PQzk61lfiHQvUh7y/uc+1iZeU0hL+yIOBwsSdeBlUYwkKF5f9lvqsdfwz6h+zPKEvGObsii7Vrj /lVfc4plwNLUiNUzseZ2Av2WmjMuftYC9APyMctlBMFsxwly5pITHlKGWc+of9Wj0Ol0w= 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: linux-media@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: <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