From owner-svn-src-head@freebsd.org Fri Oct 25 15:47:04 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EFBAE174058 for ; Fri, 25 Oct 2019 15:47:04 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4707lX3cwkz4g80 for ; Fri, 25 Oct 2019 15:47:03 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1572018422; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=j1ULjZMjYS0stPqOs88zgFfnRUU2kWRw/81VqEqOBnFxwyS53A/l0vu3ylKaX4jDDiY27+6gGD36b im5UUeFIGtbnOvd9ZR6AstiKetCPYoIWwL1F0H3NOFwR+wAbmqD1m8ISNnIbaJnCpNEkk7DuqPQZat XgBqCEoCiUBUCS7pg/uYTXD1fk6Kh1UcxMrTBkuNt1vm7dCpERUrGkUQrwWKmuGh5CthZwB21ZaYue RCt8IZHIiWK0CXG9cElK2iqiGEc7teqEtBrhnGn8ehS9UTcj98IV/cOHRJrVdahd+lC6GNAkx17Xzu pZW3aI0VFKLDCeOYs8guqaVZVVolmUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=DeOvwX+j/vkqLTfZ6ysoPHwoQy3ark/1CetsbHtK/mM=; b=Ru8PD816A3mcPR195/iBt5mMGOBRXWKAyeNNIwgZ6hDqFTRNK12IRAUMqcZf3G0rNDWK+v47JSOBq vpzco2dzvdke9uOsfByIaCylbc2fFxyqIZ7wY/H552PXsEf9R/3FehgttLpA2cw4Jg3VKhbAoPuqqq zmQGxOE2TnXTsaJw2WSswjy65O9GcK5wovaFLlRAn0twy5jzr1jss2gedcmdnBic4Lq1AnmOwU2quO KHhpBE8wqee8tSRmiab5MynVNSqFfnIkWSsss3xsfoZaZrMsyEt2yXPREu45+kV/IXoOeUwB0+dqGT uw0IQlRyReZFeG5ZA+1yeLIn4xk0lDg== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=DeOvwX+j/vkqLTfZ6ysoPHwoQy3ark/1CetsbHtK/mM=; b=QIQ56jbZDknrHD6EDIibIZNIoXU2tozx7+y/Doo0CQHWfyJ8XcwKc7e2pjildBPBa2AkRaZjm2sR/ m36W7AZH0F+jPNwXpBhx/pteh3bC6eXJTgiRXlhpkLuezFKzK+p4vixzBjmyZO5ygqdD5/KO3heMPd VB7Yg3VoapCATIBytDau9tOPGRRlbk2VWXiS/1ppmmaUqftgtjmrNPxVjFpjqftIZ7KTxQsyoeCTeQ eiX9odOF//EA/Q3UaVd/ky6BjnJC452TCAdr3v475PdcTb0BUN0K0ZvNSE35jHDbarXieAqHDdr5SI OIC2+q3yDuWpmel/QvPlrG3o8EvnUHg== X-MHO-RoutePath: aGlwcGll X-MHO-User: ae8f26c1-f73e-11e9-b80b-052b4a66b6b2 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id ae8f26c1-f73e-11e9-b80b-052b4a66b6b2; Fri, 25 Oct 2019 15:47:01 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x9PFkxJQ049685; Fri, 25 Oct 2019 09:46:59 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: Subject: Re: svn commit: r354076 - head/sys/dev/ow From: Ian Lepore To: Andriy Gapon , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Fri, 25 Oct 2019 09:46:59 -0600 In-Reply-To: <201910251538.x9PFc9ii028313@repo.freebsd.org> References: <201910251538.x9PFc9ii028313@repo.freebsd.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4707lX3cwkz4g80 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.89 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.89)[-0.892,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 15:47:05 -0000 On Fri, 2019-10-25 at 15:38 +0000, Andriy Gapon wrote: > Author: avg > Date: Fri Oct 25 15:38:09 2019 > New Revision: 354076 > URL: https://svnweb.freebsd.org/changeset/base/354076 > > Log: > owc_gpiobus_read_data: compare times in sbintime_t units > > Previously the code used sbttous() before microseconds comparison > in one > place, sbttons() and nanoseconds in another, division by SBT_1US > and > microseconds in yet another. > > Now the code consistently uses multiplication by SBT_1US to convert > microseconds to sbintime_t before comparing them with periods > between > calls to sbinuptime(). This is fast, this is precise enough (below > 0.03%) and the periods defined by the protocol cannot overflow. > > Reviewed by: imp (D22108) > MFC after: 2 weeks > > Modified: > head/sys/dev/ow/owc_gpiobus.c > > Modified: head/sys/dev/ow/owc_gpiobus.c > ===================================================================== > ========= > --- head/sys/dev/ow/owc_gpiobus.c Fri Oct 25 15:02:50 2019 (r354 > 075) > +++ head/sys/dev/ow/owc_gpiobus.c Fri Oct 25 15:38:09 2019 (r354 > 076) > @@ -296,10 +296,10 @@ owc_gpiobus_read_data(device_t dev, struct > ow_timing * > do { > now = sbinuptime(); > GETPIN(sc, &sample); > - } while (sbttous(now - then) < t->t_rdv + 2 && sample == 0); > + } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0); > critical_exit(); > > - if (sbttons(now - then) < t->t_rdv * 1000) > + if (now - then < t->t_rdv * SBT_1US) > *bit = 1; > else > *bit = 0; > @@ -307,7 +307,7 @@ owc_gpiobus_read_data(device_t dev, struct > ow_timing * > /* Wait out the rest of t_slot */ > do { > now = sbinuptime(); > - } while ((now - then) / SBT_1US < t->t_slot); > + } while (now - then < t->t_slot * SBT_1US); > > RELBUS(sc); > Unit conversions with sbt times should be done using the macros that carefully avoid roundoff errors. I don't understand why you've changed the code that correctly did use those macros to inline math. -- Ian