Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1025196imj; Sat, 9 Feb 2019 13:36:28 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7+PvynBFLTI8I9Jp/HiKpzWDmNhI1omyp0nqmUOhcZBk1pF2o1LiK1Mie69qLBYN4kZrN X-Received: by 2002:a65:46cf:: with SMTP id n15mr12633689pgr.187.1549748188048; Sat, 09 Feb 2019 13:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549748188; cv=none; d=google.com; s=arc-20160816; b=V3SYi71q6HWlnFbEFjGgOxDRZbKc6MPvwsWVtGvdNZnSl3xZg1AeIqtoYlH/Obbddm GpfN8X18abKA3mz7krNxxy1aUtNPV87pzw06D/oM+yR3G7G5uEect2Z44s7QE4Zwdyex JymFAyTqkoV7BmY9yUaq41o/HlHcBu7ad5CPvWU1m2YrEixGs+awFNiiHaSd3k76H+4S e+VVrj9klNO0mnV4GtSWissSyIY/rnxAXBlx92nFjVBesrVQ5u+SiB0AzmMUgt9ox6i8 Df7X8xoqBfkBd3/0CzWWMPSA0wn/CPJ9bv1mtc+Dt4c+9xXBSU89xJmAP315ncAYavyz dbAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5Iu7a4Jy5kWO21IKeKsAKXoePMvF3BOx8RjgF65xhr8=; b=ZbUBfBMxmcU/p38j3r0Mg8JzmGegnP1OQL862PICbCPomy5dy4crIwM3+2Nk3pdlhR LQP+XbjX5p4Ff6VDegLeE9v7gFM5xHzZWHgKrukon9E7Ac3avbaYFcOFc1vBiT1ULrQB BiDToJ9UX8eVy0OAzRA6zgsL6vBSAu264pUgJ0O+kZUmixV/nbLLej9WZjh4Ft3XWJFO GeZLq15BpIeH3jlCEc3yWUOmzQa9dRfeQkoxZMb52TZKJq4P4BTc9lDQRGPIKx293oDg 7k3CoGmwpfYs6xsBbCPW9cOrt3otfzFndKLB5R/5+VBEMXinenP4YSwRsNWQ/9wOuGpI 9qRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=lZ1JHJ3b; 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 z21si2294067plo.317.2019.02.09.13.36.12; Sat, 09 Feb 2019 13:36:28 -0800 (PST) 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=fail header.i=@lunn.ch header.s=20171124 header.b=lZ1JHJ3b; 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 S1727084AbfBIVd7 (ORCPT + 99 others); Sat, 9 Feb 2019 16:33:59 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:45486 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbfBIVd7 (ORCPT ); Sat, 9 Feb 2019 16:33:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5Iu7a4Jy5kWO21IKeKsAKXoePMvF3BOx8RjgF65xhr8=; b=lZ1JHJ3bdEU6+j8ASDDwmzwyW7 9YNncFKoQKQhG41QH5NUnfMg9KE66m81AEbRlwUq74wXRvh+adiberIwDXSio3UUOouqGInmMHQAZ w9lyx1x14gjWoeQdMrM+SWI7P98i7rWKzePRUCWRI3Jycr7FkFwVJBvu3UX6bhGVO+kM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1gsaG1-0002PQ-Vc; Sat, 09 Feb 2019 22:33:54 +0100 Date: Sat, 9 Feb 2019 22:33:53 +0100 From: Andrew Lunn To: Federico Vaga Cc: Peter Korsgaard , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/5] i2c:ocores: add polling interface Message-ID: <20190209213353.GA9061@lunn.ch> References: <20190208161201.7860-1-federico.vaga@cern.ch> <20190208161201.7860-4-federico.vaga@cern.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190208161201.7860-4-federico.vaga@cern.ch> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int ocores_poll_wait(struct ocores_i2c *i2c) > +{ > + u8 mask; > + int err; > + > + if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) { > + /* transfer is over */ > + mask = OCI2C_STAT_BUSY; > + } else { > + /* on going transfer */ > + mask = OCI2C_STAT_TIP; > + udelay((8 * 1000) / i2c->bus_clock_khz); > + } > + > + /* > + * once we are here we expect to get the expected result immediately > + * so if after 1ms we timeout then something is broken. > + */ > + err = ocores_wait(i2c, OCI2C_STATUS, mask, 0, msecs_to_jiffies(1)); Hi Federico I did some timing tests for this. On my box, we request a udelay of 80uS. The kernel actually delays for about 79uS. We then spin in ocores_wait() for an additional 10-11uS, which is 3 to 4 iterations. There are actually 9 bits on the wire, not 8, since there is an ACK/NACK bit after the actual data transfer. So i changed the delay to (9 * 1000) / i2c->bus_clock_khz. That resulted in ocores_wait() mostly not looping at all. But for reading an 4K AT24 EEPROM, it increased the read time by 10ms, from 424ms to 434ms. So we should probably keep with 8. Tested-by: Andrew Lunn Andrew