Message ID | 1451266467-15377-3-git-send-email-bjorn.andersson@sonymobile.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
On Sun, 27 Dec 2015 17:34:25 -0800 Bjorn Andersson <bjorn@kryo.se> wrote: > In preparation for handling incoming messages from IRQ context, change > the indication list lock to a spinlock > > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> > --- > drivers/net/wireless/ath/wcn36xx/smd.c | 12 ++++++------ > drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 2 +- > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c > index 6b5dbe6f0d0a..4307429740a9 100644 > --- a/drivers/net/wireless/ath/wcn36xx/smd.c > +++ b/drivers/net/wireless/ath/wcn36xx/smd.c > @@ -2165,10 +2165,10 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len) > msg_ind->msg_len = len; > memcpy(msg_ind->msg, buf, len); > > - mutex_lock(&wcn->hal_ind_mutex); > + spin_lock(&wcn->hal_ind_lock); If you are going to handle messages in IRQ context, that better be a spin_lock_irq() or spin_lock_bh(). -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon 28 Dec 15:06 PST 2015, Stephen Hemminger wrote: > On Sun, 27 Dec 2015 17:34:25 -0800 > Bjorn Andersson <bjorn@kryo.se> wrote: > > > In preparation for handling incoming messages from IRQ context, change > > the indication list lock to a spinlock > > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> > > --- > > drivers/net/wireless/ath/wcn36xx/smd.c | 12 ++++++------ > > drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 2 +- > > 2 files changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c > > index 6b5dbe6f0d0a..4307429740a9 100644 > > --- a/drivers/net/wireless/ath/wcn36xx/smd.c > > +++ b/drivers/net/wireless/ath/wcn36xx/smd.c > > @@ -2165,10 +2165,10 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len) > > msg_ind->msg_len = len; > > memcpy(msg_ind->msg, buf, len); > > > > - mutex_lock(&wcn->hal_ind_mutex); > > + spin_lock(&wcn->hal_ind_lock); > > If you are going to handle messages in IRQ context, that better be a > spin_lock_irq() or spin_lock_bh(). This function is executed in IRQ context after the next patch, as such I use spin_lock() here and spin_lock_irqsave() in the worker thread (wcn36xx_ind_smd_work()). Is this not how the spin_lock API should be used? Regards, Bjorn -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index 6b5dbe6f0d0a..4307429740a9 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -2165,10 +2165,10 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len) msg_ind->msg_len = len; memcpy(msg_ind->msg, buf, len); - mutex_lock(&wcn->hal_ind_mutex); + spin_lock(&wcn->hal_ind_lock); list_add_tail(&msg_ind->list, &wcn->hal_ind_queue); queue_work(wcn->hal_ind_wq, &wcn->hal_ind_work); - mutex_unlock(&wcn->hal_ind_mutex); + spin_unlock(&wcn->hal_ind_lock); wcn36xx_dbg(WCN36XX_DBG_HAL, "indication arrived\n"); break; default: @@ -2182,8 +2182,9 @@ static void wcn36xx_ind_smd_work(struct work_struct *work) container_of(work, struct wcn36xx, hal_ind_work); struct wcn36xx_hal_msg_header *msg_header; struct wcn36xx_hal_ind_msg *hal_ind_msg; + unsigned long flags; - mutex_lock(&wcn->hal_ind_mutex); + spin_lock_irqsave(&wcn->hal_ind_lock, flags); hal_ind_msg = list_first_entry(&wcn->hal_ind_queue, struct wcn36xx_hal_ind_msg, @@ -2215,8 +2216,8 @@ static void wcn36xx_ind_smd_work(struct work_struct *work) msg_header->msg_type); } list_del(wcn->hal_ind_queue.next); + spin_unlock_irqrestore(&wcn->hal_ind_lock, flags); kfree(hal_ind_msg); - mutex_unlock(&wcn->hal_ind_mutex); } int wcn36xx_smd_open(struct wcn36xx *wcn) { @@ -2229,7 +2230,7 @@ int wcn36xx_smd_open(struct wcn36xx *wcn) } INIT_WORK(&wcn->hal_ind_work, wcn36xx_ind_smd_work); INIT_LIST_HEAD(&wcn->hal_ind_queue); - mutex_init(&wcn->hal_ind_mutex); + spin_lock_init(&wcn->hal_ind_lock); ret = wcn->ctrl_ops->open(wcn, wcn36xx_smd_rsp_process); if (ret) { @@ -2249,5 +2250,4 @@ void wcn36xx_smd_close(struct wcn36xx *wcn) { wcn->ctrl_ops->close(); destroy_workqueue(wcn->hal_ind_wq); - mutex_destroy(&wcn->hal_ind_mutex); } diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h index 7b41e833e18c..7997cc1312ee 100644 --- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h +++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h @@ -215,7 +215,7 @@ struct wcn36xx { struct completion hal_rsp_compl; struct workqueue_struct *hal_ind_wq; struct work_struct hal_ind_work; - struct mutex hal_ind_mutex; + spinlock_t hal_ind_lock; struct list_head hal_ind_queue; /* DXE channels */
In preparation for handling incoming messages from IRQ context, change the indication list lock to a spinlock Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> --- drivers/net/wireless/ath/wcn36xx/smd.c | 12 ++++++------ drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)