{"id":808696,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808696/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170901140234.7840-2-sassmann@kpanic.de>","date":"2017-09-01T14:02:33","name":"[1/2] i40e: use non-locking i40e_read_nvm_word() function during nvmupdate","commit_ref":null,"pull_url":null,"state":"awaiting-upstream","archived":true,"hash":"792e8866494143ca2defb80133ce290457b13dae","submitter":{"id":7508,"url":"http://patchwork.ozlabs.org/api/1.0/people/7508/?format=json","name":"Stefan Assmann","email":"sassmann@kpanic.de"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.0/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170901140234.7840-2-sassmann@kpanic.de/mbox/","series":[{"id":1035,"url":"http://patchwork.ozlabs.org/api/1.0/series/1035/?format=json","date":"2017-09-01T14:02:32","name":"i40e: fix firmware update","version":1,"mbox":"http://patchwork.ozlabs.org/series/1035/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808696/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=kpanic.de","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=none smtp.mailfrom=sassmann@kpanic.de"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkLY63yb8z9s7F\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  2 Sep 2017 00:02:50 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752091AbdIAOCr (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 1 Sep 2017 10:02:47 -0400","from mx1.redhat.com ([209.132.183.28]:64572 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751966AbdIAOCq (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tFri, 1 Sep 2017 10:02:46 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 49628806CA;\n\tFri,  1 Sep 2017 14:02:46 +0000 (UTC)","from w541.redhat.com (ovpn-116-204.ams2.redhat.com [10.36.116.204])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 07DAD81F90;\n\tFri,  1 Sep 2017 14:02:44 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 49628806CA","DKIM-Filter":"OpenDKIM Filter v2.11.0 mx1.redhat.com 49628806CA","From":"Stefan Assmann <sassmann@kpanic.de>","To":"intel-wired-lan@lists.osuosl.org","Cc":"netdev@vger.kernel.org, davem@davemloft.net,\n\tjeffrey.t.kirsher@intel.com, sassmann@kpanic.de","Subject":"[PATCH 1/2] i40e: use non-locking i40e_read_nvm_word() function\n\tduring nvmupdate","Date":"Fri,  1 Sep 2017 16:02:33 +0200","Message-Id":"<20170901140234.7840-2-sassmann@kpanic.de>","In-Reply-To":"<20170901140234.7840-1-sassmann@kpanic.de>","References":"<20170901140234.7840-1-sassmann@kpanic.de>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tFri, 01 Sep 2017 14:02:46 +0000 (UTC)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"During firmware update the adminq gets locked. Currently during the\nupdate i40e_calc_nvm_checksum() calls i40e_read_nvm_word() which itself\ntries to acquire the adminq lock. This fails as the lock is already\ntaken.\nThis results in the firmware update to fail, leaving the eeprom in a\ncorrupt state.\n\nTo fix this, introducing __i40e_read_nvm_word() which avoids locking and\nreplace the calls to i40e_read_nvm_word() in i40e_calc_nvm_checksum()\nwith the newly introduced function. The change matches the i40e\nsourceforge driver as much as possible.\n\nWith this in place the firmware update is now working again.\nFixes: (\"96a39aed25e6 i40e: Acquire NVM lock before reads on all devices\")\n\nSigned-off-by: Stefan Assmann <sassmann@kpanic.de>\n---\n drivers/net/ethernet/intel/i40e/i40e_nvm.c | 24 ++++++++++++++++++++++--\n 1 file changed, 22 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c\nindex 96afef98a08f..aa4cfdc51d2b 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c\n@@ -322,6 +322,26 @@ i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,\n }\n \n /**\n+ * __i40e_read_nvm_word - Reads nvm word, assumes caller does the locking\n+ * @hw: pointer to the HW structure\n+ * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)\n+ * @data: word read from the Shadow RAM\n+ *\n+ * Reads one 16 bit word from the Shadow RAM using the GLNVM_SRCTL register.\n+ **/\n+static i40e_status __i40e_read_nvm_word(struct i40e_hw *hw,\n+\t\t\t\t\tu16 offset, u16 *data)\n+{\n+\tenum i40e_status_code ret_code = 0;\n+\n+\tif (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE)\n+\t\tret_code = i40e_read_nvm_word_aq(hw, offset, data);\n+\telse\n+\t\tret_code = i40e_read_nvm_word_srctl(hw, offset, data);\n+\treturn ret_code;\n+}\n+\n+/**\n  * i40e_read_nvm_buffer_srctl - Reads Shadow RAM buffer via SRCTL register\n  * @hw: pointer to the HW structure\n  * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF).\n@@ -516,14 +536,14 @@ static i40e_status i40e_calc_nvm_checksum(struct i40e_hw *hw,\n \tdata = (u16 *)vmem.va;\n \n \t/* read pointer to VPD area */\n-\tret_code = i40e_read_nvm_word(hw, I40E_SR_VPD_PTR, &vpd_module);\n+\tret_code = __i40e_read_nvm_word(hw, I40E_SR_VPD_PTR, &vpd_module);\n \tif (ret_code) {\n \t\tret_code = I40E_ERR_NVM_CHECKSUM;\n \t\tgoto i40e_calc_nvm_checksum_exit;\n \t}\n \n \t/* read pointer to PCIe Alt Auto-load module */\n-\tret_code = i40e_read_nvm_word(hw, I40E_SR_PCIE_ALT_AUTO_LOAD_PTR,\n+\tret_code = __i40e_read_nvm_word(hw, I40E_SR_PCIE_ALT_AUTO_LOAD_PTR,\n \t\t\t\t      &pcie_alt_module);\n \tif (ret_code) {\n \t\tret_code = I40E_ERR_NVM_CHECKSUM;\n","prefixes":["1/2"]}