From patchwork Sat Jul 23 00:55:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12927017 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A3A1CCA473 for ; Sat, 23 Jul 2022 00:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237049AbiGWA5t (ORCPT ); Fri, 22 Jul 2022 20:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237168AbiGWA5j (ORCPT ); Fri, 22 Jul 2022 20:57:39 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4AFC1989 for ; Fri, 22 Jul 2022 17:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658537759; x=1690073759; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j8uqVWeBPSXupKOtq7g+mKN1164j2dCDA74jCfUCico=; b=hx6MpC0HgKQpMSgXbAismVtDeXd9f4QdR+7cdc+IFqPKdBN5Q8HycOa5 yFZu4fWIdUH8JII/x2403UoIjPL5D/cZuXtD/pBDHer/Jmg8XLLAv9oPs FqGflLsCrchXjSAOzf59LK+BF2/x8Hx4bCgy6XaGMc70JPmBfIG90od1y 2soVxwSyMsBj1JolpJFhAMAIYvW7uzsGfjs/p5QZjNuNMeXelOAUD8El9 Nmua/sGpRiC2WT6UPw1WfxOkkGTSldQhBLiHigV683O8CBKeeGDM1Cq7K hQzLzxOlABA3vR2DOF3A8NBfvynwG4wyWDluehIrYmtH47hUqryu+PXuT Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10416"; a="351427774" X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="351427774" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:55:58 -0700 X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="626761469" Received: from jeescalx-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.116.64]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:55:58 -0700 Subject: [PATCH 1/5] cxl/acpi: Autoload driver for 'cxl_acpi' test devices From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Dave Jiang , Dave Jiang Date: Fri, 22 Jul 2022 17:55:57 -0700 Message-ID: <165853775783.2430596.13637998086505316619.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> References: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In support of CXL unit tests in the ndctl project, arrange for the cxl_acpi driver to load in response to the registration of cxl_test devices. Reported-by: Dave Jiang Tested-by: Dave Jiang Signed-off-by: Dan Williams Reviewed-by: Vishal Verma --- drivers/cxl/acpi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 64004eb672d0..eb436268b92c 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -515,12 +515,19 @@ static const struct acpi_device_id cxl_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, cxl_acpi_ids); +static const struct platform_device_id cxl_test_ids[] = { + { "cxl_acpi" }, + { }, +}; +MODULE_DEVICE_TABLE(platform, cxl_test_ids); + static struct platform_driver cxl_acpi_driver = { .probe = cxl_acpi_probe, .driver = { .name = KBUILD_MODNAME, .acpi_match_table = cxl_acpi_ids, }, + .id_table = cxl_test_ids, }; module_platform_driver(cxl_acpi_driver); From patchwork Sat Jul 23 00:56:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12927019 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC6BC433EF for ; Sat, 23 Jul 2022 00:58:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiGWA6E (ORCPT ); Fri, 22 Jul 2022 20:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236535AbiGWA5x (ORCPT ); Fri, 22 Jul 2022 20:57:53 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037C0CB746 for ; Fri, 22 Jul 2022 17:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658537778; x=1690073778; h=subject:from:to:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=ARrGLjwMqGTLAr/rNLHIODZ7DQB5maIT/SP8gAnvGbE=; b=fJVymGYp9DQKFu/aviyNQb8mpjtRHche3QNQ38Lcl2DY7V0DJwHQEWqi PTnGEHIidSL9RvxVAizpwY/i+JgDd+gxX9cEui0aahDQmIjRGYTT7otQZ 885U9okYTCwOjPRYqeqBVZttu6ZElKHfJjxuxBrRoIc86sChzUPd//1UA GilXzcWtNI2WOVRBWhDd4Nw4EK5XErwIoS4JcM9mdnhckuIVkJImgg24b bRLlWtJzQGW/OOoRgJC1EzrZK6tEwhfgefjrCsYY8SlEjcHO/RD/Yzo4o 0IjHZ5eNMVsgzDtmDmNfyg55260uFza5mYejDWUJl6AdT2rPhjR22kL1L g==; X-IronPort-AV: E=McAfee;i="6400,9594,10416"; a="286193762" X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="286193762" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:04 -0700 X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="741231914" Received: from jeescalx-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.116.64]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:03 -0700 Subject: [PATCH 2/5] cxl/region: Delete 'region' attribute from root decoders From: Dan Williams To: linux-cxl@vger.kernel.org Date: Fri, 22 Jul 2022 17:56:03 -0700 Message-ID: <165853776328.2430596.4647259305040072751.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> References: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org For switch and endpoint decoders the relationship of decoders to regions is 1:1. However, for root decoders the relationship is 1:N. Also, regions are already children of root decoders, so the 1:N relationship is observed by walking the following glob: /sys/bus/cxl/devices/$decoder/region* Hide the vestigial 'region' attribute for root decoders. Signed-off-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Vishal Verma --- drivers/cxl/core/port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 3d2d0119cc3d..bffde862de0b 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -290,7 +290,6 @@ static struct attribute *cxl_decoder_base_attrs[] = { &dev_attr_locked.attr, &dev_attr_interleave_granularity.attr, &dev_attr_interleave_ways.attr, - SET_CXL_REGION_ATTR(region) NULL, }; @@ -345,6 +344,7 @@ static const struct attribute_group *cxl_decoder_root_attribute_groups[] = { static struct attribute *cxl_decoder_switch_attrs[] = { &dev_attr_target_type.attr, &dev_attr_target_list.attr, + SET_CXL_REGION_ATTR(region) NULL, }; @@ -364,6 +364,7 @@ static struct attribute *cxl_decoder_endpoint_attrs[] = { &dev_attr_mode.attr, &dev_attr_dpa_size.attr, &dev_attr_dpa_resource.attr, + SET_CXL_REGION_ATTR(region) NULL, }; From patchwork Sat Jul 23 00:56:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12927021 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09125C43334 for ; Sat, 23 Jul 2022 00:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbiGWA6M (ORCPT ); Fri, 22 Jul 2022 20:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237000AbiGWA5q (ORCPT ); Fri, 22 Jul 2022 20:57:46 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E527C9E78 for ; Fri, 22 Jul 2022 17:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658537770; x=1690073770; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HVfFYsLsvuf6dsq6e1YjVlXLrZXGqG8HeTC5Tk3xb1M=; b=Wud42ZN1D1WRcaI77jvrrPpUP2MB91SDUAxSng0JOuiu6goPZNEWZ3TS rj5xTnwSC+bEq7tYBWnrJBZASTKLmVfzBDED5noy3miJMio1NV5RoQZNp IxPgmkUNWh2ctW0vXpYHHBNOvNQRpobQ9RtwmL71teAOcz/df2p2+j7NM +Jz9yfv10zSsAF6Uj1G6Q3r3/47WBbEiUqlFMgShjvl4qz2SlkV7kwOU2 9+4ojfjnNQjsQfrxG9HoifLJxJNhpKS+DB5Oh03YCiJhT4B651ktwzn/H TuDJLmtTDUUKhLBYGnbvMY08cwO/jUNSeKZ6MPzrVOKEjy+DPVmGvm3EZ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10416"; a="267206912" X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="267206912" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:09 -0700 X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="657415749" Received: from jeescalx-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.116.64]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:09 -0700 Subject: [PATCH 3/5] cxl/acpi: Minimize granularity for x1 interleaves From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Jonathan Cameron Date: Fri, 22 Jul 2022 17:56:09 -0700 Message-ID: <165853776917.2430596.16823264262010844458.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> References: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The kernel enforces that region granularity is >= to the top-level interleave-granularity for the given CXL window. However, when the CXL window interleave is x1, i.e. non-interleaved at the host bridge level, then the specified granularity does not matter. Override the window specified granularity to the CXL minimum so that any valid region granularity is >= to the root granularity. Reported-by: Jonathan Cameron Signed-off-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Vishal Verma --- drivers/cxl/acpi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index eb436268b92c..67137e17b8c9 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -140,6 +140,12 @@ static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg, .end = res->end, }; cxld->interleave_ways = ways; + /* + * Minimize the x1 granularity to advertise support for any + * valid region granularity + */ + if (ways == 1) + ig = 256; cxld->interleave_granularity = ig; rc = cxl_decoder_add(cxld, target_map); From patchwork Sat Jul 23 00:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12927018 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D999C43334 for ; Sat, 23 Jul 2022 00:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiGWA6D (ORCPT ); Fri, 22 Jul 2022 20:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236596AbiGWA5t (ORCPT ); Fri, 22 Jul 2022 20:57:49 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 081D1CA763 for ; Fri, 22 Jul 2022 17:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658537776; x=1690073776; h=subject:from:to:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=KsivkXgRo5zRyqP6+Ga5pUqtKe+eKKiV2yeQsKUryzs=; b=PBfnq8A1UMIE93ZubsJQny1kTDPKGxrp6mcmpVeh3Ttanfc/KNFbtwRL XdGNNtXRMXiGaoClu7iDziHTXqUlINSh9BLlccxfDdYyql2xI7Vma2zAx RfUwGJqyvXn4+1o7LrknKkZjRqUEIjiaIi8w5xvB28xCVdWfpmyDW8fS2 eX6JB/940y7uy9oapuvvVLfosicaG4j3lc+P4QKIwGe77KetmpgaHWbfe oA8NGvIa5uYQQVsYpg1QcUyyQsbVrxMMcUri5JkyDhLwf8IBnZl4RhKXg Onp2nmsTEgBgKxifGWgf3ExFrjtggh/6eeEundSnOVwG7OFTnLPBXE15Z Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10416"; a="267206914" X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="267206914" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="631750287" Received: from jeescalx-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.116.64]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:15 -0700 Subject: [PATCH 4/5] cxl/region: Stop initializing interleave granularity From: Dan Williams To: linux-cxl@vger.kernel.org Date: Fri, 22 Jul 2022 17:56:14 -0700 Message-ID: <165853777484.2430596.3423921169034844397.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> References: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org In preparation for a patch that validates that the region ways setting is compatible with the granularity setting, the initial granularity setting needs to start at zero to indicate "unset". Signed-off-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Vishal Verma --- drivers/cxl/core/region.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index df35d3c475a0..05b6212e6399 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1524,7 +1524,6 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd, enum cxl_decoder_type type) { struct cxl_port *port = to_cxl_port(cxlrd->cxlsd.cxld.dev.parent); - struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; struct cxl_region_params *p; struct cxl_region *cxlr; struct device *dev; @@ -1536,7 +1535,6 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd, p = &cxlr->params; cxlr->mode = mode; cxlr->type = type; - p->interleave_granularity = cxld->interleave_granularity; dev = &cxlr->dev; rc = dev_set_name(dev, "region%d", id); From patchwork Sat Jul 23 00:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12927020 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCFC9C433EF for ; Sat, 23 Jul 2022 00:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231772AbiGWA6H (ORCPT ); Fri, 22 Jul 2022 20:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236838AbiGWA5z (ORCPT ); Fri, 22 Jul 2022 20:57:55 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0CE5CB752 for ; Fri, 22 Jul 2022 17:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658537780; x=1690073780; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jtreZ0vyEu3MtyJw62wYNOL8iKexXJrWzcbQT/8vpY8=; b=Mmw62LI+y2C1jkRhmmXT2ogxeOAIoB9EjuqmiG/6rTqXtjdd7DX9HLDu gtloVhBwS+uuurrtVcOpPTzSAUCj1/hVRju28yI7WWp3LR1sjLqr73CTT Tc8mCLkDUogcWfIocsdMUuf9ktZInu1Bh15a/mm1nEk+5hINfOIMBM22O P/Z7BHCpCmwHG/iyfGZjR+bh+eJP5MsTKf50nNEg2IkWSmoIXgs9Go79l +s2qND3s8azTKWG8W6caEb2hv3Saf0WojpXIfKL/k15f71erKGejlEsH5 WW0z5+kdDr7N0ZV1LqN3h6MT6v12TFzLOPxL2xXWme8mFBa4OE+07H/mj A==; X-IronPort-AV: E=McAfee;i="6400,9594,10416"; a="349131613" X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="349131613" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:20 -0700 X-IronPort-AV: E=Sophos;i="5.93,186,1654585200"; d="scan'208";a="626761540" Received: from jeescalx-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.116.64]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 17:56:20 -0700 Subject: [PATCH 5/5] cxl/region: Constrain region granularity scaling factor From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Jonathan Cameron Date: Fri, 22 Jul 2022 17:56:20 -0700 Message-ID: <165853778028.2430596.7493880465382850752.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> References: <165853775181.2430596.3054032756974329979.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Consider the scenario where a platform provides for a x2 host-bridge interleave at a granularity of 256 bytes. The only permitted region granularities for that configuration are 256 or 512. Anything larger than 512 results in unmapped capacity within a given decoder. Also, if the region granularity is 512 then the interleave_ways for the region must be 4 to keep the scaling matched. Here are the translations for the first (4) 256-byte blocks where an endpoint decoder is configured for a 512-byte granularity: Block[0] => HB0 => DPA: 0 Block[1] => HB1 => DPA: 0 Block[2] => HB0 => DPA: 0 Block[3] => HB1 => DPA: 0 In order for those translations to not alias the region interleave ways must be 4 resulting in: Block[0] => HB0 => Dev0 => DPA: 0 Block[1] => HB1 => Dev1 => DPA: 0 Block[2] => HB0 => Dev2 => DPA: 0 Block[3] => HB1 => Dev3 => DPA: 0 ...not 2, resulting in: Block[0] => HB0 => Dev0 => DPA: 0 Block[1] => HB1 => Dev1 => DPA: 0 Block[2] => HB0 => Dev0 => DPA: 0 ! Block[3] => HB1 => Dev1 => DPA: 0 ! Given tooling is already being built around this ABI allow for granularity and ways to be set in either order and validate the combination once both are set. Reported-by: Jonathan Cameron Signed-off-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Vishal Verma --- drivers/cxl/core/region.c | 63 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 05b6212e6399..a34e537e4cb2 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -348,6 +348,25 @@ static ssize_t interleave_ways_store(struct device *dev, goto out; } + /* + * If region granularity has been set and xHB interleave is active, + * validate that granularity is compatible with specified ways. + * Otherwise allow ways to be set now and depend on + * interleave_granularity_store() to validate this constraint. + */ + if (cxld->interleave_ways > 1 && + p->interleave_granularity > cxld->interleave_granularity && + p->interleave_granularity / cxld->interleave_granularity != + val / cxld->interleave_ways) { + dev_dbg(dev, + "ways scaling factor %d mismatch with granularity %d\n", + val / cxld->interleave_ways, + p->interleave_granularity / + cxld->interleave_granularity); + rc = -EINVAL; + goto out; + } + save = p->interleave_ways; p->interleave_ways = val; rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group()); @@ -386,7 +405,7 @@ static ssize_t interleave_granularity_store(struct device *dev, struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; struct cxl_region *cxlr = to_cxl_region(dev); struct cxl_region_params *p = &cxlr->params; - int rc, val; + int rc, val, ways; u16 ig; rc = kstrtoint(buf, 0, &val); @@ -403,9 +422,29 @@ static ssize_t interleave_granularity_store(struct device *dev, * granularity less than the root interleave result in needing * multiple endpoints to support a single slot in the * interleave. + * + * When the root interleave ways is 1 then the root granularity is a + * don't care. + * + * Limit region granularity to cxld->interleave_granularity * + * rounddown_pow_of_two(cxld->interleave_ways) otherwise holes result in + * the decode at each endpoint. Note that rounddown_pow_of_two() + * accounts for x3, x6, and x9 root intereleave. */ - if (val < cxld->interleave_granularity) - return -EINVAL; + ways = rounddown_pow_of_two(cxld->interleave_ways); + if (ways > 1) { + if (val < cxld->interleave_granularity) { + dev_dbg(dev, "granularity %d must be >= %d\n", val, + cxld->interleave_granularity); + return -EINVAL; + } + + if (val > cxld->interleave_granularity * ways) { + dev_dbg(dev, "granularity %d must be <= %d\n", val, + cxld->interleave_granularity * ways); + return -EINVAL; + } + } rc = down_write_killable(&cxl_region_rwsem); if (rc) @@ -415,6 +454,24 @@ static ssize_t interleave_granularity_store(struct device *dev, goto out; } + /* + * If region ways has been set and xHB interleave is active, validate + * that ways is compatible with specified granularity. Otherwise allow + * granularity to be set now and depend on interleave_ways_store() to + * validate this constraint. + */ + if (cxld->interleave_ways > 1 && p->interleave_ways && + val > cxld->interleave_granularity && + p->interleave_ways / cxld->interleave_ways != + val / cxld->interleave_granularity) { + dev_dbg(dev, + "granularity scaling factor %d mismatch with ways %d\n", + val / cxld->interleave_granularity, + p->interleave_ways / cxld->interleave_ways); + rc = -EINVAL; + goto out; + } + p->interleave_granularity = val; out: up_write(&cxl_region_rwsem);