Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2414032imj; Mon, 11 Feb 2019 02:25:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IYTuTqa6dZkeduWHBwEoWav78BhjA9PNBsaTAu1dwKHHMWae9l8RRoeyTcX/XYC3bfqKXRW X-Received: by 2002:a63:484c:: with SMTP id x12mr32693360pgk.375.1549880702239; Mon, 11 Feb 2019 02:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549880702; cv=none; d=google.com; s=arc-20160816; b=SNu20fkai/G9mpbHsEfx6bXWlGTA2dR/ydEX1Mb4nLLDWkwjOdbIkwKd/g1CLWhM+6 kmEO5Tb/SDC4dbF0H/Xc94NZBgs8WSzo9cDhD6c5GcTO9vAB/2+V8cE8Ntl+UAnEJwFR EU2lpCRXZMktAAhMiop1pusurnpgyIfiLD4dxYRfbu44CY/qWjvh+ZqkU5l7buc/TFWq wMrgbwF8xH2i/0NyxGKLfW/vHebiUKRr8ySAtpdAeyIpBqX8dEnki3gU4pxWJuYN1zA/ 7TG07FL1Uuy2dbHs6gGJ4zyNYUg4W0WJkULFvPBHSvgxm3gDiQctrMmAGapi8324Y7au 5clg== 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; bh=8417gk5CvkpHZwjfimUMbqOkiy5WRrzRzXRdRTKdZ44=; b=xnrhlGdQN66sP1MElS7KV3QKmt+mqFNejC5lKeBFap/5ZGBsNmcyO/JLR576HZdOLJ jx7XLtbCUKqfLjtlklhtApQu0n+7J4Pj/dDQn+ii1S9FfnWBEF1GIAtGfl/FpZBb+Geq oDyIBd0J6DtCuNtrnShI8cU+OVf4UoGS05YHh65XffiT7Kwqry8p9GJD84bw1AXsYm/p lmZVe6vdT+73f/uyJzS3d8CNcRheRPaeKvx/mKvpd/rSn4fOp1bNAwdU1bbWjMgAMmjw M6SHgwTWHLPpoX/e099zedWyidbys0qioIz3km47TKK+uIIy3cn4TA6sOKp6SOi+ld2Z LzNg== ARC-Authentication-Results: i=1; mx.google.com; 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 l81si3287646pfj.230.2019.02.11.02.24.46; Mon, 11 Feb 2019 02:25:02 -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; 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 S1726366AbfBKKYb (ORCPT + 99 others); Mon, 11 Feb 2019 05:24:31 -0500 Received: from sauhun.de ([88.99.104.3]:52922 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbfBKKYb (ORCPT ); Mon, 11 Feb 2019 05:24:31 -0500 Received: from localhost (p54B333B4.dip0.t-ipconnect.de [84.179.51.180]) by pokefinder.org (Postfix) with ESMTPSA id 0DA142E3542; Mon, 11 Feb 2019 11:24:28 +0100 (CET) Date: Mon, 11 Feb 2019 11:24:24 +0100 From: Wolfram Sang To: Federico Vaga Cc: Peter Korsgaard , Andrew Lunn , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/5] i2c:ocores: stop transfer on timeout Message-ID: <20190211102424.5xnzyxvfd2yhf6ui@ninjato> References: <20190211083122.32485-1-federico.vaga@cern.ch> <20190211083122.32485-2-federico.vaga@cern.ch> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="k34seb4vqcvdmmff" Content-Disposition: inline In-Reply-To: <20190211083122.32485-2-federico.vaga@cern.ch> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --k34seb4vqcvdmmff Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 11, 2019 at 09:31:18AM +0100, Federico Vaga wrote: > Detecting a timeout is ok, but we also need to assert a STOP command on > the bus in order to prevent it from generating interrupts when there are > no on going transfers. >=20 > Example: very long transmission. >=20 > 1. ocores_xfer: START a transfer > 2. ocores_isr : handle byte by byte the transfer > 3. ocores_xfer: goes in timeout [[bugfix here]] > 4. ocores_xfer: return to I2C subsystem and to the I2C driver > 5. I2C driver : it may clean up the i2c_msg memory > 6. ocores_isr : receives another interrupt (pending bytes to be > transferred) but the i2c_msg memory is invalid now >=20 > So, since the transfer was too long, we have to detect the timeout and > STOP the transfer. >=20 > Another point is that we have a critical region here. When handling the > timeout condition we may have a running IRQ handler. For this reason I > introduce a spinlock. >=20 > In order to make easier to understan locking I have: > - added a new function to handle timeout > - modified the current ocores_process() function in order to be protected > by the new spinlock > Like this it is obvious at first sight that this locking serializes > the execution of ocores_process() and ocores_process_timeout() >=20 > Signed-off-by: Federico Vaga > Reviewed-by: Andrew Lunn >=20 Applied to for-next, thanks! --k34seb4vqcvdmmff Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAlxhTVQACgkQFA3kzBSg KbbIzBAAk28yIbH11CCG/mU8YLcPZTJRQh7q2VqKZQkxV0pf0CCx+N0pAdlFrzSv pzsLLeIpQPUZE37Alfacz+dKZRVimcPGJ4qvR7Gja1onWkSpzOhYPp8LiEBFhgtO UTdjqeVLs+/Au35gdZ0vKNKOy62B9azsU11FpY5ygDYrF2KDlE3wIlzEoKrXnG37 cBhkwFi/xXZL+N9Ew1PIkr4qdPArARHXdvlrsiV48ZHp54byJ0VKTHp80Mvut4IW Xs2AFLK+K7u2b6ZGGrbKst6xeRZBQ+lHMxCDzx1jiYMaGoltubOd45uk/Ujdb51r de1/6tijFEvvInI1nWucbpLhY79bz7VRYH4rw+NJWwrTlqxGws0uytm3bSD3u6vJ 2q/5WtPC+vPFl/D42fQcJRwrzg62hls0RRjhO13YscobpCijohVtPLuZerXYAyTq FoMcWdFj6H8BCwhB3tobjoDS7VajcN2Yj0H/mhxI8iqUiUSD/03aXYSzeidZzWDd z7YYUvv/0fWrhv6MdXpYGZjvzfNoQE8aJVMZ3+ULUWSoeNZ1YfjIogXdYhdxlOBv FB9JI0+TeVCgkJBD1AYmuC6GWf1UU7DkpeoLZkpx79ndvXn2XXYdMRs9wHIw242X SB5jEQoST38O9F81MOPcGLfpuIFV08kmUcs36jtP1mFQ8ktYZtg= =48TV -----END PGP SIGNATURE----- --k34seb4vqcvdmmff--