Linux CXL
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>,
	<nvdimm@lists.linux.dev>
Cc: <alison.schofield@intel.com>
Subject: Re: [NDCTL PATCH v5 2/3] cxl: Enumerate major/minor of FWCTL char device
Date: Tue, 22 Apr 2025 20:31:56 -0700	[thread overview]
Message-ID: <68085f2cd70da_71fe29420@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250411184831.2367464-3-dave.jiang@intel.com>

Dave Jiang wrote:
> Add major/minor discovery for the FWCTL character device that is associated
> with supprting CXL Features under 'struct cxl_fwctl'. A 'struct cxl_fwctl'
> may be installed under cxl_memdev if CXL Features are supported and FWCTL
> is enabled. Add libcxl API functions to retrieve the major and minor of the
> FWCTL character device.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> v5:
> - Add documentation. (Alison)
> - Alloc path on stack. (Alison)
> - Deal with out of entry and no match case. (Alison)
> - Make fwctl operations part of 'struct cxl_fwctl' (Dan)
> ---
>  Documentation/cxl/lib/libcxl.txt | 21 +++++++++
>  cxl/lib/libcxl.c                 | 78 ++++++++++++++++++++++++++++++++
>  cxl/lib/libcxl.sym               |  3 ++
>  cxl/lib/private.h                |  8 ++++
>  cxl/libcxl.h                     |  5 ++
>  5 files changed, 115 insertions(+)
> 
> diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
> index 25ff406c2920..1e00e2dd1abc 100644
> --- a/Documentation/cxl/lib/libcxl.txt
> +++ b/Documentation/cxl/lib/libcxl.txt
> @@ -42,6 +42,7 @@ struct cxl_memdev *cxl_memdev_get_next(struct cxl_memdev *memdev);
>  struct cxl_ctx *cxl_memdev_get_ctx(struct cxl_memdev *memdev);
>  const char *cxl_memdev_get_host(struct cxl_memdev *memdev)
>  struct cxl_memdev *cxl_endpoint_get_memdev(struct cxl_endpoint *endpoint);
> +struct cxl_fwctl *cxl_memdev_get_fwctl(struct cxl_memdev *memdev);
>  
>  #define cxl_memdev_foreach(ctx, memdev) \
>          for (memdev = cxl_memdev_get_first(ctx); \
> @@ -59,6 +60,9 @@ specific memdev.
>  The host of a memdev is the PCIe Endpoint device that registered its CXL
>  capabilities with the Linux CXL core.
>  
> +A memdev may host a 'struct cxl_fwctl' if CXL Features are supported and
> +Firmware Contrl (FWCTL) is also enabled.

s/Contrl/Control/

Also, do you mean CONFIG_CXL_FEATURES instead of "FWCTL", because
CONFIG_FWCTL is not sufficient.

> +
>  === MEMDEV: Attributes
>  ----
>  int cxl_memdev_get_id(struct cxl_memdev *memdev);
> @@ -185,6 +189,23 @@ device is in use. When CXL_SETPART_NEXTBOOT mode is set, the change
>  in partitioning shall become the “next” configuration, to become
>  active on the next device reset.
>  
> +FWCTL
> +-----
> +The object representing a Firmware Control (FWCTL) device is 'struct cxl_fwctl'.
> +Library interfaces related to these devices have the prefix 'cxl_fwctl_'.
> +These interfaces are associated with retrieving attributes related to the
> +CXL FWCTL character device that is a child of the memdev.

I assume any other fwctl helpers that might get added in the future
would use the object so I would give yourself some wiggle room for
cxl_fwctl to be used for more than just conveying chardev major / minor.

> +
> +=== FWCTL: Attributes
> +----
> +int cxl_fwctl_get_major(struct cxl_memdev *memdev);
> +int cxl_fwctl_get_minor(struct cxl_memdev *memdev);
> +----
> +
> +The character device node for Feature (firmware) control can be found by
> +default at /dev/fwctl/fwctl%d, or created with a major / minor returned
> +from cxl_memdev_get_fwctl_{major,minor}().
> +
>  BUSES
>  -----
>  The CXL Memory space is CPU and Device coherent. The address ranges that
> diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
> index bab7343e8a4a..be54db1b9bb9 100644
> --- a/cxl/lib/libcxl.c
> +++ b/cxl/lib/libcxl.c
> @@ -88,6 +88,7 @@ static void free_memdev(struct cxl_memdev *memdev, struct list_head *head)
>  	free(memdev->dev_buf);
>  	free(memdev->dev_path);
>  	free(memdev->host_path);
> +	free(memdev->fwctl);
>  	free(memdev);
>  }
>  
> @@ -1253,6 +1254,64 @@ static int add_cxl_memdev_fwl(struct cxl_memdev *memdev,
>  	return -ENOMEM;
>  }
>  
> +static const char fwctl_prefix[] = "fwctl";
> +static int get_feature_chardev(const char *base, char *chardev_path)
> +{
> +	char path[CXL_PATH_MAX];

This CXL_PATH_MAX approach stands out as different than all the other
path buffer management in the rest of the implementation.

In all other paths ->dev_buf has the scratch space for printing buffers.

It's not broken, but it's also odd for one off functions to switch
schemes.

  parent reply	other threads:[~2025-04-23  3:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 18:47 [NDCTL PATCH v5 0/3] ndctl: Add support and test for CXL Features support Dave Jiang
2025-04-11 18:47 ` [NDCTL PATCH v5 1/3] cxl: Add cxl_bus_get_by_provider() Dave Jiang
2025-04-11 18:47 ` [NDCTL PATCH v5 2/3] cxl: Enumerate major/minor of FWCTL char device Dave Jiang
2025-04-11 20:53   ` Alison Schofield
2025-04-11 21:06     ` Dave Jiang
2025-04-23  3:31   ` Dan Williams [this message]
2025-04-11 18:47 ` [NDCTL PATCH v5 3/3] cxl/test: Add test for cxl features device Dave Jiang
2025-04-23  3:40   ` Dan Williams
2025-04-23  5:37     ` Dan Williams
2025-04-15 20:19 ` [NDCTL PATCH v5 0/3] ndctl: Add support and test for CXL Features support Alison Schofield

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=68085f2cd70da_71fe29420@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /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