Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp504194pxb; Wed, 3 Nov 2021 07:45:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyabf/feV99w0g7EijLHbsK4oUkdX46KRmDqH9NhUXY53oogXMXxLSXAxhSSDKYSooYcSaX X-Received: by 2002:a05:6638:3052:: with SMTP id u18mr34296974jak.148.1635950734475; Wed, 03 Nov 2021 07:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635950734; cv=none; d=google.com; s=arc-20160816; b=jz75xbwWktOlN6bTxl04151cjg9EquBpZdl4YEAgntMJafB5xG43tc2ZMoqkkJVI8X XqhQ0/kAy3WTI4pDiR2FeCkPOMO1W2TsbQdRdK/tQ8R3BkJToRbLAP7QJ7QMUwToWr/u 3e5JKzzJjXghnE8fghTCvJZ46hey8nlJ/WCp7xbChyG15Boic0u71sTJbWoPIcSt57+1 8ZjLEcfhdJQ4CWe2JYZNDaWP/N2Od/2+aUlL5+8ViZJ0oIhHxffzfWdwCqSl3GOqLofW eK1i5fY4NT39MyQd4B0tpinaIpsYUvNtAhzQ+8GSRbBe3PvSZb8oGPAawHG9Awv2wUUf +cXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=h8J2kmEgurblPdeLMlFL+uqxgtxQUO5ic+miy3dskg8=; b=MrzcJFB73xmq8LmQUol9rF5tT1wpLn7v1W4IbulfFPcI33/M/HOn0HSE4N55PQUyo+ aIWIRlRcpKHVfh1Ztk5RuRKeqidyPNzHPMj5QdNW+su3eg4MxzqV5K+cAzrWlZXRSjVk 4jOji4FXgT1GWG3yJjmNdtkJFecVgd4ehNmAhe90qstRGr9FaY9D1tFq1U56tNZ/ak+O y4KMAJNiOGB9LHRiO/rLpOmE9nr7hFAoGu3QdIQG96bbq1JCqN0Axvps7P73Ww2qnNec LKACpsBtINtQjRhbbiIizP0psdSLyQiAmxgOk+BPlks14PJzrAs/vHfnQTbizC6JlKWA r+jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=CXUR7vlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si4675277jat.17.2021.11.03.07.45.22; Wed, 03 Nov 2021 07:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=CXUR7vlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231517AbhKCOpU (ORCPT + 99 others); Wed, 3 Nov 2021 10:45:20 -0400 Received: from smtp1.axis.com ([195.60.68.17]:52499 "EHLO smtp1.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbhKCOpT (ORCPT ); Wed, 3 Nov 2021 10:45:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1635950563; x=1667486563; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=h8J2kmEgurblPdeLMlFL+uqxgtxQUO5ic+miy3dskg8=; b=CXUR7vlvsFSycuUv8FzLY0Ckjl4O73lrdf0KI+IGTo4tcpDna7E1Oaa7 4QNRVo8bgimyZxtTTEZGGykGHPicvJ0MEOA+0X8moC5u7CTWtDB4IfCOy x1ixdT+jtE8GwrSV8d6IxagfdgT7wlN30dMgxnVADzwOfmp94gFwfV6OP CnsnrlL5EFtRdKFG1SU0UIhOAC/WtsvQYBZcysoNrj3LLn1v3RO3RlSpb +d6wMIhQY+sSGauyIMBaG2o4bONlvtVkHtYcRtHJRDBTZqXqVvT91FDB2 im/AeCET6vBznlCLl4aEUoteU4Np1tCh5hUx9mN/M33cHFjipsqUpAiLY A==; Date: Wed, 3 Nov 2021 15:42:41 +0100 From: Vincent Whitchurch To: Viresh Kumar CC: "Chen, Conghui" , "Deng, Jie" , Greg KH , Wolfram Sang , "virtualization@lists.linux-foundation.org" , "linux-i2c@vger.kernel.org" , "linux-kernel@vger.kernel.org" , kernel Subject: Re: [PATCH 1/2] i2c: virtio: disable timeout handling Message-ID: <20211103144241.GA27285@axis.com> References: <8e182ea8-5016-fa78-3d77-eefba7d58612@intel.com> <20211020064128.y2bjsbdmpojn7pjo@vireshk-i7> <01d9c992-28cc-6644-1e82-929fc46f91b4@intel.com> <20211020105554.GB9985@axis.com> <20211020110316.4x7tnxonswjuuoiw@vireshk-i7> <20211029122450.GB24060@axis.com> <8592a48d-0131-86bf-586a-d33e7989e523@intel.com> <20211103063745.utpphthou4angs4s@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20211103063745.utpphthou4angs4s@vireshk-i7> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 03, 2021 at 07:37:45AM +0100, Viresh Kumar wrote: > On 03-11-21, 06:18, Chen, Conghui wrote: > > >>> Over the long term, I think the backend should provide that timeout > > >>> value and guarantee that its processing time should not exceed that > > >>> value. > > >> If you mean that the spec should be changed to allow the virtio driver > > >> to be able to program a certain timeout for I2C transactions in the > > >> virtio device, yes, that does sound reasonable. > > > > > > > > >Due to changes in my work, I will pass my virtio-i2c maintenance to Conghui. > > > > > >She may work on this in the future. > > > > > > > I'll try to update the spec first. > > I don't think the spec should be changed for timeout. Timeout-interval > here isn't the property of just the host firmware/kernel, but the > entire setup plays a role here. > > Host have its own timeframe to take care of things (I think HZ should > really be enough for that, since kernel can manage it for busses > normally with just that). Then comes the virtualization, context > switches, guest OS, backend, etc, which add to this delay. All this is > not part of the virtio protocol and so shouldn't be made part of it. The suggested timeout is not meant to take into account the overhead of virtualization, but to be used by the virtio device as a timeout for the transaction on the I2C bus (presumably by programming this value to the physical I2C controller, if one exists). Assume that userspace (or an I2C client driver) asks for a timeout of 20 ms for a particular transfer because it, say, knows that the particular connected I2C peripheral either responds within 10 ms to a particular register read or never responds, so it doesn't want to waste time waiting unnecessarily long for the transfer to complete. If the virtio device end does not have any information on what timeout is required (as in the current spec), it must assume some high value which will never cause I2C transactions to spuriously timeout, say 10 seconds. Even if the virtio driver is fixed to copy and hold all buffers to avoid memory corruption and to time out and return to the caller after the requested 20 ms, the next I2C transfer can not be issued until 10 seconds have passed, since the virtio device end will still be waiting for the hardcoded 10 second timeout and may not respond to new requests until that transfer has timed out.