Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5432381rwl; Tue, 21 Mar 2023 19:16:14 -0700 (PDT) X-Google-Smtp-Source: AK7set+YgBT3iRzsO3fRE3eQchx1PufzhmscxOaR6dKjiQ3yeTV5d6eVZctfheS6xE4np7MXblYE X-Received: by 2002:a17:906:2081:b0:8d2:78c5:1d4e with SMTP id 1-20020a170906208100b008d278c51d4emr4653833ejq.5.1679451373582; Tue, 21 Mar 2023 19:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679451373; cv=none; d=google.com; s=arc-20160816; b=wrAEdNYHbTcgpzqy6akGIuUcJ92qqcX0SPjUVo3AtnFKv9nVM1S+dAvkUAcbe5L1kO eoHUZZljSPV4GyYIltU+AkPMwBbKmC7nDmli8bHaxvCulIS+u/YKf3BOC7xry3DQpluN AmoDNiE3NgyqU3C5tM1oAUFRI1H8SzCllKnsvyYu9fmKisI8YPzW0UFOlTi4ldSwbJ7B eA4tl0YquycXdyGDKzqxqprZWDzJIYwCHwSJOj3HSWe5On88CiFxVNGXzcKh5Pob8SUR 93MS002l6iI4CLkCBqCi29ZOFcn1YqIfZ/3hJ5AYjJwZEKqP18hhrrQ5E5LhnB1JcbBJ izOw== 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=NBIAMHX8+SgEj+ZfKw+Xha6FkxFVwGQ9Bu1y1VgXBIE=; b=lTxdRTfGip0onIA1DaYFnbrpaL9rbhYryBOYZcShXaM5hPtzX59YgA4LaRBcFDm31R OHxF1XaVqC2XqNY8M1PE6vQ3z6cGgb3yGLcHWqscCoXVPqolqRbar0hWrQGH7VM18kuf cGMn8HbpxlNm/xzdVt3LiR1iYa4d4xjLlan52I99lVKBjTDPadIKki9suFkJ9XhE6OyA djX8lVaqfh7MJMSYZeiO+rnDB3UKvdswItSDoEHUJmj7Ev3RfguytcVkXV5iX/9reHbh mVZ//+q/DmD991syiUMZh5WPm1W3qEyfTUYsEJFALDNj4vqt/IY1MtejiyE7Asd7hWNS sq1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Wxanfj/V"; 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 h1-20020a1709063c0100b009310ff0d7ffsi14423572ejg.260.2023.03.21.19.15.49; Tue, 21 Mar 2023 19:16:13 -0700 (PDT) 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="Wxanfj/V"; 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 S230297AbjCVCMy (ORCPT + 99 others); Tue, 21 Mar 2023 22:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbjCVCMh (ORCPT ); Tue, 21 Mar 2023 22:12:37 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A57015A1B4; Tue, 21 Mar 2023 19:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679451151; x=1710987151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bx5UzUKl047tv8KD71htOdRpfAR/w5OkFPahmHxcAs4=; b=Wxanfj/VahLySig6Q5ja5Qp7Uf5TRfi/RJz9nt7ICi00FtJudFLZkYuV KzW6ICCErfVREvYcbuPvq4+7LqltsULMX/YMNUoGodB7np0iawcniUjo3 iqaHzLMeM7iJQYtGI9t8Cq1kNx1fxOLXj4JQALZBx09KfsqoRBFheILGk lUghLbuYrp0ycf0Gyi8Ue7/07IxqT886lvuFIushg97vxp/Vqw41K5W/b qUhYtJbpakchaL+oeAarTzpfOty/9vPtl0CWv6IuA1/kgILEfb4P4hJAM WuM8I2qHRONod9YXLpbzbFyTldnOU3A0Lk71mR7p4KnYC2OZQ3fCypzLw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="322949650" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="322949650" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 19:12:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="805663252" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="805663252" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.251.21.85]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 19:12:29 -0700 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 v10 6/6] tools/testing/cxl: Mock support for Get Poison List Date: Tue, 21 Mar 2023 19:12:19 -0700 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=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=unavailable 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. Signed-off-by: Alison Schofield Reviewed-by: Jonathan Cameron Reviewed-by: Ira Weiny --- 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; -- 2.37.3