Re: [PATCH v4 08/14] iommufd/viommu: Add vdev_to_dev helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 21, 2024 at 05:20:17PM -0700, Nicolin Chen wrote:
> +/* Caller should xa_lock(&viommu->vdevs) to protect the return value */
> +struct device *vdev_to_dev(struct iommufd_vdevice *vdev)
> +{
> +       return vdev ? vdev->idev->dev : NULL;
> +}
> +EXPORT_SYMBOL_NS_GPL(vdev_to_dev, IOMMUFD);

Changing to not exposing the iommufd_vdevice structure, I reworked
this helper to a vIOMMU-based one:

+/* Caller should xa_lock(&viommu->vdevs) to protect the return value */
+struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
+                                      unsigned long vdev_id)
+{
+       struct iommufd_vdevice *vdev;
+
+       lockdep_is_held(&viommu->vdevs.xa_lock);
+
+       vdev = xa_load(&viommu->vdevs, vdev_id);
+       return vdev ? vdev->idev->dev : NULL;
+}
+EXPORT_SYMBOL_NS_GPL(iommufd_viommu_find_dev, IOMMUFD);

Nicolin




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux