Skip to content

Commit 7e113d0

Browse files
committed
Merge tag 'iommu-updates-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull iommu updates from Joerg Roedel: - Intel IOMMU Updates fro Lu Baolu: - Dump DMAR translation structure when DMA fault occurs - An optimization in the page table manipulation code - Use second level for GPA->HPA translation - Various cleanups - Arm SMMU Updates from Will - Minor optimisations to SMMUv3 command creation and submission - Numerous new compatible string for Qualcomm SMMUv2 implementations - Fixes for the SWIOTLB based implemenation of dma-iommu code for untrusted devices - Add support for r8a779a0 to the Renesas IOMMU driver and DT matching code for r8a77980 - A couple of cleanups and fixes for the Apple DART IOMMU driver - Make use of generic report_iommu_fault() interface in the AMD IOMMU driver - Various smaller fixes and cleanups * tag 'iommu-updates-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (35 commits) iommu/dma: Fix incorrect error return on iommu deferred attach iommu/dart: Initialize DART_STREAMS_ENABLE iommu/dma: Use kvcalloc() instead of kvzalloc() iommu/tegra-smmu: Use devm_bitmap_zalloc when applicable iommu/dart: Use kmemdup instead of kzalloc and memcpy iommu/vt-d: Avoid duplicate removing in __domain_mapping() iommu/vt-d: Convert the return type of first_pte_in_page to bool iommu/vt-d: Clean up unused PASID updating functions iommu/vt-d: Delete dev_has_feat callback iommu/vt-d: Use second level for GPA->HPA translation iommu/vt-d: Check FL and SL capability sanity in scalable mode iommu/vt-d: Remove duplicate identity domain flag iommu/vt-d: Dump DMAR translation structure when DMA fault occurs iommu/vt-d: Do not falsely log intel_iommu is unsupported kernel option iommu/arm-smmu-qcom: Request direct mapping for modem device iommu: arm-smmu-qcom: Add compatible for QCM2290 dt-bindings: arm-smmu: Add compatible for QCM2290 SoC iommu/arm-smmu-qcom: Add SM6350 SMMU compatible dt-bindings: arm-smmu: Add compatible for SM6350 SoC iommu/arm-smmu-v3: Properly handle the return value of arm_smmu_cmdq_build_cmd() ...
2 parents abfecb3 + 52d9691 commit 7e113d0

24 files changed

Lines changed: 367 additions & 243 deletions

File tree

Documentation/devicetree/bindings/iommu/arm,smmu.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ properties:
3333
- description: Qcom SoCs implementing "arm,mmu-500"
3434
items:
3535
- enum:
36+
- qcom,qcm2290-smmu-500
3637
- qcom,sc7180-smmu-500
3738
- qcom,sc7280-smmu-500
3839
- qcom,sc8180x-smmu-500
3940
- qcom,sdm845-smmu-500
41+
- qcom,sm6350-smmu-500
4042
- qcom,sm8150-smmu-500
4143
- qcom,sm8250-smmu-500
4244
- qcom,sm8350-smmu-500

Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ properties:
4343
- renesas,ipmmu-r8a77980 # R-Car V3H
4444
- renesas,ipmmu-r8a77990 # R-Car E3
4545
- renesas,ipmmu-r8a77995 # R-Car D3
46+
- renesas,ipmmu-r8a779a0 # R-Car V3U
4647

4748
reg:
4849
maxItems: 1

arch/x86/include/asm/fpu/api.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ extern int cpu_has_xfeatures(u64 xfeatures_mask, const char **feature_name);
108108
*/
109109
#define PASID_DISABLED 0
110110

111-
static inline void update_pasid(void) { }
112-
113111
/* Trap handling */
114112
extern int fpu__exception_code(struct fpu *fpu, int trap_nr);
115113
extern void fpu_sync_fpstate(struct fpu *fpu);

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
#define EVENT_DOMID_MASK_HI 0xf0000
139139
#define EVENT_FLAGS_MASK 0xfff
140140
#define EVENT_FLAGS_SHIFT 0x10
141+
#define EVENT_FLAG_RW 0x020
142+
#define EVENT_FLAG_I 0x008
141143

