Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp593033pxj; Fri, 7 May 2021 15:53:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDUBVslvMFr24oyE3Cn6uLCWpRPQzsWkm5pyAFBkTR+fXZg3rcwUpm5J0skL2vnrpybaEx X-Received: by 2002:a17:902:8685:b029:e6:5ff6:f7df with SMTP id g5-20020a1709028685b02900e65ff6f7dfmr12243373plo.40.1620428036112; Fri, 07 May 2021 15:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620428036; cv=none; d=google.com; s=arc-20160816; b=wveLJDLNhXU5yVcPmdhGq/9JX9xhPlDXFSqlo4cieX/ont+cEmpGYCmF2fbl7rTMY6 ydltH49jwhOl+SP8axWgQnu+SWF9b0qB0nTzcorsX0g5jpaMQLtlYCuRAf8T1sr8/jRo dAHgfYJ72casadWO5RC0eyu3M/+Jwz0Cfh3/wKTkSCkIB3v+KUoyYoWncVDWtfuB5xtU y2nHj+3zBtsKUdz7XKrs8lKQ73Nn8gSmopqwNlCIGtjDJGpKlaO6f3z+/n4CtYXLwhH8 4htjlYiFrEb44Zkm6FbmX0jgYKObjPu10aYQBfRTWregr4IVd4ZlvVWI8F7We5yZ9L0C ql7A== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=q2cZW7VJ6uA3WNjWNQUJZwcHAhjPNCtI0Yq19Lbgsqw=; b=LVTBtbngGZI+IfUnKGdGlnl184jfJK8+R6gOhr38v3gfF/Wdj8uSbz9dWSjU+PGS50 Ewy5XNStAIs4DJm3H3WlzrPwag4F2apSAYHXdgWlA8fjo7VFyfZW6WuHCNMvJptmaZEA WWIlwGut+cQcTdxHpY6f/iLdilwm8NxSMbhdWq30gOj8gZrajQqGynKF9eEaiXEZZ0ya 3GCTzc8WVPrXoVkME4YkCN1cdrPKI+LkCveAbgg9m8J+xHyTBPISDwM8AivmEKKdLNPB aQabrEaJRHS1kRSOeW/wRZtaVJ1oc9KOPwnQjEVnz8izMYhJXIX3SIQGCsvrf/GpvBXW uTig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si8529063pgo.3.2021.05.07.15.53.44; Fri, 07 May 2021 15:53:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbhEGWxG (ORCPT + 99 others); Fri, 7 May 2021 18:53:06 -0400 Received: from mga05.intel.com ([192.55.52.43]:33183 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbhEGWxE (ORCPT ); Fri, 7 May 2021 18:53:04 -0400 IronPort-SDR: 7RDnDXHSQcdh0tofuQsEkU/IN5kxPnej1jCVYWxv0/RDTWo/Jf6A+YpwMDaY8wSwM24eT/1G8Q mYZBmyjBLaHw== X-IronPort-AV: E=McAfee;i="6200,9189,9977"; a="284290023" X-IronPort-AV: E=Sophos;i="5.82,282,1613462400"; d="scan'208";a="284290023" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2021 15:52:04 -0700 IronPort-SDR: FeJlpeY3CRjRO5ViQBB6nJ6Cd1Q2PdnSs3BBGVDNM0nOq006Aw8R3EpHvIiX9aRpl2zFD4+Nrl vRd4ZPVTICBg== X-IronPort-AV: E=Sophos;i="5.82,282,1613462400"; d="scan'208";a="459953572" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2021 15:52:04 -0700 Subject: [PATCH 8/8] cxl/acpi: Add module parameters to stand in for ACPI tables From: Dan Williams To: linux-cxl@vger.kernel.org Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Date: Fri, 07 May 2021 15:52:03 -0700 Message-ID: <162042792370.1202325.11876776878497740843.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <162042787450.1202325.5718541949681409566.stgit@dwillia2-desk3.amr.corp.intel.com> References: <162042787450.1202325.5718541949681409566.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [debug / to-be-replaced / not-for-upstream] Given ACPICA support is needed before drivers can integrate ACPI functionality add some module parameters as proxies. --- drivers/cxl/acpi.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index bc2a35ae880b..2a48a728f3e0 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -4,10 +4,84 @@ #include #include #include +#include #include #include #include "cxl.h" +/* + * TODO: Replace all of the below module parameters with ACPI CXL + * resource descriptions once ACPICA makes them available. + */ +static unsigned long chbcr[4]; +module_param_named(chbcr0, chbcr[0], ulong, 0400); +module_param_named(chbcr1, chbcr[1], ulong, 0400); +module_param_named(chbcr2, chbcr[2], ulong, 0400); +module_param_named(chbcr3, chbcr[3], ulong, 0400); + +/* TODO: cross-bridge interleave */ +static struct cxl_address_space cxl_space[] = { + [0] = { .range = { 0, -1 }, .targets = 0x1, }, + [1] = { .range = { 0, -1 }, .targets = 0x1, }, + [2] = { .range = { 0, -1 }, .targets = 0x1, }, + [3] = { .range = { 0, -1 }, .targets = 0x1, }, +}; + +static int set_range(const char *val, const struct kernel_param *kp) +{ + unsigned long long size, base; + struct cxl_address_space *space; + unsigned long flags; + char *p; + int rc; + + size = memparse(val, &p); + if (*p != '@') + return -EINVAL; + + base = memparse(p + 1, &p); + if (*p != ':') + return -EINVAL; + + rc = kstrtoul(p + 1, 0, &flags); + if (rc) + return rc; + if (!flags || flags > CXL_ADDRSPACE_MASK) + return rc; + + space = kp->arg; + *space = (struct cxl_address_space) { + .range = { + .start = base, + .end = base + size - 1, + }, + .flags = flags, + }; + + return 0; +} + +static int get_range(char *buf, const struct kernel_param *kp) +{ + struct cxl_address_space *space = kp->arg; + + if (!range_len(&space->range)) + return -EINVAL; + + return sysfs_emit(buf, "%#llx@%#llx :%s%s%s%s\n", + (unsigned long long)range_len(&space->range), + (unsigned long long)space->range.start, + space->flags & CXL_ADDRSPACE_RAM ? " ram" : "", + space->flags & CXL_ADDRSPACE_PMEM ? " pmem" : "", + space->flags & CXL_ADDRSPACE_TYPE2 ? " type2" : "", + space->flags & CXL_ADDRSPACE_TYPE3 ? " type3" : ""); +} + +module_param_call(range0, set_range, get_range, &cxl_space[0], 0400); +module_param_call(range1, set_range, get_range, &cxl_space[1], 0400); +module_param_call(range2, set_range, get_range, &cxl_space[2], 0400); +module_param_call(range3, set_range, get_range, &cxl_space[3], 0400); + static int match_ACPI0016(struct device *dev, const void *host) { struct acpi_device *adev = to_acpi_device(dev); @@ -67,13 +141,16 @@ static int cxl_acpi_register_ports(struct device *dev, struct acpi_device *root, struct cxl_port *port, int idx) { struct acpi_pci_root *pci_root = acpi_pci_find_root(root->handle); + resource_size_t chbcr_base = ~0ULL; struct cxl_walk_context ctx; if (!pci_root) return -ENXIO; /* TODO: fold in CEDT.CHBS retrieval */ - port = devm_cxl_add_port(dev, port, &root->dev, idx, ~0ULL); + if (idx < ARRAY_SIZE(chbcr)) + chbcr_base = chbcr[idx]; + port = devm_cxl_add_port(dev, port, &root->dev, idx, chbcr_base); if (IS_ERR(port)) return PTR_ERR(port); dev_dbg(dev, "%s: register: %s\n", dev_name(&root->dev), @@ -99,7 +176,7 @@ static int cxl_acpi_probe(struct platform_device *pdev) struct cxl_root *cxl_root; int rc, i = 0; - cxl_root = devm_cxl_add_root(dev, NULL, 0); + cxl_root = devm_cxl_add_root(dev, cxl_space, ARRAY_SIZE(cxl_space)); if (IS_ERR(cxl_root)) return PTR_ERR(cxl_root); dev_dbg(dev, "register: %s\n", dev_name(&cxl_root->port.dev));