Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2168940imm; Thu, 20 Sep 2018 08:47:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbyLoSI85ZZTzyrj4BgHikp4DfJ/mykwYGuKZzPhtto5jHp60MJRHZX99bvD89pOBFLi/YR X-Received: by 2002:a17:902:4201:: with SMTP id g1-v6mr40478201pld.203.1537458419988; Thu, 20 Sep 2018 08:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537458419; cv=none; d=google.com; s=arc-20160816; b=GiP2gdDZe4pzkNJMIaYWGNUlqvEnMSmmFAbm5kJYwmZIN2UNRaPbT+Vx1uqV0gW73Y x+/zcRmSmgU/QkKEvKvGFoePGfDtV8c4p6idfBV+h2oTu0oH/Z1IdfiWehleaLZbMFBs dkLzqAfyO5Hcq91gU+Iy4FT8je6btXgUXLdPXNH6qezr6d3zyRuXtn4/3/cFysMRJsHU ll5C9Fk2ed6vjZrG5hY0sqjOVoWdnUz5fdAwbIFvc/yL9Cmr+mbpyerkEOjz7OhM7TF/ 0b+/uY+l813gyuFnLGjI4F1jD7mikbGjcIp0FWcYBEIdFgoNpZXCZI/GGGwN3kL/NgGx wFEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vB6icuBZtONcdJE81OTynlGpnhhW6fzCbvvtxe8DkLI=; b=rPHBSMdItyr1d/Dzsa1d4wioF/YV3uCZpd73ZnTAWLsr8VAs0JTNqstQKOoYo/frCI u+gzstxn6Vq6fDXJrfB5kLCWb89mnV/81JK+MnexdTJBn0o9xAvyHgc3vSL1EvpwX8rr 0Hc2JWWQY3qCr14F5sM/FvayMO0pOZqXhmzGUzxB8XYL7Qp71BwHOlGS9Ixbsn77sot0 4wOqkJ3OvsJIusCLiRIugErqvKstrTIc/u3yMmSJJgv0Des1FGweY20ujShVsYgygq3t b55VZbBKE0/4YT01Lq4fYBGjH8Hp/sYsbKRTh9yWygAdbRtDcvxLjVn3kZBlWJCLDZY/ 1+8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WrMQau+B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65-v6si26238215pff.196.2018.09.20.08.46.44; Thu, 20 Sep 2018 08:46:59 -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=@linaro.org header.s=google header.b=WrMQau+B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732884AbeITVaP (ORCPT + 99 others); Thu, 20 Sep 2018 17:30:15 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:56197 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728444AbeITVaP (ORCPT ); Thu, 20 Sep 2018 17:30:15 -0400 Received: by mail-it0-f65.google.com with SMTP id d10-v6so13747842itj.5 for ; Thu, 20 Sep 2018 08:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vB6icuBZtONcdJE81OTynlGpnhhW6fzCbvvtxe8DkLI=; b=WrMQau+BpefXqQvP07/ruh3mFJYJ552mcL7eohJuW3DQgykWBte7Sx3S6iVe2MdcIz a/kGDNkIQXQThGpVpGpwZak6XNFq8LeOuCJyuYlDDEfdimvURc728JQ57gSBfEGAECiL 0z/MyE45UEAIB+e0goCCysvdkb4tkg+Co9sbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vB6icuBZtONcdJE81OTynlGpnhhW6fzCbvvtxe8DkLI=; b=BNon0doY18JsS4Jy3JXm81AUWBVt/5d0ER2V/pZwKI3tOlOx4YhrrUlUK8K2rfEQFr ey9zCQd1BTM5231pBWa3zQ51/fbPG2o1CQjR3JHg7KI13Qbd2vvg4YIFkfB0xnq1rQ39 2y3fvT2VSaR3YxmqYxmJEX0o7qVZD9ISBIGF5Z8nT/8cNewbMQx+Y0Vc0MAjyoVedpYI NLs+YSeKSv/kuMwPFS1aUZ3x3j3674RZK5OPcOqpl5JUE4YHMbsV31tm3lDnuMzedq0Y 4qK9WwPjBXsMjF685dYvQjQEhYstXVoFaYxBP093cORy+a72HlN9wJ3XQFhTo9epph4X B/yA== X-Gm-Message-State: APzg51A3NiBvL4OaYodUJKswCk2JjKBEPodWpqrCutkX6FHoDEw1pfVS dy3PwbI/Jp3CuVA8DG8rbJDaku/2cnWBsaBG5TSfhA== X-Received: by 2002:a24:7605:: with SMTP id z5-v6mr2440285itb.62.1537458369879; Thu, 20 Sep 2018 08:46:09 -0700 (PDT) MIME-Version: 1.0 References: <20180919221331.2511558-1-taoren@fb.com> In-Reply-To: <20180919221331.2511558-1-taoren@fb.com> From: Linus Walleij Date: Thu, 20 Sep 2018 08:45:57 -0700 Message-ID: Subject: Re: [PATCH] clocksource/drivers/fttmr010: fix set_next_event handler To: taoren@fb.com, Joel Stanley , Andrew Jeffery Cc: Daniel Lezcano , Thomas Gleixner , "linux-kernel@vger.kernel.org" , OpenBMC Maillist , cov@fb.com, tfang@fb.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 19, 2018 at 3:13 PM Tao Ren wrote: > Currently, the aspeed MATCH1 register is updated to cycles> 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 Actually this is much more intuitive too, it is the typical way to handle a down-counting timer. Good catch! Reviewed-by: Linus Walleij Sorry for any cargo-cult programming on my part :/ Would be nice to get a nod from the AST2400 users that this works for them too, so included them in the To: field. I can't test it on up-counting hardware right now but I convinced myself it is handled just like before so it shouldn't be an issue. It actually would make kind of sense to restart the up-counting timer from zero and set match to whatever value is passed in as well, so I might send a patch for this. It's no regression though so no hurry with that. Yours, Linus Walleij