142144
/* feature control bits */
143145
#define CONTROL_IOMMU_EN 0x00ULL

drivers/iommu/amd/iommu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,12 @@ static void amd_iommu_report_rmp_fault(volatile u32 *event)
474474
pci_dev_put(pdev);
475475
}
476476

477+
#define IS_IOMMU_MEM_TRANSACTION(flags) \
478+
(((flags) & EVENT_FLAG_I) == 0)
479+
480+
#define IS_WRITE_REQUEST(flags) \
481+
((flags) & EVENT_FLAG_RW)
482+
477483
static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
478484
u64 address, int flags)
479485
{
@@ -486,6 +492,20 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
486492
dev_data = dev_iommu_priv_get(&pdev->dev);
487493

488494
if (dev_data) {
495+
/*
496+
* If this is a DMA fault (for which the I(nterrupt)
497+
* bit will be unset), allow report_iommu_fault() to
498+
* prevent logging it.
499+
*/
500+
if (IS_IOMMU_MEM_TRANSACTION(flags)) {
501+
if (!report_iommu_fault(&dev_data->domain->domain,
502+
&pdev->dev, address,
503+
IS_WRITE_REQUEST(flags) ?
504+
IOMMU_FAULT_WRITE :
505+
IOMMU_FAULT_READ))
506+
goto out;
507+
}
508+
489509
if (__ratelimit(&dev_data->rs)) {
490510
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
491511
domain_id, address, flags);
@@ -496,6 +516,7 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
496516
domain_id, address, flags);
497517
}
498518

519+
out:
499520
if (pdev)
500521
pci_dev_put(pdev);
501522
}

drivers/iommu/apple-dart.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/bitfield.h>
1616
#include <linux/clk.h>
1717
#include <linux/dev_printk.h>
18-
#include <linux/dma-iommu.h>
1918
#include <linux/dma-mapping.h>
2019
#include <linux/err.h>
2120
#include <linux/interrupt.h>
@@ -70,6 +69,8 @@
7069
#define DART_ERROR_ADDR_HI 0x54
7170
#define DART_ERROR_ADDR_LO 0x50
7271

72+
#define DART_STREAMS_ENABLE 0xfc
73+
7374
#define DART_TCR(sid) (0x100 + 4 * (sid))
7475
#define DART_TCR_TRANSLATE_ENABLE BIT(7)
7576
#define DART_TCR_BYPASS0_ENABLE BIT(8)
@@ -301,6 +302,9 @@ static int apple_dart_hw_reset(struct apple_dart *dart)
301302
apple_dart_hw_disable_dma(&stream_map);
302303
apple_dart_hw_clear_all_ttbrs(&stream_map);
303304

305+
/* enable all streams globally since TCR is used to control isolation */
306+
writel(DART_STREAM_ALL, dart->regs + DART_STREAMS_ENABLE);
307+
304308
/* clear any pending errors before the interrupt is unmasked */
305309
writel(readl(dart->regs + DART_ERROR), dart->regs + DART_ERROR);
306310

@@ -578,7 +582,6 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type)
578582
if (!dart_domain)
579583
return NULL;
580584

581-
iommu_get_dma_cookie(&dart_domain->domain);
582585
mutex_init(&dart_domain->init_lock);
583586

584587
/* no need to allocate pgtbl_ops or do any other finalization steps */
@@ -702,13 +705,12 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)
702705
if (!group)
703706
goto out;
704707

705-
group_master_cfg = kzalloc(sizeof(*group_master_cfg), GFP_KERNEL);
708+
group_master_cfg = kmemdup(cfg, sizeof(*group_master_cfg), GFP_KERNEL);
706709
if (!group_master_cfg) {
707710
iommu_group_put(group);
708711
goto out;
709712
}
710713

711-
memcpy(group_master_cfg, cfg, sizeof(*group_master_cfg));
712714
iommu_group_set_iommudata(group, group_master_cfg,
713715
apple_dart_release_group);
714716

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,7 @@ static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
409409
dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]);
410410

