From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>,
Robert Richter <rrichter@amd.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] cxl/uapi: Tag commands from cxl_query_cmd()
Date: Thu, 2 Feb 2023 10:01:25 +0000 [thread overview]
Message-ID: <20230202100125.0000590a@Huawei.com> (raw)
In-Reply-To: <20230202095821.00001a98@Huawei.com>
On Thu, 2 Feb 2023 09:58:21 +0000
Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:
> On Wed, 01 Feb 2023 17:23:12 -0800
> Ira Weiny <ira.weiny@intel.com> wrote:
>
> > It was pointed out that commands not supported by the device or excluded
> > by the kernel were being returned in cxl_query_cmd().[1]
> >
> > While libcxl correctly handles failing commands, it is more efficient to
> > not issue an invalid command in the first place. This can't be done
> > without additional information being returned from cxl_query_cmd(). In
> > addition, information about the availability of commands can be useful
> > for debugging.
> >
> > Add flags to struct cxl_command_info which reflect if a command is
> > enabled and/or exclusive to the kernel.
> >
> > [1] https://lore.kernel.org/all/63b4ec4e37cc1_5178e2941d@dwillia2-xfh.jf.intel.com.notmuch/
> >
> > Suggested-by: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
>
> No mention of why we can use space in the existing defined flag mask?
>
> I couldn't find a reason why we couldn't previously but Dan's proposal
> was to reserve that first bit so I'm wondering on the reasoning one
> way or the other!
>
> Other than that detail, this looks like a good solution to me.
On second thoughts. Some docs for the two flags explaining what they
mean would be good to have (as there isn't a reference to how to use
them in the Docs patch that follows this).
>
> Jonathan
>
>
> >
> > ---
> > Changes for v3:
> > Dan
> > Pass enabled/exclusive flags to user space rather than
> > masking those commands.
> > ---
> > drivers/cxl/core/mbox.c | 9 +++++++--
> > include/uapi/linux/cxl_mem.h | 4 +++-
> > 2 files changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index b03fba212799..6ab4613f3cf9 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -445,9 +445,14 @@ int cxl_query_cmd(struct cxl_memdev *cxlmd,
> > * structures.
> > */
> > cxl_for_each_cmd(cmd) {
> > - const struct cxl_command_info *info = &cmd->info;
> > + struct cxl_command_info info = cmd->info;
> >
> > - if (copy_to_user(&q->commands[j++], info, sizeof(*info)))
> > + if (test_bit(info.id, cxlmd->cxlds->enabled_cmds))
> > + info.flags |= CXL_MEM_COMMAND_FLAG_ENABLED;
> > + if (test_bit(info.id, cxlmd->cxlds->exclusive_cmds))
> > + info.flags |= CXL_MEM_COMMAND_FLAG_EXCLUSIVE;
> > +
> > + if (copy_to_user(&q->commands[j++], &info, sizeof(info)))
> > return -EFAULT;
> >
> > if (j == n_commands)
> > diff --git a/include/uapi/linux/cxl_mem.h b/include/uapi/linux/cxl_mem.h
> > index 459a3f7f764b..4aee64b7cc1a 100644
> > --- a/include/uapi/linux/cxl_mem.h
> > +++ b/include/uapi/linux/cxl_mem.h
> > @@ -91,7 +91,9 @@ struct cxl_command_info {
> > __u32 id;
> >
> > __u32 flags;
> > -#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0)
> > +#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(1, 0)
> > +#define CXL_MEM_COMMAND_FLAG_ENABLED BIT(0)
> > +#define CXL_MEM_COMMAND_FLAG_EXCLUSIVE BIT(1)
> >
> > __u32 size_in;
> > __u32 size_out;
> >
>
next prev parent reply other threads:[~2023-02-02 10:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 1:23 [PATCH v3 0/4] CXL: Miscellaneous fixes Ira Weiny
2023-02-02 1:23 ` [PATCH v3 1/4] cxl/mem: Remove unused CXL_CMD_FLAG_NONE define Ira Weiny
2023-02-02 1:23 ` [PATCH v3 2/4] cxl/uapi: Add warning on CXL command enum Ira Weiny
2023-02-02 1:23 ` [PATCH v3 3/4] cxl/uapi: Tag commands from cxl_query_cmd() Ira Weiny
2023-02-02 9:58 ` Jonathan Cameron
2023-02-02 10:01 ` Jonathan Cameron [this message]
2023-02-02 23:58 ` Ira Weiny
2023-02-02 1:23 ` [PATCH v3 4/4] cxl/mem: Fix UAPI command comment Ira Weiny
2023-02-02 10:01 ` Jonathan Cameron
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=20230202100125.0000590a@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=rrichter@amd.com \
--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