Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3267948ybl; Sun, 11 Aug 2019 19:41:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7iIRPH1Oekwj7mhJzKHZnVx0vNqHB05y1UMtxmso0MGYXEH33znGh184JxAZpWfVmYzD7 X-Received: by 2002:a17:902:bb8d:: with SMTP id m13mr8340734pls.307.1565577699143; Sun, 11 Aug 2019 19:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565577699; cv=none; d=google.com; s=arc-20160816; b=1FRISAmh15V03O8VkWig9bNMLySeaYf1/laatUcORXBaTWxk38+qDSqg5N3HQodWLO fpdOW7gpKGnptqwuCfHET9jVKbEdJhw0QoejmluYm5ko14PRCaiGJ0i0VtiPi4G32vmb fCWdYJO2xTmvKHzqul208pNaM4rrUSU6c8XDXh7mlGOMxJ2MoHjqAz0ykwWRAD/Y1lxt D32cVsVeCWfMQOGoyvsWBGXr8jg0IYNu04Kdg8IRH1c2+st+CblT974pmC4IwqCSzrzg JGqMX8RTNE4EqVrEEyz26iTnsJrXoyduE/WokM3as869me5iC3yla3p9dWkAEnJxr4Qq /0jg== 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=vVPUyU0J20dZaP14ZLtarTnmhaUFJnFvaSIBf/iSdHg=; b=aLg3cM/kndTUxfQ9tBElrPkYu/mV9hl4GNZo1ng7hxaLlwVxNPIebDbuwKnVyR/4S4 8xsLgmx48886aVrXIYbsOVbkwTIB2ThPih8aMbwy1bxaXKqk8zc7No+DaVh4PoJPhO2O 6oy0g3jEJAInoFYOYOcUVXHgsu/miJM2q2p8JXswoGTMB9bsfr3ROXEdZdpQhybWxbdv K8cpDGMfA34kKYQmpWVlSNwaMsEIt1LAZC6ZOa4Uv6BXsbv4Uvgjf912WPK90ld2XWA5 7YCeRTBOUcB1HokoUBKH5AVKjqzWgf91O/WjNg73Dv862BXmJXVENSiKxbBSpXikYYcP a1cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqKR6v7r; 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 65si67360419pff.220.2019.08.11.19.41.10; Sun, 11 Aug 2019 19:41:39 -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=HqKR6v7r; 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 S1726515AbfHLCh5 (ORCPT + 99 others); Sun, 11 Aug 2019 22:37:57 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:44544 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbfHLCh5 (ORCPT ); Sun, 11 Aug 2019 22:37:57 -0400 Received: by mail-ot1-f65.google.com with SMTP id b7so103499874otl.11 for ; Sun, 11 Aug 2019 19:37:56 -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=vVPUyU0J20dZaP14ZLtarTnmhaUFJnFvaSIBf/iSdHg=; b=HqKR6v7rUVKSqH/801mtUb1b78SxT444rRCVYLlXNrRvp07ibQehYufIH7zwzwDso/ IS581UNC9Z8ELxE5VeWHqzl8I0+7/AQXjYXv8hZ5jV2ZTVsYRXf20Gb0EYxfA8/z28sr MRqdBnWVDqq/ZnLG/D42iTpl6ZxPuVa3lXzrwNHq9DwTray9m9bCOh2gpZ+EmIDRQE3X POb1arab6XlIRV+ysy2faIH4gXg345Z0QVuhpy+zodgkrp1iLRmWiEXFWjK5cfPbIixu g8XwfRwS0rwmmuWSs5qBONARdmSm+i2T/G17QvWwhQ6D0z1fPGRlBZJ5mIPEQzYiiosh Qc2w== 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=vVPUyU0J20dZaP14ZLtarTnmhaUFJnFvaSIBf/iSdHg=; b=d8WFrTLLfww2z9HOWcqZFK6Hr9h/0IRuXn91d0jPW8Aogo0u08UAioZBb9TGveUUjy K7+ogBjFZb3oc3Gta2BIhBtVhHgqSj3IKmKjRULRSgM8ZmDpQg3JEYvBP8xifD8FOlQ6 GtGXGHNSWz4z4iua343SZDRKVaHqlic+2vtjWfKNvii9Gy4UsRpW9ZwUvv6YIHOPaAhE MBAb4t/AidQMPpM5Q1OwEOW620nmUrlursKfyo/lByRsI+CmmB/DkIChrY9Hkd4x+CBB LrMz+2LeUgefS1uGAEJCRQTC0eiMq7WfzdeNThN08uFs6kaTjweR+krtbfYc1iXWQW4Q dPlg== X-Gm-Message-State: APjAAAXu0rF+C/lKKw+VWjqNmtaHjvYRDZ0hSGsv0PF6dCUZjKSjV+Q6 1BBEAeyfLEu0PgFDh0X+r6PisGcU3TPJDEg95TmXjw== X-Received: by 2002:a9d:590d:: with SMTP id t13mr18027546oth.281.1565577475725; Sun, 11 Aug 2019 19:37:55 -0700 (PDT) MIME-Version: 1.0 References: <1870ea18729f93fb36694affaf7e9443733dd988.1564035575.git.baolin.wang@linaro.org> <20190727182709.037fc595@archlinux> <20190805145037.0a03f21e@archlinux> <20190811090251.5fbd7d75@archlinux> In-Reply-To: <20190811090251.5fbd7d75@archlinux> From: Baolin Wang Date: Mon, 12 Aug 2019 10:37:44 +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 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. -- Baolin Wang Best Regards