Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4193396rdb; Mon, 11 Dec 2023 11:27:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIi4qShe38xnAZQ8SgbnOkTs/3RaJdqwRrDEVP149kfamGpgAazLg+zCB8tX5onYf681HT X-Received: by 2002:a05:6871:a686:b0:1fa:fb60:b3e4 with SMTP id wh6-20020a056871a68600b001fafb60b3e4mr5505769oab.22.1702322863733; Mon, 11 Dec 2023 11:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702322863; cv=none; d=google.com; s=arc-20160816; b=R493jH5R9QOj8FtlHpPKJH1bldQIGt8PfCaWENdT3gupZCFyg1UZM4t+qSB9+krvc+ ERwUg2Ty6jrz8yl1hW2Q73/ezPi9z68ruGFAlSmATvFRhgXNA/8Gp8K6IeMHEyCojQXg pu6hQrN19xEDxLizOgNAYqWizMtMaYPJgcycYAoZF8Vd12RpYtaJyDgkExuJ+bvyMYua JDnKvWwMJlQECd6G0JkUUnumU5c6kQfareeV6HEACGj2s5WB4NZ9io3ZDdviD3LGP902 Qvt5F34ZiUbcygWpdpmwdKRf0vKGAdwpDXBbCauYIggW9Bd1+MxQ0olSCiggwELu92E7 yEfg== 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 :message-id:date:subject:cc:to:from; bh=Q1cq0XlMRixIunaN/b4sfSFNoYIDqLX8Qk4c4tcdBNc=; fh=5eTsl8DZJtk22FZMserOlh83jaey1v40CuRMPgl25m8=; b=yyqwFARYdsQlaCpwJUisrAzvHbNVcLktBholoqF02pMQmfHgpBAwaGNimtFAlvlOgF sJ9gIF/Q/DCzRFWhQkiZFDqONqzO+of1lu5FsRGC+piGNSlwr0XCUvjQQ1k6lMzF9oMt RklBUMet+BJWWPqzMkbcMWDKEVgnqnbI4M2qeBIegDkOuFAZ4Hl1xcWHMPeicbQt6q2U VvOyUawFeSSfo1qTckMfsX8+lGwyupL0zS8bVItKHQm6MNdSGxFnTTR2WAau/DxEx9Rm r1djmZJAFciKI6uM9rWuKPHKg6BPA5wxYc4sd4Ix9GnB6vK9jQ9kYHkW6ijxsxbYomjN kxag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x16-20020a634a10000000b005b96d038729si5444554pga.728.2023.12.11.11.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 11:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3DE598068C70; Mon, 11 Dec 2023 11:27:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344410AbjLKT12 (ORCPT + 99 others); Mon, 11 Dec 2023 14:27:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjLKT12 (ORCPT ); Mon, 11 Dec 2023 14:27:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A46199F for ; Mon, 11 Dec 2023 11:27:34 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B82F1007; Mon, 11 Dec 2023 11:28:21 -0800 (PST) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5D7A53F762; Mon, 11 Dec 2023 11:27:33 -0800 (PST) From: Robin Murphy To: will@kernel.org Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com, ilkka@os.amperecomputing.com, renyu.zj@linux.alibaba.com Subject: [PATCH] perf/arm-cmn: Fail DTC counter allocation correctly Date: Mon, 11 Dec 2023 19:27:28 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 11:27:41 -0800 (PST) Calling arm_cmn_event_clear() before all DTC indices are allocated is wrong, and can lead to arm_cmn_event_add() erroneously clearing live counters from full DTCs where allocation fails. Since the DTC counters are only updated by arm_cmn_init_counter() after all DTC and DTM allocations succeed, nothing actually needs cleaning up in this case anyway, and it should just return directly as it did before. Fixes: 7633ec2c262f ("perf/arm-cmn: Rework DTC counters (again)") Signed-off-by: Robin Murphy --- drivers/perf/arm-cmn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 86d970e74129..c584165b13ba 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1816,7 +1816,7 @@ static int arm_cmn_event_add(struct perf_event *event, int flags) idx = 0; while (cmn->dtc[j].counters[idx]) if (++idx == CMN_DT_NUM_COUNTERS) - goto free_dtms; + return -ENOSPC; } hw->dtc_idx[j] = idx; } -- 2.39.2.101.g768bb238c484.dirty