diff options
| author | Poddar, Siddarth <siddpodd@codeaurora.org> | 2017-07-18 16:10:07 +0530 |
|---|---|---|
| committer | snandini <snandini@codeaurora.org> | 2017-08-07 04:17:04 -0700 |
| commit | c81c2fb48cfd1a0abaca1f4262bc15f020c1a04b (patch) | |
| tree | 9db53cce1f4f26eaf7cd42a24251835e9fae9abc | |
| parent | f16ab0feacc1ee23802dff3ac912291524136fc0 (diff) | |
qcacmn: Perform napi state comparison before releasing napi lock
Release napi spinlock only after performing napi state
comparison to avoid any race condition.
Change-Id: Icd7b713e474a818dfc6d0fa402496bbe06a3af66
CRs-Fixed: 2078294
| -rw-r--r-- | hif/src/hif_napi.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c index 946699f6f9b7..821039cfa486 100644 --- a/hif/src/hif_napi.c +++ b/hif/src/hif_napi.c @@ -497,6 +497,7 @@ int hif_napi_event(struct hif_opaque_softc *hif_ctx, enum qca_napi_event event, int rc = 0; uint32_t prev_state; int i; + bool state_changed; struct napi_struct *napi; struct hif_softc *hif = HIF_GET_SOFTC(hif_ctx); struct qca_napi_data *napid = &(hif->napi_data); @@ -643,9 +644,18 @@ int hif_napi_event(struct hif_opaque_softc *hif_ctx, enum qca_napi_event event, break; } /* switch blacklist_pending */ + /* we want to perform the comparison in lock: + * there is a possiblity of hif_napi_event get called + * from two different contexts (driver unload and cpu hotplug + * notification) and napid->state get changed + * in driver unload context and can lead to race condition + * in cpu hotplug context. Therefore, perform the napid->state + * comparison before releasing lock. + */ + state_changed = (prev_state != napid->state); qdf_spin_unlock_bh(&(napid->lock)); - if (prev_state != napid->state) { + if (state_changed) { if (napid->state == ENABLE_NAPI_MASK) { rc = 1; for (i = 0; i < CE_COUNT_MAX; i++) { |
