diff mbox series

[1/1] clocksource/timer-risc: Add riscv_clock_shutdown callback

Message ID 20231115061811.10041-1-joshua.yeong@starfivetech.com (mailing list archive)
State Superseded
Headers show
Series [1/1] clocksource/timer-risc: Add riscv_clock_shutdown callback | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/verify_signedoff.sh

Commit Message

Joshua Yeong Nov. 15, 2023, 6:18 a.m. UTC
Add clocksource detach/shutdown callback to disable RISC-V timer interrupt when
switching out riscv timer as clock source

Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
---
 drivers/clocksource/timer-riscv.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Anup Patel Nov. 15, 2023, 7 a.m. UTC | #1
On Wed, Nov 15, 2023 at 11:49 AM Joshua Yeong
<joshua.yeong@starfivetech.com> wrote:
>
> Add clocksource detach/shutdown callback to disable RISC-V timer interrupt when
> switching out riscv timer as clock source
>
> Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
> ---
>  drivers/clocksource/timer-riscv.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> index da3071b387eb..588a05459b6a 100644
> --- a/drivers/clocksource/timer-riscv.c
> +++ b/drivers/clocksource/timer-riscv.c
> @@ -50,12 +50,19 @@ static int riscv_clock_next_event(unsigned long delta,
>         return 0;
>  }
>
> +static int riscv_clock_shutdown(struct clock_event_device *evt)
> +{
> +       sbi_set_timer(-1);

Use riscv_clock_event_stop() here.

> +       return 0;
> +}
> +
>  static unsigned int riscv_clock_event_irq;
>  static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = {
>         .name                   = "riscv_timer_clockevent",
>         .features               = CLOCK_EVT_FEAT_ONESHOT,
>         .rating                 = 100,
>         .set_next_event         = riscv_clock_next_event,
> +       .set_state_shutdown     = riscv_clock_shutdown,
>  };
>
>  /*
> --
> 2.25.1
>

Regards,
Anup
Joshua Yeong Nov. 15, 2023, 7:52 a.m. UTC | #2
Hi Anup,

On 15-Nov-23 3:00 PM, Anup Patel wrote:
> On Wed, Nov 15, 2023 at 11:49 AM Joshua Yeong
> <joshua.yeong@starfivetech.com> wrote:
>> Add clocksource detach/shutdown callback to disable RISC-V timer interrupt when
>> switching out riscv timer as clock source
>>
>> Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
>> ---
>>   drivers/clocksource/timer-riscv.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
>> index da3071b387eb..588a05459b6a 100644
>> --- a/drivers/clocksource/timer-riscv.c
>> +++ b/drivers/clocksource/timer-riscv.c
>> @@ -50,12 +50,19 @@ static int riscv_clock_next_event(unsigned long delta,
>>          return 0;
>>   }
>>
>> +static int riscv_clock_shutdown(struct clock_event_device *evt)
>> +{
>> +       sbi_set_timer(-1);
> Use riscv_clock_event_stop() here.
You mean replacing riscv_clock_shutdown as riscv_clock_event_stop?
>
>> +       return 0;
>> +}
>> +
>>   static unsigned int riscv_clock_event_irq;
>>   static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = {
>>          .name                   = "riscv_timer_clockevent",
>>          .features               = CLOCK_EVT_FEAT_ONESHOT,
>>          .rating                 = 100,
>>          .set_next_event         = riscv_clock_next_event,
>> +       .set_state_shutdown     = riscv_clock_shutdown,
>>   };
>>
>>   /*
>> --
>> 2.25.1
>>
> Regards,
> Anup
Anup Patel Nov. 15, 2023, 4:24 p.m. UTC | #3
On Wed, Nov 15, 2023 at 1:22 PM Joshua Yeong
<joshua.yeong@starfivetech.com> wrote:
>
> Hi Anup,
>
> On 15-Nov-23 3:00 PM, Anup Patel wrote:
> > On Wed, Nov 15, 2023 at 11:49 AM Joshua Yeong
> > <joshua.yeong@starfivetech.com> wrote:
> >> Add clocksource detach/shutdown callback to disable RISC-V timer interrupt when
> >> switching out riscv timer as clock source
> >>
> >> Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
> >> ---
> >>   drivers/clocksource/timer-riscv.c | 7 +++++++
> >>   1 file changed, 7 insertions(+)
> >>
> >> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> >> index da3071b387eb..588a05459b6a 100644
> >> --- a/drivers/clocksource/timer-riscv.c
> >> +++ b/drivers/clocksource/timer-riscv.c
> >> @@ -50,12 +50,19 @@ static int riscv_clock_next_event(unsigned long delta,
> >>          return 0;
> >>   }
> >>
> >> +static int riscv_clock_shutdown(struct clock_event_device *evt)
> >> +{
> >> +       sbi_set_timer(-1);
> > Use riscv_clock_event_stop() here.
> You mean replacing riscv_clock_shutdown as riscv_clock_event_stop?

I meant replacing sbi_set_timer() with riscv_clock_event_stop().

> >
> >> +       return 0;
> >> +}
> >> +
> >>   static unsigned int riscv_clock_event_irq;
> >>   static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = {
> >>          .name                   = "riscv_timer_clockevent",
> >>          .features               = CLOCK_EVT_FEAT_ONESHOT,
> >>          .rating                 = 100,
> >>          .set_next_event         = riscv_clock_next_event,
> >> +       .set_state_shutdown     = riscv_clock_shutdown,
> >>   };
> >>
> >>   /*
> >> --
> >> 2.25.1
> >>
> > Regards,
> > Anup

Regards,
Anup
diff mbox series

Patch

diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index da3071b387eb..588a05459b6a 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -50,12 +50,19 @@  static int riscv_clock_next_event(unsigned long delta,
 	return 0;
 }
 
+static int riscv_clock_shutdown(struct clock_event_device *evt)
+{
+	sbi_set_timer(-1);
+	return 0;
+}
+
 static unsigned int riscv_clock_event_irq;
 static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = {
 	.name			= "riscv_timer_clockevent",
 	.features		= CLOCK_EVT_FEAT_ONESHOT,
 	.rating			= 100,
 	.set_next_event		= riscv_clock_next_event,
+	.set_state_shutdown	= riscv_clock_shutdown,
 };
 
 /*