Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4716610pxj; Wed, 12 May 2021 11:34:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCfKUolV1Phi/HiKPofzB2pWYZZpGLQ0/T/gmmgUm1nedUB/GVPVNLDLbLTtDBdcs25jTX X-Received: by 2002:a17:906:4ad0:: with SMTP id u16mr39134939ejt.19.1620844384101; Wed, 12 May 2021 11:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620844384; cv=none; d=google.com; s=arc-20160816; b=sfkwXUkLGIhNvwg6nQkBgB+gGlbnoCi8uX029BQF2KIvmLgyLIw1o9RGnTEg4o4Fev vuOv2B03qjl6JCL13gx6/lGP3QMeTJsaRw6Iun9y14z+xalz5einejvGMeOuUwnV7vGY HqqwZv0AmDMZnGoKjzi9HEsecy1t2FZmdmOaF18UcXX4Z4tjte83OpB+VYzAKq3CY/nH /Mn8axFcSb11pcCaulORRyzEcz9L1PaCYY2ovsst1AfnEnFjNOpnuYCxNuZeiwLm0uKC a4KB9Q3b2/En3XuhwefXMfW4XEOgRq1ho/DfmmQ+CXlidsu4lhpyDSoRmRRaMnmO7NPl hF9g== 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=6fQ4r2Q41pkrGm7XoRAp4mYpbJTrh0rsbjSe6IlGnSo=; b=ODFfLvxGQ6w4hlbGlWrDy5rCq2tRP+KGTQQIbDpLpq3t+O1scJ5uyon2CIkoesIotj VK8gxkTZW4VIfjXc7m54ET5JhYIzzZ4p7CCxtWVR8lDN+g3sHKmXXWDUuICnlxbDmIvI U4+OQb8nLIiqvlbx5l+VV7LPG9wR/qLQ3SOJgNtMunAeDop1sB50zlFDb8x21tImBwMV +sFHYSuNCTJ8cT9Z6+JL+pxJyb7nRCLf1+TybvDiEIM9f00F5kLac6rL0K4NGFrLRbDe NIR7S8sBfhk/rvtqa1XbJCpzY2oKx/43r9iutghLH+QcaDjYqTiVu5x0B9jAN9Ink7dP E1hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ug3YRo8t; 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 ov24si658881ejb.375.2021.05.12.11.32.40; Wed, 12 May 2021 11:33:04 -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=Ug3YRo8t; 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 S245377AbhELSbW (ORCPT + 99 others); Wed, 12 May 2021 14:31:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:57038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243136AbhELQgw (ORCPT ); Wed, 12 May 2021 12:36:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E3E761E0B; Wed, 12 May 2021 16:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835258; bh=iskjLq3stQY6pW14znA3uT5yirChRDox2RZ7J4dGAQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ug3YRo8tWREHR46jx65ok4bx2CzCjqo+/SSviqb3dLSzfYDtcDjer8wETH+KHJ6Oq CN9cD9p3mrVV3JelPn9p7YirMCCfoCvrBilXuiNkZxMgGz67nSIVKUjI8rEkY+SUtT P7jHtIhGYkgidoThmxdULdj4OkIWRMyYAc3WXbX8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lindgren , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.12 272/677] clocksource/drivers/timer-ti-dm: Fix posted mode status check order Date: Wed, 12 May 2021 16:45:18 +0200 Message-Id: <20210512144846.261072130@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 [ Upstream commit 212709926c5493a566ca4086ad4f4b0d4e66b553 ] 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 Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210304072135.52712-2-tony@atomide.com Signed-off-by: Sasha Levin --- 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 index 33b3e8aa2cc5..422376680c8a 100644 --- 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.2