OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers
@ 2023-07-05  6:45 Anup Patel
  2023-07-06  3:19 ` Xiang W
  2023-07-09  5:40 ` Anup Patel
  0 siblings, 2 replies; 3+ messages in thread
From: Anup Patel @ 2023-07-05  6:45 UTC (permalink / raw)
  To: opensbi

The cold_init() functions of ACLINT drivers should skip the HART
is sbi_hartid_to_scratch() returns NULL because we might be dealing
with a HART that is disabled in the device tree.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/utils/ipi/aclint_mswi.c     | 7 ++++++-
 lib/utils/timer/aclint_mtimer.c | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c
index f47b3bc..140a49b 100644
--- a/lib/utils/ipi/aclint_mswi.c
+++ b/lib/utils/ipi/aclint_mswi.c
@@ -101,8 +101,13 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
 	/* Update MSWI pointer in scratch space */
 	for (i = 0; i < mswi->hart_count; i++) {
 		scratch = sbi_hartid_to_scratch(mswi->first_hartid + i);
+		/*
+		 * We don't need to fail if scratch pointer is not available
+		 * because we might be dealing with hartid of a HART disabled
+		 * in the device tree.
+		 */
 		if (!scratch)
-			return SBI_ENOENT;
+			continue;
 		mswi_set_hart_data_ptr(scratch, mswi);
 	}
 
diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c
index 13af5d8..271e625 100644
--- a/lib/utils/timer/aclint_mtimer.c
+++ b/lib/utils/timer/aclint_mtimer.c
@@ -219,8 +219,13 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
 	/* Update MTIMER pointer in scratch space */
 	for (i = 0; i < mt->hart_count; i++) {
 		scratch = sbi_hartid_to_scratch(mt->first_hartid + i);
+		/*
+		 * We don't need to fail if scratch pointer is not available
+		 * because we might be dealing with hartid of a HART disabled
+		 * in the device tree.
+		 */
 		if (!scratch)
-			return SBI_ENOENT;
+			continue;
 		mtimer_set_hart_data_ptr(scratch, mt);
 	}
 
-- 
2.34.1



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

* [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers
  2023-07-05  6:45 [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers Anup Patel
@ 2023-07-06  3:19 ` Xiang W
  2023-07-09  5:40 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Xiang W @ 2023-07-06  3:19 UTC (permalink / raw)
  To: opensbi

? 2023-07-05???? 12:15 +0530?Anup Patel???
> The cold_init() functions of ACLINT drivers should skip the HART
> is sbi_hartid_to_scratch() returns NULL because we might be dealing
> with a HART that is disabled in the device tree.
> 
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Look good to me

Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> ?lib/utils/ipi/aclint_mswi.c???? | 7 ++++++-
> ?lib/utils/timer/aclint_mtimer.c | 7 ++++++-
> ?2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c
> index f47b3bc..140a49b 100644
> --- a/lib/utils/ipi/aclint_mswi.c
> +++ b/lib/utils/ipi/aclint_mswi.c
> @@ -101,8 +101,13 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
> ????????/* Update MSWI pointer in scratch space */
> ????????for (i = 0; i < mswi->hart_count; i++) {
> ????????????????scratch = sbi_hartid_to_scratch(mswi->first_hartid + i);
> +???????????????/*
> +??????????????? * We don't need to fail if scratch pointer is not available
> +??????????????? * because we might be dealing with hartid of a HART disabled
> +??????????????? * in the device tree.
> +??????????????? */
> ????????????????if (!scratch)
> -???????????????????????return SBI_ENOENT;
> +???????????????????????continue;
> ????????????????mswi_set_hart_data_ptr(scratch, mswi);
> ????????}
> ?
> diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c
> index 13af5d8..271e625 100644
> --- a/lib/utils/timer/aclint_mtimer.c
> +++ b/lib/utils/timer/aclint_mtimer.c
> @@ -219,8 +219,13 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
> ????????/* Update MTIMER pointer in scratch space */
> ????????for (i = 0; i < mt->hart_count; i++) {
> ????????????????scratch = sbi_hartid_to_scratch(mt->first_hartid + i);
> +???????????????/*
> +??????????????? * We don't need to fail if scratch pointer is not available
> +??????????????? * because we might be dealing with hartid of a HART disabled
> +??????????????? * in the device tree.
> +??????????????? */
> ????????????????if (!scratch)
> -???????????????????????return SBI_ENOENT;
> +???????????????????????continue;
> ????????????????mtimer_set_hart_data_ptr(scratch, mt);
> ????????}
> ?
> -- 
> 2.34.1
> 
> 


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

* [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers
  2023-07-05  6:45 [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers Anup Patel
  2023-07-06  3:19 ` Xiang W
@ 2023-07-09  5:40 ` Anup Patel
  1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2023-07-09  5:40 UTC (permalink / raw)
  To: opensbi

On Wed, Jul 5, 2023 at 12:15?PM Anup Patel <apatel@ventanamicro.com> wrote:
>
> The cold_init() functions of ACLINT drivers should skip the HART
> is sbi_hartid_to_scratch() returns NULL because we might be dealing
> with a HART that is disabled in the device tree.
>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>

Applied this patch to the riscv/opensbi repo.

Regards,
Anup

> ---
>  lib/utils/ipi/aclint_mswi.c     | 7 ++++++-
>  lib/utils/timer/aclint_mtimer.c | 7 ++++++-
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c
> index f47b3bc..140a49b 100644
> --- a/lib/utils/ipi/aclint_mswi.c
> +++ b/lib/utils/ipi/aclint_mswi.c
> @@ -101,8 +101,13 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
>         /* Update MSWI pointer in scratch space */
>         for (i = 0; i < mswi->hart_count; i++) {
>                 scratch = sbi_hartid_to_scratch(mswi->first_hartid + i);
> +               /*
> +                * We don't need to fail if scratch pointer is not available
> +                * because we might be dealing with hartid of a HART disabled
> +                * in the device tree.
> +                */
>                 if (!scratch)
> -                       return SBI_ENOENT;
> +                       continue;
>                 mswi_set_hart_data_ptr(scratch, mswi);
>         }
>
> diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c
> index 13af5d8..271e625 100644
> --- a/lib/utils/timer/aclint_mtimer.c
> +++ b/lib/utils/timer/aclint_mtimer.c
> @@ -219,8 +219,13 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
>         /* Update MTIMER pointer in scratch space */
>         for (i = 0; i < mt->hart_count; i++) {
>                 scratch = sbi_hartid_to_scratch(mt->first_hartid + i);
> +               /*
> +                * We don't need to fail if scratch pointer is not available
> +                * because we might be dealing with hartid of a HART disabled
> +                * in the device tree.
> +                */
>                 if (!scratch)
> -                       return SBI_ENOENT;
> +                       continue;
>                 mtimer_set_hart_data_ptr(scratch, mt);
>         }
>
> --
> 2.34.1
>


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

end of thread, other threads:[~2023-07-09  5:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05  6:45 [PATCH] lib: utils: Fix sbi_hartid_to_scratch() usage in ACLINT drivers Anup Patel
2023-07-06  3:19 ` Xiang W
2023-07-09  5:40 ` Anup Patel

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