From patchwork Tue Jun 5 11:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137711 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp850129lji; Tue, 5 Jun 2018 04:43:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLrs9kzLn4lNi2Gp3Xl/Myp3ivPg2JU0A78PIFXfFvoF0dw8FwAqigbSGfI82DtfsZwCgrR X-Received: by 2002:a63:aa07:: with SMTP id e7-v6mr20497214pgf.331.1528198993184; Tue, 05 Jun 2018 04:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528198993; cv=none; d=google.com; s=arc-20160816; b=e6Rde/mD6s97e9+AJiKfOcAFxfA7gjgnPrkMX8ZPTkChLmBU/A2SpO6tP+IGNMvvdk LV0+tRM/DIj2mJ2Cn61EJvUlyQTbLiTl1tGN0LHBujDqyJPAMy0pTnHBHZ1ss/R9y8bx XFHr4lhNIDdbRzGxzlQslWyB9JvzK57032+CScvY3YJh0XnuOlr1B3MPY6VyJL7B6uGu LMyWGB3SAIZaEEz84vkYcHqCw4Fmcv7OjpTUw3QNpCrFo5w6cC2o9EebWQ9Tj7dc0Cde 60Zq9Wub1qer0P2L8z6KSuV/qAn02Lk0S1FzSLcYKPpVGR/ayyucqvjX6gXnqKAcqj0A i1CQ== 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:arc-authentication-results; bh=YvY2bOgjW0qWrfCtwMnX6EeGTJsQ+jBOF/XFQEpPMhw=; b=lIc8o9PQjpPkMUBartNDwBDGQH93mmzzxuKLRJaBtn8sB762RPWt5dHerRpQFehf5Y ytCU4bvzPV97zrgf9R2Yz5aC1j+dTkedcXH794lyomE7lMIr4UVFxqEwmO7KpCgI8Je1 L8jOeGAPclfo1JJ7he57NPIsa/vHS5VJhHfKnLluz3PlTQelOJbNcboyd56PtQW8VkT+ BCLpP8B5dfHN3U9IJfekOZwtm5Gd3zsTqXG4g7DGjduLplkBRHd8Tlb5W7uL6hz40DI+ 9EfvS+1y3vOOXTsPk+l4GdGPLT/QnNCRBcn24GbXCA+VXRk9uu15EQbn5DFICvva7cwV e97A== 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 e11-v6si36165523pgs.476.2018.06.05.04.43.12; Tue, 05 Jun 2018 04:43:13 -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 S1751929AbeFELnL (ORCPT + 30 others); Tue, 5 Jun 2018 07:43:11 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8695 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751856AbeFELnI (ORCPT ); Tue, 5 Jun 2018 07:43:08 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9BF17D6669B82; Tue, 5 Jun 2018 19:42:53 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Tue, 5 Jun 2018 19:42:45 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net-next 1/3] net: hns3: Fix for VF mailbox cannot receiving PF response Date: Tue, 5 Jun 2018 12:41:59 +0100 Message-ID: <20180605114201.29900-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180605114201.29900-1-salil.mehta@huawei.com> References: <20180605114201.29900-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang When the VF frequently switches the CMDQ interrupt, if the CMDQ_SRC is not cleared, the VF will not receive the new PF response after the interrupt is re-enabled, the corresponding log is as follows: [ 317.482222] hns3 0000:00:03.0: VF could not get mbx resp(=0) from PF in 500 tries [ 317.483137] hns3 0000:00:03.0: VF request to get tqp info from PF failed -5 This patch fixes this problem by clearing CMDQ_SRC before enabling interrupt and syncing pending IRQ handlers after disabling interrupt. Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index dd8e8e6..d55ee9c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1576,6 +1576,8 @@ static int hclgevf_misc_irq_init(struct hclgevf_dev *hdev) return ret; } + hclgevf_clear_event_cause(hdev, 0); + /* enable misc. vector(vector 0) */ hclgevf_enable_vector(&hdev->misc_vector, true); @@ -1586,6 +1588,7 @@ static void hclgevf_misc_irq_uninit(struct hclgevf_dev *hdev) { /* disable misc vector(vector 0) */ hclgevf_enable_vector(&hdev->misc_vector, false); + synchronize_irq(hdev->misc_vector.vector_irq); free_irq(hdev->misc_vector.vector_irq, hdev); hclgevf_free_vector(hdev, 0); } From patchwork Tue Jun 5 11:42:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137713 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp850646lji; Tue, 5 Jun 2018 04:43:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI81UNZzcNrydso5T8zyVX+UPuZxhjBHLV3LfAe7+iALOhABZ+tax+bxFdHWDin8H+x6Eyy X-Received: by 2002:a63:6dce:: with SMTP id i197-v6mr14985920pgc.215.1528199027878; Tue, 05 Jun 2018 04:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528199027; cv=none; d=google.com; s=arc-20160816; b=mkVNf+8IBCyvxCNpBjQiOqsxczKZGGeK+nj6krvSAl1bKtp0l9SPSsnkGjkvz11EEY 0H5DEqflJ2K5hVNnaQF5RxaYTkYKJPo4nObNniDfubSLTTLoGVvKTjYytT+ptSn74JGp 8zkErBvhgSCHz3s5gedIF9EODCYywWZLs7m6v7MoDNIYkox0Iw89U2WOQSQbAugLlhBC 6Z3kJWAahZXGB4xjwJWs0ds65Ge1ipY/F4D5x57rNHYL6YgBGwn+31zUGiuKyuuxQnaU eo8mAa7k9zQiNXA9xIwxOzC9fXC3U0/vUXk7k4VEaEcSL+aPji2Yc4PFW2w/Ucq/rxB3 UQsg== 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:arc-authentication-results; bh=vGS1L2WqciQtHTFWZci1SxLp953fa3RmW7nswYfC9ak=; b=EIqi4o1PWFAS4QhHViKcyC1rVdmguOYfNeqNnGR/yLbVHsm+ErfEbgyLivhxhcRlKh POStc6oS0QPztW5BcXoBe781YR+dpSKwGPnO9B+RGqCPsTFANqy5+IqXgxzCH6atmReF sWTN6g/ss2uhC+r/16i2WHloM07ekxHnfj3uLuaoNsoDMNL4XXzdkyuH99kOSAj2M2iF 2+4BPNTNRqkJ+hEypqqfRUHrbLhwaSQ46Y5f+S0R2vQ4UeKoVKaVWZpGOSP2JVa+VrJc +TvHWIX2MBvqLAAXqaT3bi7DiHPXlGKW40g4qboCed9mlvFniUg8cniqEx6jEsm6Qotg svJw== 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 k5-v6si8598725pgs.680.2018.06.05.04.43.47; Tue, 05 Jun 2018 04:43:47 -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 S1751969AbeFELnp (ORCPT + 30 others); Tue, 5 Jun 2018 07:43:45 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8696 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751866AbeFELnK (ORCPT ); Tue, 5 Jun 2018 07:43:10 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8CD26CDE3E4FF; Tue, 5 Jun 2018 19:42:53 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Tue, 5 Jun 2018 19:42:48 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net-next 2/3] net: hns3: Fix for VF mailbox receiving unknown message Date: Tue, 5 Jun 2018 12:42:00 +0100 Message-ID: <20180605114201.29900-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180605114201.29900-1-salil.mehta@huawei.com> References: <20180605114201.29900-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang Before the firmware updates the crq's tail pointer, if the VF driver reads the data in the crq, the data may be incomplete at this time, which will lead to the driver read an unknown message. This patch fixes it by checking if crq is empty before reading the message. Fixes: b11a0bb231f3 ("net: hns3: Add mailbox support to VF driver") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index a286184..173ca27 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -126,6 +126,13 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, return status; } +static bool hclgevf_cmd_crq_empty(struct hclgevf_hw *hw) +{ + u32 tail = hclgevf_read_dev(hw, HCLGEVF_NIC_CRQ_TAIL_REG); + + return tail == hw->cmq.crq.next_to_use; +} + void hclgevf_mbx_handler(struct hclgevf_dev *hdev) { struct hclgevf_mbx_resp_status *resp; @@ -140,11 +147,22 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) resp = &hdev->mbx_resp; crq = &hdev->hw.cmq.crq; - flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); - while (hnae_get_bit(flag, HCLGEVF_CMDQ_RX_OUTVLD_B)) { + while (!hclgevf_cmd_crq_empty(&hdev->hw)) { desc = &crq->desc[crq->next_to_use]; req = (struct hclge_mbx_pf_to_vf_cmd *)desc->data; + flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); + if (unlikely(!hnae3_get_bit(flag, HCLGEVF_CMDQ_RX_OUTVLD_B))) { + dev_warn(&hdev->pdev->dev, + "dropped invalid mailbox message, code = %d\n", + req->msg[0]); + + /* dropping/not processing this invalid message */ + crq->desc[crq->next_to_use].flag = 0; + hclge_mbx_ring_ptr_move_crq(crq); + continue; + } + /* synchronous messages are time critical and need preferential * treatment. Therefore, we need to acknowledge all the sync * responses as quickly as possible so that waiting tasks do not @@ -205,7 +223,6 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) } crq->desc[crq->next_to_use].flag = 0; hclge_mbx_ring_ptr_move_crq(crq); - flag = le16_to_cpu(crq->desc[crq->next_to_use].flag); } /* Write back CMDQ_RQ header pointer, M7 need this pointer */ From patchwork Tue Jun 5 11:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137712 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp850248lji; Tue, 5 Jun 2018 04:43:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKAKUeqD/b3fZtGiMXGNB2mB6d2ujWJhs//1sBA+7kN7OTXtXur13bduEX8ca/9QkpyW5Kp X-Received: by 2002:a63:a00a:: with SMTP id r10-v6mr20796663pge.222.1528198999905; Tue, 05 Jun 2018 04:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528198999; cv=none; d=google.com; s=arc-20160816; b=CYsnlLPgaDRQbjpWlZzr8k+efTj5MX8k/EkdwRhRKZ2ZzHe0GIXxwgYUz8mbYTHw5Q s8E0htR067XfV6P8VxrSsxzaYO2/Ksc7OaDPnijXOrzrG8ld+KkTDsd/V6MdeE7PwssD GSiCvs7oiK7bibgVkhPlxMfJELARC9GMza9YpqmGLPq/1kPI+urHZxIEQYptfh944ZNh 0CasKz7znk9pzD82scXsnH08EI7tJcUfjckyr3dYlDufXbc6jQiNmW8dshLZ+82O4Uk/ rpf5+LvrMsey/22dNtaMw00VKjJWdyfYFOQ8qmxHXpuw1W73KTE8OciS3xwmoFrKtjeC SbDA== 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:arc-authentication-results; bh=rUgOCcetzR3rd/qOhiYTAQuxdtuSsjBHeb1E7oyQUns=; b=e3Vc0R395jHQiEX7FicYaiNn8FUHy05JYXSkPhUf5nu4bkrY7sJAqk441tVSDR74a8 eKJXfVEg4Rd5977W7ew2LcXnA7ClJzCaxGgqLJ/u8nH5GtcHgAdmqtfng76zyAcgi11G M1Fz1KaKzNn3CTPbba+2/5FA1aZ1QbT4TYJ5xNV9hT675nuUVjGFcVWPuz10uGLeu/YD FP2XH0Af+tKz03neipO5Tr+gqMeiTk4FI15Hm7GrZJGSUlphBCYjT/MvLTbGCyjFjqLs UznNI1/bw+E+rKPeN1yZmCukuPHvCMCIFu4tRT22OkiFd816eOASyarQs1L6S4emdwKf fETA== 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 k5-v6si8598725pgs.680.2018.06.05.04.43.19; Tue, 05 Jun 2018 04:43:19 -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 S1751953AbeFELnR (ORCPT + 30 others); Tue, 5 Jun 2018 07:43:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8644 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751721AbeFELnO (ORCPT ); Tue, 5 Jun 2018 07:43:14 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B68BC3F6DA4A; Tue, 5 Jun 2018 19:42:58 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Tue, 5 Jun 2018 19:42:50 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net-next 3/3] net: hns3: Optimize PF CMDQ interrupt switching process Date: Tue, 5 Jun 2018 12:42:01 +0100 Message-ID: <20180605114201.29900-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180605114201.29900-1-salil.mehta@huawei.com> References: <20180605114201.29900-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang When the PF frequently switches the CMDQ interrupt, if the CMDQ_SRC is not cleared before the hardware interrupt is generated, the new interrupt will not be reported. This patch optimizes this problem by clearing CMDQ_SRC and RESET_STS before enabling interrupt and syncing pending IRQ handlers after disabling interrupt. Fixes: 466b0c00391b ("net: hns3: Add support for misc interrupt") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2a80134..d318d35 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2557,6 +2557,15 @@ static void hclge_clear_event_cause(struct hclge_dev *hdev, u32 event_type, } } +static void hclge_clear_all_event_cause(struct hclge_dev *hdev) +{ + hclge_clear_event_cause(hdev, HCLGE_VECTOR0_EVENT_RST, + BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) | + BIT(HCLGE_VECTOR0_CORERESET_INT_B) | + BIT(HCLGE_VECTOR0_IMPRESET_INT_B)); + hclge_clear_event_cause(hdev, HCLGE_VECTOR0_EVENT_MBX, 0); +} + static void hclge_enable_vector(struct hclge_misc_vector *vector, bool enable) { writel(enable ? 1 : 0, vector->addr); @@ -5688,6 +5697,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) INIT_WORK(&hdev->rst_service_task, hclge_reset_service_task); INIT_WORK(&hdev->mbx_service_task, hclge_mailbox_service_task); + hclge_clear_all_event_cause(hdev); + /* Enable MISC vector(vector0) */ hclge_enable_vector(&hdev->misc_vector, true); @@ -5817,6 +5828,8 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) /* Disable MISC vector(vector0) */ hclge_enable_vector(&hdev->misc_vector, false); + synchronize_irq(hdev->misc_vector.vector_irq); + hclge_destroy_cmd_queue(&hdev->hw); hclge_misc_irq_uninit(hdev); hclge_pci_uninit(hdev);