Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2898859pxb; Tue, 24 Aug 2021 10:08:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2CeWSsb0RA0ku979bLPuhkFXg4oUxg7QMRSFS4UI3HmfCi6XjNUYJZe+3CBOuKOfBFm4W X-Received: by 2002:a17:907:92c:: with SMTP id au12mr6785150ejc.523.1629824930779; Tue, 24 Aug 2021 10:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824930; cv=none; d=google.com; s=arc-20160816; b=TNx/rncJNbmvyW6LA0gjmBsJktkpvw0XYHbbU5Kwk9IJSenb+jRyq5Ac6FFBntcaLh qwyWF7ZyVRY6/svuG1oAu2urlAXUtFpklXb1MssrnwOOVYC2VNPJTcggMMnZ0H8pf8Sp Uiph+0w2nj76c6fJtXU1qZQjQLdzFtyqQoH+ZxYt7w+2JNMvhNBR8R6A4YsguDEf6dkM FULFWEZN1aJxfpYdDKlVG23+qiUj1n33F1ZW0tmsOFqKtzUZhc34uVTCIUdA4/du20AF +mBvz8Y5+8KRUicTyeynDAlftNS2hI8BOYNCiX/0L4FukwB6ABjHboZRg7hCOE9pNW8Q J3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LmOzsx1yUUb+BpqQG7VCMfafyHqkR0vVxKZRG2bfCZY=; b=fyv03WsonQAZSp4tl+ixsBzgdrKDxbptS6AAHuuVspnSU9aT5GtzrXbnIVSZJoPgwv fs/yiO+7f51Tamkt/+bplLokOilN0a23mjrrjvIJOtjICHTNfarrODK3tfjy1agvyzlt PpJX8PLV037lQ2mf2Cs7s11EmJMOhX1VOgPCj/1HsmEvO00aobruw+YlaP/mfI449cjx wvfhAhsRYsj0jXnSE8J3xZCLwtJkEhW2PwSfq3V8aQ076VxAx2HYIX9FNPIdgq/zPdpr EffIonFbZKNsJyah1Fidi5r2SIxlSq3W2vPBH6Ye9IKxwUQM9CCkdbkpb/1CbD980RfH vapw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HHJDGtKZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si17188112edy.419.2021.08.24.10.08.27; Tue, 24 Aug 2021 10:08:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HHJDGtKZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbhHXRHr (ORCPT + 99 others); Tue, 24 Aug 2021 13:07:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239852AbhHXRFC (ORCPT ); Tue, 24 Aug 2021 13:05:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84EC761501; Tue, 24 Aug 2021 16:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824378; bh=qon0AMhRRPKgmGhJwGKu2wgu5lQuEa/liFHyFJtUuTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHJDGtKZ7ZN+TK/bx1B8iAXm+Vn1WdC5lJQXo3WmZtU57A3J9bLQYkSG2Ii5ft0t/ tboXvIIVPceKxsBpjOvO6q0bySR+n0M89LxflS7nEpHnBKeX+DjXczSkrzTGcqnBOO fTAuRLYC2RicA+EXAsALtyjwkArNNdlm5b4SLVKNqfRtdxqCIGHLnLcpmEEW+42Ynj ESdFlhL5Z25iHtSi32XoOCJ1T8AvNxH9d0vcGg1mNFuMf+ut5fjh/YttctZEy/EV2a Lj3+ESWNZ4SDrI/WFh18W8x7cGRXWbRC5lo1H//seiD/bmaPshcR4GnoL4XNYr4rVX s1TliUVqVLe4g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Prabhakar Kushwaha , Alok Prasad , Shai Malin , Ariel Elior , "David S . Miller" , Sasha Levin Subject: [PATCH 5.10 28/98] qede: fix crash in rmmod qede while automatic debug collection Date: Tue, 24 Aug 2021 12:57:58 -0400 Message-Id: <20210824165908.709932-29-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prabhakar Kushwaha [ Upstream commit 1159e25c137422bdc48ee96e3fb014bd942092c6 ] A crash has been observed if rmmod is done while automatic debug collection in progress. It is due to a race condition between both of them. To fix stop the sp_task during unload to avoid running qede_sp_task even if they are schedule during removal process. Signed-off-by: Alok Prasad Signed-off-by: Shai Malin Signed-off-by: Ariel Elior Signed-off-by: Prabhakar Kushwaha Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qede/qede.h | 1 + drivers/net/ethernet/qlogic/qede/qede_main.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h index 3efc5899f656..f313fd730331 100644 --- a/drivers/net/ethernet/qlogic/qede/qede.h +++ b/drivers/net/ethernet/qlogic/qede/qede.h @@ -494,6 +494,7 @@ struct qede_fastpath { #define QEDE_SP_HW_ERR 4 #define QEDE_SP_ARFS_CONFIG 5 #define QEDE_SP_AER 7 +#define QEDE_SP_DISABLE 8 #ifdef CONFIG_RFS_ACCEL int qede_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c index 05e3a3b60269..d9a3c811ac8b 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c @@ -1006,6 +1006,13 @@ static void qede_sp_task(struct work_struct *work) struct qede_dev *edev = container_of(work, struct qede_dev, sp_task.work); + /* Disable execution of this deferred work once + * qede removal is in progress, this stop any future + * scheduling of sp_task. + */ + if (test_bit(QEDE_SP_DISABLE, &edev->sp_flags)) + return; + /* The locking scheme depends on the specific flag: * In case of QEDE_SP_RECOVERY, acquiring the RTNL lock is required to * ensure that ongoing flows are ended and new ones are not started. @@ -1297,6 +1304,7 @@ static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode) qede_rdma_dev_remove(edev, (mode == QEDE_REMOVE_RECOVERY)); if (mode != QEDE_REMOVE_RECOVERY) { + set_bit(QEDE_SP_DISABLE, &edev->sp_flags); unregister_netdev(ndev); cancel_delayed_work_sync(&edev->sp_task); -- 2.30.2