All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Cc: "Alistair Francis" <alistair.francis@wdc.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Romain Caritey" <Romain.Caritey@microchip.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 13/16] xen/riscv: implement reprogram_timer() via SBI
Date: Wed, 4 Feb 2026 11:39:07 +0100	[thread overview]
Message-ID: <bddacebe-e84b-4ba0-959e-be078d613d03@suse.com> (raw)
In-Reply-To: <732635f43fb80daec332f78d4442b56bf5dfda98.1769099885.git.oleksii.kurochko@gmail.com>

On 22.01.2026 17:47, Oleksii Kurochko wrote:
> @@ -40,6 +43,46 @@ static void __init preinit_dt_xen_time(void)
>      cpu_khz = rate / 1000;
>  }
>  
> +int reprogram_timer(s_time_t timeout)
> +{
> +    uint64_t deadline, now;
> +    int rc;
> +
> +    if ( timeout == 0 )
> +    {
> +        /* Disable timers */
> +        csr_clear(CSR_SIE, BIT(IRQ_S_TIMER, UL));

For here and below: Is it guaranteed that the SIE bit is writable? The privileged
spec looks to have provisions for the case that it isn't (together with the
corresponding SIP bit).

As to the comment - why plural here, when ...

> +        return 1;
> +    }
> +
> +    deadline = ns_to_ticks(timeout) + boot_clock_cycles;
> +    now = get_cycles();
> +    if ( deadline <= now )
> +        return 0;
> +
> +    /* Enable timer */
> +    csr_set(CSR_SIE, BIT(IRQ_S_TIMER, UL));

... it's singular here? Also in both cases, isn't it the timer interrupt you
enable, not the timer itself?

> +    /*
> +     * TODO: When the SSTC extension is supported, it would be preferable to
> +     *       use the supervisor timer registers directly here for better
> +     *       performance, since an SBI call and context switch would no longer
> +     *       be required.

I think you mean a mode switch here, not a context one?

Jan

> +     *       This would also reduce reliance on a specific SBI implementation.
> +     *       For example, it is not ideal to panic() if sbi_set_timer() returns
> +     *       a non-zero value. Currently it can return 0 or -ENOSUPP, and
> +     *       without SSTC we still need an implementation because only the
> +     *       M-mode timer is available, and it can only be programmed in
> +     *       M-mode.
> +     */
> +    if ( (rc = sbi_set_timer(deadline)) )
> +        panic("%s: timer wasn't set because: %d\n", __func__, rc);
> +
> +    return 1;
> +}
> +
>  void __init preinit_xen_time(void)
>  {
>      if ( acpi_disabled )



  parent reply	other threads:[~2026-02-04 10:39 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 16:47 [PATCH v2 00/16] xen/riscv: introduce vtimer related things Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 01/16] xen/riscv: introduce struct arch_vcpu Oleksii Kurochko
2026-01-26 11:41   ` Jan Beulich
2026-01-26 12:30     ` Oleksii Kurochko
2026-01-26 12:53       ` Jan Beulich
2026-01-26 14:22         ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 02/16] xen/riscv: implement arch_vcpu_{create,destroy}() Oleksii Kurochko
2026-01-23 11:30   ` Teddy Astie
2026-01-26  9:00     ` Oleksii Kurochko
2026-01-26 11:47       ` Jan Beulich
2026-01-26 12:07         ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 03/16] xen/riscv: implement vcpu_csr_init() Oleksii Kurochko
2026-01-24 22:44   ` Teddy Astie
2026-01-26  8:36     ` Jan Beulich
2026-01-26  9:47       ` Oleksii Kurochko
2026-01-26  9:54         ` Jan Beulich
2026-01-26  9:39     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 04/16] xen/riscv: introduce tracking of pending vCPU interrupts, part 1 Oleksii Kurochko
2026-01-29 16:44   ` Jan Beulich
2026-02-02 10:16     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 05/16] xen/riscv: introduce tracking of pending vCPU interrupts, part 2 Oleksii Kurochko
2026-01-29 17:01   ` Jan Beulich
2026-02-02 10:50     ` Oleksii Kurochko
2026-02-02 14:22       ` Jan Beulich
2026-01-22 16:47 ` [PATCH v2 06/16] xen/time: move ticks<->ns helpers to common code Oleksii Kurochko
2026-01-29  8:48   ` Jan Beulich
2026-02-04  8:13     ` Jan Beulich
2026-02-04  9:00       ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 07/16] xen/riscv: introduce basic vtimer infrastructure for guests Oleksii Kurochko
2026-02-03 15:47   ` Jan Beulich
2026-02-03 16:55     ` Oleksii Kurochko
2026-02-03 17:04       ` Jan Beulich
2026-01-22 16:47 ` [PATCH v2 08/16] xen/riscv: add temporary stub for smp_send_event_check_mask() Oleksii Kurochko
2026-01-29 16:32   ` Jan Beulich
2026-01-29 16:46     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 09/16] xen/riscv: introduce vcpu_kick() implementation Oleksii Kurochko
2026-02-06 16:36   ` Oleksii Kurochko
2026-02-09  9:07     ` Jan Beulich
2026-02-09  9:40       ` Oleksii Kurochko
2026-02-09  9:51         ` Jan Beulich
2026-02-09 12:35           ` Oleksii Kurochko
2026-02-09 12:54             ` Jan Beulich
2026-01-22 16:47 ` [PATCH v2 10/16] xen/riscv: add vtimer context switch helpers Oleksii Kurochko
2026-02-03 16:43   ` Jan Beulich
2026-02-03 16:56     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 11/16] xen/riscv: implement SBI legacy SET_TIMER support for guests Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 12/16] xen/riscv: introduce sbi_set_timer() Oleksii Kurochko
2026-02-03 17:02   ` Jan Beulich
2026-02-04  9:29     ` Oleksii Kurochko
2026-02-04 10:11       ` Jan Beulich
2026-02-04  6:50   ` Jan Beulich
2026-02-04  9:36     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 13/16] xen/riscv: implement reprogram_timer() via SBI Oleksii Kurochko
2026-01-24 23:13   ` Teddy Astie
2026-01-26 10:20     ` Oleksii Kurochko
2026-02-04 10:39   ` Jan Beulich [this message]
2026-02-05 16:25     ` Oleksii Kurochko
2026-01-22 16:47 ` [PATCH v2 14/16] xen/riscv: handle hypervisor timer interrupts Oleksii Kurochko
2026-02-04 10:42   ` Jan Beulich
2026-01-22 16:47 ` [PATCH v2 15/16] xen/riscv: init tasklet subsystem Oleksii Kurochko
2026-01-29 16:33   ` Jan Beulich
2026-01-22 16:47 ` [PATCH v2 16/16] xen/riscv: implement sync_vcpu_execstate() Oleksii Kurochko
2026-02-04 10:49   ` Jan Beulich
2026-02-05 16:51     ` Oleksii Kurochko
2026-02-05 16:53       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bddacebe-e84b-4ba0-959e-be078d613d03@suse.com \
    --to=jbeulich@suse.com \
    --cc=Romain.Caritey@microchip.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=connojdavis@gmail.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.