From patchwork Mon Feb 20 01:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146028 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 55178C05027 for ; Mon, 20 Feb 2023 01:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbjBTBgP (ORCPT ); Sun, 19 Feb 2023 20:36:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjBTBgO (ORCPT ); Sun, 19 Feb 2023 20:36:14 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 674BACDF0 for ; Sun, 19 Feb 2023 17:36:11 -0800 (PST) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230220013607epoutp01effa0613b70de033a74b3ed5b78f6e43~FZIbzeFRf0859508595epoutp014 for ; Mon, 20 Feb 2023 01:36:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230220013607epoutp01effa0613b70de033a74b3ed5b78f6e43~FZIbzeFRf0859508595epoutp014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676856967; bh=r+xFE5aTgSzJ+99XOc1TcIc6SBBlpEr+tRMCUosjHTU=; h=From:To:Cc:Subject:Date:References:From; b=apAzYB+7ozmywNJk4DZz1ZD1NM+DvMwTwVkGvto5WUyVZTjjK0vc3keLtpNtfBWx6 HSzDMkjQMSKov9if0WYUQDgLKBT6WkkixaXz7iWYsxqaBJsPvBRNVmo8nJZ4CngWu8 Atq8YBIItNlXfo8+TLwqlTpIiX1sL8mcMUrQBvoE= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230220013606epcas2p4adca5794d60a03ea8a33bb0038c183f5~FZIbbgn062821128211epcas2p4U; Mon, 20 Feb 2023 01:36:06 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.69]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4PKlPL06Jhz4x9Pq; Mon, 20 Feb 2023 01:36:06 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.81.57412.58EC2F36; Mon, 20 Feb 2023 10:36:05 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20230220013605epcas2p414e4f0c0c3c82bc5a004d19f4f02f15f~FZIaev-Nx2821128211epcas2p4O; Mon, 20 Feb 2023 01:36:05 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230220013605epsmtrp1bead02619b7bb064e85e85dc2fab27e9~FZIaeGhsJ1322213222epsmtrp1g; Mon, 20 Feb 2023 01:36:05 +0000 (GMT) X-AuditID: b6c32a47-ab7ff7000000e044-78-63f2ce8513ab Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 69.BF.05839.58EC2F36; Mon, 20 Feb 2023 10:36:05 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230220013605epsmtip1afa060ec95c58d0ad61e0432e9c74a82~FZIaT26qB1780917809epsmtip1g; Mon, 20 Feb 2023 01:36:05 +0000 (GMT) From: junhyeok.im@samsung.com 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 10:37:12 +0900 Message-Id: <20230220013714.22277-1-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMKsWRmVeSWpSXmKPExsWy7bCmqW7ruU/JBu0fzCzuPr7AZtE8eTGj xfSpFxgtFh+dwWxxftYpFotbE44xObB5LN7zkslj06pONo++LasYPT5vkgtgicq2yUhNTEkt UkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAFarqRQlphTChQKSCwu VtK3synKLy1JVcjILy6xVUotSMkpMC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIztjc9Iit4JJw xYlFX5gbGCcJdDFyckgImEgsb9rH3MXIxSEksINR4ubkOUwgCSGBT4wSP7uzIRLfGCUe7vjN 2sXIAdax9qMzRHwvUE3jE3YIp5FJ4t+yU6wg3WwCshJXD99gB7FFgOzmdQ+YQIqYBSYwSiyd e5AZJCEsYCvR+nkmG4jNIqAqMW37QbDVvAI2Eos+HWaFuE9eYv/Bs8wQcUGJkzOfsIDYzEDx 5q2zwe6WEDjELtG1/AJUg4vElhcTWSBsYYlXx7ewQ9hSEi/726DsfImpBydC2SUSbWcOQNnG Eu9uPgd7k1lAU2L9Ln2Ij5UljtyCWssn0XH4LztEmFeio00IolFVYsuGF1BDpCWOTtwEdYCH xM+re9hAyoUEYiUub4mbwCg/C8kvs5D8Mgth7QJG5lWMYqkFxbnpqcVGBcbwKE3Oz93ECE59 Wu47GGe8/aB3iJGJg/EQowQHs5IIr/ShD8lCvCmJlVWpRfnxRaU5qcWHGE2BoTuRWUo0OR+Y fPNK4g1NLA1MzMwMzY1MDcyVxHmlbU8mCw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vrFi3b5Cz8vNHX98/p7iI5vV3Jf1Us2t/VWod8TWlfuWeVSv/zU/gJnhn2T NkT7fn9UOb08P/eiaP/1uKTYRolk/oxZ+maXPsVp37Pr/jZju7i7yIJa87fXKnY9bvpzwnWD b3Kc546rFsvePMm7POnO/PCfFX5Hw/knid7fbhXv+14hvrqBeef+2dYu/mrlIRJR6aIOy37s SQ3P/2/zS0yJpTgj0VCLuag4EQB88HNAtwIAAA== X-CMS-MailID: 20230220013605epcas2p414e4f0c0c3c82bc5a004d19f4f02f15f X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220013605epcas2p414e4f0c0c3c82bc5a004d19f4f02f15f References: Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Junhyeok Im 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 01:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146029 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 3476DC05027 for ; Mon, 20 Feb 2023 01:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbjBTBgU (ORCPT ); Sun, 19 Feb 2023 20:36:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbjBTBgT (ORCPT ); Sun, 19 Feb 2023 20:36:19 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2B0D509 for ; Sun, 19 Feb 2023 17:36:17 -0800 (PST) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230220013616epoutp01c8742f3d2db1fe2bc1602f8718f4d2f5~FZIkToHrb0996009960epoutp01C for ; Mon, 20 Feb 2023 01:36:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230220013616epoutp01c8742f3d2db1fe2bc1602f8718f4d2f5~FZIkToHrb0996009960epoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676856976; bh=jOE0S1lpP/uoxhtSgbae+fH/Au3BGni5ipxoEv6UUoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+b3/LMqy8jK2YQ0f2byEEQhNuVCSMbu49FZ1h9KAzgP/yxdmC8m78wz8CoUqQuY0 IsOZCT+dtZEgpCxoR+6MDqWPd4hQk2Za2qGqQ2WcBVFLpbbLGdg3vl2a+hngL/qBIS uH5ZIjKxDhWi5I86KUkpx4KTPL5hvaZnMAjUNSzY= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230220013615epcas2p489b0a7c343cdbab44cc942c55c72a061~FZIjtjITn2089420894epcas2p4F; Mon, 20 Feb 2023 01:36:15 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.89]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4PKlPV6X0Wz4x9Q9; Mon, 20 Feb 2023 01:36:14 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 68.9D.05668.E8EC2F36; Mon, 20 Feb 2023 10:36:14 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230220013613epcas2p23cee8c0fe839f12ca125e97c6f66d815~FZIiJTQgg3031730317epcas2p2P; Mon, 20 Feb 2023 01:36:13 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230220013613epsmtrp2ba5cbe3465123b8fb84f55771782a17b~FZIiIduV40856508565epsmtrp2U; Mon, 20 Feb 2023 01:36:13 +0000 (GMT) X-AuditID: b6c32a48-45bfc70000021624-1e-63f2ce8e6eed Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 80.5C.17995.D8EC2F36; Mon, 20 Feb 2023 10:36:13 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230220013613epsmtip19972cd83f8867d9ca1f798048653586e~FZIh8auug2382023820epsmtip1F; Mon, 20 Feb 2023 01:36:13 +0000 (GMT) From: junhyeok.im@samsung.com 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 10:37:13 +0900 Message-Id: <20230220013714.22277-2-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220013714.22277-1-junhyeok.im@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLKsWRmVeSWpSXmKPExsWy7bCmuW7fuU/JBs/+cVjcfXyBzaJ58mJG i+lTLzBaLD46g9ni/KxTLBa3JhxjcmDzWLznJZPHplW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ktstQl/iV/aCSXYLLrF8XslypMxU iaU4I9FQi7moOBEAYEhI4BAEAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsWy7bCSnG7vuU/JBo+69C3uPr7AZtE8eTGj xfSpFxgtFh+dwWxxftYpFotbE44xObB5LN7zkslj06pONo++LasYPT5vkgtgieKySUnNySxL LdK3S+DKuPzkFHvBJO2Kld9TGxjnKnUxcnJICJhI7Nx3hBHEFhLYwSjxtI0fIi4tceNRFxuE LSxxv+UIaxcjF1DNf0aJDdc2gDWwCchKXD18gx3EFgGym9c9YAKxmQWmMUps35vYxcjBISxg LzFnfz5ImEVAVeLUhtdgrbwCNhK7v/ezQMyXl9h/8CwzSDmngK3E1mOsEOfYSLQ8nscKUS4o cXLmExaI6fISzVtnM09gFJiFJDULSWoBI9MqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95Pzc TYzg0NXS2sG4Z9UHvUOMTByMhxglOJiVRHilD31IFuJNSaysSi3Kjy8qzUktPsQozcGiJM57 oetkvJBAemJJanZqakFqEUyWiYNTqoHJfvm00vMs4qvMF5/Y0VDG/OqyVHexQYu/9M7eTdrb Xtg6TZ21a2PlBP2OP1tcAnoF7OyLn0YqTfzUYBS1p3PPqSm/tBprNK++XvK0TpPn3hLeLe4r prZ/lLxbslCdJ0rn46Et65bzyZS9MuSo0fvDNHfeuidztx1b0ibX/jCCP/Lq5aaUpOjpQkFP Dy1qM9S2nn7IvjNpU49x43pVQdvSuGyhZVrLvb6wd4ts+BTRc1urKyfqyteCxZ19e39P3b3m pMHTxbrtz7z60m7qLtqq98o4Z5/I/KM/kyZN/FctxpFx5F7pN1tObbG644omRbdud26Yr3WL +afeFk0XeXnZ/EZ+1zqTJ+lrF/yqr6pRYinOSDTUYi4qTgQAcyNbqcwCAAA= X-CMS-MailID: 20230220013613epcas2p23cee8c0fe839f12ca125e97c6f66d815 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220013613epcas2p23cee8c0fe839f12ca125e97c6f66d815 References: <20230220013714.22277-1-junhyeok.im@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Junhyeok Im 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 01:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Junhyeok Im X-Patchwork-Id: 13146030 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 975B7C6379F for ; Mon, 20 Feb 2023 01:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbjBTBg1 (ORCPT ); Sun, 19 Feb 2023 20:36:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbjBTBg1 (ORCPT ); Sun, 19 Feb 2023 20:36:27 -0500 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F579D504 for ; Sun, 19 Feb 2023 17:36:24 -0800 (PST) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230220013618epoutp023c6fdff5fe5592e5b0cfe8b20c985c38~FZIm1sKn_0161401614epoutp02w for ; Mon, 20 Feb 2023 01:36:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230220013618epoutp023c6fdff5fe5592e5b0cfe8b20c985c38~FZIm1sKn_0161401614epoutp02w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676856978; bh=/IBwnt1tVu0nWCR1VNwMGDzLhw2dt8eo54Zi6bAqvDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6I1wwbrPBbb/uAs/pi8juiwpf0N7ma2hA/UQTHl6IaV1HmTXSkxzMJhj9QSnkIaD Z+58q/EQVZQolYeRLsxQiSYoyHTLn4553ipYd+VR7i8Z8jle/eJFHL9430M/7swdJx V1MTBdMPKhiiyVaDEjA5da/u6Q6pnK+IK8yaUkn0= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230220013618epcas2p284503f3f48eb531daa308a8b84c74c7f~FZImUzmE02984429844epcas2p2A; Mon, 20 Feb 2023 01:36:18 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.99]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4PKlPY5ST1z4x9QH; Mon, 20 Feb 2023 01:36:17 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id F5.32.31307.09EC2F36; Mon, 20 Feb 2023 10:36:17 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230220013616epcas2p331fee08f8caaa0402ab33ebdd07d868e~FZIkpRO1r1401114011epcas2p3S; Mon, 20 Feb 2023 01:36:16 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230220013616epsmtrp20f6066b49efcac868e28c486b9303477~FZIkojbjY0850708507epsmtrp2p; Mon, 20 Feb 2023 01:36:16 +0000 (GMT) X-AuditID: b6c32a46-743fa70000007a4b-e1-63f2ce90fe5a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id DC.BF.05839.09EC2F36; Mon, 20 Feb 2023 10:36:16 +0900 (KST) Received: from dell-ArcherCity.dsn.sec.samsung.com (unknown [10.229.83.212]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230220013616epsmtip1141e6676fc67c79f8cc7ea9c21e82985~FZIkd9RwJ2340523405epsmtip1J; Mon, 20 Feb 2023 01:36:16 +0000 (GMT) From: junhyeok.im@samsung.com 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 10:37:14 +0900 Message-Id: <20230220013714.22277-3-junhyeok.im@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220013714.22277-1-junhyeok.im@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkk+LIzCtJLcpLzFFi42LZdljTTHfiuU/JBj1fGC3uPr7AZtE8eTGj xfSpFxgtFh+dwWxxftYpFotbE44xObB5LN7zkslj06pONo++LasYPT5vkgtgicq2yUhNTEkt UkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAFarqRQlphTChQKSCwu VtK3synKLy1JVcjILy6xVUotSMkpMC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIzpj1ZDNbwSyp iptv5rM3MN4W7WLk5JAQMJF4eH4BYxcjF4eQw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ms tUjfLoErY9aTzWwFs6Qqbr6Zz97AeFu0i5GTQ0LARKL71T7WLkYuDiGB3YwSBz8sZYZISEvc eNTFBmELS9xvOQJV9J9RYtKjg2AJNgFZiauHb7CD2CJAdvO6B0wgNrPANEaJ7XsTQWxhgQCJ /4/nAg3l4GARUJXYfTMTJMwrYCPx82EzE8R8eYn9B8+ClXAK2EpsPcYKEhYCKml5PI8VolxQ 4uTMJywgJcwC6hLr5wlBLJKXaN46m3kCo+AsJFWzEKpmIalawMi8ilEytaA4Nz232LDAMC+1 XK84Mbe4NC9dLzk/dxMjONS1NHcwbl/1Qe8QIxMH4yFGCQ5mJRFe6UMfkoV4UxIrq1KL8uOL SnNSiw8xSnOwKInzXug6GS8kkJ5YkpqdmlqQWgSTZeLglGpgcu8wvd14PMeI4Y37mwUsQbdn BD1l79q2PvGWUkDKrul3K84lpFmfDw2Xf/IlkWdbh+b1SUfvyWta3GqZtLXav69v+STu9Gs2 11Lm5AneDv6h9lL4GWda6NNH/lPOPVu4JyD29LfvXd9T1DPaOWabs/ltZllz6urnMx+nznz3 867cg9QVBW+XGprMO+teZuPEc7D69oPUFLc49sYK1l9Ggav/2he9d7eIezcvQsj7kPKaDX1z OoLCH210EH19U1AnRjm4UTc04bXH53nX7q+crrzp/h//X8+1iu/q9NXoHFw44d7dHwcij00O 3V9fphx1VaQqvnNRfVXLXIefpx5XvWJ+t3CFT7jyHHVz5ttM05RYijMSDbWYi4oTAbEU22Pk AgAA X-CMS-MailID: 20230220013616epcas2p331fee08f8caaa0402ab33ebdd07d868e X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230220013616epcas2p331fee08f8caaa0402ab33ebdd07d868e References: <20230220013714.22277-1-junhyeok.im@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Junhyeok Im 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