From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: <ira.weiny@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
"Ben Widawsky" <ben.widawsky@intel.com>,
<linux-cxl@vger.kernel.org>
Subject: Re: [PATCH V2 1/3] cxl/pci: Store memory capacity values
Date: Fri, 18 Jun 2021 14:40:58 +0100 [thread overview]
Message-ID: <20210618144058.0000742c@Huawei.com> (raw)
In-Reply-To: <20210617221620.1904031-2-ira.weiny@intel.com>
On Thu, 17 Jun 2021 15:16:18 -0700
<ira.weiny@intel.com> wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> The Identify Memory Device command returns information about the
> volatile only and persistent only memory capacities. Store those values
> in the cxl_mem structure for later use. While at it, reuse those
> calculations to calculate the ram and pmem ranges.
>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
New naming is indeed clearer.
FWIW
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> Changes for V2:
> Ben
> Change names to be more clear
> total_bytes
> volatile_only_bytes
> persistent_only_bytes
> ---
> drivers/cxl/mem.h | 4 ++++
> drivers/cxl/pci.c | 36 +++++++++++++++++++++++++++++++++---
> 2 files changed, 37 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/mem.h b/drivers/cxl/mem.h
> index 13868ff7cadf..9dc34418db36 100644
> --- a/drivers/cxl/mem.h
> +++ b/drivers/cxl/mem.h
> @@ -75,5 +75,9 @@ struct cxl_mem {
>
> struct range pmem_range;
> struct range ram_range;
> + u64 total_bytes;
> + u64 volatile_only_bytes;
> + u64 persistent_only_bytes;
> + u64 partition_align_bytes;
> };
> #endif /* __CXL_MEM_H__ */
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 5a1705b52278..94b7ee08ef67 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -57,6 +57,15 @@ enum opcode {
> CXL_MBOX_OP_MAX = 0x10000
> };
>
> +/*
> + * CXL 2.0 - Memory capacity multiplier
> + * See Section 8.2.9.5
> + *
> + * Volatile, Persistent, and Partition capacities are specified to be in
> + * multiples of 256MB - define a multiplier to convert to/from bytes.
> + */
> +#define CXL_CAPACITY_MULTIPLIER SZ_256M
> +
> /**
> * struct mbox_cmd - A command to be submitted to hardware.
> * @opcode: (input) The command set and command submitted to hardware.
> @@ -1542,16 +1551,37 @@ static int cxl_mem_identify(struct cxl_mem *cxlm)
> if (rc < 0)
> return rc;
>
> + cxlm->total_bytes = le64_to_cpu(id.total_capacity);
> + cxlm->total_bytes *= CXL_CAPACITY_MULTIPLIER;
> +
> + cxlm->volatile_only_bytes = le64_to_cpu(id.volatile_capacity);
> + cxlm->volatile_only_bytes *= CXL_CAPACITY_MULTIPLIER;
> +
> + cxlm->persistent_only_bytes = le64_to_cpu(id.persistent_capacity);
> + cxlm->persistent_only_bytes *= CXL_CAPACITY_MULTIPLIER;
> +
> + cxlm->partition_align_bytes = le64_to_cpu(id.partition_align);
> + cxlm->partition_align_bytes *= CXL_CAPACITY_MULTIPLIER;
> +
> + dev_dbg(&cxlm->pdev->dev, "Identify Memory Device\n"
> + " total_bytes = %#llx\n"
> + " volatile_only_bytes = %#llx\n"
> + " persistent_only_bytes = %#llx\n"
> + " partition_align_bytes = %#llx\n",
> + cxlm->total_bytes,
> + cxlm->volatile_only_bytes,
> + cxlm->persistent_only_bytes,
> + cxlm->partition_align_bytes);
> +
> /*
> * TODO: enumerate DPA map, as 'ram' and 'pmem' do not alias.
> * For now, only the capacity is exported in sysfs
> */
> cxlm->ram_range.start = 0;
> - cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) * SZ_256M - 1;
> + cxlm->ram_range.end = cxlm->volatile_only_bytes - 1;
>
> cxlm->pmem_range.start = 0;
> - cxlm->pmem_range.end =
> - le64_to_cpu(id.persistent_capacity) * SZ_256M - 1;
> + cxlm->pmem_range.end = cxlm->persistent_only_bytes - 1;
>
> cxlm->lsa_size = le32_to_cpu(id.lsa_size);
> memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));
next prev parent reply other threads:[~2021-06-18 13:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 22:16 [PATCH V2 0/3] Query and use Partition Info ira.weiny
2021-06-17 22:16 ` [PATCH V2 1/3] cxl/pci: Store memory capacity values ira.weiny
2021-06-18 13:40 ` Jonathan Cameron [this message]
2021-06-17 22:16 ` [PATCH V2 2/3] cxl/mem: Account for partitionable space in ram/pmem ranges ira.weiny
2021-06-18 13:59 ` Jonathan Cameron
2021-06-18 16:30 ` Ira Weiny
2021-06-18 16:31 ` [PATCH V3] " ira.weiny
2021-06-18 16:58 ` Ben Widawsky
2021-06-18 18:48 ` Ira Weiny
2021-06-18 19:32 ` Ben Widawsky
2021-08-11 1:49 ` [PATCH v4 2/3] " Dan Williams
2021-06-17 22:16 ` [PATCH V2 3/3] cxl/mem: Adjust ram/pmem range to represent DPA ranges ira.weiny
2021-06-18 14:03 ` Jonathan Cameron
2021-06-21 19:54 ` [PATCH V3] " ira.weiny
2021-10-27 22:40 ` [PATCH 0/9] CDAT/DSMAS reading and cleanups ira.weiny
2021-10-27 22:40 ` [PATCH 1/9] Documentation/auxiliary_bus: Clarify auxiliary_device creation ira.weiny
2021-10-27 22:40 ` [PATCH 2/9] Documentation/auxiliary_bus: Clarify match_name ira.weiny
2021-10-27 22:40 ` [PATCH 3/9] Documentation/auxiliary_bus: Update Auxiliary device lifespan ira.weiny
2021-10-27 22:43 ` [PATCH 0/9] CDAT/DSMAS reading and cleanups Ira Weiny
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=20210618144058.0000742c@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.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).