Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1593687imj; Fri, 8 Feb 2019 04:11:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZZOUGlwwfPsyOGza7aPnQrWevvsxT2oK2mCnUJLBJls+Qo5agFONV5t2j+TkxKQ6ttFjSO X-Received: by 2002:a17:902:1022:: with SMTP id b31mr22208996pla.141.1549627907126; Fri, 08 Feb 2019 04:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549627907; cv=none; d=google.com; s=arc-20160816; b=BqYN2Kq1W5RpfRehR+pZMR50DwNs+25iJOtZEvMVXIio5aZQqQ+Ewm+P2XWMRiWkjL P13unRS5My2leBtqi94nSZZw6PWwCau04yYBbJ+9zCoh4tWIg59tKmhKafp9/Es7ADKJ VNQJz9xkA7X/IOodA/GzdvMNVAHs7gInKss97hASo+9C+vsOrLcI7T2Z0+dHSWWVK5C0 OeUufFIGYaVP4iTi04jB3htyw6f+dS2FTDw1qM2fgmbbEL+2887pDkp0EQ7MyZxJWHx7 ltb4gxQQB76LjmcafBlg7TGjfAfnczCqAEo7jYv0jFNUa/iAXsB7g/k7wKR7fUK7iGUn LjrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CZLHKWj2Q8DhmY54XjLnYgLZm9EiY/w6ycnNznhp46k=; b=uFYnOxxhDaUlfsInBKV/NR83MycKQ5wdCfae6vuoSDhKsaPCtw+6ZJcls0MIkJCGtw 3qhggsgmv37ldnZ9HZZYHQV9QFQo33LYpQBEDqVma+wzUEoYBKcB8QDP8QGelA1pydHZ /KoByuzm4VLI6uLC63VQ5nolnOnuxF0D7dyXPhr2UJ5PczsbkctorRSD4TWEgTyfgdCU U3qF+p1kF+X7A1s8jnfwZjB8Q1MDj8wf41Aj35ALmdh8lBtXEtyDOh1jUhMZJTyUXqbA zpjVvnd9mAqvAYK7TtSOCRQvk6KFvWnNB/kqRByGYmv1vsvbnzsd43+LUZ7Qa8vj1Ntn bnrA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si1807888pgv.498.2019.02.08.04.11.30; Fri, 08 Feb 2019 04:11:47 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbfBHMJz (ORCPT + 99 others); Fri, 8 Feb 2019 07:09:55 -0500 Received: from foss.arm.com ([217.140.101.70]:49858 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbfBHMJy (ORCPT ); Fri, 8 Feb 2019 07:09:54 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D49D80D; Fri, 8 Feb 2019 04:09:54 -0800 (PST) Received: from e107155-lin (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1948D3F719; Fri, 8 Feb 2019 04:09:51 -0800 (PST) Date: Fri, 8 Feb 2019 12:09:49 +0000 From: Sudeep Holla To: "Rafael J. Wysocki" Cc: Viresh Kumar , Marek Szyprowski , Linux Kernel Mailing List , Linux PM , Linux Samsung SoC , "Rafael J . Wysocki" , Nishanth Menon , Stephen Boyd , Bartlomiej Zolnierkiewicz , Dave Gerlach , Wolfram Sang Subject: Re: [PATCH 0/2] cpufreq/opp: rework regulator initialization Message-ID: <20190208120949.GB13043@e107155-lin> References: <20190207122227.19873-1-m.szyprowski@samsung.com> <20190208064957.zhyue42kpgaoslwm@vireshk-i7> <20190208103133.ysvaroyniuc3k4i5@vireshk-i7> <20190208113904.GB7913@e107155-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 08, 2019 at 01:03:10PM +0100, Rafael J. Wysocki wrote: > On Fri, Feb 8, 2019 at 12:39 PM Sudeep Holla wrote: > > > > On Fri, Feb 08, 2019 at 11:42:20AM +0100, Rafael J. Wysocki wrote: > > > On Fri, Feb 8, 2019 at 11:31 AM Viresh Kumar wrote: > > > > > > > > On 08-02-19, 11:22, Rafael J. Wysocki wrote: > > > > > There are cpufreq driver suspend and resume callbacks, maybe use them? > > > > > > > > > > The driver could do the I2C transactions in its suspend/resume > > > > > callbacks and do nothing in online/offline if those are part of > > > > > system-wide suspend/resume. > > > > > > > > These are per-policy things that we need to do, not sure if driver > > > > suspend/resume is a good place for that. It is more for a case where > > > > CPU 0-3 are in one policy and 4-7 in another. Now 1-7 are > > > > hot-unplugged during system suspend and hotplugged later on. This is > > > > more like complete removal/addition of devices instead of > > > > suspend/resume. > > > > > > No, it isn't. We don't remove devices on offline. We migrate stuff > > > away from them and (opportunistically) power them down. > > > > > > If this is system suspend, the driver kind of knows that offline will > > > take place, so it can prepare for it. Likewise, when online takes > > > place during system-wide resume, it generally is known that this is > > > system-wide resume (there is a flag to indicate that in CPU hotplug), > > > it can be "smart" and avoid accessing suspended devices. Deferring > > > the frequency set up until the driver resume time should do the trick > > > I suppose. > > > > I agree. The reason we don't see this generally on boot is because all > > the CPUs are brought online before CPUfreq is initialised. While during > > system suspend, we call cpufreq_online which in turn calls ->init in > > the hotplug state machine. > > > > So as Rafael suggests we need to do some trick, but can it be done in > > the core itself ? I may be missing something, but how about the patch > > below: > > > > Regards, > > Sudeep > > > > -- > > diff --git i/drivers/cpufreq/cpufreq.c w/drivers/cpufreq/cpufreq.c > > index e35a886e00bc..7d8b0b99f91d 100644 > > --- i/drivers/cpufreq/cpufreq.c > > +++ w/drivers/cpufreq/cpufreq.c > > @@ -1241,7 +1241,8 @@ static int cpufreq_online(unsigned int cpu) > > policy->max = policy->user_policy.max; > > } > > > > - if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { > > + if (cpufreq_driver->get && !cpufreq_driver->setpolicy && > > + !cpufreq_suspended) { > > policy->cur = cpufreq_driver->get(policy->cpu); > > if (!policy->cur) { > > pr_err("%s: ->get() failed\n", __func__); > > It looks like we need to skip the "initial freq check" block below. > Indeed, copy pasted an earlier version of diff. I found that I even used a goto label wrong which I fixed along with the additional check in "initial freq check" when I tried to compile :). > Also this doesn't really help the case when the driver ->init() messes > up with things. > Yes, in that case additional logic in the driver also needed. I am fine if we enforce driver to deal with this issue, but was thinking if we can make it generic. Also I was just trying to avoid adding _suspend/resume to driver just to avoid this issue. -- Regards, Sudeep