From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Vishwanathan Date: Fri, 7 Feb 2025 13:34:08 -0800 Subject: [PATCH] Convert hartid to hart index to get scratch. In-Reply-To: <20250109233241.2491-1-cfu@mips.com> References: <20250109233241.2491-1-cfu@mips.com> Message-ID: <20250207213422.175358-1-Raj.Vishwanathan@gmail.com> List-Id: To: opensbi@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Any feedback on this patch? The hartid's may not be sequential. We need to use the index to get the scratch. Raj On Thu, Jan 9, 2025 at 4:07?PM Chao-ying Fu wrote: > > Hartid may not be sequential, so we need to use index to get scratch. > --- > lib/utils/ipi/aclint_mswi.c | 2 +- > lib/utils/timer/aclint_mtimer.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c > index 9e55078..e22903f 100644 > --- a/lib/utils/ipi/aclint_mswi.c > +++ b/lib/utils/ipi/aclint_mswi.c > @@ -87,7 +87,7 @@ 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); > + scratch = sbi_hartindex_to_scratch(sbi_hartid_to_hartindex(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 > diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c > index 3db3c3b..eb80f24 100644 > --- a/lib/utils/timer/aclint_mtimer.c > +++ b/lib/utils/timer/aclint_mtimer.c > @@ -206,7 +206,7 @@ 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); > + scratch = sbi_hartindex_to_scratch(sbi_hartid_to_hartindex(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 > -- > 2.47.1 > -- 2.43.0