Message ID | 20231013062623.6745-1-dwagner@suse.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1694862vqb; Thu, 12 Oct 2023 23:25:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGF3o3obrVfpZd8znzM8JmqCXA60xoYXx9eTViIkQhX0JxdhiUeflIuDaocn6kgnmAP8c63 X-Received: by 2002:a05:6a00:2e92:b0:692:b3d4:e6c3 with SMTP id fd18-20020a056a002e9200b00692b3d4e6c3mr28382752pfb.0.1697178321874; Thu, 12 Oct 2023 23:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697178321; cv=none; d=google.com; s=arc-20160816; b=GMdbUFtYjhR9G1hyAJtYw2xfLMqA/kvwCIU7KRFylNYldjFAsWolTD7WdVwsnbTmrw NHoT9oKw6C4jLqRO5dNVqXR1c8UjXWI97VQNtPLhJEPb3JV8ucg8SQ/mI78Fg4XJoNQt unxfRuOFddiQGDREqO/C7o4Lgg0Jx0HosPgTV4KTdfV6YxN2gxPeLrOnNm7xqLSwwMye X4a+1oO2fvLuMQydQo3bgVVLRjnp8kX/HcVH+uWMGCP0Zz33O6UqzA4829B4AHDeAK6Y jgDUrtFqTq4OnuKOPtT2tWPpgk/vOgkMODmmrub4ZNxDaMh8PXq9ddm5BrRpWdCfTb/k sVSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=T9TmIodEecjXhOeeyVrpi/lTsL8WIjPMSwLYTMa8tvQ=; fh=MO7PhMb8ok0Y0DF3Q1DBbn2ZS9Oc1sAgLO8XSCwICUg=; b=ZLzEyshHL+bRMeE+JBCDSkXAhakMHmJJIKTtzpGknyEQ5ABlMAOuf783ijA78+aFi2 qs+4oJpf+soKH4bqsYxr+UR87gCgJDEn/tXBxnlvy3Mi1qe/UfB85cRfys361miv05Qd Y9hJFSbvpW0w1VYmSx+kj4heu1TpqRsm7isQfHcfyCOuzLVRSLCpEe876s49qbWblt0z b8QjFY4CX4Hm5t8nHEXINYgUDucsEZJiSk5SJgdpFzeYJY9+i+xOqSmw5GNRFb0cX8dv NXjEnMmOakIOGfGdL562I57bvQ8IVvjIUhjVh+XWLW1le+CK/TYm2OYlRsxXlm1FerET 8USg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JLCLMy6w; dkim=neutral (no key) header.i=@suse.de header.b=7AjiLkau; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id dw11-20020a056a00368b00b006a969bad773si7258011pfb.380.2023.10.12.23.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:25:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JLCLMy6w; dkim=neutral (no key) header.i=@suse.de header.b=7AjiLkau; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CEF7082663ED; Thu, 12 Oct 2023 23:25:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjJMGZR (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 02:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJMGZQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 02:25:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B67B7 for <linux-kernel@vger.kernel.org>; Thu, 12 Oct 2023 23:25:14 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7F27E2188E; Fri, 13 Oct 2023 06:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697178313; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T9TmIodEecjXhOeeyVrpi/lTsL8WIjPMSwLYTMa8tvQ=; b=JLCLMy6wswunI8hU6sPbjwoP/t0Ty/c1IeLSfXcWEuOBv28FvZWwfXG+kGX0L0Wl2ItZdD S3PaaGn1Jf6TSo1slBFf0sxtePdCdMP1uQXZ5fBfPCT6GRl4eaHvwuaBNC9Q1lFgsfbWyE 3X81qg0HtXKG5100/xI+weOypjXniQI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697178313; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T9TmIodEecjXhOeeyVrpi/lTsL8WIjPMSwLYTMa8tvQ=; b=7AjiLkauuPFUix9b7kF2COHEbA56vaqruZLElPf2aJkyNCInFjhKjCW81fMGi8QcLuAW3b PJuVEysxjDJ3ihBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 713BE138EF; Fri, 13 Oct 2023 06:25:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bkqXG8niKGX/NwAAMHmgww (envelope-from <dwagner@suse.de>); Fri, 13 Oct 2023 06:25:13 +0000 From: Daniel Wagner <dwagner@suse.de> To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>, Daniel Wagner <dwagner@suse.de> Subject: [PATCH] nvme: update firmware version after commit Date: Fri, 13 Oct 2023 08:26:23 +0200 Message-ID: <20231013062623.6745-1-dwagner@suse.de> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: 0.50 X-Spamd-Result: default: False [0.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.40)[77.76%] X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 23:25:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779620455863060327 X-GMAIL-MSGID: 1779620455863060327 |
Series |
nvme: update firmware version after commit
|
|
Commit Message
Daniel Wagner
Oct. 13, 2023, 6:26 a.m. UTC
The firmware version sysfs entry needs to be updated after a successfully
firmware activation.
nvme-cli stopped issuing an Identify Controller command to list the
current firmware information and relies on sysfs showing the current
firmware version.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
drivers/nvme/host/core.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Comments
On Fri, Oct 13, 2023 at 08:26:23AM +0200, Daniel Wagner wrote: > The firmware version sysfs entry needs to be updated after a successfully > firmware activation. > > nvme-cli stopped issuing an Identify Controller command to list the > current firmware information and relies on sysfs showing the current > firmware version. > > Signed-off-by: Daniel Wagner <dwagner@suse.de> > --- > drivers/nvme/host/core.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 62612f87aafa..bb15d878e8a2 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -4079,6 +4079,20 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) > kfree(log); > } > > +static void nvme_update_firmware_rev(struct nvme_ctrl *ctrl) > +{ > + struct nvme_id_ctrl *id; > + int ret; > + > + ret = nvme_identify_ctrl(ctrl, &id); Hello Daniel, I understand that nvme_fw_act_work() is called when receiving a NVME_AER_NOTICE_FW_ACT_STARTING AEN. This AEN is received when a Firmware Activate command was issued with value 0x3 "The image specified by the Firmware Slot field is requested to be activated immediately without reset." However, when upgrading firmware (even without a reset), can't more things other than FW version change? Sure, I understand that there is no need to do a reset (as in the cases there the firmware deems that a reset is needed to do the FW activation without reset, the Firmware Activate command with value 0x3 returns a failure), but it just seems like more fields than FW version needs to be re-read. Theoretically, can't a FW upgrade go from NVMe 1.4 to NVMe 2.0, and that firmware can return success for the Firmware Activate command with value 0x3? Kind regards, Niklas
On Fri, Oct 13, 2023 at 08:26:23AM +0200, Daniel Wagner wrote: > +static void nvme_update_firmware_rev(struct nvme_ctrl *ctrl) > +{ > + struct nvme_id_ctrl *id; > + int ret; > + > + ret = nvme_identify_ctrl(ctrl, &id); > + if (ret) { > + dev_warn(ctrl->device, "Identify Controller failed (%d)\n", ret); > + return; > + } > + memcpy(ctrl->subsys->firmware_rev, id->fr, > + sizeof(ctrl->subsys->firmware_rev)); > +} > + > static void nvme_fw_act_work(struct work_struct *work) > { > struct nvme_ctrl *ctrl = container_of(work, > @@ -4109,6 +4123,7 @@ static void nvme_fw_act_work(struct work_struct *work) > nvme_unquiesce_io_queues(ctrl); > /* read FW slot information to clear the AER */ > nvme_get_fw_slot_info(ctrl); > + nvme_update_firmware_rev(ctrl); The "fw_slot_info()" call also gets the firmware version, so no need to do it a different way. Just add the memcpy to that function instead of introducing a new one.
On Fri, Oct 13, 2023 at 01:02:29PM +0000, Niklas Cassel wrote: > > However, when upgrading firmware (even without a reset), > can't more things other than FW version change? New firmware can change all sorts of things, but I think firmware_rev is the only exported sysfs attribute we expect to change. Other attributes, like model, serial and unique id's, should be stable across these types of firmware upgrades. I don't think "activation without reset" can be used for firmware upgrades that change fundamental ways the device operates.
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 62612f87aafa..bb15d878e8a2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -4079,6 +4079,20 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl) kfree(log); } +static void nvme_update_firmware_rev(struct nvme_ctrl *ctrl) +{ + struct nvme_id_ctrl *id; + int ret; + + ret = nvme_identify_ctrl(ctrl, &id); + if (ret) { + dev_warn(ctrl->device, "Identify Controller failed (%d)\n", ret); + return; + } + memcpy(ctrl->subsys->firmware_rev, id->fr, + sizeof(ctrl->subsys->firmware_rev)); +} + static void nvme_fw_act_work(struct work_struct *work) { struct nvme_ctrl *ctrl = container_of(work, @@ -4109,6 +4123,7 @@ static void nvme_fw_act_work(struct work_struct *work) nvme_unquiesce_io_queues(ctrl); /* read FW slot information to clear the AER */ nvme_get_fw_slot_info(ctrl); + nvme_update_firmware_rev(ctrl); queue_work(nvme_wq, &ctrl->async_event_work); }