Skip to contentSkip to conversation

cxl: Set endianess of kernel contexts

PATCH Applied Frederic Barrat 4 participants 4 messages Dec 7, 2015 – Dec 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl: Set endianess of kernel contexts

A process element (defined in CAIA) keeps track of the endianess of contexts through the Little Endian (LE) bit of the State Register. It is currently set for user contexts, but was somehow forgotten for kernel contexts, so this patch fixes it.
It could lead to erratic behavior from an AFU when the context is attached through the kernel API.

---
cxl kernel API is supported starting with 4.3 (for cxlflash)

 drivers/misc/cxl/native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cxl/native.c +1 -1
index d2e75c8..f409097 100644
@@ -497,6 +497,7 @@ static u64 calculate_sr(struct cxl_context *ctx)
 {
 	u64 sr = 0;
 
+	set_endian(sr);
 	if (ctx->master)
 		sr |= CXL_PSL_SR_An_MP;
 	if (mfspr(SPRN_LPCR) & LPCR_TC)
@@ -506,7 +507,6 @@ static u64 calculate_sr(struct cxl_context *ctx)
 		sr |= CXL_PSL_SR_An_HV;
 	} else {
 		sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
-		set_endian(sr);
 		sr &= ~(CXL_PSL_SR_An_HV);
 		if (!test_tsk_thread_flag(current, TIF_32BIT))
 			sr |= CXL_PSL_SR_An_SF;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Frederic Barrat

A process element (defined in CAIA) keeps track of the endianess of contexts through the Little Endian (LE) bit of the State Register. It is currently set for user contexts, but was somehow forgotten for kernel contexts, so this patch fixes it.
It could lead to erratic behavior from an AFU when the context is attached through the kernel API.
=20

Quoted 5 lines

---
cxl kernel API is supported starting with 4.3 (for cxlflash)

The cxlflash's AFU doesn't use this bit, so the stable@ marker here is probably not strictly needed.

Mikey

Quoted 23 lines
 drivers/misc/cxl/native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

=20

drivers/misc/cxl/native.c +0 -0
index d2e75c8..f409097 100644
@@ -497,6 +497,7 @@ static u64 calculate_sr(struct cxl_context *ctx)
 {
 	u64 sr =3D 0;

=20

drivers/misc/cxl/native.c +1 -1
+	set_endian(sr);
 	if (ctx->master)
 		sr |=3D CXL_PSL_SR_An_MP;
 	if (mfspr(SPRN_LPCR) & LPCR_TC)
@@ -506,7 +507,6 @@ static u64 calculate_sr(struct cxl_context *ctx)
 		sr |=3D CXL_PSL_SR_An_HV;
 	} else {
 		sr |=3D CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
-		set_endian(sr);
 		sr &=3D ~(CXL_PSL_SR_An_HV);
 		if (!test_tsk_thread_flag(current, TIF_32BIT))
 			sr |=3D CXL_PSL_SR_An_SF;
#3 lore raw
In reply to Frederic Barrat
Quoted 10 lines · Frederic Barrat

A process element (defined in CAIA) keeps track of the endianess of contexts through the Little Endian (LE) bit of the State Register. It is currently set for user contexts, but was somehow forgotten for kernel contexts, so this patch fixes it.
It could lead to erratic behavior from an AFU when the context is attached through the kernel API.

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/e606e035cc7293a3824527d9

cheers