public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: <Padmarao.Begari@microchip.com>
To: <u-boot@lists.denx.de>, <peterlin@andestech.com>
Cc: <samuel@sholland.org>
Subject: Re: [PATCH v2] riscv: Fix detecting FPU support in standard extension
Date: Thu, 10 Nov 2022 12:30:01 +0000	[thread overview]
Message-ID: <18a73d04d0bc9d1abe3dcafd91bd4fd82898e31b.camel@microchip.com> (raw)
In-Reply-To: <20221105060214.2526-1-peterlin@andestech.com>

> On Sat, 2022-11-05 at 14:02 +0800, Yu Chien Peter Lin wrote:
> 
> We should check the string until it hits underscore, in case it
> searches for the letters in the custom extension. For example,
> "rv64imac_xandes" will be treated as D extension support since
> there is a "d" in "andes", resulting illegal instruction caused
> by initializing FCSR.
> 
> Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
> ---
>  arch/riscv/cpu/cpu.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index 52ab02519f..d34c8efce0 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -36,6 +36,7 @@ static inline bool supports_extension(char ext)
>  #ifdef CONFIG_CPU
>         struct udevice *dev;
>         char desc[32];
> +       int i;
> 
>         uclass_find_first_device(UCLASS_CPU, &dev);
>         if (!dev) {
> @@ -43,9 +44,16 @@ static inline bool supports_extension(char ext)
>                 return false;
>         }
>         if (!cpu_get_desc(dev, desc, sizeof(desc))) {
> -               /* skip the first 4 characters (rv32|rv64) */
> -               if (strchr(desc + 4, ext))
> -                       return true;
> +               /*
> +                * skip the first 4 characters (rv32|rv64) and
> +                * check until underscore
> +                */
> +               for (i = 4; i < sizeof(desc); i++) {
> +                       if (desc[i] == '_' || desc[i] == '\0')
> +                               break;
> +                       if (desc[i] == ext)
> +                               return true;
> +               }
> 

Reviewed-by: Padmarao Begari <padmarao.begari@microchip.com>

>         }
> 
>         return false;
> --
> 2.34.1
> 

  parent reply	other threads:[~2022-11-10 12:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05  6:02 [PATCH v2] riscv: Fix detecting FPU support in standard extension Yu Chien Peter Lin
     [not found] ` <HK0PR03MB2994D5179CFED4510DB0DCCDC1019@HK0PR03MB2994.apcprd03.prod.outlook.com>
2022-11-10  7:45   ` Rick Chen
2022-11-10 12:30 ` Padmarao.Begari [this message]
2022-11-13 21:47 ` Samuel Holland
2022-11-14  8:48   ` Yu-Chien Peter Lin

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=18a73d04d0bc9d1abe3dcafd91bd4fd82898e31b.camel@microchip.com \
    --to=padmarao.begari@microchip.com \
    --cc=peterlin@andestech.com \
    --cc=samuel@sholland.org \
    --cc=u-boot@lists.denx.de \
    /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