Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp7012972rwb; Wed, 18 Jan 2023 12:15:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5MfXbmJIfZ2ute0PRexMybHTz0mHfiSWiTacsDqaHp7aGP2PFj/OkpfPiKaHddtmj29f6 X-Received: by 2002:a05:6402:401b:b0:46f:d386:117d with SMTP id d27-20020a056402401b00b0046fd386117dmr9121554eda.33.1674072949766; Wed, 18 Jan 2023 12:15:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674072949; cv=none; d=google.com; s=arc-20160816; b=MAh6DhCKQiLMACdYpgVRdFBEH0z5Qz0JxzbLa7bHYgx7xao0mCw9sOiIoGTjdidNA7 GiyAeV74VzQIxLH/0/k1gDUGAFxCSK1Me3Laow4U65y1MnNnmlxuSfHRs4pMFUjBl86w 9jvc7FUVJ6Vkwgky3tQqdAOKXd3In0M5T8s3O88E4Cdxr7T0Fm9VF6I5dBFtRyAZtT23 c6XQXXVydwQny4DnBqYPLuCWRjixytYym2SgaAexxsx2mbxFuEV8Jfg1ed+/egOFN5dE j5yKRBXZkWeN1Giem5sQAVfwzeA+1CKZz8moadKm+tdFaHf0dXZ8ZEiBEQUw0LP0fyGJ 8pIg== 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=6to2tOtCuvpcSPyuXOXdStUlYVqiFxg/lye7ig/9Q5U=; b=ISzg0jW9NlCrYeupU3ldbL4M42agAi3TfuMe6V83/hKoZ1ApwvL7qKBJSNngucngwO SgHomKTKF1fc71ElJZ87aNRQf42x5mNEmtQihIYvaMbAChMTVRszU0uT/x069MTPx5z7 qm1Fl3ix5CCZEGk+wwDTKFJDU3z8uvxRST/egN/7wKFr6l3TRJnSwIH8D08tzYuS99Y2 rZql3GNUO/St9lRYgEmphbT1BQnvZYx5IK0P4s6FDw10PBc7YF3OZ1Z+k48pJac6Up+a IwIzlEa6B6laTtF3fWkls6NwtXhLR4RnZuS4hCh3dZLb/A8h63pIzsYtWeKhmBldO+WV NX6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AvMvIf9+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v17-20020a056402349100b0049e1b840be0si12692197edc.9.2023.01.18.12.15.39; Wed, 18 Jan 2023 12:15:49 -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=AvMvIf9+; 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 S229818AbjARUDS (ORCPT + 45 others); Wed, 18 Jan 2023 15:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbjARUDG (ORCPT ); Wed, 18 Jan 2023 15:03:06 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C033A5899F; Wed, 18 Jan 2023 12:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674072171; x=1705608171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K6n6AW/LYnF9WLCAnay5xJmlW79haRIrJ58eRL1qqYo=; b=AvMvIf9+mMkN/o1mngvhjXHgD8LlZV3hAu0o672G/cyn7KsXITbk36mY mpr5ScsMSv8yyLRRvwD8CM0T8Y1micnLY/db3Los7ZEg2NZSKMQNHr0tn afW57MCB37pKZPpHGUzbyjmzbAn1XBusFDeIwXntsZCZWjiI2VDC66tW4 ldJNkpoiy5qFMLiTKmKz6ynHSUzepf8HjextIeNjTgsVrE1lTsUNyO4Aj mYBusfkg8jgg9pVVJWEEQCye/JK53jPEMX7PXkBCHfVQ25emJf+oSQSTu WJ0GR7+fGObBFmf+dB6NA94L37ywlZz9nvJ8ZFLayzXyShbc8AKwtH/sJ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322776805" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="322776805" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 12:02:31 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="661861705" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="661861705" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.119.104]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 12:02:30 -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 v5 5/5] tools/testing/cxl: Mock support for Get Poison List Date: Wed, 18 Jan 2023 12:02:21 -0800 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 5e4ecd93f1d2..09dc358bb33b 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #define LSA_SIZE SZ_128K @@ -38,6 +39,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 */ @@ -141,6 +146,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; @@ -558,6 +565,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; + } mock_plist = { + .po = { + .count = cpu_to_le16(1), + }, + .record = { + .length = cpu_to_le32(1), + .address = cpu_to_le64(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; @@ -606,6 +641,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; } @@ -664,6 +702,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; -- 2.37.3