Skip to content

Commit 17fae1c

Browse files
committed
Merge tag 'iommu-fixes-v3.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU fixes from Joerg Roedel: "The patches fix several issues in the AMD IOMMU driver, the NVidia SMMU driver, and the DMA debug code. The most important fix for the AMD IOMMU solves a problem with SR-IOV devices where virtual functions did not work with IOMMU enabled. The NVidia SMMU patch fixes a possible sleep while spin-lock situation (queued the small fix for v3.5, a better but more intrusive fix is coming for v3.6). The DMA debug patches fix a possible data corruption issue due to bool vs u32 usage." * tag 'iommu-fixes-v3.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/amd: fix type bug in flush code dma-debug: debugfs_create_bool() takes a u32 pointer iommu/tegra: smmu: Fix unsleepable memory allocation iommu/amd: Initialize dma_ops for hotplug and sriov devices iommu/amd: Fix missing iommu_shutdown initialization in passthrough mode
2 parents 8c84bf4 + 3775d48 commit 17fae1c

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static struct iommu_ops amd_iommu_ops;
8383
static ATOMIC_NOTIFIER_HEAD(ppr_notifier);
8484
int amd_iommu_max_glx_val = -1;
8585

86+
static struct dma_map_ops amd_iommu_dma_ops;
87+
8688
/*
8789
* general struct to manage commands send to an IOMMU
8890
*/
@@ -402,7 +404,7 @@ static void amd_iommu_stats_init(void)
402404
return;
403405

404406
de_fflush = debugfs_create_bool("fullflush", 0444, stats_dir,
405-
(u32 *)&amd_iommu_unmap_flush);
407+
&amd_iommu_unmap_flush);
406408

407409
amd_iommu_stats_add(&compl_wait);
408410
amd_iommu_stats_add(&cnt_map_single);
@@ -2267,6 +2269,13 @@ static int device_change_notifier(struct notifier_block *nb,
22672269
list_add_tail(&dma_domain->list, &iommu_pd_list);
22682270
spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
22692271

2272+
dev_data = get_dev_data(dev);
2273+
2274+
if (!dev_data->passthrough)
2275+
dev->archdata.dma_ops = &amd_iommu_dma_ops;
2276+
else
2277+
dev->archdata.dma_ops = &nommu_dma_ops;
2278+
22702279
break;
22712280
case BUS_NOTIFY_DEL_DEVICE:
22722281

drivers/iommu/amd_iommu_init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
129129
to handle */
130130
LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
131131
we find in ACPI */
132-
bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
132+
u32 amd_iommu_unmap_flush; /* if true, flush on every unmap */
133133

134134
LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
135135
system */
@@ -1641,6 +1641,8 @@ static int __init amd_iommu_init(void)
16411641

16421642
amd_iommu_init_api();
16431643

1644+
x86_platform.iommu_shutdown = disable_iommus;
1645+
16441646
if (iommu_pass_through)
16451647
goto out;
16461648

@@ -1649,8 +1651,6 @@ static int __init amd_iommu_init(void)
16491651
else
16501652
printk(KERN_INFO "AMD-Vi: Lazy IO/TLB flushing enabled\n");
16511653

1652-
x86_platform.iommu_shutdown = disable_iommus;
1653-
16541654
out:
16551655
return ret;
16561656

drivers/iommu/amd_iommu_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ extern unsigned long *amd_iommu_pd_alloc_bitmap;
652652
* If true, the addresses will be flushed on unmap time, not when
653653
* they are reused
654654
*/
655-
extern bool amd_iommu_unmap_flush;
655+
extern u32 amd_iommu_unmap_flush;
656656

657657
/* Smallest number of PASIDs supported by any IOMMU in the system */
658658
extern u32 amd_iommu_max_pasids;

drivers/iommu/tegra-smmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ static int alloc_pdir(struct smmu_as *as)
550550
return 0;
551551

552552
as->pte_count = devm_kzalloc(smmu->dev,
553-
sizeof(as->pte_count[0]) * SMMU_PDIR_COUNT, GFP_KERNEL);
553+
sizeof(as->pte_count[0]) * SMMU_PDIR_COUNT, GFP_ATOMIC);
554554
if (!as->pte_count) {
555555
dev_err(smmu->dev,
556556
"failed to allocate smmu_device PTE cunters\n");
557557
return -ENOMEM;
558558
}
559-
as->pdir_page = alloc_page(GFP_KERNEL | __GFP_DMA);
559+
as->pdir_page = alloc_page(GFP_ATOMIC | __GFP_DMA);
560560
if (!as->pdir_page) {
561561
dev_err(smmu->dev,
562562
"failed to allocate smmu_device page directory\n");

lib/dma-debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static LIST_HEAD(free_entries);
7878
static DEFINE_SPINLOCK(free_entries_lock);
7979

8080
/* Global disable flag - will be set in case of an error */
81-
static bool global_disable __read_mostly;
81+
static u32 global_disable __read_mostly;
8282

8383
/* Global error count */
8484
static u32 error_count;
@@ -657,7 +657,7 @@ static int dma_debug_fs_init(void)
657657

658658
global_disable_dent = debugfs_create_bool("disabled", 0444,
659659
dma_debug_dent,
660-
(u32 *)&global_disable);
660+
&global_disable);
661661
if (!global_disable_dent)
662662
goto out_err;
663663

0 commit comments

Comments
 (0)