From patchwork Fri Feb 10 09:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 13135550 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 8BCF6C636CD for ; Fri, 10 Feb 2023 09:05:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E04116B0118; Fri, 10 Feb 2023 04:05:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB59E6B011A; Fri, 10 Feb 2023 04:05:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7C426B011B; Fri, 10 Feb 2023 04:05:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9F5DA6B0118 for ; Fri, 10 Feb 2023 04:05:45 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54D48A1363 for ; Fri, 10 Feb 2023 09:05:45 +0000 (UTC) X-FDA: 80450799450.29.1F22449 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf15.hostedemail.com (Postfix) with ESMTP id 11C36A0016 for ; Fri, 10 Feb 2023 09:05:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=GthjjzCw; spf=pass (imf15.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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=1676019943; 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=zMQUl4J6X7ULaIrRgxt3l1Taiz3cx+Xhc0qmS3HTx30=; b=iSNJh3GKpLGuW173gQ6Z0CJD5gqiH7KjWbwcxYP7haDq5kR1LDqY05mmOCuCudu90F1z3v oizfE8oeb6OoTyoCJcbGZmtJXzcMR1aUGFw6q48IP22h3XwdDzMrccbTD69QOhYQGGJYu0 InayJeOdGF2TCJD+HU/4TKFvNFy/9Vk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=GthjjzCw; spf=pass (imf15.hostedemail.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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=1676019943; a=rsa-sha256; cv=none; b=Om6oylTqFPpxk8i2ao+8i9AKU1QrO/PTJcWcT1h4k5ePYZA62jyDw4GKQZARXwuQ2wS4IB OpIdICFluW0TEm6/V4s8spfXcet8PcE5B3YGM9x+7AQDrIiaanCe39f7dT2h3WA708G1Rt nX3J0EcnKJWKnSgS9E/YrhjXMm2f4s4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676019943; x=1707555943; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3cQC8uwKOt3b1h6vNcSkmE8AzC7Sg9UhcvwbHDHzsBA=; b=GthjjzCwOi7uG3kETx0bPYCBAtGeC5W3+34do27cxP9cTAKM45YtHTht /C4OircWRoJnikFyxQRUeqv0vXUdWpQlUPBK/S5QwUdjZRBTj5j1ysPQr E9BpSSsFVWXy+C9nrmlQwkHD/xIwmJsRHmnOO+l8GYPwiJFi68kK7JA8E MW8AavKI4k54QXKUBqqCkbD3uDS/nDNvMFP++Qk+mfd4ouFTQ8aRNV/NA 8KNdwh9REjB2fxj+SBAX3wUpaWjOORpfm/xfOxbxJeqTD/+7Qu1KLSRgJ 2/cFRI5t1pYJnC3wOV9tRJSPwlv9QE+Q3oXnoDel6CEocnQ0fYj/3ollR w==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="416599983" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="416599983" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 01:05:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="669930135" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="669930135" Received: from hrchavan-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.46.42]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 01:05:39 -0800 Subject: [PATCH v2 03/20] cxl/region: Add a mode attribute for regions From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Vishal Verma , Dave Jiang , Gregory Price , Ira Weiny , Jonathan Cameron , Fan Ni , dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-acpi@vger.kernel.org Date: Fri, 10 Feb 2023 01:05:39 -0800 Message-ID: <167601993930.1924368.4305018565539515665.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <167601992097.1924368.18291887895351917895.stgit@dwillia2-xfh.jf.intel.com> References: <167601992097.1924368.18291887895351917895.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: 11C36A0016 X-Stat-Signature: dwnb4fmes9wyxzfisa6xo89h7yxt4qir X-Rspam-User: X-HE-Tag: 1676019942-138262 X-HE-Me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vWHOVfuzHgYvklG8y5KBf3qlqMA8fDANS9AalMcd7XtsiCG0ZziDB2dB/kxaUDTCt8PV6P35xuzOrzVu9qbny+pk4/IpfRGyfX1wsmyj1klZDMcKLlgo+zOie9OkbH+kMJ13EHQLWuAbomXhUrlsmOjaufEe+1ZGREwfQ2l1WiR2pDc2qsTog98dRc9g4UW5eVnfr3ut9+ysZ9d7yT5G6vhtHwd7JbONuk5uyZrX4TQJEI0/E+tk73IkPR0qIx5OS20KtgJokK275y1iRxnCz+JYuoYg== 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. Reviewed-by: Vishal Verma Reviewed-by: Dave Jiang Reviewed-by: Gregory Price Reviewed-by: Ira Weiny Reviewed-by: Jonathan Cameron Tested-by: Fan Ni Link: https://lore.kernel.org/r/167564536041.847146.11330354943211409793.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams --- 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 317bcf4dbd9d..1e541956f605 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