mbox series

[V2,0/3] fix cpu softlock when using T-HEAD c9xx pmu

Message ID IA1PR20MB495351FBE86C63ECBB8764C7BB14A@IA1PR20MB4953.namprd20.prod.outlook.com
Headers show
Series fix cpu softlock when using T-HEAD c9xx pmu | expand

Message

Inochi Amaoto Aug. 15, 2023, 9:39 a.m. UTC
These patches fix the system hang issue caused by using perf tool on
T-HEAD c9xx related platforms.

These patch solves two issues for T-HEAD c9xx pmu:
When detecting features of PMU, MHPMCOUNTER3 is written to all 1s. This
will cause an unexpected overflow interrupt before starting the PMU in
T-HEAD cores.

Another thing is the T-HEAD c9xx pmu is not a standart pmu, especially
in interrupt process and access delegation. For interrupt process, the
T-HEAD pmu uses MCOUNTERINTEN and MCOUNTEROF to control and identify the
interrupt. For access delegation. It needs to set MCOUNTERWEN to allow
S-mode to access related CSRs.

Changed from V1:
1. fix the hang issue when using perf with high profile frequency.
2. optimze the performance of irq process of T-HEAD c9xx pmu.

Inochi Amaoto (3):
  lib: sbi_pmu: ensure update hpm counter before starting counting
  platform: generic: allwinner: fix OF process for T-HEAD c9xx pmu
  lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled

 lib/sbi/sbi_pmu.c                      | 17 +++++++++++------
 platform/generic/allwinner/sun20i-d1.c | 25 +++++++++++++++----------
 2 files changed, 26 insertions(+), 16 deletions(-)

--
2.41.0

Comments

Anup Patel Sept. 6, 2023, 10:59 a.m. UTC | #1
Hi Guo,

On Tue, Aug 15, 2023 at 3:09 PM Inochi Amaoto <inochiama@outlook.com> wrote:
>
> These patches fix the system hang issue caused by using perf tool on
> T-HEAD c9xx related platforms.
>
> These patch solves two issues for T-HEAD c9xx pmu:
> When detecting features of PMU, MHPMCOUNTER3 is written to all 1s. This
> will cause an unexpected overflow interrupt before starting the PMU in
> T-HEAD cores.
>
> Another thing is the T-HEAD c9xx pmu is not a standart pmu, especially
> in interrupt process and access delegation. For interrupt process, the
> T-HEAD pmu uses MCOUNTERINTEN and MCOUNTEROF to control and identify the
> interrupt. For access delegation. It needs to set MCOUNTERWEN to allow
> S-mode to access related CSRs.
>
> Changed from V1:
> 1. fix the hang issue when using perf with high profile frequency.
> 2. optimze the performance of irq process of T-HEAD c9xx pmu.
>
> Inochi Amaoto (3):
>   lib: sbi_pmu: ensure update hpm counter before starting counting
>   platform: generic: allwinner: fix OF process for T-HEAD c9xx pmu
>   lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled

I intend to merge this series by end-of-week.

Please let me know if you want to hold-off merging this.

Regards,
Anup

>
>  lib/sbi/sbi_pmu.c                      | 17 +++++++++++------
>  platform/generic/allwinner/sun20i-d1.c | 25 +++++++++++++++----------
>  2 files changed, 26 insertions(+), 16 deletions(-)
>
> --
> 2.41.0
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Guo Ren Sept. 8, 2023, 2:37 a.m. UTC | #2
On Wed, Sep 6, 2023 at 6:59 PM Anup Patel <anup@brainfault.org> wrote:
>
> Hi Guo,
>
> On Tue, Aug 15, 2023 at 3:09 PM Inochi Amaoto <inochiama@outlook.com> wrote:
> >
> > These patches fix the system hang issue caused by using perf tool on
> > T-HEAD c9xx related platforms.
> >
> > These patch solves two issues for T-HEAD c9xx pmu:
> > When detecting features of PMU, MHPMCOUNTER3 is written to all 1s. This
> > will cause an unexpected overflow interrupt before starting the PMU in
> > T-HEAD cores.
> >
> > Another thing is the T-HEAD c9xx pmu is not a standart pmu, especially
> > in interrupt process and access delegation. For interrupt process, the
> > T-HEAD pmu uses MCOUNTERINTEN and MCOUNTEROF to control and identify the
> > interrupt. For access delegation. It needs to set MCOUNTERWEN to allow
> > S-mode to access related CSRs.
> >
> > Changed from V1:
> > 1. fix the hang issue when using perf with high profile frequency.
> > 2. optimze the performance of irq process of T-HEAD c9xx pmu.
> >
> > Inochi Amaoto (3):
> >   lib: sbi_pmu: ensure update hpm counter before starting counting
> >   platform: generic: allwinner: fix OF process for T-HEAD c9xx pmu
> >   lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled
>
> I intend to merge this series by end-of-week.
>
> Please let me know if you want to hold-off merging this.
This is okay for me, thx for merging.

