Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2416640ybl; Sun, 11 Aug 2019 01:04:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8bDO5TkhaGx6TPgFyO971hnKP2Za8I/kMVkmhZ8EfvTREkr31xZsITqprDZh0H+kgFPwd X-Received: by 2002:a65:528d:: with SMTP id y13mr25882147pgp.120.1565510688710; Sun, 11 Aug 2019 01:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565510688; cv=none; d=google.com; s=arc-20160816; b=ha4lxBMWlJy+5y8BzP5s3TaiA4cj1JE4rnhaiD7a84KlVUFSuDt9bAZwfSrjZhuf9x idd8BuNtv4uCdLojYEFu6mca+9Rb50Hr5QaoPaDbkIUerlqf7z18gQSKqT6I24EzDwNl ZUwV/CyzPYKF40BGd1YaasxfpBpE5+rmvdDnWB0qony8/ZnCWxOTXAyXr40ReCrx/V/U Ohseh2X3hSlH5a0KBdMpLj3oghGxOmr2xsWBoXYquTafbOtD6eo0kJ+b5sd8DcNVd6Mo Nl0b9DBZw7A2p2C+zSfYXW7dkgi3AJNtZsB2bG11bo3FMbsednQseIlKzuY+d6iizbRP PGhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=O4CrwddHNaQQVz5p1AkRuf2Vanbc3vuxEtLByR+Bp30=; b=ODH84uqO9tW4US4GX/mOJAMSVpDrgDlJnmmfhXK3WsReJFQ5g2oGjlpFIK04Ksm/o0 PK6yPwfZ5mGB1GhVCahQnaWhzGcnTue+d39trZLhCZy3l8E7s5QWX+CBfk6vvMH5nhHq jnGRJGsE2Gnvu3UiKIE/S85FVYUK9v8XXmeEV/V2UE5T0TdDuCPNHuLTecbPvx3J0/Jy iV7Gp0Gq4IeBXxYKd/Ntvoccfe5yDz7wkxftSuSG50t1aCWHsu774PwGm/8Fmw2lemsM u9nR9jJ72XLzZ6kbDYcEFDqNHAWEB8jOd7jNANfmTliECxcnjMyAcs9nHJAvjcB7zdHz 8vGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O+G9jL5g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z185si58506846pfz.248.2019.08.11.01.04.18; Sun, 11 Aug 2019 01:04:48 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=O+G9jL5g; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbfHKIDX (ORCPT + 99 others); Sun, 11 Aug 2019 04:03:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:60894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbfHKIDW (ORCPT ); Sun, 11 Aug 2019 04:03:22 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2F5C2085B; Sun, 11 Aug 2019 08:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565510601; bh=mdfX89J7i+I020yze43/ImZLz3U+e+1AfvwU979Ejv4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O+G9jL5g/jV9cBbfxjaGSjkdAfE03ZkSqCWbrXwscD9uIX++wtts46w6Wr435CwXw 3VUT199SP6WFjzLkqojQHNi2i3kw6ah5DS8TDxF9dZH1isw3tml8Dwxw9eoD5oaWQv GRYhKtJYlhTiOHJFbmYUYBM9H3/dqyoVbb/hKkoc= Date: Sun, 11 Aug 2019 09:03:15 +0100 From: Jonathan Cameron To: Baolin Wang Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , freeman.liu@unisoc.com, Vincent Guittot , linux-iio@vger.kernel.org, LKML Subject: Re: [PATCH] iio: adc: sc27xx: Change to polling mode to read data Message-ID: <20190811090251.5fbd7d75@archlinux> In-Reply-To: References: <1870ea18729f93fb36694affaf7e9443733dd988.1564035575.git.baolin.wang@linaro.org> <20190727182709.037fc595@archlinux> <20190805145037.0a03f21e@archlinux> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 6 Aug 2019 15:39:45 +0800 Baolin Wang wrote: > Hi Jonathan, > > On Mon, 5 Aug 2019 at 21:50, Jonathan Cameron wrote: > > > > On Mon, 29 Jul 2019 10:19:48 +0800 > > Baolin Wang wrote: > > > > > Hi Jonathan, > > > > > > On Sun, 28 Jul 2019 at 01:27, Jonathan Cameron wrote: > > > > > > > > On Thu, 25 Jul 2019 14:33:50 +0800 > > > > Baolin Wang wrote: > > > > > > > > > From: Freeman Liu > > > > > > > > > > On Spreadtrum platform, the headphone will read one ADC channel multiple > > > > > times to identify the headphone type, and the headphone identification is > > > > > sensitive of the ADC reading time. And we found it will take longer time > > > > > to reading ADC data by using interrupt mode comparing with the polling > > > > > mode, thus we should change to polling mode to improve the efficiency > > > > > of reading data, which can identify the headphone type successfully. > > > > > > > > > > Signed-off-by: Freeman Liu > > > > > Signed-off-by: Baolin Wang > > > > > > > > Hi, > > > > > > > > My concerns with this sort of approach is that we may be sacrificing power > > > > efficiency for some usecases to support one demanding one. > > > > > > > > The maximum sleep time is 1 second (I think) which is probably too long > > > > to poll a register for in general. > > > > > > 1 second is the timeout time, that means something wrong when reading > > > the data taking 1 second, and we will poll the register status every > > > 500 us. > > > From the testing, polling mode takes less time than interrupt mode > > > when reading ADC data multiple times, so polling mode did not > > > sacrifice power > > > efficiency. > > > > Hmm. I'll go with a probably on that, depends on interrupt response > > latency etc so isn't entirely obvious. Faster response doesn't necessarily > > mean lower power. > > > > > > > > > Is there some way we can bound that time and perhaps switch between > > > > interrupt and polling modes depending on how long we expect to wait? > > > > > > I do not think the interrupt mode is needed any more, since the ADC > > > reading is so fast enough usually. Thanks. > > The reason for interrupts in such devices is usually precisely the opposite. > > > > You do it because things are slow enough that you can go to sleep > > for a long time before the interrupt occurs. > > > > So question becomes whether there are circumstances in which we are > > running with long timescales and would benefit from using interrupts. > > From our testing, the ADC version time is usually about 100us, it will > be faster to get data if we poll every 50us in this case. But if we > change to use interrupt mode, it will take millisecond level time to > get data. That will cause problems for those time sensitive scenarios, > like headphone detection, that's the main reason we can not use > interrupt mode. > > For those non-time-sensitive scenarios, yes, I agree with you, the > interrupt mode will get a better power efficiency. But ADC driver can > not know what scenarios asked by consumers, so changing to polling > mode seems the easiest way to solve the problem, and we've applied > this patch in our downstream kernel for a while, we did not see any > other problem. > > Thanks for your comments. OK. It's not ideal but sometimes such is life ;) So last question - fix or not? If a fix, can I have a fixes tag please. Thanks, Jonathan >