Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2262641rwl; Thu, 6 Apr 2023 07:59:15 -0700 (PDT) X-Google-Smtp-Source: AKy350b76wYtXbWklrwJdy3C3Ji3L3vSNz9+fF5bOWD0BHu5SV6p1raICraiDZbmszEN+zI3usXY X-Received: by 2002:a17:903:32ca:b0:19c:dbce:dce8 with SMTP id i10-20020a17090332ca00b0019cdbcedce8mr12849724plr.15.1680793154802; Thu, 06 Apr 2023 07:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680793154; cv=none; d=google.com; s=arc-20160816; b=ZshLbXauNyLoDTUN42WtZhVa8vS1UrJhoJL7oS6+ZKtKnOmqyTYXsv0Du6E8Kb5QAj mJqAPO4+MdRPjaeZwUVYgHSx18YEtsiOWSmGXogms1gTkopck93Y1GCRjwbvkNO0DnwK PdbEgzKbQ2wyBF0R4ixZyq5TGJpHbZUhv52lMyEO0C3lWxTZq6/C+KlLZnfd8ZqaVTUp /yB6dMnAm3KWD/hFi/IaXAfRMWjgCQsbykAyw1hKnKRfu66lD4se+a4g1RUK9g017MjL P/MvRFhjEDgwlulJG+77aog0if5O80o8EVKj40M2gP0lnq8BSZGzbyDqNBVKa/y89F/6 VNSw== 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=gpTNcbow9DQlI8LZDthMUCFrTLfI6KYd2Zg7FIxsWDI=; b=ceoYbmGRxrI4gJkTMBHcj2+Drd0ueEsRNcVfNJK4AI79PBtufkfW5h0US/rHoDpmue xQKX9pC0lH8GpWRc6PDalwl0cQfiJP/58SlVdvAcbL3fpfbb0DvVQCFSX5gh5siJ3zhE 66fMjEg3KpJMQxunIPLPEwNiz7+Sch2CywkkOxzOq7NpcDO0MsJQu7PJHB7Z31u1P0bz gYbPxdWE2JA9L647hDdDg3UdvncWdC3MOJcggoYtdew14fQyU7Jf9ESHIHRtWtAuUI6k cTCIVwJ6TFkdq9LTRJmCmqbA05yCeu81BSvRMsRKEBfScXtD6rqPJLf6dSHXCyDHW7wS zbYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a6543c7000000b005032da21acasi1441031pgp.204.2023.04.06.07.59.03; Thu, 06 Apr 2023 07:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239502AbjDFOu5 (ORCPT + 99 others); Thu, 6 Apr 2023 10:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238925AbjDFOuf (ORCPT ); Thu, 6 Apr 2023 10:50:35 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E5DFA258 for ; Thu, 6 Apr 2023 07:49:32 -0700 (PDT) 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 C57BC106F; Thu, 6 Apr 2023 07:50:15 -0700 (PDT) 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 B18EE3F762; Thu, 6 Apr 2023 07:49:30 -0700 (PDT) From: Robin Murphy To: will@kernel.org Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ilkka@os.amperecomputing.com, Geoff Blake Subject: [PATCH] perf/arm-cmn: Fix DTC reset Date: Thu, 6 Apr 2023 15:49:15 +0100 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=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It turns out that my naive DTC reset logic fails to work as intended, since clearing PMCR.PMU_EN appears to result in writes to PMOVSR_CLR being ignored, while some hard-to-characterise combination of conditions (differently between DTC0 and secondary DTCs) also appears to result in PMOVSR reading as zero even when an overflow remains asserted. Thus rather than resetting the PMU to a nice clean state, we can currently end up with screaming spurious interrupts from secondary DTCs which we can neither see nor clear. This behaviour is of course not documented. Resetting PMCR to disable the interrupt output but enable the PMU itself seems to at least make the PMOVSR_CLR write work as expected on DTC0 (although it looks like writing to PMCR twice has actually been having some hidden side-effect of clearing any pending overflows there). Unfortunately this still does not seem to help secondary DTCs, but going beyond PMU scope and additionally resetting DTC_CTL does seems to make everything work out, and superficially looks sensible. Therefore pile that onto the house of empirical cards too, until I can check with the hardware team whether there's actually any proper recommended way of recovering from an arbitrary PMU state after an oops/kexec/whatever. Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver") Reported-by: Geoff Blake Signed-off-by: Robin Murphy --- This supersedes the previous shutdown/IRQ patches, now that I've finally managed to make *some* sense of what's really going on. If anyone's interested, this is the contrivance I used for testing: https://gitlab.arm.com/linux-arm/linux-rm/-/commit/d8f1035c5bc510516d6e4f0b7bf0b875a749daf7 --- drivers/perf/arm-cmn.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 144cc08d9e04..81fe01171e33 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1899,7 +1899,10 @@ static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int id if (dtc->irq < 0) return dtc->irq; - writel_relaxed(0, dtc->base + CMN_DT_PMCR); + if (idx == 0) + writel_relaxed(0, dtc->base + CMN_DT_DTC_CTL); + + writel_relaxed(CMN_DT_PMCR_PMU_EN, dtc->base + CMN_DT_PMCR); writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR); writel_relaxed(CMN_DT_PMCR_OVFL_INTR_EN, dtc->base + CMN_DT_PMCR); -- 2.39.2.101.g768bb238c484.dirty