From patchwork Wed Aug 3 07:24:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12935233 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 9F2D0C19F28 for ; Wed, 3 Aug 2022 07:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbiHCHY0 (ORCPT ); Wed, 3 Aug 2022 03:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiHCHYZ (ORCPT ); Wed, 3 Aug 2022 03:24:25 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E971CFF8 for ; Wed, 3 Aug 2022 00:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659511464; x=1691047464; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s/f6F02clECnp9UMok7z/iDc6nTP9DI5CBuQ8iEcWFM=; b=FJRATpnCxelDJxRmZ81vmIdyI4qVej1aGhbTu16sPOD4hQMXIXAsVXIv m60LPhh54IvgdqDirjJBR3Ty+NiKZ0TXbqk3jqPaWIgmf/Ug2WMZ7IElW ebTbqihTkYU/Glj0vXRmOLtLGYaJMIww620qaJv84e5hVTMojuuRpG1lE +OOv2PS7rr4BglZIAxD1M4/coYBdxjSmmrnmiLf/Wl4aqftoGpfytuo9P LYO11slqu5cmlCHbJ8XEU1WaTn0mbZfqiP0tTqI6EPnSTl97AXQ/9O+TJ 8ABfC5KDo2+oDKxI/EKMHjL9DqWf1XDyGwM4ICZoGaSAPD+G2WuD2ji27 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10427"; a="290380804" X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="290380804" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:24 -0700 X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="606294170" Received: from jplumb-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.28.212]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:23 -0700 Subject: [PATCH 1/4] cxl/region: Fix decoder interleave programming From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Jonathan Cameron , vishal.l.verma@intel.com, alison.schofield@intel.com, ira.weiny@intel.com, dave.jiang@intel.com Date: Wed, 03 Aug 2022 00:24:23 -0700 Message-ID: <165951146336.967013.11160153960900111443.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165951145706.967013.3023584411011908037.stgit@dwillia2-xfh.jf.intel.com> References: <165951145706.967013.3023584411011908037.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 Jonathan notes: "Curiously interleave ways = 1 for the EPs which is obviously wrong" ...while testing the latest CXL development branch on QEMU. It turns out the region creation process failed to program the endpoint decoders. This was missed because the default settings of x1 at 4K intereleave still results in the region appearing to function. Jonathan caught the bug by reverse mapping the translations that need to happen for the QEMU support. Link: https://lore.kernel.org/r/62e95fdf9f6e2_30440294e4@dwillia2-xfh.jf.intel.com.notmuch Fixes: 384e624bb211 ("cxl/region: Attach endpoint decoders") Reported-by: Jonathan Cameron Signed-off-by: Dan Williams Acked-by: Jonathan Cameron --- drivers/cxl/core/region.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index cf5d5811fe4c..8e6ff3f39755 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1294,6 +1294,9 @@ static int cxl_region_attach(struct cxl_region *cxlr, p->state = CXL_CONFIG_ACTIVE; } + cxled->cxld.interleave_ways = p->interleave_ways; + cxled->cxld.interleave_granularity = p->interleave_granularity; + return 0; err_decrement: From patchwork Wed Aug 3 07:24:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12935236 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 C9D64C19F29 for ; Wed, 3 Aug 2022 07:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233079AbiHCHYq (ORCPT ); Wed, 3 Aug 2022 03:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233748AbiHCHYn (ORCPT ); Wed, 3 Aug 2022 03:24:43 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 620671D30C for ; Wed, 3 Aug 2022 00:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659511482; x=1691047482; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nZCWGRSuKfJARINwAzVMo5zWdwnijPTGD6BLp/khSXc=; b=hbuUdwbhjDjGlhg/kEaCyJ2MtgP33A4qOft99VIdL/ih6sh/YDFS+bvY npMUAssgVsChBadYSNIXHlzAUPyF49n3GCoc1eqia/xCj7djkED3vfTiC ri7SS5RbSNszC3paLwlsi19NCIpFCjG0WF70Re47aoygMqYpHLjL8WKLp nTDm6KQN5RpfS2S5dewTyvCLbS/V6zfin74FqcYSTvp+EmthbAljcnODm CplCsGwbVBLDK9kM1wr2ST+l6QyKAhgxusWVyR9K7X1XzdHO4NcaRL+4x dtaq1wDv6JbUdNJqNoB3O/sTQ47roPVqaSOHqBc17EEx8sSdrVL6WD6kh g==; X-IronPort-AV: E=McAfee;i="6400,9594,10427"; a="269987581" X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="269987581" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="599554122" Received: from anushkab-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.28.212]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:29 -0700 Subject: [PATCH 2/4] cxl/region: Move HPA setup to cxl_region_attach() From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Jonathan Cameron , vishal.l.verma@intel.com, alison.schofield@intel.com, ira.weiny@intel.com, dave.jiang@intel.com Date: Wed, 03 Aug 2022 00:24:29 -0700 Message-ID: <165951146924.967013.13625127756930271590.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165951145706.967013.3023584411011908037.stgit@dwillia2-xfh.jf.intel.com> References: <165951145706.967013.3023584411011908037.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 A recent bug fix added the setup of the endpoint decoder interleave geometry settings to cxl_region_attach(). Move the HPA setup there as well to keep all endpoint decoder parameter setting in a central location. Cc: Jonathan Cameron Signed-off-by: Dan Williams Reviewed-by: Jonathan Cameron --- drivers/cxl/core/hdm.c | 17 ++--------------- drivers/cxl/core/region.c | 4 ++++ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 8143e2615957..5aadefd670d1 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -499,20 +499,6 @@ static void cxld_set_type(struct cxl_decoder *cxld, u32 *ctrl) CXL_HDM_DECODER0_CTRL_TYPE); } -static void cxld_set_hpa(struct cxl_decoder *cxld, u64 *base, u64 *size) -{ - struct cxl_region *cxlr = cxld->region; - struct cxl_region_params *p = &cxlr->params; - - cxld->hpa_range = (struct range) { - .start = p->res->start, - .end = p->res->end, - }; - - *base = p->res->start; - *size = resource_size(p->res); -} - static void cxld_clear_hpa(struct cxl_decoder *cxld) { cxld->hpa_range = (struct range) { @@ -601,7 +587,8 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld) ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(cxld->id)); cxld_set_interleave(cxld, &ctrl); cxld_set_type(cxld, &ctrl); - cxld_set_hpa(cxld, &base, &size); + base = cxld->hpa_range.start; + size = range_len(&cxld->hpa_range); writel(upper_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(id)); writel(lower_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(id)); diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 8e6ff3f39755..a073f16355ca 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1296,6 +1296,10 @@ static int cxl_region_attach(struct cxl_region *cxlr, cxled->cxld.interleave_ways = p->interleave_ways; cxled->cxld.interleave_granularity = p->interleave_granularity; + cxled->cxld.hpa_range = (struct range) { + .start = p->res->start, + .end = p->res->end, + }; return 0; From patchwork Wed Aug 3 07:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12935234 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 93ED0C19F28 for ; Wed, 3 Aug 2022 07:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234312AbiHCHYn (ORCPT ); Wed, 3 Aug 2022 03:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiHCHYk (ORCPT ); Wed, 3 Aug 2022 03:24:40 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088401CFF8 for ; Wed, 3 Aug 2022 00:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659511480; x=1691047480; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=insGid9yE2zTq/BmuOBxwZ6Po+yLXOnN7+jiObbMdt4=; b=hRXGSZA3elmmlroK25NlI/ejHF88gD5kSgjnItrAc3Jkp84gf2nGYLlL IUJdfH5M8T6WKrnrNozcNg2koyM6N36ru2UkHC05jG2LFUlLn6Di8BMPQ 8IHOglpvkq0AdPdNniZuqnPrMgT1/2FSu4B5npPlwkLbd7PQ/QBEnIN6t CefUc/9WLqCDLXnnlZ23GNgWQanbtDbIHzdcR34sB7P9EcS0c7TgkPT9W zmfZBGpPLEoKDolB0UlZ5BCOZD0NL1l5ORBokqT9CjGHR+Xs83dmq0AfQ Xhh35BqRNIGGvdOdRE7We6N0TRKTB80RKY4B4yh+mS+eJZ1D0kP6na21u g==; X-IronPort-AV: E=McAfee;i="6400,9594,10427"; a="353611061" X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="353611061" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:36 -0700 X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="670766068" Received: from jplumb-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.28.212]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:35 -0700 Subject: [PATCH 3/4] cxl/region: Fix port setup uninitialized variable warnings From: Dan Williams To: linux-cxl@vger.kernel.org Cc: kernel test robot , vishal.l.verma@intel.com, alison.schofield@intel.com, ira.weiny@intel.com, dave.jiang@intel.com Date: Wed, 03 Aug 2022 00:24:34 -0700 Message-ID: <165951147487.967013.929590444907251028.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165951145706.967013.3023584411011908037.stgit@dwillia2-xfh.jf.intel.com> References: <165951145706.967013.3023584411011908037.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 0day robot reports: drivers/cxl/core/region.c:1068 cxl_port_setup_targets() error: uninitialized symbol 'eiw'. drivers/cxl/core/region.c:1068 cxl_port_setup_targets() error: uninitialized symbol 'peig'. drivers/cxl/core/region.c:1068 cxl_port_setup_targets() error: uninitialized symbol 'peiw'. ...which are all valid reports. Add debug statement to consume the, albeit unexpected, errors. Fixes: 27b3f8d13830 ("cxl/region: Program target lists") Reported-by: kernel test robot Signed-off-by: Dan Williams Reviewed-by: Jonathan Cameron --- drivers/cxl/core/region.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index a073f16355ca..5c931b6eb4e7 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1059,8 +1059,21 @@ static int cxl_port_setup_targets(struct cxl_port *port, parent_iw = parent_cxld->interleave_ways; } - granularity_to_cxl(parent_ig, &peig); - ways_to_cxl(parent_iw, &peiw); + rc = granularity_to_cxl(parent_ig, &peig); + if (rc) { + dev_dbg(&cxlr->dev, "%s:%s: invalid parent granularity: %d\n", + dev_name(parent_port->uport), + dev_name(&parent_port->dev), parent_ig); + return rc; + } + + rc = ways_to_cxl(parent_iw, &peiw); + if (rc) { + dev_dbg(&cxlr->dev, "%s:%s: invalid parent interleave: %d\n", + dev_name(parent_port->uport), + dev_name(&parent_port->dev), parent_iw); + return rc; + } iw = cxl_rr->nr_targets; ways_to_cxl(iw, &eiw); From patchwork Wed Aug 3 07:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12935235 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 4561FC19F2A for ; Wed, 3 Aug 2022 07:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbiHCHYp (ORCPT ); Wed, 3 Aug 2022 03:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233565AbiHCHYn (ORCPT ); Wed, 3 Aug 2022 03:24:43 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578121CFF8 for ; Wed, 3 Aug 2022 00:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659511482; x=1691047482; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5VyLK7zLsvMs11Lr/T+aqE92V4Dg2vmFXrVcVV4Lv9I=; b=S5+uJW9Bg2JdW/sP3VlC5sG/xkIHTs+tb6BnSFgdjWSfwr3eZQkfWUpG 91mjAd+huFX1KtZIG8/Azb1EA+8b7h9LdEJirffX2zATwO2Vyc3W7jUEf rRoAcWv9PXdq821GKwWvzZJ6bVDSD8kd6D/3BP4pAavdMOLDGyYjILtZT V3qpxJ+Ps66rfYZ4Ma1xJ3mDiwDdC2VvcD7rL/s1A5A2G/SlWIWd19D/k j95/eH8wFzn6Yw7if25rlf9OuvHGrKi+YxvA2c7LUbDGJe5jzsWYK++rS KyWj+Qvnj/dMxqqyFoAc8rdnGbg6Z7clpW7WlsosEQ0QZ2Z11MiT+gSh7 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10427"; a="353611078" X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="353611078" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,213,1654585200"; d="scan'208";a="606294220" Received: from jplumb-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.28.212]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 00:24:41 -0700 Subject: [PATCH 4/4] cxl/region: Fix region commit uninitialized variable warning From: Dan Williams To: linux-cxl@vger.kernel.org Cc: kernel test robot , vishal.l.verma@intel.com, alison.schofield@intel.com, ira.weiny@intel.com, dave.jiang@intel.com Date: Wed, 03 Aug 2022 00:24:41 -0700 Message-ID: <165951148105.967013.14191992449932268431.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <165951145706.967013.3023584411011908037.stgit@dwillia2-xfh.jf.intel.com> References: <165951145706.967013.3023584411011908037.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 0day robot reports: drivers/cxl/core/region.c:196 cxl_region_decode_commit() error: uninitialized symbol 'rc'. The re-checking of loop termination conditions to determine "success" makes it hard to see that @rc is initialized in all cases. Remove those to make it explicit that @rc reflects a commit error and that the rest of logic is concerned with unwinding committed decoders. Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware") Reported-by: kernel test robot Signed-off-by: Dan Williams Reviewed-by: Jonathan Cameron Reviewed-by: Ira Weiny --- drivers/cxl/core/region.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 5c931b6eb4e7..a68e4e0cf169 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -159,7 +159,7 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count) static int cxl_region_decode_commit(struct cxl_region *cxlr) { struct cxl_region_params *p = &cxlr->params; - int i, rc; + int i, rc = 0; for (i = 0; i < p->nr_targets; i++) { struct cxl_endpoint_decoder *cxled = p->targets[i]; @@ -180,7 +180,7 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr) } /* success, all decoders up to the root are programmed */ - if (is_cxl_root(iter)) + if (rc == 0) continue; /* programming @iter failed, teardown */ @@ -192,14 +192,12 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr) } cxled->cxld.reset(&cxled->cxld); - if (i == 0) - return rc; - break; + goto err; } - if (i >= p->nr_targets) - return 0; + return 0; +err: /* undo the targets that were successfully committed */ cxl_region_decode_reset(cxlr, i); return rc;