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 47595233D9C for ; Wed, 6 Aug 2025 22:02:10 +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-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-ESL4ZFPiMAmKgCZXn3Yp2A-1; Wed, 06 Aug 2025 18:02:09 -0400 X-MC-Unique: ESL4ZFPiMAmKgCZXn3Yp2A-1 X-Mimecast-MFC-AGG-ID: ESL4ZFPiMAmKgCZXn3Yp2A_1754517728 Received: by mail-il1-f200.google.com with SMTP id e9e14a558f8ab-3e51bf0a924so898915ab.1 for ; Wed, 06 Aug 2025 15:02:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754517728; x=1755122528; 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=cl1PVQaJFs7mX7ci7qLowdduw1GZvDk1mton24nWIJIudLLlWqTg80XkUe39WmVxjM kRma4pthZz4/4386aKhWTYLgpQv1wQ7oDEG6tgRmABFBQeqeKaEvYDvvCpixaqQxhKMd sjrp+OwhKO6WOqWSgUvxcGRuy1UxXC4TWh1GuajTaAOes/0n4NQQ0zTONZr+Rjw6LL1T t/+Yz/c5AOdoz1LDpe+uuSQe0O664AHTy0ppASBnFMEx3XT7lFUZqXUXiF2d4N48u5f+ Q5LGipg9U8LP8G6S0VVCHXbN5c3e3YAoXmkMDbzpoO5vohxJolCTTqisbamGaLL65H18 J/eA== X-Forwarded-Encrypted: i=1; AJvYcCX/1G82q2GUZnwO1AxLKnLCXZsubcatThW69kSpOBXGvqFQXpIbzZyZ1Yb0VV1wkJYT5BL9irLk5C6xmw==@vger.kernel.org X-Gm-Message-State: AOJu0YwD2AavX+i+MekPHZhaIHzps6mJzYXx3SuPiaeTdUyeLEHRFFla tRwvCferNSwMmNQj4QLwO0kDD32TIdM0Z8DoyuD2XG7LFabAUGc54QL5hQkfgJ37UEu3oWMRGL2 pdw5sPOMZIpbIPndIy8IwiAMsWSMCG1z0soNavnf1R0AGoPgOrCBghI0yuqzbheKo X-Gm-Gg: ASbGncuvMGcf9BaUhhXQFcG2V4iJemoi2d0IgOMFCm/zjzxWOiQ9RahtA/RwA0Tz6O2 JiWiBrrbwtUCX9eDvujlDDWY+q0vpb4O5dcXfQ8jwXSp4nmHHWFu/SDJuWHRSHMyrsqZhxSVXbl uUsT65QKvGsvYeK/f+46KHSF+/NqhmrY4gjMYJI2Aa6eLOz3euA0duNHKHYEEA3l6hlNqWhQsL/ Gi8IvMSH9v03cUG4KRBn2oIquFVG7Iq75DMM/sKv1igc94RDfGTH1welN2J12WfOjSSmK6/dtEl jq9CKipMy6QKC86ntY3vBNsnlepXIHUv2lOm0GWAkgk= X-Received: by 2002:a05:6e02:3193:b0:3dd:c927:3b4f with SMTP id e9e14a558f8ab-3e51b8854c1mr22433215ab.2.1754517728154; Wed, 06 Aug 2025 15:02:08 -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-block@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 */