Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1581408pxb; Fri, 13 Nov 2020 17:19:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxS6sJ14auZjokFGtHOrxQUC1K2UY1GI8KShKYrJ++SgmVKcY0eYiibV9KbkLf50bbTsFTz X-Received: by 2002:a50:eb0a:: with SMTP id y10mr5678298edp.342.1605316777238; Fri, 13 Nov 2020 17:19:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605316777; cv=none; d=google.com; s=arc-20160816; b=AsN4nEQh6pQ23f49kcQTIH+39GNIUk/jtNlFfaUzMIkNQ1oUYqX13J6+nCUI3nF0mI UXVCQsBlqu6iB5lfOpBVjxrtzO44ELgy1zBWiS0mv84oN2m+5yndOfzvHP5d5ayQ1vsW yp8zHq14Z8Rf//0c9vENqzHesaUvWBEFNDlkm19pQD3Ei6LarMiGZWR7MCpP0Eiqfq0N vusP35th7sHPJN//h1gOIuix8BjoMH6YcYHexA1+sYlnaIfhyj2rMWA/x03PTQq387XI 2vRDPNRAso/X/xT4fnjEh0O6/l0MOTtV/ZHkNSZbcKAD3huKtb5mUd4Vbsj0OzoPyJ2b QDLg== 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=yUF3L6bAkQSx57oUz6pPfzc487YJPjSYBv9gnynSNRc=; b=kF7xLJPtJ8YqGcNTbEVY1jbtt9YNQ+bIM6gEd3b7ghC59SfZGaHcVCdAxCjpp8F/VV v6H7nqWyDJOBQhX6J4zXLU/q+ymorJqeEHFd/AxPzNcckQD9E1KFe5zqp8yco5zK1gEe bL/xoYEGGn3q8WMaj0PG9lBAwl4RDMNUG0g0Vv5gQfBUxRY57o6d5JszE+Ma3awMSMOj +dzFDc9WPSnOHamjYzJ2Kpdm7NP8FGhIC/plnflPeczRI4mdTW3i0jy/wJDfD2oUriRL qdBO4kFfhKaIkdp4orbvTb7eusleqTZrUBc19eAXXmE+S8KKCdupQeiZzsZs+a5kP/kz /5Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=nyIdzzSJ; 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 gb8si7194362ejc.285.2020.11.13.17.19.13; Fri, 13 Nov 2020 17:19:37 -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=nyIdzzSJ; 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 S1726285AbgKNBRk (ORCPT + 99 others); Fri, 13 Nov 2020 20:17:40 -0500 Received: from linux.microsoft.com ([13.77.154.182]:59560 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgKNBRk (ORCPT ); Fri, 13 Nov 2020 20:17:40 -0500 Received: by linux.microsoft.com (Postfix, from userid 1046) id 6B85E20B71B7; Fri, 13 Nov 2020 17:17:39 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6B85E20B71B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1605316659; bh=yUF3L6bAkQSx57oUz6pPfzc487YJPjSYBv9gnynSNRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nyIdzzSJoZHNLbkf+LBkN/YUO6dxnk6BDkVtbkFafsayjDjlVxKzhLONudEhqYDv6 D9npTEhjg/JOevaU0Q36G00on/hick+/lKyn+OmBYn2kIr5iL7JudDm1y/04WskFz2 eX/flqr4sjvmhvP3OTEHutoRn+qE7jFScyau/vkU= From: Dhananjay Phadke To: ray.jui@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, rayagonda.kokatanur@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, 13 Nov 2020 17:17:39 -0800 Message-Id: <1605316659-3422-1-git-send-email-dphadke@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <38a23afc-57da-a01f-286c-15f8b3d61705@broadcom.com> References: <38a23afc-57da-a01f-286c-15f8b3d61705@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Nov 2020 11:24:36 -0800, Ray Jui wrote: >>>> 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. >>> > >kernel thread was proposed in the internal review. I don't see much >benefit of using tasklet. If a thread is blocked from running for more >than several tenth of ms, that's really a system-level issue than an >issue with this driver. > >IMO, it's an overkill to use tasklet here but we can probably leave it >as it is since it does not have a adverse effect and the code ran in >tasklet is short. > >How much time is expected to read 64 bytes from an RX FIFO? Even with >APB bus each register read is expected to be in the tenth or hundreds of >nanosecond range. Reading the entire FIFO of 64 bytes should take less >than 10 us. The interrupt context switch overhead is probably longer >than that. It's much more effective to read all of them in a single >batch than breaking them into multiple batches. OK, there's a general discussions towards removing tasklets, if this fix works with threaded isr, strongly recommend that route. This comment in the code suggested that register reads take long time to drain 64 bytes. >+/* >+ * It takes ~18us to reading 10bytes of data, hence to keep tasklet >+ * running for less time, max slave read per tasklet is set to 10 >bytes. @Rayagonda, please take care of hand-off mentioned below, once the tasklet is scheduled, isr should just return and clear status at the end of tasklet. >> >> 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? Regards, Dhananjay