From: "Cao, Quanquan/曹 全全" <caoqq@fujitsu.com>
To: Dave Jiang <dave.jiang@intel.com>,
linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev
Cc: vishal.l.verma@intel.com, alison.schofield@intel.com
Subject: Re: [NDCTL PATCH v2 2/2] cxl: Add check for regions before disabling memdev
Date: Thu, 30 Nov 2023 09:41:39 +0800 [thread overview]
Message-ID: <c4af4018-aec2-4874-ab9b-b24b88e9d9dc@fujitsu.com> (raw)
In-Reply-To: <170120423751.2725915.8152057882418377474.stgit@djiang5-mobl3>
> Add a check for memdev disable to see if there are active regions present
> before disabling the device. This is necessary now regions are present to
> fulfill the TODO that was left there. The best way to determine if a
> region is active is to see if there are decoders enabled for the mem
> device. This is also best effort as the state is only a snapshot the
> kernel provides and is not atomic WRT the memdev disable operation. The
> expectation is the admin issuing the command has full control of the mem
> device and there are no other agents also attempt to control the device.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> v2:
> - Warn if active region regardless of -f. (Alison)
> - Expound on -f behavior in man page. (Vishal)
> ---
> Documentation/cxl/cxl-disable-memdev.txt | 4 +++-
> cxl/memdev.c | 17 ++++++++++++++---
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/cxl/cxl-disable-memdev.txt b/Documentation/cxl/cxl-disable-memdev.txt
> index c4edb93ee94a..34b720288705 100644
> --- a/Documentation/cxl/cxl-disable-memdev.txt
> +++ b/Documentation/cxl/cxl-disable-memdev.txt
> @@ -27,7 +27,9 @@ include::bus-option.txt[]
> a device if the tool determines the memdev is in active usage. Recall
> that CXL memory ranges might have been established by platform
> firmware and disabling an active device is akin to force removing
> - memory from a running system.
> + memory from a running system. Going down this path does not offline
> + active memory if they are currently online. User is recommended to
> + offline and disable the appropriate regions before disabling the memdevs.
>
> -v::
> Turn on verbose debug messages in the library (if libcxl was built with
> diff --git a/cxl/memdev.c b/cxl/memdev.c
> index 2dd2e7fcc4dd..1d3121915284 100644
> --- a/cxl/memdev.c
> +++ b/cxl/memdev.c
> @@ -437,14 +437,25 @@ static int action_free_dpa(struct cxl_memdev *memdev,
>
> static int action_disable(struct cxl_memdev *memdev, struct action_context *actx)
> {
> + struct cxl_endpoint *ep;
> + struct cxl_port *port;
> +
> if (!cxl_memdev_is_enabled(memdev))
> return 0;
>
> - if (!param.force) {
> - /* TODO: actually detect rather than assume active */
> + ep = cxl_memdev_get_endpoint(memdev);
> + if (!ep)
> + return -ENODEV;
> +
> + port = cxl_endpoint_get_port(ep);
> + if (!port)
> + return -ENODEV;
> +
> + if (cxl_port_decoders_committed(port)) {
> log_err(&ml, "%s is part of an active region\n",
> cxl_memdev_get_devname(memdev));
> - return -EBUSY;
> + if (!param.force)
> + return -EBUSY;
> }
>
> return cxl_memdev_disable_invalidate(memdev);
>
>
Reviewed-by: Quanquan Cao <caoqq@fujitsu.com>
next prev parent reply other threads:[~2023-11-30 1:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 20:43 [NDCTL PATCH v2 1/2] cxl: Save the number of decoders committed to a port Dave Jiang
2023-11-28 20:43 ` [NDCTL PATCH v2 2/2] cxl: Add check for regions before disabling memdev Dave Jiang
2023-11-30 1:41 ` Cao, Quanquan/曹 全全 [this message]
2023-11-30 8:29 ` Cao, Quanquan/曹 全全
2023-11-30 16:07 ` Dave Jiang
2023-11-30 21:51 ` [NDCTL PATCH v3 " Dave Jiang
2024-04-17 6:46 ` Yao Xingtao
2024-04-17 18:14 ` Verma, Vishal L
2024-04-22 7:26 ` Re: Xingtao Yao (Fujitsu)
2024-04-25 5:30 ` [NDCTL PATCH v3 2/2] cxl: Add check for regions before disabling memdev Zhijian Li (Fujitsu)
2024-04-25 16:52 ` Alison Schofield
2024-04-26 1:57 ` Zhijian Li (Fujitsu)
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=c4af4018-aec2-4874-ab9b-b24b88e9d9dc@fujitsu.com \
--to=caoqq@fujitsu.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--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).