From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCCA8221299 for ; Wed, 6 Aug 2025 22:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754517733; cv=none; b=j80k1F34XND7daS79q1tJ7bZ/53dzBA3Yabjqj4KJb9s3VbB4Zn4TvZzwJgrLL1EkKnPdRfE7Q7qI59aYQtX8YcJ1mxKF4Rzb1kHIDlKa4uaqvE5BCwTxZPtgPr2PDMqs7US5hlxiRO7Tnl8l5XcRc1CNXma5RBC/s9AzkcR8Us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754517733; c=relaxed/simple; bh=sBGR4NtuEpYLnU8xLpZkN2kUNrTNO6/D2QzCl2EwKDw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g5iGv3vG1WJFzHKKbXmO4+QJw84ZTJdPSt9jY8B27RA6nCmti28hU61vpM/+xLUVx9eTGZRIUWUoBwkJJTYOo5/6TcwtT4552I7wfbmjKIMXrPeX3IKEmTgK/MwfNfT8os7k8aHi3ZBFcgUnEYg7DPJxuHkfF/T8R5dOjy0wdWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CFdqmzkX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CFdqmzkX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754517730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DPKtzeEHbCO/oC/mPOhJydcV6bGZHZZqGISB9ILuO/c=; b=CFdqmzkXwjG7/90VFtMUN12j30HgBWafM3zN1/K36BMDJmGJqaoAWh11AXsNwIt3vtZhgy eCkNPcT7BppW6x84/Vn8r6n4zLedL2r4suT8IWJ0GaOlzgVzWbHJtPTqhu1V7s+CeCLE9J 48+RGb7UcKsexp4IfnPS6250Gte8pxs= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-lp3b8QwSMRWul4JfwaziQA-1; Wed, 06 Aug 2025 18:02:09 -0400 X-MC-Unique: lp3b8QwSMRWul4JfwaziQA-1 X-Mimecast-MFC-AGG-ID: lp3b8QwSMRWul4JfwaziQA_1754517729 Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-3e3fdd9298eso841615ab.3 for ; Wed, 06 Aug 2025 15:02:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754517729; x=1755122529; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DPKtzeEHbCO/oC/mPOhJydcV6bGZHZZqGISB9ILuO/c=; b=JKE9GFSfI4gxhExZxIqQurRqYbDbhb9y/VfR620BrQGlhjCXO9Zf3zj/wpOjfwlTWo fOIyWrEzYduUt4+vuoq6CN7IDLXDWIyW/+3JhQU1++X5YND9tS7v0wIiN6KHLA1kmyEO bRYA5Yu9sxSehWXGK7OH+IR2l3xg62hmsmOt5StNmjCkMhWywhHBGYb3adanPol7AhJS oZyCaMqgDoFCoM3fF0HH6hYExjEgiubaZyJ5/ZeascmYCWgDUcZszaCm//Ror+U5a2ta ICq/ZwwxZfldRtRO+VrCQwXJs7C/Okuu+MO9KxJBAcAgsQ7pPtm6xrBMgA0M9SqvO459 i7qA== X-Forwarded-Encrypted: i=1; AJvYcCU9LoB7et6+YRf4ytMyIKQJdadkL0BuhL/dEISOZs2h14rLHvyuqalj1oQwSpBwXmiR/co6TJ6+xodzUCk=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu8hrJ6//RgazBuPyW2h7sknsfYNfvMMvmbgpOb4O0gvKZlkd0 wzR8Qx46s1fR0vc+vHI2oBI+tYWoT2XqFrQOOc3LX6vsCTQvEnMR0zQ647QovaUmjrv4ioesjSM aVucBULy6jmQDnvmcA6ZvgmWuWSQfsacAM9HqiqpFcuswma56pdNkuu81zy6Vru1NVQ== X-Gm-Gg: ASbGncvfCYXsEW7eXtZYQTZqc9dPn3fB2GS99M9FszQKgfupHA9mNL9bRRopXufa7uj PPPQzIYL4GPlanrP2LztDC35lwXEDHS4lvgzFR0lKU78634gujj7Q4VTupnXYyJ5V+ypw0egKM4 f6u2vShrjNNRQn3hmXRJNUVWl6aIsprAMcbICEZs58r0Xvu59Vjehm9WJMlXiu1nm4NrDQISVZM uqtOEMkkVUTc/QYfUwGE9xO0qkXpzxE8zvyjo63sDJtOB0aEj1dA6x+1/RP2zVekkFUvWQmH3CE mziM6lGxIlmKZ3vkAhSxODZlQTJEbHgB6bBTXjFevTk= X-Received: by 2002:a05:6e02:3193:b0:3dd:c927:3b4f with SMTP id e9e14a558f8ab-3e51b8854c1mr22432975ab.2.1754517727889; Wed, 06 Aug 2025 15:02:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIzdy8eeJry7tYq6oPCO7e2LCNwpZ/0SyAUMoLDbyTlBwk+OaaK/N75sVSFjgffH+CpRQ7JQ== X-Received: by 2002:a05:6e02:3193:b0:3dd:c927:3b4f with SMTP id e9e14a558f8ab-3e51b8854c1mr22432755ab.2.1754517727346; Wed, 06 Aug 2025 15:02:07 -0700 (PDT) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3e40297c389sm63783105ab.2.2025.08.06.15.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Aug 2025 15:02:05 -0700 (PDT) Date: Wed, 6 Aug 2025 16:02:01 -0600 From: Alex Williamson To: Leon Romanovsky Cc: Leon Romanovsky , Jason Gunthorpe , Andrew Morton , Bjorn Helgaas , Christian =?UTF-8?B?S8O2bmln?= , Christoph Hellwig , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, Jens Axboe , Joerg Roedel , kvm@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Logan Gunthorpe , Marek Szyprowski , Robin Murphy , Sumit Semwal , Vivek Kasireddy , Will Deacon Subject: Re: [PATCH v1 08/10] vfio/pci: Enable peer-to-peer DMA transactions by default Message-ID: <20250806160201.2b72e7a0.alex.williamson@redhat.com> In-Reply-To: References: Organization: Red Hat 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-Transfer-Encoding: 7bit On Mon, 4 Aug 2025 16:00:43 +0300 Leon Romanovsky wrote: > From: Leon Romanovsky > > Make sure that all VFIO PCI devices have peer-to-peer capabilities > enables, so we would be able to export their MMIO memory through DMABUF, > > Signed-off-by: Leon Romanovsky > --- > drivers/vfio/pci/vfio_pci_core.c | 4 ++++ > include/linux/vfio_pci_core.h | 1 + > 2 files changed, 5 insertions(+) > > diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c > index 31bdb9110cc0f..df9a32d3deac9 100644 > --- a/drivers/vfio/pci/vfio_pci_core.c > +++ b/drivers/vfio/pci/vfio_pci_core.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #if IS_ENABLED(CONFIG_EEH) > #include > #endif > @@ -2088,6 +2089,9 @@ int vfio_pci_core_init_dev(struct vfio_device *core_vdev) > INIT_LIST_HEAD(&vdev->dummy_resources_list); > INIT_LIST_HEAD(&vdev->ioeventfds_list); > INIT_LIST_HEAD(&vdev->sriov_pfs_item); > + vdev->provider = pci_p2pdma_enable(vdev->pdev); > + if (IS_ERR(vdev->provider)) > + return PTR_ERR(vdev->provider); I think this just made all vfio-pci drivers functionally dependent on CONFIG_PCI_P2PDMA. Seems at best exporting a dma-buf should be restricted if this fails. Thanks, Alex > init_rwsem(&vdev->memory_lock); > xa_init(&vdev->ctx); > > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h > index fbb472dd99b36..b017fae251811 100644 > --- a/include/linux/vfio_pci_core.h > +++ b/include/linux/vfio_pci_core.h > @@ -94,6 +94,7 @@ struct vfio_pci_core_device { > struct vfio_pci_core_device *sriov_pf_core_dev; > struct notifier_block nb; > struct rw_semaphore memory_lock; > + struct p2pdma_provider *provider; > }; > > /* Will be exported for vfio pci drivers usage */