Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2254009imm; Thu, 18 Oct 2018 11:27:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV62wdkQ/aRUiKeFCCmGGKORskCOqTScGRXx3OQVxOi/SF3zhbGpMgNQ5mY6o/xIUyjV5/48j X-Received: by 2002:a63:2d07:: with SMTP id t7-v6mr10343059pgt.260.1539887277866; Thu, 18 Oct 2018 11:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539887277; cv=none; d=google.com; s=arc-20160816; b=OZxjMpaxs9psjf4b8rF7iE28taEGLr6INhJzRdkrD8k+uqYdxq15q/t7k5cfZpgPvR gJ52OJTPE9HjxA3z4YgRytKxYNv294Mu//jajAqlilTZT3aWbv6lUh7BqYBIf41mMQNW L727T7cY4m+sfI+p6xooQJiOz6VOT30hL6tcDmx204NfeAfWUNm0JNhnBuZrYEdMvwsq HDu5FnEIeyiquk2/xN62z+yF+yL+oetx6oa+6LnQImS0NpyxvG95lvAo0EM6bcfZaLGv s7DWyVA4FbksaHlqj4DG9+uu6xgHwQyv9jq4g56K3N9RKNnurJQrRpSJEsy/B+fqaXy1 tCMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7jXfiAVE+pCTcQ6d7nvzvPtGxKxdC/80od2ZVrc2pTE=; b=MHrypQypOZYp9IWr73yqGLOCCOTi0XuBQWPga3VLYSjBVr3iWo/2FTj/oz8d/di23+ DycVM6pAqSEvEI2cDi8XgNzMUdmpVO0Ru+/V/YSby+qrhdbEDcMcHUknrubXqSDWH0Vn Dq3sc85Y0bY+iPw6aVbfn1JN2GjQ4c+OgHcA1s038Lm/554dVqIrZyTDXcozgdc8QhcO 5ziGd5PtkmQYgrKnUA8IAvN2+ncnfGXy54HgqUOIcDOiF0404kAPjfYYfQlZ9bmHn4qC X94ZP3ZYTAbGMychnlMCIotwzERM3mOWWix74G+EPHJIQ0oQKkgwplXS57XidxAocAfN vQ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fpy3IpH5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j134-v6si22888742pgc.134.2018.10.18.11.27.41; Thu, 18 Oct 2018 11:27:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fpy3IpH5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729085AbeJSCCx (ORCPT + 99 others); Thu, 18 Oct 2018 22:02:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:50898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbeJSCCw (ORCPT ); Thu, 18 Oct 2018 22:02:52 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AB96205C9; Thu, 18 Oct 2018 18:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885646; bh=77hvDowjz7rAVIZna4bdt+g6VhEtBpYV1d4AsVIWCb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpy3IpH5poRko3Y6KqooVe0NP62wnYBd3goB1fw72Sg0Kug/zkzIAk5EsvSbnXe0c sP/N0uRftK7XU5eMChSwW/d56jLWv6vWsGKmjRRc/DY63EIuo84B0rU6fqBKrhV5f0 lxqUwAqzr+tPPXh+JsT9hRHhY3IDbkeAl+FCaGAw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tao Ren , Linus Walleij , Lei YU , Daniel Lezcano , Sasha Levin Subject: [PATCH 4.14 25/41] clocksource/drivers/fttmr010: Fix set_next_event handler Date: Thu, 18 Oct 2018 19:54:40 +0200 Message-Id: <20181018175421.419733800@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.718399607@linuxfoundation.org> References: <20181018175416.718399607@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tao Ren [ Upstream commit 4451d3f59f2a6f95e5d205c2d04ea072955d080d ] Currently, the aspeed MATCH1 register is updated to in set_next_event handler, with the assumption that COUNT register value is preserved when the timer is disabled and it continues decrementing after the timer is enabled. But the assumption is wrong: RELOAD register is loaded into COUNT register when the aspeed timer is enabled, which means the next event may be delayed because timer interrupt won't be generated until <0xFFFFFFFF - current_count + cycles>. The problem can be fixed by updating RELOAD register to , and COUNT register will be re-loaded when the timer is enabled and interrupt is generated when COUNT register overflows. The test result on Facebook Backpack-CMM BMC hardware (AST2500) shows the issue is fixed: without the patch, usleep(100) suspends the process for several milliseconds (and sometimes even over 40 milliseconds); after applying the fix, usleep(100) takes averagely 240 microseconds to return under the same workload level. Signed-off-by: Tao Ren Reviewed-by: Linus Walleij Tested-by: Lei YU Signed-off-by: Daniel Lezcano Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/clocksource/timer-fttmr010.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -130,13 +130,17 @@ static int fttmr010_timer_set_next_event cr &= ~fttmr010->t1_enable_val; writel(cr, fttmr010->base + TIMER_CR); - /* Setup the match register forward/backward in time */ - cr = readl(fttmr010->base + TIMER1_COUNT); - if (fttmr010->count_down) - cr -= cycles; - else - cr += cycles; - writel(cr, fttmr010->base + TIMER1_MATCH1); + if (fttmr010->count_down) { + /* + * ASPEED Timer Controller will load TIMER1_LOAD register + * into TIMER1_COUNT register when the timer is re-enabled. + */ + writel(cycles, fttmr010->base + TIMER1_LOAD); + } else { + /* Setup the match register forward in time */ + cr = readl(fttmr010->base + TIMER1_COUNT); + writel(cr + cycles, fttmr010->base + TIMER1_MATCH1); + } /* Start */ cr = readl(fttmr010->base + TIMER_CR);