* [NDCTL PATCH] cxl/region: Move cxl destroy_region() to new disable_region() helper
@ 2023-11-27 23:53 Dave Jiang
2023-11-28 2:19 ` Cao, Quanquan/曹 全全
0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2023-11-27 23:53 UTC (permalink / raw
To: vishal.l.verma; +Cc: Quanquan Cao, linux-cxl, nvdimm, caoqq
To keep the behavior consistent with the disable region operation, change
the calling of cxl_region_disable() directly in destroy_region() to the
new disable_region() helper in order to check whether the region is still
online.
Suggested-by: Quanquan Cao <caoqq@fujitsu.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
cxl/region.c | 100 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 50 insertions(+), 50 deletions(-)
diff --git a/cxl/region.c b/cxl/region.c
index 5cbbf2749e2d..4091ee8d2713 100644
--- a/cxl/region.c
+++ b/cxl/region.c
@@ -728,6 +728,55 @@ out:
return rc;
}
+static int disable_region(struct cxl_region *region)
+{
+ const char *devname = cxl_region_get_devname(region);
+ struct daxctl_region *dax_region;
+ struct daxctl_memory *mem;
+ struct daxctl_dev *dev;
+ int failed = 0, rc;
+
+ dax_region = cxl_region_get_daxctl_region(region);
+ if (!dax_region)
+ goto out;
+
+ daxctl_dev_foreach(dax_region, dev) {
+ mem = daxctl_dev_get_memory(dev);
+ if (!mem)
+ return -ENXIO;
+
+ /*
+ * If memory is still online and user wants to force it, attempt
+ * to offline it.
+ */
+ if (daxctl_memory_is_online(mem)) {
+ rc = daxctl_memory_offline(mem);
+ if (rc < 0) {
+ log_err(&rl, "%s: unable to offline %s: %s\n",
+ devname,
+ daxctl_dev_get_devname(dev),
+ strerror(abs(rc)));
+ if (!param.force)
+ return rc;
+
+ failed++;
+ }
+ }
+ }
+
+ if (failed) {
+ log_err(&rl, "%s: Forcing region disable without successful offline.\n",
+ devname);
+ log_err(&rl, "%s: Physical address space has now been permanently leaked.\n",
+ devname);
+ log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n",
+ devname);
+ }
+
+out:
+ return cxl_region_disable(region);
+}
+
static int destroy_region(struct cxl_region *region)
{
const char *devname = cxl_region_get_devname(region);
@@ -737,7 +786,7 @@ static int destroy_region(struct cxl_region *region)
/* First, unbind/disable the region if needed */
if (cxl_region_is_enabled(region)) {
if (param.force) {
- rc = cxl_region_disable(region);
+ rc = disable_region(region);
if (rc) {
log_err(&rl, "%s: error disabling region: %s\n",
devname, strerror(-rc));
@@ -792,55 +841,6 @@ static int destroy_region(struct cxl_region *region)
return cxl_region_delete(region);
}
-static int disable_region(struct cxl_region *region)
-{
- const char *devname = cxl_region_get_devname(region);
- struct daxctl_region *dax_region;
- struct daxctl_memory *mem;
- struct daxctl_dev *dev;
- int failed = 0, rc;
-
- dax_region = cxl_region_get_daxctl_region(region);
- if (!dax_region)
- goto out;
-
- daxctl_dev_foreach(dax_region, dev) {
- mem = daxctl_dev_get_memory(dev);
- if (!mem)
- return -ENXIO;
-
- /*
- * If memory is still online and user wants to force it, attempt
- * to offline it.
- */
- if (daxctl_memory_is_online(mem)) {
- rc = daxctl_memory_offline(mem);
- if (rc < 0) {
- log_err(&rl, "%s: unable to offline %s: %s\n",
- devname,
- daxctl_dev_get_devname(dev),
- strerror(abs(rc)));
- if (!param.force)
- return rc;
-
- failed++;
- }
- }
- }
-
- if (failed) {
- log_err(&rl, "%s: Forcing region disable without successful offline.\n",
- devname);
- log_err(&rl, "%s: Physical address space has now been permanently leaked.\n",
- devname);
- log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n",
- devname);
- }
-
-out:
- return cxl_region_disable(region);
-}
-
static int do_region_xable(struct cxl_region *region, enum region_actions action)
{
switch (action) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [NDCTL PATCH] cxl/region: Move cxl destroy_region() to new disable_region() helper
2023-11-27 23:53 [NDCTL PATCH] cxl/region: Move cxl destroy_region() to new disable_region() helper Dave Jiang
@ 2023-11-28 2:19 ` Cao, Quanquan/曹 全全
0 siblings, 0 replies; 2+ messages in thread
From: Cao, Quanquan/曹 全全 @ 2023-11-28 2:19 UTC (permalink / raw
To: Dave Jiang, vishal.l.verma; +Cc: linux-cxl, nvdimm
> To keep the behavior consistent with the disable region operation, change
> the calling of cxl_region_disable() directly in destroy_region() to the
> new disable_region() helper in order to check whether the region is still
> online.
>
> Suggested-by: Quanquan Cao <caoqq@fujitsu.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> cxl/region.c | 100 +++++++++++++++++++++++++++++-----------------------------
> 1 file changed, 50 insertions(+), 50 deletions(-)
>
> diff --git a/cxl/region.c b/cxl/region.c
> index 5cbbf2749e2d..4091ee8d2713 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -728,6 +728,55 @@ out:
> return rc;
> }
>
> +static int disable_region(struct cxl_region *region)
> +{
> + const char *devname = cxl_region_get_devname(region);
> + struct daxctl_region *dax_region;
> + struct daxctl_memory *mem;
> + struct daxctl_dev *dev;
> + int failed = 0, rc;
> +
> + dax_region = cxl_region_get_daxctl_region(region);
> + if (!dax_region)
> + goto out;
> +
> + daxctl_dev_foreach(dax_region, dev) {
> + mem = daxctl_dev_get_memory(dev);
> + if (!mem)
> + return -ENXIO;
> +
> + /*
> + * If memory is still online and user wants to force it, attempt
> + * to offline it.
> + */
> + if (daxctl_memory_is_online(mem)) {
> + rc = daxctl_memory_offline(mem);
> + if (rc < 0) {
> + log_err(&rl, "%s: unable to offline %s: %s\n",
> + devname,
> + daxctl_dev_get_devname(dev),
> + strerror(abs(rc)));
> + if (!param.force)
> + return rc;
> +
> + failed++;
> + }
> + }
> + }
> +
> + if (failed) {
> + log_err(&rl, "%s: Forcing region disable without successful offline.\n",
> + devname);
> + log_err(&rl, "%s: Physical address space has now been permanently leaked.\n",
> + devname);
> + log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n",
> + devname);
> + }
> +
> +out:
> + return cxl_region_disable(region);
> +}
> +
> static int destroy_region(struct cxl_region *region)
> {
> const char *devname = cxl_region_get_devname(region);
> @@ -737,7 +786,7 @@ static int destroy_region(struct cxl_region *region)
> /* First, unbind/disable the region if needed */
> if (cxl_region_is_enabled(region)) {
> if (param.force) {
> - rc = cxl_region_disable(region);
> + rc = disable_region(region);
> if (rc) {
> log_err(&rl, "%s: error disabling region: %s\n",
> devname, strerror(-rc));
> @@ -792,55 +841,6 @@ static int destroy_region(struct cxl_region *region)
> return cxl_region_delete(region);
> }
>
> -static int disable_region(struct cxl_region *region)
> -{
> - const char *devname = cxl_region_get_devname(region);
> - struct daxctl_region *dax_region;
> - struct daxctl_memory *mem;
> - struct daxctl_dev *dev;
> - int failed = 0, rc;
> -
> - dax_region = cxl_region_get_daxctl_region(region);
> - if (!dax_region)
> - goto out;
> -
> - daxctl_dev_foreach(dax_region, dev) {
> - mem = daxctl_dev_get_memory(dev);
> - if (!mem)
> - return -ENXIO;
> -
> - /*
> - * If memory is still online and user wants to force it, attempt
> - * to offline it.
> - */
> - if (daxctl_memory_is_online(mem)) {
> - rc = daxctl_memory_offline(mem);
> - if (rc < 0) {
> - log_err(&rl, "%s: unable to offline %s: %s\n",
> - devname,
> - daxctl_dev_get_devname(dev),
> - strerror(abs(rc)));
> - if (!param.force)
> - return rc;
> -
> - failed++;
> - }
> - }
> - }
> -
> - if (failed) {
> - log_err(&rl, "%s: Forcing region disable without successful offline.\n",
> - devname);
> - log_err(&rl, "%s: Physical address space has now been permanently leaked.\n",
> - devname);
> - log_err(&rl, "%s: Leaked address cannot be recovered until a reboot.\n",
> - devname);
> - }
> -
> -out:
> - return cxl_region_disable(region);
> -}
> -
> static int do_region_xable(struct cxl_region *region, enum region_actions action)
> {
> switch (action) {
>
Thank you very much for your patch.
Reviewed-by: Quanquan Cao <caoqq@fujitsu.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-28 2:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 23:53 [NDCTL PATCH] cxl/region: Move cxl destroy_region() to new disable_region() helper Dave Jiang
2023-11-28 2:19 ` Cao, Quanquan/曹 全全
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.