Skip to content

Commit

Permalink
Merge branches 'apple/dart', 'arm/rockchip', 'arm/smmu', 'virtio', 'x…
Browse files Browse the repository at this point in the history
…86/vt-d', 'x86/amd' and 'core' into next
  • Loading branch information
joergroedel committed Jan 3, 2024
8 parents 610a9b8 + b6b2264 + f8aa519 + 3453c2b + 6f01a73 + 80b79e1 + c7fc123 + bb57f67 commit 75f74f8
Show file tree
Hide file tree
Showing 63 changed files with 1,278 additions and 1,042 deletions.
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/iommu/apple,dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ properties:
compatible:
enum:
- apple,t8103-dart
- apple,t8103-usb4-dart
- apple,t8110-dart
- apple,t6000-dart

Expand Down
77 changes: 74 additions & 3 deletions Documentation/devicetree/bindings/iommu/arm,smmu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ properties:
- qcom,sm8350-smmu-500
- qcom,sm8450-smmu-500
- qcom,sm8550-smmu-500
- qcom,sm8650-smmu-500
- qcom,x1e80100-smmu-500
- const: qcom,smmu-500
- const: arm,mmu-500

Expand Down Expand Up @@ -89,6 +91,8 @@ properties:
- qcom,sm8150-smmu-500
- qcom,sm8250-smmu-500
- qcom,sm8350-smmu-500
- qcom,sm8450-smmu-500
- qcom,sm8550-smmu-500
- const: qcom,adreno-smmu
- const: qcom,smmu-500
- const: arm,mmu-500
Expand Down Expand Up @@ -429,6 +433,30 @@ allOf:
- description: interface clock required to access smmu's registers
through the TCU's programming interface.

- if:
properties:
compatible:
items:
- enum:
- qcom,sm8350-smmu-500
- const: qcom,adreno-smmu
- const: qcom,smmu-500
- const: arm,mmu-500
then:
properties:
clock-names:
items:
- const: bus
- const: iface
- const: ahb
- const: hlos1_vote_gpu_smmu
- const: cx_gmu
- const: hub_cx_int
- const: hub_aon
clocks:
minItems: 7
maxItems: 7

- if:
properties:
compatible:
Expand All @@ -453,6 +481,50 @@ allOf:
- description: Voter clock required for HLOS SMMU access
- description: Interface clock required for register access

- if:
properties:
compatible:
const: qcom,sm8450-smmu-500
then:
properties:
clock-names:
items:
- const: gmu
- const: hub
- const: hlos
- const: bus
- const: iface
- const: ahb

clocks:
items:
- description: GMU clock
- description: GPU HUB clock
- description: HLOS vote clock
- description: GPU memory bus clock
- description: GPU SNoC bus clock
- description: GPU AHB clock

- if:
properties:
compatible:
const: qcom,sm8550-smmu-500
then:
properties:
clock-names:
items:
- const: hlos
- const: bus
- const: iface
- const: ahb

clocks:
items:
- description: HLOS vote clock
- description: GPU memory bus clock
- description: GPU SNoC bus clock
- description: GPU AHB clock

# Disallow clocks for all other platforms with specific compatibles
- if:
properties:
Expand All @@ -472,9 +544,8 @@ allOf:
- qcom,sdx65-smmu-500
- qcom,sm6350-smmu-500
- qcom,sm6375-smmu-500
- qcom,sm8350-smmu-500
- qcom,sm8450-smmu-500
- qcom,sm8550-smmu-500
- qcom,sm8650-smmu-500
- qcom,x1e80100-smmu-500
then:
properties:
clock-names: false
Expand Down
11 changes: 8 additions & 3 deletions Documentation/devicetree/bindings/iommu/rockchip,iommu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ description: |+
properties:
compatible:
enum:
- rockchip,iommu
- rockchip,rk3568-iommu
oneOf:
- enum:
- rockchip,iommu
- rockchip,rk3568-iommu
- items:
- enum:
- rockchip,rk3588-iommu
- const: rockchip,rk3568-iommu

