Message ID | 20240219071406.41703-1-joshua.yeong@starfivetech.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] lib: sbi_hsm: Restor hart state to stop when fails to start | expand |
在 2024-02-19星期一的 15:14 +0800,Joshua Yeong写道: > Hart state should change back to hart stop when hsm_device_hart_start() > or sbi_ipi_raw_send() fails to perform hart start. > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > --- > lib/sbi/sbi_hsm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c > index 3d60ceb..be48d64 100644 > --- a/lib/sbi/sbi_hsm.c > +++ b/lib/sbi/sbi_hsm.c > @@ -360,6 +360,10 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, > > if (!rc) > return 0; > + > + /* If it fails to start, change hart state back to stop */ > + __sbi_hsm_hart_change_state(hdata, SBI_HSM_STATE_START_PENDING, > + SBI_HSM_STATE_STOPPED); This is not needed. Because if hdata->state is not equal to SBI_HSM_STATE_STOPPED, SBI_HSM_STATE_START_PENDING will not be written. Regards, Xiang W > err: > hsm_start_ticket_release(hdata); > return rc; > -- > 2.25.1 > >
On Mon, Feb 19, 2024 at 05:39:26PM +0800, Joshua Yeong <joshua.yeong@starfivetech.com> wrote: > 在 2024-02-19星期一的 15:14 +0800,Joshua Yeong写道: > > Hart state should change back to hart stop when > > hsm_device_hart_start() or sbi_ipi_raw_send() fails to perform hart start. > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > --- > > lib/sbi/sbi_hsm.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index > > 3d60ceb..be48d64 100644 > > --- a/lib/sbi/sbi_hsm.c > > +++ b/lib/sbi/sbi_hsm.c > > @@ -360,6 +360,10 @@ int sbi_hsm_hart_start(struct sbi_scratch > > *scratch, > > > > if (!rc) > > return 0; > > + > > + /* If it fails to start, change hart state back to stop */ > > + __sbi_hsm_hart_change_state(hdata, > SBI_HSM_STATE_START_PENDING, > > + SBI_HSM_STATE_STOPPED); > > This is not needed. Because if hdata->state is not equal to > SBI_HSM_STATE_STOPPED, SBI_HSM_STATE_START_PENDING will not be > written. > > Regards, > Xiang W The scenario is that the Hart is in SBI_HSM_STATE_STOPPED and then it switches to SBI_HSM_STATE_START_PENDING, but it got stuck in SBI_HSM_STATE_START_PENDING if it fails to start. The hart's state has impact on other process where hart's state is taken into consideration, for example system suspend. Regards, Joshua > > > err: > > hsm_start_ticket_release(hdata); > > return rc; > > -- > > 2.25.1 > > > >
在 2024-02-19星期一的 09:44 +0000,Joshua Yeong写道: > On Mon, Feb 19, 2024 at 05:39:26PM +0800, Joshua Yeong <joshua.yeong@starfivetech.com> wrote: > > 在 2024-02-19星期一的 15:14 +0800,Joshua Yeong写道: > > > Hart state should change back to hart stop when > > > hsm_device_hart_start() or sbi_ipi_raw_send() fails to perform hart start. > > > > > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> > > > --- > > > lib/sbi/sbi_hsm.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index > > > 3d60ceb..be48d64 100644 > > > --- a/lib/sbi/sbi_hsm.c > > > +++ b/lib/sbi/sbi_hsm.c > > > @@ -360,6 +360,10 @@ int sbi_hsm_hart_start(struct sbi_scratch > > > *scratch, > > > > > > if (!rc) > > > return 0; > > > + > > > + /* If it fails to start, change hart state back to stop */ > > > + __sbi_hsm_hart_change_state(hdata, > > SBI_HSM_STATE_START_PENDING, > > > + SBI_HSM_STATE_STOPPED); > > > > This is not needed. Because if hdata->state is not equal to > > SBI_HSM_STATE_STOPPED, SBI_HSM_STATE_START_PENDING will not be > > written. > > > > Regards, > > Xiang W > > The scenario is that the Hart is in SBI_HSM_STATE_STOPPED and then it switches to SBI_HSM_STATE_START_PENDING, > but it got stuck in SBI_HSM_STATE_START_PENDING if it fails to start. The hart's state has impact on > other process where hart's state is taken into consideration, for example system suspend. Sorry. I mistakenly thought that these codes were added after the err tag. Signed-off-by: Xiang W <wxjstz@126.com> > > Regards, > Joshua > > > > > > err: > > > hsm_start_ticket_release(hdata); > > > return rc; > > > -- > > > 2.25.1 > > > > > > >
On Mon, Feb 19, 2024 at 12:44 PM Joshua Yeong <joshua.yeong@starfivetech.com> wrote: > > Hart state should change back to hart stop when hsm_device_hart_start() > or sbi_ipi_raw_send() fails to perform hart start. > > Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> LGTM. Reviewed-by: Anup Patel <anup@brainfault.org> Applied this patch to the riscv/opensbi repo. Thanks, Anup > --- > lib/sbi/sbi_hsm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c > index 3d60ceb..be48d64 100644 > --- a/lib/sbi/sbi_hsm.c > +++ b/lib/sbi/sbi_hsm.c > @@ -360,6 +360,10 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, > > if (!rc) > return 0; > + > + /* If it fails to start, change hart state back to stop */ > + __sbi_hsm_hart_change_state(hdata, SBI_HSM_STATE_START_PENDING, > + SBI_HSM_STATE_STOPPED); > err: > hsm_start_ticket_release(hdata); > return rc; > -- > 2.25.1 > > > -- > opensbi mailing list > opensbi@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/opensbi
diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 3d60ceb..be48d64 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -360,6 +360,10 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, if (!rc) return 0; + + /* If it fails to start, change hart state back to stop */ + __sbi_hsm_hart_change_state(hdata, SBI_HSM_STATE_START_PENDING, + SBI_HSM_STATE_STOPPED); err: hsm_start_ticket_release(hdata); return rc;
Hart state should change back to hart stop when hsm_device_hart_start() or sbi_ipi_raw_send() fails to perform hart start. Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com> --- lib/sbi/sbi_hsm.c | 4 ++++ 1 file changed, 4 insertions(+)