Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2225917imm; Thu, 18 Oct 2018 11:00:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV63G0v2j5WEpaPr+ich9UeQi2IMoNAii0gTfpIBpF/sjkZq+qC2PuLoP1VtBrIXTFPR4J7zE X-Received: by 2002:a62:cfc4:: with SMTP id b187-v6mr22651903pfg.249.1539885652524; Thu, 18 Oct 2018 11:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539885652; cv=none; d=google.com; s=arc-20160816; b=va9XwHq+zNaQHl1HoUe+ZaZcb7Es6Mt4c392Gz2M14XlnakVfPbt6g2a24KUF5xJe4 Z4LJTnfjanB5xJ7zEClQrMAdyAK9QAbuYMj92c6clOLKLni5YPu9qNDcamZAK+i2HtwK VXT1lzPfDpVBHQKP8GZSzeFgVjY0OjFcNlFDiRLDfAM7jSeXGlOeZwur3JRXcqjbc8/C XKStkP5shOAHjmNdm7lR/wBWbmDykeq53LJ0Yb+zhwW6DFiWQfaGQNtPzYhjU/SusmXU AvTjIIii6jNQ6h1HbGJWIWuuzvXvEDvoUiJwbaa9GrQRiFapLKrC9qZ+D12sfg5dv51O uKWQ== 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=En4UtLttHduefZ55PUafc+i/376LrWYIFjDGPEKR8Kc=; b=PKIBzTaeBivSATvuE5EeGjBfNqW1klbjcp6D+89jl2H2w4B+qyeTyKU/WuyX7TGr2a n8pyy9Eqpd5iYmAhIpaIeSyTQ1K2YlU+qJ9eTXXcwH+KzAosAAdivYKaBALt6N+NDNqg nl3FqPOGEdPdDx9yJ06pzEKgS9KzgGe9Ei9mMUT246vII0HC7kaCOQNCrhNx05ELQkDK DeHx/aADt6l9lo2aKq8l+CnLKzrZChsYw1JeAdpYswgnFgyNsx3dsfg1tABZr9QTSKJi gdT1RvMpSbBtjwQtqTtdx2xtXxCeyy0EJl7WWOs7pMDpTVv4pd5vR1RbqzGnGkjx0skW PsiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eYnZdyFR; 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 5-v6si23155955pfz.160.2018.10.18.11.00.36; Thu, 18 Oct 2018 11:00:52 -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=eYnZdyFR; 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 S1729238AbeJSCBg (ORCPT + 99 others); Thu, 18 Oct 2018 22:01:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728438AbeJSCBf (ORCPT ); Thu, 18 Oct 2018 22:01:35 -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 29BC921476; Thu, 18 Oct 2018 17:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885569; bh=WLNWUb0P5habQaZeWhmnf9AJATj5aKHbLJ6UKti3uc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYnZdyFR0AGEgZaqBg+mOoF1GPIybMdiXVKRLiYHxLasnW+whV5U0I6HgYMF6VZ1l mu06+mF+aelNfQXIjJAJypyMKl8QsadAkaohwmGIX+4IR6UbMPqoKEEQ7c3Q5XJ/0r iFb+qaxSSFn7vvF4AvHYFF6EOgxJ41yqsOOVTKUQ= 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.18 40/53] clocksource/drivers/fttmr010: Fix set_next_event handler Date: Thu, 18 Oct 2018 19:54:33 +0200 Message-Id: <20181018175423.415418195@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.561567978@linuxfoundation.org> References: <20181018175416.561567978@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.18-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);