Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp24773iog; Tue, 14 Jun 2022 18:01:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slw4rPrPWaxx4IEQEWEaPEHpA9Mia6Q7tof93cMpZ4A8BrPeLZVEZat88F0uBpZEgOFHvq X-Received: by 2002:a17:906:728a:b0:715:2fb5:19f9 with SMTP id b10-20020a170906728a00b007152fb519f9mr6663562ejl.170.1655254863682; Tue, 14 Jun 2022 18:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655254863; cv=none; d=google.com; s=arc-20160816; b=MH1llZBxmdeVR/rSfCjm1pSjeTDlRagsnQJky1ycamcwJ9a/cqsNUTzUs0U/WxT8gj Fws34BKi7JlMqmyCK0EkU4X5IiTnQxTNrxbDwKu20Pt+CDUq9+vHbeDkum2Sx90bmbBC wC87airfKk8s/awIvFjBGxXKfoNk2IaTaAhXeoFno/BGBX68vKKfWDU6FVsnDHTiQCRM pN6Urd+vlT91z6ET5mvSBQq7zg6DSVq/fQPT/bn4gYekOIiyBOkRFxZykfx0GYrJ5dsu hQjVk9XnZuD+JnSg3hnhCN7lLgkbDuYla1Bqq0fKZrBjXP/xkcQy96mM6CU9NoIpyhtR wLuA== 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=bD0Xr6PtCCOkKLv3C6+nOwkjpTzitBlScwZ7sAP0kxk=; b=Hvxq80agucqwb3wV5rN0cjAHRv6qR2o15p+LEwotMH7ElJDBf8UVoHkKPygKsZHcXu ZvEzRyM6DcLgLrANM8a9+FrourAjh0gLYJIDrz40s6OoFj3B8XTCPMq03z9vj4RN4/V+ IRbi8dEFptfsWMcQy5ghSzU39Yn9XNlcK1Qz4c6GfDNB0hzbcGJDUZ5S0Rpn2SCa6HYv 4sGg9GR8WhDpgK+dhYbZeZlNAIluAQHogztKNpG4xvut8qLKxK+FEJJeMOPAg1xw7gF3 fYhHRoahUiOwoiRlRhM77aqX80UT+OrKmMqhgiDPkcfj8+zC8/VpbDqlII0efX6tYht9 2yAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WfuUk4Eh; 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 b18-20020a0564021f1200b0042b0a1bfd4esi12768055edb.343.2022.06.14.18.00.38; Tue, 14 Jun 2022 18:01:03 -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=WfuUk4Eh; 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 S236887AbiFOALH (ORCPT + 99 others); Tue, 14 Jun 2022 20:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231530AbiFOAKz (ORCPT ); Tue, 14 Jun 2022 20:10:55 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2065736176; Tue, 14 Jun 2022 17:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655251854; x=1686787854; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rmwqOoory/BhG+mzzDYl/irO2wGnfPfD8xSW1RR8boc=; b=WfuUk4EhdSwZLQ7jdTQiG9I/IPtcn81sX09oqnTKKYgH5jkMWEICy4y+ xxLT3wEp6s4zwYWTolnviBRJx2y0PNDJmvQ9y2LqlwaRDKQKwoDaw+PyX O5bNDkpGJ1+CqZvfMTEWnn57Re3CCy8dse+yPA2pkKCParg3KWp999MAh GV3l2eAa2ty3wVZKFa53iuN/GAic+A5z/T5onO3mS112Py96/uauoD/EC v7HO412OvWP3Cw5G48pSLlWnDfNOD2Ix2j7wVecrL/RNhTlCViVub7FPF MQPW7qC4lKzDm8bSc+9tfiUPSyzoRWsqJf2BNRhQnpMs+IhkgYqD4Js92 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="278825457" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="278825457" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 17:10:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="640662914" Received: from alison-desk.jf.intel.com (HELO localhost) ([10.54.74.41]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 17:10:53 -0700 From: alison.schofield@intel.com To: Dan Williams , Ira Weiny , Vishal Verma , Ben Widawsky , Steven Rostedt , Ingo Molnar Cc: Alison Schofield , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] cxl/core: Add sysfs attribute get_poison for list retrieval Date: Tue, 14 Jun 2022 17:10:28 -0700 Message-Id: <57644934bb7af8e1c692735f53c2c415a1ba16d1.1655250669.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 The sysfs attribute, get_poison, allows user space to request the retrieval of a CXL devices poison list for its persistent memory. From Documentation/ABI/.../sysfs-bus-cxl (WO) When a '1' is written to this attribute the memdev driver retrieves the poison list from the device. The list includes 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_list. Signed-off-by: Alison Schofield --- Documentation/ABI/testing/sysfs-bus-cxl | 13 ++++++++++ drivers/cxl/core/memdev.c | 32 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl index 7c2b846521f3..9d0c3988fdd2 100644 --- a/Documentation/ABI/testing/sysfs-bus-cxl +++ b/Documentation/ABI/testing/sysfs-bus-cxl @@ -163,3 +163,16 @@ Description: memory (type-3). The 'target_type' attribute indicates the current setting which may dynamically change based on what memory regions are activated in this decode hierarchy. + +What: /sys/bus/cxl/devices/memX/get_poison +Date: June, 2022 +KernelVersion: v5.20 +Contact: linux-cxl@vger.kernel.org +Description: + (WO) When a '1' is written to this attribute the memdev + driver retrieves the poison list from the device. The list + includes 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_list. diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index f7cdcd33504a..5ef9ffaa934a 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -106,12 +106,34 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(numa_node); +static ssize_t get_poison_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) + +{ + int rc; + + if (!sysfs_streq(buf, "1")) { + dev_err(dev, "%s: unknown value: %s\n", attr->attr.name, buf); + return -EINVAL; + } + + rc = cxl_mem_get_poison_list(dev); + if (rc) { + dev_err(dev, "Failed to retrieve poison list %d\n", rc); + return rc; + } + return len; +} +static DEVICE_ATTR_WO(get_poison); + 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_get_poison.attr, NULL, }; @@ -130,6 +152,16 @@ 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_get_poison.attr) { + struct device *dev = container_of(kobj, struct device, kobj); + struct cxl_memdev *cxlmd = to_cxl_memdev(dev); + struct cxl_dev_state *cxlds = cxlmd->cxlds; + + if (!test_bit(CXL_MEM_COMMAND_ID_GET_POISON, + cxlds->enabled_cmds)) + return 0; + } return a->mode; } -- 2.31.1