Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1443654pxb; Fri, 6 Nov 2020 09:43:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBwqBNoxx3kmLnJVcvzuArhwTQdVYPOHSq+R7zhs5iIkj1zY0KRpXqEdHloHGsUojI48ZX X-Received: by 2002:a05:6402:48d:: with SMTP id k13mr3254382edv.92.1604684633268; Fri, 06 Nov 2020 09:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604684633; cv=none; d=google.com; s=arc-20160816; b=hW2J4buwBw/+pHWLI2+DLtBGMmT8bA2hU2cGE/Ys010b1pYVHgtWVYF4TNQAk2BEv6 9i/YzbBtoilYJfboOhn9xBsqCTMrkNFDaGS3+wfchd0oxxkj7+SY8iB+OlqYNTdFNhLY JxagdHIwdBNQnHoCkDockvheLnRRVF7pTZHuObWUFvF0QKYJrp6tFryqrxjcNEHMTQ+L N5eQNTmChhBAU/jwPeYfeVFJ9FMJO7Vq93Uc3Zbb2z2twNVdWl/viAGx4/Mvoy9nEP7x RswXU82HR0dPlxu3W19wxNNBYdjfCCbPdnwv4T/WDoMcAxNyIxvkutUbtDJdC275R7LY xwlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=/E8p26BZs+ElXJp0kzG7i/GtDQpHpgqTRJRJOBKzc7c=; b=MlkwgOgQ5yApFGJhHwD8+wPsM+QamFCaC+swzov41cThLTs2EfrDRodGb8EORVEPnB kNfq+lD0vBj3th5hYfvutbPg+CN+pJnasIo8GVVtI5Y3ORraVfP7iopLms6Ht8n3jma7 t1pm0ljv8eGkgMsHmbYJ8LWwSjdXRQhXpISbSQF0Y8/K2tT4/xsa0ufwUR8lOF8TGnxa rnB1Ye8cvp/LjgBaURr3i3QHAoc1k+aDDClfOVBC/hHdzrR4he6bGQ5DRld742saA+hI L3o5HndVuf4Sli8yTwLLwqKtMMxY1WD/e5q5MAK3zqGB5eOXaxoZpVPcxtqGPIiVxJ2D OCwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bcYquINM; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a35si1597494edf.202.2020.11.06.09.43.29; Fri, 06 Nov 2020 09:43:53 -0800 (PST) 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 header.i=@linux.microsoft.com header.s=default header.b=bcYquINM; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727612AbgKFRl1 (ORCPT + 99 others); Fri, 6 Nov 2020 12:41:27 -0500 Received: from linux.microsoft.com ([13.77.154.182]:46340 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgKFRl1 (ORCPT ); Fri, 6 Nov 2020 12:41:27 -0500 Received: by linux.microsoft.com (Postfix, from userid 1046) id 226BF20BE4A6; Fri, 6 Nov 2020 09:41:26 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 226BF20BE4A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1604684486; bh=/E8p26BZs+ElXJp0kzG7i/GtDQpHpgqTRJRJOBKzc7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcYquINMUl7AEexnx6z825WlUruPKZPoDg6YR5G5OiuWryDDlOi3zdvH5XVoy/t7g 7yDwQxPun5EDf9OFv7INJ+kgnKh7aByCLuPGd7D2b6BsroV0beZRzydMIVDSXSmHbh kyx8Fe7Yi1eI+e4e5LBmwYyoIEcEylyxVIzTgbPw= From: Dhananjay Phadke To: rayagonda.kokatanur@broadcom.com Cc: andriy.shevchenko@linux.intel.com, bcm-kernel-feedback-list@broadcom.com, brendanhiggins@google.com, dphadke@linux.microsoft.com, f.fainelli@gmail.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, lori.hikichi@broadcom.com, ray.jui@broadcom.com, rjui@broadcom.com, sbranden@broadcom.com, wsa@kernel.org Subject: Re: [PATCH v3 5/6] i2c: iproc: handle master read request Date: Fri, 6 Nov 2020 09:41:26 -0800 Message-Id: <1604684486-16272-1-git-send-email-dphadke@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Nov 2020 15:13:04 +0530, Rayagonda Kokatanur wrote: >> So the suggestion was to set HW threshold for rx fifo interrupt, not >> really a SW property. By setting it in DT, makes it easier to >> customize for target system, module param needs or ioctl makes it >> dependent on userpsace to configure it. >> >> The need for tasklet seems to arise from the fact that many bytes are >> left in the fifo. If there's a common problem here, such tasklet would be >> needed in i2c subsys rather than controller specific tweak, akin to >> how networking uses NAPI or adding block transactions to the interface? >> >> For master write-read event, it seems both IS_S_RD_EVENT_SHIFT and >> IS_S_RX_EVENT_SHIFT are detected, which implies that core is late to >> drain rx fifo i.e. write is complete and the read has started on the bus? > >Yes it's true that for master write-read events both >IS_S_RD_EVENT_SHIFT and IS_S_RX_EVENT_SHIFT are coming together. >So before the slave starts transmitting data to the master, it should >first read all data from rx-fifo i.e. complete master write and then >process master read. > >To minimise interrupt overhead, we are batching 64bytes. >To keep isr running for less time, we are using a tasklet. >Again to keep the tasklet not running for more than 20u, we have set >max of 10 bytes data read from rx-fifo per tasklet run. > >If we start processing everything in isr and using rx threshold >interrupt, then isr will run for a longer time and this may hog the >system. >For example, to process 10 bytes it takes 20us, to process 30 bytes it >takes 60us and so on. >So is it okay to run isr for so long ? > >Keeping all this in mind we thought a tasklet would be a good option >and kept max of 10 bytes read per tasklet. > >Please let me know if you still feel we should not use a tasklet and >don't batch 64 bytes. Deferring to tasklet is OK, could use a kernel thread (i.e. threaded_irq) as i2c rate is quite low. But do enable rx_threshold and read out early. This will avoid fifo full or master write-read situation where lot of bytes must be drained from rx fifo before serving tx fifo (avoid tx underrun). Best would have been setting up DMA into mem (some controllers seem capable). In absence of that, it's a trade off: if rx intr threshold is low, there will be more interrupts, but less time spent in each. Default could still be 64B or no-thresh (allow override in dtb). Few other comments - >+ /* schedule tasklet to read data later */ >+ tasklet_schedule(&iproc_i2c->slave_rx_tasklet); >+ >+ /* clear only IS_S_RX_EVENT_SHIFT interrupt */ >+ iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, >+ BIT(IS_S_RX_EVENT_SHIFT)); >+ } Why clearing one rx interrupt bit here after scheduling tasklet? Should all that be done by tasklet? Also should just return after scheduling tasklet? Thanks, Dhananjay