From patchwork Tue Oct 27 22:54:40 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: 310730 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=unavailable 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 A74EBC55179 for ; Tue, 27 Oct 2020 22:55:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73C072076D for ; Tue, 27 Oct 2020 22:55:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3FiB4+F2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rv75+kug" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1790065AbgJ0Wzc (ORCPT ); Tue, 27 Oct 2020 18:55:32 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49870 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S374977AbgJ0Wzb (ORCPT ); Tue, 27 Oct 2020 18:55:31 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839328; 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=F4e1jj7WEPocePjy6Hywu9Wq8qr5VByL3erxk5CNuaA=; b=3FiB4+F2Ct0QcIJOw0tfFlETx8PA8cgs958H2wTMHeIYNJ0RRxXGs6tAH11rNFnAQDRqXv DiV3e6ZVQjCp2kVh+2lqXgAnbKEsoByqjy4HPuMPpPBT+xCjx48lfoOPYGXyL0DGxE5kdj Pt8LZvzDp0EniVd+Vjb8qp4JtRGjXpvJNPJfY2HwJvxfIpKTEmy0caMxpZMx7FCNsI/+bq gTGW0uTlWOJqLxt/aDjI84arJJ44P90+8mLVO0Hqe1ps2OAY0MlpASYJOeMb8RZ3lPetwz PS86UoN0H14FK5bv+UVykEyZ+2DxHYCHpB6sea87Jg4b4sskoPBvobapEA047Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839328; 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=F4e1jj7WEPocePjy6Hywu9Wq8qr5VByL3erxk5CNuaA=; b=rv75+kugraFffbq7nLw3mAS8i1Mg3dMERU51OgwfdltVGaW1rfmkPNdjlHkVLTVjhar4Ts 4Kor9NM6UXqalcDw== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 01/15] net: orinoco: Remove BUG_ON(in_interrupt/irq()) Date: Tue, 27 Oct 2020 23:54:40 +0100 Message-Id: <20201027225454.3492351-2-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@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 Tue Oct 27 22:54:42 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: 310729 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=unavailable 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 E03C6C55179 for ; Tue, 27 Oct 2020 22:55:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACB5822202 for ; Tue, 27 Oct 2020 22:55:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ras1ZN9p"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="v4kTPiwV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832523AbgJ0Wzx (ORCPT ); Tue, 27 Oct 2020 18:55:53 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49954 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1795169AbgJ0Wzt (ORCPT ); Tue, 27 Oct 2020 18:55:49 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839347; 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=NCh5w9ecP7hR6Lh6yrwLcXDxY3S9AS4A8O59ClkmQuc=; b=ras1ZN9p/0s71wAw6BiBK7tQahnylR+TBxJ5FU+RyyAUd654I45XroAagmXNcOhZGwycQU JuB4srVEeq8JEdNYcazZGYxW43kHEWBW5olkexuNTx+ROG4rW4+lIg6oh7RjFfnmiYIMSa wja8WVkTfnwqG5yCdjniR3JYvVzyFeZ5xY4gUgFa/48uACynrZzW+jFjl7+Gm1Ak37HK8p i/LKjYW8uioJWsvMjaEFv0DOxsaAb1xs+tCGlkELjceM3XFKR9pZVfCoL3oL63qwaBCct1 uDLBmNS2D4JG5AgIEUYeAmWi2edcivpTlNAp8bjFhFJaHoQh3tvbl3SKJ1tFdA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839347; 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=NCh5w9ecP7hR6Lh6yrwLcXDxY3S9AS4A8O59ClkmQuc=; b=v4kTPiwVtn0BHjC1H1qdUC0DOW5ocQSNsfxbnR+jglqhT5b2wBt7em4IRx8CX07gIiVoDE zxqH636veSWAMICg== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 03/15] net: forcedeth: Replace context and lock check with a lockdep_assert() Date: Tue, 27 Oct 2020 23:54:42 +0100 Message-Id: <20201027225454.3492351-4-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org nv_update_stats() triggers a WARN_ON() when invoked from hard interrupt context because the locks in use are not hard interrupt safe. It also has an assert_spin_locked() which was the lock check before the lockdep era. Lockdep has way broader locking correctness checks and covers both issues, so replace the warning and the lock assert with lockdep_assert_held(). Signed-off-by: Sebastian Andrzej Siewior Cc: Rain River Cc: Zhu Yanjun Cc: "David S. Miller" Cc: Jakub Kicinski Cc: netdev@vger.kernel.org --- drivers/net/ethernet/nvidia/forcedeth.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 2fc10a36afa4a..7e85cf943be11 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -1666,11 +1666,7 @@ static void nv_update_stats(struct net_device *dev) struct fe_priv *np = netdev_priv(dev); u8 __iomem *base = get_hwbase(dev); - /* If it happens that this is run in top-half context, then - * replace the spin_lock of hwstats_lock with - * spin_lock_irqsave() in calling functions. */ - WARN_ONCE(in_irq(), "forcedeth: estats spin_lock(_bh) from top-half"); - assert_spin_locked(&np->hwstats_lock); + lockdep_assert_held(&np->hwstats_lock); /* query hardware */ np->estats.tx_bytes += readl(base + NvRegTxCnt); From patchwork Tue Oct 27 22:54:43 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: 310723 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 1BD16C55178 for ; Tue, 27 Oct 2020 22:57:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D42DB2222C for ; Tue, 27 Oct 2020 22:57:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3kp7YDf0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xGAdgcHv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832610AbgJ0W5Q (ORCPT ); Tue, 27 Oct 2020 18:57:16 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49992 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1795540AbgJ0Wzv (ORCPT ); Tue, 27 Oct 2020 18:55:51 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839348; 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=ApwQCgaMixcuC9eYB2lgT0F8OtvMn3mKtyMgUXQslP0=; b=3kp7YDf0JW3dUiXKR/lIkGaq9IUzvbof2U+ioaOEM0BXZ25zKHZ3VvKuUCeYh6GTrBpfNm GRwCN13HX21o0SlkuNx5V3Vsv+ceb2O2cK7q2g/9RWMajdYHHyg7LbgRGpePukCXT+FW94 zxSs77FFszQUu3jBPzmNd0L9yWdS1ctJhQZJ4aPxrjFcMaUZeiA2uxMMbxrKJxSMeMh8cO r/f2cAZmd40765LdmanfOcBrvIuywbt8AXl2532QDscJylvxZHgZvGB4lysvx4ioXvLOX1 thtT1pxIN/tGyj/2hDhPGcArtzXTAydNZAuzy7DpYVeva9MxWbS2OrkDypdpFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839348; 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=ApwQCgaMixcuC9eYB2lgT0F8OtvMn3mKtyMgUXQslP0=; b=xGAdgcHvBjsBbyq8waqxdv8AKE7ZVadlKCP9fhj2yu2LxgTB7Lwz1WNyHMgs1SQY6+RaF0 /TJFp2upKtsb3RBQ== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 04/15] net: mlx5: Replace in_irq() usage. Date: Tue, 27 Oct 2020 23:54:43 +0100 Message-Id: <20201027225454.3492351-5-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org mlx5_eq_async_int() uses in_irq() to decide whether eq::lock needs to be acquired and released with spin_[un]lock() or the irq saving/restoring variants. The usage of in_*() in drivers is phased out and 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. mlx5_eq_async_int() knows the context via the action argument already so using it for the lock variant decision is a straight forward replacement for in_irq(). Signed-off-by: Sebastian Andrzej Siewior Cc: Saeed Mahameed Cc: Leon Romanovsky Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-rdma@vger.kernel.org --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index 8ebfe782f95e5..3800e9415158b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -189,19 +189,21 @@ u32 mlx5_eq_poll_irq_disabled(struct mlx5_eq_comp *eq) return count_eqe; } -static void mlx5_eq_async_int_lock(struct mlx5_eq_async *eq, unsigned long *flags) +static void mlx5_eq_async_int_lock(struct mlx5_eq_async *eq, bool recovery, + unsigned long *flags) __acquires(&eq->lock) { - if (in_irq()) + if (!recovery) spin_lock(&eq->lock); else spin_lock_irqsave(&eq->lock, *flags); } -static void mlx5_eq_async_int_unlock(struct mlx5_eq_async *eq, unsigned long *flags) +static void mlx5_eq_async_int_unlock(struct mlx5_eq_async *eq, bool recovery, + unsigned long *flags) __releases(&eq->lock) { - if (in_irq()) + if (!recovery) spin_unlock(&eq->lock); else spin_unlock_irqrestore(&eq->lock, *flags); @@ -222,12 +224,14 @@ static int mlx5_eq_async_int(struct notifier_block *nb, struct mlx5_core_dev *dev; struct mlx5_eqe *eqe; unsigned long flags; + bool recovery; int num_eqes = 0; dev = eq->dev; eqt = dev->priv.eq_table; - mlx5_eq_async_int_lock(eq_async, &flags); + recovery = action == ASYNC_EQ_RECOVER; + mlx5_eq_async_int_lock(eq_async, recovery, &flags); eqe = next_eqe_sw(eq); if (!eqe) @@ -249,9 +253,9 @@ static int mlx5_eq_async_int(struct notifier_block *nb, out: eq_update_ci(eq, 1); - mlx5_eq_async_int_unlock(eq_async, &flags); + mlx5_eq_async_int_unlock(eq_async, recovery, &flags); - return unlikely(action == ASYNC_EQ_RECOVER) ? num_eqes : 0; + return unlikely(recovery) ? num_eqes : 0; } void mlx5_cmd_eq_recover(struct mlx5_core_dev *dev) From patchwork Tue Oct 27 22:54:45 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: 310725 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=unavailable 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 A481CC4363A for ; Tue, 27 Oct 2020 22:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 704602223C for ; Tue, 27 Oct 2020 22:57:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fx5mIpQN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4fdK0Siy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832540AbgJ0Wzz (ORCPT ); Tue, 27 Oct 2020 18:55:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50078 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1822300AbgJ0Wzy (ORCPT ); Tue, 27 Oct 2020 18:55:54 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839351; 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=mqMN4ct9VbfHqkFKNiMKAw2F6YYZ02CQk7qh9a7Lg6A=; b=fx5mIpQNf24U4OKtffNf9Wx02FQrkLRTetizyvfAXrbeWdNEOAM2YgkMLanZFK51opIXP/ ht8Cb1LUWkJGi7cSpliYshIYT52WrVcVf/0Gox0l1wlFcE53nKSX+2CokYhxqgpt9vXhO8 ENu95JqaoJDpxG1oTteDugBZtS33STVYV8JgCFBnkF6MCFgR83L00HjjJptOf900x1oadV s8ku6a2pCLtC6oySCmxKF5sWmw5RL76lfGGuvX1wXRcGO0gD0GTOHN6qHf/5SsS7Q78lMy lEtbvwp5O/rXYrGfai16ntN90coQz052mVktHDfiKLm8Xc3tFycNvJ7AvxuPbQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839351; 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=mqMN4ct9VbfHqkFKNiMKAw2F6YYZ02CQk7qh9a7Lg6A=; b=4fdK0Siy7UlwpuqDN1Jmg/r5/WOGzHcjo/YM4lJ802RgjezqZ/22VTwf/TimbgjRPnzsTk V9/4+4XMOa9YvSAw== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 06/15] net: airo: Invoke airo_read_wireless_stats() directly Date: Tue, 27 Oct 2020 23:54:45 +0100 Message-Id: <20201027225454.3492351-7-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@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 Tue Oct 27 22:54:47 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: 310724 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=-7.0 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, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED autolearn=unavailable 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 ED597C388F9 for ; Tue, 27 Oct 2020 22:57:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9AB72076D for ; Tue, 27 Oct 2020 22:57:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tKTPZpxa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Hw+UJiwY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832630AbgJ0W45 (ORCPT ); Tue, 27 Oct 2020 18:56:57 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50018 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832530AbgJ0Wz6 (ORCPT ); Tue, 27 Oct 2020 18:55:58 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839354; 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=tcSa5YSrfG4xl3ThzEZbNNTbn7vFa8bF7wp3SbXlfyw=; b=tKTPZpxaVJ4ueIxENaTCMjcs82oPAhM9X0ViDPIhrQDfN1CJ45JiU0lTlSgyE5FT3xpzhj AtrQgSVIRLImXk3T3LrzKzEZx2yg82g0JWKe0rtKUqHjqUFINyiukEwAjKDGug8k4qScit dINLX05imL1aZ/S0R5nqWnVaSizPqvKJuvnF77mOBVUq0pD53WkafBfFpLwS9gBuaArbQ0 +8abfQunVVjfyWFeHe/bKCyi1ILhIwC8K970LgjlhRrZ83O84O6hbvE0uTfDCnYNmGSeSe 3Z9NMRwWuQy1ff65arS1mQ51ed8V1wD/or/6ZF4yfZsVbWVhbDcKxV+k/EJ0HA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839354; 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=tcSa5YSrfG4xl3ThzEZbNNTbn7vFa8bF7wp3SbXlfyw=; b=Hw+UJiwYeyLH1r/VLjfzOSxuldeQVIwHCtgT40wTXRX+AnQfE4hyLdl6kElrx05thIhSYK 91j5F6AsKR7YGiAg== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 08/15] net: airo: Replace in_atomic() usage. Date: Tue, 27 Oct 2020 23:54:47 +0100 Message-Id: <20201027225454.3492351-9-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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. Add an may_sleep argument to issuecommand() indicating when it is save to sleep and change schedule() to cond_resched() because it's pointless to invoke schedule() if there is no request to reschedule. Pass the may_sleep condition through the various call chains leading to issuecommand(). Signed-off-by: Sebastian Andrzej Siewior Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/wireless/cisco/airo.c | 86 +++++++++++++++++-------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 369a6ca44d1ff..74acf9af2adb1 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -1115,7 +1115,8 @@ static int enable_MAC(struct airo_info *ai, int lock); static void disable_MAC(struct airo_info *ai, int lock); static void enable_interrupts(struct airo_info*); static void disable_interrupts(struct airo_info*); -static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp); +static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp, + bool may_sleep); static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap); static int aux_bap_read(struct airo_info*, __le16 *pu16Dst, int bytelen, int whichbap); @@ -1130,8 +1131,10 @@ static int PC4500_writerid(struct airo_info*, u16 rid, const void static int do_writerid(struct airo_info*, u16 rid, const void *rid_data, int len, int dummy); static u16 transmit_allocate(struct airo_info*, int lenPayload, int raw); -static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket); -static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket); +static int transmit_802_3_packet(struct airo_info*, int len, char *pPacket, + bool may_sleep); +static int transmit_802_11_packet(struct airo_info*, int len, char *pPacket, + bool may_sleep); static int mpi_send_packet(struct net_device *dev); static void mpi_unmap_card(struct pci_dev *pci); @@ -1753,7 +1756,7 @@ static int readBSSListRid(struct airo_info *ai, int first, if (down_interruptible(&ai->sem)) return -ERESTARTSYS; ai->list_bss_task = current; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); up(&ai->sem); /* Let the command take effect */ schedule_timeout_uninterruptible(3 * HZ); @@ -2096,7 +2099,7 @@ static void get_tx_error(struct airo_info *ai, s32 fid) } } -static void airo_end_xmit(struct net_device *dev) +static void airo_end_xmit(struct net_device *dev, bool may_sleep) { u16 status; int i; @@ -2107,7 +2110,7 @@ static void airo_end_xmit(struct net_device *dev) clear_bit(JOB_XMIT, &priv->jobs); clear_bit(FLAG_PENDING_XMIT, &priv->flags); - status = transmit_802_3_packet (priv, fids[fid], skb->data); + status = transmit_802_3_packet(priv, fids[fid], skb->data, may_sleep); up(&priv->sem); i = 0; @@ -2164,11 +2167,11 @@ static netdev_tx_t airo_start_xmit(struct sk_buff *skb, set_bit(JOB_XMIT, &priv->jobs); wake_up_interruptible(&priv->thr_wait); } else - airo_end_xmit(dev); + airo_end_xmit(dev, false); return NETDEV_TX_OK; } -static void airo_end_xmit11(struct net_device *dev) +static void airo_end_xmit11(struct net_device *dev, bool may_sleep) { u16 status; int i; @@ -2179,7 +2182,7 @@ static void airo_end_xmit11(struct net_device *dev) clear_bit(JOB_XMIT11, &priv->jobs); clear_bit(FLAG_PENDING_XMIT11, &priv->flags); - status = transmit_802_11_packet (priv, fids[fid], skb->data); + status = transmit_802_11_packet(priv, fids[fid], skb->data, may_sleep); up(&priv->sem); i = MAX_FIDS / 2; @@ -2243,7 +2246,7 @@ static netdev_tx_t airo_start_xmit11(struct sk_buff *skb, set_bit(JOB_XMIT11, &priv->jobs); wake_up_interruptible(&priv->thr_wait); } else - airo_end_xmit11(dev); + airo_end_xmit11(dev, false); return NETDEV_TX_OK; } @@ -2293,7 +2296,7 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) return &dev->stats; } -static void airo_set_promisc(struct airo_info *ai) +static void airo_set_promisc(struct airo_info *ai, bool may_sleep) { Cmd cmd; Resp rsp; @@ -2302,7 +2305,7 @@ static void airo_set_promisc(struct airo_info *ai) cmd.cmd = CMD_SETMODE; clear_bit(JOB_PROMISC, &ai->jobs); cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, may_sleep); up(&ai->sem); } @@ -2316,7 +2319,7 @@ static void airo_set_multicast_list(struct net_device *dev) set_bit(JOB_PROMISC, &ai->jobs); wake_up_interruptible(&ai->thr_wait); } else - airo_set_promisc(ai); + airo_set_promisc(ai, false); } if ((dev->flags&IFF_ALLMULTI) || !netdev_mc_empty(dev)) { @@ -2476,7 +2479,7 @@ static int mpi_init_descriptors (struct airo_info *ai) cmd.parm0 = FID_RX; cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); cmd.parm2 = MPI_MAX_FIDS; - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); return rc; @@ -2504,7 +2507,7 @@ static int mpi_init_descriptors (struct airo_info *ai) } ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); return rc; @@ -2518,7 +2521,7 @@ static int mpi_init_descriptors (struct airo_info *ai) cmd.parm0 = RID_RW; cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); cmd.parm2 = 1; /* Magic number... */ - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc != SUCCESS) { airo_print_err(ai->dev->name, "Couldn't allocate RID"); return rc; @@ -3144,13 +3147,13 @@ static int airo_thread(void *data) } if (test_bit(JOB_XMIT, &ai->jobs)) - airo_end_xmit(dev); + airo_end_xmit(dev, true); else if (test_bit(JOB_XMIT11, &ai->jobs)) - airo_end_xmit11(dev); + airo_end_xmit11(dev, true); else if (test_bit(JOB_STATS, &ai->jobs)) airo_read_stats(dev); else if (test_bit(JOB_PROMISC, &ai->jobs)) - airo_set_promisc(ai); + airo_set_promisc(ai, true); else if (test_bit(JOB_MIC, &ai->jobs)) micinit(ai); else if (test_bit(JOB_EVENT, &ai->jobs)) @@ -3599,7 +3602,7 @@ static int enable_MAC(struct airo_info *ai, int lock) if (!test_bit(FLAG_ENABLED, &ai->flags)) { memset(&cmd, 0, sizeof(cmd)); cmd.cmd = MAC_ENABLE; - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rc == SUCCESS) set_bit(FLAG_ENABLED, &ai->flags); } else @@ -3631,7 +3634,7 @@ static void disable_MAC(struct airo_info *ai, int lock) netif_carrier_off(ai->dev); memset(&cmd, 0, sizeof(cmd)); cmd.cmd = MAC_DISABLE; // disable in case already enabled - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); clear_bit(FLAG_ENABLED, &ai->flags); } if (lock == 1) @@ -3834,7 +3837,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) cmd.parm0 = cmd.parm1 = cmd.parm2 = 0; if (lock && down_interruptible(&ai->sem)) return ERROR; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { if (lock) up(&ai->sem); return ERROR; @@ -3844,7 +3847,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) // Let's figure out if we need to use the AUX port if (!test_bit(FLAG_MPI,&ai->flags)) { cmd.cmd = CMD_ENABLEAUX; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { if (lock) up(&ai->sem); airo_print_err(ai->dev->name, "Error checking for AUX port"); @@ -3956,7 +3959,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) return SUCCESS; } -static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) +static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp, + bool may_sleep) { // Im really paranoid about letting it run forever! int max_tries = 600000; @@ -3973,8 +3977,8 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) if ((IN4500(ai, COMMAND)) == pCmd->cmd) // PC4500 didn't notice command, try again OUT4500(ai, COMMAND, pCmd->cmd); - if (!in_atomic() && (max_tries & 255) == 0) - schedule(); + if (may_sleep && (max_tries & 255) == 0) + cond_resched(); } if (max_tries == -1) { @@ -4131,7 +4135,7 @@ static int PC4500_accessrid(struct airo_info *ai, u16 rid, u16 accmd) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = accmd; cmd.parm0 = rid; - status = issuecommand(ai, &cmd, &rsp); + status = issuecommand(ai, &cmd, &rsp, true); if (status != 0) return status; if ((rsp.status & 0x7F00) != 0) { return (accmd << 8) + (rsp.rsp0 & 0xFF); @@ -4167,7 +4171,7 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in memcpy_toio(ai->config_desc.card_ram_off, &ai->config_desc.rid_desc, sizeof(Rid)); - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if (rsp.status & 0x7f00) rc = rsp.rsp0; @@ -4246,7 +4250,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid, memcpy(ai->config_desc.virtual_host_addr, pBuf, len); - rc = issuecommand(ai, &cmd, &rsp); + rc = issuecommand(ai, &cmd, &rsp, true); if ((rc & 0xff00) != 0) { airo_print_err(ai->dev->name, "%s: Write rid Error %d", __func__, rc); @@ -4292,7 +4296,7 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) cmd.parm0 = lenPayload; if (down_interruptible(&ai->sem)) return ERROR; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) { + if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { txFid = ERROR; goto done; } @@ -4338,7 +4342,8 @@ static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) /* In general BAP1 is dedicated to transmiting packets. However, since we need a BAP when accessing RIDs, we also use BAP1 for that. Make sure the BAP1 spinlock is held when this is called. */ -static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) +static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket, + bool may_sleep) { __le16 payloadLen; Cmd cmd; @@ -4376,12 +4381,14 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_TRANSMIT; cmd.parm0 = txFid; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; + if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) + return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR; return SUCCESS; } -static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) +static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket, + bool may_sleep) { __le16 fc, payloadLen; Cmd cmd; @@ -4416,7 +4423,8 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket) memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_TRANSMIT; cmd.parm0 = txFid; - if (issuecommand(ai, &cmd, &rsp) != SUCCESS) return ERROR; + if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) + return ERROR; if ((rsp.status & 0xFF00) != 0) return ERROR; return SUCCESS; } @@ -5480,7 +5488,7 @@ static int proc_BSSList_open(struct inode *inode, struct file *file) kfree(file->private_data); return -ERESTARTSYS; } - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); up(&ai->sem); data->readlen = 0; return 0; @@ -5617,7 +5625,7 @@ static int __maybe_unused airo_pci_suspend(struct device *dev_d) netif_device_detach(dev); ai->power = PMSG_SUSPEND; cmd.cmd = HOSTSLEEP; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); device_wakeup_enable(dev_d); return 0; @@ -5960,7 +5968,7 @@ static int airo_set_wap(struct net_device *dev, cmd.cmd = CMD_LOSE_SYNC; if (down_interruptible(&local->sem)) return -ERESTARTSYS; - issuecommand(local, &cmd, &rsp); + issuecommand(local, &cmd, &rsp, true); up(&local->sem); } else { memset(APList_rid, 0, sizeof(*APList_rid)); @@ -7258,7 +7266,7 @@ static int airo_set_scan(struct net_device *dev, ai->scan_timeout = RUN_AT(3*HZ); memset(&cmd, 0, sizeof(cmd)); cmd.cmd = CMD_LISTBSS; - issuecommand(ai, &cmd, &rsp); + issuecommand(ai, &cmd, &rsp, true); wake = 1; out: @@ -7525,7 +7533,7 @@ static int airo_config_commit(struct net_device *dev, writeConfigRid(local, 0); enable_MAC(local, 0); if (test_bit (FLAG_RESET, &local->flags)) - airo_set_promisc(local); + airo_set_promisc(local, true); else up(&local->sem); From patchwork Tue Oct 27 22:54:49 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: 310726 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=unavailable 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 B0900C55178 for ; Tue, 27 Oct 2020 22:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EE912225E for ; Tue, 27 Oct 2020 22:56:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IrVDFjU5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1hcOJSQq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832600AbgJ0W4Z (ORCPT ); Tue, 27 Oct 2020 18:56:25 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50198 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832548AbgJ0W4A (ORCPT ); Tue, 27 Oct 2020 18:56:00 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839357; 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=DjmStdTYpXx0Q5cgHBNYgoGt1xQMDGvpBhIAE5x62bo=; b=IrVDFjU5wiUh3/1b+EWqAdpLz9jEaa0feaxAB0seewu3KP62xQWrIDIDRFVfJR88akb5V8 pixqewfSpPphy6wjIpk84kuwnoRmYibI+WPGXbSjRtkxqKuGHv479c5O+07RtRHzWP9EyO /XS2O6gq02ndIa9jvIju3YeZBwPe7jdNPpcZYA5f5c/yCRKzmmvrHi/lomT6/LJwNTuzDq 79tALLYTDN3HvBlJ21WplNePz/PcB96jD/urLc/mb0VXNxgXdrKoOYIKtApY4oS3NuMRJx udPmRn5otfroi+DJXX7goaPxUdhrmyFNBJYKUfaap+PqN/QIS+Vy6OoaWTLFrw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839357; 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=DjmStdTYpXx0Q5cgHBNYgoGt1xQMDGvpBhIAE5x62bo=; b=1hcOJSQqWKvZ0z3m9yg8HSR6q16whMj9tbVFBVxwm9sIAnvgysjdR0EPOnpijehHN6jTXv eMzOMmrlvWnhypDQ== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 10/15] net: zd1211rw: Remove in_atomic() usage. Date: Tue, 27 Oct 2020 23:54:49 +0100 Message-Id: <20201027225454.3492351-11-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The usage of in_atomic() in driver code is deprecated as it can not always detect all states where it is not allowed to sleep. All callers are in premptible thread context and all functions invoke core functions which have checks for invalid calling contexts already. Signed-off-by: Sebastian Andrzej Siewior Cc: Daniel Drake Cc: Ulrich Kunitz Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c index 66367ab7e4c1e..5c4cd0e1adebb 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c @@ -1711,11 +1711,6 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, count, USB_MAX_IOREAD16_COUNT); return -EINVAL; } - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } if (!usb_int_enabled(usb)) { dev_dbg_f(zd_usb_dev(usb), "error: usb interrupt not enabled\n"); @@ -1882,11 +1877,6 @@ int zd_usb_iowrite16v_async(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs, count, USB_MAX_IOWRITE16_COUNT); return -EINVAL; } - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } udev = zd_usb_to_usbdev(usb); @@ -1966,11 +1956,6 @@ int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits) int i, req_len, actual_req_len; u16 bit_value_template; - if (in_atomic()) { - dev_dbg_f(zd_usb_dev(usb), - "error: io in atomic context not supported\n"); - return -EWOULDBLOCK; - } if (bits < USB_MIN_RFWRITE_BIT_COUNT) { dev_dbg_f(zd_usb_dev(usb), "error: bits %d are smaller than" From patchwork Tue Oct 27 22:54:51 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: 310727 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=unavailable 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 8531DC4363A for ; Tue, 27 Oct 2020 22:56:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42FFA2222C for ; Tue, 27 Oct 2020 22:56:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fnnyXMra"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LhRto8Gj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832565AbgJ0W4F (ORCPT ); Tue, 27 Oct 2020 18:56:05 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50018 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832551AbgJ0W4C (ORCPT ); Tue, 27 Oct 2020 18:56:02 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839360; 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=JUnXmlM0pClR2oSFLL6eEWvAWYA2QW+YiY+0XjVZIZk=; b=fnnyXMraO7p09sICaO22cniixEyjU6BSK7GQa102YZaPqJxYBdda0nB0KIVATJejAL2/uz dwW8QXz8mYyHf6wvdEv7B65G3nJKntzU59jdHqIxSRlqilM5Vpr2wvnrE51RINrrYRVHRe PYThagWLiHUWO7FhC2mnHwrFy3IVdjNUgiL/XlYmlMRWAIK8uRUEfGiNl6/NLx6ZPnjmoB m4EKy+VbBc7Z5MDc3k5wsXGmgmNm3efPQ927+tdFrQs6gVq2oP42ouJmxLfX8u0K7yq3H2 VBX44HdWy79z0/CZfIzePmm3knhG8C2g58k2rdVTD1aHkbRQndTEpRqc79jH7Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839360; 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=JUnXmlM0pClR2oSFLL6eEWvAWYA2QW+YiY+0XjVZIZk=; b=LhRto8GjrXrS3x1WtqyEzaR2oSLcCb9lDG0/JNGC54mzzO12yMUMHiL7FS5TIt+/eyI4fV suVt8QjXdQk+iCAw== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 12/15] net: rtlwifi: Remove in_interrupt() usage in halbtc_send_bt_mp_operation() Date: Tue, 27 Oct 2020 23:54:51 +0100 Message-Id: <20201027225454.3492351-13-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org halbtc_send_bt_mp_operation() uses in_interrupt() to determine if it is safe to invoke wait_for_completion(). 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. Aside of that in_interrupt() is not correct as it does not catch preempt disabled regions which neither can sleep. halbtc_send_bt_mp_operation() is called from: rtl_watchdog_wq_callback() rtl_btc_periodical() halbtc_get() case BTC_GET_U4_BT_PATCH_VER: halbtc_get_bt_patch_version() which is preemtible context. rtl_c2h_content_parsing() btc_ops->btc_btinfo_notify() rtl_btc_btinfo_notify() exhalbtc_bt_info_notify() ex_btc8723b1ant_bt_info_notify() ex_btc8821a1ant_bt_info_notify() ex_btc8821a2ant_bt_info_notify() btcoexist->btc_set_bt_reg() halbtc_set_bt_reg() rtl_c2h_content_parsing() is in turn called from: rtl_c2hcmd_wq_callback() rtl_c2hcmd_launcher() which is preemptible context and from: _rtl_pci_rx_interrupt rtl_c2hcmd_enqueue() which is obviously not preemptible but limited to C2H_BT_MP commands which does invoke rtl_c2h_content_parsing(). Aside of that it can be reached from: halbtc_get() case BTC_GET_U4_SUPPORTED_FEATURE: halbtc_get_bt_coex_supported_feature() case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL: halbtc_get_bt_forbidden_slot_val() case BTC_GET_U4_BT_DEVICE_INFO: halbtc_get_bt_device_info() case BTC_GET_U4_SUPPORTED_VERSION: halbtc_get_bt_coex_supported_version() case BTC_GET_U4_SUPPORTED_FEATURE: halbtc_get_bt_coex_supported_feature() btcoexist->btc_get_bt_afh_map_from_bt() halbtc_get_bt_afh_map_from_bt() btcoexist->btc_get_ble_scan_para_from_bt() halbtc_get_ble_scan_para_from_bt() btcoexist->btc_get_ble_scan_type_from_bt() halbtc_get_ble_scan_type_from_bt() btcoexist->btc_get_ant_det_val_from_bt() halbtc_get_ant_det_val_from_bt() btcoexist->btc_get_bt_coex_supported_version() halbtc_get_bt_coex_supported_version() btcoexist->btc_get_bt_coex_supported_feature() halbtc_get_bt_coex_supported_feature() None of these have a caller. Welcome to the wonderful world of HALs and onion layers. Remove in_interrupt() check. Signed-off-by: Sebastian Andrzej Siewior Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c index 2155a6699ef8d..be4c0e60d44d1 100644 --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c @@ -240,9 +240,6 @@ bool halbtc_send_bt_mp_operation(struct btc_coexist *btcoexist, u8 op_code, rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms); - if (in_interrupt()) - return false; - if (wait_for_completion_timeout(&btcoexist->bt_mp_comp, msecs_to_jiffies(wait_ms)) == 0) { rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, From patchwork Tue Oct 27 22:54:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 310728 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=unavailable 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 28EFAC4363A for ; Tue, 27 Oct 2020 22:56:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9777221F7 for ; Tue, 27 Oct 2020 22:56:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HCswUXFn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oAEOw6n2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832526AbgJ0W4H (ORCPT ); Tue, 27 Oct 2020 18:56:07 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50362 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832562AbgJ0W4F (ORCPT ); Tue, 27 Oct 2020 18:56:05 -0400 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603839362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JdH9fbe/FwP3XeKGJ3l0Cm+b4e3o/aTEE/5T4JYIZFo=; b=HCswUXFnBU+7krIAiJOvKpJSk3khqzvmKXrOz1gM0erhfW+xw/741cfqlWqCbrRKLGLiBt 2ZUaoSP5ox8MMXp4zr4zTdeIQdrQbLDd0lfErEBFbuXJjY3Sl3TG4/ouW5bIhvmTNIXpU2 BTxYIVC5S4gOd9AbXC9lwhtY+aEdK+XsyZo+dmWM4PBHrMzxjgQL0BRejFLweIG6Bz/IjH nC8PmUrMrQF9GbZZGnV1R5kFKPY2Fs+ZajwTg/K7K2jZYCeoeZvjAFEvEq0xdkMubwsmn/ UsR1mqQZqTsrHdN5Gr4QV7uqdaWF2X7OF6/NuBkY5fZeD4jNj5by8GNXbkDe4w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603839362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JdH9fbe/FwP3XeKGJ3l0Cm+b4e3o/aTEE/5T4JYIZFo=; b=oAEOw6n2K77vQLRBPQlNlkEg06bqlyVo2TatzLpimvX8utPK3aWhDMLaJa4tCTD6u/57ST kccvLXygOL73iBBg== To: netdev@vger.kernel.org Cc: Aymen Sghaier , Daniel Drake , "David S. Miller" , Herbert Xu , =?utf-8?q?Horia_Geant=C4=83?= , Jakub Kicinski , Jon Mason , Jouni Malinen , Kalle Valo , Leon Romanovsky , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, Li Yang , Madalin Bucur , Ping-Ke Shih , Rain River , Saeed Mahameed , Samuel Chessman , Ulrich Kunitz , Zhu Yanjun , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH net-next 14/15] net: dpaa: Replace in_irq() usage. Date: Tue, 27 Oct 2020 23:54:53 +0100 Message-Id: <20201027225454.3492351-15-bigeasy@linutronix.de> In-Reply-To: <20201027225454.3492351-1-bigeasy@linutronix.de> References: <20201027225454.3492351-1-bigeasy@linutronix.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The driver uses in_irq() + in_serving_softirq() magic to decide if NAPI scheduling is required or packet processing. The usage of in_*() in drivers is phased out and 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. Use the `napi' argument passed by the callback. It is set true if called from the interrupt handler and NAPI should be scheduled. Signed-off-by: Sebastian Andrzej Siewior Cc: "Horia Geantă" Cc: Aymen Sghaier Cc: Herbert Xu Cc: "David S. Miller" Cc: Madalin Bucur Cc: Jakub Kicinski Cc: Li Yang Cc: linux-crypto@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 27835310b718e..2c949acd74c67 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2300,9 +2300,9 @@ static void dpaa_tx_conf(struct net_device *net_dev, } static inline int dpaa_eth_napi_schedule(struct dpaa_percpu_priv *percpu_priv, - struct qman_portal *portal) + struct qman_portal *portal, bool napi) { - if (unlikely(in_irq() || !in_serving_softirq())) { + if (napi) { /* Disable QMan IRQ and invoke NAPI */ qman_p_irqsource_remove(portal, QM_PIRQ_DQRI); @@ -2333,7 +2333,7 @@ static enum qman_cb_dqrr_result rx_error_dqrr(struct qman_portal *portal, percpu_priv = this_cpu_ptr(priv->percpu_priv); - if (dpaa_eth_napi_schedule(percpu_priv, portal)) + if (dpaa_eth_napi_schedule(percpu_priv, portal, napi)) return qman_cb_dqrr_stop; dpaa_eth_refill_bpools(priv); @@ -2377,7 +2377,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, percpu_priv = this_cpu_ptr(priv->percpu_priv); percpu_stats = &percpu_priv->stats; - if (unlikely(dpaa_eth_napi_schedule(percpu_priv, portal))) + if (unlikely(dpaa_eth_napi_schedule(percpu_priv, portal, napi))) return qman_cb_dqrr_stop; /* Make sure we didn't run out of buffers */ @@ -2474,7 +2474,7 @@ static enum qman_cb_dqrr_result conf_error_dqrr(struct qman_portal *portal, percpu_priv = this_cpu_ptr(priv->percpu_priv); - if (dpaa_eth_napi_schedule(percpu_priv, portal)) + if (dpaa_eth_napi_schedule(percpu_priv, portal, napi)) return qman_cb_dqrr_stop; dpaa_tx_error(net_dev, priv, percpu_priv, &dq->fd, fq->fqid); @@ -2499,7 +2499,7 @@ static enum qman_cb_dqrr_result conf_dflt_dqrr(struct qman_portal *portal, percpu_priv = this_cpu_ptr(priv->percpu_priv); - if (dpaa_eth_napi_schedule(percpu_priv, portal)) + if (dpaa_eth_napi_schedule(percpu_priv, portal, napi)) return qman_cb_dqrr_stop; dpaa_tx_conf(net_dev, priv, percpu_priv, &dq->fd, fq->fqid);