From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 B6B96387563 for ; Fri, 12 Jun 2026 09:20:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781256014; cv=none; b=nfEFCFd/hsrUYmZcdcSxP3h/f2Ubt7EKchWUFt7vnDAQZS//6x5T9WdY0Nkfpr4no9ymzdW5m2Wc/na9J9KIJTsn50o0xA3YaTyO5ETeBqAAQuPysADV1EhJgvVXKGQRvZVkTuz07bjtbLhaTfhaC2+bqmY10GIrh+vlNByQenk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781256014; c=relaxed/simple; bh=nK8oSt5EIh86hjy16VZ5ws+ZIcIDCfDkVWMJvoB+yNI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=No524UtH/+bx6VflfkY25+KQ+lSqhcWyDxuLTn10hqj0k5pbkAX7d3r/oaYJt1GG5/Bs09IGpLMrRmJpzWHK/dq5Lta3ptrU+C5sgPdyfJiYRofoRi3Jz65AmNHVJgf04HiYA24Pb7HvlJ3SQNTDskQea3Hmlwn8vhjaEw6t8cQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fRzzMYYL; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fRzzMYYL" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2c0b1a48855so85375ad.0 for ; Fri, 12 Jun 2026 02:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781256010; x=1781860810; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zvPmlCR2+M8z2It1PyWjRPyBRhJXBH/RxmRhWYVyMeM=; b=fRzzMYYLXoLbwa6O4DDeOA1Dd721HBWwlMWYDllZUFJ/PTywZdsB5Nwlzv5k7x2d0R WvHhTKPMyLGoqFR3dXk4MZlKcgQ+ayEvfB5xvC5obxLWlwNHu2z7b0SjDke0/huZR6Dy rACpzpT2wiXVJNFA67ImFhSZr9+neZziK6J2yoh4qRgMtwPT/ZfW3hNtyxHfc/fsRD3g GFcOs2i1hCawvKj3RLmbnBeGgbQr7dOlEft+MKhsSkeo4F880mzkcKN8W80Ip0Lby3e9 4s7LNmv9oz+vhxUaKaLOH7e/ZpmkbxeE0XuEbJaU1jhwkOtaSukQ+7t//wS7/4pyvAFv 1Y6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781256010; x=1781860810; h=in-reply-to: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=zvPmlCR2+M8z2It1PyWjRPyBRhJXBH/RxmRhWYVyMeM=; b=gbriAvh2Ox4k1cVXj6WessIlCLN/pRKN4IbTgMMaQciaMS8iS011TkhZBTT4WSTVEV AZ6eG8lFXK05OYUVIbgbfdzFVUTCtVb2P/Os6wsBf8GPD8PR+P7F7zDUhz4DJbm8WgZq ZdvimMJxwJUQD62IDu5XgCyW4YACWZXs3Lx5zTG8aR0BwTJQLxypaEH7EvfMJBrXjrb2 VqNnlMCKPNs69q1MLub9t6/RkSVffJyBH+zpjIOJzWWowDjUumwRDlEQ+PlUWi1Dywwv DDjANlAO4lCyPlffJ+exzblHZqq+dtwAXzqUSoMbWsj/9ARD3h5HHXkKzNZWkx7oIvs/ 7cRA== X-Forwarded-Encrypted: i=1; AFNElJ+WMjFdSrVOMVBNepY7PqM0tZrXWLCCcztQtXy/wTnykPAXslQAisr8JHIofOwaKEFf7UPZANrMxWCbaoo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0hUhQhYOwCuJnrN+1x0vCyOlYhpEjcrD69GhIlVwZOYW7smCN z2sUOcExdNda6AVLcRS0nQBJdj9Qnf8F6SwQqYrZGcH3rBCLFeA0sXotV1XrzcN2wA== X-Gm-Gg: Acq92OHWi+ANMcTpaDkx/dnyvuFPjXHyg24i/6oTfz85wlboJAst1aNTgsl3FzFT718 c8Ftn9km1/KpHgsTzFwaAdqbfxPzujmi2Ekc066AciAF8eL7Yxj/RuUX9gwxVr5RGLMWLXbiIZb ANsrWfzmb5COhXdRcN+wMhiJuHuCRQMqHTeAs95vhxxaKczoiKq7evWMUIvIaOCDm50NylP0P0k icgvRMeQRa77WBz1pIPw1DgOJM5ATgTrGg17KxqIgbCV9CRrvNhzDqoGckxEydWFYO044WCiZLQ 5E2tq1UeQ6DUrhop8BERDcnrhlAWlQuH/ZH+b8LWLLpkIi/ChmIcm/SwRGTXzyLgthVZ4lhYcSw JIxl4jq9ugyuiMRUyd30dsICeavj5ws/1ib4rbyzaoD6kBu7WWqXlOs4D/kUckBDi56wxOoSAHA x5H2Smay74KGBT3QpPEQXjN9AAZLeDPB3sclJvJWqkvmXHz6b/KGT6XTwn3pXPUXiSHk63iPU= X-Received: by 2002:a17:902:e811:b0:2bf:139c:dcf3 with SMTP id d9443c01a7336-2c405c8817fmr1345405ad.19.1781256009183; Fri, 12 Jun 2026 02:20:09 -0700 (PDT) Received: from google.com (199.255.142.34.bc.googleusercontent.com. [34.142.255.199]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8434afd17f5sm1476657b3a.39.2026.06.12.02.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2026 02:20:08 -0700 (PDT) Date: Fri, 12 Jun 2026 09:20:01 +0000 From: Pranjal Shrivastava To: Matt Evans Cc: Alex Williamson , Leon Romanovsky , Jason Gunthorpe , Alex Mastro , Christian =?iso-8859-1?Q?K=F6nig?= , Bjorn Helgaas , Logan Gunthorpe , Mahmoud Adam , David Matlack , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Sumit Semwal , Kevin Tian , Ankit Agrawal , Alistair Popple , Vivek Kasireddy , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kvm@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v3 3/9] vfio/pci: Add a helper to create a DMABUF for a BAR-map VMA Message-ID: References: <20260610154327.37758-1-matt@ozlabs.org> <20260610154327.37758-4-matt@ozlabs.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260610154327.37758-4-matt@ozlabs.org> On Wed, Jun 10, 2026 at 04:43:17PM +0100, Matt Evans wrote: > This helper, vfio_pci_core_mmap_prep_dmabuf(), creates a single-range > DMABUF for the purpose of mapping a PCI BAR. This is used in a future > commit by VFIO's ordinary mmap() path. > > This function transfers ownership of the VFIO device fd to the > DMABUF, which fput()s when it's released. > > Refactor the existing vfio_pci_core_feature_dma_buf() to split out > export code common to the two paths, VFIO_DEVICE_FEATURE_DMA_BUF and > this new VFIO_BAR mmap(). > > Signed-off-by: Matt Evans > --- > drivers/vfio/pci/vfio_pci_dmabuf.c | 142 +++++++++++++++++++++++------ > drivers/vfio/pci/vfio_pci_priv.h | 5 + > 2 files changed, 117 insertions(+), 30 deletions(-) > [...] > + > + /* > + * Ownership of the DMABUF file transfers to the VMA so that > + * other users can locate the DMABUF via a VA. Ownership of > + * the original VFIO device file being mmap()ed transfers to > + * priv, and is put when the DMABUF is released. This > + * intentionally does not use get_file()/vma_set_file() > + * because the references are already held, and ownership > + * moves. > + */ > + priv->vfile = vma->vm_file; > + vma->vm_file = priv->dmabuf->file; > + vma->vm_private_data = priv; I appreciate this comment. Thanks for being clear! Reviewed-by: Pranjal Shrivastava Thanks, Praan