Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1875861yba; Thu, 25 Apr 2019 07:09:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNBnRhtz3bVMvp8tLQ6TEwvJ0K76cLK4d49jPSAiWtSR/gerTK/YMmnHT5LHUypupNw01P X-Received: by 2002:a17:902:1103:: with SMTP id d3mr2080327pla.247.1556201346529; Thu, 25 Apr 2019 07:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556201346; cv=none; d=google.com; s=arc-20160816; b=yMeJxebnz94eY9LpQRBADeWL10ACEF5AtTNg1LyclJw56XpLucVMCOGv8L6kUy2lrw AgaRj19TYn5qN/+CfWp094ZoojTpks7d9vHypbTyR6scccmEVukaEwkVx0pLWwMvXUSb QVGx0LQyHQpjwZAFwpcifztMoKHHjlvrqprPR9w9z36j3jRV3DkC8HXQOMdN7BgmRtgi BHXA616SnHz8tvaIEctI2jWlAaamVZm5cON9Q5DrXQGbBnNYlhrs5Iv0vLGydgwU1BGA aaGhcTVhKruA5oTjlVKffIOzubNioCv8uucmoSEZJWF2bnJE8lKtTWyv5v+rItuv6w+U Bw9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=jhqaRlejM4EaQDZBFU9VjssXubH0anPSqYDhMLRzr2A=; b=RhOrCkA1BmOGlYpKw1AXMBvaAh2JbVeK7iQmQWoUviY+cTa48oQiSL/Dg6n6oNtl59 Einh4v1iuraIpNewCA+cE8EdYYOC8Zodp/PBYL404XvxeCzVKfMcPz5AHZG8YwjvOHrA wdBSkwZe009Xg8C3Gn6V4kUKIp8t7lz99haOFSwhDPwuOUWK6ETHPHrCZmnRWljnKI2d 60cgPBKhSEZk6UWM22Os6fHGylXh6Pz/mbojnGwjT3akTbe98m3CPhu4SL81gDXuFKBF SO4GrEDq6jDTjm0/nIASLSC1t5sSZRixXegbhAeh7Ow7qjUPlRBDAT+exU+akWjMAV8S s+kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61si22669980plb.410.2019.04.25.07.08.50; Thu, 25 Apr 2019 07:09:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731471AbfDYMpD (ORCPT + 99 others); Thu, 25 Apr 2019 08:45:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7690 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731397AbfDYMoQ (ORCPT ); Thu, 25 Apr 2019 08:44:16 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6B1F4271DC940DED6267; Thu, 25 Apr 2019 20:44:14 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Thu, 25 Apr 2019 20:44:04 +0800 From: Huazhong Tan To: CC: , , , , , , Huazhong Tan , Peng Li Subject: [PATCH V3 net-next 05/11] net: hns3: use atomic_t replace u32 for arq's count Date: Thu, 25 Apr 2019 20:42:49 +0800 Message-ID: <1556196175-65389-6-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556196175-65389-1-git-send-email-tanhuazhong@huawei.com> References: <1556196175-65389-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since irq handler and mailbox task will both update arq's count, so arq's count should use atomic_t instead of u32, otherwise its value may go wrong finally. Fixes: 07a0556a3a73 ("net: hns3: Changes to support ARQ(Asynchronous Receive Queue)") Signed-off-by: Huazhong Tan Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index 360463a..8b6191f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -111,7 +111,7 @@ struct hclgevf_mbx_arq_ring { struct hclgevf_dev *hdev; u32 head; u32 tail; - u32 count; + atomic_t count; u16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE]; }; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c index 1b428d4..71f356f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c @@ -340,7 +340,7 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev) hdev->arq.hdev = hdev; hdev->arq.head = 0; hdev->arq.tail = 0; - hdev->arq.count = 0; + atomic_set(&hdev->arq.count, 0); hdev->hw.cmq.csq.next_to_clean = 0; hdev->hw.cmq.csq.next_to_use = 0; hdev->hw.cmq.crq.next_to_clean = 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index eb56287..3c22639 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -212,7 +212,8 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) /* we will drop the async msg if we find ARQ as full * and continue with next message */ - if (hdev->arq.count >= HCLGE_MBX_MAX_ARQ_MSG_NUM) { + if (atomic_read(&hdev->arq.count) >= + HCLGE_MBX_MAX_ARQ_MSG_NUM) { dev_warn(&hdev->pdev->dev, "Async Q full, dropping msg(%d)\n", req->msg[1]); @@ -224,7 +225,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) memcpy(&msg_q[0], req->msg, HCLGE_MBX_MAX_ARQ_MSG_SIZE * sizeof(u16)); hclge_mbx_tail_ptr_move_arq(hdev->arq); - hdev->arq.count++; + atomic_inc(&hdev->arq.count); hclgevf_mbx_task_schedule(hdev); @@ -317,7 +318,7 @@ void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev) } hclge_mbx_head_ptr_move_arq(hdev->arq); - hdev->arq.count--; + atomic_dec(&hdev->arq.count); msg_q = hdev->arq.msg_q[hdev->arq.head]; } } -- 2.7.4