All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms()
@ 2024-08-12 14:13 Heinrich Schuchardt
  2024-08-13 13:52 ` Daniel Kiper via Grub-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2024-08-12 14:13 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: GRUB development, Heinrich Schuchardt

The cycle register is not guaranteed to count at constant frequency.
If it is counting at all depends on the state the performance monitoring
unit.

Use the time register to measure time.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 grub-core/kern/riscv/efi/init.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c
index 38795fe67..519e4625a 100644
--- a/grub-core/kern/riscv/efi/init.c
+++ b/grub-core/kern/riscv/efi/init.c
@@ -33,16 +33,15 @@ grub_efi_get_time_ms (void)
   grub_uint64_t tmr;
 
 #if __riscv_xlen == 64
-  asm volatile ("rdcycle %0" : "=r" (tmr));
+  asm volatile ("rdtime %0" : "=r"(tmr));
 #else
   grub_uint32_t lo, hi, tmp;
-  asm volatile (
-    "1:\n"
-    "rdcycleh %0\n"
-    "rdcycle %1\n"
-    "rdcycleh %2\n"
-    "bne %0, %2, 1b"
-    : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
+  asm volatile ("1:\n"
+                "rdtimeh %0\n"
+                "rdtime %1\n"
+                "rdtimeh %2\n"
+                "bne %0, %2, 1b"
+                : "=&r"(hi), "=&r"(lo), "=&r"(tmp));
   tmr = ((grub_uint64_t)hi << 32) | lo;
 #endif
 
-- 
2.45.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms()
  2024-08-12 14:13 [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms() Heinrich Schuchardt
@ 2024-08-13 13:52 ` Daniel Kiper via Grub-devel
  2024-09-10  9:54   ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper via Grub-devel @ 2024-08-13 13:52 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Daniel Kiper, GRUB development

On Mon, Aug 12, 2024 at 04:13:18PM +0200, Heinrich Schuchardt wrote:
> The cycle register is not guaranteed to count at constant frequency.
> If it is counting at all depends on the state the performance monitoring
> unit.
>
> Use the time register to measure time.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms()
  2024-08-13 13:52 ` Daniel Kiper via Grub-devel
@ 2024-09-10  9:54   ` Heinrich Schuchardt
  2024-09-10 12:59     ` Daniel Kiper via Grub-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2024-09-10  9:54 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: GRUB development

On 13.08.24 15:52, Daniel Kiper wrote:
> On Mon, Aug 12, 2024 at 04:13:18PM +0200, Heinrich Schuchardt wrote:
>> The cycle register is not guaranteed to count at constant frequency.
>> If it is counting at all depends on the state the performance monitoring
>> unit.
>>
>> Use the time register to measure time.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> 
> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
> 
> Daniel

Hello Daniel,

Thanks for your review. Does anything prevent merging the patch?

Best regards

Heinrich

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms()
  2024-09-10  9:54   ` Heinrich Schuchardt
@ 2024-09-10 12:59     ` Daniel Kiper via Grub-devel
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Kiper via Grub-devel @ 2024-09-10 12:59 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Daniel Kiper, GRUB development

On Tue, Sep 10, 2024 at 11:54:20AM +0200, Heinrich Schuchardt wrote:
> On 13.08.24 15:52, Daniel Kiper wrote:
> > On Mon, Aug 12, 2024 at 04:13:18PM +0200, Heinrich Schuchardt wrote:
> > > The cycle register is not guaranteed to count at constant frequency.
> > > If it is counting at all depends on the state the performance monitoring
> > > unit.
> > >
> > > Use the time register to measure time.
> > >
> > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >
> > Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
> >
> > Daniel
>
> Hello Daniel,
>
> Thanks for your review. Does anything prevent merging the patch?

Oh, I skipped it by mistake. Sorry about that. I have added it to the queue.

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-10 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 14:13 [PATCH 1/1] riscv: use time register in grub_efi_get_time_ms() Heinrich Schuchardt
2024-08-13 13:52 ` Daniel Kiper via Grub-devel
2024-09-10  9:54   ` Heinrich Schuchardt
2024-09-10 12:59     ` Daniel Kiper via Grub-devel

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.