Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1264690pxb; Thu, 4 Mar 2021 07:20:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4r6SzbVnt17jWesOQb1ixZFD4Di4hpRgiMa2CB9wY2CV6r2ZC1LlgwrwQzt4QfUlb5S0+ X-Received: by 2002:a05:6402:26c9:: with SMTP id x9mr1063066edd.322.1614871238579; Thu, 04 Mar 2021 07:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614871238; cv=none; d=google.com; s=arc-20160816; b=zN7Rm65S6rOrp5Mhe8TiQrzdkQN0dcxYkFn8pEXR2yn2PyU+k7wRi9vdMxN6ObPz5Z lBgeyqA5TbI/WDEEw8stcb8Sjt1ssDoDs5cdsocK+jZzeOP9Kztb2am5Q4hlRwimkZn9 6uzLxQelvitMcOv4Nzic6qZxJDx6zW0RhLgIDGnQPAgaSCqAPsUVqGSmn30D9HQLlqBU xLwLBycgV9wov6ZASZvjmyhvCKHNt2poaMiIwbe1fUpzXZRZCffm6iVrViDJNGBaH79d Lg8Tt4XU6YNtE1Mj03gh+So+ADQM2VMI/tfYmF2Fld4CHYhLMrkFPNdN8J8iv6De8Q/d FUpw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Le4eAuGnrwHYJlG96E+YIfZnUhQbxMyYIAzbfJRkkoo=; b=TIKOD8+eUcAiWRVB8ijlD+gtM+AxaWGKl17lgrNu4wI4Luvf6zk7kKcBMbeCgRR2QA YIrpqtNeWjMlH9d6jKSewcIIttp5nCoJHRdAUoA+/hfMmvin93YBnUB+3JVK3K29L/m5 RYcii0IrImW4BchG+AfGD+uhUiZnkkR2GDO/xzIUvoxJI8QTIyGPwxuJnHcE5fW+Xw5l LnJJH1ldNwRD08DZiXgG9RNIAWLSWs4u4zn0rX3ACS8jeS6uhqrVqoKr+1B1pPZyZuo5 Wy228ZnPmh33bCma3ULZ2AwGMAPQbwYQ7TaQlu4SUa7QnPW8oI6ao7AS2UxhrBpAuNI6 n9eA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si8285872ejb.380.2021.03.04.07.20.14; Thu, 04 Mar 2021 07:20:38 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236244AbhCDHWi (ORCPT + 99 others); Thu, 4 Mar 2021 02:22:38 -0500 Received: from muru.com ([72.249.23.125]:39278 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236204AbhCDHW0 (ORCPT ); Thu, 4 Mar 2021 02:22:26 -0500 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id D012C810E; Thu, 4 Mar 2021 07:22:23 +0000 (UTC) From: Tony Lindgren To: Daniel Lezcano , Thomas Gleixner Cc: Keerthy , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] clocksource/drivers/timer-ti-dm: Fix posted mode status check order Date: Thu, 4 Mar 2021 09:21:33 +0200 Message-Id: <20210304072135.52712-2-tony@atomide.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210304072135.52712-1-tony@atomide.com> References: <20210304072135.52712-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the timer is configured in posted mode, we need to check the write- posted status register (TWPS) before writing to the register. We now check TWPS after the write starting with commit 52762fbd1c47 ("clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support"). For example, in the TRM for am571x the following is documented in chapter "22.2.4.13.1.1 Write Posting Synchronization Mode": "For each register, a status bit is provided in the timer write-posted status (TWPS) register. In this mode, it is mandatory that software check this status bit before any write access. If a write is attempted to a register with a previous access pending, the previous access is discarded without notice." The regression happened when I updated the code to use standard read/write accessors for the driver instead of using __omap_dm_timer_load_start(). We have__omap_dm_timer_load_start() check the TWPS status correctly using __omap_dm_timer_write(). Fixes: 52762fbd1c47 ("clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support") Signed-off-by: Tony Lindgren --- drivers/clocksource/timer-ti-dm-systimer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c --- a/drivers/clocksource/timer-ti-dm-systimer.c +++ b/drivers/clocksource/timer-ti-dm-systimer.c @@ -449,13 +449,13 @@ static int dmtimer_set_next_event(unsigned long cycles, struct dmtimer_systimer *t = &clkevt->t; void __iomem *pend = t->base + t->pend; - writel_relaxed(0xffffffff - cycles, t->base + t->counter); while (readl_relaxed(pend) & WP_TCRR) cpu_relax(); + writel_relaxed(0xffffffff - cycles, t->base + t->counter); - writel_relaxed(OMAP_TIMER_CTRL_ST, t->base + t->ctrl); while (readl_relaxed(pend) & WP_TCLR) cpu_relax(); + writel_relaxed(OMAP_TIMER_CTRL_ST, t->base + t->ctrl); return 0; } @@ -490,18 +490,18 @@ static int dmtimer_set_periodic(struct clock_event_device *evt) dmtimer_clockevent_shutdown(evt); /* Looks like we need to first set the load value separately */ - writel_relaxed(clkevt->period, t->base + t->load); while (readl_relaxed(pend) & WP_TLDR) cpu_relax(); + writel_relaxed(clkevt->period, t->base + t->load); - writel_relaxed(clkevt->period, t->base + t->counter); while (readl_relaxed(pend) & WP_TCRR) cpu_relax(); + writel_relaxed(clkevt->period, t->base + t->counter); - writel_relaxed(OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST, - t->base + t->ctrl); while (readl_relaxed(pend) & WP_TCLR) cpu_relax(); + writel_relaxed(OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST, + t->base + t->ctrl); return 0; } -- 2.30.1