Skip to content

Commit 89e5035

Browse files
committed
Merge tag 'iommu-fixes-v5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu fixes from Joerg Roedel: - Two fixes for the new Apple DART driver to fix a kernel panic and a stale data usage issue - Intel VT-d fix for how PCI device ids are printed * tag 'iommu-fixes-v5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/dart: Clear sid2group entry when a group is freed iommu/vt-d: Drop "0x" prefix from PCI bus & device addresses iommu/dart: Remove iommu_flush_ops
2 parents 4de593f + f0b6368 commit 89e5035

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

drivers/iommu/apple-dart.c

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ struct apple_dart_master_cfg {
183183

184184
static struct platform_driver apple_dart_driver;
185185
static const struct iommu_ops apple_dart_iommu_ops;
186-
static const struct iommu_flush_ops apple_dart_tlb_ops;
187186

188187
static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom)
189188
{
@@ -338,22 +337,6 @@ static void apple_dart_iotlb_sync_map(struct iommu_domain *domain,
338337
apple_dart_domain_flush_tlb(to_dart_domain(domain));
339338
}
340339

341-
static void apple_dart_tlb_flush_all(void *cookie)
342-
{
343-
apple_dart_domain_flush_tlb(cookie);
344-
}
345-
346-
static void apple_dart_tlb_flush_walk(unsigned long iova, size_t size,
347-
size_t granule, void *cookie)
348-
{
349-
apple_dart_domain_flush_tlb(cookie);
350-
}
351-
352-
static const struct iommu_flush_ops apple_dart_tlb_ops = {
353-
.tlb_flush_all = apple_dart_tlb_flush_all,
354-
.tlb_flush_walk = apple_dart_tlb_flush_walk,
355-
};
356-
357340
static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain,
358341
dma_addr_t iova)
359342
{
@@ -435,7 +418,6 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,
435418
.ias = 32,
436419
.oas = 36,
437420
.coherent_walk = 1,
438-
.tlb = &apple_dart_tlb_ops,
439421
.iommu_dev = dart->dev,
440422
};
441423

@@ -661,16 +643,34 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args)
661643
return -EINVAL;
662644
}
663645

646+
static DEFINE_MUTEX(apple_dart_groups_lock);
647+
648+
static void apple_dart_release_group(void *iommu_data)
649+
{
650+
int i, sid;
651+
struct apple_dart_stream_map *stream_map;
652+
struct apple_dart_master_cfg *group_master_cfg = iommu_data;
653+
654+
mutex_lock(&apple_dart_groups_lock);
655+
656+
for_each_stream_map(i, group_master_cfg, stream_map)
657+
for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS)
658+
stream_map->dart->sid2group[sid] = NULL;
659+
660+
kfree(iommu_data);
661+
mutex_unlock(&apple_dart_groups_lock);
662+
}
663+
664664
static struct iommu_group *apple_dart_device_group(struct device *dev)
665665
{
666-
static DEFINE_MUTEX(lock);
667666
int i, sid;
668667
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
669668
struct apple_dart_stream_map *stream_map;
669+
struct apple_dart_master_cfg *group_master_cfg;
670670
struct iommu_group *group = NULL;
671671
struct iommu_group *res = ERR_PTR(-EINVAL);
672672

673-
mutex_lock(&lock);
673+
mutex_lock(&apple_dart_groups_lock);
674674

675675
for_each_stream_map(i, cfg, stream_map) {
676676
for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS) {
@@ -698,14 +698,28 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)
698698
#endif
699699
group = generic_device_group(dev);
700700

701+
res = ERR_PTR(-ENOMEM);
702+
if (!group)
703+
goto out;
704+
705+
group_master_cfg = kzalloc(sizeof(*group_master_cfg), GFP_KERNEL);
706+
if (!group_master_cfg) {
707+
iommu_group_put(group);
708+
goto out;
709+
}
710+
711+
memcpy(group_master_cfg, cfg, sizeof(*group_master_cfg));
712+
iommu_group_set_iommudata(group, group_master_cfg,
713+
apple_dart_release_group);
714+
701715
for_each_stream_map(i, cfg, stream_map)
702716
for_each_set_bit(sid, &stream_map->sidmap, DART_MAX_STREAMS)
703717
stream_map->dart->sid2group[sid] = group;
704718

705719
res = group;
706720

707721
out:
708-
mutex_unlock(&lock);
722+
mutex_unlock(&apple_dart_groups_lock);
709723
return res;
710724
}
711725

drivers/iommu/intel/dmar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,18 +1942,18 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
19421942
reason = dmar_get_fault_reason(fault_reason, &fault_type);
19431943

19441944
if (fault_type == INTR_REMAP)
1945-
pr_err("[INTR-REMAP] Request device [0x%02x:0x%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
1945+
pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
19461946
source_id >> 8, PCI_SLOT(source_id & 0xFF),
19471947
PCI_FUNC(source_id & 0xFF), addr >> 48,
19481948
fault_reason, reason);
19491949
else if (pasid == INVALID_IOASID)
1950-
pr_err("[%s NO_PASID] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
1950+
pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
19511951
type ? "DMA Read" : "DMA Write",
19521952
source_id >> 8, PCI_SLOT(source_id & 0xFF),
19531953
PCI_FUNC(source_id & 0xFF), addr,
19541954
fault_reason, reason);
19551955
else
1956-
pr_err("[%s PASID 0x%x] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
1956+
pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
19571957
type ? "DMA Read" : "DMA Write", pasid,
19581958
source_id >> 8, PCI_SLOT(source_id & 0xFF),
19591959
PCI_FUNC(source_id & 0xFF), addr,

0 commit comments

Comments
 (0)