{"id":792381,"url":"http://patchwork.ozlabs.org/api/1.2/patches/792381/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170721151801.30794-1-alice.michael@intel.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.2/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":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170721151801.30794-1-alice.michael@intel.com>","list_archive_url":null,"date":"2017-07-21T15:18:01","name":"[next,S75-V4,04/11] i40e: synchronize nvmupdate command and adminq subtask","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c487e9742d10c2ea589e944b9a6650fdb3d31efe","submitter":{"id":71123,"url":"http://patchwork.ozlabs.org/api/1.2/people/71123/?format=json","name":"Michael, Alice","email":"alice.michael@intel.com"},"delegate":{"id":68,"url":"http://patchwork.ozlabs.org/api/1.2/users/68/?format=json","username":"jtkirshe","first_name":"Jeff","last_name":"Kirsher","email":"jeffrey.t.kirsher@intel.com"},"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20170721151801.30794-1-alice.michael@intel.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/792381/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/792381/checks/","tags":{},"related":[],"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.138; helo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)","Received":["from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 3xDmy50pTFz9s7m\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 22 Jul 2017 09:22:19 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 93B028857A;\n\tFri, 21 Jul 2017 23:22:17 +0000 (UTC)","from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id HAH0K113oLiF; Fri, 21 Jul 2017 23:22:16 +0000 (UTC)","from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id E28FB886CC;\n\tFri, 21 Jul 2017 23:22:16 +0000 (UTC)","from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id D842F1C08F7\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 23:22:15 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id CB6E187A58\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 23:22:15 +0000 (UTC)","from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id vu3iUSUMO0SB for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 23:22:15 +0000 (UTC)","from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 0244B877D8\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 21 Jul 2017 23:22:14 +0000 (UTC)","from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Jul 2017 16:22:14 -0700","from unknown (HELO localhost.jf.intel.com) ([10.166.16.121])\n\tby orsmga003.jf.intel.com with ESMTP; 21 Jul 2017 16:22:13 -0700"],"X-Virus-Scanned":["amavisd-new at osuosl.org","amavisd-new at osuosl.org"],"X-Greylist":"domain auto-whitelisted by SQLgrey-1.7.6","X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.40,392,1496127600\"; d=\"scan'208\";a=\"995750949\"","From":"Alice Michael <alice.michael@intel.com>","To":"alice.michael@osuosl.org, intel-wired-lan@lists.osuosl.org","Date":"Fri, 21 Jul 2017 11:18:01 -0400","Message-Id":"<20170721151801.30794-1-alice.michael@intel.com>","X-Mailer":"git-send-email 2.9.4","Subject":"[Intel-wired-lan] [next PATCH S75-V4 04/11] i40e: synchronize\n\tnvmupdate command and adminq subtask","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":"From: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>\n\nDuring NVM update, state machine gets into unrecoverable state because\ni40e_clean_adminq_subtask can get scheduled after the admin queue\ncommand but before other state variables are updated. This causes\nincorrect input to i40e_nvmupd_check_wait_event and state transitions\ndon't happen.\n\nThis issue existed before but surfaced after commit 373149fc99a0\n(\"i40e: Decrease the scope of rtnl lock\")\n\nThis fix adds locking around admin queue command and update of\nstate variables so that adminq_subtask will have accurate information\nwhenever it gets scheduled.\n\nSigned-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e_nvm.c | 14 +++++++++++++-\n 1 file changed, 13 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c\nindex 17607a2..c90abb2 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c\n@@ -753,6 +753,15 @@ i40e_status i40e_nvmupd_command(struct i40e_hw *hw,\n \t\thw->nvmupd_state = I40E_NVMUPD_STATE_INIT;\n \t}\n \n+\t/* Acquire lock to prevent race condition where adminq_task\n+\t * can execute after i40e_nvmupd_nvm_read/write but before state\n+\t * variables (nvm_wait_opcode, nvm_release_on_done) are updated.\n+\t *\n+\t * During NVMUpdate, it is observed that lock could be held for\n+\t * ~5ms for most commands. However lock is held for ~60ms for\n+\t * NVMUPD_CSUM_LCB command.\n+\t */\n+\tmutex_lock(&hw->aq.arq_mutex);\n \tswitch (hw->nvmupd_state) {\n \tcase I40E_NVMUPD_STATE_INIT:\n \t\tstatus = i40e_nvmupd_state_init(hw, cmd, bytes, perrno);\n@@ -773,7 +782,8 @@ i40e_status i40e_nvmupd_command(struct i40e_hw *hw,\n \t\t */\n \t\tif (cmd->offset == 0xffff) {\n \t\t\ti40e_nvmupd_check_wait_event(hw, hw->nvm_wait_opcode);\n-\t\t\treturn 0;\n+\t\t\tstatus = 0;\n+\t\t\tgoto exit;\n \t\t}\n \n \t\tstatus = I40E_ERR_NOT_READY;\n@@ -788,6 +798,8 @@ i40e_status i40e_nvmupd_command(struct i40e_hw *hw,\n \t\t*perrno = -ESRCH;\n \t\tbreak;\n \t}\n+exit:\n+\tmutex_unlock(&hw->aq.arq_mutex);\n \treturn status;\n }\n \n","prefixes":["next","S75-V4","04/11"]}