1 From 353725d455cc27aa2008456c2711e7fae2b8a631 Mon Sep 17 00:00:00 2001
2 From: Bharat Bhushan <Bharat.Bhushan@nxp.com>
3 Date: Wed, 7 Mar 2018 21:35:37 +0530
4 Subject: [PATCH] soc: fsl: dpio: aligned access of qbman cacheable region
6 Alignment requirement on ARM is lenient (In Linux) for regions
7 mapped as "Memory Type" but have very strict policy for regions
8 mapped as "Device Type". Unaligned access to regions mapped
9 as "Device Type" will always result to unaligned fault.
11 DPIO driver have un-aligned access to QBman cacheable region
12 and the Linux driver maps the region as "Memory Type". On Host
13 Linux this works because MMU Stage-1 configured by driver allows
14 unaligned access. In Virtual Machine cases, final region mapping type
15 is governed by combination of Stage-1 and Stage-2 MMU mapping.
17 Linux driver in VM controls maps the region as "Memory Type" in
18 Stage-1 MMU while Stage-2 is controlled by KVM. And current KVM
19 implementation does not allow device region to be mapped as
20 "Memory Type". Till we have a working/upstream-able solution
21 for Virtual Machine, we need to change un-aligned access in DPIO
24 While we reached to this point as we observed below alignment
25 exception in Virtual Machine when accessing qbman cacheable region.
27 kvm [2347]: Unsupported FSC: EC=0x24 xFSC=0x21
29 error: kvm run failed Bad address
30 PC=ffff000008398e78 SP=ffff800009bcb540
31 X00=ffff000008041000 X01=ffff800009bcb580 X02=ffff800009bcb650
33 X04=ffff000008041001 X05=ffff800009bcb581 X06=0200000000000000
35 X08=0000000000000000 X09=ffff000008041000 X10=0000000000000001
37 X12=00000000fa83b2da X13=0000000000000001 X14=000000007f605ec8
39 X16=000000008521af1e X17=000000001076277e X18=ffff800009bcb5c0
41 X20=ffff800009bcb650 X21=0000000000000002 X22=0000000000000000
43 X24=0000000000000000 X25=ffff8000099e7440 X26=ffff000008da6000
45 X28=00000000499e7440 X29=ffff800009bcb540 X30=ffff00000839a160
46 PSTATE=20000145 --C- EL1h
48 Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
50 drivers/soc/fsl/dpio/qbman-portal.c | 12 +++++++++++-
51 1 file changed, 11 insertions(+), 1 deletion(-)
53 --- a/drivers/soc/fsl/dpio/qbman-portal.c
54 +++ b/drivers/soc/fsl/dpio/qbman-portal.c
55 @@ -515,7 +515,17 @@ int qbman_swp_enqueue(struct qbman_swp *
58 p = qbman_get_cmd(s, QBMAN_CENA_SWP_EQCR(EQAR_IDX(eqar)));
59 - memcpy(&p->dca, &d->dca, 31);
60 + /* This is mapped as DEVICE type memory, writes are
61 + * with address alignment:
62 + * desc.dca address alignment = 1
63 + * desc.seqnum address alignment = 2
64 + * desc.orpid address alignment = 4
65 + * desc.tgtid address alignment = 8
68 + p->seqnum = d->seqnum;
69 + p->orpid = d->orpid;
70 + memcpy(&p->tgtid, &d->tgtid, 24);
71 memcpy(&p->fd, fd, sizeof(*fd));
73 if ((s->desc->qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {