Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp7018155rwb; Wed, 18 Jan 2023 12:20:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtSMROh86BpKZEFunZn/KfwyQkMB+1Lq++IJo/4XuD4y3ypJdOcuYNtAgT3t3Di1NLrlnu9 X-Received: by 2002:a17:907:1c07:b0:86f:2819:2760 with SMTP id nc7-20020a1709071c0700b0086f28192760mr19456434ejc.41.1674073218117; Wed, 18 Jan 2023 12:20:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674073218; cv=none; d=google.com; s=arc-20160816; b=fGvHmT6LpVyWhPYFdvZinm8yoyNLLVoYgFod7X9qzmQmnLWJDe/xmamOHfYJmse2wE GOPErocIE2t8UX056DMvoNkkv7ZiCCcTjD7al1sa7muicKpRHYzGUxJlIC4hC8Lgt3Jb +v0zO/Qb1foWAKAYjOJFiMMWPiiwHEgfl5KkU3Fx+jIxIInfI4vuLY9C2Oea7muX88A0 2uH5mL5fes2I5cNlY7CGAnxs0m0UB9UV38Neb/aoozUGkGc/7EpfzSLmZxxBCfcYrqiP oYZCWOVxNcG2ZMlayl1eXj5RPs4t2Ylnm+zukCEH5ops97suPHym7AGt5cJW2TDJWF2R ePCw== 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=WCml+nrry4E2LVzNJ/Kk84JvLXWOZk5fTQpeUy1x3hE=; b=gLzNlqnOH2/i378gGGOVx8E9k6LWycWhffMH085SN4kdz8pgW9HwSpFJR8QTBOnqUF 6ZYOx3PRbqD43Hl+7xO08HP7Iw0F5njq/L3ln2t2cMeuZUelzj393XK5AmJU9xlAmo/4 pg+ZUOXdybkA5Hw2iEyMzi488PpeW9NESSCd2QdNkO1SOnydfzxtZFMSFzvEc8cfY/hu 2Gx5QxKF3RkFfWJRrMYrWfzMWCtLbyQ/4EGjC+rPbfrEZXwlA1eRQpoGzWEiIOIqze5T h13mk303WMJ48d2TklXlAIHN/g1ZqqdguUUXiEPxJejoYrSYJ+TI0ot7cQ/knrwi5iL5 ZKtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YNLxLFfo; 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 b17-20020aa7cd11000000b0049d27c79ecfsi16737169edw.415.2023.01.18.12.20.07; Wed, 18 Jan 2023 12:20:18 -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=YNLxLFfo; 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 S229843AbjARUCk (ORCPT + 45 others); Wed, 18 Jan 2023 15:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbjARUCd (ORCPT ); Wed, 18 Jan 2023 15:02:33 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF8B58289; Wed, 18 Jan 2023 12:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674072151; x=1705608151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jpLlAKswEh4UuzLPlTUcyeFewdXnALel5wXlbYz+UJM=; b=YNLxLFfoVqzkFJ39a9c+YXBjR5BsPC7J8cxkZT3Wf/rzdt0fobokle5N n/xnTvDYPILyBCpOd35/Bfh9ZdSOm+NvcAEmZzWdxhAFUPX2Yv/osAhtb LTkf14kN3OBobrHZSHc45JS7RMVvxS+JCWIaVCl34vwppkqaYIEn2Dbzj Y1QNHpAvLuWpf+MR3wJoriJC0g8d+WvpE3j+G1O45Euj8yj2ajZ2BnAJY 6nHdxm+vAprO3rXjyNIMKufOxQZU8DMGC03EaSFaONuA1DAH7Bhr9Uzg5 fT8zcyTzgzYKbrQzMqcGQ9nw1E4l71OtUko0pnwNN9sJYKODsV2YAMUWJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322776788" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="322776788" 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:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="661861690" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="661861690" 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:28 -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 3/5] cxl/memdev: Add trigger_poison_list sysfs attribute Date: Wed, 18 Jan 2023 12:02:19 -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 When a boolean 'true' is written to this attribute the memdev driver retrieves the poison list from the device. The list consists of addresses that are poisoned, or would result in poison if accessed, and the source of the poison. This attribute is only visible for devices supporting the capability. The retrieved errors are logged as kernel trace events with the label 'cxl_poison'. Reviewed-by: Jonathan Cameron Signed-off-by: Alison Schofield --- Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++++++ drivers/cxl/core/memdev.c | 45 +++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl index 8494ef27e8d2..df40ed09ea67 100644 --- a/Documentation/ABI/testing/sysfs-bus-cxl +++ b/Documentation/ABI/testing/sysfs-bus-cxl @@ -388,3 +388,17 @@ Description: 1), and checks that the hardware accepts the commit request. Reading this value indicates whether the region is committed or not. + + +What: /sys/bus/cxl/devices/memX/trigger_poison_list +Date: November, 2022 +KernelVersion: v6.2 +Contact: linux-cxl@vger.kernel.org +Description: + (WO) When a boolean 'true' is written to this attribute the + memdev driver retrieves the poison list from the device. The + list consists of addresses that are poisoned, or would result + in poison if accessed, and the source of the poison. This + attribute is only visible for devices supporting the + capability. The retrieved errors are logged as kernel + trace events with the label 'cxl_poison'. diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index a74a93310d26..e0af7e9c9989 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -106,12 +106,49 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(numa_node); +static ssize_t trigger_poison_list_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct cxl_memdev *cxlmd = to_cxl_memdev(dev); + struct cxl_dev_state *cxlds = cxlmd->cxlds; + u64 offset, length; + bool tmp; + int rc; + + if (kstrtobool(buf, &tmp)) + return -EINVAL; + + /* CXL 3.0 Spec 8.2.9.8.4.1 Separate pmem and ram poison requests */ + if (resource_size(&cxlds->pmem_res)) { + offset = cxlds->pmem_res.start; + length = resource_size(&cxlds->pmem_res); + rc = cxl_mem_get_poison(cxlmd, offset, length, NULL); + if (rc) + return rc; + } + if (resource_size(&cxlds->ram_res)) { + offset = cxlds->ram_res.start; + length = resource_size(&cxlds->ram_res); + rc = cxl_mem_get_poison(cxlmd, offset, length, NULL); + /* + * Invalid Physical Address is not an error for + * volatile addresses. Device support is optional. + */ + if (rc && rc != -EFAULT) + return rc; + } + return len; +} +static DEVICE_ATTR_WO(trigger_poison_list); + static struct attribute *cxl_memdev_attributes[] = { &dev_attr_serial.attr, &dev_attr_firmware_version.attr, &dev_attr_payload_max.attr, &dev_attr_label_storage_size.attr, &dev_attr_numa_node.attr, + &dev_attr_trigger_poison_list.attr, NULL, }; @@ -130,6 +167,14 @@ static umode_t cxl_memdev_visible(struct kobject *kobj, struct attribute *a, { if (!IS_ENABLED(CONFIG_NUMA) && a == &dev_attr_numa_node.attr) return 0; + + if (a == &dev_attr_trigger_poison_list.attr) { + struct device *dev = kobj_to_dev(kobj); + + if (!test_bit(CXL_MEM_COMMAND_ID_GET_POISON, + to_cxl_memdev(dev)->cxlds->enabled_cmds)) + return 0; + } return a->mode; } diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index f53fae20f502..28ba0cd8f2d3 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -139,7 +139,7 @@ struct cxl_mbox_cmd { C(FWROLLBACK, -ENXIO, "rolled back to the previous active FW"), \ C(FWRESET, -ENXIO, "FW failed to activate, needs cold reset"), \ C(HANDLE, -ENXIO, "one or more Event Record Handles were invalid"), \ - C(PADDR, -ENXIO, "physical address specified is invalid"), \ + C(PADDR, -EFAULT, "physical address specified is invalid"), \ C(POISONLMT, -ENXIO, "poison injection limit has been reached"), \ C(MEDIAFAILURE, -ENXIO, "permanent issue with the media"), \ C(ABORT, -ENXIO, "background cmd was aborted by device"), \ -- 2.37.3