>
> Regards,
> Anup
>
> >
> >  lib/sbi/sbi_pmu.c                      | 17 +++++++++++------
> >  platform/generic/allwinner/sun20i-d1.c | 25 +++++++++++++++----------
> >  2 files changed, 26 insertions(+), 16 deletions(-)
> >
> > --
> > 2.41.0
> >
> >
> > --
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi
Samuel Holland Sept. 9, 2023, 11:32 p.m. UTC | #3
On 8/15/23 04:39, Inochi Amaoto wrote:
> These patches fix the system hang issue caused by using perf tool on
> T-HEAD c9xx related platforms.
> 
> These patch solves two issues for T-HEAD c9xx pmu:
> When detecting features of PMU, MHPMCOUNTER3 is written to all 1s. This
> will cause an unexpected overflow interrupt before starting the PMU in
> T-HEAD cores.
> 
> Another thing is the T-HEAD c9xx pmu is not a standart pmu, especially
> in interrupt process and access delegation. For interrupt process, the
> T-HEAD pmu uses MCOUNTERINTEN and MCOUNTEROF to control and identify the
> interrupt. For access delegation. It needs to set MCOUNTERWEN to allow
> S-mode to access related CSRs.
> 
> Changed from V1:
> 1. fix the hang issue when using perf with high profile frequency.
> 2. optimze the performance of irq process of T-HEAD c9xx pmu.
> 
> Inochi Amaoto (3):
>   lib: sbi_pmu: ensure update hpm counter before starting counting
>   platform: generic: allwinner: fix OF process for T-HEAD c9xx pmu
>   lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled
> 
>  lib/sbi/sbi_pmu.c                      | 17 +++++++++++------
>  platform/generic/allwinner/sun20i-d1.c | 25 +++++++++++++++----------
>  2 files changed, 26 insertions(+), 16 deletions(-)

For the series:
Tested-by: Samuel Holland <samuel@sholland.org>
Anup Patel Sept. 10, 2023, 5:46 a.m. UTC | #4
On Sun, Sep 10, 2023 at 5:03 AM Samuel Holland <samuel@sholland.org> wrote:
>
> On 8/15/23 04:39, Inochi Amaoto wrote:
> > These patches fix the system hang issue caused by using perf tool on
> > T-HEAD c9xx related platforms.
> >
> > These patch solves two issues for T-HEAD c9xx pmu:
> > When detecting features of PMU, MHPMCOUNTER3 is written to all 1s. This
> > will cause an unexpected overflow interrupt before starting the PMU in
> > T-HEAD cores.
> >
> > Another thing is the T-HEAD c9xx pmu is not a standart pmu, especially
> > in interrupt process and access delegation. For interrupt process, the
> > T-HEAD pmu uses MCOUNTERINTEN and MCOUNTEROF to control and identify the
> > interrupt. For access delegation. It needs to set MCOUNTERWEN to allow
> > S-mode to access related CSRs.
> >
> > Changed from V1:
> > 1. fix the hang issue when using perf with high profile frequency.
> > 2. optimze the performance of irq process of T-HEAD c9xx pmu.
> >
> > Inochi Amaoto (3):
> >   lib: sbi_pmu: ensure update hpm counter before starting counting
> >   platform: generic: allwinner: fix OF process for T-HEAD c9xx pmu
> >   lib: sbi_pmu: keep overflow interrupt of stopped hpm counter disabled
> >
> >  lib/sbi/sbi_pmu.c                      | 17 +++++++++++------
> >  platform/generic/allwinner/sun20i-d1.c | 25 +++++++++++++++----------
> >  2 files changed, 26 insertions(+), 16 deletions(-)
>
> For the series:
> Tested-by: Samuel Holland <samuel@sholland.org>

Thanks for testing this series.

Applied this series to the riscv/opensbi repo.

Thanks,
Anup