From: Michael Neuling <mikey@neuling.org>
To: mpe@ellerman.id.au
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
mikey@neuling.org, benh@kernel.crashing.org
Subject: [PATCH] powerpc/powernv: Fix XSCOM address mangling for form 1 indirect
Date: Fri, 24 Mar 2017 12:43:17 +1100 [thread overview]
Message-ID: <1490319797.28113.46.camel@neuling.org> (raw)
POWER9 adds form 1 scoms. The form of the indirection is specified in
the top nibble of the scom address.
Currently we do some (ugly) bit mangling so that we can fit a 64 bit
scom address into the debugfs interface. The current code only shifts
the top bit (indirect bit).
This patch changes it to shift the whole top nibble so that the form
of the indirection is also shifted.
This patch is backwards compatible with older scoms.
(This change isn't required in the
arch/powerpc/platformspowernv/opal-prd.c scom interface as it passes
the whole 64bit scom address without any bit mangling)
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
(resending to correct linuxppc address)
=C2=A0arch/powerpc/platforms/powernv/opal-xscom.c | 27 +++++++++++++++++---=
-------
=C2=A01 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c
b/arch/powerpc/platforms/powernv/opal-xscom.c
index d0ac535cf5..28651fb254 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -73,25 +73,32 @@ static int opal_xscom_err_xlate(int64_t rc)
=C2=A0
=C2=A0static u64 opal_scom_unmangle(u64 addr)
=C2=A0{
+ u64 tmp;
+
=C2=A0 /*
- =C2=A0* XSCOM indirect addresses have the top bit set. Additionally
- =C2=A0* the rest of the top 3 nibbles is always 0.
+ =C2=A0* XSCOM addresses use the top nibble to set indirect mode and
+ =C2=A0* its form.=C2=A0=C2=A0Bits 4-11 are always 0.
=C2=A0 =C2=A0*
=C2=A0 =C2=A0* Because the debugfs interface uses signed offsets and shifts
=C2=A0 =C2=A0* the address left by 3, we basically cannot use the top 4 bit=
s
=C2=A0 =C2=A0* of the 64-bit address, and thus cannot use the indirect bit.
=C2=A0 =C2=A0*
- =C2=A0* To deal with that, we support the indirect bit being in bit
- =C2=A0* 4 (IBM notation) instead of bit 0 in this API, we do the
- =C2=A0* conversion here. To leave room for further xscom address
- =C2=A0* expansion, we only clear out the top byte
+ =C2=A0* To deal with that, we support the indirect bits being in
+ =C2=A0* bits 4-7 (IBM notation) instead of bit 0-3 in this API, we
+ =C2=A0* do the conversion here.
=C2=A0 =C2=A0*
- =C2=A0* For in-kernel use, we also support the real indirect bit, so
- =C2=A0* we test for any of the top 5 bits
+ =C2=A0* For in-kernel use, we don't need to do this mangling.=C2=A0=C2=A0=
In
+ =C2=A0* kernel won't have bits 4-7 set.
=C2=A0 =C2=A0*
+ =C2=A0* So:
+ =C2=A0*=C2=A0=C2=A0=C2=A0debugfs will always=C2=A0=C2=A0=C2=A0set 0-3 =3D=
0 and clear 4-7
+ =C2=A0*=C2=A0=C2=A0=C2=A0=C2=A0kernel will always clear 0-3 =3D 0 and=C2=
=A0=C2=A0=C2=A0set 4-7
=C2=A0 =C2=A0*/
- if (addr & (0x1full << 59))
- addr =3D (addr & ~(0xffull << 56)) | (1ull << 63);
+ tmp =3D addr;
+ tmp=C2=A0=C2=A0&=3D 0x0f00000000000000;
+ addr &=3D 0xf0ffffffffffffff;
+ addr |=3D tmp << 4;
+
=C2=A0 return addr;
=C2=A0}
=C2=A0
next reply other threads:[~2017-03-24 1:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 1:43 Michael Neuling [this message]
2017-03-31 12:33 ` powerpc/powernv: Fix XSCOM address mangling for form 1 indirect Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490319797.28113.46.camel@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).