Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1483337imj; Fri, 8 Feb 2019 02:10:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IYK6nGA5CmhQgPwJJTlVDDIfN3AFqTqh1LUUYBaSfxl3fat3XThfu6wFLmW9VRr4Oj4h094 X-Received: by 2002:a17:902:e090:: with SMTP id cb16mr7859666plb.32.1549620625629; Fri, 08 Feb 2019 02:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549620625; cv=none; d=google.com; s=arc-20160816; b=bVjDJ5DRr/drO/5+gGgL0VP1ZlEHrFiOJGrryNa0TtDz0u4eGVKX8NMA2aLBH6WeLy 4qHH+MfB5pduZyYWZHGI+L9UCRECbwnurb2E5k77NZPZHrwLUwe4YF7QBmGG7jSVWHro IoAnapTcfQl8ihrIn4+z8cCFx7E1Vi+XOzSOaVaTCB2i5+6Sp8mPrdtOtGleJMf+5oUW DL8WYQ4SCs9VgsK7AhtDdy4w/OdfissqMwfBIQSn+J4lRGzbFAz6MbJQBBjjSVKQuX7Y 1RAqU/MKxSQK84kAm2YNXLfJXK2V9C3XdsLjCoKIZenCAeVL+pkhPbfZkDY5IYlhdVOJ YVLg== 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=kPS4HTgskwUlUMnOBvJo5+OvKhvbDqbJ2iI8tuXHBCU=; b=T+1DFWmwDU2DwJugd62Z1Da1dHIrCHWTOCYeVmZBZ32RU4AmiEcmHeV/IOuCp2uoK5 TGmqOSK+3L9BFAT/mAJutKPsJCHYSgN7W07AU1IgwSryCkJy6FZ4y575xB4TqhPCYNCT EIBkTHDB4hyzIvqET7vs1qqmG0J2OAHdTROJF402Mut6p2YmHg2XwXu8pY4h7b6AW5VI 1biTCgU8WFHTqMuOORP1JaN+W05jmJFIEMmLdamLlKJrC8bdAynZ9D+jaiBQmt67R71v e1z98c3B9mBRPVB0oZXscV9iHc1MWJsTGGPqyCHD5UD90x+I1IXvlS/UwB6Rkt4jjwO7 9D5g== 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 h85si1870344pfd.27.2019.02.08.02.10.09; Fri, 08 Feb 2019 02:10:25 -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 S1726679AbfBHKIw (ORCPT + 99 others); Fri, 8 Feb 2019 05:08:52 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45676 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726063AbfBHKIv (ORCPT ); Fri, 8 Feb 2019 05:08:51 -0500 Received: by mail-ot1-f66.google.com with SMTP id 32so4868726ota.12; Fri, 08 Feb 2019 02:08:50 -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=kPS4HTgskwUlUMnOBvJo5+OvKhvbDqbJ2iI8tuXHBCU=; b=JVdC7PJEwc4ipF/NeDx2ZYIV90UT1Tu8f7497kIk4NFv7Dbw/xwhWCiIerHXPyyATU AozpaJRs3LoEelI3ktZWzntJz1R238v7wMOg6p+0/Ly+NxziRhsnjfMNzYh7TpM0VQCK ArgWBPLql82nUjZXrs9F4R7VVxoSNPw6DS1KD7fDboVSuTZ1JsHGmz6xPz88+maVY1BW alqelO+YpiavuOEvhKr4fjCR1Rqtxk2sp7iZw2cXB5PiXprmskAItgIWyspzoOqnEcuG /wcvK3HTSWI0nLOsrLNNPELSg5xVvlJfSWro8fQQtC3dLrxLaFvlHbKCG7QFY8wK26TB iX2g== X-Gm-Message-State: AHQUAuYdVspGFKnkSyAJoJLMP3SgSmRK13SQnMfvnkp0BvQM/nPVNe7V HS5QkOC4yy2F86egcumGfRFzBcbv0wZJmEOrAX8= X-Received: by 2002:a9d:2062:: with SMTP id n89mr4225692ota.244.1549620529635; Fri, 08 Feb 2019 02:08:49 -0800 (PST) MIME-Version: 1.0 References: <20190207122227.19873-1-m.szyprowski@samsung.com> <20190208064957.zhyue42kpgaoslwm@vireshk-i7> <20190208085544.vqkebcgg7jpbv2a6@vireshk-i7> <20190208092348.uqkfgxwx2pe3lmpd@vireshk-i7> In-Reply-To: <20190208092348.uqkfgxwx2pe3lmpd@vireshk-i7> From: "Rafael J. Wysocki" Date: Fri, 8 Feb 2019 11:08:38 +0100 Message-ID: Subject: Re: [PATCH 0/2] cpufreq/opp: rework regulator initialization To: Viresh Kumar Cc: 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 10:23 AM Viresh Kumar wrote: > > On 08-02-19, 10:15, Marek Szyprowski wrote: > > On 2019-02-08 09:55, Viresh Kumar wrote: > > > On 08-02-19, 09:12, Marek Szyprowski wrote: > > >> On 2019-02-08 07:49, Viresh Kumar wrote: > > >>> Why don't you get similar problem during suspend? I think you can get > > >>> it when the CPUs are offlined as I2C would have gone by then. The > > >>> cpufreq or OPP core can try and run some regulator or genpd or clk > > >>> calls to disable resources, etc. Even if doesn't happen, it certainly > > >>> can. > > >> CPUfreq is suspended very early during system suspend and thus it does > > >> nothing when CPUs are being offlined. > > >>> Also at resume the cpufreq core may try to change the frequency right > > >>> from ->init() on certain cases, though not everytime and so the > > >>> problem can come despite of this series. > > >> cpufreq is still in suspended state (it is being 'resume' very late in > > >> the system resume procedure), so if driver doesn't explicitly change any > > >> opp in ->init(), then cpufreq core waits until everything is resumed. To > > >> sum up, this seems to be fine, beside the issue with regulator > > >> initialization I've addressed in this patchset. > > > Yeah, the governors are suspended very soon, but any frequency change > > > starting from cpufreq core can still happen. There are at least two > > > points in cpufreq_online() where we may end up changing the frequency, > > > but that is conditional and may not be getting hit. > > > > Then probably cpufreq core suspend should handle this. > > Handle what ? That code is part of cpufreq_online() and needs to be > there only. > > > >>> We guarantee that the resources are available during probe but not > > >>> during resume, that's where the problem is. > > >> Yes, so I've changed cpufreq-dt to the common approach, in which the > > >> driver keeps all needed resources for the whole lifetime of the device. > > > That's not what I was saying actually. I was saying that it should be > > > fine to do a I2C transfer during resume, else we will always have > > > problems and have to fix them with hacks like the one you proposed > > > where you acquire resources for all the possible CPUs. Maybe we can > > > fix it once and for all. > > > > It is fine to do i2c transfers during cpufreq resume (see > > By resume I meant system resume and the whole onlining process of > non-boot CPUs. > > > drivers/base/power/main.c dpm_resume() function for exact call place). > > The problem is that such calls are not allowed in ->init(), which might > > be called very early from CPU hotplug path (CPUs are resumed in the > > first step of system resume procedure). > > Right and that's where I think we can do something to fix it in a > proper way. > > > What's wrong with my proposed fix? It is not that uncommon to gather all > > resources in probe() and keep them until remove() happens. > > For cpufreq drivers, we must be doing most of the stuff in init/exit > only as far as possible. I am not saying your patch is bad, that is > the best we can do in such situations. But I don't like that we have > to get the resources for all CPUs, despite the fact that many of them > would be part of the same policy and hence share resources. The > problem was that we need to get sharing-cpus detail as well in probe > then, etc. > > I was thinking about doing disable_nonboot_cpus() much earlier as the > userspace is already frozen by then. > > @Rafael: Will that slowdown the suspend/resume process? Maybe not as > we are doing everything from a single CPU/thread anyways ? First, we used to do that and we switched over to what we have right now several years ago, because it didn't work reliably then. Arguably, CPU hotplug is in a much better shape now, so it might be working better, but that would be a huge change and lots of documentation would need to be revised. :-) Also it is not true that everything is done on a single CPU, but I'm not really sure about the possible slowdown. Second, there are (many) systems for which that change is not really necessary and it is risky because of possible regressions. I guess that CPUs depending on I2C for online/offline could be taken offline earlier and brought back online later during suspend/resume, like before/after the _noirq suspend of devices, but doing that on all systems altogether is almost guaranteed to introduce regressions.