anitazha / rpms / ndctl

Forked from rpms/ndctl a year ago
Clone

Blame SOURCES/0134-libcxl-return-the-partition-alignment-field-in-bytes.patch

e0018b
From ac0066a6095e9ed0910fc560277ec693d3b507fa Mon Sep 17 00:00:00 2001
e0018b
From: Alison Schofield <alison.schofield@intel.com>
e0018b
Date: Tue, 22 Feb 2022 11:56:05 -0800
e0018b
Subject: [PATCH 134/217] libcxl: return the partition alignment field in bytes
e0018b
e0018b
Per the CXL specification, the partition alignment field reports
e0018b
the alignment value in multiples of 256MB. In the libcxl API, values
e0018b
for all capacity fields are defined to return bytes.
e0018b
e0018b
Update the partition alignment accessor to return bytes so that it
e0018b
is in sync with other capacity related fields.
e0018b
e0018b
Since this is early in the development cycle, the expectation is that
e0018b
no third party consumers of this library have come to depend on the
e0018b
encoded capacity field. If that is not the case, the original format
e0018b
can be restored, and a new _bytes version introduced.
e0018b
e0018b
Link: https://lore.kernel.org/r/6b937b09b61ddf95e069fd7acfda0c5bbb845be8.1645558189.git.alison.schofield@intel.com
e0018b
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 cxl/lib/libcxl.c | 13 +++++--------
e0018b
 1 file changed, 5 insertions(+), 8 deletions(-)
e0018b
e0018b
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
e0018b
index 9413384..c05c13c 100644
e0018b
--- a/cxl/lib/libcxl.c
e0018b
+++ b/cxl/lib/libcxl.c
e0018b
@@ -2308,15 +2308,12 @@ CXL_EXPORT int cxl_cmd_identify_get_fw_rev(struct cxl_cmd *cmd, char *fw_rev,
e0018b
 CXL_EXPORT unsigned long long cxl_cmd_identify_get_partition_align(
e0018b
 		struct cxl_cmd *cmd)
e0018b
 {
e0018b
-	struct cxl_cmd_identify *id =
e0018b
-			(struct cxl_cmd_identify *)cmd->send_cmd->out.payload;
e0018b
-
e0018b
-	if (cmd->send_cmd->id != CXL_MEM_COMMAND_ID_IDENTIFY)
e0018b
-		return -EINVAL;
e0018b
-	if (cmd->status < 0)
e0018b
-		return cmd->status;
e0018b
+	struct cxl_cmd_identify *c;
e0018b
 
e0018b
-	return le64_to_cpu(id->partition_align);
e0018b
+	c = cmd_to_identify(cmd);
e0018b
+	if (!c)
e0018b
+		return ULLONG_MAX;
e0018b
+	return cxl_capacity_to_bytes(c->partition_align);
e0018b
 }
e0018b
 
e0018b
 CXL_EXPORT unsigned int cxl_cmd_identify_get_label_size(struct cxl_cmd *cmd)
e0018b
-- 
e0018b
2.27.0
e0018b