From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>,
Oliver O'Halloran <oohall@gmail.com>,
Alastair D'Silva <alastair@au1.ibm.com>,
"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Subject: [RFC PATCH 6/6] powerpc/papr_scm: Implement support for DSM_PAPR_SCM_STATS
Date: Wed, 29 Jan 2020 20:58:44 +0530 [thread overview]
Message-ID: <20200129152844.71286-7-vaibhav@linux.ibm.com> (raw)
In-Reply-To: <20200129152844.71286-1-vaibhav@linux.ibm.com>
The DSM 'DSM_PAPR_SCM_STATS' should return the PAPR defined buffer
that holds various dimm performance attributes as defined in Ref[1]
back to user-space in response to ND_CMD_CALL.
Presently the module doesn't interpret nor consume these stat as they
are only intended to be consumer and reported by
'libndctl'[2]. PAPR sped [1] states that input buffer to be provided
to H_SCM_PERFORMANCE_HEALTH hcall should be 4KiB in size. However due
to limitations of the libnvdimm envelop (which is 256 bytes in size)
such a large buffer cannot be copied back to user-space.
Hence we do an optimization of querying the size of the output buffer
from H_SCM_PERFORMANCE_HEALTH hcall and copy only the needed portion
of the buffer to the user-space payload package.
This patch implements this DSM by implementing a new function
papr_scm_get_stats that queries the DIMM stat information and then
copies PHYP provided buffer that holds these stat attributes to the
package payload whose layout is defined by 'struct
papr_scm_perf_stats'
References:
[1]: https://patchwork.ozlabs.org/patch/1154292/
[2]: https://github.com/pmem/ndctl
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
arch/powerpc/platforms/pseries/papr_scm.c | 51 +++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
index 6c0bc8f027db..ac50968453b0 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -34,6 +34,7 @@
enum {
DSM_PAPR_MIN = 0x10000,
DSM_PAPR_SCM_HEALTH,
+ DSM_PAPR_SCM_STATS,
DSM_PAPR_MAX,
};
@@ -410,6 +411,51 @@ static int papr_scm_get_health(struct papr_scm_priv *p,
return 0;
}
+/* Fetch the DIMM stats and populate it in provided papr_scm package */
+static int papr_scm_get_stats(struct papr_scm_priv *p,
+ struct nd_pkg_papr_scm *pkg)
+{
+ struct papr_scm_perf_stats *retbuffer;
+ int rc;
+ size_t copysize;
+
+ /* Return buffer for phyp where stats are written */
+ retbuffer = kzalloc(PAPR_SCM_MAX_PERF_STAT, GFP_KERNEL);
+
+ if (!retbuffer)
+ return -ENOMEM;
+
+ rc = drc_pmem_query_stats(p, retbuffer);
+ if (rc)
+ goto out;
+
+ /*
+ * Parse the retbuffer, fetch the size returned and return the
+ * first nd_size_out bytes back to userspce.
+ */
+ pkg->hdr.nd_fw_size = be16_to_cpu(retbuffer->size);
+ copysize = min_t(__u32, pkg->hdr.nd_fw_size, pkg->hdr.nd_size_out);
+
+ memcpy(pkg->payload, retbuffer, copysize);
+
+ /* Verify if the returned buffer was copied completely */
+ if (pkg->hdr.nd_fw_size > copysize) {
+ rc = -ENOSPC;
+ goto out;
+ }
+
+out:
+ kfree(retbuffer);
+ /*
+ * Put the error in out package and return success from function
+ * so that errors if any are propogated back to userspace.
+ */
+ pkg->cmd_status = rc;
+ dev_dbg(&p->pdev->dev, "%s completion code = %d\n", __func__, rc);
+
+ return 0;
+}
+
int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc)
{
@@ -460,6 +506,11 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
*cmd_rc = papr_scm_get_health(p, call_pkg);
break;
+ case DSM_PAPR_SCM_STATS:
+ call_pkg = (struct nd_pkg_papr_scm *) buf;
+ *cmd_rc = papr_scm_get_stats(p, call_pkg);
+ break;
+
default:
dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd_in);
*cmd_rc = -EINVAL;
--
2.24.1
prev parent reply other threads:[~2020-01-29 15:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 15:28 [RFC PATCH 0/6] powerpc/papr_scm: Implement support for reporting DIMM health and stats Vaibhav Jain
2020-01-29 15:28 ` [RFC PATCH 1/6] powerpc/papr_scm: Provide support for fetching dimm health information Vaibhav Jain
2020-01-29 15:28 ` [RFC PATCH 2/6] powerpc/papr_scm: Fetch dimm performance stats from PHYP Vaibhav Jain
2020-01-29 15:28 ` [RFC PATCH 3/6] UAPI: ndctl: Introduce NVDIMM_FAMILY_PAPR as a new NVDIMM DSM family Vaibhav Jain
2020-01-29 15:28 ` [RFC PATCH 4/6] powerpc/papr_scm: Add support for handling PAPR DSM commands Vaibhav Jain
2020-01-29 15:28 ` [RFC PATCH 5/6] powerpc/papr_scm: Implement support for DSM_PAPR_SCM_HEALTH Vaibhav Jain
2020-01-29 15:28 ` Vaibhav Jain [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200129152844.71286-7-vaibhav@linux.ibm.com \
--to=vaibhav@linux.ibm.com \
--cc=alastair@au1.ibm.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=oohall@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).