diff mbox series

[1/1] firmware: Minor optimization for relocate

Message ID 20221129035407.28946-2-zhangdongdong@eswincomputing.com
State Accepted
Headers show
Series firmware: Minor optimization for relocate | expand

Commit Message

DongdongZhang Nov. 29, 2022, 3:54 a.m. UTC
The t3 register stores the address of _load_end. If relocation is not required, it is unnecessary to calculate the address of _load_end.

This can reduce the operation time of two instructions.

Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>
---
 firmware/fw_base.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bin Meng Nov. 29, 2022, 7:51 a.m. UTC | #1
On Tue, Nov 29, 2022 at 11:57 AM Dongdong Zhang
<zhangdongdong@eswincomputing.com> wrote:
>
> The t3 register stores the address of _load_end. If relocation is not required, it is unnecessary to calculate the address of _load_end.

nits: commit messages should be written like about 70 characters per line.

>
> This can reduce the operation time of two instructions.
>
> Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>
> ---
>  firmware/fw_base.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng@tinylab.org>
DongdongZhang Nov. 29, 2022, 9:10 a.m. UTC | #2
Hi, Bin

Thank you for your review, and I will pay attention to the style of the commit message next time.

> -----原始邮件-----发件人:"Bin Meng" <bmeng.cn@gmail.com>发送时间:2022-11-29 15:51:33 (星期二)收件人:"Dongdong Zhang" <zhangdongdong@eswincomputing.com>抄送:opensbi@lists.infradead.org主题:Re: [PATCH 1/1] firmware: Minor optimization for relocate
> 
> On Tue, Nov 29, 2022 at 11:57 AM Dongdong Zhang
> <zhangdongdong@eswincomputing.com> wrote:
> >
> > The t3 register stores the address of _load_end. If relocation is not required, it is unnecessary to calculate the address of _load_end.
> 
> nits: commit messages should be written like about 70 characters per line.
> 
> >
> > This can reduce the operation time of two instructions.
> >
> > Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>
> > ---
> >  firmware/fw_base.S | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> 
> Reviewed-by: Bin Meng <bmeng@tinylab.org>
Anup Patel Dec. 5, 2022, 5:23 a.m. UTC | #3
On Tue, Nov 29, 2022 at 9:26 AM Dongdong Zhang
<zhangdongdong@eswincomputing.com> wrote:
>
> The t3 register stores the address of _load_end. If relocation is not required, it is unnecessary to calculate the address of _load_end.
>
> This can reduce the operation time of two instructions.
>
> Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

I have taken care of Bin's comment at the time of merging this patch.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  firmware/fw_base.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/firmware/fw_base.S b/firmware/fw_base.S
> index 07be4c4..3f622b3 100644
> --- a/firmware/fw_base.S
> +++ b/firmware/fw_base.S
> @@ -128,9 +128,9 @@ _relocate:
>         REG_L   t1, 0(t1)
>         lla     t2, _load_start
>         REG_L   t2, 0(t2)
> +       beq     t0, t2, _relocate_done
>         sub     t3, t1, t0
>         add     t3, t3, t2
> -       beq     t0, t2, _relocate_done
>         lla     t4, _relocate_done
>         sub     t4, t4, t2
>         add     t4, t4, t0
> --
> 2.17.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
diff mbox series

Patch

diff --git a/firmware/fw_base.S b/firmware/fw_base.S
index 07be4c4..3f622b3 100644
--- a/firmware/fw_base.S
+++ b/firmware/fw_base.S
@@ -128,9 +128,9 @@  _relocate:
 	REG_L	t1, 0(t1)
 	lla	t2, _load_start
 	REG_L	t2, 0(t2)
+	beq	t0, t2, _relocate_done
 	sub	t3, t1, t0
 	add	t3, t3, t2
-	beq	t0, t2, _relocate_done
 	lla	t4, _relocate_done
 	sub	t4, t4, t2
 	add	t4, t4, t0