iommufd.c (31014aef9e4cc0326b5df0c3149e757a2b490176) | iommufd.c (9048c7341c4df9cae04c154a8b0f556dbe913358) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES 4 */ 5#include <linux/vfio.h> 6#include <linux/iommufd.h> 7 8#include "vfio.h" --- 126 unchanged lines hidden (view full) --- 135 vdev->iommufd_device = NULL; 136} 137EXPORT_SYMBOL_GPL(vfio_iommufd_physical_unbind); 138 139int vfio_iommufd_physical_attach_ioas(struct vfio_device *vdev, u32 *pt_id) 140{ 141 int rc; 142 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES 4 */ 5#include <linux/vfio.h> 6#include <linux/iommufd.h> 7 8#include "vfio.h" --- 126 unchanged lines hidden (view full) --- 135 vdev->iommufd_device = NULL; 136} 137EXPORT_SYMBOL_GPL(vfio_iommufd_physical_unbind); 138 139int vfio_iommufd_physical_attach_ioas(struct vfio_device *vdev, u32 *pt_id) 140{ 141 int rc; 142 |
143 lockdep_assert_held(&vdev->dev_set->lock); 144 145 if (WARN_ON(!vdev->iommufd_device)) 146 return -EINVAL; 147 148 if (vdev->iommufd_attached) 149 return -EBUSY; 150 |
|
143 rc = iommufd_device_attach(vdev->iommufd_device, pt_id); 144 if (rc) 145 return rc; 146 vdev->iommufd_attached = true; 147 return 0; 148} 149EXPORT_SYMBOL_GPL(vfio_iommufd_physical_attach_ioas); 150 | 151 rc = iommufd_device_attach(vdev->iommufd_device, pt_id); 152 if (rc) 153 return rc; 154 vdev->iommufd_attached = true; 155 return 0; 156} 157EXPORT_SYMBOL_GPL(vfio_iommufd_physical_attach_ioas); 158 |
159void vfio_iommufd_physical_detach_ioas(struct vfio_device *vdev) 160{ 161 lockdep_assert_held(&vdev->dev_set->lock); 162 163 if (WARN_ON(!vdev->iommufd_device) || !vdev->iommufd_attached) 164 return; 165 166 iommufd_device_detach(vdev->iommufd_device); 167 vdev->iommufd_attached = false; 168} 169EXPORT_SYMBOL_GPL(vfio_iommufd_physical_detach_ioas); 170 |
|
151/* 152 * The emulated standard ops mean that vfio_device is going to use the 153 * "mdev path" and will call vfio_pin_pages()/vfio_dma_rw(). Drivers using this 154 * ops set should call vfio_register_emulated_iommu_dev(). Drivers that do 155 * not call vfio_pin_pages()/vfio_dma_rw() have no need to provide dma_unmap. 156 */ 157 158static void vfio_emulated_unmap(void *data, unsigned long iova, --- 55 unchanged lines hidden --- | 171/* 172 * The emulated standard ops mean that vfio_device is going to use the 173 * "mdev path" and will call vfio_pin_pages()/vfio_dma_rw(). Drivers using this 174 * ops set should call vfio_register_emulated_iommu_dev(). Drivers that do 175 * not call vfio_pin_pages()/vfio_dma_rw() have no need to provide dma_unmap. 176 */ 177 178static void vfio_emulated_unmap(void *data, unsigned long iova, --- 55 unchanged lines hidden --- |