From patchwork Mon Feb 24 05:07:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 11399345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A37414D5 for ; Mon, 24 Feb 2020 05:09:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29DD62080D for ; Mon, 24 Feb 2020 05:09:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Yjy7E5qm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgBXFJB (ORCPT ); Mon, 24 Feb 2020 00:09:01 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44670 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgBXFJA (ORCPT ); Mon, 24 Feb 2020 00:09:00 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01O58ndh043261; Sun, 23 Feb 2020 23:08:49 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1582520930; bh=Rl9mP7346FmUgsFlfQHPHIgoAbb44S30T/NYsb34Dok=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Yjy7E5qmMS0MMSI82l1zW2oECvnlG8OX2jdiJVNMjHm+oTMcFneIbnZEjocN4ypC1 lT+yvYAt2aUWeUL33vnkWp8b3Mb+FNRjiIBZbS3/oBtexSaF3lkqJcTokqoDHqf/f3 eepRFrePOoO8Ixp2nZrMs//LRezqWvN3Ip8Gd65E= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01O58nrW096125; Sun, 23 Feb 2020 23:08:49 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Sun, 23 Feb 2020 23:08:49 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Sun, 23 Feb 2020 23:08:49 -0600 Received: from uda0131933.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01O58g4o113272; Sun, 23 Feb 2020 23:08:46 -0600 From: Lokesh Vutla To: Tony Lindgren , Daniel Lezcano , Thomas Gleixner CC: Linux OMAP Mailing List , , , Sekhar Nori , Tero Kristo , Lokesh Vutla Subject: [PATCH 1/2] clocksource: timer-ti-dm: Do not restore context on every timer enable Date: Mon, 24 Feb 2020 10:37:52 +0530 Message-ID: <20200224050753.17784-2-lokeshvutla@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200224050753.17784-1-lokeshvutla@ti.com> References: <20200224050753.17784-1-lokeshvutla@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org omap_dm_timer_enable() restores the entire context(including counter) based on 2 conditions: - If get_context_loss_count is populated and context is lost. - If get_context_loss_count is not populated update unconditionally. Case2 has a side effect of updating the counter register even though context is not lost. When timer is configured in pwm mode, this is causing undesired behaviour in the pwm period. So restore context only if get_context_loss_count is populated and context is actually lost. Signed-off-by: Lokesh Vutla --- drivers/clocksource/timer-ti-dm.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c index 269a994d6a99..40742715ed21 100644 --- a/drivers/clocksource/timer-ti-dm.c +++ b/drivers/clocksource/timer-ti-dm.c @@ -229,15 +229,12 @@ static void omap_dm_timer_enable(struct omap_dm_timer *timer) pm_runtime_get_sync(&timer->pdev->dev); - if (!(timer->capability & OMAP_TIMER_ALWON)) { - if (timer->get_context_loss_count) { - c = timer->get_context_loss_count(&timer->pdev->dev); - if (c != timer->ctx_loss_count) { - omap_timer_restore_context(timer); - timer->ctx_loss_count = c; - } - } else { + if (!(timer->capability & OMAP_TIMER_ALWON) && + timer->get_context_loss_count) { + c = timer->get_context_loss_count(&timer->pdev->dev); + if (c != timer->ctx_loss_count) { omap_timer_restore_context(timer); + timer->ctx_loss_count = c; } } } From patchwork Mon Feb 24 05:07:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 11399343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B34AB14D5 for ; Mon, 24 Feb 2020 05:09:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92C6120675 for ; Mon, 24 Feb 2020 05:09:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BGFsWs+V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbgBXFJE (ORCPT ); Mon, 24 Feb 2020 00:09:04 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44680 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgBXFJD (ORCPT ); Mon, 24 Feb 2020 00:09:03 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01O58rcf043304; Sun, 23 Feb 2020 23:08:53 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1582520933; bh=Pw+D2a+3OphgFS87lvewjCiL6zcqZD5p3bEKHdKJQPY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BGFsWs+Vf5TCmMo+FWtOa9Qwa/bfmLzFs8GLypVP1OoZSlxq0b/WY4TZ35uud2uIv kEXpnyt5VeqNGuQARTkdzn6HhT0JXO6lnCq6KMXeGZI1ZGwXpdwWpS/ojkd1XqHcBz URVEXzBcu4aKPZXBji+RVOrSmtlCiA78tsWXCffw= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 01O58rSA072847 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 23 Feb 2020 23:08:53 -0600 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Sun, 23 Feb 2020 23:08:52 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Sun, 23 Feb 2020 23:08:52 -0600 Received: from uda0131933.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01O58g4p113272; Sun, 23 Feb 2020 23:08:49 -0600 From: Lokesh Vutla To: Tony Lindgren , Daniel Lezcano , Thomas Gleixner CC: Linux OMAP Mailing List , , , Sekhar Nori , Tero Kristo , Lokesh Vutla Subject: [PATCH 2/2] clocksource: timer-ti-dm: Do not update counter on updating the period Date: Mon, 24 Feb 2020 10:37:53 +0530 Message-ID: <20200224050753.17784-3-lokeshvutla@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200224050753.17784-1-lokeshvutla@ti.com> References: <20200224050753.17784-1-lokeshvutla@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Write to trigger register(OMAP_TIMER_TRIGGER_REG) will load the value in Load register(OMAP_TIMER_LOAD_REG) into Counter register (OMAP_TIMER_COUNTER_REG). omap_dm_timer_set_load() writes into trigger register every time load register is updated. When timer is configured in pwm mode, this causes disruption in current pwm cycle, which is not expected especially when pwm is used as PPS signal for synchronized PTP clocks. So do not write into trigger register on updating the period. Signed-off-by: Lokesh Vutla Tested-by: Tony Lindgren --- drivers/clocksource/timer-ti-dm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c index 40742715ed21..62b145ef3bb8 100644 --- a/drivers/clocksource/timer-ti-dm.c +++ b/drivers/clocksource/timer-ti-dm.c @@ -574,7 +574,6 @@ static int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l); omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load); - omap_dm_timer_write_reg(timer, OMAP_TIMER_TRIGGER_REG, 0); /* Save the context */ timer->context.tclr = l; timer->context.tldr = load;