From: Thomas Huth <thuth@redhat.com>
To: Nicholas Piggin <npiggin@gmail.com>, kvm@vger.kernel.org
Cc: Laurent Vivier <lvivier@redhat.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [kvm-unit-tests PATCH 3/7] powerpc: abstract H_CEDE calls into a sleep() function
Date: Fri, 17 Mar 2023 14:01:14 +0100 [thread overview]
Message-ID: <d65643cf-ea6e-7263-8263-52a6c4223aac@redhat.com> (raw)
In-Reply-To: <20230317123614.3687163-3-npiggin@gmail.com>
On 17/03/2023 13.36, Nicholas Piggin wrote:
> This consolidates several implementations, and it no longer leaves
> MSR[EE] enabled after the decrementer interrupt is handled, but
> rather disables it on return.
>
> The handler no longer allows a continuous ticking, but rather dec
> has to be re-armed and EE re-enabled (e.g., via H_CEDE hcall) each
> time.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
...
> diff --git a/lib/powerpc/processor.c b/lib/powerpc/processor.c
> index ec85b9d..f1fb50f 100644
> --- a/lib/powerpc/processor.c
> +++ b/lib/powerpc/processor.c
> @@ -10,6 +10,8 @@
> #include <asm/ptrace.h>
> #include <asm/setup.h>
> #include <asm/barrier.h>
> +#include <asm/hcall.h>
> +#include <asm/handlers.h>
>
> static struct {
> void (*func)(struct pt_regs *, void *data);
> @@ -54,3 +56,32 @@ void udelay(uint64_t us)
> {
> delay((us * tb_hz) / 1000000);
> }
> +
> +void sleep(uint64_t cycles)
When I see a sleep() in a C program, I automatically assume that it's
parameter is "seconds", so having a sleep() function here that is taking
cycles as a parameter is confusing. Could you please name the function
differently?
> +{
> + uint64_t start, end, now;
> +
> + start = now = get_tb();
> + end = start + cycles;
> +
> + while (end > now) {
> + uint64_t left = end - now;
> +
> + /* Could support large decrementer */
> + if (left > 0x7fffffff)
> + left = 0x7fffffff;
> +
> + asm volatile ("mtdec %0" : : "r" (left));
> + handle_exception(0x900, &dec_handler_oneshot, NULL);
> + if (hcall(H_CEDE) != H_SUCCESS) {
> + printf("H_CEDE failed\n");
> + abort();
> + }
> + handle_exception(0x900, NULL, NULL);
> +
> + if (left < 0x7fffffff)
> + break;
Shouldn't that be covered by the "end > now" in the while loop condition
check already?
> + now = get_tb();
> + }
> +}
Thomas
next prev parent reply other threads:[~2023-03-17 13:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 12:36 [kvm-unit-tests PATCH 1/7] MAINTAINERS: Update powerpc list Nicholas Piggin
2023-03-17 12:36 ` [kvm-unit-tests PATCH 2/7] powerpc: add local variant of SPR test Nicholas Piggin
2023-03-17 12:52 ` Thomas Huth
2023-03-17 12:36 ` [kvm-unit-tests PATCH 3/7] powerpc: abstract H_CEDE calls into a sleep() function Nicholas Piggin
2023-03-17 13:01 ` Thomas Huth [this message]
2023-03-17 12:36 ` [kvm-unit-tests PATCH 4/7] powerpc: Add ISA v3.1 (POWER10) support to SPR test Nicholas Piggin
2023-03-23 11:55 ` Thomas Huth
2023-03-17 12:36 ` [kvm-unit-tests PATCH 5/7] powerpc: Indirect SPR accessor functions Nicholas Piggin
2023-03-17 12:36 ` [kvm-unit-tests PATCH 6/7] powerpc/sprs: Specify SPRs with data rather than code Nicholas Piggin
2023-03-17 12:36 ` [kvm-unit-tests PATCH 7/7] powerpc/spapr_vpa: Add basic VPA tests Nicholas Piggin
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=d65643cf-ea6e-7263-8263-52a6c4223aac@redhat.com \
--to=thuth@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lvivier@redhat.com \
--cc=npiggin@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).