[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/time: move BCD_TO_BIN() uses



commit b46352f31c8fd05db3834ffe3809e02289bab3d3
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jun 30 09:38:51 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jun 30 09:38:51 2026 +0200

    x86/time: move BCD_TO_BIN() uses
    
    ... outside of __get_cmos_time()'s locked region. There's no need to hold
    the lock for these computations.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/time.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index d339111239..bc76e20777 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1257,6 +1257,7 @@ struct rtc_time {
 static bool __get_cmos_time(struct rtc_time *rtc)
 {
     s_time_t start, t1, t2;
+    bool bcd;
     unsigned int century = 0;
     unsigned long flags;
 
@@ -1283,8 +1284,12 @@ static bool __get_cmos_time(struct rtc_time *rtc)
     rtc->year = CMOS_READ(RTC_YEAR);
     if ( acpi_gbl_FADT.century && acpi_gbl_FADT.century < 0x80 )
         century = CMOS_READ(acpi_gbl_FADT.century);
-    
-    if ( RTC_ALWAYS_BCD || !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) )
+
+    bcd = RTC_ALWAYS_BCD || !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY);
+
+    spin_unlock_irqrestore(&rtc_lock, flags);
+
+    if ( bcd )
     {
         BCD_TO_BIN(rtc->sec);
         BCD_TO_BIN(rtc->min);
@@ -1294,8 +1299,6 @@ static bool __get_cmos_time(struct rtc_time *rtc)
         BCD_TO_BIN(rtc->year);
     }
 
-    spin_unlock_irqrestore(&rtc_lock, flags);
-
     if ( century )
     {
         BCD_TO_BIN(century);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.