Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1445267pxb; Sun, 11 Apr 2021 20:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxylkpuKqQ4kNm+FVHSSULStxqmwM72V5naB9AbO/f1iK3i+BeXglXE5l5PPnPa7sl5xhsS X-Received: by 2002:a05:6402:17c6:: with SMTP id s6mr27824132edy.319.1618197840356; Sun, 11 Apr 2021 20:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618197840; cv=none; d=google.com; s=arc-20160816; b=XaMpiuCXoWhDEoBPjNQ2mA2jAGp7mAGafUOGa43k/kJUA15z8ODcAhfTDwKX4sfH1b 7yGtSu1lfRxyjvou2agT0ArswP153IeiD5TJ5jes7U5Ets0sfXmWdnt7+HRScU1DiUlK x/55ue1LEX8lsvm8tSLehC8TYzKQex7CbKeKDI5qzUNyzhR97XuotQymdjv6zh5qXhm3 Y/d4ATb4kyxvaenpXG/y6AzuiBKG3988i59KM6CCh6YCXa1ZaodZ73b8Dd6sOo9Ttstn gfMHH7ZuLEA6dELZAZx4nuIhM21fVzYBuw6p11Gfyls2/fny7myQ4dL+XohLKomulICP 2YZw== 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:dkim-signature; bh=2MIF0iAJlOzjRFkD1X3zRNDFEO5YU1OCow9vUrQ1Ec0=; b=ik914+0x+7FfpOlmJ2bV+21SY3A8oz3BFbO8P63DcwEqciXRuIwJ6ENT5O/d0n1wMF n4oGVKs0bf6+tN62FTHXOG49yqs5tuq5X3rCHXwNgDc7a3rRrahRkKolBijQouWjUN7K 1+NoUtZ0bfZOn85LUKqeknVcEpQt1GK76wiiWTZV75cfVaXHkwvMIFXukMwiORvFtwvz QXWXnqPMyWS6Ma9jDb3mK6/qGluhU4ojY4vi7XB4tC+vuqBk0CvzwsXpZlLlBZa4GxFk R0S5QEz/d4M/F++2ZvCLeHjptXYTIm9jstSUvaiU/VAAnZ+r6laV2whMxCmejSKpMvdn diAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="eqJG/xyJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si6987682edq.124.2021.04.11.20.23.37; Sun, 11 Apr 2021 20:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="eqJG/xyJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235722AbhDLDXG (ORCPT + 99 others); Sun, 11 Apr 2021 23:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235555AbhDLDWx (ORCPT ); Sun, 11 Apr 2021 23:22:53 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43098C061574 for ; Sun, 11 Apr 2021 20:22:33 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id i4so5896943pjk.1 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=lRXherpDS3QdqOFLyzQLd1fTyV4e8+Du6k9WNn6kTxtVRDyxVxZ8k+93RSuZSTdAxo PqjCfbcdPk3e1NDDIRRAkM4woITiR/UnK+FBq+zxMitHgXf/HKrX0uqBmDRwsB04hABQ ogQ0IDlGSed+HRMgfk4ysxRvtyEQu804d9Z68wmK+vk6jN/g0fAf1UglonLInM2p9NZ9 5PHwuLMK+FTEgh4MIr4K28iL8G03ddrm85QbqdVnCPvhM5zi6mXcwJ/JUNIsuJH6SOpG S48/tVi/gGjW5V6Ajp2prFHwoUuvs+3jAb8HaLPvJMptOCK/Oe+9dqUcb7hdZlOiAowX 8BFw== X-Gm-Message-State: AOAM532R7w+Yo6lH1rtMbUdWd3xY+OP8FzWOtzs3tHbb+VuuqBxfFT4x dxvkwTHau2k1ii4Wt6EUf1aD+A== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.31.1.295.g9ea45b61b8-goog