From patchwork Thu Feb 9 23:32:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 55139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp637570wrn; Thu, 9 Feb 2023 15:37:26 -0800 (PST) X-Google-Smtp-Source: AK7set/GzJtDpZwc8CeNK4fU8r4iwcULT4FxwNl4jAfyrHjIWEjD/T+0Ft24PS7wrW42ZJN95jLu X-Received: by 2002:a17:90b:b0d:b0:230:caa5:521d with SMTP id bf13-20020a17090b0b0d00b00230caa5521dmr15080836pjb.17.1675985845768; Thu, 09 Feb 2023 15:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675985845; cv=none; d=google.com; s=arc-20160816; b=hDC4jZDph+TxoU7P2NXjXgj4Bs5O6rJzao3iWXYT7IanOqPhQSwpPatf2yWCfnrMOb kB5s0/CkqY/OMYmemh1KWr5bNY8lMTKousDCKJbstQ5aAPm8RVANVI/y2pCXkdwy7of7 MsBN2vWFo8lXcUh4JXSQWwMgKb8/A3MzZMsiu0KAUvymY0VLq1Yz1Zhn1h1LxOysaoPk pnGV9WC42rGsvchCgmMBj9YCvwDZgXffKhRI+BC87tkWQ9ufdC91sgsKKZKfh6MU3YxA TiEvxuJ0HOGp2ZFfWV5+wkkqst+j5drgBWdQbYIfKtwqj5FnqW4VhDhkRxlQHUKDjwa/ 7ggQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fCa/LUAJy/za2K2nv1j4fENllcfqcXtVarR6+6AZ4wQ=; b=RVSmV4EZOeII5dWLaM621adna0kJpmXkEByJecDZgf669nZ9TyKDtOKkrWVFlWBxje FIg0aa7LkXFDQUgoS4ck6Lp5Hv6OE09frsInHpGuxy+VrobftMlRaqLjUxzeDZq7PezF sbi4VBUnr3GKtVlVFz5h4dDe9XHxqjxD5eUGy9BpaYkkAbdPxfzc95nDq1mrjWHTmCQp qEi4cykazZNxmzs6LZ0z94OxCbmfzAGpmLt/vyS1dDO4TJRcBcfxvxX6O2ndKpmhuFOM Y0djzQ7uBWogJ11cx3vu0Vee1EtyBAfB8hVSC8OAxkmcE3tYT4UzqYEA0dKnmIfp4kNo A7eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HvkrHeTa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s26-20020a63925a000000b00477bf7b0c43si2941790pgn.458.2023.02.09.15.37.13; Thu, 09 Feb 2023 15:37:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HvkrHeTa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231210AbjBIXgJ (ORCPT + 99 others); Thu, 9 Feb 2023 18:36:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231172AbjBIXfg (ORCPT ); Thu, 9 Feb 2023 18:35:36 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D68176F201; Thu, 9 Feb 2023 15:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675985712; x=1707521712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XCVgqF8shH5rFyH7hk0Emjtujq62iDahDM3kYDntmz4=; b=HvkrHeTa4VBHBXazw+WB9hly1+XkQGAY3hnHhnLC0o4Yjd1ti+qLFq6Q lYsfOfqS0jmhu5lj3PZZreN+439RfPPCMjY9aLaABoXB0niUYWaB+gINV gG2rTnA47I965A81UueXJMP7T7nJ0Hqdp5uqoaOh78WxKIOeA1IjoFclf E03hFiy7cxeCfDPSjXZpAHw3C4XGUhq9kjBvlzc5qEXgBWu4HaUtE6D1Q uuNFXh7d6bhIX+YTY+ZY/RAeYH2FTFyIfMBHd62K25RUAzXzVF6w/fpMY 4hAtDyd8PWS9A/lIXSMQ+9HvjMvIo07frg+2+7gbT8LjyhVeRArEEjbPr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="416508753" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="416508753" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 15:33:12 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="756592054" X-IronPort-AV: E=Sophos;i="5.97,285,1669104000"; d="scan'208";a="756592054" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.13.232]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2023 15:33:11 -0800 From: alison.schofield@intel.com To: Dan Williams , Ira Weiny , Vishal Verma , Dave Jiang , Ben Widawsky , Steven Rostedt Cc: Alison Schofield , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 6/6] tools/testing/cxl: Mock support for Get Poison List Date: Thu, 9 Feb 2023 15:32:59 -0800 Message-Id: <26eb1ac9b8d6e7ff969537e29812d9e2d007632a.1675983077.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757398533969062012?= X-GMAIL-MSGID: =?utf-8?q?1757398533969062012?= From: Alison Schofield Make mock memdevs support the Get Poison List mailbox command. Return a fake poison error record when the get poison list command is issued. This supports testing the kernel tracing and cxl list capabilities for media errors. Reviewed-by: Jonathan Cameron Signed-off-by: Alison Schofield --- tools/testing/cxl/test/mem.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 9263b04d35f7..2fa9c18d4c2c 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "trace.h" @@ -40,6 +41,10 @@ static struct cxl_cel_entry mock_cel[] = { .opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO), .effect = cpu_to_le16(0), }, + { + .opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON), + .effect = cpu_to_le16(0), + }, }; /* See CXL 2.0 Table 181 Get Health Info Output Payload */ @@ -471,6 +476,8 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER), }; + put_unaligned_le24(CXL_POISON_LIST_MAX, id.poison_list_max_mer); + if (cmd->size_out < sizeof(id)) return -EINVAL; @@ -888,6 +895,34 @@ static int mock_health_info(struct cxl_dev_state *cxlds, return 0; } +static int mock_get_poison(struct cxl_dev_state *cxlds, + struct cxl_mbox_cmd *cmd) +{ + struct cxl_mbox_poison_payload_in *pi = cmd->payload_in; + + /* Mock one poison record at pi.offset for 64 bytes */ + struct { + struct cxl_mbox_poison_payload_out po; + struct cxl_poison_record record; + } __packed mock_plist = { + .po = { + .count = cpu_to_le16(1), + }, + .record = { + .length = cpu_to_le32(1), + .address = cpu_to_le64(le64_to_cpu(pi->offset) + + CXL_POISON_SOURCE_INJECTED), + }, + }; + + if (cmd->size_out < sizeof(mock_plist)) + return -EINVAL; + + memcpy(cmd->payload_out, &mock_plist, sizeof(mock_plist)); + cmd->size_out = sizeof(mock_plist); + return 0; +} + static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) { struct device *dev = cxlds->dev; @@ -942,6 +977,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd * case CXL_MBOX_OP_PASSPHRASE_SECURE_ERASE: rc = mock_passphrase_secure_erase(cxlds, cmd); break; + case CXL_MBOX_OP_GET_POISON: + rc = mock_get_poison(cxlds, cmd); + break; default: break; } @@ -1010,6 +1048,10 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) if (rc) return rc; + rc = cxl_poison_state_init(cxlds); + if (rc) + return rc; + rc = cxl_dev_state_identify(cxlds); if (rc) return rc;