* [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV
@ 2019-01-30 18:48 Dexuan Cui
[not found] ` <PU1P153MB01691690696D8F83FC1872C7BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Dexuan Cui @ 2019-01-30 18:48 UTC (permalink / raw)
To: Dan Williams, Ross Zwisler, Vishal Verma, Dave Jiang,
Rafael J. Wysocki, Len Brown,
linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org,
linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Josh Poulson, Stephen Hemminger, Haiyang Zhang,
driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Michael Kelley, Sasha Levin, KY Srinivasan
See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"):
"Get Unsafe Shutdown Count (Function Index 2)".
Let's expose the info to the userspace (e.g. ntctl) via sysfs.
Signed-off-by: Dexuan Cui <decui-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
---
drivers/acpi/nfit/core.c | 51 ++++++++++++++++++++++++++++++++++++++
drivers/acpi/nfit/hyperv.h | 26 +++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 drivers/acpi/nfit/hyperv.h
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index d5a164b6833a..d504da34ce34 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -25,6 +25,7 @@
#include <asm/cacheflush.h>
#include <acpi/nfit.h>
#include "intel.h"
+#include "hyperv.h"
#include "nfit.h"
/*
@@ -1802,6 +1803,54 @@ __weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
}
}
+__weak void nfit_hyperv_shutdown_status(struct nfit_mem *nfit_mem)
+{
+ struct device *dev = &nfit_mem->adev->dev;
+ struct nd_hyperv_shutdown_status status;
+ union acpi_object in_buf = {
+ .buffer.type = ACPI_TYPE_BUFFER,
+ .buffer.length = 0,
+ };
+ union acpi_object in_obj = {
+ .package.type = ACPI_TYPE_PACKAGE,
+ .package.count = 1,
+ .package.elements = &in_buf,
+ };
+ const u8 func = ND_HYPERV_GET_UNSAFE_SHUTDOWN_COUNT;
+ const guid_t *guid = to_nfit_uuid(nfit_mem->family);
+ u8 revid = nfit_dsm_revid(nfit_mem->family, func);
+ struct acpi_device *adev = nfit_mem->adev;
+ acpi_handle handle = adev->handle;
+ union acpi_object *out_obj;
+
+ if ((nfit_mem->dsm_mask & BIT(func)) == 0)
+ return;
+
+ out_obj = acpi_evaluate_dsm(handle, guid, revid, func, &in_obj);
+ if (!out_obj || out_obj->type != ACPI_TYPE_BUFFER
+ || out_obj->buffer.length < sizeof(status)) {
+ dev_dbg(dev->parent,
+ "%s: failed to get Unsafe Shutdown Count\n",
+ dev_name(dev));
+ ACPI_FREE(out_obj);
+ return;
+ }
+
+ memcpy(&status, out_obj->buffer.pointer, sizeof(status));
+ ACPI_FREE(out_obj);
+
+ if (status.general_err != 0) {
+ dev_dbg(dev->parent,
+ "%s: failed to get Unsafe Shutdown Count: err=0x%x\n",
+ dev_name(dev), status.status);
+ return;
+ }
+
+ set_bit(NFIT_MEM_DIRTY_COUNT, &nfit_mem->flags);
+ nfit_mem->dirty_shutdown = status.shutdown_count;
+}
+
+
static void populate_shutdown_status(struct nfit_mem *nfit_mem)
{
/*
@@ -1811,6 +1860,8 @@ static void populate_shutdown_status(struct nfit_mem *nfit_mem)
*/
if (nfit_mem->family == NVDIMM_FAMILY_INTEL)
nfit_intel_shutdown_status(nfit_mem);
+ else if (nfit_mem->family == NVDIMM_FAMILY_HYPERV)
+ nfit_hyperv_shutdown_status(nfit_mem);
}
static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
diff --git a/drivers/acpi/nfit/hyperv.h b/drivers/acpi/nfit/hyperv.h
new file mode 100644
index 000000000000..c4a25b8624cc
--- /dev/null
+++ b/drivers/acpi/nfit/hyperv.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright(c) 2019 Microsoft Corporation. All rights reserved.
+ * Hyper-V specific definitions for _DSM of Hyper-V Virtual NVDIMM
+ *
+ * See http://www.uefi.org/RFIC_LIST (Virtual NVDIMM 0x1901)
+ */
+#ifndef _NFIT_HYPERV_H_
+#define _NFIT_HYPERV_H_
+
+#define ND_HYPERV_GET_UNSAFE_SHUTDOWN_COUNT 2
+
+struct nd_hyperv_shutdown_status {
+ union {
+ u32 status;
+ struct {
+ u16 general_err;
+ u8 func_err;
+ u8 vendor_err;
+ };
+ };
+ u32 shutdown_count;
+} __packed;
+
+
+#endif
--
2.19.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <PU1P153MB01691690696D8F83FC1872C7BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org>]
* Re: [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV [not found] ` <PU1P153MB01691690696D8F83FC1872C7BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org> @ 2019-01-30 18:57 ` Dan Williams 2019-01-30 19:37 ` Greg KH 1 sibling, 0 replies; 5+ messages in thread From: Dan Williams @ 2019-01-30 18:57 UTC (permalink / raw) To: Dexuan Cui Cc: Josh Poulson, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, Haiyang Zhang, driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org, Rafael J. Wysocki, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kelley, Sasha Levin, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ross Zwisler, Stephen Hemminger, KY Srinivasan, Len Brown On Wed, Jan 30, 2019 at 10:49 AM Dexuan Cui <decui-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> wrote: > > > See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"): > "Get Unsafe Shutdown Count (Function Index 2)". > > Let's expose the info to the userspace (e.g. ntctl) via sysfs. > > Signed-off-by: Dexuan Cui <decui-0li6OtcxBFHby3iVrkZq2A@public.gmane.org> > --- > drivers/acpi/nfit/core.c | 51 ++++++++++++++++++++++++++++++++++++++ > drivers/acpi/nfit/hyperv.h | 26 +++++++++++++++++++ > 2 files changed, 77 insertions(+) > create mode 100644 drivers/acpi/nfit/hyperv.h Looks ok to me, but if we grow any more of these "shutdown count" retrievals I'll want to take a look at being able to call acpi_nfit_ctl() earlier in the init process so that this data marshaling can be unified. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV [not found] ` <PU1P153MB01691690696D8F83FC1872C7BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org> 2019-01-30 18:57 ` Dan Williams @ 2019-01-30 19:37 ` Greg KH [not found] ` <20190130193752.GA21181-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 5+ messages in thread From: Greg KH @ 2019-01-30 19:37 UTC (permalink / raw) To: Dexuan Cui Cc: Josh Poulson, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, Haiyang Zhang, driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org, Rafael J. Wysocki, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kelley, Sasha Levin, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ross Zwisler, Stephen Hemminger, Len Brown On Wed, Jan 30, 2019 at 06:48:40PM +0000, Dexuan Cui wrote: > > See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"): > "Get Unsafe Shutdown Count (Function Index 2)". > > Let's expose the info to the userspace (e.g. ntctl) via sysfs. If you add a new sysfs file, you need to add a new Documentation/ABI/ update as well :( ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20190130193752.GA21181-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>]
* RE: [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV [not found] ` <20190130193752.GA21181-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> @ 2019-01-30 20:02 ` Dexuan Cui [not found] ` <PU1P153MB01696669DA81578B11734765BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Dexuan Cui @ 2019-01-30 20:02 UTC (permalink / raw) To: Greg KH Cc: Josh Poulson, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, Haiyang Zhang, driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org, Rafael J. Wysocki, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kelley, Sasha Levin, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ross Zwisler, Stephen Hemminger, Len Brown > From: Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> > Sent: Wednesday, January 30, 2019 11:38 AM > > On Wed, Jan 30, 2019 at 06:48:40PM +0000, Dexuan Cui wrote: > > > > Let's expose the info to the userspace (e.g. ntctl) via sysfs. > > If you add a new sysfs file, you need to add a new Documentation/ABI/ > update as well :( It's an existing sysfs node, which was originally added by Dan in Sep 2018: /sys/bus/nd/devices/nmem0/nfit/dirty_shutdown. Before this patch, the node doesn't appear when Linux runs on Hyper-V, and with this patch, the node can appear now. However, indeed, the node and the other related nodes have not been documented in Documentation/ABI/testing/sysfs-bus-nfit yet. I suppose Dan would add that? Thanks, -- Dexuan ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <PU1P153MB01696669DA81578B11734765BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org>]
* RE: [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV [not found] ` <PU1P153MB01696669DA81578B11734765BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org> @ 2019-01-30 20:10 ` Dexuan Cui 0 siblings, 0 replies; 5+ messages in thread From: Dexuan Cui @ 2019-01-30 20:10 UTC (permalink / raw) To: Dan Williams, Greg KH Cc: Josh Poulson, Stephen Hemminger, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, Haiyang Zhang, driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org, Rafael J. Wysocki, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kelley, Sasha Levin, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ross Zwisler, Len Brown > From: Linux-nvdimm <linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org> On Behalf Of > Dexuan Cui > Sent: Wednesday, January 30, 2019 12:03 PM > To: Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> > Cc: Josh Poulson <jopoulso-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>; linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org; > Haiyang Zhang <haiyangz-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>; > driverdev-devel-tBiZLqfeLfOHmIFyCCdPziST3g8Odh+X@public.gmane.org; Rafael J. Wysocki > <rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org>; linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Michael Kelley > <mikelley-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>; Sasha Levin <Alexander.Levin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>; > linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Ross Zwisler <zwisler-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>; Stephen > Hemminger <sthemmin-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>; Len Brown <lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > Subject: RE: [PATCH] nfit: Collect shutdown status for > NVDIMM_FAMILY_HYPERV > > > From: Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> > > Sent: Wednesday, January 30, 2019 11:38 AM > > > > On Wed, Jan 30, 2019 at 06:48:40PM +0000, Dexuan Cui wrote: > > > > > > Let's expose the info to the userspace (e.g. ntctl) via sysfs. > > > > If you add a new sysfs file, you need to add a new Documentation/ABI/ > > update as well :( > > It's an existing sysfs node, which was originally added by Dan in Sep 2018: > /sys/bus/nd/devices/nmem0/nfit/dirty_shutdown. > > Before this patch, the node doesn't appear when Linux runs on Hyper-V, > and with this patch, the node can appear now. > > However, indeed, the node and the other related nodes have not been > documented in Documentation/ABI/testing/sysfs-bus-nfit yet. > I suppose Dan would add that? Actually the other nodes have been documented, and only the "dirty_shutdown" is missed. It should be straightfoward. Let me make a patch for this. Thanks for the reminder, Greg! Thanks, -- Dexuan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-30 20:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-30 18:48 [PATCH] nfit: Collect shutdown status for NVDIMM_FAMILY_HYPERV Dexuan Cui
[not found] ` <PU1P153MB01691690696D8F83FC1872C7BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org>
2019-01-30 18:57 ` Dan Williams
2019-01-30 19:37 ` Greg KH
[not found] ` <20190130193752.GA21181-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2019-01-30 20:02 ` Dexuan Cui
[not found] ` <PU1P153MB01696669DA81578B11734765BF900-7hHSCQUTt08p9lVGRpUb+2HfQuWdHs3hiGd9ebBGJoev3QGu/rdwKA@public.gmane.org>
2019-01-30 20:10 ` Dexuan Cui
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox