Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp177760imd; Wed, 31 Oct 2018 16:53:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5e6P2j9YrYjdK8cekxvRxFATjmut9gJ79JMuNkrtYIJ6wMCLtILhMXYFUckGcc1ZfFsjtEq X-Received: by 2002:a62:d405:: with SMTP id a5-v6mr5354340pfh.174.1541029997637; Wed, 31 Oct 2018 16:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029997; cv=none; d=google.com; s=arc-20160816; b=iTF63gfbrNX2pesHTM9V2EiLZ0ksA7oukgLGTtDPw370gXVgS5lIDf0BzknAkNr1BX GpfcCPjbwGFU9/mC9mrEP5pS/U2B4ri5UmEbqIP5HJ8UpQf5nslh/s8rkAVdmuKp7jX4 Y59P4fIB29VG4WbzTMSElb0YCkL1spepItLkMpoJC4o83SWCG1zZ/VWDD9Pz4U3uK0Uz moT2+WFizz5HlcRuFClo0sI8pWVdpLi2Lqony6PcIDq0yqsqAADdgLv2RLQORkYzOzgi m+vZ4pPQQ4F6zZP8ufNiF86vSA97mwrYTlkNMkAzx46eFwW31wc5KuJ3bOjyPkfut6V3 4GoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=GQIIIQSZFXKS4aFY+RsDcS2cnSOKRzSLDgCFzzJ4JZ0=; b=0IavG7AbqcEeaYhnJtxDd9KIUVS9M9uk5QGEIj0FI7Z2XZovFjxmZrbW7L3/Td1Gge wPwfcY30qKAHMcI3UsyOBf9JwvCR4PNLNWBhCyCy3Yfx+GG4D6d7Gnd38hSz4+s3e+i8 Ql5CKDnlbPx117T39kKOJ8H6kdQk+WZn6EysVwV6u4b5BoJ4QRVl58WoEu4GosYSoJ39 X0bhL4hVIIGxxpd/bEA4i/VkXjghsS6QMHvZVP8JyEiKjetUHpZfhB+3vG35gcc2SkRl UNIH0O6z3xyG4Gq2MS224bzC8jEmf4NWHjgXJea7ZWuGxJwPIPrETi1gedcmZSM5RNOJ udVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dvU3kP/r"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 94-v6si8261466plb.87.2018.10.31.16.53.03; Wed, 31 Oct 2018 16:53:17 -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; dkim=pass header.i=@kernel.org header.s=default header.b="dvU3kP/r"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbeKAIvr (ORCPT + 99 others); Thu, 1 Nov 2018 04:51:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:53388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728063AbeKAIGc (ORCPT ); Thu, 1 Nov 2018 04:06:32 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C97F720821; Wed, 31 Oct 2018 23:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027182; bh=+5X7dIC/QbjYxm/+gKy32O98nmODIuISS/rcNXrJd8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvU3kP/rLD49wprEnj4Qi0a387IyrHht6WubvF5tv0+Tprd28zadryTsPMZbc9Pb6 aVJsxlFhKJ11uJPryqo+D8aVs0ZhVd1b5craweR9rIL9TEekpxcEytMa+tcp7f4xpC BI66pbb4v176lgRq7votaOuhhu8x8aj1dk+l7jSU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jacob Keller , Anirudh Venkataramanan , Jeff Kirsher , Sasha Levin Subject: [PATCH AUTOSEL 4.19 044/146] ice: update fw version check logic Date: Wed, 31 Oct 2018 19:03:59 -0400 Message-Id: <20181031230541.28822-44-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jacob Keller [ Upstream commit 396fbf9cab5dc07f8f87773062a8d35f54b40a05 ] We have MAX_FW_API_VER_BRANCH, MAX_FW_API_VER_MAJOR, and MAX_FW_API_VER_MINOR that we use in ice_controlq.h to test when a firmware version is newer than expected. This is currently tested by comparing each field separately. Thus, we compare the branch field against the MAX_FW_API_VER_BRANCH, and so forth. This means that currently, if we suppose that the max firmware version is defined as 0.2.1, i.e. Then firmware 0.1.3 will fail to load. This is because the minor version 3 is greater than the max minor version 1. This is not intuitive, because of the notion that increasing the major firmware version to 2 should mean any firmware version with a major version is less than 2 should be considered older than 2... In order to allow both 0.2.1 and 0.1.3 to load, you would have to define the "max" firmware version as 0.2.3.. It is possible that such a firmware version doesn't even exist yet! Fix this by replacing the current logic with an updated check that behaves as follows: First, we check the major version. If it is greater than the expected version, then we prevent driver load. Additionally, a warning message is logged to indicate to the system administrator that they need to update their driver. This is now the only case where the driver will refuse to load. Second, if the major version is less than the expected version, we log an information message indicating the NVM should be updated. Third, if the major version is exact, we'll then check the minor version. If the minor version is more than two versions less than expected, we log an information message indicating the NVM should be updated. If it is more than two versions greater than the expected version, we log an information message that the driver should be updated. To support this, the ice_aq_ver_check function needs its signature updated to pass the HW structure. Since we now pass this structure, there is no need to pass the firmware API versions separately. Signed-off-by: Jacob Keller Signed-off-by: Anirudh Venkataramanan Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_controlq.c | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_controlq.c b/drivers/net/ethernet/intel/ice/ice_controlq.c index 62be72fdc8f3..e783976c401d 100644 --- a/drivers/net/ethernet/intel/ice/ice_controlq.c +++ b/drivers/net/ethernet/intel/ice/ice_controlq.c @@ -518,22 +518,31 @@ ice_shutdown_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) /** * ice_aq_ver_check - Check the reported AQ API version. - * @fw_branch: The "branch" of FW, typically describes the device type - * @fw_major: The major version of the FW API - * @fw_minor: The minor version increment of the FW API + * @hw: pointer to the hardware structure * * Checks if the driver should load on a given AQ API version. * * Return: 'true' iff the driver should attempt to load. 'false' otherwise. */ -static bool ice_aq_ver_check(u8 fw_branch, u8 fw_major, u8 fw_minor) +static bool ice_aq_ver_check(struct ice_hw *hw) { - if (fw_branch != EXP_FW_API_VER_BRANCH) - return false; - if (fw_major != EXP_FW_API_VER_MAJOR) - return false; - if (fw_minor != EXP_FW_API_VER_MINOR) + if (hw->api_maj_ver > EXP_FW_API_VER_MAJOR) { + /* Major API version is newer than expected, don't load */ + dev_warn(ice_hw_to_dev(hw), + "The driver for the device stopped because the NVM image is newer than expected. You must install the most recent version of the network driver.\n"); return false; + } else if (hw->api_maj_ver == EXP_FW_API_VER_MAJOR) { + if (hw->api_min_ver > (EXP_FW_API_VER_MINOR + 2)) + dev_info(ice_hw_to_dev(hw), + "The driver for the device detected a newer version of the NVM image than expected. Please install the most recent version of the network driver.\n"); + else if ((hw->api_min_ver + 2) < EXP_FW_API_VER_MINOR) + dev_info(ice_hw_to_dev(hw), + "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n"); + } else { + /* Major API version is older than expected, log a warning */ + dev_info(ice_hw_to_dev(hw), + "The driver for the device detected an older version of the NVM image than expected. Please update the NVM image.\n"); + } return true; } @@ -588,8 +597,7 @@ static enum ice_status ice_init_check_adminq(struct ice_hw *hw) if (status) goto init_ctrlq_free_rq; - if (!ice_aq_ver_check(hw->api_branch, hw->api_maj_ver, - hw->api_min_ver)) { + if (!ice_aq_ver_check(hw)) { status = ICE_ERR_FW_API_VER; goto init_ctrlq_free_rq; } -- 2.17.1