411411
/* Convert the erroneous command into a CMD_SYNC */
412-
if (arm_smmu_cmdq_build_cmd(cmd, &cmd_sync)) {
413-
dev_err(smmu->dev, "failed to convert to CMD_SYNC\n");
414-
return;
415-
}
412+
arm_smmu_cmdq_build_cmd(cmd, &cmd_sync);
416413

417414
queue_write(Q_ENT(q, cons), cmd, q->ent_dwords);
418415
}
@@ -860,7 +857,7 @@ static int __arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu,
860857
{
861858
u64 cmd[CMDQ_ENT_DWORDS];
862859

863-
if (arm_smmu_cmdq_build_cmd(cmd, ent)) {
860+
if (unlikely(arm_smmu_cmdq_build_cmd(cmd, ent))) {
864861
dev_warn(smmu->dev, "ignoring unknown CMDQ opcode 0x%x\n",
865862
ent->opcode);
866863
return -EINVAL;
@@ -885,11 +882,20 @@ static void arm_smmu_cmdq_batch_add(struct arm_smmu_device *smmu,
885882
struct arm_smmu_cmdq_batch *cmds,
886883
struct arm_smmu_cmdq_ent *cmd)
887884
{
885+
int index;
886+
888887
if (cmds->num == CMDQ_BATCH_ENTRIES) {
889888
arm_smmu_cmdq_issue_cmdlist(smmu, cmds->cmds, cmds->num, false);
890889
cmds->num = 0;
891890
}
892-
arm_smmu_cmdq_build_cmd(&cmds->cmds[cmds->num * CMDQ_ENT_DWORDS], cmd);
891+
892+
index = cmds->num * CMDQ_ENT_DWORDS;
893+
if (unlikely(arm_smmu_cmdq_build_cmd(&cmds->cmds[index], cmd))) {
894+
dev_warn(smmu->dev, "ignoring unknown CMDQ opcode 0x%x\n",
895+
cmd->opcode);
896+
return;
897+
}
898+
893899
cmds->num++;
894900
}
895901

@@ -1764,10 +1770,11 @@ static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
17641770
{
17651771
int i;
17661772
struct arm_smmu_cmdq_ent cmd;
1767-
struct arm_smmu_cmdq_batch cmds = {};
1773+
struct arm_smmu_cmdq_batch cmds;
17681774

17691775
arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd);
17701776

1777+
cmds.num = 0;
17711778
for (i = 0; i < master->num_streams; i++) {
17721779
cmd.atc.sid = master->streams[i].id;
17731780
arm_smmu_cmdq_batch_add(master->smmu, &cmds, &cmd);

drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static const struct of_device_id qcom_smmu_client_of_match[] __maybe_unused = {
231231
{ .compatible = "qcom,sc7180-mdss" },
232232
{ .compatible = "qcom,sc7180-mss-pil" },
233233
{ .compatible = "qcom,sc7280-mdss" },
234+
{ .compatible = "qcom,sc7280-mss-pil" },
234235
{ .compatible = "qcom,sc8180x-mdss" },
235236
{ .compatible = "qcom,sdm845-mdss" },
236237
{ .compatible = "qcom,sdm845-mss-pil" },
@@ -403,12 +404,14 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
403404

404405
static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
405406
{ .compatible = "qcom,msm8998-smmu-v2" },
407+
{ .compatible = "qcom,qcm2290-smmu-500" },
406408
{ .compatible = "qcom,sc7180-smmu-500" },
407409
{ .compatible = "qcom,sc7280-smmu-500" },
408410
{ .compatible = "qcom,sc8180x-smmu-500" },
409411
{ .compatible = "qcom,sdm630-smmu-v2" },
410412
{ .compatible = "qcom,sdm845-smmu-500" },
411413
{ .compatible = "qcom,sm6125-smmu-500" },
414+
{ .compatible = "qcom,sm6350-smmu-500" },
412415
{ .compatible = "qcom,sm8150-smmu-500" },
413416
{ .compatible = "qcom,sm8250-smmu-500" },
414417
{ .compatible = "qcom,sm8350-smmu-500" },

0 commit comments

Comments
 (0)