amd-iommu fixes for 2.6.31
cover amd-iommu fixes for 2.6.31
This small patchset contain the fixes for the AMD IOMMU driver in the Linux kernel I have queued up for 2.6.31. Please review.
diffstat:
arch/x86/kernel/amd_iommu.c | 6 +++++- arch/x86/kernel/amd_iommu_init.c | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
shortlog:
Chris Wright (1):
amd iommu: properly detach from protection domain on ->remove
Joerg Roedel (1):
amd-iommu: make sure only ivmd entries are parsed
Neil Turton (2):
amd-iommu: fix an off-by-one error in the AMD IOMMU driver.
amd-iommu: fix the handling of device aliases in the AMD IOMMU driver.
PATCH 1/4 amd-iommu: fix an off-by-one error in the AMD IOMMU driver.
From: Neil Turton <[email protected]>
[ impact: bugfix ]
The variable amd_iommu_last_bdf holds the maximum bdf of any device controlled by an IOMMU, so the number of device entries needed is amd_iommu_last_bdf+1. The function tbl_size used amd_iommu_last_bdf instead. This would be a problem if the last device were a large enough power of 2.
--- arch/x86/kernel/amd_iommu_init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/amd_iommu_init.c +1 -1
@@ -175,7 +175,7 @@ static inline void update_last_devid(u16 devid)static inline unsigned long tbl_size (int entry_size) {unsigned shift =PAGE_SHIFT + -get_order (amd_iommu_last_bdf * entry_size); +get_order (((int )amd_iommu_last_bdf +1 ) * entry_size);return 1UL << shift; }
Signature · 1 line
1.6.3.1
PATCH 2/4 amd-iommu: fix the handling of device aliases in the AMD IOMMU driver.
In reply to Joerg RoedelFrom: Neil Turton <[email protected]>
[ impact: set flags for the right req-id in the device table ]
The devid parameter to set_dev_entry_from_acpi is the requester ID rather than the device ID since it is used to index the IOMMU device table. The handling of IVHD_DEV_ALIAS used to pass the device ID. This patch fixes it to pass the requester ID.
--- arch/x86/kernel/amd_iommu_init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/amd_iommu_init.c +1 -1
@@ -618,7 +618,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,case IVHD_DEV_ALIAS : devid = e->devid; devid_to = e->ext >>8 ; -set_dev_entry_from_acpi (iommu, devid, e->flags,0 ); +set_dev_entry_from_acpi (iommu, devid_to, e->flags,0 ); amd_iommu_alias_table[devid] = devid_to;break ;case IVHD_DEV_ALIAS_RANGE :
Signature · 1 line
1.6.3.1
PATCH 3/4 amd-iommu: make sure only ivmd entries are parsed
In reply to Joerg Roedel[ impact: protect against broken ivrs acpi table ]
The bug never triggered. But it should be fixed to protect against broken ACPI tables in the future.
--- arch/x86/kernel/amd_iommu_init.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kernel/amd_iommu_init.c +2 -0
@@ -906,6 +906,8 @@ static int __init init_unity_map_range(struct ivmd_header *m)switch (m->type) {default : +kfree (e); +return 0 ;case ACPI_IVMD_TYPE : e->devid_start = e->devid_end = m->devid;break ;
Signature · 1 line
1.6.3.1
PATCH 4/4 amd iommu: properly detach from protection domain on ->remove
In reply to Joerg RoedelFrom: Chris Wright <[email protected]>
[ impact: bugfix ]
Some drivers may use the dma api during ->remove which will cause a protection domain to get reattached to a device. Delay the detach until after the driver is completely unbound.
[ joro: added a little merge helper ]
--- arch/x86/kernel/amd_iommu.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
arch/x86/kernel/amd_iommu.c +5 -1
@@ -57,6 +57,10 @@ static int dma_ops_unity_map(struct dma_ops_domain *dma_dom,static struct dma_ops_domain *find_protection_domain (u16 devid); +#ifndef BUS_NOTIFY_UNBOUND_DRIVER +#define BUS_NOTIFY_UNBOUND_DRIVER 0x0005 +#endif +#ifdef CONFIG_AMD_IOMMU_STATS /*
@@ -1012,7 +1016,7 @@ static int device_change_notifier(struct notifier_block *nb,printk (KERN_INFO "AMD IOMMU: Using protection domain %d for " "device %s\n" , dma_domain->domain.id,dev_name (dev));break ; -case BUS_NOTIFY_UNBIND_DRIVER : +case BUS_NOTIFY_UNBOUND_DRIVER :if (!domain) goto out;detach_device (domain, devid);
Signature · 1 line
1.6.3.1