Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2372724ioo; Sat, 28 May 2022 11:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+2tX8ny/fRE4ZM86zrEfNOyofQJ3vJg6F0RpPYLFlsNeK0SAJKHaS1FWIN0YTIBaROOro X-Received: by 2002:a17:90a:7f94:b0:1cb:1853:da1b with SMTP id m20-20020a17090a7f9400b001cb1853da1bmr14496421pjl.14.1653763002218; Sat, 28 May 2022 11:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653763002; cv=none; d=google.com; s=arc-20160816; b=A9YrTiIb20EZusQUpy9jZtMI5winbqEF4IlIYK1iXOdRDP7cAAINnX852exTE89Tp5 xDAjgPc+Im0fP7UkLEQu3oFBrP8XjuBo5dw8DRjrrH1nvRmcb+AGYVaD/km3Hw/NVaKo Utp4rdu9nRuR7ab2vbtrkgXR20MNMKIJCQIrUmQVnFP2TkkywbLXhS+9pGgm9gjsHOhg TP2K4aW/xDjNoPf6Jf/0QNXLOdYtNlg+xRkOkuA6LVO1iY3CpKlxc2x7LhR3bXslQBlV nwuKhFJkqt7fxlJlPpj/cttESdorA/ukNNdKBIwkkzvcl+X/0t4x8Q8WRNI/d16YVL0Y T85g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3T4DsH4UCoUl5R2RgjZ0yHyhWI60p4wfKuM4SeQhx6U=; b=yB+PT5cCbnbBBEy7g1VINjh8yh6aD18G3cNU0SJ4hsV38gvAFCOu34MpOr1sBQCCTN VpWPXeAk5noqHcf+CxCghvTVuWuSK8hbkcCpFdYMl4Ad750xDdkGdteGMZGW9Bulz6rN oXPbEIdu3+kGm1d/ANi35+gcoFNSgUGZhai5Hioj58ZTmjh7QS3FDvMmvvqt6ZZmudw1 IKVjsFWEeGHAfWyJEQQmumCW3BF4W/dJc4tBzlb83RmmOScaGmX4bMBKgimlPgYqB4Gb D587NW2mnEc7BQ2rDI6G6J0qGJ268FVyDkBejabkAhg5gQX0WljBKvZqGXbbDTdQu13h lgaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dv+Owxdr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j5-20020a170903024500b00153b2d1646asi12754264plh.114.2022.05.28.11.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 11:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dv+Owxdr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 56BAD11143; Sat, 28 May 2022 11:31:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242752AbiEYUdY (ORCPT + 99 others); Wed, 25 May 2022 16:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbiEYUdW (ORCPT ); Wed, 25 May 2022 16:33:22 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7242C38D90; Wed, 25 May 2022 13:33:21 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-2ff155c239bso227366037b3.2; Wed, 25 May 2022 13:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3T4DsH4UCoUl5R2RgjZ0yHyhWI60p4wfKuM4SeQhx6U=; b=dv+OwxdrL+sTwl6GkMW0xyou2Th5dhgob+dZcJHyS8VFrz38UPPQm1cJMpqRohU5dM xVKct417ND39qmmbTR+c7JGQ6oMq1QK9cniugpXz4Pcz/vHg4eFwHOuPTdCu6Lu/AlfF yd5IJKNdSZhHO+/ZhtdgBDcqcQgo2o/0PyJ1q6RX3GG/TsBIH/i9CuQK5urHzZBK0W5B UsrfQ/oZFOGSmYXQHS6MOSKcA6yeClY73k2g1AOYVanujLpnrxbRVbC1Gjg6Z/TyOn0F 56d7AM88fzWCpcYg2N6Ymyu5SphtaOjSbvf+MLuUw8zsacUSgsKe1693C9IHnh729sn3 0atw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3T4DsH4UCoUl5R2RgjZ0yHyhWI60p4wfKuM4SeQhx6U=; b=ob3GxNoc3b+erIyuEhx7qUj4vsBZa6QD8QcvhKCVwJE7H4QeuoDAMkmulU982nokPS uXBhTCofc/6ZwrgduvubVDR4Pd80C07RKZt/tVlX4B/CRoAgv5Nnp8HwZjb5mtW2RB0J DTYFcytrcyHYyCXFR0s73ZVPmuRQp/fBbPXeGxsaFplP2galqG7UhgPzTVJ3lnHtnTz2 eT18GKAVf5ZZTuVyTcHaq9rx20W/ynFGRtspu/5PlvM0ZRdM7ot42npvHHycpcsfnk5s pds4nfnhkPjEa2iBRvEya5Y6OkXgKbIekmwyQX0FTXwNzjfB1DqrZe7LyNNeVwaMsjtn jiGQ== X-Gm-Message-State: AOAM533gj9ykjzwGIK4vX4iLbKAvZFNGw7gvhj/QN1A3B1Duey0Qxg/a o9rhv2SuwjSp1aeHtttGotnwZqeJmffG/zW0E3Y= X-Received: by 2002:a0d:df4a:0:b0:2ff:29c7:124e with SMTP id i71-20020a0ddf4a000000b002ff29c7124emr35843404ywe.346.1653510800738; Wed, 25 May 2022 13:33:20 -0700 (PDT) MIME-Version: 1.0 References: <20220525074757.7519-1-michael.zaidman@gmail.com> <20220525074757.7519-4-michael.zaidman@gmail.com> <20220525194242.GA13454@michael-VirtualBox> In-Reply-To: <20220525194242.GA13454@michael-VirtualBox> From: Guillaume Champagne Date: Wed, 25 May 2022 16:33:09 -0400 Message-ID: Subject: Re: [PATCH v1 3/5] HID: ft260: support i2c writes larger than HID report size To: Michael Zaidman Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, wsa@kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Mathieu Gallichand Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mer. 25 mai 2022 =C3=A0 15:42, Michael Zaidman a =C3=A9crit : > > On Wed, May 25, 2022 at 11:44:09AM -0400, Guillaume Champagne wrote: > > Le mer. 25 mai 2022 =C3=A0 03:48, Michael Zaidman > > a =C3=A9crit : > > > > > > To support longer than one HID report size write, the driver splits a= single > > > i2c message data payload into multiple i2c messages of HID report siz= e. > > > However, it does not replicate the offset bytes within the EEPROM chi= p in > > > every consequent HID report because it is not and should not be aware= of > > > the EEPROM type. It breaks the i2c write message integrity and causes= the > > > EEPROM device not to acknowledge the second HID report keeping the i2= c bus > > > busy until the ft260 controller reports failure. > > > > > > > I tested this whole patchset and it resolves the issue I raised > > https://patchwork.kernel.org/project/linux-input/patch/20220524192422.1= 3967-1-champagne.guillaume.c@gmail.com/, > > thanks. > > Much appreciated! > I will add your tested-by in the second version of the patchset. > > > > > > This patch preserves the i2c write message integrity by manipulating = the > > > i2c flag bits across multiple HID reports to be seen by the EEPROM de= vice > > > as a single i2c write transfer. > > > > > > Before: > > > > > > $ sudo ./i2cperf -f 2 -o 2 -s 64 -r 0-0xff 13 0x51 -S > > > Error: Sending messages failed: Input/output error > > > > > > [ +3.667741] ft260_i2c_write: rep 0xde addr 0x51 off 0 len 60 d[0] 0= x0 > > > [ +0.007330] ft260_hid_output_report_check_status: wait 6400 usec, l= en 64 > > > [ +0.000203] ft260_xfer_status: bus_status 0x40, clock 100 > > > [ +0.000001] ft260_i2c_write: rep 0xd1 addr 0x51 off 60 len 6 d[0] 0= x0 > > > [ +0.002337] ft260_hid_output_report_check_status: wait 1000 usec, l= en 10 > > > [ +0.000157] ft260_xfer_status: bus_status 0x2e, clock 100 > > > [ +0.000241] ft260_i2c_reset: done > > > [ +0.000003] ft260 0003:0403:6030.000E: ft260_i2c_write: failed to s= tart transfer, ret -5 > > > > > > After: > > > > > > $ sudo ./i2cperf -f 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S > > > > > > Fill block with increment via i2ctransfer by chunks > > > ------------------------------------------------------------------- > > > data rate(bps) efficiency(%) data size(B) total IOs IO size(B) > > > ------------------------------------------------------------------- > > > 58986 86 256 2 128 > > > > > > Signed-off-by: Michael Zaidman > > > --- > > > drivers/hid/hid-ft260.c | 45 ++++++++++++++++++++++++---------------= -- > > > 1 file changed, 27 insertions(+), 18 deletions(-) > > > > > > diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c > > > index 44106cadd746..bfda5b191a3a 100644 > > > --- a/drivers/hid/hid-ft260.c > > > +++ b/drivers/hid/hid-ft260.c > > > @@ -378,41 +378,50 @@ static int ft260_hid_output_report_check_status= (struct ft260_device *dev, > > > } > > > > > > static int ft260_i2c_write(struct ft260_device *dev, u8 addr, u8 *da= ta, > > > - int data_len, u8 flag) > > > + int len, u8 flag) > > > { > > > - int len, ret, idx =3D 0; > > > + int ret, wr_len, idx =3D 0; > > > + bool first =3D true; > > > struct hid_device *hdev =3D dev->hdev; > > > struct ft260_i2c_write_request_report *rep =3D > > > (struct ft260_i2c_write_request_report *)dev->write_b= uf; > > > > > > do { > > > - if (data_len <=3D FT260_WR_DATA_MAX) > > > - len =3D data_len; > > > - else > > > - len =3D FT260_WR_DATA_MAX; > > > + rep->flag =3D 0; > > > + if (first) { > > > + rep->flag =3D FT260_FLAG_START; > > > > I feel like multi packet transactions must still honor flag sent to > > ft20_i2c_write. This adds a START even if ft260_i2c_write is called > > with FT260_FLAG_START_REPEATED or FT260_FLAG_NONE. > > We use the FT260_FLAG_START_REPEATED to precede the Read message followin= g > the Write message in the i2c combined transaction. Am I missing any i2c > protocol case using the Repeated Start in the Write path? > None that I know of. My point was that software wise it may be less surprising to the programmer if "flag" is replicated as is when calling ft260_i2c_write. For example, calling it with FT260_FLAG_STOP only sends a START, no STOP. I agree that it isn't currently called that way and that it may never be. > The FT260_FLAG_NONE should not be passed into the ft20_i2c_write as well. > > So, we can keep it simple. Agreed. >