From patchwork Fri Mar 10 17:54:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 67623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1015460wrd; Fri, 10 Mar 2023 09:57:57 -0800 (PST) X-Google-Smtp-Source: AK7set+hm/CK4xfVTDZIRNuLVjdJgC0MxwFOXhnHTNxfEWpmK8hqCO8FEjGaa+C26D6B5d75cctR X-Received: by 2002:a05:6a20:2a12:b0:cc:e0fb:a835 with SMTP id e18-20020a056a202a1200b000cce0fba835mr22877029pzh.47.1678471077668; Fri, 10 Mar 2023 09:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678471077; cv=none; d=google.com; s=arc-20160816; b=LtMquPJRgGKyYRb/BqHAJxerl7ydud+Eq6RRetjBclKHLyZdqmFzCp5zzVJgtBGlXM Zg2ejV2iqjhIZ2IwOVDK5p2UMydklxkIulNjQbNi1ZYVky36VPW1GZGf2HK0GGuRzCWu lEncUi3QPS/y8igoxyxO7vhj8BUvmbwjM4tGTYSVj2K+FkRJKrU9XnyJMi6uR2VJ8wVb y+2OalUpCEIGvRIwsX96VCoOLh84GGL1u+MEBs4yyg+d2KeV7vu90aJmug9PxaCv/UXM GszxzZM6Vnf/1LHbmdzO4L31/pRIGPmCAqKvSGM9fto6aejdoFJjQ8AmtMZMEsL4yubw iOZg== 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=TeVihVHQ4yneWMfjoPrStvSkBYtqo55VZrVsN4xpsxA=; b=ZUJB4xUPbkqvi4Nu3BNy0hOmQCzqqSv9RJpbUpm4yyWh2BcDmmObuX1m/niibnu3pi 36rmWYbHAvoNKwxUpgIajPLIut6Eo6Fn+3NM9KfVloPhuG0V2yDumVQG0Y2SNCL9Bjm9 pOS5XuI5vlDnTImuyloDvZtXLHo0DNdobJDANIwdKYJ1Saq05GmLm+iAqvk+6JrZG8zs uQ2qixyun3mp2MW+x32g8ljq18lAOmpx6c9DprcbGO5fMSTBAlCJNy4m6fdoT/DcUbSz ADS1fUnVllqLpxbp/pFPhWNtrGByIh2HrHi5UL4VWuQzTPjY7dV0NKQnQRHyLyVqwZVW FPHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MAnHvaBm; 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 j7-20020a63fc07000000b004fb12ee7cb9si331403pgi.354.2023.03.10.09.57.44; Fri, 10 Mar 2023 09:57:57 -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=MAnHvaBm; 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 S231493AbjCJR47 (ORCPT + 99 others); Fri, 10 Mar 2023 12:56:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjCJR4r (ORCPT ); Fri, 10 Mar 2023 12:56:47 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94456134831; Fri, 10 Mar 2023 09:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678470968; x=1710006968; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vkJ1gJmE+nX0k0RDJxr3koG2zAk0rxfEp3qrjnGSjh8=; b=MAnHvaBmuCMWjaLG+vlk5T+EfnlLGc68rPBfoLBmMNtwwu5umkIQTSMH 8kcY+ftpgs2wivJVKzorf/xfiJHE/kvI5xnQs9U4NTZGkhBmZtIhq+G+i MToYSadTlyP/0h62hTVelgynPhP4TFLCC+MOSe4rT7wOPQ9vrd2APtod9 4cr5pXCRGMdVsebP5Qsk/jDubJt5/ncypy0fblbGm2DEX0qNosNjegOBV BXQk3U0YsncFClCEYQsa58z3Hn9j2e7m8mb1QzEz1JRM+JH8nEBtfZXe+ 5wvognIm3A1WW3jvB5czuEj8lZ8Y3xSDsuk2oE2o2SpAOs0rVrLomYmVe w==; X-IronPort-AV: E=McAfee;i="6500,9779,10645"; a="334266207" X-IronPort-AV: E=Sophos;i="5.98,250,1673942400"; d="scan'208";a="334266207" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2023 09:55:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10645"; a="852008219" X-IronPort-AV: E=Sophos;i="5.98,250,1673942400"; d="scan'208";a="852008219" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.255.228.62]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2023 09:54:32 -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 v8 6/6] tools/testing/cxl: Mock support for Get Poison List Date: Fri, 10 Mar 2023 09:54:20 -0800 Message-Id: <2d36d28755beda9d941301fa63da97b525203d7a.1678468593.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,URIBL_BLOCKED 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?1760004488683870000?= X-GMAIL-MSGID: =?utf-8?q?1760004488683870000?= 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;