From nobody Fri May 3 02:50:21 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1509547297673322.9880257617383; Wed, 1 Nov 2017 07:41:37 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1e9uCm-0007ml-OL; Wed, 01 Nov 2017 15:41:20 +0100 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1e9uCW-0007l3-Fy for seabios@seabios.org; Wed, 01 Nov 2017 15:41:19 +0100 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA1EYgfX055701 for ; Wed, 1 Nov 2017 10:41:02 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dyg4u8chr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 01 Nov 2017 10:41:02 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Nov 2017 08:41:01 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 1 Nov 2017 08:41:00 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA1Ef0Cj4063648; Wed, 1 Nov 2017 07:41:00 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0813EBE03B; Wed, 1 Nov 2017 08:41:00 -0600 (MDT) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id AAEA7BE039; Wed, 1 Nov 2017 08:40:59 -0600 (MDT) From: Stefan Berger To: seabios@seabios.org Date: Wed, 1 Nov 2017 10:40:57 -0400 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 x-cbid: 17110114-0008-0000-0000-000008CCAF24 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007992; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00939622; UDB=6.00473740; IPR=6.00719883; BA=6.00005666; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017822; XFM=3.00000015; UTC=2017-11-01 14:41:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110114-0009-0000-0000-000044976E0F Message-Id: <1509547257-1652-1-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-01_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711010202 X-Spam-Score: -6.0 (------) Subject: [SeaBIOS] [PATCH] Increase precision of usec timer calculation X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When timer_calc_usec() is used with large timeout falues, such as 60s, the function lacks precision and produces different results than when using timer_calc(time / 1000) for the same timeout. This patch fixes the precision issue by falling back to timer_calc(time / 1000) for usec values over one second. Signed-off-by: Stefan Berger --- src/hw/timer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hw/timer.c b/src/hw/timer.c index 03d22b2..2f0c864 100644 --- a/src/hw/timer.c +++ b/src/hw/timer.c @@ -213,6 +213,8 @@ timer_calc(u32 msecs) u32 timer_calc_usec(u32 usecs) { + if (usecs > 1000000) + return timer_calc(usecs / 1000); return timer_read() + DIV_ROUND_UP(GET_GLOBAL(TimerKHz) * usecs, 1000); } =20 --=20 2.5.5 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios