Skip to content

Commit 2f599c3

Browse files
Sam Protsenkojoergroedel
authored andcommitted
iommu/exynos: Implement fault handling on SysMMU v7
SysMMU v7 has a bit different registers for getting the fault info: - there is one single register (MMU_FAULT_VA) to get the fault address - fault access type (R/W) can be read from MMU_FAULT_TRANS_INFO register now - interrupt status register has different bits w.r.t. previous SysMMU versions - VM and non-VM layouts have different register addresses Add correct fault handling implementation for SysMMU v7, according to all mentioned differences. Only VID #0 (default) is handled, as VM domains support is not implemented yet. Signed-off-by: Sam Protsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent c64074b commit 2f599c3

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

drivers/iommu/exynos-iommu.c

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ static const char * const sysmmu_v5_fault_names[] = {
217217
"SECURITY PROTECTION"
218218
};
219219

220+
static const char * const sysmmu_v7_fault_names[] = {
221+
"PTW",
222+
"PAGE",
223+
"ACCESS PROTECTION",
224+
"RESERVED"
225+
};
226+
220227
/*
221228
* This structure is attached to dev->iommu->priv of the master device
222229
* on device add, contains a list of SYSMMU controllers defined by device tree,
@@ -260,6 +267,8 @@ struct sysmmu_variant {
260267
u32 flush_end; /* end address of range invalidation */
261268
u32 int_status; /* interrupt status information */
262269
u32 int_clear; /* clear the interrupt */
270+
u32 fault_va; /* IOVA address that caused fault */
271+
u32 fault_info; /* fault transaction info */
263272

264273
int (*get_fault_info)(struct sysmmu_drvdata *data, unsigned int itype,
265274
struct sysmmu_fault *fault);
@@ -337,6 +346,19 @@ static int exynos_sysmmu_v5_get_fault_info(struct sysmmu_drvdata *data,
337346
return 0;
338347
}
339348

349+
static int exynos_sysmmu_v7_get_fault_info(struct sysmmu_drvdata *data,
350+
unsigned int itype,
351+
struct sysmmu_fault *fault)
352+
{
353+
u32 info = readl(SYSMMU_REG(data, fault_info));
354+
355+
fault->addr = readl(SYSMMU_REG(data, fault_va));
356+
fault->name = sysmmu_v7_fault_names[itype % 4];
357+
fault->type = (info & BIT(20)) ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ;
358+
359+
return 0;
360+
}
361+
340362
/* SysMMU v1..v3 */
341363
static const struct sysmmu_variant sysmmu_v1_variant = {
342364
.flush_all = 0x0c,
@@ -348,7 +370,7 @@ static const struct sysmmu_variant sysmmu_v1_variant = {
348370
.get_fault_info = exynos_sysmmu_v1_get_fault_info,
349371
};
350372

351-
/* SysMMU v5 and v7 (non-VM capable) */
373+
/* SysMMU v5 */
352374
static const struct sysmmu_variant sysmmu_v5_variant = {
353375
.pt_base = 0x0c,
354376
.flush_all = 0x10,
@@ -362,7 +384,23 @@ static const struct sysmmu_variant sysmmu_v5_variant = {
362384
.get_fault_info = exynos_sysmmu_v5_get_fault_info,
363385
};
364386

365-
/* SysMMU v7: VM capable register set */
387+
/* SysMMU v7: non-VM capable register layout */
388+
static const struct sysmmu_variant sysmmu_v7_variant = {
389+
.pt_base = 0x0c,
390+
.flush_all = 0x10,
391+
.flush_entry = 0x14,
392+
.flush_range = 0x18,
393+
.flush_start = 0x20,
394+
.flush_end = 0x24,
395+
.int_status = 0x60,
396+
.int_clear = 0x64,
397+
.fault_va = 0x70,
398+
.fault_info = 0x78,
399+
400+
.get_fault_info = exynos_sysmmu_v7_get_fault_info,
401+
};
402+
403+
/* SysMMU v7: VM capable register layout */
366404
static const struct sysmmu_variant sysmmu_v7_vm_variant = {
367405
.pt_base = 0x800c,
368406
.flush_all = 0x8010,
@@ -372,8 +410,10 @@ static const struct sysmmu_variant sysmmu_v7_vm_variant = {
372410
.flush_end = 0x8024,
373411
.int_status = 0x60,
374412
.int_clear = 0x64,
413+
.fault_va = 0x1000,
414+
.fault_info = 0x1004,
375415

376-
.get_fault_info = exynos_sysmmu_v5_get_fault_info,
416+
.get_fault_info = exynos_sysmmu_v7_get_fault_info,
377417
};
378418

379419
static struct exynos_iommu_domain *to_exynos_domain(struct iommu_domain *dom)
@@ -496,7 +536,7 @@ static void __sysmmu_get_version(struct sysmmu_drvdata *data)
496536
if (data->has_vcr)
497537
data->variant = &sysmmu_v7_vm_variant;
498538
else
499-
data->variant = &sysmmu_v5_variant;
539+
data->variant = &sysmmu_v7_variant;
500540
}
501541

502542
__sysmmu_disable_clocks(data);

0 commit comments

Comments
 (0)