Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp548280pxj; Tue, 18 May 2021 09:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt4PDVYRwL12F6gF0vfBSNoZOOd3QKT9o0oo4C3OmfpS5tXko+rYbf3rxKnsQXilhn7iaJ X-Received: by 2002:a17:906:2596:: with SMTP id m22mr6918411ejb.175.1621353765642; Tue, 18 May 2021 09:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621353765; cv=none; d=google.com; s=arc-20160816; b=lurbTk51HezvoNshco6OBcOVObGGN26wmXf6wdTz8jgz77V37S7AptU5QPg/G6RG1O CwG9JCc9LGEJEoSuPXldvBO4k6RA3YWh4p5/55IG1GXV7llYcjOB3m3T8s54AmR3wWYb 9AVmbGYnHKWOCpyXAnWlFa9Sd+Bjyo3rCmomwuKIozPqlQZkQHpKAl+koCkx6xgLzd68 DKyDCyK+728ebRHk4hIJlblPRloTmMpcOF6S/+1BC0w5ThhtMRUpXAD8RY2v7+gnI4/M sd6R0CbdzN0zXdyDfoWjLs22icKj4DP5DuSI0Y5zCEWJTwz6YsRIzjnROofAc8OKV/XA Jn3w== 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=roB+oWsFCAqK0nR4uy/jYkrl8YiAdBrDvuYJBs4+03P9Gphjd8D0+HvAH5QgGnHJI+ r2dVxz8vY6qiWucAMqqbfvXQtrC0d9o8PAUXlBZQTVhKGORjchzz/Z4Lw6gRBdU2LfDv gZ5TASmRIT9m3w/eNNga+JDlun3L838F1fGz3hZgX65rsPooRteIlcLuM4I/n21bUnoi /oIheqQ35d9/EbssdKugxrwEiedNBR1bgnZFvU/nP6De0mk/y9Y3URkHACpaGF1V8/q9 n04zonX4AcqApMBFkAlJMinTfCnFaMQxzsi5F/WDsZY+DKyibwsQQg7nqtyO6i/HIkDL Iz+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MUKF8GIg; 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 b22si11800098edw.115.2021.05.18.09.02.20; Tue, 18 May 2021 09:02:45 -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=MUKF8GIg; 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 S1344761AbhEQP7x (ORCPT + 99 others); Mon, 17 May 2021 11:59:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:52064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343954AbhEQPkD (ORCPT ); Mon, 17 May 2021 11:40:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75C4C61554; Mon, 17 May 2021 14:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262498; bh=nr3DIadgRhyKZCDLi1pOFobQNv/FUqmsYyPOqkzvbgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MUKF8GIg0wnDpTjrapE6+Yn3BmFR+Cz27YuKyAn3hcgsQr7yHaLJfpscvjTxBP81/ 11zYA86f1tfCMHmk0mfmxdJjpuAIdeDKvRZ6EWhuVy81ZiWI1viQ8tD16/x93W1sFy nDO/h0HMbqEUrRSPnG+v9HkrWzyDHNesJaoGpTzU= 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.11 307/329] clocksource/drivers/timer-ti-dm: Prepare to handle dra7 timer wrap issue Date: Mon, 17 May 2021 16:03:38 +0200 Message-Id: <20210517140312.467782107@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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);