Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp272290pxt; Fri, 6 Aug 2021 01:25:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrRrQLC+WXRIQ+G5ectGVMhA1ge0hUryKW5cQa+YXArayLitoelH0T01cG76Bj9ExcN1D7 X-Received: by 2002:a05:6402:1d90:: with SMTP id dk16mr11502465edb.94.1628238342928; Fri, 06 Aug 2021 01:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628238342; cv=none; d=google.com; s=arc-20160816; b=0arhwyT4tFyts9KU8jiYj78mhCgp0hjbVJ9fN6iXS3Z8Cmo8GVQX5YRpHZvYATDmdH X/x1F05S+ITbNSdUPbJYhgR898n46h+WiEGR56S/c3OrrBN4cy+ppwvuh4CG5tkXH+Qr v6Hc0XUEY5kQ+DBeack/+1PQ2CGxGQGFwkhDHHsiN+79sTpw00yB/BBeLQAPz4Paqrcq /86//JOXt0NDLw8mjCau1xQ8k0wHvayO2fJ7cKbMDJCj1zDlLzVNg2vLuQt9GaLIOiGV oxniglUzsy6+z8e2O9DmvOnuJfLJjLZ4Oq33KUoFq4wy2bAv6nN594MZNKWWxve7esYU CzDQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m83tihsOnLNX6vtUEjqlqVJrQPaFjwaoUkG3ffRNxq0=; b=K+rhOhCO1KrgNfeG2qX8rQmikNXXKFUm6iZPF4KOHD/zB8OQw5FGRUf9CsGMpe8xeX U0RtkIQZWNTZ4Iw/efmh0yn9Aji53k2OJxcQYr+xLegPHS3PhdvK5QTd5144e5rzntzz 3tZDb/ra66kzi12LXMUpzj7CQKGb+cILX3JJ4de+3qVMTRxYl0ObEzKZ8xRx1OZ6r8K7 BHgF1NEbZ5KESQIdhOC6MscM/1EXsInQ4ErXwdWCg+pGUCckP5hLRA0BrVvZfkWrhO96 2GG9AVN7+2jmCYTkXvCzSC/jUyc39iy0XqcGBxO/sT4X0zWq+YUD2uVYsaKtRbkZ3nnd Bb6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tYnBTopK; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si8199979edv.555.2021.08.06.01.25.18; Fri, 06 Aug 2021 01:25:42 -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=@linuxfoundation.org header.s=korg header.b=tYnBTopK; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244098AbhHFIVL (ORCPT + 99 others); Fri, 6 Aug 2021 04:21:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:46778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244111AbhHFISy (ORCPT ); Fri, 6 Aug 2021 04:18:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9028B611F0; Fri, 6 Aug 2021 08:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628237914; bh=8uPZydX9gBsF0it8nG3NA0wwVehYKRnuuB9H8lWB2Lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tYnBTopK1+j09ohaarSTURomW2iokvUJDQyp2S+PYjdMSad7yU5x+rlscCqHdi8oa 6juK9cbqPjsu13AJD6uXBcTNtidkMn0DLpIw/WsPETx0lUa0FSK8XeeF8jEYuywvSo U+N4AoJ9xiLySpgC4GNhM11V9QaAhWP5k4WIjyT0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lijian Zhang , Jia He , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 10/30] qed: fix possible unpaired spin_{un}lock_bh in _qed_mcp_cmd_and_union() Date: Fri, 6 Aug 2021 10:16:48 +0200 Message-Id: <20210806081113.476608100@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081113.126861800@linuxfoundation.org> References: <20210806081113.126861800@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia He [ Upstream commit 6206b7981a36476f4695d661ae139f7db36a802d ] Liajian reported a bug_on hit on a ThunderX2 arm64 server with FastLinQ QL41000 ethernet controller: BUG: scheduling while atomic: kworker/0:4/531/0x00000200 [qed_probe:488()]hw prepare failed kernel BUG at mm/vmalloc.c:2355! Internal error: Oops - BUG: 0 [#1] SMP CPU: 0 PID: 531 Comm: kworker/0:4 Tainted: G W 5.4.0-77-generic #86-Ubuntu pstate: 00400009 (nzcv daif +PAN -UAO) Call trace: vunmap+0x4c/0x50 iounmap+0x48/0x58 qed_free_pci+0x60/0x80 [qed] qed_probe+0x35c/0x688 [qed] __qede_probe+0x88/0x5c8 [qede] qede_probe+0x60/0xe0 [qede] local_pci_probe+0x48/0xa0 work_for_cpu_fn+0x24/0x38 process_one_work+0x1d0/0x468 worker_thread+0x238/0x4e0 kthread+0xf0/0x118 ret_from_fork+0x10/0x18 In this case, qed_hw_prepare() returns error due to hw/fw error, but in theory work queue should be in process context instead of interrupt. The root cause might be the unpaired spin_{un}lock_bh() in _qed_mcp_cmd_and_union(), which causes botton half is disabled incorrectly. Reported-by: Lijian Zhang Signed-off-by: Jia He Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qed/qed_mcp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c index cd882c453394..caeef25c89bb 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c @@ -474,14 +474,18 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); - if (!qed_mcp_has_pending_cmd(p_hwfn)) + if (!qed_mcp_has_pending_cmd(p_hwfn)) { + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); break; + } rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); - if (!rc) + if (!rc) { + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); break; - else if (rc != -EAGAIN) + } else if (rc != -EAGAIN) { goto err; + } spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); @@ -498,6 +502,8 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, return -EAGAIN; } + spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); + /* Send the mailbox command */ qed_mcp_reread_offsets(p_hwfn, p_ptt); seq_num = ++p_hwfn->mcp_info->drv_mb_seq; @@ -524,14 +530,18 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); - if (p_cmd_elem->b_is_completed) + if (p_cmd_elem->b_is_completed) { + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); break; + } rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); - if (!rc) + if (!rc) { + spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); break; - else if (rc != -EAGAIN) + } else if (rc != -EAGAIN) { goto err; + } spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); } while (++cnt < max_retries); @@ -554,6 +564,7 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn, return -EAGAIN; } + spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); qed_mcp_cmd_del_elem(p_hwfn, p_cmd_elem); spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); -- 2.30.2