Skip to content

Commit 1d87cff

Browse files
author
Ingo Molnar
committed
Merge branch 'iommu/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu into x86/urgent
2 parents 0515475 + 342688f commit 1d87cff

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

‎arch/x86/include/asm/amd_iommu.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
3131
extern void amd_iommu_flush_all_domains(void);
3232
extern void amd_iommu_flush_all_devices(void);
3333
extern void amd_iommu_shutdown(void);
34+
extern void amd_iommu_apply_erratum_63(u16 devid);
3435
#else
3536
static inline int amd_iommu_init(void) { return -ENODEV; }
3637
static inline void amd_iommu_detect(void) { }

‎arch/x86/kernel/amd_iommu.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,8 @@ static void __detach_device(struct protection_domain *domain, u16 devid)
12201220
amd_iommu_dev_table[devid].data[1] = 0;
12211221
amd_iommu_dev_table[devid].data[2] = 0;
12221222

1223+
amd_iommu_apply_erratum_63(devid);
1224+
12231225
/* decrease reference counter */
12241226
domain->dev_cnt -= 1;
12251227

‎arch/x86/kernel/amd_iommu_init.c‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void iommu_feature_enable(struct amd_iommu *iommu, u8 bit)
240240
writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET);
241241
}
242242

243-
static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
243+
static void iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
244244
{
245245
u32 ctrl;
246246

@@ -519,6 +519,26 @@ static void set_dev_entry_bit(u16 devid, u8 bit)
519519
amd_iommu_dev_table[devid].data[i] |= (1 << _bit);
520520
}
521521

522+
static int get_dev_entry_bit(u16 devid, u8 bit)
523+
{
524+
int i = (bit >> 5) & 0x07;
525+
int _bit = bit & 0x1f;
526+
527+
return (amd_iommu_dev_table[devid].data[i] & (1 << _bit)) >> _bit;
528+
}
529+
530+
531+
void amd_iommu_apply_erratum_63(u16 devid)
532+
{
533+
int sysmgt;
534+
535+
sysmgt = get_dev_entry_bit(devid, DEV_ENTRY_SYSMGT1) |
536+
(get_dev_entry_bit(devid, DEV_ENTRY_SYSMGT2) << 1);
537+
538+
if (sysmgt == 0x01)
539+
set_dev_entry_bit(devid, DEV_ENTRY_IW);
540+
}
541+
522542
/* Writes the specific IOMMU for a device into the rlookup table */
523543
static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
524544
{
@@ -547,6 +567,8 @@ static void __init set_dev_entry_from_acpi(struct amd_iommu *iommu,
547567
if (flags & ACPI_DEVFLAG_LINT1)
548568
set_dev_entry_bit(devid, DEV_ENTRY_LINT1_PASS);
549569

570+
amd_iommu_apply_erratum_63(devid);
571+
550572
set_iommu_for_device(iommu, devid);
551573
}
552574

‎lib/dma-debug.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,11 @@ static void check_unmap(struct dma_debug_entry *ref)
819819
err_printk(ref->dev, entry, "DMA-API: device driver frees "
820820
"DMA memory with different CPU address "
821821
"[device address=0x%016llx] [size=%llu bytes] "
822-
"[cpu alloc address=%p] [cpu free address=%p]",
822+
"[cpu alloc address=0x%016llx] "
823+
"[cpu free address=0x%016llx]",
823824
ref->dev_addr, ref->size,
824-
(void *)entry->paddr, (void *)ref->paddr);
825+
(unsigned long long)entry->paddr,
826+
(unsigned long long)ref->paddr);
825827
}
826828

827829
if (ref->sg_call_ents && ref->type == dma_debug_sg &&

0 commit comments

Comments
 (0)