| .. | .. |
|---|
| 45 | 45 | struct amd_iommu_device_info iommu_info; |
|---|
| 46 | 46 | int err; |
|---|
| 47 | 47 | |
|---|
| 48 | | - if (!kfd->device_info->needs_iommu_device) |
|---|
| 48 | + if (!kfd->use_iommu_v2) |
|---|
| 49 | 49 | return -ENODEV; |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | iommu_info.flags = 0; |
|---|
| .. | .. |
|---|
| 66 | 66 | struct amd_iommu_device_info iommu_info; |
|---|
| 67 | 67 | unsigned int pasid_limit; |
|---|
| 68 | 68 | int err; |
|---|
| 69 | | - struct kfd_topology_device *top_dev; |
|---|
| 70 | 69 | |
|---|
| 71 | | - top_dev = kfd_topology_device_by_id(kfd->id); |
|---|
| 72 | | - |
|---|
| 73 | | - /* |
|---|
| 74 | | - * Overwrite ATS capability according to needs_iommu_device to fix |
|---|
| 75 | | - * potential missing corresponding bit in CRAT of BIOS. |
|---|
| 76 | | - */ |
|---|
| 77 | | - if (!kfd->device_info->needs_iommu_device) { |
|---|
| 78 | | - top_dev->node_props.capability &= ~HSA_CAP_ATS_PRESENT; |
|---|
| 70 | + if (!kfd->use_iommu_v2) |
|---|
| 79 | 71 | return 0; |
|---|
| 80 | | - } |
|---|
| 81 | | - |
|---|
| 82 | | - top_dev->node_props.capability |= HSA_CAP_ATS_PRESENT; |
|---|
| 83 | 72 | |
|---|
| 84 | 73 | iommu_info.flags = 0; |
|---|
| 85 | 74 | err = amd_iommu_device_info(kfd->pdev, &iommu_info); |
|---|
| .. | .. |
|---|
| 124 | 113 | struct kfd_process *p = pdd->process; |
|---|
| 125 | 114 | int err; |
|---|
| 126 | 115 | |
|---|
| 127 | | - if (!dev->device_info->needs_iommu_device || pdd->bound == PDD_BOUND) |
|---|
| 116 | + if (!dev->use_iommu_v2 || pdd->bound == PDD_BOUND) |
|---|
| 128 | 117 | return 0; |
|---|
| 129 | 118 | |
|---|
| 130 | 119 | if (unlikely(pdd->bound == PDD_BOUND_SUSPENDED)) { |
|---|
| .. | .. |
|---|
| 154 | 143 | } |
|---|
| 155 | 144 | |
|---|
| 156 | 145 | /* Callback for process shutdown invoked by the IOMMU driver */ |
|---|
| 157 | | -static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, int pasid) |
|---|
| 146 | +static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid) |
|---|
| 158 | 147 | { |
|---|
| 159 | 148 | struct kfd_dev *dev = kfd_device_by_pci_dev(pdev); |
|---|
| 160 | 149 | struct kfd_process *p; |
|---|
| .. | .. |
|---|
| 172 | 161 | if (!p) |
|---|
| 173 | 162 | return; |
|---|
| 174 | 163 | |
|---|
| 175 | | - pr_debug("Unbinding process %d from IOMMU\n", pasid); |
|---|
| 164 | + pr_debug("Unbinding process 0x%x from IOMMU\n", pasid); |
|---|
| 176 | 165 | |
|---|
| 177 | 166 | mutex_lock(kfd_get_dbgmgr_mutex()); |
|---|
| 178 | 167 | |
|---|
| .. | .. |
|---|
| 200 | 189 | } |
|---|
| 201 | 190 | |
|---|
| 202 | 191 | /* This function called by IOMMU driver on PPR failure */ |
|---|
| 203 | | -static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid, |
|---|
| 204 | | - unsigned long address, u16 flags) |
|---|
| 192 | +static int iommu_invalid_ppr_cb(struct pci_dev *pdev, u32 pasid, |
|---|
| 193 | + unsigned long address, u16 flags) |
|---|
| 205 | 194 | { |
|---|
| 206 | 195 | struct kfd_dev *dev; |
|---|
| 207 | 196 | |
|---|
| 208 | 197 | dev_warn_ratelimited(kfd_device, |
|---|
| 209 | | - "Invalid PPR device %x:%x.%x pasid %d address 0x%lX flags 0x%X", |
|---|
| 210 | | - PCI_BUS_NUM(pdev->devfn), |
|---|
| 198 | + "Invalid PPR device %x:%x.%x pasid 0x%x address 0x%lX flags 0x%X", |
|---|
| 199 | + pdev->bus->number, |
|---|
| 211 | 200 | PCI_SLOT(pdev->devfn), |
|---|
| 212 | 201 | PCI_FUNC(pdev->devfn), |
|---|
| 213 | 202 | pasid, |
|---|
| .. | .. |
|---|
| 247 | 236 | err = amd_iommu_bind_pasid(kfd->pdev, p->pasid, |
|---|
| 248 | 237 | p->lead_thread); |
|---|
| 249 | 238 | if (err < 0) { |
|---|
| 250 | | - pr_err("Unexpected pasid %d binding failure\n", |
|---|
| 239 | + pr_err("Unexpected pasid 0x%x binding failure\n", |
|---|
| 251 | 240 | p->pasid); |
|---|
| 252 | 241 | mutex_unlock(&p->mutex); |
|---|
| 253 | 242 | break; |
|---|
| .. | .. |
|---|
| 299 | 288 | */ |
|---|
| 300 | 289 | void kfd_iommu_suspend(struct kfd_dev *kfd) |
|---|
| 301 | 290 | { |
|---|
| 302 | | - if (!kfd->device_info->needs_iommu_device) |
|---|
| 291 | + if (!kfd->use_iommu_v2) |
|---|
| 303 | 292 | return; |
|---|
| 304 | 293 | |
|---|
| 305 | 294 | kfd_unbind_processes_from_device(kfd); |
|---|
| .. | .. |
|---|
| 319 | 308 | unsigned int pasid_limit; |
|---|
| 320 | 309 | int err; |
|---|
| 321 | 310 | |
|---|
| 322 | | - if (!kfd->device_info->needs_iommu_device) |
|---|
| 311 | + if (!kfd->use_iommu_v2) |
|---|
| 323 | 312 | return 0; |
|---|
| 324 | 313 | |
|---|
| 325 | 314 | pasid_limit = kfd_get_pasid_limit(); |
|---|