From patchwork Wed May 12 02:25:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Benn X-Patchwork-Id: 12252575 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=-17.5 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 A39A1C433ED for ; Wed, 12 May 2021 02:28:02 +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 29975616EA for ; Wed, 12 May 2021 02:28:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29975616EA 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=lz5BTSwvhT1fJNo4eIRc8J2QQhSO8kqPVik8jYmxCC0=; b=fFdHwRdaFsEXVjXp87CEv1Oqul Bpp0L1EHUAYNYqzXxNj9vM0jUIRLAUDUUGSlFn4GP/sgS9NQQyBWiw+3pG8z6NTzXFnfJHQbOH5BQ 4+MpuptYQ1v4B9tvrL725iTQcepQy6nycG7kzh5XHmd2HBlbzGX6vjKZiX1PuyrqzcUI2yLGDZaUa Duy06dYSuMQ1+/6ZMKf5Vga9Fg/dVB8Mc4qohMyshZkG+fwXrhKbXpg9Gie2f3lzieQs0qoO6M8nZ CGxb4mpILFhxfaWeA5qOGCkPwFdJZbem7otf8uEsYIjz9lJb4XqxUoOUvIOqm+f7Ww0Wh05SaL6TF IogbSPCg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgeZd-001mIw-AK; Wed, 12 May 2021 02:26:09 +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 1lgeZY-001mIX-A2 for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 02:26:04 +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=NFXf1SUAkReC3MtaV1k9mib3TBX01qLYNs8RqJ8r1VY=; b=WFDDSupi6YfqkxpAoSYisNRxdh 12oOFNpxSC8y2YK2JzG2E4HlHk0Pdo0Skl0Zea5twW3fSI+9vwQlZFIzGkT2iDOsMEbAecFCqYSs0 YRazomtQsGrLpM51A+YH/7aiG3A1W8lMpow1gVbFxWvS61+MHOzoKqIii5gRu9MpG2/hUQ23tBgxN kIUiCg+s+F3J/CzxIYpYD3y8A+xHnXvIvGmabb+PkckUvHtMs8cwGJMLysfzURaTea8SpaxUdYjKa on0QTgFwNG7wwurvdto/bOuB6rp97bKhPMQruEMBH1XNSAA24FJ+KjyJHAzPDQluv4bkeqibHhDwJ EqgYogTQ==; Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgeZV-00A3Cc-PD for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 02:26:03 +0000 Received: by mail-pl1-x62b.google.com with SMTP id t4so11765872plc.6 for ; Tue, 11 May 2021 19:26:00 -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=NFXf1SUAkReC3MtaV1k9mib3TBX01qLYNs8RqJ8r1VY=; b=WDry/cE9LcDDsvZONla927KdK58kdOq5cMvJBpA/+C5Roqpjz/q/YVsY9EPXO1hhfr K5wljKBiFwRzt19KANN0iSIz1JSgxbM1OGBwg4wa3rYfw3xFn6/zmE1hmjPB4jCpCQNH qgw/AdJ0gSIPx9mIWLjg3MP7RbYX1IU3BnB3U= 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=NFXf1SUAkReC3MtaV1k9mib3TBX01qLYNs8RqJ8r1VY=; b=j4/il6QMFykC7NCS9bbY4/oh7r2AxYCZvG7TMCsn4vqTxZreRKJkXc3QaM1oNi4rlW OSO2CaH2XhOlLBJp9Cbi4v8vmzTFT2qF5Sjh6paPYfBxXtwwhHNI705iqSP09YrEpNdX e55zMx1yldix8jHD6n1Mp8Q5+ADifHxOoMUc8NAlvl/Nze5GZdZpdNmomELwNqydGSOa P5XYdlt4CXjMWjSNh0LuJs1uMhhIOIRJDpjl0P2QXY71ID+qsW9t3UTcpU0nXDwLsbII YLMNeu9yeIeDPh0f2048Y7k2Xebl+a+yYUW+lRE2x+KklGFeHA6LhQB4K3Lz/R2ktRut 8fzQ== X-Gm-Message-State: AOAM5334/R8zVFR6pLTnnLJU8yrOCL8+FcuDCcwwkInoKNYBmbkJwnNS h1Cygxzwc3HffK8zovJg3G6xGTWo6dcX9g== X-Google-Smtp-Source: ABdhPJxZh9XbVa0O5QvQA3ScydCZHBQ1k/eVLELOoCUCninL/YfEiRK9LcXbyUUwaKWXqBq1ffFctw== X-Received: by 2002:a17:902:b183:b029:ee:ff72:f580 with SMTP id s3-20020a170902b183b02900eeff72f580mr29650246plr.26.1620786360149; Tue, 11 May 2021 19:26:00 -0700 (PDT) Received: from evanbenn1.syd.corp.google.com ([2401:fa00:9:15:83b5:4bca:90bf:147c]) by smtp.gmail.com with ESMTPSA id t10sm11716797pfq.68.2021.05.11.19.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 19:25:59 -0700 (PDT) From: Evan Benn To: Daniel Lezcano , Matthias Brugger Cc: LKML , Fabien Parent , Viresh Kumar , Yingjoe Chen , Stanley Chu , Julia Lawall , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Evan Benn Subject: [PATCH v4] drivers/clocksource/mediatek: Ack and disable interrupts on suspend Date: Wed, 12 May 2021 12:25:44 +1000 Message-Id: <20210512122528.v4.1.I1d9917047de06715da16e1620759f703fcfdcbcb@changeid> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210511_192601_836369_129CFD2F X-CRM114-Status: GOOD ( 14.19 ) 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 v4: Fix the comment style. 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c index 9318edcd8963..ab63b95e414f 100644 --- a/drivers/clocksource/timer-mediatek.c +++ b/drivers/clocksource/timer-mediatek.c @@ -241,6 +241,28 @@ 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 +308,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);