From patchwork Sun Nov 1 21:15:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 315602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A18BC2D0A3 for ; Sun, 1 Nov 2020 21:17:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10ED42068E for ; Sun, 1 Nov 2020 21:17:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pBUxUZ48"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="c/wktzj5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbgKAVRS (ORCPT ); Sun, 1 Nov 2020 16:17:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727280AbgKAVRS (ORCPT ); Sun, 1 Nov 2020 16:17:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAAE8C0617A6 for ; Sun, 1 Nov 2020 13:17:17 -0800 (PST) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604265436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L4gF6uF2MewoDhtcChx+sLXBtFz03453YzVW4AULfuY=; b=pBUxUZ48DsWFh9nxdiG232I99mrrRy2nf8H0KHU3BNUS3SHL5EY+4ZVOEbGOXBC1zoXnG3 C5uYWaZLFHx4VRZ9OhLEqZK3jOGyalJeERYiNEP6cgWNyOs+3MROGxUEfcuH+vFUfi048G GdlKPEXrpBlzyutwEpDr/3UCILVKXgHjFIMs3Dgxtqer9/k4rOZlBnPEZcDG9kNWMdaL2G Nb+tTH2JxjuOSOnRdt8QNc8r4WBcuNR/dkKN4A3Q3/EfgIbKuQhO9yvGMxQPxTtBdD19t4 kbSo/EPZcQH+tDVVuGHAo/V/BIGc1mzc5oN+V8xjZSAxLFWWaepuhSK+eshmxw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604265436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L4gF6uF2MewoDhtcChx+sLXBtFz03453YzVW4AULfuY=; b=c/wktzj5MGkYdKhiC3bWCYd3Vln4QH64gtY6hQm1OQx0Z0K1+jNaLcYxu+NZTyViRh8svt 2QjTFhQRj/bSfMDg== To: linux-wireless@vger.kernel.org Cc: Jouni Malinen , Kalle Valo , Ping-Ke Shih , Ulrich Kunitz , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 1/8] orinoco: Remove BUG_ON(in_interrupt/irq()) Date: Sun, 1 Nov 2020 22:15:29 +0100 Message-Id: <20201101211536.2966644-2-bigeasy@linutronix.de> In-Reply-To: <20201101211536.2966644-1-bigeasy@linutronix.de> References: <20201101211536.2966644-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The usage of in_irq()/in_interrupt() in drivers is phased out and the BUG_ON()'s based on those are not covering all contexts in which these functions cannot be called. Aside of that BUG_ON() should only be used as last resort, which is clearly not the case here. A broad variety of checks in the invoked functions (always enabled or debug option dependent) cover these conditions already, so the BUG_ON()'s do not really provide additional value. Just remove them. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org --- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c index b849d27bd741e..046f2453ad5d9 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c @@ -859,8 +859,6 @@ static int ezusb_access_ltv(struct ezusb_priv *upriv, int retval = 0; enum ezusb_state state; - BUG_ON(in_irq()); - if (!upriv->udev) { retval = -ENODEV; goto exit; @@ -1349,7 +1347,6 @@ static int ezusb_init(struct hermes *hw) struct ezusb_priv *upriv = hw->priv; int retval; - BUG_ON(in_interrupt()); if (!upriv) return -EINVAL; @@ -1448,7 +1445,6 @@ static inline void ezusb_delete(struct ezusb_priv *upriv) struct list_head *tmp_item; unsigned long flags; - BUG_ON(in_interrupt()); BUG_ON(!upriv); mutex_lock(&upriv->mtx); From patchwork Sun Nov 1 21:15:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 315601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F18CC4741F for ; Sun, 1 Nov 2020 21:17:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE10420756 for ; Sun, 1 Nov 2020 21:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FE5ZDCLt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3WdxC80E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727322AbgKAVRT (ORCPT ); Sun, 1 Nov 2020 16:17:19 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:54802 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbgKAVRS (ORCPT ); Sun, 1 Nov 2020 16:17:18 -0500 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604265436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noj1B5ca/uIxTGRkvRWYeOtEiiJK/kLamBwf0a04x0U=; b=FE5ZDCLtTSGik+U1/WhfQKejt41N1dPm9GEQ40mXwNn12u04UeoTS53Fsi8GbvRA5cBTEE Vr6viBx2jXXU60QOS0n5KEZnb9PQWnk5f9UQTYH4SXD2K3pbLVauFnFIQmQkxsWRILGx3w ZB7QYA0QT954HSgPKCExinlqo0K/kO5cAjn3bn+5hf4eAaqLo49wJZelIV7qM0HYcubJt0 1FoNrXDHT8f/eHwv3DSpP4lK7L//JiT2S9EpVve1jw1LPEu8hkkKqf2Ryia+lgJmWf2NYq wtgJX1K0I/3TPlRY3MrZTNocoN4DmKxPHo7x/8Yzly2vbXy05ldeAr6n6zZQIQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604265436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noj1B5ca/uIxTGRkvRWYeOtEiiJK/kLamBwf0a04x0U=; b=3WdxC80E6my0Y09fE6+rw6C/Q9LY2Z2iZAJrKEOaBxrRe4/dwJZFz44BRpnm7F4GOJFLWo z0lz21a2krFUwDCg== To: linux-wireless@vger.kernel.org Cc: Jouni Malinen , Kalle Valo , Ping-Ke Shih , Ulrich Kunitz , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 2/8] airo: Invoke airo_read_wireless_stats() directly Date: Sun, 1 Nov 2020 22:15:30 +0100 Message-Id: <20201101211536.2966644-3-bigeasy@linutronix.de> In-Reply-To: <20201101211536.2966644-1-bigeasy@linutronix.de> References: <20201101211536.2966644-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org airo_get_wireless_stats() is the iw_handler_if::get_wireless_stats() callback of this driver. This callback was not allowed to sleep until commit a160ee69c6a46 ("wext: let get_wireless_stats() sleep") in v2.6.32. airo still delegates the readout to a thread, which is not longer necessary. Invoke airo_read_wireless_stats() directly from the callback and remove the now unused JOB_WSTATS handling. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org --- drivers/net/wireless/cisco/airo.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 87b9398b03fd4..ca423f3b6b3ea 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -1144,7 +1144,6 @@ static int airo_thread(void *data); static void timer_func(struct net_device *dev); static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev); -static void airo_read_wireless_stats(struct airo_info *local); #ifdef CISCO_EXT static int readrids(struct net_device *dev, aironet_ioctl *comp); static int writerids(struct net_device *dev, aironet_ioctl *comp); @@ -1200,7 +1199,6 @@ struct airo_info { #define JOB_MIC 5 #define JOB_EVENT 6 #define JOB_AUTOWEP 7 -#define JOB_WSTATS 8 #define JOB_SCAN_RESULTS 9 unsigned long jobs; int (*bap_read)(struct airo_info*, __le16 *pu16Dst, int bytelen, @@ -3155,8 +3153,6 @@ static int airo_thread(void *data) airo_end_xmit11(dev); else if (test_bit(JOB_STATS, &ai->jobs)) airo_read_stats(dev); - else if (test_bit(JOB_WSTATS, &ai->jobs)) - airo_read_wireless_stats(ai); else if (test_bit(JOB_PROMISC, &ai->jobs)) airo_set_promisc(ai); else if (test_bit(JOB_MIC, &ai->jobs)) @@ -7732,15 +7728,12 @@ static void airo_read_wireless_stats(struct airo_info *local) __le32 *vals = stats_rid.vals; /* Get stats out of the card */ - clear_bit(JOB_WSTATS, &local->jobs); - if (local->power.event) { - up(&local->sem); + if (local->power.event) return; - } + readCapabilityRid(local, &cap_rid, 0); readStatusRid(local, &status_rid, 0); readStatsRid(local, &stats_rid, RID_STATS, 0); - up(&local->sem); /* The status */ local->wstats.status = le16_to_cpu(status_rid.mode); @@ -7783,15 +7776,10 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) { struct airo_info *local = dev->ml_priv; - if (!test_bit(JOB_WSTATS, &local->jobs)) { - /* Get stats out of the card if available */ - if (down_trylock(&local->sem) != 0) { - set_bit(JOB_WSTATS, &local->jobs); - wake_up_interruptible(&local->thr_wait); - } else - airo_read_wireless_stats(local); + if (!down_interruptible(&local->sem)) { + airo_read_wireless_stats(local); + up(&local->sem); } - return &local->wstats; } From patchwork Sun Nov 1 21:15:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 315600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23FF5C2D0A3 for ; Sun, 1 Nov 2020 21:17:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF6F820706 for ; Sun, 1 Nov 2020 21:17:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tLTi8vqX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ObVIm6HA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727354AbgKAVRU (ORCPT ); Sun, 1 Nov 2020 16:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727004AbgKAVRT (ORCPT ); Sun, 1 Nov 2020 16:17:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38515C0617A6 for ; Sun, 1 Nov 2020 13:17:19 -0800 (PST) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604265437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/G6jhunyYonKt/zfjJmfGJ6HFdyJdyKil2v62NvxSdM=; b=tLTi8vqXu05mdK9kFwVSWtCkvZhAO/TAM03VRbJb+oUGEGUpQU1pSZ382fo6gua0J0k7JM ZklW4ZcjrLZE0UKJe+YJVHunqmvOM6N7ClDUFyiA06JmqsrufAtgsR4ixm4MDfyk+PgKbK e0Ox0cZoPn8VAd3LZCfaZZI7iNmj4FdkwIxB0V5SYP9Byz+infjN5y2Oy9VzOAYH8XyLHQ cv0xf33+Kac/Q0U8uN3HPreDDS73df6ZZF8EdXZoKn8YhzOVUPcWgRecg2BxwVusoJAa3G WKGaDjSKerq+BD14YhqqLlLUnPw3QcGywGADJdQYBnpKk7oIel1zxKfxBw1wFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604265437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/G6jhunyYonKt/zfjJmfGJ6HFdyJdyKil2v62NvxSdM=; b=ObVIm6HAiCS49yFAhVJyxq71SKtCTTl/Gy/hPnkh9iGMCv9NXGl06jKksPFkDps/680Py4 r0X02n1byu7BNiBQ== To: linux-wireless@vger.kernel.org Cc: Jouni Malinen , Kalle Valo , Ping-Ke Shih , Ulrich Kunitz , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 3/8] airo: Always use JOB_STATS and JOB_EVENT Date: Sun, 1 Nov 2020 22:15:31 +0100 Message-Id: <20201101211536.2966644-4-bigeasy@linutronix.de> In-Reply-To: <20201101211536.2966644-1-bigeasy@linutronix.de> References: <20201101211536.2966644-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org issuecommand() is using in_atomic() to decide if it is safe to invoke schedule() while waiting for the command to be accepted. Usage of in_atomic() for this is only half correct as it can not detect all condition where it is not allowed to schedule(). Also Linus clearly requested that code which changes behaviour depending on context should either be seperated or the context be conveyed in an argument passed by the caller, which usually knows the context. Chasing the call chains leading up to issuecommand() is straight forward, but airo_link() and airo_get_stats() would require to pass the context through a quite large amount of functions. As this is ancient hardware, avoid the churn and enforce the invocation of those functions through the JOB machinery. Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org --- drivers/net/wireless/cisco/airo.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index ca423f3b6b3ea..369a6ca44d1ff 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -2286,12 +2286,8 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) struct airo_info *local = dev->ml_priv; if (!test_bit(JOB_STATS, &local->jobs)) { - /* Get stats out of the card if available */ - if (down_trylock(&local->sem) != 0) { - set_bit(JOB_STATS, &local->jobs); - wake_up_interruptible(&local->thr_wait); - } else - airo_read_stats(dev); + set_bit(JOB_STATS, &local->jobs); + wake_up_interruptible(&local->thr_wait); } return &dev->stats; @@ -3277,11 +3273,9 @@ static void airo_handle_link(struct airo_info *ai) set_bit(FLAG_UPDATE_UNI, &ai->flags); set_bit(FLAG_UPDATE_MULTI, &ai->flags); - if (down_trylock(&ai->sem) != 0) { - set_bit(JOB_EVENT, &ai->jobs); - wake_up_interruptible(&ai->thr_wait); - } else - airo_send_event(ai->dev); + set_bit(JOB_EVENT, &ai->jobs); + wake_up_interruptible(&ai->thr_wait); + netif_carrier_on(ai->dev); } else if (!scan_forceloss) { if (auto_wep && !ai->expires) { From patchwork Sun Nov 1 21:15:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 315599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56484C4741F for ; Sun, 1 Nov 2020 21:17:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24D87207C3 for ; Sun, 1 Nov 2020 21:17:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eopSm6N8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="joObuY7H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbgKAVRW (ORCPT ); Sun, 1 Nov 2020 16:17:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbgKAVRU (ORCPT ); Sun, 1 Nov 2020 16:17:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D202C0617A6 for ; Sun, 1 Nov 2020 13:17:20 -0800 (PST) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604265438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z7awEtJFUN8Qqezsp1s+wh6Wj0pYybb8lUU0KF9hZZw=; b=eopSm6N8RaPaZvEby91TB84/YQVaezUgNRFKMFt6K5rBgo5eKlOxT8TEMjEvBOSKAFLOVR S29xLG0l0bPltaL9KxoVJBoq56a6BZMPcrtanaAS/WzcykDJLmrGmg5O8Y4B52VTfhpjdD Tg9WJt0pBJ5OwGkKAhXyS7wvmza9jBF8a1PGgApKVwWYe+tdPKh0gUlpD+vDEoEyGOtjZF D6utR70VkW+a2ENlcDMZOyEbICKg88RvB0yg4JTn7Rvi3KvYj8Ud9TcZjtlYi995Fiqswh uoy3QnChCXxaHlyEx/8jFdZu1UsifD1s6y4kBllJFi0iFd6RoyibX4s9zzCdyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604265438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z7awEtJFUN8Qqezsp1s+wh6Wj0pYybb8lUU0KF9hZZw=; b=joObuY7HORKKcO1+IYu3r5NA8UNSoimNQTLS7704UQ2MUIyjN/E247z3G3dRXa8VD/MWg1 nFaAJBVRYRAP25CA== To: linux-wireless@vger.kernel.org Cc: Jouni Malinen , Kalle Valo , Ping-Ke Shih , Ulrich Kunitz , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 7/8] rtlwifi: Remove in_interrupt() usage in is_any_client_connect_to_ap(). Date: Sun, 1 Nov 2020 22:15:35 +0100 Message-Id: <20201101211536.2966644-8-bigeasy@linutronix.de> In-Reply-To: <20201101211536.2966644-1-bigeasy@linutronix.de> References: <20201101211536.2966644-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org is_any_client_connect_to_ap() is using in_interrupt() to determine whether it should acquire the lock prior accessing the list. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. The function is called from: - halbtc_get() - halbtc_get() halbtc_get_wifi_link_status() - halbtc_display_dbg_msg() halbtc_display_wifi_status() halbtc_get_wifi_link_status() All top level callers are part of the btc_coexist callback inferface and are never invoked from a context which can hold the lock already. The contexts which hold the lock are either protecting list add/del operations or list walks which never call into any of the btc_coexist interfaces. In fact the conditional is outright dangerous because if this function would be invoked from a BH disabled context the check would avoid taking the lock while on another CPU the list could be manipulated under the lock. Remove the in_interrupt() check and always acquire the lock. To simplify the code further use list_empty() instead of walking the list and counting the entries just to check the count for > 0 at the end. Signed-off-by: Sebastian Andrzej Siewior Cc: Ping-Ke Shih Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org --- .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c index 2c05369b79e4d..2155a6699ef8d 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c @@ -47,30 +47,17 @@ static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_mac *mac = rtl_mac(rtlpriv); - struct rtl_sta_info *drv_priv; - u8 cnt = 0; + bool ret = false; if (mac->opmode == NL80211_IFTYPE_ADHOC || mac->opmode == NL80211_IFTYPE_MESH_POINT || mac->opmode == NL80211_IFTYPE_AP) { - if (in_interrupt() > 0) { - list_for_each_entry(drv_priv, &rtlpriv->entry_list, - list) { - cnt++; - } - } else { - spin_lock_bh(&rtlpriv->locks.entry_list_lock); - list_for_each_entry(drv_priv, &rtlpriv->entry_list, - list) { - cnt++; - } - spin_unlock_bh(&rtlpriv->locks.entry_list_lock); - } + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + if (!list_empty(&rtlpriv->entry_list)) + ret = true; + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); } - if (cnt > 0) - return true; - else - return false; + return ret; } static bool halbtc_legacy(struct rtl_priv *adapter)