From patchwork Mon Feb 20 04:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7195C636D6 for ; Mon, 20 Feb 2023 04:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjBTE4O (ORCPT ); Sun, 19 Feb 2023 23:56:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbjBTE4N (ORCPT ); Sun, 19 Feb 2023 23:56:13 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33895AD0F for ; Sun, 19 Feb 2023 20:56:09 -0800 (PST) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230220045607epoutp01111046d5cfc73c28aa3e40a1f868a9e1~Fb3EHjZ771209212092epoutp01G for ; Mon, 20 Feb 2023 04:56:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230220045607epoutp01111046d5cfc73c28aa3e40a1f868a9e1~Fb3EHjZ771209212092epoutp01G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676868967; bh=/8XRzUPFIKumR9G+4LJhDJ/dkk6vfqbQvHO37lsNtbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLDm+j+5GLD8xwHOvqR7OEJYz6wkoVjzHUEbXvCTWz/MfU9vX8mzMEfFidRsNPEMb KxOTHF9MgTk3h+cWHFTGzDvU4PsKBzbzKrGQiJDnZTQ/YsSpD9H0DQLsz3XhVuNdyd uhDsF/KuEF2kWHPN8+9qXe2zla/9AsoQrRkfNkwE= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230220045607epcas2p16a8f22e5e832d54e28ddbb0eefaba260~Fb3D1uSTZ1866718667epcas2p14; Mon, 20 Feb 2023 04:56:07 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.91]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4PKqr64HS5z4x9Q0; Mon, 20 Feb 2023 04:56:06 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 43.07.57412.66DF2F36; Mon, 20 Feb 2023 13:56:06 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20230220045606epcas2p15419bab5979bcaa9cf5bd6ecdb84cac5~Fb3C_2Zal2440924409epcas2p1B; Mon, 20 Feb 2023 04:56:06 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230220045606epsmtrp2be50aaf3872aa076b6d1a4b23bdfcadc~Fb3C7gvDX0918909189epsmtrp2S; Mon, 20 Feb 2023 04:56:06 +0000 (GMT) X-AuditID: b6c32a47-d47fe7000000e044-90-63f2fd66885c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CD.50.17995.66DF2F36; Mon, 20 Feb 2023 13:56:06 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230220045605epsmtip23620bc75f8994d234b00b9fbfad873f6~Fb3CsKAoJ2961229612epsmtip2o; Mon, 20 Feb 2023 04:56:05 +0000 (GMT) From: Junhyeok Im To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, bwidawsk@kernel.org, alison.schofield@intel.com, Junhyeok Im Subject: [ndctl 1/3] libcxl: add memdev inject poison support Date: Mon, 20 Feb 2023 13:57:07 +0900 Message-Id: <20230220045709.94027-2-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220045709.94027-1-junhyeok.im@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpik+LIzCtJLcpLzFFi42LZdljTTDft76dkg6fzFC3uPr7AZtE8eTGj xfSpFxgtFh+dwWxxftYpFotbE44xObB5LN7zkslj06pONo++LasYPT5vkgtgicq2yUhNTEkt UkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAFarqRQlphTChQKSCwu VtK3synKLy1JVcjILy6xVUotSMkpMC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIznh7dQVTwWLh igmNx5gbGF/xdzFyckgImEh8nbmVvYuRi0NIYAejxN0zy1kgnE+MEvf3HWWEcD4zSnSeuckK 07LnUyMTRGIXo8SxbxfZIJxGJomjJz+DVbEJaEv87Z/OCGKLCMhKNK97ANbBLDCBUWLp3IPM IAlhAVuJ1s8z2UBsFgFViYU/GoGWc3DwCthIfNzDDbFNXmL/wbNg5ZxA5bueLwGbzysgKHFy 5hMWEJsZqKZ562xmkPkSArfYJSa8X8wI0ewisfLQViYIW1ji1fEt7BC2lMTnd3vZIOx8iakH J0LFSyTazhyAso0l3t18zgpyD7OApsT6XfogpoSAssSRW1Br+SQ6Dv9lhwjzSnS0CUE0qkps 2fACaoi0xNGJm1ggbA+JS4uaoOEGDIV/f2ezT2BUmIXkm1lIvpmFsHgBI/MqRrHUguLc9NRi owJjeAwn5+duYgQnRi33HYwz3n7QO8TIxMF4iFGCg1lJhFf60IdkId6UxMqq1KL8+KLSnNTi Q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ffJk6O2ms64hDLMFapd9EZrl/+ac7AwlOzv1 bt3fU9+bivkuFXsxNap6x6d/X6PeFn//xpzjHTq1OHmSlqT64daPk88bfMs6/uFZYugu+5vR eQtF9nfK1F8xMzoqxMz8+l3K7fZz2sELBM9vCf6fpnfiVeacFRxRCW+7/RVyBI+Xn5i6I1qC x8ez4I2zRcmx4PKk/5cmv/4aWlivvGTp8/DFOU+rS+PTv2w8uINb9PsNc6Hm2/uDCvboT/r5 qGKx8Qrt+MezmbPWM28rnKfxZKrYnML8o/UMb5VYijMSDbWYi4oTAQG3cyXPAgAA X-CMS-MailID: 20230220045606epcas2p15419bab5979bcaa9cf5bd6ecdb84cac5 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220045606epcas2p15419bab5979bcaa9cf5bd6ecdb84cac5 References: <20230220045709.94027-1-junhyeok.im@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Add ability to inject poison based on the kernel inject poison sysfs interface. This interface trigger inject poison function by writing DPA to the memory device sysfs attribute ('inject_poison'). Link to corresponding kernel patchset: https://lore.kernel.org/linux-cxl/cover.1674101475.git.alison.schofield@intel.com/ Signed-off-by: Junhyeok Im --- cxl/lib/libcxl.c | 26 ++++++++++++++++++++++++++ cxl/lib/libcxl.sym | 5 +++++ cxl/libcxl.h | 1 + 3 files changed, 32 insertions(+) diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index 4859bd5..d2b8e19 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -1407,6 +1407,32 @@ CXL_EXPORT int cxl_memdev_enable(struct cxl_memdev *memdev) return 0; } +CXL_EXPORT int cxl_memdev_inject_poison(struct cxl_memdev *memdev, + const char *address) +{ + struct cxl_ctx *ctx = cxl_memdev_get_ctx(memdev); + char *path = memdev->dev_buf; + int len = memdev->buf_len, rc; + + if (snprintf(path, len, "%s/inject_poison", + memdev->dev_path) >= len) { + err(ctx, "%s: buffer too small\n", + cxl_memdev_get_devname(memdev)); + return -ENXIO; + } + rc = sysfs_write_attr(ctx, path, address); + if (rc < 0) { + fprintf(stderr, "%s: Failed write sysfs attr inject_poison\n", + cxl_memdev_get_devname(memdev)); + return rc; + } + + dbg(ctx, "%s: poison injected at %s\n", cxl_memdev_get_devname(memdev), + address); + + return 0; +} + static struct cxl_endpoint *cxl_port_find_endpoint(struct cxl_port *parent_port, struct cxl_memdev *memdev) { diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym index 6bc0810..c6ba248 100644 --- a/cxl/lib/libcxl.sym +++ b/cxl/lib/libcxl.sym @@ -242,3 +242,8 @@ global: cxl_target_get_firmware_node; cxl_dport_get_firmware_node; } LIBCXL_3; + +LIBCXL_5 { +global: + cxl_memdev_inject_poison; +} LIBCXL_4; diff --git a/cxl/libcxl.h b/cxl/libcxl.h index d699af8..7a2cc5f 100644 --- a/cxl/libcxl.h +++ b/cxl/libcxl.h @@ -68,6 +68,7 @@ int cxl_memdev_read_label(struct cxl_memdev *memdev, void *buf, size_t length, size_t offset); int cxl_memdev_write_label(struct cxl_memdev *memdev, void *buf, size_t length, size_t offset); +int cxl_memdev_inject_poison(struct cxl_memdev *memdev, const char *address); #define cxl_memdev_foreach(ctx, memdev) \ for (memdev = cxl_memdev_get_first(ctx); \ From patchwork Mon Feb 20 04:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C5E0C64EC4 for ; Mon, 20 Feb 2023 04:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbjBTE4Q (ORCPT ); Sun, 19 Feb 2023 23:56:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbjBTE4P (ORCPT ); Sun, 19 Feb 2023 23:56:15 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9356EB477 for ; Sun, 19 Feb 2023 20:56:11 -0800 (PST) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230220045610epoutp016599141b634c2c4c7467a5e1964b6987~Fb3GiBAEE1209112091epoutp01L for ; Mon, 20 Feb 2023 04:56:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230220045610epoutp016599141b634c2c4c7467a5e1964b6987~Fb3GiBAEE1209112091epoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676868970; bh=rnK2jF8fa2h5GKKaa2x/H8Jc+D90RT+sgHPrSoAXrsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSWXyJ+sTWVDeqy+f8b2Z3KO3TPrClfihRXaSuqHrWQ7CbBMIunPtBO5nGAF1lrrc w+n2TG3iimRjMSlmxZYpwuuW7n3uJllrt+VjgUwt31dCiPCNBt9rK3EfTqIXYmBzsO N7W2VJiGyepN5FZiERVLVrHKNTcq/KuHKSvNgxGE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230220045609epcas2p2a22275931c28fc18e6a08f6d8e25d432~Fb3GNFfrs1751717517epcas2p2K; Mon, 20 Feb 2023 04:56:09 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.98]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4PKqr91Xr9z4x9Q1; Mon, 20 Feb 2023 04:56:09 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 33.1A.61927.86DF2F36; Mon, 20 Feb 2023 13:56:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20230220045608epcas2p11d40339e7401f5bf99a9e97308058fec~Fb3FC95xY2440924409epcas2p1I; Mon, 20 Feb 2023 04:56:08 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230220045608epsmtrp1caba9ee99caf62e079a09daf15a53e62~Fb3FCNXLS1499014990epsmtrp1Q; Mon, 20 Feb 2023 04:56:08 +0000 (GMT) X-AuditID: b6c32a45-671ff7000001f1e7-53-63f2fd68e98e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CE.50.17995.86DF2F36; Mon, 20 Feb 2023 13:56:08 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230220045608epsmtip24520f52e27069e83ea990899a7d43862~Fb3E0TzSM2878428784epsmtip2g; Mon, 20 Feb 2023 04:56:08 +0000 (GMT) From: Junhyeok Im To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, bwidawsk@kernel.org, alison.schofield@intel.com, Junhyeok Im Subject: [ndctl 2/3] cxl: add inject-poison command to cxl tool Date: Mon, 20 Feb 2023 13:57:08 +0900 Message-Id: <20230220045709.94027-3-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220045709.94027-1-junhyeok.im@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkk+LIzCtJLcp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S-MailID: 20230220045608epcas2p11d40339e7401f5bf99a9e97308058fec X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220045608epcas2p11d40339e7401f5bf99a9e97308058fec References: <20230220045709.94027-1-junhyeok.im@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Add new command to cli tool, to inject poison into dpa(-a) on the memory device. DPA written in sysfs attribute(inject_poison) is converted by kstrtou64 with 0 base by 'inject_poison_store' of CXL driver, so if it begins with 0x the number will be parsed as a hexadecimal (case insensitive), if it otherwise begins with 0, it will be parsed as an octal number. Otherwise it will be parsed as a decimal. Since the validity verification of the dpa would be done in 'cxl_validate_poison_dpa' of CXL driver, no additional logic is added. Also since it is expected no use case of injecting poison into the same address for multiple devices, this command targets only one memdev, like write-labels command. usage: cxl inject-poison -a [] -v, --verbose turn on debug -S, --serial use serial numbers to id memdevs -a, --address DPA to inject poison Link to corresponding kernel patch: https://patchwork.kernel.org/project/cxl/patch/97a0b128d0d0df56cea1a1a4ead65a40b9cf008e.1674101475.git.alison.schofield@intel.com/ Signed-off-by: Junhyeok Im --- cxl/builtin.h | 1 + cxl/cxl.c | 1 + cxl/memdev.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/cxl/builtin.h b/cxl/builtin.h index 34c5cfb..ddc4da9 100644 --- a/cxl/builtin.h +++ b/cxl/builtin.h @@ -23,4 +23,5 @@ int cmd_enable_region(int argc, const char **argv, struct cxl_ctx *ctx); int cmd_disable_region(int argc, const char **argv, struct cxl_ctx *ctx); int cmd_destroy_region(int argc, const char **argv, struct cxl_ctx *ctx); int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx); +int cmd_inject_poison(int argc, const char **argv, struct cxl_ctx *ctx); #endif /* _CXL_BUILTIN_H_ */ diff --git a/cxl/cxl.c b/cxl/cxl.c index 3be7026..aa8d090 100644 --- a/cxl/cxl.c +++ b/cxl/cxl.c @@ -77,6 +77,7 @@ static struct cmd_struct commands[] = { { "disable-region", .c_fn = cmd_disable_region }, { "destroy-region", .c_fn = cmd_destroy_region }, { "monitor", .c_fn = cmd_monitor }, + { "inject-poison", .c_fn = cmd_inject_poison }, }; int main(int argc, const char **argv) diff --git a/cxl/memdev.c b/cxl/memdev.c index 0b3ad02..7a10f79 100644 --- a/cxl/memdev.c +++ b/cxl/memdev.c @@ -34,6 +34,7 @@ static struct parameters { const char *type; const char *size; const char *decoder_filter; + const char *poison_address; } param; static struct log_ctx ml; @@ -85,6 +86,10 @@ OPT_STRING('t', "type", ¶m.type, "type", \ OPT_BOOLEAN('f', "force", ¶m.force, \ "Attempt 'expected to fail' operations") +#define INJECT_POISON_OPTIONS() \ +OPT_STRING('a', "address", ¶m.poison_address, "dpa", \ + "DPA to inject poison") + static const struct option read_options[] = { BASE_OPTIONS(), LABEL_OPTIONS(), @@ -135,6 +140,12 @@ static const struct option free_dpa_options[] = { OPT_END(), }; +static const struct option inject_poison_options[] = { + BASE_OPTIONS(), + INJECT_POISON_OPTIONS(), + OPT_END(), +}; + enum reserve_dpa_mode { DPA_ALLOC, DPA_FREE, @@ -351,6 +362,24 @@ static int action_free_dpa(struct cxl_memdev *memdev, return __reserve_dpa(memdev, DPA_FREE, actx); } +static int action_inject_poison(struct cxl_memdev *memdev, + struct action_context *actx) +{ + int rc; + + if (!param.poison_address) { + log_err(&ml, "%s: set dpa to inject poison.\n", + cxl_memdev_get_devname(memdev)); + return -EINVAL; + } + rc = cxl_memdev_inject_poison(memdev, param.poison_address); + if (rc < 0) { + log_err(&ml, "%s: inject poison failed: %s\n", + cxl_memdev_get_devname(memdev), strerror(-rc)); + } + return rc; +} + static int action_disable(struct cxl_memdev *memdev, struct action_context *actx) { if (!cxl_memdev_is_enabled(memdev)) @@ -755,7 +784,8 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx, continue; found = true; - if (action == action_write) { + if ((action == action_write) || + (action == action_inject_poison)) { single = memdev; rc = 0; } else @@ -771,9 +801,15 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx, } rc = err; - if (action == action_write) { + if ((action == action_write) || (action == action_inject_poison)) { if (count > 1) { - error("write-labels only supports writing a single memdev\n"); + if (action == action_write) { + error("write-labels only supports writing " + "a single memdev\n"); + } else { + error("inject-poison only supports injection " + "of poison into a single memdev\n"); + } usage_with_options(u, options); return -EINVAL; } else if (single) { @@ -893,3 +929,14 @@ int cmd_free_dpa(int argc, const char **argv, struct cxl_ctx *ctx) return count >= 0 ? 0 : EXIT_FAILURE; } + +int cmd_inject_poison(int argc, const char **argv, struct cxl_ctx *ctx) +{ + int count = memdev_action( + argc, argv, ctx, action_inject_poison, inject_poison_options, + "cxl inject-poison -a []"); + log_info(&ml, "inject-poison %d mem%s\n", count >= 0 ? count : 0, + count > 1 ? "s" : ""); + + return count >= 0 ? 0 : EXIT_FAILURE; +} From patchwork Mon Feb 20 04:57:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45217C05027 for ; Mon, 20 Feb 2023 04:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbjBTE4S (ORCPT ); Sun, 19 Feb 2023 23:56:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjBTE4Q (ORCPT ); Sun, 19 Feb 2023 23:56:16 -0500 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5846CAD0F for ; Sun, 19 Feb 2023 20:56:14 -0800 (PST) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230220045612epoutp02a311608604de0e242391e04a158bd15d~Fb3IimEiO0251302513epoutp02C for ; Mon, 20 Feb 2023 04:56:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230220045612epoutp02a311608604de0e242391e04a158bd15d~Fb3IimEiO0251302513epoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676868972; bh=Pfrzu8Wbex/JgffOTP9GKaek8xOiG+IofFAMFv8YnRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3g+rvwfxydFaVl6HYgHzgL/vNnBkKHEKc7V6WcmiWuoOp+AavtJDpHKH5YY1dvyh E6iKReZMNzm4qMK5nz+1wRhMSmPZ4Occ2/t73crGcIV1szs3e0jkJAFlyvKTnQk+Vx unEDpC+zOmyvnSlrxwqMPBcKOjmyQCaxXpOiAJic= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230220045611epcas2p207db0f79cd4059e14ec98437cc811975~Fb3INj-Q41274112741epcas2p2C; Mon, 20 Feb 2023 04:56:11 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.88]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4PKqrC2Vzxz4x9Pt; Mon, 20 Feb 2023 04:56:11 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 58.1A.61927.B6DF2F36; Mon, 20 Feb 2023 13:56:11 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230220045610epcas2p269c76f9b80a8d18d357af396b2968970~Fb3HTJWbd1274112741epcas2p29; Mon, 20 Feb 2023 04:56:10 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230220045610epsmtrp259f02d9e0c55e74c79ca47579018902c~Fb3HQwYgt0918909189epsmtrp2W; Mon, 20 Feb 2023 04:56:10 +0000 (GMT) X-AuditID: b6c32a45-e942ca800001f1e7-61-63f2fd6bb2cb Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 84.63.05839.A6DF2F36; Mon, 20 Feb 2023 13:56:10 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230220045610epsmtip2e07fa35a96cbe13dc1c4fd1fab22963f~Fb3HC-1T73014230142epsmtip2I; Mon, 20 Feb 2023 04:56:10 +0000 (GMT) From: Junhyeok Im To: linux-cxl@vger.kernel.org Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, bwidawsk@kernel.org, alison.schofield@intel.com, Junhyeok Im Subject: [ndctl 3/3] Documentation: add man page documentation for inject-poison Date: Mon, 20 Feb 2023 13:57:09 +0900 Message-Id: <20230220045709.94027-4-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220045709.94027-1-junhyeok.im@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpik+LIzCtJLcpLzFFi42LZdljTVDf776dkg+YnghZ3H19gs2ievJjR YvrUC4wWi4/OYLY4P+sUi8WtCceYHNg8Fu95yeSxaVUnm0ffllWMHp83yQWwRGXbZKQmpqQW KaTmJeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gAtV1IoS8wpBQoFJBYX K+nb2RTll5akKmTkF5fYKqUWpOQUmBfoFSfmFpfmpevlpZZYGR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ZtE8eTGj xfSpFxgtFh+dwWxxftYpFotbE44xObB5LN7zkslj06pONo++LasYPT5vkgtgieKySUnNySxL LdK3S+DKeDJ9ImPBa8mK6Xe+MTYwbhbtYuTkkBAwkbh7ey57FyMXh5DAbkaJvbOXM0MkpCVu POpig7CFJe63HGEFsYUE/jNKHP+uDGKzCWhL/O2fzghiiwjISjSve8AEYjMLTGOU2L43EcQW FgiQ+P94LthMFgFViUvfZ7CD2LwCNhIvJ3yDmi8vsf/gWbAaTgFbiV3Pl0DtspH4OeshVL2g xMmZT1i6GDmA5qtLrJ8nBLFKXqJ562zmCYyCs5BUzUKomoWkagEj8ypGydSC4tz03GLDAsO8 1HK94sTc4tK8dL3k/NxNjOBg19Lcwbh91Qe9Q4xMHIyHGCU4mJVEeKUPfUgW4k1JrKxKLcqP LyrNSS0+xCjNwaIkznuh62S8kEB6YklqdmpqQWoRTJaJg1OqgWn7r8JYj6oXGwUjPk0LMpIM MHknYpObE160T+3bemCEm0Zc55mp5dObW7ia6XPisSwn9XIemUmX826UJ5ndnjrdt1IioWHG Pp8Fwu/buBTq7laruwbsceqbpHdFv4fnqIra+aZbW6wi+kuuf3vwboZb/zRzXh+jO5c9hWs+ Ppv2wvsa/7dQ5zVGty/uZ7DpfWxz2qzIe8Hh1Zy3/stxMWxY4Sx8I7E/6cPU4Fy3W1XWXSW7 zt3UjHt57DXH8VcXzm7elTZH1fB4yez1x1siVZf8lOep5LM/6v++7cavaQba59R69Lf6s9yN L3z5gMFbZvbF2079qx+Jfcy+LTD3pc+HyRLFTat8Tn958enrRSWW4oxEQy3mouJEALPMx/zl AgAA X-CMS-MailID: 20230220045610epcas2p269c76f9b80a8d18d357af396b2968970 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220045610epcas2p269c76f9b80a8d18d357af396b2968970 References: <20230220045709.94027-1-junhyeok.im@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Add man page documentation for inject-poison command in cxl, also add the content of cxl_memdev_inject_poison in libcxl. Signed-off-by: Junhyeok Im --- Documentation/cxl/cxl-inject-poison.txt | 42 +++++++++++++++++++++++++ Documentation/cxl/lib/libcxl.txt | 4 +++ Documentation/cxl/meson.build | 1 + 3 files changed, 47 insertions(+) create mode 100644 Documentation/cxl/cxl-inject-poison.txt diff --git a/Documentation/cxl/cxl-inject-poison.txt b/Documentation/cxl/cxl-inject-poison.txt new file mode 100644 index 0000000..d438d33 --- /dev/null +++ b/Documentation/cxl/cxl-inject-poison.txt @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 + +cxl-inject-poison(1) +==================== + +NAME +---- +cxl-inject-poison - send inject poison command to specified CXL memdev + targeting given DPA. + +SYNOPSIS +-------- +[verse] +'cxl inject-poison -a []' + +DESCRIPTION +----------- +Add the to the poison list and the error source shall be set +to an injected error. In addition, the device shall add an appropriate poison +creation event to its internal Informational Event Log, update the Event Status +register, and if configured, interrupt the host. + +OPTIONS +------- +:: + A 'memX' device name, or a memdev id number. Restrict the operation to + the specified memdev. + +-a:: +--address=:: + Physical address of a CXL memdev to inject poison into. + +-S:: +--serial=:: + Specify CXL memory device serial number(s) to filter the listing + +include::verbose-option.txt[] + + +SEE ALSO +-------- +CXL-2.0 8.2.9.5.4.2 diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt index f9af376..95f5662 100644 --- a/Documentation/cxl/lib/libcxl.txt +++ b/Documentation/cxl/lib/libcxl.txt @@ -132,6 +132,7 @@ int cxl_memdev_read_label(struct cxl_memdev *memdev, void *buf, size_t length, size_t offset); int cxl_memdev_write_label(struct cxl_memdev *memdev, void *buf, size_t length, size_t offset); +int cxl_memdev_inject_poison(struct cxl_memdev *memdev, const char *address); struct cxl_cmd *cxl_cmd_new_get_partition(struct cxl_memdev *memdev); struct cxl_cmd *cxl_cmd_new_set_partition(struct cxl_memdev *memdev, unsigned long long volatile_size); @@ -172,6 +173,9 @@ cxl_memdev{read,write,zero}_label() are helpers for marshaling multiple label access commands over an arbitrary extent of the device's label area. +cxl_memdev_inject_poison supports injecting poison into a physical address +on a specified CXL memory device. + cxl_cmd_partition_set_mode() supports selecting NEXTBOOT or IMMEDIATE mode. When CXL_SETPART_IMMEDIATE mode is set, it is the caller’s responsibility to avoid immediate changes to partitioning when the diff --git a/Documentation/cxl/meson.build b/Documentation/cxl/meson.build index a6d77ab..a972467 100644 --- a/Documentation/cxl/meson.build +++ b/Documentation/cxl/meson.build @@ -46,6 +46,7 @@ cxl_manpages = [ 'cxl-enable-region.txt', 'cxl-destroy-region.txt', 'cxl-monitor.txt', + 'cxl-inject-poison.txt', ] foreach man : cxl_manpages