public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] riscv: vector: Check SR_SD before saving vstate
@ 2023-12-21  7:04 Song Shuai
  2023-12-21  7:37 ` Wang, Xiao W
  2024-01-11 14:50 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 6+ messages in thread
From: Song Shuai @ 2023-12-21  7:04 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, andy.chiu, greentime.hu, conor.dooley,
	guoren, songshuaishuai, bjorn, xiao.w.wang, heiko, ruinland.tsai
  Cc: linux-riscv, linux-kernel

The SD bit summarizes the dirty states of FS, VS, or XS fields,
providing a "fast check" before saving fstate or vstate.

Let __switch_to_vector() check SD bit as __switch_to_fpu() does.

Fixes: 3a2df6323def ("riscv: Add task switch support for vector")
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
---
 arch/riscv/include/asm/vector.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
index 87aaef656257..d30fa56f67c6 100644
--- a/arch/riscv/include/asm/vector.h
+++ b/arch/riscv/include/asm/vector.h
@@ -190,7 +190,8 @@ static inline void __switch_to_vector(struct task_struct *prev,
 	struct pt_regs *regs;
 
 	regs = task_pt_regs(prev);
-	riscv_v_vstate_save(prev, regs);
+	if (unlikely(regs->status & SR_SD))
+		riscv_v_vstate_save(prev, regs);
 	riscv_v_vstate_restore(next, task_pt_regs(next));
 }
 
-- 
2.20.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-11 15:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21  7:04 [PATCH] riscv: vector: Check SR_SD before saving vstate Song Shuai
2023-12-21  7:37 ` Wang, Xiao W
2023-12-21  7:54   ` Andy Chiu
2024-01-11 14:50 ` patchwork-bot+linux-riscv
2024-01-11 15:16   ` Andy Chiu
2024-01-11 15:36     ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox