From patchwork Wed Nov 30 15:36:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13060043 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA3D0C433FE for ; Wed, 30 Nov 2022 15:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WiqoJIWXon/wgc1VJNfIJMoiG9fe7GMEXV9vvDBkCAs=; b=Tp+nTNf8tUHaN1 Do3RUYg1QWNEgvG4+qMmIgn4127HVTaIQrsVzDRCkv1RFJTXdaRZMcEIloBO0D6xTrP+QegJSkeVX 6NEN0zO+VOVqxFnvxSAv3zJHx2gqJeapA6UnmAwiIlXdCTzQamwFJSvGsLWp4vfuuGMZZaAqlKpIS gCKpj/znrv9sx8jRFM7V1WFkYhJoqIubBiLNmGJgqYn0GtETXyWezmtVwraiIxTyv+jMsiiZwFzaZ 3fWPAL6q1Zewv6A9HFP+K2jE+TabtPMLrVqKesdgDNb1ErEH/iccFyM7mZn36TLQIK1rJZ4RqaF2t c+4dfkfAWZZmyhlJMIaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0P8r-00HXa6-BJ; Wed, 30 Nov 2022 15:36:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0P8l-00HXV3-IO for linux-arm-kernel@lists.infradead.org; Wed, 30 Nov 2022 15:36:54 +0000 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 30EE4D6E; Wed, 30 Nov 2022 07:36:52 -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 C77E33F67D; Wed, 30 Nov 2022 07:36:44 -0800 (PST) From: Robin Murphy To: will@kernel.org, mark.rutland@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geoff Blake Subject: [PATCH 1/2] perf/arm-cmn: Cope with spurious IRQs better Date: Wed, 30 Nov 2022 15:36:38 +0000 Message-Id: X-Mailer: git-send-email 2.36.1.dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_073651_689378_68D90D64 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Although we reset the CMN state during probe before requesting our interrupt(s), a pending IRQ could already have been latched at the interrupt controller, and thus be delivered spuriously as soon as the IRQ is enabled. Not handling that can then lead to the IRQ layer disabling it again, and things subseuqently going wonky. Since we can't support shared IRQs anyway for affinity-management reasons, the only time we should concievably return IRQ_NONE is for a spurious interrupt which did somehow originate from our CMN, so there should be no harm in removing the problem by simply claiming to have handled those as well. Reported-by: Geoff Blake Signed-off-by: Robin Murphy --- drivers/perf/arm-cmn.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index b80a9b74662b..9e8be5586423 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1798,7 +1798,6 @@ static int arm_cmn_pmu_offline_cpu(unsigned int cpu, struct hlist_node *cpuhp_no static irqreturn_t arm_cmn_handle_irq(int irq, void *dev_id) { struct arm_cmn_dtc *dtc = dev_id; - irqreturn_t ret = IRQ_NONE; for (;;) { u32 status = readl_relaxed(dtc->base + CMN_DT_PMOVSR); @@ -1807,7 +1806,6 @@ static irqreturn_t arm_cmn_handle_irq(int irq, void *dev_id) for (i = 0; i < CMN_DTM_NUM_COUNTERS; i++) { if (status & (1U << i)) { - ret = IRQ_HANDLED; if (WARN_ON(!dtc->counters[i])) continue; delta = (u64)arm_cmn_read_counter(dtc, i) << 16; @@ -1816,7 +1814,6 @@ static irqreturn_t arm_cmn_handle_irq(int irq, void *dev_id) } if (status & (1U << CMN_DT_NUM_COUNTERS)) { - ret = IRQ_HANDLED; if (dtc->cc_active && !WARN_ON(!dtc->cycles)) { delta = arm_cmn_read_cc(dtc); local64_add(delta, &dtc->cycles->count); @@ -1826,7 +1823,7 @@ static irqreturn_t arm_cmn_handle_irq(int irq, void *dev_id) writel_relaxed(status, dtc->base + CMN_DT_PMOVSR_CLR); if (!dtc->irq_friend) - return ret; + return IRQ_HANDLED; dtc += dtc->irq_friend; } } From patchwork Wed Nov 30 15:36:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 13060042 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB96CC4332F for ; Wed, 30 Nov 2022 15:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zrp2VPyUZAF8QPtUTsJOnx37vBZxhzmef1U1Wo0I+5M=; b=0HIaFEe61j7Tg0 rKifGw8SYxyxEFWCo4+zoDmHKRHb/2HZHIg4vQN1oKu3h0EueIhnOYW7BLSmJpCyoWfiN24A/jsJM EpigOtmh8th7pot1XC/aRZPRlMCLpIb9HQRCrsFwzZ9OA74Po0zqvulfGBc0EUsxcSyEGaS60AqA7 BEoooX2Saw61l5UHfBdNM46P4sooy0YaQJjPrrOlnLoTKNktZLiqR6lVbYaEv1juBlA1ucAGe5TKU 5rqSSOWYdrxzx9iFbXDic3sscrmPIeeVVHTZteEbE+BGDqxr2Q07CkgLBfoWPoiETUg0ERbynpAna UQDXBR3SaAdtGTdD40rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0P91-00HXeb-9n; Wed, 30 Nov 2022 15:37:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0P8l-00HXWt-IQ for linux-arm-kernel@lists.infradead.org; Wed, 30 Nov 2022 15:36:54 +0000 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 B43A91042; Wed, 30 Nov 2022 07:36:55 -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 56EB63F67D; Wed, 30 Nov 2022 07:36:48 -0800 (PST) From: Robin Murphy To: will@kernel.org, mark.rutland@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geoff Blake Subject: [PATCH 2/2] perf/arm-cmn: Implement shutdown method Date: Wed, 30 Nov 2022 15:36:39 +0000 Message-Id: <43fb90e6428d0a667deedd3726f462c3c71a8e94.1669822447.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.36.1.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_073651_689037_D1AE249C X-CRM114-Status: GOOD ( 14.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Apparently a kexec-induced shutdown does not manage to close perf events that processes still had open, and thus can leave the PMU running such that the next kernel may find an overflow interrupt already asserted. Although the next kernel should ideally be robust aganst that anyway, let's be polite and disable the PMU to match what we do on remove. Suggested-by: Geoff Blake Signed-off-by: Robin Murphy --- drivers/perf/arm-cmn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 9e8be5586423..0b2df72cee9f 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -2309,11 +2309,18 @@ static int arm_cmn_probe(struct platform_device *pdev) return err; } -static int arm_cmn_remove(struct platform_device *pdev) +static void arm_cmn_shutdown(struct platform_device *pdev) { struct arm_cmn *cmn = platform_get_drvdata(pdev); writel_relaxed(0, cmn->dtc[0].base + CMN_DT_DTC_CTL); +} + +static int arm_cmn_remove(struct platform_device *pdev) +{ + struct arm_cmn *cmn = platform_get_drvdata(pdev); + + arm_cmn_shutdown(pdev); perf_pmu_unregister(&cmn->pmu); cpuhp_state_remove_instance_nocalls(arm_cmn_hp_state, &cmn->cpuhp_node); @@ -2350,6 +2357,7 @@ static struct platform_driver arm_cmn_driver = { }, .probe = arm_cmn_probe, .remove = arm_cmn_remove, + .shutdown = arm_cmn_shutdown, }; static int __init arm_cmn_init(void)