Skip to content

Commit 3623002

Browse files
HaiNguyenPhamjoergroedel
authored andcommitted
iommu/ipmmu-vmsa: Disable cache snoop transactions on R-Car Gen3
According to the Hardware Manual Errata for Rev. 1.50 of April 10, 2019, cache snoop transactions for page table walk requests are not supported on R-Car Gen3. Hence, this patch removes setting these fields in the IMTTBCR register, since it will have no effect, and adds comments to the register bit definitions, to make it clear they apply to R-Car Gen2 only. Signed-off-by: Hai Nguyen Pham <[email protected]> [geert: Reword, add comments] Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5ca54fd commit 3623002

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

drivers/iommu/ipmmu-vmsa.c

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct ipmmu_features {
4949
bool setup_imbuscr;
5050
bool twobit_imttbcr_sl0;
5151
bool reserved_context;
52+
bool cache_snoop;
5253
};
5354

5455
struct ipmmu_vmsa_device {
@@ -115,36 +116,36 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
115116
#define IMTTBCR 0x0008
116117
#define IMTTBCR_EAE (1 << 31)
117118
#define IMTTBCR_PMB (1 << 30)
118-
#define IMTTBCR_SH1_NON_SHAREABLE (0 << 28)
119-
#define IMTTBCR_SH1_OUTER_SHAREABLE (2 << 28)
120-
#define IMTTBCR_SH1_INNER_SHAREABLE (3 << 28)
121-
#define IMTTBCR_SH1_MASK (3 << 28)
122-
#define IMTTBCR_ORGN1_NC (0 << 26)
123-
#define IMTTBCR_ORGN1_WB_WA (1 << 26)
124-
#define IMTTBCR_ORGN1_WT (2 << 26)
125-
#define IMTTBCR_ORGN1_WB (3 << 26)
126-
#define IMTTBCR_ORGN1_MASK (3 << 26)
127-
#define IMTTBCR_IRGN1_NC (0 << 24)
128-
#define IMTTBCR_IRGN1_WB_WA (1 << 24)
129-
#define IMTTBCR_IRGN1_WT (2 << 24)
130-
#define IMTTBCR_IRGN1_WB (3 << 24)
131-
#define IMTTBCR_IRGN1_MASK (3 << 24)
119+
#define IMTTBCR_SH1_NON_SHAREABLE (0 << 28) /* R-Car Gen2 only */
120+
#define IMTTBCR_SH1_OUTER_SHAREABLE (2 << 28) /* R-Car Gen2 only */
121+
#define IMTTBCR_SH1_INNER_SHAREABLE (3 << 28) /* R-Car Gen2 only */
122+
#define IMTTBCR_SH1_MASK (3 << 28) /* R-Car Gen2 only */
123+
#define IMTTBCR_ORGN1_NC (0 << 26) /* R-Car Gen2 only */
124+
#define IMTTBCR_ORGN1_WB_WA (1 << 26) /* R-Car Gen2 only */
125+
#define IMTTBCR_ORGN1_WT (2 << 26) /* R-Car Gen2 only */
126+
#define IMTTBCR_ORGN1_WB (3 << 26) /* R-Car Gen2 only */
127+
#define IMTTBCR_ORGN1_MASK (3 << 26) /* R-Car Gen2 only */
128+
#define IMTTBCR_IRGN1_NC (0 << 24) /* R-Car Gen2 only */
129+
#define IMTTBCR_IRGN1_WB_WA (1 << 24) /* R-Car Gen2 only */
130+
#define IMTTBCR_IRGN1_WT (2 << 24) /* R-Car Gen2 only */
131+
#define IMTTBCR_IRGN1_WB (3 << 24) /* R-Car Gen2 only */
132+
#define IMTTBCR_IRGN1_MASK (3 << 24) /* R-Car Gen2 only */
132133
#define IMTTBCR_TSZ1_MASK (7 << 16)
133134
#define IMTTBCR_TSZ1_SHIFT 16
134-
#define IMTTBCR_SH0_NON_SHAREABLE (0 << 12)
135-
#define IMTTBCR_SH0_OUTER_SHAREABLE (2 << 12)
136-
#define IMTTBCR_SH0_INNER_SHAREABLE (3 << 12)
137-
#define IMTTBCR_SH0_MASK (3 << 12)
138-
#define IMTTBCR_ORGN0_NC (0 << 10)
139-
#define IMTTBCR_ORGN0_WB_WA (1 << 10)
140-
#define IMTTBCR_ORGN0_WT (2 << 10)
141-
#define IMTTBCR_ORGN0_WB (3 << 10)
142-
#define IMTTBCR_ORGN0_MASK (3 << 10)
143-
#define IMTTBCR_IRGN0_NC (0 << 8)
144-
#define IMTTBCR_IRGN0_WB_WA (1 << 8)
145-
#define IMTTBCR_IRGN0_WT (2 << 8)
146-
#define IMTTBCR_IRGN0_WB (3 << 8)
147-
#define IMTTBCR_IRGN0_MASK (3 << 8)
135+
#define IMTTBCR_SH0_NON_SHAREABLE (0 << 12) /* R-Car Gen2 only */
136+
#define IMTTBCR_SH0_OUTER_SHAREABLE (2 << 12) /* R-Car Gen2 only */
137+
#define IMTTBCR_SH0_INNER_SHAREABLE (3 << 12) /* R-Car Gen2 only */
138+
#define IMTTBCR_SH0_MASK (3 << 12) /* R-Car Gen2 only */
139+
#define IMTTBCR_ORGN0_NC (0 << 10) /* R-Car Gen2 only */
140+
#define IMTTBCR_ORGN0_WB_WA (1 << 10) /* R-Car Gen2 only */
141+
#define IMTTBCR_ORGN0_WT (2 << 10) /* R-Car Gen2 only */
142+
#define IMTTBCR_ORGN0_WB (3 << 10) /* R-Car Gen2 only */
143+
#define IMTTBCR_ORGN0_MASK (3 << 10) /* R-Car Gen2 only */
144+
#define IMTTBCR_IRGN0_NC (0 << 8) /* R-Car Gen2 only */
145+
#define IMTTBCR_IRGN0_WB_WA (1 << 8) /* R-Car Gen2 only */
146+
#define IMTTBCR_IRGN0_WT (2 << 8) /* R-Car Gen2 only */
147+
#define IMTTBCR_IRGN0_WB (3 << 8) /* R-Car Gen2 only */
148+
#define IMTTBCR_IRGN0_MASK (3 << 8) /* R-Car Gen2 only */
148149
#define IMTTBCR_SL0_TWOBIT_LVL_3 (0 << 6) /* R-Car Gen3 only */
149150
#define IMTTBCR_SL0_TWOBIT_LVL_2 (1 << 6) /* R-Car Gen3 only */
150151
#define IMTTBCR_SL0_TWOBIT_LVL_1 (2 << 6) /* R-Car Gen3 only */
@@ -421,17 +422,19 @@ static void ipmmu_domain_setup_context(struct ipmmu_vmsa_domain *domain)
421422

422423
/*
423424
* TTBCR
424-
* We use long descriptors with inner-shareable WBWA tables and allocate
425-
* the whole 32-bit VA space to TTBR0.
425+
* We use long descriptors and allocate the whole 32-bit VA space to
426+
* TTBR0.
426427
*/
427428
if (domain->mmu->features->twobit_imttbcr_sl0)
428429
tmp = IMTTBCR_SL0_TWOBIT_LVL_1;
429430
else
430431
tmp = IMTTBCR_SL0_LVL_1;
431432

432-
ipmmu_ctx_write_root(domain, IMTTBCR, IMTTBCR_EAE |
433-
IMTTBCR_SH0_INNER_SHAREABLE | IMTTBCR_ORGN0_WB_WA |
434-
IMTTBCR_IRGN0_WB_WA | tmp);
433+
if (domain->mmu->features->cache_snoop)
434+
tmp |= IMTTBCR_SH0_INNER_SHAREABLE | IMTTBCR_ORGN0_WB_WA |
435+
IMTTBCR_IRGN0_WB_WA;
436+
437+
ipmmu_ctx_write_root(domain, IMTTBCR, IMTTBCR_EAE | tmp);
435438

436439
/* MAIR0 */
437440
ipmmu_ctx_write_root(domain, IMMAIR0,
@@ -987,6 +990,7 @@ static const struct ipmmu_features ipmmu_features_default = {
987990
.setup_imbuscr = true,
988991
.twobit_imttbcr_sl0 = false,
989992
.reserved_context = false,
993+
.cache_snoop = true,
990994
};
991995

992996
static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
@@ -997,6 +1001,7 @@ static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
9971001
.setup_imbuscr = false,
9981002
.twobit_imttbcr_sl0 = true,
9991003
.reserved_context = true,
1004+
.cache_snoop = false,
10001005
};
10011006

10021007
static const struct of_device_id ipmmu_of_ids[] = {

0 commit comments

Comments
 (0)