reg:
items:
Expand Down
5 changes: 5 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ config ARCH_HAS_DMA_CLEAR_UNCACHED
config ARCH_HAS_CPU_FINALIZE_INIT
bool

# The architecture has a per-task state that includes the mm's PASID
config ARCH_HAS_CPU_PASID
bool
select IOMMU_MM_DATA

# Select if arch init_task must go in the __init_task_data section
config ARCH_TASK_STRUCT_ON_STACK
bool
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/mm/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
* Plug in direct dma map ops.
*/
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
/*
* IOC hardware snoops all DMA traffic keeping the caches consistent
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/dma-mapping-nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
}

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
if (IS_ENABLED(CONFIG_CPU_V7M)) {
/*
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ void arm_iommu_detach_device(struct device *dev)
EXPORT_SYMBOL_GPL(arm_iommu_detach_device);

static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
struct dma_iommu_mapping *mapping;

Expand Down Expand Up @@ -1748,7 +1748,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
#else

static void arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
}

Expand All @@ -1757,7 +1757,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
#endif /* CONFIG_ARM_DMA_USE_IOMMU */

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
/*
* Due to legacy code that sets the ->dma_coherent flag from a bus
Expand All @@ -1776,8 +1776,8 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
if (dev->dma_ops)
return;

if (iommu)
arm_setup_iommu_dma_ops(dev, dma_base, size, iommu, coherent);
if (device_iommu_mapped(dev))
arm_setup_iommu_dma_ops(dev, dma_base, size, coherent);

xen_setup_dma_ops(dev);
dev->archdata.dma_ops_setup = true;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void arch_teardown_dma_ops(struct device *dev)
#endif

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
int cls = cache_line_size_of_cpu();

Expand All @@ -58,7 +58,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
ARCH_DMA_MINALIGN, cls);

dev->dma_coherent = coherent;
if (iommu)
if (device_iommu_mapped(dev))
iommu_setup_dma_ops(dev, dma_base, dma_base + size - 1);

xen_setup_dma_ops(dev);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/mm/dma-noncoherent.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,

#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
dev->dma_coherent = coherent;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/mm/dma-noncoherent.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
}

void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
bool coherent)
{
WARN_TAINT(!coherent && riscv_cbom_block_size > ARCH_DMA_MINALIGN,
TAINT_CPU_OUT_OF_SPEC,
Expand Down
1 change: 1 addition & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ config X86
select ARCH_HAS_CACHE_LINE_SIZE
select ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION
select ARCH_HAS_CPU_FINALIZE_INIT
select ARCH_HAS_CPU_PASID if IOMMU_SVA
select ARCH_HAS_CURRENT_STACK_POINTER
select ARCH_HAS_DEBUG_VIRTUAL
select ARCH_HAS_DEBUG_VM_PGTABLE if !X86_PAE
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ static bool fixup_iopl_exception(struct pt_regs *regs)
*/
static bool try_fixup_enqcmd_gp(void)
{
#ifdef CONFIG_IOMMU_SVA
#ifdef CONFIG_ARCH_HAS_CPU_PASID
u32 pasid;

/*
Expand All @@ -591,7 +591,7 @@ static bool try_fixup_enqcmd_gp(void)
if (!mm_valid_pasid(current->mm))
return false;

pasid = current->mm->pasid;
pasid = mm_get_enqcmd_pasid(current->mm);

/*
* Did this thread already have its PASID activated?
Expand Down
32 changes: 18 additions & 14 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,8 +1562,7 @@ static inline const struct iommu_ops *acpi_iommu_fwspec_ops(struct device *dev)
return fwspec ? fwspec->ops : NULL;
}

static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,
const u32 *id_in)
static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
{
int err;
const struct iommu_ops *ops;
Expand All @@ -1577,7 +1576,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,
ops = acpi_iommu_fwspec_ops(dev);
if (ops) {
mutex_unlock(&iommu_probe_device_lock);
return ops;
return 0;
}

err = iort_iommu_configure_id(dev, id_in);
Expand All @@ -1594,12 +1593,14 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,

/* Ignore all other errors apart from EPROBE_DEFER */
if (err == -EPROBE_DEFER) {
return ERR_PTR(err);
return err;
} else if (err) {
dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
return NULL;
return -ENODEV;
}
return acpi_iommu_fwspec_ops(dev);
if (!acpi_iommu_fwspec_ops(dev))
return -ENODEV;
return 0;
}

