From patchwork Mon Apr 12 03:22:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Benn X-Patchwork-Id: 12196701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2170EC433B4 for ; Mon, 12 Apr 2021 03:24:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A81C76120D for ; Mon, 12 Apr 2021 03:24:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A81C76120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=JZIGlgEPaatPYtxS1L3wY2Oe8nsLfWtH6vgDUcZJUvI=; b=A0JUhd9AJMyQHzZ0u6xrz21Gi7 IQD1drzoXHGDzh/cc1mA2gsexrCg8mOK+gWZw6C34EydUGdwF/tZVy+0nN+aZTlrbSZT/vDEmV6Uk VWrt1Oqmz+iqfV+y0aZuB6hTZvliQrx25wkmOpjvPXSoqvL0mGjC5JqHkDCdIn6CcepDS3TnpT7fm 2PXMoiT6QrWFP8PhkwjeiI9mzgyJLb2ap0n1K2TSvq9Z5jG4F3O+G2k2PVU4WLrkfFhkLZT2swHPG 96AAjI7L8oKSp5JxJ3CPWvyCmtxkdlXrBDJcrrHcpGpOAgSA0uAaLzGLZ6Chlf6jxMEiUHCzOn1JQ w1KejDPA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVn9s-005acl-Cu; Mon, 12 Apr 2021 03:22:40 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVn9p-005acO-1Y for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 03:22:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=2MIF0iAJlOzjRFkD1X3zRNDFEO5YU1OCow9vUrQ1Ec0=; b=dlBGWaUmBptIuB+/m4aVjd8Nql BtOfY0CE/2lQrBNuZvwi76D1Jif8Y0J16Wwo3pyV8O81mEtI3iY/pUSG/DIgLJevHak0WHatXz4QP xvoiBsA5k6DQnPQw6/mHuGols02/FRPAxReSicoYBUHjPfW15uHNH4PBox4ZxQiOyjdGsqIMqeup8 3taWBT5UVAIXkPc+6V4NEQ+179m5lIY0grobU4ySJLl/Jg0AkYa6nrTWHPA+RpkDubQgtatpZaaEE KFB5NClIRNQr2i8l6SG04zmCNxuaTjYMVBW+hsE+D1n12LqvNGN0s5xB9J0/o7fHePH0jlwsVrJFd QZp0/ucg==; Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVn9m-005rB6-7H for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 03:22:35 +0000 Received: by mail-pj1-x102a.google.com with SMTP id cu16so3888288pjb.4 for ; Sun, 11 Apr 2021 20:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2MIF0iAJlOzjRFkD1X3zRNDFEO5YU1OCow9vUrQ1Ec0=; b=eqJG/xyJz4pFsiGLXd8iRXk6L7TKPaSTVxu31AE1BxCVz/bKjGYUGV43TZ1+wXQi44 f5RdejpDlM1yY8aNsVhvcLc4S9AHNUxfEjzOl5E6O9WkIkBSlZJuh/akbrJ0PAIeptXm IOArD+4S1RvBmvgQ6zO35TEIK/zEBSZW+scg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2MIF0iAJlOzjRFkD1X3zRNDFEO5YU1OCow9vUrQ1Ec0=; b=ewa05wAN2xANnPoK2q0flkwY4QSgmQox2w7QQRczsXWQc5e9Iks45fulcuZyuL2zPX NmBZ3jtmflpyHXnAVYKIKcN1XD1v7YSbIgcw0XBUTnLjQR+BvctR5GVOW5rKUTYll7RF ywQIIBuYf9nkIOJwpJfNh+6HFteSypFmibbl0/wX9pViJtr2yc0BHDtPl/32DhksNA6c Wze8aftXSq8jK9Wkf/V/jLXURFnEs/KiN+sd5brz6sXTSyxh7phbaG3wIGLEMqOiOf/W 6A9iL//pyH6bF+YNEcDjbQpRJk5dmP8dQsK4xEQIF4/DOqN2fjNoUcxhV5H2zMtNNkJb P67A== X-Gm-Message-State: AOAM532iHNQ629xalZECVkEXoK6HJc2Amlq90KpzGZq2I3Hv8/c7vDEx GeH/dQg6mxcEyLOiIl8t+j5qiw== X-Google-Smtp-Source: ABdhPJwmDZ638Yqs1btdo68wp/5hoyLDHJEcFhSlXcJCXASInPEUYg3KQwuvbRhg+wHRmIQqw/wkhQ== X-Received: by 2002:a17:902:7589:b029:e8:c011:1f28 with SMTP id j9-20020a1709027589b02900e8c0111f28mr23859383pll.35.1618197752825; Sun, 11 Apr 2021 20:22:32 -0700 (PDT) Received: from evanbenn1.syd.corp.google.com ([2401:fa00:9:15:9f69:197:25b3:20f8]) by smtp.gmail.com with ESMTPSA id f17sm9558020pgj.86.2021.04.11.20.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Apr 2021 20:22:32 -0700 (PDT) From: Evan Benn To: Daniel Lezcano , Matthias Brugger Cc: Evan Benn , linux-mediatek@lists.infradead.org, Fabien Parent , Yingjoe Chen , Viresh Kumar , linux-arm-kernel@lists.infradead.org, Julia Lawall , Stanley Chu , Thomas Gleixner , LKML Subject: [PATCH v3] drivers/clocksource/mediatek: Ack and disable interrupts on suspend Date: Mon, 12 Apr 2021 13:22:19 +1000 Message-Id: <20210412132200.v3.1.I1d9917047de06715da16e1620759f703fcfdcbcb@changeid> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210411_202234_314677_F3EB6852 X-CRM114-Status: GOOD ( 13.96 ) 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 Interrupts are disabled during suspend before this driver disables its timers. ARM trusted firmware will abort suspend if the timer irq is pending, so ack and disable the timer interrupt during suspend. Signed-off-by: Evan Benn --- Changes in v3: Move the ACK from the shutdown to the suspend function. Changes in v2: Remove the patch that splits the drivers into 2 files. drivers/clocksource/timer-mediatek.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c index 9318edcd8963..1ae8fee639bf 100644 --- a/drivers/clocksource/timer-mediatek.c +++ b/drivers/clocksource/timer-mediatek.c @@ -241,6 +241,27 @@ static void mtk_gpt_enable_irq(struct timer_of *to, u8 timer) timer_of_base(to) + GPT_IRQ_EN_REG); } +static void mtk_gpt_resume(struct clock_event_device *clk) +{ + struct timer_of *to = to_timer_of(clk); + + mtk_gpt_enable_irq(to, TIMER_CLK_EVT); +} + +static void mtk_gpt_suspend(struct clock_event_device *clk) +{ + struct timer_of *to = to_timer_of(clk); + + /* Disable all interrupts */ + writel(0x0, timer_of_base(to) + GPT_IRQ_EN_REG); + + /* This is called with interrupts disabled, + * so we need to ack any interrupt that is pending + * Or for example ATF will prevent a suspend from completing. + */ + writel(0x3f, timer_of_base(to) + GPT_IRQ_ACK_REG); +} + static struct timer_of to = { .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK, @@ -286,6 +307,8 @@ static int __init mtk_gpt_init(struct device_node *node) to.clkevt.set_state_oneshot = mtk_gpt_clkevt_shutdown; to.clkevt.tick_resume = mtk_gpt_clkevt_shutdown; to.clkevt.set_next_event = mtk_gpt_clkevt_next_event; + to.clkevt.suspend = mtk_gpt_suspend; + to.clkevt.resume = mtk_gpt_resume; to.of_irq.handler = mtk_gpt_interrupt; ret = timer_of_init(node, &to);