From 70757d54d113fea7b1405c312e1d0a6fcebf321f Mon Sep 17 00:00:00 2001 From: Yu Wang Date: Thu, 8 Jun 2017 12:15:42 +0800 Subject: [PATCH] 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 --- core/hdd/src/wlan_hdd_tsf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/hdd/src/wlan_hdd_tsf.c b/core/hdd/src/wlan_hdd_tsf.c index 53dc753b11ea..edb8a7557e1b 100644 --- a/core/hdd/src/wlan_hdd_tsf.c +++ b/core/hdd/src/wlan_hdd_tsf.c @@ -422,11 +422,21 @@ static void hdd_update_timestamp(hdd_adapter_t *adapter, if (!adapter) 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); if (target_time > 0) 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, adapter->last_host_time,