{"id":808699,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808699/?format=json","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.0/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":""},"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":"superseded","archived":false,"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":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170901140234.7840-2-sassmann@kpanic.de/mbox/","series":[{"id":1036,"url":"http://patchwork.ozlabs.org/api/1.0/series/1036/?format=json","date":"2017-09-01T14:02:34","name":"i40e: fix firmware update","version":1,"mbox":"http://patchwork.ozlabs.org/series/1036/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808699/checks/","tags":{},"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkLg52r3pz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 00:08:01 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id A4CA930B72;\n\tFri,  1 Sep 2017 14:07:59 +0000 (UTC)","from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Gyepeqk2d46i; Fri,  1 Sep 2017 14:07:58 +0000 (UTC)","from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id C874D30B5F;\n\tFri,  1 Sep 2017 14:07:58 +0000 (UTC)","from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 65C291C0306\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 14:07:56 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 606968A298\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 14:07:56 +0000 (UTC)","from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 1mvN0MRPMa68 for <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 14:07:54 +0000 (UTC)","from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 8CFB38A296\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  1 Sep 2017 14:07:54 +0000 (UTC)","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)"],"X-Virus-Scanned":["amavisd-new at osuosl.org","amavisd-new at osuosl.org"],"X-Greylist":["delayed 00:05:09 by SQLgrey-1.7.6","Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]); Fri, 01 Sep 2017 14:02:46 +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","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","Cc":"netdev@vger.kernel.org, davem@davemloft.net, sassmann@kpanic.de","Subject":"[Intel-wired-lan] [PATCH 1/2] i40e: use non-locking\n\ti40e_read_nvm_word() function during nvmupdate","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.18-1","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.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"]}