From patchwork Fri Nov 11 03:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 18403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp512072wru; Thu, 10 Nov 2022 19:15:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+EG+bZJcBKavMDuCs5UFxC3H+7eBX0fJJiq2MvJlbcbhlEbI0eAATvIREmN9KxfckqyEI X-Received: by 2002:a17:902:e5c9:b0:188:602b:8259 with SMTP id u9-20020a170902e5c900b00188602b8259mr509116plf.139.1668136556099; Thu, 10 Nov 2022 19:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668136556; cv=none; d=google.com; s=arc-20160816; b=mrDJ+y2wX4eDI6coJe56DWzLV0Z7IGfpPthA+rU24rQ9ukauNMOwtQ1cC4z6JeGr/g MOPPmgzNYgyy7Q/DUYBpXP7aiNRHvSMGmLJ5uukhyUNdPQrCF+9Rz68jnbMO1UxhsPrt r9l32iIKcjkw4sTYuS0fnygXhRpApg5JT5GURpOrCzZBJfGnVE9svs9cgrbW+krmJrzn 3lAJLb6XpLV6xSvCF6ll6lYFa42nhpQxWixrZNH7PPE0EbRWp/jGRhbsVvLx6PSPgM4y Qh/F60O7V0petpyqnl1d2XXLanUw5etBwaiHz6jpULyiiVXqgHbsVld3cfkweh1JOaTi iJhw== 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=VljfeLsa4uxFVwdlDyMrvC9ocC0NGWhhxBaPHmC0jps=; b=TZ77OL5N3m2KNYSDr+IOzLZUIRT4z3GVXeJJ+2hgsnMppf/IIWSSyuv+ph3x/KH8oV 4uDt437mzvwRjfec67IKoDD+fi5B6/SmfVgKsZdb2SWCGTL/1VEDqViiBIedsVCPVdkY iJEHKYvwe5jJ6gqwFq0effOyV8vctwDHB9/XUbm/bngjCZfx4TBcnJLTW94HEGuv+ymM hdbxwW7jGe27YxL66u42COZWaZRVpk1JOOepiJrX04J1RyA4uw9hiy4up2SfBk1VgaXO mJIoK8067rdRLdJfeLJIJ+8fRnYU87ikjiDolnpF5FcPvEBxixLTW/ARVULjWlz4B6OB qywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IUdDeEcW; 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 hk16-20020a17090b225000b00213db2b6587si7202054pjb.169.2022.11.10.19.15.43; Thu, 10 Nov 2022 19:15:56 -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=IUdDeEcW; 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 S232855AbiKKDNP (ORCPT + 99 others); Thu, 10 Nov 2022 22:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232667AbiKKDND (ORCPT ); Thu, 10 Nov 2022 22:13:03 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC2F5CD29; Thu, 10 Nov 2022 19:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668136380; x=1699672380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y00FqPXd0tXMVfbMPOYOFfjRtaD0786m2Qc/OlOfGUE=; b=IUdDeEcWfeS9KM33cf7hVpD8Az0gL3y3vfxU+Fdsb/MJyFviz3FLIoc4 cWZKLYlVg8Y0FM88FSzBw9vZAVE1vsPIGhFu5Lr8Ce0mc4VA/dARTEOjX WYefm52/CWHIPPhsaAsDFZ9l7kwJRJMOXfGXMe39WhE2bMzeajtRigpWQ dQBhP8LU2lxYyhh6e0CCegh+SAXh/mP+c4cJZDZqpErXu6m39qnd+j44k FHg5ubgQA7PTMhD0ADaP+pb8upN0lgv3SsyTK9iqyTV5UZcZyj4rSOnoc ycT1a7EUUmvJ5Uy/MHebiwf4Wj78WVpPIW/W7rGrpBna/tEIa26F9MlzU g==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="310224419" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="310224419" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 19:13:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="812296108" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="812296108" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.161.45]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 19:12:59 -0800 From: alison.schofield@intel.com To: Dan Williams , Ira Weiny , Vishal Verma , Dave Jiang , Ben Widawsky , Steven Rostedt , Ingo Molnar Cc: Alison Schofield , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/6] tools/testing/cxl: Mock the Get Poison List mbox command Date: Thu, 10 Nov 2022 19:12:44 -0800 Message-Id: <7accc4b25613bd04ded1c48fa317dcf08803575f.1668115235.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?1749167957770910944?= X-GMAIL-MSGID: =?utf-8?q?1749167957770910944?= From: Alison Schofield Return fake poison error records when the get poison list mbox 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 --- tools/testing/cxl/test/mem.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index f0704d090073..f729e055605d 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -38,6 +38,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 */ @@ -207,6 +211,30 @@ 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 { + struct cxl_mbox_poison_payload_out poison_out; + struct cxl_poison_record record; + } mock_poison_list = { + .poison_out = { + .count = cpu_to_le16(1), + }, + .record = { + /* .address encodes DPA and poison source bits */ + .address = cpu_to_le64(CXL_POISON_SOURCE_INTERNAL), + .length = cpu_to_le32(1), + }, + }; + + if (cmd->size_out < sizeof(mock_poison_list)) + return -EINVAL; + + memcpy(cmd->payload_out, &mock_poison_list, sizeof(mock_poison_list)); + cmd->size_out = sizeof(mock_poison_list); + return 0; +} + static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) { struct device *dev = cxlds->dev; @@ -234,6 +262,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd * case CXL_MBOX_OP_GET_HEALTH_INFO: rc = mock_health_info(cxlds, cmd); break; + case CXL_MBOX_OP_GET_POISON: + rc = mock_get_poison(cxlds, cmd); + break; default: break; }