Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions drivers/iommu/arm/arm-smmu/arm-smmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,19 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
return ERR_PTR(-ENODEV);
}

#ifdef CONFIG_ARCH_PHYTIUM
/* Phytium Ps17064 workaround patch */
if ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_PHYTIUM_PS17064) {
int num = fwspec->num_ids;

for (i = 0; i < num; i++) {
u32 fwid = FWID_READ(fwspec->ids[i]);

iommu_fwspec_add_ids(dev, &fwid, 1);
}
Comment on lines +1382 to +1386
}
#endif

ret = -EINVAL;
for (i = 0; i < fwspec->num_ids; i++) {
u16 sid = FIELD_GET(ARM_SMMU_SMR_ID, fwspec->ids[i]);
Expand Down
5 changes: 5 additions & 0 deletions drivers/iommu/arm/arm-smmu/arm-smmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef _ARM_SMMU_H
#define _ARM_SMMU_H

#include <asm/cputype.h>
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
Expand All @@ -23,6 +24,10 @@
#include <linux/spinlock.h>
#include <linux/types.h>

#ifdef CONFIG_ARCH_PHYTIUM
#define FWID_READ(id) (((u16)(id) >> 3) | (((id) >> 16 | 0x7000) << 16))
#endif

/* Configuration registers */
#define ARM_SMMU_GR0_sCR0 0x0
#define ARM_SMMU_sCR0_VMID16EN BIT(31)
Expand Down
25 changes: 25 additions & 0 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include <trace/events/iommu.h>
#include <linux/sched/mm.h>
#include <linux/msi.h>
#ifdef CONFIG_ARCH_PHYTIUM
#include <asm/cputype.h>
#endif

#include "dma-iommu.h"
#include "iommu-priv.h"
Expand Down Expand Up @@ -198,6 +201,15 @@ static int __init iommu_subsys_init(void)
iommu_set_default_passthrough(false);
else
iommu_set_default_translated(false);
#ifdef CONFIG_ARCH_PHYTIUM
/*
* Always set default iommu type to IOMMU_DOMAIN_IDENTITY
* on Phytium Ps17064 SoC to avoid unnecessary troubles
* introduced by the SMMU workaround.
*/
if ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_PHYTIUM_PS17064)
iommu_set_default_passthrough(true);
#endif

if (iommu_default_passthrough() && cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
pr_info("Memory encryption detected - Disabling default IOMMU Passthrough\n");
Expand Down Expand Up @@ -660,6 +672,19 @@ static int __init iommu_set_def_domain_type(char *str)
if (ret)
return ret;

#ifdef CONFIG_ARCH_PHYTIUM
/*
* Always set default iommu type to IOMMU_DOMAIN_IDENTITY
* on Phytium Ps17064 SoC to avoid unnecessary troubles
* introduced by the SMMU workaround.
*/
if ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_PHYTIUM_PS17064) {
iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY;
iommu_set_default_passthrough(true);
return 0;
}
#endif

if (pt)
iommu_set_default_passthrough(true);
else
Expand Down
4 changes: 4 additions & 0 deletions drivers/irqchip/irq-gic-v3-its.c
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,10 @@ static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg)
msg->address_hi = upper_32_bits(addr);
msg->data = its_get_event_id(d);

#ifdef CONFIG_ARCH_PHYTIUM
if ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_PHYTIUM_PS17064)
return;
#endif
iommu_dma_compose_msi_msg(irq_data_get_msi_desc(d), msg);
}

Expand Down
Loading
Loading