From patchwork Tue Oct 10 18:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Harris X-Patchwork-Id: 13415861 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 897B7EB8 for ; Tue, 10 Oct 2023 18:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="J71oAm2L" Received: from mailout2.w2.samsung.com (mailout2.w2.samsung.com [211.189.100.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8707C94 for ; Tue, 10 Oct 2023 11:38:42 -0700 (PDT) Received: from uscas1p1.samsung.com (unknown [182.198.245.206]) by mailout2.w2.samsung.com (KnoxPortal) with ESMTP id 20231010183840usoutp02ff48670a35442226fa6d9978e3219830~M0ver2uOD0393103931usoutp02m; Tue, 10 Oct 2023 18:38:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w2.samsung.com 20231010183840usoutp02ff48670a35442226fa6d9978e3219830~M0ver2uOD0393103931usoutp02m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1696963120; bh=oI/sb+3jq9rk/RWEqZp07XuknPPe93xMN9P+8IT8/J4=; h=From:To:Subject:Date:References:From; b=J71oAm2LctkjVk0CHQXsNKv+ZYisxSY2kjIlcoPDkrzBANDbRPd0KX9ohz9nwa3G3 1kExt4TAV5qPlHKLhJzoO7NWn+uN7z2UQ51IMqE8cZgCcEgZSHQ4Z8T0fY8BD6SelK EHsxx+JvFuZ71V+c1sQV/LR5FxhB/BrCL/oQWrrI= Received: from ussmges1new.samsung.com (u109.gpu85.samsung.co.kr [203.254.195.109]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20231010183840uscas1p23505231b5d68d67ce5bdaf1c7e3f90cb~M0vebigm53057530575uscas1p2h; Tue, 10 Oct 2023 18:38:40 +0000 (GMT) Received: from uscas1p2.samsung.com ( [182.198.245.207]) by ussmges1new.samsung.com (USCPEMTA) with SMTP id 2A.B9.50148.03A95256; Tue, 10 Oct 2023 14:38:40 -0400 (EDT) Received: from ussmgxs2new.samsung.com (u91.gpu85.samsung.co.kr [203.254.195.91]) by uscas1p2.samsung.com (KnoxPortal) with ESMTP id 20231010183840uscas1p294532ae60e6014508efd897fef14fffd~M0veH-OwN1308913089uscas1p2c; Tue, 10 Oct 2023 18:38:40 +0000 (GMT) X-AuditID: cbfec36d-7bdff7000002c3e4-a2-65259a30e016 Received: from SSI-EX2.ssi.samsung.com ( [105.128.2.146]) by ussmgxs2new.samsung.com (USCPEXMTA) with SMTP id E2.E7.31200.F2A95256; Tue, 10 Oct 2023 14:38:40 -0400 (EDT) Received: from SSI-EX2.ssi.samsung.com (105.128.2.227) by SSI-EX2.ssi.samsung.com (105.128.2.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Tue, 10 Oct 2023 11:38:39 -0700 Received: from SSI-EX2.ssi.samsung.com ([105.128.2.227]) by SSI-EX2.ssi.samsung.com ([105.128.2.227]) with mapi id 15.01.2375.024; Tue, 10 Oct 2023 11:38:39 -0700 From: Jim Harris To: "linux-cxl@vger.kernel.org" , "dan.carpenter@linaro.org" , "dan.j.williams@intel.com" Subject: [PATCH] cxl/region: don't try to cleanup after cxl_region_setup_targets() fails Thread-Topic: [PATCH] cxl/region: don't try to cleanup after cxl_region_setup_targets() fails Thread-Index: AQHZ+6j8MpVLjV1hUUCWKxMwxFDyyg== Date: Tue, 10 Oct 2023 18:38:39 +0000 Message-ID: <169696311899.1171696.7812961484055097837.stgit@bgt-140510-bm03.eng.stellus.in> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [105.128.2.176] Content-ID: <39A9F2973CCB7C47A6D18365657E3A34@ssi.samsung.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42LZduzreV2DWaqpBp0t0hYf5rWyW0yfeoHR 4vysUywOzB6L97xk8rhzbQ+bx+dNcgHMUVw2Kak5mWWpRfp2CVwZB09vYC94IlYx88B39gbG GWJdjJwcEgImEm13fzB2MXJxCAmsZJQ4OncCO4TTyiRxet8vVpiqm+/uMkMk1jJK/Pv/jw3C +cQosebTKyYIZxmjxPbfxxhBWtgENCV+XVkDlhABabndPY0NJCEsECUxa8MDZhBbRCBe4sOa L1C2nsSunyuYQGwWAVWJNY1t7CA2r0C0xJ2Vu8CGMgqISXw/tQashllAXOLWk/lMEPcJSiya vYcZwhaT+LfrIRuErShx//tLoDkcQPWaEut36UO02kmc+N7KDmErSkzpfgi1SlDi5MwnLBCt khIHV9xgAblfQqCTQ+LnvnPMIHMkBFwkTt5ihKiRlvh7dxnUCdkSK9d3MEGUFEg0HAmCCFtL LPyzHupiPom/vx4xQpTwSnS0CU1gVJqF5JdZCHfOQnLnLCR3zkJy5wJG1lWM4qXFxbnpqcWG eanlesWJucWleel6yfm5mxiB6eX0v8O5Oxh33Pqod4iRiYPxEKMEB7OSCO+jTJVUId6UxMqq 1KL8+KLSnNTiQ4zSHCxK4ryGtieThQTSE0tSs1NTC1KLYLJMHJxSDUxt6tLnZu1Y+YAzIvPy N/HaAxf7ZhyTcW3SfRhrNt1EOHpV58NlM9bU7anMEH+xSzehsPaba1S+oa7LMTeVk2tMd/33 P8pzVkovzvby6t70aKW6c4WFYUGbz87vqehXCctmSJn8JXBO0qRlae8Mr0oaf94Xu+Tg0T37 5q9MNUrV3nPr4st9UmuNU1MlXwTNX3tCR+vH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K6z+t0j2xKF/YbsWv7zhdJbj5eJ7WSftfz7wbb08f0uKTFbf29WMiROnlsz+PEFl 3XfBQ4IPlFiKMxINtZiLihMB7Qhl9xoDAAA= X-CMS-MailID: 20231010183840uscas1p294532ae60e6014508efd897fef14fffd CMS-TYPE: 301P X-CMS-RootMailID: 20231010183840uscas1p294532ae60e6014508efd897fef14fffd References: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Patch 5e42bcbc ("cxl/region: decrement ->nr_targets on error in cxl_region_attach()") tried to avoid 'eiw' initialization errors when ->nr_targets exceeded 16, by just decrementing ->nr_targets when cxl_region_setup_targets() failed. Patch 86987c76 ("cxl/region: Cleanup target list on attach error") extended that cleanup to also clear cxled->pos and p->targets[pos]. The initialization error was incidentally fixed separately by patch 8d4285425 ("cxl/region: Fix port setup uninitialized variable warnings") which was merged a few days after 5e42bcbc. But now the original cleanup when cxl_region_setup_targets() fails prevents endpoint and switch decoder resources from being reused: 1) the cleanup does not set the decoder's region to NULL, which results in future dpa_size_store() calls returning -EBUSY 2) the decoder is not properly freed, which results in future commit errors associated with the upstream switch Now that the initialization errors were fixed separately, the proper cleanup for this case is to just return immediately. Then the resources associated with this target get cleanup up as normal when the failed region is deleted. Tested by trying to create an invalid region for a 2 switch * 2 endpoint topology, and then following up with creating a valid region. Signed-off-by: Jim Harris --- drivers/cxl/core/region.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 6d63b8798c29..315ca1640e06 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1750,7 +1750,7 @@ static int cxl_region_attach(struct cxl_region *cxlr, if (p->nr_targets == p->interleave_ways) { rc = cxl_region_setup_targets(cxlr); if (rc) - goto err_decrement; + return rc; p->state = CXL_CONFIG_ACTIVE; } @@ -1762,12 +1762,6 @@ static int cxl_region_attach(struct cxl_region *cxlr, }; return 0; - -err_decrement: - p->nr_targets--; - cxled->pos = -1; - p->targets[pos] = NULL; - return rc; } static int cxl_region_detach(struct cxl_endpoint_decoder *cxled)