All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Shuai <songshuaishuai@tinylab.org>
To: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, andy.chiu@sifive.com,
	greentime.hu@sifive.com, conor.dooley@microchip.com,
	guoren@kernel.org, songshuaishuai@tinylab.org,
	bjorn@rivosinc.com, xiao.w.wang@intel.com, heiko@sntech.de,
	ruinland.tsai@sifive.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] riscv: vector: Check SR_SD before saving vstate
Date: Thu, 21 Dec 2023 15:04:49 +0800	[thread overview]
Message-ID: <20231221070449.1809020-1-songshuaishuai@tinylab.org> (raw)

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

WARNING: multiple messages have this Message-ID (diff)
From: Song Shuai <songshuaishuai@tinylab.org>
To: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, andy.chiu@sifive.com,
	greentime.hu@sifive.com, conor.dooley@microchip.com,
	guoren@kernel.org, songshuaishuai@tinylab.org,
	bjorn@rivosinc.com, xiao.w.wang@intel.com, heiko@sntech.de,
	ruinland.tsai@sifive.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] riscv: vector: Check SR_SD before saving vstate
Date: Thu, 21 Dec 2023 15:04:49 +0800	[thread overview]
Message-ID: <20231221070449.1809020-1-songshuaishuai@tinylab.org> (raw)

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


             reply	other threads:[~2023-12-21  7:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21  7:04 Song Shuai [this message]
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:37   ` Wang, Xiao W
2023-12-21  7:54   ` Andy Chiu
2023-12-21  7:54     ` Andy Chiu
2024-01-11 14:50 ` patchwork-bot+linux-riscv
2024-01-11 14:50   ` patchwork-bot+linux-riscv
2024-01-11 15:16   ` Andy Chiu
2024-01-11 15:16     ` Andy Chiu
2024-01-11 15:36     ` Palmer Dabbelt
2024-01-11 15:36       ` Palmer Dabbelt

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=20231221070449.1809020-1-songshuaishuai@tinylab.org \
    --to=songshuaishuai@tinylab.org \
    --cc=andy.chiu@sifive.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bjorn@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=greentime.hu@sifive.com \
    --cc=guoren@kernel.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=ruinland.tsai@sifive.com \
    --cc=xiao.w.wang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.