Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1357958imm; Tue, 2 Oct 2018 07:03:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV60PHVL9cr8t7w7oKJw/0PzyMIH0cIeejCm5l2+33XjDCzxHc+5zY48VcKYgR26HIFhbGQhy X-Received: by 2002:a17:902:1101:: with SMTP id d1-v6mr17186017pla.131.1538489011510; Tue, 02 Oct 2018 07:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538489011; cv=none; d=google.com; s=arc-20160816; b=FCJIa0wTVmDeE6o9pxLpLdN7ACp5ZmMYHvgt5EBNkwVw0p8NBajZ5C4h6X+hiLq9lF PrNVizjxrFczxgLp1EykJVL/I+8bgo3sQST9ba+WFN+m/vwMGZ+0Z+kiTa//+r+8X4TQ wVqx8M9aTCnY7/JdsZr6K0663CcKKHE+VAQBhPxH8zGdXasJGtHRu9/XdhqqfySob3ds qEYluMn5KRyjklcf4o7fgjTrUW/ogQ7sre1xI1Ccm1XT8CmFh+mam6B8bAhuSS+xlRjq hrWFfevrWOkoTO8SCD4N/rpz8FfLDJ885TJbkumPT6SEc9D4Z/Tf7iIyVYhjcLq5ziGt S8qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=NayOlwxf86j78fQ/pCz1iGyHb2Zf/WSV1dWWobnyGUc=; b=pcA4AS4zAKKST28jotmV3GeSVl/hAv3CnYrn8XEXvPkUeoGfJLw0OOmHcu1B9yqHcs Z0U92UbFXWPOW5qwry6aQuNLOxaBjjF9Qb6uyBgewjIwp8yRPuzZY91Rmb0tjRpX3YPZ lmzpXb09ZeKoeKylizHYhsGoiQiquB2cHq8kZuEXUbD8elJDvLxYbGdlrpOqmUw49n+f 6QKceD5KCQsGjvRFu7TA6XXKtwwZVWMuU3bxC4V1mRlrb9RhS/TkDp25oQcQoohXVu5a 3I9r0pEW7gwcjx/LYKjbfgaCXHvF2sfNZumuhySTi22YMdTkr689plfNFEObWF5sulj4 t19g== 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 r17-v6si8513373pgi.132.2018.10.02.07.03.16; Tue, 02 Oct 2018 07:03:31 -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 S1730606AbeJBUpm (ORCPT + 99 others); Tue, 2 Oct 2018 16:45:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33334 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730233AbeJBUNW (ORCPT ); Tue, 2 Oct 2018 16:13:22 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C93D7B2F; Tue, 2 Oct 2018 13:29:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomer Tayar , Ariel Elior , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 172/228] qed: Wait for ready indication before rereading the shmem Date: Tue, 2 Oct 2018 06:24:29 -0700 Message-Id: <20181002132510.289135971@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132459.032960735@linuxfoundation.org> References: <20181002132459.032960735@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tomer Tayar [ Upstream commit f00d25f3154b676fcea4502a25b94bd7f142ca74 ] The MFW might be reset and re-update its shared memory. Upon the detection of such a reset the driver rereads this memory, but it has to wait till the data is valid. This patch adds the missing wait for a data ready indication. Signed-off-by: Tomer Tayar Signed-off-by: Ariel Elior Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qed/qed_mcp.c | 50 ++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c @@ -183,18 +183,57 @@ int qed_mcp_free(struct qed_hwfn *p_hwfn return 0; } +/* Maximum of 1 sec to wait for the SHMEM ready indication */ +#define QED_MCP_SHMEM_RDY_MAX_RETRIES 20 +#define QED_MCP_SHMEM_RDY_ITER_MS 50 + static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) { struct qed_mcp_info *p_info = p_hwfn->mcp_info; + u8 cnt = QED_MCP_SHMEM_RDY_MAX_RETRIES; + u8 msec = QED_MCP_SHMEM_RDY_ITER_MS; u32 drv_mb_offsize, mfw_mb_offsize; u32 mcp_pf_id = MCP_PF_ID(p_hwfn); p_info->public_base = qed_rd(p_hwfn, p_ptt, MISC_REG_SHARED_MEM_ADDR); - if (!p_info->public_base) - return 0; + if (!p_info->public_base) { + DP_NOTICE(p_hwfn, + "The address of the MCP scratch-pad is not configured\n"); + return -EINVAL; + } p_info->public_base |= GRCBASE_MCP; + /* Get the MFW MB address and number of supported messages */ + mfw_mb_offsize = qed_rd(p_hwfn, p_ptt, + SECTION_OFFSIZE_ADDR(p_info->public_base, + PUBLIC_MFW_MB)); + p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id); + p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt, + p_info->mfw_mb_addr + + offsetof(struct public_mfw_mb, + sup_msgs)); + + /* The driver can notify that there was an MCP reset, and might read the + * SHMEM values before the MFW has completed initializing them. + * To avoid this, the "sup_msgs" field in the MFW mailbox is used as a + * data ready indication. + */ + while (!p_info->mfw_mb_length && --cnt) { + msleep(msec); + p_info->mfw_mb_length = + (u16)qed_rd(p_hwfn, p_ptt, + p_info->mfw_mb_addr + + offsetof(struct public_mfw_mb, sup_msgs)); + } + + if (!cnt) { + DP_NOTICE(p_hwfn, + "Failed to get the SHMEM ready notification after %d msec\n", + QED_MCP_SHMEM_RDY_MAX_RETRIES * msec); + return -EBUSY; + } + /* Calculate the driver and MFW mailbox address */ drv_mb_offsize = qed_rd(p_hwfn, p_ptt, SECTION_OFFSIZE_ADDR(p_info->public_base, @@ -204,13 +243,6 @@ static int qed_load_mcp_offsets(struct q "drv_mb_offsiz = 0x%x, drv_mb_addr = 0x%x mcp_pf_id = 0x%x\n", drv_mb_offsize, p_info->drv_mb_addr, mcp_pf_id); - /* Set the MFW MB address */ - mfw_mb_offsize = qed_rd(p_hwfn, p_ptt, - SECTION_OFFSIZE_ADDR(p_info->public_base, - PUBLIC_MFW_MB)); - p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id); - p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt, p_info->mfw_mb_addr); - /* Get the current driver mailbox sequence before sending * the first command */