From patchwork Wed Nov 23 10:06:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duoming Zhou X-Patchwork-Id: 24850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2706109wrr; Wed, 23 Nov 2022 02:30:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf54mPS2px/B7lodqq70OgI6YdgRsP+0LNNcIn8gtOXROtbEak1jE09Ov/MY/EZgU0xOcQ3t X-Received: by 2002:a17:906:9f10:b0:7ad:86f9:1d70 with SMTP id fy16-20020a1709069f1000b007ad86f91d70mr2685157ejc.179.1669199419855; Wed, 23 Nov 2022 02:30:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669199419; cv=none; d=google.com; s=arc-20160816; b=Ms4hW+o4BscBQI3wsxQbs1H2fFpE2e73d8B7fbh4pftY591P2y6U+nbZbhkz4X9qey 9Phgx6gIHC8crajb/sZRVswUcsnPRv4lpInxnufh5v3ntL0FbwWA3elD71t4Ruz/HABG l19DTRSk/jVCDkLzItOcyIiuXNruGHeKfmHuWwFgUGGFK/yTSWQByRmmEpqnDlCjFdkh T2M9GkI2k8oJWdlrXY60ZVPGMigbA9yUlYN9SYn1Bgpptiu2fLXHVntVpDNwrIQFZABD PiqoRL5hEAlPKXl1T6uDSitJtLwfkWjYYkXcOvQj7fiKCVxegtcBwCYllYRjJ0Yoj9+N rzbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=NY+p9JEChTJbDnn9X1Hhb/DS1OipdMrH3h9Kb/aDlT0=; b=QYqKpbI1LiuKGoGLT6OIfdZKvmYQ7HC6vC5ZJe0j9g5ksnBZ87aCBwdIrYxINNhIIP UMJOBM65ceHyRvdNHgVEBRttGReLHLYFu47v5z8fJVN5iTSlFcCRkPiZaNItr2bMq+/K c2pnXSj8BSbq6s60142O8KUNFvP5mxCiYrU6VktN7j8ixMYyZpW17WM3DHkCrv+qJi87 hG8n5KIjoW8jZ+/V+7PsbuwBFjxRn/yIBrseKVb8MQYU1gVB8gi53gt+Z5uutireOf1l Ilg4kpK5pKo+Ukc4xWKhjAxpnsNIQbpspzYNiWpF/Zzo+6NkEWt0qzYUUKexiWm7uO5I kn1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14-20020aa7df0e000000b004692dc7d456si10230582edy.370.2022.11.23.02.29.56; Wed, 23 Nov 2022 02:30:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237256AbiKWKTh (ORCPT + 99 others); Wed, 23 Nov 2022 05:19:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236347AbiKWKTH (ORCPT ); Wed, 23 Nov 2022 05:19:07 -0500 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99D82116058; Wed, 23 Nov 2022 02:07:05 -0800 (PST) Received: from ubuntu.localdomain (unknown [10.162.98.155]) by mail-app4 (Coremail) with SMTP id cS_KCgCHrN+y8H1jRKRPCA--.33927S2; Wed, 23 Nov 2022 18:06:49 +0800 (CST) From: Duoming Zhou To: linux-kernel@vger.kernel.org Cc: shshaikh@marvell.com, manishc@marvell.com, GR-Linux-NIC-Dev@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, Duoming Zhou Subject: [PATCH net] qlcnic: fix sleep-in-atomic-context bugs caused by msleep Date: Wed, 23 Nov 2022 18:06:42 +0800 Message-Id: <20221123100642.6922-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgCHrN+y8H1jRKRPCA--.33927S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CF47Aw4kAw1DCF18Xr17Awb_yoW8ur1fpr 4agF9rGr4DAr1Yy3yxAw18ZF98CayvyFyI9Fn8u393Xrn0yF1fJFy8Kw4fWa48ArykJFyj yr15Zan8ZF12yF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvm1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AE w4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2 IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2 z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcV Aq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j 6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64 vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28I cxkI7VAKI48JMxAIw28IcVCjz48v1sIEY20_GFWkJr1UJwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnU UI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAgcDAVZdtcjhAAAss8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750282450616669476?= X-GMAIL-MSGID: =?utf-8?q?1750282450616669476?= The watchdog timer is used to monitor whether the process of transmitting data is timeout. If we use qlcnic driver, the dev_watchdog() that is the timer handler of watchdog timer will call qlcnic_tx_timeout() to process the timeout. But the qlcnic_tx_timeout() calls msleep(), as a result, the sleep-in-atomic-context bugs will happen. The processes are shown below: (atomic context) dev_watchdog qlcnic_tx_timeout qlcnic_83xx_idc_request_reset qlcnic_83xx_lock_driver msleep --------------------------- (atomic context) dev_watchdog qlcnic_tx_timeout qlcnic_83xx_idc_request_reset qlcnic_83xx_lock_driver qlcnic_83xx_recover_driver_lock msleep Fix by changing msleep() to mdelay(), the mdelay() is busy-waiting and the bugs could be mitigated. Fixes: 629263acaea3 ("qlcnic: 83xx CNA inter driver communication mechanism") Signed-off-by: Duoming Zhou --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c index bd060768032..2fd5c6fdb50 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c @@ -2991,7 +2991,7 @@ static void qlcnic_83xx_recover_driver_lock(struct qlcnic_adapter *adapter) QLCWRX(adapter->ahw, QLC_83XX_RECOVER_DRV_LOCK, val); dev_info(&adapter->pdev->dev, "%s: lock recovery initiated\n", __func__); - msleep(QLC_83XX_DRV_LOCK_RECOVERY_DELAY); + mdelay(QLC_83XX_DRV_LOCK_RECOVERY_DELAY); val = QLCRDX(adapter->ahw, QLC_83XX_RECOVER_DRV_LOCK); id = ((val >> 2) & 0xF); if (id == adapter->portnum) { @@ -3027,7 +3027,7 @@ int qlcnic_83xx_lock_driver(struct qlcnic_adapter *adapter) if (status) break; - msleep(QLC_83XX_DRV_LOCK_WAIT_DELAY); + mdelay(QLC_83XX_DRV_LOCK_WAIT_DELAY); i++; if (i == 1)