Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp767064pxb; Thu, 17 Feb 2022 14:24:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeiIKTuQpducMo18Kn4tzmBebPmZnL5IdzCN5KXoGMGJuRq7X6KAaDAs4uSdtelQfyH1a4 X-Received: by 2002:a63:5f14:0:b0:373:9e86:44d3 with SMTP id t20-20020a635f14000000b003739e8644d3mr3986701pgb.416.1645136679910; Thu, 17 Feb 2022 14:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645136679; cv=none; d=google.com; s=arc-20160816; b=y2dC8kbQPTMepLSXcXm+Xs1WOKCiFlDivc8EJDUTPV9P8LeHS9SB9BSSaMPdNMTg/2 ug0NAFMkhQRlbX4MhhtC+XkHwNy085EDZeIGI6pplpVmTv6RX8nFWt5ALRiCBaRGTMCI O1tOwiJ8X5A5aw2aPoO6N9Kru4VMJuggcWvo+sVBem6y4HQ8KWpwZEJ13Ut/rZK6TStx dms3WYqSm1QC7PYeEF7DVfqC/moEjnh1/a9b+m+yiKiiOr52icpBSiXwJFgLgB/YJlVw BSuIsOFvvyv+5by76e0/pFzf4EWDwFR6e6dCiSZ7ojRTOOuPyg92aFwBEnn/w9tWSpi6 ewbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=1Lx3YV8kA9uY20gpyQydNrRASi9fYCln8oqm+QIq6k4=; b=YYH7WtVxbv+DOtnIp0CUAv+9WB3x3epZMF5nROdA7dekvLRMEMQHjT5feliOq213iZ AsPITj9TyhPqS94OWEAnR7Hj87kQXPMSrdQo464w0WVqSBgC9hDCufsEaS+Cg6TWaatR 8AT4mVobjLeDOT8UvbNfjdWtIL8V5ZxmZCZUnfcPhX21znR35PyvZn69Ce1iJSFHFn0X iU88NCqqBD9CnXcJgKnYzbKe9IF9bOCIoayPA3WG1mBSQgxCG/NVl2a42YHNtlDWLwIv hbbXdSjvR7MPsttrUTJB8AgXL0kqC5z+aU4I5T5ByTHomC3IumQB4qu++kXRTuXw7uNO xfgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=fJL2ikFx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f127si9342612pgc.335.2022.02.17.14.24.19; Thu, 17 Feb 2022 14:24:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=fJL2ikFx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245568AbiBQTvz (ORCPT + 99 others); Thu, 17 Feb 2022 14:51:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245557AbiBQTvy (ORCPT ); Thu, 17 Feb 2022 14:51:54 -0500 X-Greylist: delayed 400 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 17 Feb 2022 11:51:38 PST Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6AB747544 for ; Thu, 17 Feb 2022 11:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=k1; bh=PLV4LWdDj/u4ldrwNJYwwtOs/CoI lUCOXcXS6q9IYUo=; b=fJL2ikFxTOLyTXIRNVEYrWc0XWEN34j1CyPK4lhiH+rY /9XQ8S2Qp7qxN2GdupIvJ9LbAX7m59ina+JE/ZcEyS5CZF1Rn+mY3j966OJwrHW7 QrJ87kXFw2LIK0RqAefXtu3QnG5iYSKr1/gCLMZLk3dyVUK74zEoUh8h8SwMmuQ= Received: (qmail 507920 invoked from network); 17 Feb 2022 20:44:54 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 Feb 2022 20:44:54 +0100 X-UD-Smtp-Session: l3s3148p1@9M/h/zvY1uogAQnoAFSyAKtB1T4Nf0Bd Date: Thu, 17 Feb 2022 20:44:51 +0100 From: Wolfram Sang To: Andrew Gabbasov Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Bhuvanesh Surachari Subject: Re: [PATCH v2] i2c: rcar: add SMBus block read support Message-ID: Mail-Followup-To: Wolfram Sang , Andrew Gabbasov , linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Bhuvanesh Surachari References: <20210922160649.28449-1-andrew_gabbasov@mentor.com> <000001d7badd$a8512d30$f8f38790$@mentor.com> <20211006182314.10585-1-andrew_gabbasov@mentor.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2acm5ptTzxcRBe88" Content-Disposition: inline In-Reply-To: <20211006182314.10585-1-andrew_gabbasov@mentor.com> X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_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 --2acm5ptTzxcRBe88 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Andrew, first sorry that it took so long. The reason here is that my original plan was to add 256-byte support to RECV_LEN in the I2C core and enable it on R-Car afterwards. Sadly, I never found the time to drive this forward. So, all RECV_LEN things got stuck for a while :( > This patch (adapted) was tested with v4.14, but due to lack of real > hardware with SMBus block read operations support, using "simulation", > that is manual analysis of data, read from plain I2C devices with > SMBus block read request. You could wire up two R-Car I2C instances, set up one as an I2C slave handled by the I2C testunit and then use the other instance with SMBUS_BLOCK_PROC_CALL which also needs RECV_LEN. Check Documentation/i2c/slave-testunit-backend.rst for details. I wonder a bit about the complexity of your patch. In my WIP-branch for 256-byte transfers, I have the following patch. It is only missing the range check for the received byte, but that it easy to add. Do you see anything else missing? If not, I prefer this simpler version because it is less intrusive and the state machine is a bit fragile (due to HW issues with old HW). =46rom: Wolfram Sang Date: Sun, 2 Aug 2020 00:24:52 +0200 Subject: [PATCH] i2c: rcar: add support for I2C_M_RECV_LEN Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-rcar.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 217def2d7cb4..e473f5c0a708 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -528,6 +528,7 @@ static void rcar_i2c_irq_send(struct rcar_i2c_priv *pri= v, u32 msr) static void rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr) { struct i2c_msg *msg =3D priv->msg; + bool recv_len_init =3D priv->pos =3D=3D 0 && msg->flags & I2C_M_RECV_LEN; =20 /* FIXME: sometimes, unknown interrupt happened. Do nothing */ if (!(msr & MDR)) @@ -542,11 +543,13 @@ static void rcar_i2c_irq_recv(struct rcar_i2c_priv *p= riv, u32 msr) } else if (priv->pos < msg->len) { /* get received data */ msg->buf[priv->pos] =3D rcar_i2c_read(priv, ICRXTX); + if (recv_len_init) + msg->len +=3D msg->buf[0]; priv->pos++; } =20 /* If next received data is the _LAST_, go to new phase. */ - if (priv->pos + 1 =3D=3D msg->len) { + if (priv->pos + 1 =3D=3D msg->len && !recv_len_init) { if (priv->flags & ID_LAST_MSG) { rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP); } else { @@ -889,7 +892,7 @@ static u32 rcar_i2c_func(struct i2c_adapter *adap) * I2C_M_IGNORE_NAK (automatically sends STOP after NAK) */ u32 func =3D I2C_FUNC_I2C | I2C_FUNC_SLAVE | - (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); + (I2C_FUNC_SMBUS_EMUL_ALL & ~I2C_FUNC_SMBUS_QUICK); =20 if (priv->flags & ID_P_HOST_NOTIFY) func |=3D I2C_FUNC_SMBUS_HOST_NOTIFY; Happy hacking, Wolfram --2acm5ptTzxcRBe88 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAmIOpa8ACgkQFA3kzBSg KbbOpw/6AytfzBlrI+AZSPjgcsIAOV/p95TJu+PcUIgOeKtyleBeoMzd2r29bfuV 1hrMdmU145BUZHmpiwGOqILZwihZa7TKoZvHB+ZZfSI/5qvCCv5jNyLEx3u8MiOX sl0CT5YcMPYCyfDO3AsPAN9Oxq0VdDTbpPv2TZ9MBycl62UDoFbGfYPHfxyKy3CQ Bp6QxT05cWiw1yRRK2hF89nGb4oeWeD1EV3ELIkJAIQtQSunJmu0lymr+lJJR8uz j03LeikTmgoU2hgW23Y6GLQJe85LyAiQZhGT6g2kXabsJQJv9Fu1YLTwJvcb5+Np wQ9daniG9wsqjTvpOkVlPzrAQCyoAZ0veQwkKd9FrCgZZ3K+hXdujkAMY/tHGmvC 9/kW07yO6a0UlJ1S2QD86Byc5R8+t3WI9xU6y0fQgHKxcUoMfxrnapOMATLb0kEm w/Q5RQzgLKaj/71SGf/92/tc57D1Li1i+uG6rVmNLPHHGbqOfSInRDkut8Ac/TJh AUft/52hdAVQPgaj2vDXlw43gwfgfrouwBEwjn6thjJ27BQlp+onwkwjuThop8zP 8erJycPp5fqqSh7hObVQSzZjBljVAuWNIyDM76/TcTtekR+s3AkHmt1D9Z9WeyJS +zRaqQD016MwwX/r/oKO03y47DzCDg+Vee3h3caQjAVXlLFWmtk= =QVKF -----END PGP SIGNATURE----- --2acm5ptTzxcRBe88--