mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
iommu/s390: Tolerate repeat attach_dev calls
Since commit 0286300e60
("iommu: iommu_group_claim_dma_owner() must
always assign a domain") s390-iommu will get called to allocate multiple
unmanaged iommu domains for a vfio-pci device -- however the current
s390-iommu logic tolerates only one. Recognize that multiple domains can
be allocated and handle switching between DMA or different iommu domain
tables during attach_dev.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20220519182929.581898-1-mjrosato@linux.ibm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
0286300e60
commit
fa7e9ecc5e
1 changed files with 12 additions and 3 deletions
|
@ -99,7 +99,7 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,
|
||||||
if (!domain_device)
|
if (!domain_device)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (zdev->dma_table) {
|
if (zdev->dma_table && !zdev->s390_domain) {
|
||||||
cc = zpci_dma_exit_device(zdev);
|
cc = zpci_dma_exit_device(zdev);
|
||||||
if (cc) {
|
if (cc) {
|
||||||
rc = -EIO;
|
rc = -EIO;
|
||||||
|
@ -107,6 +107,9 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zdev->s390_domain)
|
||||||
|
zpci_unregister_ioat(zdev, 0);
|
||||||
|
|
||||||
zdev->dma_table = s390_domain->dma_table;
|
zdev->dma_table = s390_domain->dma_table;
|
||||||
cc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
|
cc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
|
||||||
virt_to_phys(zdev->dma_table));
|
virt_to_phys(zdev->dma_table));
|
||||||
|
@ -136,7 +139,13 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_restore:
|
out_restore:
|
||||||
zpci_dma_init_device(zdev);
|
if (!zdev->s390_domain) {
|
||||||
|
zpci_dma_init_device(zdev);
|
||||||
|
} else {
|
||||||
|
zdev->dma_table = zdev->s390_domain->dma_table;
|
||||||
|
zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
|
||||||
|
virt_to_phys(zdev->dma_table));
|
||||||
|
}
|
||||||
out_free:
|
out_free:
|
||||||
kfree(domain_device);
|
kfree(domain_device);
|
||||||
|
|
||||||
|
@ -167,7 +176,7 @@ static void s390_iommu_detach_device(struct iommu_domain *domain,
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&s390_domain->list_lock, flags);
|
spin_unlock_irqrestore(&s390_domain->list_lock, flags);
|
||||||
|
|
||||||
if (found) {
|
if (found && (zdev->s390_domain == s390_domain)) {
|
||||||
zdev->s390_domain = NULL;
|
zdev->s390_domain = NULL;
|
||||||
zpci_unregister_ioat(zdev, 0);
|
zpci_unregister_ioat(zdev, 0);
|
||||||
zpci_dma_init_device(zdev);
|
zpci_dma_init_device(zdev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue