hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c
....@@ -45,7 +45,7 @@
4545 struct amd_iommu_device_info iommu_info;
4646 int err;
4747
48
- if (!kfd->device_info->needs_iommu_device)
48
+ if (!kfd->use_iommu_v2)
4949 return -ENODEV;
5050
5151 iommu_info.flags = 0;
....@@ -66,20 +66,9 @@
6666 struct amd_iommu_device_info iommu_info;
6767 unsigned int pasid_limit;
6868 int err;
69
- struct kfd_topology_device *top_dev;
7069
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)
7971 return 0;
80
- }
81
-
82
- top_dev->node_props.capability |= HSA_CAP_ATS_PRESENT;
8372
8473 iommu_info.flags = 0;
8574 err = amd_iommu_device_info(kfd->pdev, &iommu_info);
....@@ -124,7 +113,7 @@
124113 struct kfd_process *p = pdd->process;
125114 int err;
126115
127
- if (!dev->device_info->needs_iommu_device || pdd->bound == PDD_BOUND)
116
+ if (!dev->use_iommu_v2 || pdd->bound == PDD_BOUND)
128117 return 0;
129118
130119 if (unlikely(pdd->bound == PDD_BOUND_SUSPENDED)) {
....@@ -154,7 +143,7 @@
154143 }
155144
156145 /* 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)
158147 {
159148 struct kfd_dev *dev = kfd_device_by_pci_dev(pdev);
160149 struct kfd_process *p;
....@@ -172,7 +161,7 @@
172161 if (!p)
173162 return;
174163
175
- pr_debug("Unbinding process %d from IOMMU\n", pasid);
164
+ pr_debug("Unbinding process 0x%x from IOMMU\n", pasid);
176165
177166 mutex_lock(kfd_get_dbgmgr_mutex());
178167
....@@ -200,14 +189,14 @@
200189 }
201190
202191 /* 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)
205194 {
206195 struct kfd_dev *dev;
207196
208197 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,
211200 PCI_SLOT(pdev->devfn),
212201 PCI_FUNC(pdev->devfn),
213202 pasid,
....@@ -247,7 +236,7 @@
247236 err = amd_iommu_bind_pasid(kfd->pdev, p->pasid,
248237 p->lead_thread);
249238 if (err < 0) {
250
- pr_err("Unexpected pasid %d binding failure\n",
239
+ pr_err("Unexpected pasid 0x%x binding failure\n",
251240 p->pasid);
252241 mutex_unlock(&p->mutex);
253242 break;
....@@ -299,7 +288,7 @@
299288 */
300289 void kfd_iommu_suspend(struct kfd_dev *kfd)
301290 {
302
- if (!kfd->device_info->needs_iommu_device)
291
+ if (!kfd->use_iommu_v2)
303292 return;
304293
305294 kfd_unbind_processes_from_device(kfd);
....@@ -319,7 +308,7 @@
319308 unsigned int pasid_limit;
320309 int err;
321310
322
- if (!kfd->device_info->needs_iommu_device)
311
+ if (!kfd->use_iommu_v2)
323312 return 0;
324313
325314 pasid_limit = kfd_get_pasid_limit();