Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'iommu-fixes-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux

Pull iommu fix from Joerg Roedel:

- core: skip PASID validation for devices without PASID support

* tag 'iommu-fixes-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux:
iommu: Skip PASID validation for devices without PASID capability

+28 -15
+28 -15
drivers/iommu/iommu.c
··· 3366 3366 int ret; 3367 3367 3368 3368 for_each_group_device(group, device) { 3369 - ret = domain->ops->set_dev_pasid(domain, device->dev, 3370 - pasid, old); 3371 - if (ret) 3372 - goto err_revert; 3369 + if (device->dev->iommu->max_pasids > 0) { 3370 + ret = domain->ops->set_dev_pasid(domain, device->dev, 3371 + pasid, old); 3372 + if (ret) 3373 + goto err_revert; 3374 + } 3373 3375 } 3374 3376 3375 3377 return 0; ··· 3381 3379 for_each_group_device(group, device) { 3382 3380 if (device == last_gdev) 3383 3381 break; 3384 - /* 3385 - * If no old domain, undo the succeeded devices/pasid. 3386 - * Otherwise, rollback the succeeded devices/pasid to the old 3387 - * domain. And it is a driver bug to fail attaching with a 3388 - * previously good domain. 3389 - */ 3390 - if (!old || WARN_ON(old->ops->set_dev_pasid(old, device->dev, 3382 + if (device->dev->iommu->max_pasids > 0) { 3383 + /* 3384 + * If no old domain, undo the succeeded devices/pasid. 3385 + * Otherwise, rollback the succeeded devices/pasid to 3386 + * the old domain. And it is a driver bug to fail 3387 + * attaching with a previously good domain. 3388 + */ 3389 + if (!old || 3390 + WARN_ON(old->ops->set_dev_pasid(old, device->dev, 3391 3391 pasid, domain))) 3392 - iommu_remove_dev_pasid(device->dev, pasid, domain); 3392 + iommu_remove_dev_pasid(device->dev, pasid, domain); 3393 + } 3393 3394 } 3394 3395 return ret; 3395 3396 } ··· 3403 3398 { 3404 3399 struct group_device *device; 3405 3400 3406 - for_each_group_device(group, device) 3407 - iommu_remove_dev_pasid(device->dev, pasid, domain); 3401 + for_each_group_device(group, device) { 3402 + if (device->dev->iommu->max_pasids > 0) 3403 + iommu_remove_dev_pasid(device->dev, pasid, domain); 3404 + } 3408 3405 } 3409 3406 3410 3407 /* ··· 3447 3440 3448 3441 mutex_lock(&group->mutex); 3449 3442 for_each_group_device(group, device) { 3450 - if (pasid >= device->dev->iommu->max_pasids) { 3443 + /* 3444 + * Skip PASID validation for devices without PASID support 3445 + * (max_pasids = 0). These devices cannot issue transactions 3446 + * with PASID, so they don't affect group's PASID usage. 3447 + */ 3448 + if ((device->dev->iommu->max_pasids > 0) && 3449 + (pasid >= device->dev->iommu->max_pasids)) { 3451 3450 ret = -EINVAL; 3452 3451 goto out_unlock; 3453 3452 }