xiaoxiang781216 commented on code in PR #15413:
URL: https://github.com/apache/nuttx/pull/15413#discussion_r1903193518


##########
arch/x86_64/src/intel64/intel64_rtc.c:
##########
@@ -140,11 +145,14 @@ int up_rtc_initialize(void)
 
 int up_rtc_gettime(struct timespec *tp)
 {
+  irqstate_t flags;
   uint64_t tmp;
 
+  flags = spin_lock_irqsave(&g_rtc_lock);

Review Comment:
   move before line 94, or use atomic operation directly



##########
arch/arm/src/sam34/sam_rtc.c:
##########
@@ -759,11 +764,14 @@ int up_rtc_gettime(struct timespec *tp)
 {
   /* This is a hack to emulate a high resolution rtc using the rtt */
 
+  irqstate_t flags;
   uint32_t rtc_cal;
   uint32_t rtc_tim;
   uint32_t rtt_val;
   struct tm t;
 
+  flags = spin_lock_irqsave(&g_rtc_lock);
+  sched_lock();

Review Comment:
   remove sched_lock



##########
arch/arm/src/sam34/sam_rtc.c:
##########
@@ -794,6 +802,8 @@ int up_rtc_gettime(struct timespec *tp)
   tp->tv_nsec = (((rtt_val - g_rtt_offset) & (CONFIG_RTC_FREQUENCY - 1)) *
                    1000000000ull) / CONFIG_RTC_FREQUENCY;
 
+  spin_unlock_irqrestore(&g_rtc_lock, flags);

Review Comment:
   move before line 785



##########
arch/renesas/src/rx65n/rx65n_rtc.c:
##########
@@ -476,6 +480,9 @@ int up_rtc_gettime(struct timespec *tp)
   uint8_t regval;
   struct tm t;
 
+  flags = spin_lock_irqsave(&g_rtc_lock);
+  sched_lock();

Review Comment:
   don't need sched_lock



##########
arch/arm/src/max326xx/max32660/max32660_rtc.c:
##########
@@ -424,6 +427,7 @@ int up_rtc_gettime(struct timespec *tp)
 
   tp->tv_sec  = sec;
   tp->tv_nsec = (long)tmp;
+  spin_unlock_irqrestore(&g_rtc_lock, flags);

Review Comment:
   move before line 424



##########
arch/renesas/src/rx65n/rx65n_rtc.c:
##########
@@ -916,7 +926,8 @@ int rx65n_rtc_setalarm(struct alm_setalarm_s *alminfo)
 
   /* Is there already something waiting on the ALARM? */
 
-  flags = enter_critical_section();
+  flags = spin_lock_irqsave(&g_rtc_lock);
+  sched_lock();

Review Comment:
   why need sched_lock



##########
arch/arm/src/cxd56xx/cxd56_rtc.c:
##########
@@ -410,6 +413,8 @@ int up_rtc_gettime(struct timespec *tp)
   tp->tv_nsec = (count % CONFIG_RTC_FREQUENCY) *
                 (NSEC_PER_SEC / CONFIG_RTC_FREQUENCY);
 
+  spin_unlock_irqrestore(&g_rtc_lock, flags);

Review Comment:
   move before line 410



##########
arch/x86_64/src/intel64/intel64_rtc.c:
##########
@@ -140,11 +145,14 @@ int up_rtc_initialize(void)
 
 int up_rtc_gettime(struct timespec *tp)
 {
+  irqstate_t flags;
   uint64_t tmp;
 
+  flags = spin_lock_irqsave(&g_rtc_lock);
   tmp = rtc_read();
   tp->tv_sec  = (tmp / NS_PER_SEC);
   tp->tv_nsec = (tmp - (tp->tv_sec) * NS_PER_SEC);
+  spin_unlock_irqrestore(&g_rtc_lock, flags);

Review Comment:
   move after line 99



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to