Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp669486pxj; Tue, 18 May 2021 11:26:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqpl5n8KXBzbnU1vJOjA3TtmurukmE52qA0DiyKW9Mr+g2BysH20PxTKWzlQa+ZQH0yA2K X-Received: by 2002:a17:906:7f09:: with SMTP id d9mr1119614ejr.145.1621362360795; Tue, 18 May 2021 11:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621362360; cv=none; d=google.com; s=arc-20160816; b=o00EQPC/qZI9lON3osSIFo/KZBqeAdVOxkJoSIj0lD5qjGbCcz3K0iFozp8zIgfga3 6I70qcCb9r83RYvgI4VSbxrPU7jw/itmbVEpDoe9QJUGL2r6rWpKii26q0y7TKF6ex40 2cZRcv8e3BEAv531bAhfHANArHfSTyJbmKChTsQMnjeyiOHxIBqLRuYmIFhEn4ODVzg/ iVy1gvFBYZeH3tJY58oV60AnIR7ud7n8sqnTaN6nQhBcPNH6dFXI7hN596vlGetACFfh ZWNyfx8iVun0KQzNU+hti4GeqzBYRSujyEPjXymyE7VGasPdwVboA9SKnW/2Ch4MAJEj pJUQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K8whJ13RlVrQAccgP744eWshgUFHST989UNYKegL2LU=; b=IS97w0+plKw7Mlan+bFX05pLYZsmpS5apQLlW0/jEIH5ZygerZmGoSONbpeNFaBNaa IrMdd331YgQCprzbJG34+5TyXNTzUBKzB2AfzdOlWzXd7Xf+OybS2udwetYhi78va2uY ZrTv0Y+V66h917rZNS1tvqsAm6erA2pcLhMXpwAEchdQNEULcP/YabBCO5uw+99t6XeT 4EB+sZ4IMce4MH3F3TJ2WXZz3iMmLphEaUS7gsVJg/5jD7JeaLm/+YjjdRH+vsC21ymR a24VQrhFZVGAhyQJTd7v53bg+ulak0ggqcprcUJGeuwX2KPbdcylgF0B/OaKTHF3Xyhr ftBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pjO0G9ff; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si18103540ejc.334.2021.05.18.11.25.36; Tue, 18 May 2021 11:26: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=@linuxfoundation.org header.s=korg header.b=pjO0G9ff; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347118AbhEQQPK (ORCPT + 99 others); Mon, 17 May 2021 12:15:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:46278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242882AbhEQPun (ORCPT ); Mon, 17 May 2021 11:50:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D3AB61440; Mon, 17 May 2021 14:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262756; bh=nr3DIadgRhyKZCDLi1pOFobQNv/FUqmsYyPOqkzvbgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjO0G9ffw6HTICxyTs2fAhFawBGjAi6VoSFXQbtEKjNmdsDgWYhMG9SKyitVOdnjy 5mNg/39lNZfj7y3mKwlxnnVtdgvwpi7pgnZQz/3XHRHaEnbR6D9LjvLQeL2dFWpSQS UujB+6IYyuNYyPAhhl56207nxBEwDhkkFOvYibAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lindgren , Daniel Lezcano Subject: [PATCH 5.10 269/289] clocksource/drivers/timer-ti-dm: Prepare to handle dra7 timer wrap issue Date: Mon, 17 May 2021 16:03:14 +0200 Message-Id: <20210517140314.202256252@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Lindgren commit 3efe7a878a11c13b5297057bfc1e5639ce1241ce upstream. There is a timer wrap issue on dra7 for the ARM architected timer. In a typical clock configuration the timer fails to wrap after 388 days. To work around the issue, we need to use timer-ti-dm timers instead. Let's prepare for adding support for percpu timers by adding a common dmtimer_clkevt_init_common() and call it from dmtimer_clockevent_init(). This patch makes no intentional functional changes. Signed-off-by: Tony Lindgren Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210323074326.28302-2-tony@atomide.com Signed-off-by: Greg Kroah-Hartman --- drivers/clocksource/timer-ti-dm-systimer.c | 68 ++++++++++++++++++----------- 1 file changed, 44 insertions(+), 24 deletions(-) --- a/drivers/clocksource/timer-ti-dm-systimer.c +++ b/drivers/clocksource/timer-ti-dm-systimer.c @@ -530,17 +530,17 @@ static void omap_clockevent_unidle(struc writel_relaxed(OMAP_TIMER_INT_OVERFLOW, t->base + t->wakeup); } -static int __init dmtimer_clockevent_init(struct device_node *np) +static int __init dmtimer_clkevt_init_common(struct dmtimer_clockevent *clkevt, + struct device_node *np, + unsigned int features, + const struct cpumask *cpumask, + const char *name, + int rating) { - struct dmtimer_clockevent *clkevt; struct clock_event_device *dev; struct dmtimer_systimer *t; int error; - clkevt = kzalloc(sizeof(*clkevt), GFP_KERNEL); - if (!clkevt) - return -ENOMEM; - t = &clkevt->t; dev = &clkevt->dev; @@ -548,25 +548,23 @@ static int __init dmtimer_clockevent_ini * We mostly use cpuidle_coupled with ARM local timers for runtime, * so there's probably no use for CLOCK_EVT_FEAT_DYNIRQ here. */ - dev->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; - dev->rating = 300; + dev->features = features; + dev->rating = rating; dev->set_next_event = dmtimer_set_next_event; dev->set_state_shutdown = dmtimer_clockevent_shutdown; dev->set_state_periodic = dmtimer_set_periodic; dev->set_state_oneshot = dmtimer_clockevent_shutdown; dev->set_state_oneshot_stopped = dmtimer_clockevent_shutdown; dev->tick_resume = dmtimer_clockevent_shutdown; - dev->cpumask = cpu_possible_mask; + dev->cpumask = cpumask; dev->irq = irq_of_parse_and_map(np, 0); - if (!dev->irq) { - error = -ENXIO; - goto err_out_free; - } + if (!dev->irq) + return -ENXIO; error = dmtimer_systimer_setup(np, &clkevt->t); if (error) - goto err_out_free; + return error; clkevt->period = 0xffffffff - DIV_ROUND_CLOSEST(t->rate, HZ); @@ -578,32 +576,54 @@ static int __init dmtimer_clockevent_ini writel_relaxed(OMAP_TIMER_CTRL_POSTED, t->base + t->ifctrl); error = request_irq(dev->irq, dmtimer_clockevent_interrupt, - IRQF_TIMER, "clockevent", clkevt); + IRQF_TIMER, name, clkevt); if (error) goto err_out_unmap; writel_relaxed(OMAP_TIMER_INT_OVERFLOW, t->base + t->irq_ena); writel_relaxed(OMAP_TIMER_INT_OVERFLOW, t->base + t->wakeup); - pr_info("TI gptimer clockevent: %s%lu Hz at %pOF\n", - of_find_property(np, "ti,timer-alwon", NULL) ? + pr_info("TI gptimer %s: %s%lu Hz at %pOF\n", + name, of_find_property(np, "ti,timer-alwon", NULL) ? "always-on " : "", t->rate, np->parent); - clockevents_config_and_register(dev, t->rate, - 3, /* Timer internal resynch latency */ + return 0; + +err_out_unmap: + iounmap(t->base); + + return error; +} + +static int __init dmtimer_clockevent_init(struct device_node *np) +{ + struct dmtimer_clockevent *clkevt; + int error; + + clkevt = kzalloc(sizeof(*clkevt), GFP_KERNEL); + if (!clkevt) + return -ENOMEM; + + error = dmtimer_clkevt_init_common(clkevt, np, + CLOCK_EVT_FEAT_PERIODIC | + CLOCK_EVT_FEAT_ONESHOT, + cpu_possible_mask, "clockevent", + 300); + if (error) + goto err_out_free; + + clockevents_config_and_register(&clkevt->dev, clkevt->t.rate, + 3, /* Timer internal resync latency */ 0xffffffff); if (of_machine_is_compatible("ti,am33xx") || of_machine_is_compatible("ti,am43")) { - dev->suspend = omap_clockevent_idle; - dev->resume = omap_clockevent_unidle; + clkevt->dev.suspend = omap_clockevent_idle; + clkevt->dev.resume = omap_clockevent_unidle; } return 0; -err_out_unmap: - iounmap(t->base); - err_out_free: kfree(clkevt);