Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp321232ybh; Mon, 20 Jul 2020 18:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIewTiwaGzKNOFt2Uk1ZPv4lCLaQiAfmLJHeyOyNM/iNuxJOA0NVQHHQS5djGq+4nTj1JG X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr22953466edb.155.1595293280482; Mon, 20 Jul 2020 18:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595293280; cv=none; d=google.com; s=arc-20160816; b=SsZrCONPFwQHhJ62USS4MYkV9Zayt3ej527u2Knk2n7lhTMu47oQGB1oCcw0/IbuK0 BqA9TIleW2nqacgFkZzA9lHQSZDbFhKE8GxkQCK+WaKXb/B3BdVN8+xjeL6qj9WKsivb ZQVIHS+sQerXuTIhf10RInoOi/3K1IHx00HbsR0qxhBeWBW2X4j325P2ePRciQscP0w0 RKVzpBHAyYNwqqeJHo1wez/HHFkAsWP/rAo1cp735GhIcQZRq/eGOulUVRujyzPWA80j N1b+dOS0RwbLTUz5TH34maRJrgigZv7LeP+GZOAhaZ/svCuoE4gDOpf2geBEvNzg7Q7n NnFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9b/dWUWcmQC3VAaa8Cg/JXLF0cqmH/Md5xiTM9HBxjQ=; b=MXqg3IhME2bv3xsWm7daiIS2d9iblfSG1q7QWGMAV4cRQ2jpWBZ4L7sJjtVpcMEJ3X 1GTnE81dxgEmLI4LlYoqL3+9qHvl2KldL5avY9rKGV2abg42/zXSseH/VhxHZmeXcYXw EC2hvUQc0LqCesdBYwgUSJ/3GlkkFhKGkE/beUzfAEDylVOwK478sJetgPw3cZOxheu4 MFB37z38my3m751kTUGRfQ7MEbwEl2qRYm0RG04idh46puexYiK+B1MYL2jh6WjnlIEI 24WAwohE3sw2krxZXdKdmRWG/7xoABlPcMan5EXfVFTXOYDftDLrDk2x5lwGTTNdK1li wujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=diD3DVsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk1si10901640ejb.15.2020.07.20.18.00.57; Mon, 20 Jul 2020 18:01:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=diD3DVsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbgGUA6Z (ORCPT + 99 others); Mon, 20 Jul 2020 20:58:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgGUA6Z (ORCPT ); Mon, 20 Jul 2020 20:58:25 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA53C061794 for ; Mon, 20 Jul 2020 17:58:24 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id o18so19913828eje.7 for ; Mon, 20 Jul 2020 17:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9b/dWUWcmQC3VAaa8Cg/JXLF0cqmH/Md5xiTM9HBxjQ=; b=diD3DVsxMCkiIzevO0+JCae+FxhUk569wVXPS1cRfwY3pETJzf/3PLI2b9XoEyyDXw Z6pIGGBxBMkmAlVBQm50HIbkZdAdYypcaSuf2iweirUt0+XxTecetCnlyXELdL4/FXQ6 ZtByrRngf2shBc+YkqWZXmfq/VNYmsdECRyVRYNOTFuP5ZbE7MWjafb2IOGH4lvfjWlY 0xwxrGDdqnFGd8YAt+vtLlH832ackygwFGBll/6y5Rd31R23/PkltkHtKhhl591wxg2I mbBQ8L1UeYeUq4JBvECQc9/KD5MZQXx4FT2ZnxOf49iS7J0f2FjmwtZNPjp78WlmkSk/ +GCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9b/dWUWcmQC3VAaa8Cg/JXLF0cqmH/Md5xiTM9HBxjQ=; b=gNFyaFWOa7kqJBKoxbm4UVj5WG1b283bSWAYeTPUQhJ7Sl5DZlJiViJR9GRdoclJGT JWO87AJYBwH+Yr4TzyDCr1VwI70L7WRwcud8kWaiDs3Iay8LPpCmKRCUzjHmlzKfj4yt mhAAalH++pePbhLJhcYWfNTKr0kv3sNIL2zbtIul96jWTERABZHkTtLziU7DGkc2azzF N9DElFPD/Nj/YG5t56HlESMFRwfmfh4cmG3shUyKE+tIXKmU+hIEOmRLCNL+K76gKUBx c46Gs7/yFEdmKzHM2fhZONNxRXa4ela0lMW4p+iIY2UzPvXVAZe8GeMM7zhL4Vj+hCfy kjVQ== X-Gm-Message-State: AOAM533tq3iQzS2ZpmMflLTVP4IGoSvo8FzmlzyAxvjoiERNHfISBcuz cs59EARk2Vt1FsrzUKKXGXyLGIZkJeJcuvQtDxgPOw== X-Received: by 2002:a17:906:cc0e:: with SMTP id ml14mr22733669ejb.432.1595293103436; Mon, 20 Jul 2020 17:58:23 -0700 (PDT) MIME-Version: 1.0 References: <159528284411.993790.11733759435137949717.stgit@dwillia2-desk3.amr.corp.intel.com> <159528289856.993790.11787167534159675987.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Dan Williams Date: Mon, 20 Jul 2020 17:58:12 -0700 Message-ID: Subject: Re: [PATCH v3 10/11] PM, libnvdimm: Add runtime firmware activation support To: Randy Dunlap Cc: linux-nvdimm , Pavel Machek , Ira Weiny , Len Brown , Jonathan Corbet , Dave Jiang , Vishal Verma , Linux ACPI , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 5:02 PM Randy Dunlap wrote: > > Hi Dan, > > Documentation comments below: > > On 7/20/20 3:08 PM, Dan Williams wrote: > > Abstract platform specific mechanics for nvdimm firmware activation > > behind a handful of generic ops. At the bus level ->activate_state() > > indicates the unified state (idle, busy, armed) of all DIMMs on the bus, > > and ->capability() indicates the system state expectations for activate. > > At the DIMM level ->activate_state() indicates the per-DIMM state, > > ->activate_result() indicates the outcome of the last activation > > attempt, and ->arm() attempts to transition the DIMM from 'idle' to > > 'armed'. > > > > A new hibernate_quiet_exec() facility is added to support firmware > > activation in an OS defined system quiesce state. It leverages the fact > > that the hibernate-freeze state wants to assert that a memory > > hibernation snapshot can be taken. This is in contrast to a platform > > firmware defined quiesce state that may forcefully quiet the memory > > controller independent of whether an individual device-driver properly > > supports hibernate-freeze. > > > > The libnvdimm sysfs interface is extended to support detection of a > > firmware activate capability. The mechanism supports enumeration and > > triggering of firmware activate, optionally in the > > hibernate_quiet_exec() context. > > > > Cc: Pavel Machek > > Cc: Ira Weiny > > Cc: Len Brown > > Cc: Jonathan Corbet > > Cc: Dave Jiang > > Cc: Vishal Verma > > [rafael: hibernate_quiet_exec() proposal] > > Co-developed-by: "Rafael J. Wysocki" > > Signed-off-by: Dan Williams > > --- > > Documentation/ABI/testing/sysfs-bus-nvdimm | 2 > > .../driver-api/nvdimm/firmware-activate.rst | 86 ++++++++++++ > > drivers/nvdimm/core.c | 149 ++++++++++++++++++++ > > drivers/nvdimm/dimm_devs.c | 115 +++++++++++++++ > > drivers/nvdimm/nd-core.h | 1 > > include/linux/libnvdimm.h | 44 ++++++ > > include/linux/suspend.h | 6 + > > kernel/power/hibernate.c | 97 +++++++++++++ > > 8 files changed, 500 insertions(+) > > create mode 100644 Documentation/ABI/testing/sysfs-bus-nvdimm > > create mode 100644 Documentation/driver-api/nvdimm/firmware-activate.rst > > > > diff --git a/Documentation/driver-api/nvdimm/firmware-activate.rst b/Documentation/driver-api/nvdimm/firmware-activate.rst > > new file mode 100644 > > index 000000000000..9eb98aa833c5 > > --- /dev/null > > +++ b/Documentation/driver-api/nvdimm/firmware-activate.rst > > @@ -0,0 +1,86 @@ > > +.. SPDX-License-Identifier: GPL-2.0 > > + > > +================================== > > +NVDIMM Runtime Firmware Activation > > +================================== > > + > > +Some persistent memory devices run a firmware locally on the device / > > run firmware That works too. I was going to say "run a firmware image", but "run firmware" is clearer. > > > +"DIMM" to perform tasks like media management, capacity provisioning, > > +and health monitoring. The process of updating that firmware typically > > +involves a reboot because it has implications for in-flight memory > > +transactions. However, reboots are disruptive and at least the Intel > > +persistent memory platform implementation, described by the Intel ACPI > > +DSM specification [1], has added support for activating firmware at > > that's an Intel spec? just checking. Correct. It's a public specification of the ACPI methods that Intel platform BIOS or virtual-machine BIOS deploys to talk to NVDIMM devices. > > > +runtime. > > + > > +A native sysfs interface is implemented in libnvdimm to allow platform > > platforms Ack. > > > +to advertise and control their local runtime firmware activation > > +capability. > > + > > +The libnvdimm bus object, ndbusX, implements an ndbusX/firmware/activate > > +attribute that shows the state of the firmware activation as one of 'idle', > > +'armed', 'overflow', and 'busy'. > > or Yup. > > > + > > +- idle: > > + No devices are set / armed to activate firmware > > + > > +- armed: > > + At least one device is armed > > + > > +- busy: > > + In the busy state armed devices are in the process of transitioning > > + back to idle and completing an activation cycle. > > + > > +- overflow: > > + If the platform has a concept of incremental work needed to perform > > + the activation it could be the case that too many DIMMs are armed for > > + activation. In that scenario the potential for firmware activation to > > + timeout is indicated by the 'overflow' state. > > + > > +The 'ndbusX/firmware/activate' property can be written with a value of > > +either 'live', or 'quiesce'. A value of 'quiesce' triggers the kernel to > > +run firmware activation from within the equivalent of the hibernation > > +'freeze' state where drivers and applications are notified to stop their > > +modifications of system memory. A value of 'live' attempts > > +firmware-activation without this hibernation cycle. The > > no hyphen^^ Agree. > > > +'ndbusX/firmware/activate' property will be elided completely if no > > +firmware activation capability is detected. > > + > > +Another property 'ndbusX/firmware/capability' indicates a value of > > +'live', or 'quiesce'. Where 'live' indicates that the firmware > > no comma. no period. So this: > > +'live' or 'quiesce', where Ok. > > > +does not require or inflict any quiesce period on the system to update > > +firmware. A capability value of 'quiesce' indicates that firmware does > > +expect and injects a quiet period for the memory controller, but 'live' > > +may still be written to 'ndbusX/firmware/activate' as an override to > > +assume the risk of racing firmware update with in-flight device and > > +application activity. The 'ndbusX/firmware/capability' property will be > > +elided completely if no firmware activation capability is detected. > > + > > +The libnvdimm memory-device / DIMM object, nmemX, implements > > +'nmemX/firmware/activate' and 'nmemX/firmware/result' attributes to > > +communicate the per-device firmware activation state. Similar to the > > +'ndbusX/firmware/activate' attribute, the 'nmemX/firmware/activate' > > +attribute indicates 'idle', 'armed', or 'busy'. The state transitions > > +from 'armed' to 'idle' when the system is prepared to activate firmware, > > +firmware staged + state set to armed, and 'ndbusX/firmware/activate' is > > +triggered. After that activation event the nmemX/firmware/result > > +attribute reflects the state of the last activation as one of: > > + > > +- none: > > + No runtime activation triggered since the last time the device was reset > > + > > +- success: > > + The last runtime activation completed successfully. > > + > > +- fail: > > + The last runtime activation failed for device-specific reasons. > > + > > +- not_staged: > > + The last runtime activation failed due to a sequencing error of the > > + firmware image not being staged. > > + > > +- need_reset: > > + Runtime firmware activation failed, but the firmware can still be > > + activated via the legacy method of power-cycling the system. > > + > > +[1]: https://docs.pmem.io/persistent-memory/ > > > thanks. > -- > ~Randy Thanks Randy.