All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ellen Wang <ellen@cumulusnetworks.com>
To: Antonio Borneo <borneo.antonio@gmail.com>
Cc: David Barksdale <dbarksdale@uplogix.com>,
	Jiri Kosina <jkosina@suse.cz>,
	linux-input <linux-input@vger.kernel.org>,
	linux-i2c@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>
Subject: Re: [PATCH v1] HID: support multiple and large i2c transfers in hid-cp2112
Date: Fri, 29 May 2015 21:58:09 -0700	[thread overview]
Message-ID: <55694361.4000404@cumulusnetworks.com> (raw)
In-Reply-To: <CAAj6DX2LC8EP8niRPgwXuehGqmOySSuPMe88Aa+hTqr7ry+eXQ@mail.gmail.com>

On 05/29/2015 08:38 PM, Antonio Borneo wrote:
> On Sat, May 30, 2015 at 1:32 AM, Ellen Wang <ellen@cumulusnetworks.com> wrote:
>>
>> On 05/29/2015 09:28 AM, Antonio Borneo wrote:
>>>
>>> CP2112 is not able to combine messages since unable to repeat the start
>>> bits.
>>> It can only send simple transfers or a combined read-after-write.
>>>
>>> Here you cannot simply loop on all the messages and send them one by
>>> one because there is no way to force the repeated start bit in
>>> between.
>>> You can find more details in this thread about CP2112
>>> https://lkml.org/lkml/2015/3/15/64
>>> and here info about the repeated start bit under "Combined transactions"
>>> Documentation/i2c/i2c-protocol
>>>
>>> Anyway your idea to introduce read-after-write is valid.
>>> I suggest you to check the drivers i2c-opal.c and i2c-pmcmsp.c ; at a
>>> quick check I think they have similar limitation as CP2112.
>>> You could replicate the same check, supporting only num==1 (always)
>>> and num==2 (only if msg[0] is write and msg[1] is read).
>>>
>>> Best Regards,
>>> Antonio
>>
>>
>> It don't think the code attempts to generate repeated start.  It simply
>> issues and completes each message as separate transfers.  It's not different
>> from calling cp2112_i2c_xfer() repeatedly with single messages, except in
>> the bracketing hid_hw_power().
>
> cp2112_i2c_xfer() is the lower level side of i2c_transfer().
> i2c_transfer() requires that only one Stop bit is sent at the end of
> last message. Between messages a repeated start is mandatory.
> In general case, CP2112 cannot do that, that's why the original code
> returns error if num != 1
>
> It's not correct to issue each message as separate transfer inside
> cp2112_i2c_xfer(); the caller of i2c_transfer() expects the messages
> to be sent with repeated start.
>
> With you patch you highlight that there is another case that should be
> implemented.
> CP2112 can handle the case of num==2 when msg[0] is write and msg[1] is read.
> There are other devices with similar limitations, as I pointed above.
>
> Extending cp2112_i2c_xfer() to support a combined read-after-write is
> ok, while issuing each message without forcing repeated start is
> incorrect.
>
> Best Regards,
> Antonio

OK.  I neglected to read the later messages in the thread you pointed me 
to.  Oddly, I submitted my patch weeks before that thread, and was given 
exactly the opposite feedback, which was that the fix was fine in 
principle (but I should separate out some unrelated bug fixes).  And I 
agreed to using the quirks mechanism in a later patch.

Do you already have a patch that addresses the whole issue?  I just 
rewrote my code to handle single messages and the write-read case, as 
you suggested.

Thanks

  reply	other threads:[~2015-05-30  4:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 21:49 [PATCH v1] HID: support multiple and large i2c transfers in hid-cp2112 Ellen Wang
     [not found] ` <1429825766-19594-1-git-send-email-ellen-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-05-29 14:54   ` Jiri Kosina
2015-05-29 16:28 ` Antonio Borneo
     [not found]   ` <CAAj6DX38Op1NkF==6L5Y=Fcm5puOgK7N=aK4NQ9u8G1gK-KB_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-29 17:32     ` Ellen Wang
     [not found]       ` <5568A2A7.5090203-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-05-30  3:38         ` Antonio Borneo
2015-05-30  4:58           ` Ellen Wang [this message]
     [not found]             ` <55694361.4000404-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-05-30  5:23               ` Antonio Borneo
     [not found]                 ` <CAAj6DX0tUto6fBp4okFQNjL66UtktEZSH+VDmRYszsA=rjR5HQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-30  5:34                   ` Ellen Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55694361.4000404@cumulusnetworks.com \
    --to=ellen@cumulusnetworks.com \
    --cc=borneo.antonio@gmail.com \
    --cc=dbarksdale@uplogix.com \
    --cc=jkosina@suse.cz \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.