File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 21
21
#include <linux/idr.h>
22
22
#include <linux/err.h>
23
23
#include <linux/pci.h>
24
+ #include <linux/pci-ats.h>
24
25
#include <linux/bitops.h>
25
26
#include <linux/platform_device.h>
26
27
#include <linux/property.h>
@@ -278,6 +279,24 @@ static void dev_iommu_free(struct device *dev)
278
279
kfree (param );
279
280
}
280
281
282
+ static u32 dev_iommu_get_max_pasids (struct device * dev )
283
+ {
284
+ u32 max_pasids = 0 , bits = 0 ;
285
+ int ret ;
286
+
287
+ if (dev_is_pci (dev )) {
288
+ ret = pci_max_pasids (to_pci_dev (dev ));
289
+ if (ret > 0 )
290
+ max_pasids = ret ;
291
+ } else {
292
+ ret = device_property_read_u32 (dev , "pasid-num-bits" , & bits );
293
+ if (!ret )
294
+ max_pasids = 1UL << bits ;
295
+ }
296
+
297
+ return min_t (u32 , max_pasids , dev -> iommu -> iommu_dev -> max_pasids );
298
+ }
299
+
281
300
static int __iommu_probe_device (struct device * dev , struct list_head * group_list )
282
301
{
283
302
const struct iommu_ops * ops = dev -> bus -> iommu_ops ;
@@ -303,6 +322,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
303
322
}
304
323
305
324
dev -> iommu -> iommu_dev = iommu_dev ;
325
+ dev -> iommu -> max_pasids = dev_iommu_get_max_pasids (dev );
306
326
307
327
group = iommu_group_get_for_dev (dev );
308
328
if (IS_ERR (group )) {
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ struct iommu_fault_param {
368
368
* @fwspec: IOMMU fwspec data
369
369
* @iommu_dev: IOMMU device this device is linked to
370
370
* @priv: IOMMU Driver private data
371
+ * @max_pasids: number of PASIDs this device can consume
371
372
*
372
373
* TODO: migrate other per device data pointers under iommu_dev_data, e.g.
373
374
* struct iommu_group *iommu_group;
@@ -379,6 +380,7 @@ struct dev_iommu {
379
380
struct iommu_fwspec * fwspec ;
380
381
struct iommu_device * iommu_dev ;
381
382
void * priv ;
383
+ u32 max_pasids ;
382
384
};
383
385
384
386
int iommu_device_register (struct iommu_device * iommu ,
You can’t perform that action at this time.
0 commit comments