Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1584515imj; Fri, 8 Feb 2019 04:03:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ5UrL0/+TLjSJ86M4OJsA0pDSuLTG9UgCGkKzrVD1hVnOn4m1NHsn29SGSvYAn9ayCyoJq X-Received: by 2002:a17:902:e01:: with SMTP id 1mr21798556plw.251.1549627426937; Fri, 08 Feb 2019 04:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549627426; cv=none; d=google.com; s=arc-20160816; b=Vc7lC94AJ6doEcR0XBc7X5EpTSQIq9XDBFx55ZZpRZeOLw9u3iZVSjVn/0IlSnx26M bj3QLH0pDd9ygicz6ehJHDhGarjPv6k5Ktu72Y6glk+Xc6+QCZVXq/7QuCE0+J0EEsNJ qmChH8v8/15x+Z7PQf0BdulLKJOF+e42wm1gZbEur+JQI5Tz2rrtrDNsANEUaDicsQ3n MzETRfB3ZWKvZ2gbtSYxwvH+Plq7ati91WSsnzCX4cx2cQKjTWJV5fq1i1mBq0kWM+w0 K9R5vMLIQ7v8I+N1F3ySUeSxWcpKbkKyJ7a7lbOJIjk0uo3wCk6m8rL3qmEyJopzgve5 jBUw== 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; bh=33Yc1xgAz4JvrWq/Cec+/bqJtEAgT4g1BZ9fsfhOVE0=; b=FtNs0yauNq9JEnX0P4yWzEV+LraIhWtHI1vgtVGQ+VuN0TdzBtRfqEvzotb+VUFi0n ubjjMOCbjyZaDJFAYztsnb7AwnuDAe5V/Y5SUsW+iaHz0Ml1NEjzGQnNQiigKNiOPpL8 Rxt9WogRmI9IbxTvU/h19F1oJYh08J1rzrQ1GzNBDdobgklqXdqwFQPs53wHw+dwsE7a F9ly5A9LJXshIQMEG+yARRCDEZRFDjL0iLqojFVYdYJR0ifyIqMxUWzZqP3Ub1HmbMrc AZjVflx+lNsHgCbFhmD0bs+GUixP5OSVvN5IumF9L+iIdSqPkPphvlau79DlplF2Gj9c Vo4Q== 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; dmarc=fail (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 w24si1970596pgj.582.2019.02.08.04.03.28; Fri, 08 Feb 2019 04:03:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbfBHMDX (ORCPT + 99 others); Fri, 8 Feb 2019 07:03:23 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:38827 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfBHMDW (ORCPT ); Fri, 8 Feb 2019 07:03:22 -0500 Received: by mail-ot1-f68.google.com with SMTP id e12so5409281otl.5; Fri, 08 Feb 2019 04:03:21 -0800 (PST) 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=33Yc1xgAz4JvrWq/Cec+/bqJtEAgT4g1BZ9fsfhOVE0=; b=BPGlTH94sVQvINjcAjJPrEoP1eDZOPx2qlcBJoQKVxSN9RcUe5pmFDTpL55kkFCim4 Q1l2CsFYzYEd3RT2FKWmYxBxyKVOJz6aI6Ct6+TDMpmarJuGFtyl4Vivzdd4Kwhcd4XD wW4OV+mK4W+pSYFHKnhfN60X/Qo2Ubs4mlEOm9d3TqGyOjPUnBIJgUHtsYn7ia79CxoJ ty5Gz+7JqFUdutZsNP+XxUK7vlqRS6ASIEwAYC0JDCuxMtGysfMaIHjajas03fS3nh/1 jScgQwoTKzcqObMRu1VwiArlnsdSQBGaBiALc1jM5Qpprccy/ZDdK04KO59jbQe0cu/6 vF8w== X-Gm-Message-State: AHQUAuapl/jrIM9ri8QgEcCXkC9eOZdz2l67cuSSHhmIumo9O/5Gd4kL Z/MOIxr+V2uUG8+QwVAeSZYz3rPOOqcPIU8hTeY= X-Received: by 2002:a9d:5f06:: with SMTP id f6mr12988335oti.258.1549627401281; Fri, 08 Feb 2019 04:03:21 -0800 (PST) MIME-Version: 1.0 References: <20190207122227.19873-1-m.szyprowski@samsung.com> <20190208064957.zhyue42kpgaoslwm@vireshk-i7> <20190208103133.ysvaroyniuc3k4i5@vireshk-i7> <20190208113904.GB7913@e107155-lin> In-Reply-To: <20190208113904.GB7913@e107155-lin> From: "Rafael J. Wysocki" Date: Fri, 8 Feb 2019 13:03:10 +0100 Message-ID: Subject: Re: [PATCH 0/2] cpufreq/opp: rework regulator initialization To: Sudeep Holla Cc: "Rafael J. Wysocki" , 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 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 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. Also this doesn't really help the case when the driver ->init() messes up with things. > @@ -1702,6 +1703,11 @@ void cpufreq_resume(void) > pr_err("%s: Failed to start governor for policy: %p\n", > __func__, policy); > } > + policy->cur = cpufreq_driver->get(policy->cpu); > + if (!policy->cur) { > + pr_err("%s: ->get() failed\n", __func__); > + goto out_destroy_policy; > + } > } > } >