Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3697546pxv; Mon, 26 Jul 2021 09:38:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoO5m/XEfac5GZmPgtaDUZwQHdrnZXcz693dRvJV4PW9WXFAtrbHhrnAAw3me9PFDpuKvL X-Received: by 2002:a05:6402:31a6:: with SMTP id dj6mr23132099edb.248.1627317505875; Mon, 26 Jul 2021 09:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317505; cv=none; d=google.com; s=arc-20160816; b=l9oPqGO1RMN5uEByoSMnJSfVXv2Cco6VtXKdxiJ3RUV03x4EG5wiGMaZ8g8C+0YBUO yRydsOgOW89jHSPu02Mrrrb1VVjc//mswpZc4pKLSzHXuGNAYIIx3x6m3ZjSHEfeWvNi I5s+4Z4ZkhwkpuYfqIXylRBspPbPUclSoz2PoaEWnrGt1hfDBbCFHi6gZBmuqIseVxbM I9L3UsPGVSo7p/ekdT/xVSAk13B0397HFmD+dOuWDDkHQAN5ZdnOBbyV2ub4vMvWOym3 lVUCa60xYOSBH3npWl5KKrdQVXNJbZnm23IUI3fkuKkgJDWkoCESJ1CrM9O6kDD/ReKG DRXg== 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=36LA+xDSA0I4KzZfwzhUoPQ8J3vwTAyYKpt0EfylNd4=; b=hTJnFODXvYot1fdFN76pDbDMGyEI7BgyE0RjORB6FFCNuhgkdnRy52sv+LOP2IVFyS W2d7N1QSaob/nIMsrqnyPtBeZOoIMdqCDYP9K9onrUU+W652l6hP/D9UwDi/R3NtaZ8n rrQFpbClOfzYdKj4kYRVBY95KfoPjqMOJHZVsg9lPwbkYAO4cOe38zMpdNQa6a9pA66e D1k/LcjkRZBzaxd9vzW3Zb6VksMQvP33e/Et0cvAb4W0qQ0qPtvsTkC5C81tZbUUKdlT 5+mLZ1n3Q2x0zg05fYW153tcJ28QSjM2tA8dend8Xk1dcjnh6TFRvps+0y3ZlUAsflQO 1/ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QA9bPIgC; 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 i14si444777eje.573.2021.07.26.09.38.02; Mon, 26 Jul 2021 09:38:25 -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=QA9bPIgC; 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 S238788AbhGZPyG (ORCPT + 99 others); Mon, 26 Jul 2021 11:54:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233904AbhGZPcv (ORCPT ); Mon, 26 Jul 2021 11:32:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4385F60C40; Mon, 26 Jul 2021 16:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315998; bh=O/uDQGTfxzNPMnwcyEV2gPyHXtuUgPJo1AwHDEq+VTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QA9bPIgCv99lTLGcU2SqFSAoYk02OeT2AtlS6vTIo9CwocEfzO8cXOR15abxeiu3V vGjjT+Aud862Pnzl8a1r3w3nkwNqCMztbJpYMFabZoFHo7XTwWmm/PAt/LVWPybFE7 Z+G3MVzPUbGT534pfdbuXXfxYL84CZ+BNQh/7szo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chengwen Feng , Guangbin Huang , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.13 113/223] net: hns3: fix possible mismatches resp of mailbox Date: Mon, 26 Jul 2021 17:38:25 +0200 Message-Id: <20210726153849.970126374@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@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: Chengwen Feng [ Upstream commit 1b713d14dc3c077ec45e65dab4ea01a8bc41b8c1 ] Currently, the mailbox synchronous communication between VF and PF use the following fields to maintain communication: 1. Origin_mbx_msg which was combined by message code and subcode, used to match request and response. 2. Received_resp which means whether received response. There may possible mismatches of the following situation: 1. VF sends message A with code=1 subcode=1. 2. PF was blocked about 500ms when processing the message A. 3. VF will detect message A timeout because it can't get the response within 500ms. 4. VF sends message B with code=1 subcode=1 which equal message A. 5. PF processes the first message A and send the response message to VF. 6. VF will identify the response matched the message B because the code/subcode is the same. This will lead to mismatch of request and response. To fix the above bug, we use the following scheme: 1. The message sent from VF was labelled with match_id which was a unique 16-bit non-zero value. 2. The response sent from PF will label with match_id which got from the request. 3. The VF uses the match_id to match request and response message. As for PF driver, it only needs to copy the match_id from request to response. Fixes: dde1a86e93ca ("net: hns3: Add mailbox support to PF driver") Signed-off-by: Chengwen Feng Signed-off-by: Guangbin Huang Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 6 ++++-- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index a2c17af57fde..d283beec9f66 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -135,7 +135,8 @@ struct hclge_mbx_vf_to_pf_cmd { u8 mbx_need_resp; u8 rsv1[1]; u8 msg_len; - u8 rsv2[3]; + u8 rsv2; + u16 match_id; struct hclge_vf_to_pf_msg msg; }; @@ -145,7 +146,8 @@ struct hclge_mbx_pf_to_vf_cmd { u8 dest_vfid; u8 rsv[3]; u8 msg_len; - u8 rsv1[3]; + u8 rsv1; + u16 match_id; struct hclge_pf_to_vf_msg msg; }; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index f1c9f4ada348..38b601031db4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -47,6 +47,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, resp_pf_to_vf->dest_vfid = vf_to_pf_req->mbx_src_vfid; resp_pf_to_vf->msg_len = vf_to_pf_req->msg_len; + resp_pf_to_vf->match_id = vf_to_pf_req->match_id; resp_pf_to_vf->msg.code = HCLGE_MBX_PF_VF_RESP; resp_pf_to_vf->msg.vf_mbx_msg_code = vf_to_pf_req->msg.code; -- 2.30.2