From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Liu, Yi L" <yi.l.liu@intel.com>,
Alex Williamson <alex.williamson@redhat.com>
Cc: baolu.lu@linux.intel.com, "jgg@nvidia.com" <jgg@nvidia.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"lulu@redhat.com" <lulu@redhat.com>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"intel-gvt-dev@lists.freedesktop.org"
<intel-gvt-dev@lists.freedesktop.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"Hao, Xudong" <xudong.hao@intel.com>,
"Zhao, Yan Y" <yan.y.zhao@intel.com>,
"Xu, Terrence" <terrence.xu@intel.com>,
"Jiang, Yanting" <yanting.jiang@intel.com>,
"Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
"clegoate@redhat.com" <clegoate@redhat.com>
Subject: Re: [PATCH v6 09/10] vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev
Date: Fri, 26 May 2023 10:04:27 +0800 [thread overview]
Message-ID: <355a9f1e-64e6-d785-5a22-027b708b4935@linux.intel.com> (raw)
In-Reply-To: <DS0PR11MB752935203F87D69D4468B890C3469@DS0PR11MB7529.namprd11.prod.outlook.com>
On 5/25/23 9:02 PM, Liu, Yi L wrote:
>> It's possible that requirement
>> might be relaxed in the new DMA ownership model, but as it is right
>> now, the code enforces that requirement and any new discussion about
>> what makes hot-reset available should note both the ownership and
>> dev_set requirement. Thanks,
> I think your point is that if an iommufd_ctx has acquired DMA ownerhisp
> of an iommu_group, it means the device is owned. And it should not
> matter whether all the devices in the iommu_group is present in the
> dev_set. It is allowed that some devices are bound to pci-stub or
> pcieport driver. Is it?
>
> Actually I have a doubt on it. IIUC, the above requirement on dev_set
> is to ensure the reset to the devices are protected by the dev_set->lock.
> So that either the reset issued by driver itself or a hot reset request
> from user, there is no race. But if a device is not in the dev_set, then
> hot reset request from user might race with the bound driver. DMA ownership
> only guarantees the drivers won't handle DMA via DMA API which would have
> conflict with DMA mappings from user. I'm not sure if it is able to
> guarantee reset is exclusive as well. I see pci-stub and pcieport driver
> are the only two drivers that set the driver_managed_dma flag besides the
> vfio drivers. pci-stub may be fine. not sure about pcieport driver.
commit c7d469849747 ("PCI: portdrv: Set driver_managed_dma") described
the criteria of adding driver_managed_dma to the pcieport driver.
"
We achieve this by setting ".driver_managed_dma = true" in pci_driver
structure. It is safe because the portdrv driver meets below criteria:
- This driver doesn't use DMA, as you can't find any related calls like
pci_set_master() or any kernel DMA API (dma_map_*() and etc.).
- It doesn't use MMIO as you can't find ioremap() or similar calls. It's
tolerant to userspace possibly also touching the same MMIO registers
via P2P DMA access.
"
pci_rest_device() definitely shouldn't be done by the kernel drivers
that have driver_managed_dma set.
>
> # line filename / context / line
> 1 39 drivers/pci/pci-stub.c <<GLOBAL>>
> .driver_managed_dma = true,
> 2 796 drivers/pci/pcie/portdrv.c <<GLOBAL>>
> .driver_managed_dma = true,
> 3 607 drivers/vfio/fsl-mc/vfio_fsl_mc.c <<GLOBAL>>
> .driver_managed_dma = true,
> 4 1459 drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c <<GLOBAL>>
> .driver_managed_dma = true,
> 5 1374 drivers/vfio/pci/mlx5/main.c <<GLOBAL>>
> .driver_managed_dma = true,
> 6 203 drivers/vfio/pci/vfio_pci.c <<GLOBAL>>
> .driver_managed_dma = true,
> 7 139 drivers/vfio/platform/vfio_amba.c <<GLOBAL>>
> .driver_managed_dma = true,
> 8 120 drivers/vfio/platform/vfio_platform.c <<GLOBAL>>
> .driver_managed_dma = true,
>
> Anyhow, I think this is not a must so far. is it? Even doable, it shall
> be done in the future. 😄
Perhaps we can take it in this way: it's a bug if any driver sets its
driver_managed_dma but still resets the hardware during it's life cycle?
Best regards,
baolu
next prev parent reply other threads:[~2023-05-26 2:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-22 11:57 [PATCH v6 00/10] Enhance vfio PCI hot reset for vfio cdev device Yi Liu
2023-05-22 11:57 ` [PATCH v6 01/10] vfio-iommufd: Create iommufd_access for noiommu devices Yi Liu
2023-05-22 11:57 ` [PATCH v6 02/10] vfio/pci: Update comment around group_fd get in vfio_pci_ioctl_pci_hot_reset() Yi Liu
2023-05-22 11:57 ` [PATCH v6 03/10] vfio/pci: Move the existing hot reset logic to be a helper Yi Liu
2023-05-22 11:57 ` [PATCH v6 04/10] iommufd: Reserve all negative IDs in the iommufd xarray Yi Liu
2023-05-22 11:57 ` [PATCH v6 05/10] iommufd: Add iommufd_ctx_has_group() Yi Liu
2023-05-22 11:57 ` [PATCH v6 06/10] iommufd: Add helper to retrieve iommufd_ctx and devid Yi Liu
2023-05-22 11:57 ` [PATCH v6 07/10] vfio: Mark cdev usage in vfio_device Yi Liu
2023-05-22 11:57 ` [PATCH v6 08/10] vfio: Add helper to search vfio_device in a dev_set Yi Liu
2023-05-22 11:57 ` [PATCH v6 09/10] vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev Yi Liu
2023-05-24 19:56 ` Alex Williamson
2023-05-25 13:02 ` Liu, Yi L
2023-05-26 2:04 ` Baolu Lu [this message]
[not found] ` <ZHeZPPo/MWXV1L9Q@nvidia.com>
2023-06-01 6:06 ` Liu, Yi L
2023-06-01 14:24 ` Alex Williamson
2023-05-22 11:57 ` [PATCH v6 10/10] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET Yi Liu
2023-05-24 20:19 ` Alex Williamson
2023-05-30 4:23 ` Liu, Yi L
2023-05-31 17:21 ` Alex Williamson
2023-06-01 5:55 ` Liu, Yi L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=355a9f1e-64e6-d785-5a22-027b708b4935@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=clegoate@redhat.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=terrence.xu@intel.com \
--cc=xudong.hao@intel.com \
--cc=yan.y.zhao@intel.com \
--cc=yanting.jiang@intel.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@linux.intel.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox