From: Ira Weiny <ira.weiny@intel.com>
To: Ben Widawsky <ben.widawsky@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
linux-cxl@vger.kernel.org
Subject: Re: [PATCH V3] cxl/mem: Account for partitionable space in ram/pmem ranges
Date: Fri, 18 Jun 2021 11:48:32 -0700 [thread overview]
Message-ID: <20210618184832.GD1905674@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20210618165833.2jem3rshyy7szsm6@intel.com>
On Fri, Jun 18, 2021 at 09:58:33AM -0700, Widawsky, Ben wrote:
> On 21-06-18 09:31:29, ira.weiny@intel.com wrote:
> > From: Ira Weiny <ira.weiny@intel.com>
> >
> > Memory devices may specify volatile only, persistent only, and
> > partitionable space which when added together result in a total capacity.
> >
> > If Identify Memory Device.Partition Alignment != 0 the device supports
> > partitionable space. This partitionable space can be split between
> > volatile and persistent space. The total volatile and persistent sizes
> > are reported in Get Partition Info. ie
> >
> > active volatile memory = volatile only + partitionable volatile
> > active persistent memory = persistent only + partitionable persistent
> >
> > Define cxl_mem_get_partition(), check for partitionable support, and use
> > cxl_mem_get_partition() if applicable.
>
> This doesn't look right to me, but I'll happily stand corrected.
>
[snip]
> > +
> > +static int cxl_mem_create_range_info(struct cxl_mem *cxlm)
> > +{
> > + int rc;
> > +
> > + if (cxlm->partition_align_bytes == 0) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This...
> > + cxlm->ram_range.start = 0;
> > + cxlm->ram_range.end = cxlm->volatile_only_bytes - 1;
> > + cxlm->pmem_range.start = 0;
> > + cxlm->pmem_range.end = cxlm->persistent_only_bytes - 1;
> > + return 0;
> > + }
> > +
> > + rc = cxl_mem_get_partition_info(cxlm,
> > + &cxlm->active_volatile_bytes,
> > + &cxlm->active_persistent_bytes,
> > + &cxlm->next_volatile_bytes,
> > + &cxlm->next_persistent_bytes);
> > + if (rc < 0) {
> > + dev_err(&cxlm->pdev->dev, "Failed to query partition information\n");
> > + return rc;
> > + }
>
> If the command is not supported, you're going to get back -ENXIO here and fail.
> I think what you want to do also is use IDENTIFY if PARTITION_INFO doesn't
> exist.
... should handle the situation where Get Partition Info is not supported.
I did not see it explicitly stated but I believe if Partition Align Bytes is
non-0 then partitioning is supported and Get/Set Partition Info should work.
>
> Assuming my assessment is correct, I think it's time to make
> cxl_mem_mbox_send_cmd grow a little bit better error handling. I'd recommend
> something like this and then checking for -ENOTSUPP.
>
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index b1a5a18dba92..3b7d8a905393 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -92,6 +92,7 @@ struct mbox_cmd {
> size_t size_out;
> u16 return_code;
> #define CXL_MBOX_SUCCESS 0
> +#define CXL_MBOX_UNSUPPORTED 0x15
> };
>
> static int cxl_mem_major;
> @@ -876,9 +877,15 @@ static int cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm, u16 opcode,
> if (rc)
> return rc;
>
> - /* TODO: Map return code to proper kernel style errno */
> - if (mbox_cmd.return_code != CXL_MBOX_SUCCESS)
> + switch (mbox_cmd.return_code) {
> + case CXL_MBOX_SUCCESS:
> + break;
> + case CXL_MBOX_UNSUPPORTED:
> + return -ENOTSUPP;
> + default:
> + /* TODO: Map return code to proper kernel style errno */
> return -ENXIO;
> + }
I'm not opposed to adding this though.
Ira
next prev parent reply other threads:[~2021-06-18 18:48 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
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 [this message]
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=20210618184832.GD1905674@iweiny-DESK2.sc.intel.com \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@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