#else /* !CONFIG_IOMMU_API */
Expand All @@ -1611,10 +1612,9 @@ int acpi_iommu_fwspec_init(struct device *dev, u32 id,
return -ENODEV;
}

static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,
const u32 *id_in)
static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
{
return NULL;
return -ENODEV;
}

#endif /* !CONFIG_IOMMU_API */
Expand All @@ -1628,7 +1628,7 @@ static const struct iommu_ops *acpi_iommu_configure_id(struct device *dev,
int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
const u32 *input_id)
{
const struct iommu_ops *iommu;
int ret;

if (attr == DEV_DMA_NOT_SUPPORTED) {
set_dma_ops(dev, &dma_dummy_ops);
Expand All @@ -1637,12 +1637,16 @@ int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,

acpi_arch_dma_setup(dev);

iommu = acpi_iommu_configure_id(dev, input_id);
if (PTR_ERR(iommu) == -EPROBE_DEFER)
ret = acpi_iommu_configure_id(dev, input_id);
if (ret == -EPROBE_DEFER)
return -EPROBE_DEFER;

arch_setup_dma_ops(dev, 0, U64_MAX,
iommu, attr == DEV_DMA_COHERENT);
/*
* Historically this routine doesn't fail driver probing due to errors
* in acpi_iommu_configure_id()
*/

arch_setup_dma_ops(dev, 0, U64_MAX, attr == DEV_DMA_COHERENT);

return 0;
}
Expand Down
8 changes: 3 additions & 5 deletions drivers/dma/tegra186-gpc-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,8 @@ static int tegra_dma_program_sid(struct tegra_dma_channel *tdc, int stream_id)
static int tegra_dma_probe(struct platform_device *pdev)
{
const struct tegra_dma_chip_data *cdata = NULL;
struct iommu_fwspec *iommu_spec;
unsigned int stream_id, i;
unsigned int i;
u32 stream_id;
struct tegra_dma *tdma;
int ret;

Expand Down Expand Up @@ -1378,12 +1378,10 @@ static int tegra_dma_probe(struct platform_device *pdev)

tdma->dma_dev.dev = &pdev->dev;

iommu_spec = dev_iommu_fwspec_get(&pdev->dev);
if (!iommu_spec) {
if (!tegra_dev_iommu_get_stream_id(&pdev->dev, &stream_id)) {
dev_err(&pdev->dev, "Missing iommu stream-id\n");
return -EINVAL;
}
stream_id = iommu_spec->ids[0] & 0xffff;

ret = device_property_read_u32(&pdev->dev, "dma-channel-mask",
&tdma->chan_mask);
Expand Down
9 changes: 2 additions & 7 deletions drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gp10b.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ static void
gp10b_ltc_init(struct nvkm_ltc *ltc)
{
struct nvkm_device *device = ltc->subdev.device;
struct iommu_fwspec *spec;
u32 sid;

nvkm_wr32(device, 0x17e27c, ltc->ltc_nr);
nvkm_wr32(device, 0x17e000, ltc->ltc_nr);
nvkm_wr32(device, 0x100800, ltc->ltc_nr);

spec = dev_iommu_fwspec_get(device->dev);
if (spec) {
u32 sid = spec->ids[0] & 0xffff;

/* stream ID */
if (tegra_dev_iommu_get_stream_id(device->dev, &sid))
nvkm_wr32(device, 0x160000, sid << 2);
}
}

static const struct nvkm_ltc_func
Expand Down
Loading

0 comments on commit 75f74f8

Please sign in to comment.