Browse Source

qcacld-3.0: fix a potential spinlock lockup issue

When time stamping RX packets, spinlock
host_target_sync_lock will be hold if it's
now in TSF capturing state; if TSF-captured
IRQ happened at this moment, it will also
try to get host_target_sync_lock; if it's
handled on the same CPU, lockup will happen.

In the use-case, to update the current host
time, it's no need to get the spinlock in
this TSF-captured IRQ context, so move
host-time updating out of the lock.

Change-Id: I87205d5935bd2063c80ce7cf767cbc36dde55236
CRs-Fixed: 2057693
Yu Wang 8 years ago
parent
commit
70757d54d1
1 changed files with 12 additions and 2 deletions
  1. 12 2
      core/hdd/src/wlan_hdd_tsf.c

+ 12 - 2
core/hdd/src/wlan_hdd_tsf.c

@@ -422,11 +422,21 @@ static void hdd_update_timestamp(hdd_adapter_t *adapter,
 	if (!adapter)
 	if (!adapter)
 		return;
 		return;
 
 
+	/* host time is updated in IRQ context, it's always before target time,
+	 * and so no need to try update last_host_time at present;
+	 * since the interval of capturing TSF
+	 * (WLAN_HDD_CAPTURE_TSF_INTERVAL_SEC) is long enough, host and target
+	 * time are updated in pairs, and one by one, we can return here to
+	 * avoid requiring spin lock, and to speed up the IRQ processing.
+	 */
+	if (host_time > 0) {
+		adapter->cur_host_time = host_time;
+		return;
+	}
+
 	qdf_spin_lock_bh(&adapter->host_target_sync_lock);
 	qdf_spin_lock_bh(&adapter->host_target_sync_lock);
 	if (target_time > 0)
 	if (target_time > 0)
 		adapter->cur_target_time = target_time;
 		adapter->cur_target_time = target_time;
-	if (host_time > 0)
-		adapter->cur_host_time = host_time;
 
 
 	sync_status = hdd_check_timestamp_status(adapter->last_target_time,
 	sync_status = hdd_check_timestamp_status(adapter->last_target_time,
 						 adapter->last_host_time,
 						 adapter->last_host_time,