Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2088603ybl; Sun, 18 Aug 2019 18:13:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyP6oxKzJPwFZUyIUjrg/5OHxcufi1NNNBXqjSz4eurw1b9jiL6ksG8wZE47UMbHsLBNg+b X-Received: by 2002:a17:902:28c9:: with SMTP id f67mr20345051plb.19.1566177233635; Sun, 18 Aug 2019 18:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566177233; cv=none; d=google.com; s=arc-20160816; b=RdqovEkiASDosXuyN6Sh6nzG6Zjde2b5IuOVBtAdMJBRrNnK8hvk6/ma512ICnWGDT TRaaRInQv7GbDfcURpI1FcHiH+gpXYvGrFq69XBl+rHaD1lSbq82PYBYxyQzSlL34F1/ OQKBlh+41mghWV07Q6Jwx7YMbXsUFNDeXwANCP2l+WKUKmfryJUb3sMgVPcCH2F6Ghd7 VUQYvJCgzuRgroMn+T+3kOMbpML6CrM+VtcAKKDmNrkYBqFbaNjZCzwITbwJb+IHbTvq Ysyg3ZUxG3+1d+WrLL1VkxjsmHn8OGAXNFQs3GZVFd0GKKWCwCE4WGKwXiq6uLm63gtP 10TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ov1ZoZUrJZ+JTAyOesjjuMheROZh7OUlKOkkFfcWSmM=; b=MB29H+38R1EtfqRhlXcIDLPyqjdW42Qn0a9+ul5y9JVVElwnna7qMiVFUTLrxUWQXv jNfFFj7FjiXNlLBgaMnpyMXIvtrEhqjkOfNz+95MQzbiDqJtTr9/HKGS1fB28lCFyd14 JG74F3r2UJT+UIhk5JuRQst+VJt2TFVyBVfQaT+X99wvItJZYTeasczPzSVqW3lVy5F+ RBVls0oxSDzg1rPfVai6DKsFfZ+S6x/q46Bb285k8D0izp/LFFC9OeB47MkSFa0lsG16 5y8vW+YfOPH9dGH2wzl+X9f6zV25+Hl7e3t+qD+r+eC9dJ0yxVG2Lcij80PGZxe4Z1Al LRFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PuQO63fc; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az8si5853069plb.34.2019.08.18.18.13.37; Sun, 18 Aug 2019 18:13:53 -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=@linaro.org header.s=google header.b=PuQO63fc; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726371AbfHSBMp (ORCPT + 99 others); Sun, 18 Aug 2019 21:12:45 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:33682 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfHSBMo (ORCPT ); Sun, 18 Aug 2019 21:12:44 -0400 Received: by mail-oi1-f193.google.com with SMTP id q10so139631oij.0 for ; Sun, 18 Aug 2019 18:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ov1ZoZUrJZ+JTAyOesjjuMheROZh7OUlKOkkFfcWSmM=; b=PuQO63fcEHlAV3z+KIhb2fK+YHgCVOytT5BLCOUxEG+WOTv/m1l1EbREdhu7BTB1/e 2lEugBzzYuQ3RARXhmLl7f0wR52+H+sJ+g6ykRpu9SKtlrG/49lqM/FN2UjOVUSY+7xe yceL8Pc+9u2iDyi1he/C9OV+VDuAq+pcjzjMRfl08R5bZHJmdoBfhlqjj+xmcEyulQzX IzufRym/SicpzSjl4M8Eazo9OzmJJhDWjdSWtvqNXzqydmU1uIom2IWmRScDBduYpfuo +Pl/O6yhmJiolgACWc1FrRVuxo03hRIzb9QB1+l2CyM3SDOPdAtkMJ70gL8hQHZGJ1qr N+aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ov1ZoZUrJZ+JTAyOesjjuMheROZh7OUlKOkkFfcWSmM=; b=NUy2GMynkyPrCjt8NZ/xkPUBIuTz6ZCHXOoqLGCE2v38zrkKKsUcgEvxj95/lIaTAT BsfduVzQIyAlxAzX3nYea64Qy6mYQ6//f/88GfnpaF0/c78WoySm6akR4+dDurq40bGl W8bVKpenLZJLqp/lucMZKLs6KLjWQEo7Nc/p6uxZYhrIZ5NNdkPtrW/7QmUpEwFTBRiT 2dvNzFGrDx3CdFOuE5gL6c2jyzv1GluGpxxNCtawzbN/I9XWENAeSO7pCKCE7SMeHTuS ZyUxqmiryr6N3iei6Hahbnq5XzOoUmgQMY2BvSREZb2GIk0wmepoP6Ao9IZOqyE2jzrA yqhg== X-Gm-Message-State: APjAAAX9b2sGJ9Y3Ometiwkjf9kjN1kVT8SqmUDlzl8kXw7C/gl3dyzw u4jDm/RdTumuScO845OGJmXvKBvPhZeQGNlcyFvYaQ== X-Received: by 2002:aca:5b05:: with SMTP id p5mr2043065oib.6.1566177163319; Sun, 18 Aug 2019 18:12:43 -0700 (PDT) MIME-Version: 1.0 References: <1870ea18729f93fb36694affaf7e9443733dd988.1564035575.git.baolin.wang@linaro.org> <20190727182709.037fc595@archlinux> <20190805145037.0a03f21e@archlinux> <20190811090251.5fbd7d75@archlinux> <20190818202704.69e95a4d@archlinux> In-Reply-To: <20190818202704.69e95a4d@archlinux> From: Baolin Wang Date: Mon, 19 Aug 2019 09:12:32 +0800 Message-ID: Subject: Re: [PATCH] iio: adc: sc27xx: Change to polling mode to read data To: Jonathan Cameron Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , freeman.liu@unisoc.com, Vincent Guittot , linux-iio@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Aug 2019 at 03:27, Jonathan Cameron wrote: > > On Mon, 12 Aug 2019 10:37:44 +0800 > Baolin Wang wrote: > > > On Sun, 11 Aug 2019 at 16:03, Jonathan Cameron wrote: > > > > > > 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 ;) > > > > Thanks for your understanding :) > > > > > > > > So last question - fix or not? If a fix, can I have a fixes tag > > > please. > > > > This is a bigger patch, I am afraid it can not be merged into stable > > kernel, and original code can work at most scenarios. So I think no > > need add stable tag for this patch. Thanks. > > > Fair enough. Needed a bit of merge effort as crossed with a generic > cleanup patch it seems. > > Anyhow, hopefully I got it right. I checked you are right. > > Pushed out as testing for the autobuilders to play with it. Thanks. -- Baolin Wang Best Regards