Skip to content

Commit fae8817

Browse files
committed
cxl/mem: Fix memory device capacity probing
The CXL Identify Memory Device output payload emits capacity in 256MB units. The driver is treating the capacity field as bytes. This was missed because QEMU reports bytes when it should report bytes / 256MB. Fixes: 8adaf74 ("cxl/mem: Find device capabilities") Reviewed-by: Vishal Verma <vishal.l.verma@intel.com> Cc: Ben Widawsky <ben.widawsky@intel.com> Link: https://lore.kernel.org/r/161862021044.3259705.7008520073059739760.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent b21bb4c commit fae8817

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/cxl/mem.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/security.h>
55
#include <linux/debugfs.h>
66
#include <linux/module.h>
7+
#include <linux/sizes.h>
78
#include <linux/mutex.h>
89
#include <linux/cdev.h>
910
#include <linux/idr.h>
@@ -1419,6 +1420,7 @@ static int cxl_mem_enumerate_cmds(struct cxl_mem *cxlm)
14191420
*/
14201421
static int cxl_mem_identify(struct cxl_mem *cxlm)
14211422
{
1423+
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
14221424
struct cxl_mbox_identify {
14231425
char fw_revision[0x10];
14241426
__le64 total_capacity;
@@ -1447,10 +1449,11 @@ static int cxl_mem_identify(struct cxl_mem *cxlm)
14471449
* For now, only the capacity is exported in sysfs
14481450
*/
14491451
cxlm->ram_range.start = 0;
1450-
cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) - 1;
1452+
cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) * SZ_256M - 1;
14511453

14521454
cxlm->pmem_range.start = 0;
1453-
cxlm->pmem_range.end = le64_to_cpu(id.persistent_capacity) - 1;
1455+
cxlm->pmem_range.end =
1456+
le64_to_cpu(id.persistent_capacity) * SZ_256M - 1;
14541457

14551458
memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));
14561459

0 commit comments

Comments
 (0)