From owner-freebsd-hackers@freebsd.org Sat Mar 24 16:47:29 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39D78F5A80F for ; Sat, 24 Mar 2018 16:47:29 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0DDB74A63; Sat, 24 Mar 2018 16:47:28 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-lf0-f46.google.com with SMTP id t132-v6so22512912lfe.2; Sat, 24 Mar 2018 09:47:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QBumXmN2iBCbJgQ0WoSpHynPgGsix8UYHIGnDduMW+0=; b=T3vdd/c/hN9GWtDZ1kvuOt9JlQJLBlI7SJKhzLfLE6sTh6xb9T7L5pKf2DNWWgb385 XUvwo7nTWcq2raWeaOEDbl3vY0ADlbLVbDbWBYsMnR1RCefSvDEfeDXkFLE7B0nnWu5n SC2EmvV7eCyafZm58FSc7IKCh3DgDnv5OMIukkjCmBxdwuHNisiHYrbXAPpx7RRqUACW KhXBF8uvTnXEz43HXYoy7HBRhfgZonwac7zcD7SWvpM5pDywSbl8LyyeUa5223rb/8rJ TxhWh2dw0mX1/7oXz3wWCrW/D9RJ+eg09qdLJMmMB/92YKqiCzqX0LRIxOZjf+w1WEs5 ZdyA== X-Gm-Message-State: AElRT7FqdpMg0ph4+7m2B+k89c8s8J08XQ0j7dq95x5sEErEbUia3hCa ycfVcwTW4YTDsRVHUJ+mE0hB7oAb X-Google-Smtp-Source: AG47ELsTE8El50QVs70fNCJ2Z/u/eZXZMBuRIIeS1jeVhhXr0jAoAGpYdMqzprCOqUwvqS4pPADvCA== X-Received: by 2002:a19:a9d3:: with SMTP id s202-v6mr16581858lfe.30.1521910046780; Sat, 24 Mar 2018 09:47:26 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id c29sm2546538ljd.30.2018.03.24.09.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Mar 2018 09:47:25 -0700 (PDT) Subject: Re: Custom I2C and RTC chip drivers: where is iccbus_get_nostop() defined? To: Ian Lepore , FreeBSD Hackers Cc: Konstantin Belousov References: <1521383420.99081.87.camel@freebsd.org> <0b0dee4b-e958-e25c-72d9-1ca296495802@FreeBSD.org> <1521906199.51564.19.camel@freebsd.org> From: Andriy Gapon Message-ID: <2b49cfed-1aeb-47c8-4722-2cf2ceb4dc40@FreeBSD.org> Date: Sat, 24 Mar 2018 18:47:24 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1521906199.51564.19.camel@freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Mar 2018 16:47:29 -0000 On 24/03/2018 17:43, Ian Lepore wrote: > I think our whole interface for transfers is conceptually broken. I > would like to just redefine the behavior of the interface. I think what > I want is basically the same thing that nostop ivar was trying to > achieve: > > Ignore the existing start/stop flags in the transfer structures. > When you pass an array of transfers, there is one bus START at the > beginning, one bus STOP at the end, and an automatic REPEAT_START > between any two transfers in the array where the slave address or > direction changes. When there are two adjacent transfers in the > array with the same address and direction, that's just one long > continuous flow of bytes -- effectively, it's scatter/gather IO. I completely agree. If you have a transfer / transaction, then why have STOP+START in the middle it. The current default behavior just does not make sense to me. > As an optimization, we could define an IICBUS_STOP flag that could be > added to any transfer in the array to force a full STOP/START sequence > after that transfer and before the next. That would amount to basically > a minor optimization... it would be identical to just calling transfer > twice. So I'm not even sure it's a good idea. Linux has I2C_M_STOP to force a stop. I guess that it's a workaround for some broken slaves that are confused by repeated start. But as you say, just splitting the transfers would work as well. > We might need to leave the current broken interface in place for out- > of-tree code like proprietary drivers, and define a new transfer method > that works the new way. That would make sense to do. > When I started looking at all existing callers of iicbus_transfer() I > came to the conclusion that almost all of them followed such identical > patterns that I wrote the iicdev_readfrom()/writeto() functions. I > figured I would run through the system converting everything I could to > those new functions, then whatever changes need to be made to the > interface would almost all be in just a couple functions. But that > project bogged down then other things came along and I forgot all about > it. Indeed, these are the most used patterns, so makes sense to have common routines for them. -- Andriy Gapon