From patchwork Mon Feb 6 01:02:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 13129227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22CC1C636CD for ; Mon, 6 Feb 2023 01:02:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C00EB6B0078; Sun, 5 Feb 2023 20:02:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB0E86B007B; Sun, 5 Feb 2023 20:02:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A796D6B007D; Sun, 5 Feb 2023 20:02:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 99AE96B0078 for ; Sun, 5 Feb 2023 20:02:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 71BF91A03FE for ; Mon, 6 Feb 2023 01:02:43 +0000 (UTC) X-FDA: 80435067006.13.CF7C188 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf24.hostedemail.com (Postfix) with ESMTP id 59DD0180002 for ; Mon, 6 Feb 2023 01:02:41 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="JBq5/8tj"; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675645361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1+dl7gdU5BIw/whwSe9Fk7DKYVHBtFbRO6x5tt6HwSw=; b=eBMLkeU8kQZHEMQzgJloIOP18LuSKw/3OkUoiv6UDWsGtciXvOgDtFIn1JlJcqlNHCCF88 fsJTvqHIodpufSKsrAHU9yITVifvzqC7jL1AdHYvLFDsik5k5/VPeM5yFnHpILdsj0pbMQ tvlFqxPyJTDI4RIW1Hgc51lUdMiBs+c= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="JBq5/8tj"; spf=pass (imf24.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675645361; a=rsa-sha256; cv=none; b=hcEJbqhbuLe111VgIOh1D0lOyOUCHnNY2epx1Wv/b0r+7zPqwH2JT3tjII1l7d2K2KChdi 7c8ASMZT+iAdUmTh2VZ00ifEu+N7vzHh5PIj6ApWdnHqlBGR4Q+X9KSvdEApFCde7sfiO8 vnW00SzXWDwl4uKc47ycxoCrHCAD/+8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675645361; x=1707181361; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UOKI+/A98jKePPsZHuytj7Ccuyq4WgZ+jxkAtz+DXQ4=; b=JBq5/8tjjChrlSIbXtpzVmElLFRJbt4qZKfb8xkCnrhAN51PLeBfh7Gu 1BgG10LCNGDvEtwjZPdFaMsbk1euVlUZlwjo0RNz4QKHgQR68jMY1FcvW 9GtjYhal95kUFr42WM0sjKU1z3rK0OIUmw/VV2k3XYFlsZ+qTO1XrRx+x PFGOUSDRLWkDPeAwoES1EAp08ZTN9MLYMleqpqXIu+OyNjApidWZWXkm6 OKdk0rEACHO38vXFuwIwMSklmK1b0HAYksJn3Mh3Dnj9qQcsiQEF/TqWO z+ev0j4zrORXdVfoDKIGhhULlZZV5GUQ2fJvPS6l2dy5AVd1kJmAN2O5C w==; X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="331243786" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="331243786" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 17:02:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="643855730" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="643855730" Received: from mkrysak-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.212.255.187]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 17:02:40 -0800 Subject: [PATCH 02/18] cxl/region: Add a mode attribute for regions From: Dan Williams To: linux-cxl@vger.kernel.org Cc: dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-acpi@vger.kernel.org Date: Sun, 05 Feb 2023 17:02:40 -0800 Message-ID: <167564536041.847146.11330354943211409793.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <167564534874.847146.5222419648551436750.stgit@dwillia2-xfh.jf.intel.com> References: <167564534874.847146.5222419648551436750.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 59DD0180002 X-Stat-Signature: poesurmdm7waru5at49og1e7wr5airnt X-Rspam-User: X-HE-Tag: 1675645361-756393 X-HE-Meta: U2FsdGVkX1+g4iac/r0No74yhNHzGUVDCA7NyZ4laCI9+luMYbt3XXz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t6HIf1WsM3QWTWDVM/rc/A+wPBhk/GBkCteR2pye1LYMRXRquNbtWzTB2mo3rNlSczIo/mQeeq1L/syjrw2qnN6Cbb4q8AOeBn5Hj3+r3gciy72AGAXMtGk7VnpnV+jh5+Oa5+9Lqng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation for a new region type, "ram" regions, add a mode attribute to clarify the mode of the decoders that can be added to a region. Share the internals of mode_show() (for decoders) with the region case. Signed-off-by: Dan Williams Reviewed-by: Jonathan Cameron Reviewed-by: Gregory Price Reviewed-by: Ira Weiny Reviewed-by: Dave Jiang Reviewed-by: Vishal Verma --- Documentation/ABI/testing/sysfs-bus-cxl | 11 +++++++++++ drivers/cxl/core/port.c | 12 +----------- drivers/cxl/core/region.c | 10 ++++++++++ drivers/cxl/cxl.h | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl index 5be032313e29..058b0c45001f 100644 --- a/Documentation/ABI/testing/sysfs-bus-cxl +++ b/Documentation/ABI/testing/sysfs-bus-cxl @@ -358,6 +358,17 @@ Description: results in the same address being allocated. +What: /sys/bus/cxl/devices/regionZ/mode +Date: January, 2023 +KernelVersion: v6.3 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) The mode of a region is established at region creation time + and dictates the mode of the endpoint decoder that comprise the + region. For more details on the possible modes see + /sys/bus/cxl/devices/decoderX.Y/mode + + What: /sys/bus/cxl/devices/regionZ/resource Date: May, 2022 KernelVersion: v6.0 diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 410c036c09fa..8566451cb22f 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -180,17 +180,7 @@ static ssize_t mode_show(struct device *dev, struct device_attribute *attr, { struct cxl_endpoint_decoder *cxled = to_cxl_endpoint_decoder(dev); - switch (cxled->mode) { - case CXL_DECODER_RAM: - return sysfs_emit(buf, "ram\n"); - case CXL_DECODER_PMEM: - return sysfs_emit(buf, "pmem\n"); - case CXL_DECODER_NONE: - return sysfs_emit(buf, "none\n"); - case CXL_DECODER_MIXED: - default: - return sysfs_emit(buf, "mixed\n"); - } + return sysfs_emit(buf, "%s\n", cxl_decoder_mode_name(cxled->mode)); } static ssize_t mode_store(struct device *dev, struct device_attribute *attr, diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 60828d01972a..17d2d0c12725 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -458,6 +458,15 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(resource); +static ssize_t mode_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct cxl_region *cxlr = to_cxl_region(dev); + + return sysfs_emit(buf, "%s\n", cxl_decoder_mode_name(cxlr->mode)); +} +static DEVICE_ATTR_RO(mode); + static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) { struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent); @@ -585,6 +594,7 @@ static struct attribute *cxl_region_attrs[] = { &dev_attr_interleave_granularity.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_mode.attr, NULL, }; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index aa3af3bb73b2..ca76879af1de 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -320,6 +320,20 @@ enum cxl_decoder_mode { CXL_DECODER_DEAD, }; +static inline const char *cxl_decoder_mode_name(enum cxl_decoder_mode mode) +{ + static const char * const names[] = { + [CXL_DECODER_NONE] = "none", + [CXL_DECODER_RAM] = "ram", + [CXL_DECODER_PMEM] = "pmem", + [CXL_DECODER_MIXED] = "mixed", + }; + + if (mode >= CXL_DECODER_NONE && mode <= CXL_DECODER_MIXED) + return names[mode]; + return "mixed"; +} + /** * struct cxl_endpoint_decoder - Endpoint / SPA to DPA decoder * @cxld: base cxl_decoder_object