lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181219111744.GA23393@e107981-ln.cambridge.arm.com>
Date:   Wed, 19 Dec 2018 11:17:44 +0000
From:   Lorenzo Pieralisi <lorenzo.pieralisi@....com>
To:     Ulf Hansson <ulf.hansson@...aro.org>
Cc:     "Rafael J . Wysocki" <rjw@...ysocki.net>,
        Sudeep Holla <sudeep.holla@....com>,
        Mark Rutland <mark.rutland@....com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        linux-pm@...r.kernel.org,
        "Raju P . L . S . S . S . N" <rplsssn@...eaurora.org>,
        Stephen Boyd <sboyd@...nel.org>,
        Tony Lindgren <tony@...mide.com>,
        Kevin Hilman <khilman@...nel.org>,
        Lina Iyer <ilina@...eaurora.org>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Geert Uytterhoeven <geert+renesas@...der.be>,
        linux-arm-kernel@...ts.infradead.org,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v10 24/27] drivers: firmware: psci: Support CPU hotplug
 for the hierarchical model

On Thu, Nov 29, 2018 at 06:46:57PM +0100, Ulf Hansson wrote:
> When the hierarchical CPU topology is used and when a CPU has been put
> offline (hotplug), that same CPU prevents its PM domain and thus also
> potential master PM domains, from being powered off. This is because genpd
> observes the CPU's struct device to remain being active from a runtime PM
> point of view.
> 
> To deal with this, let's decrease the runtime PM usage count by calling
> pm_runtime_put_sync_suspend() of the CPU's struct device when putting it
> offline. Consequentially, we must then increase the runtime PM usage for
> the CPU, while putting it online again.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@...aro.org>
> ---
> 
> Changes in v10:
> 	- Make it work when the hierarchical CPU topology is used, which may be
> 	  used both for OSI and PC mode.
> 	- Rework the code to prevent "BUG: sleeping function called from
> 	  invalid context".
> ---
>  drivers/firmware/psci/psci.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index b03bccce0a5d..f62c4963eb62 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -15,6 +15,7 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/arm-smccc.h>
> +#include <linux/cpu.h>
>  #include <linux/cpuidle.h>
>  #include <linux/errno.h>
>  #include <linux/linkage.h>
> @@ -199,9 +200,20 @@ static int psci_cpu_suspend(u32 state, unsigned long entry_point)
>  
>  static int psci_cpu_off(u32 state)
>  {
> +	struct device *dev;
>  	int err;
>  	u32 fn;
>  
> +	/*
> +	 * When the hierarchical CPU topology is used, decrease the runtime PM
> +	 * usage count for the current CPU, as to allow other parts in the
> +	 * topology to enter low power states.
> +	 */
> +	if (psci_dt_topology) {
> +		dev = get_cpu_device(smp_processor_id());
> +		pm_runtime_put_sync_suspend(dev);
> +	}
> +
>  	fn = psci_function_id[PSCI_FN_CPU_OFF];
>  	err = invoke_psci_fn(fn, state, 0, 0);
>  	return psci_to_linux_errno(err);
> @@ -209,6 +221,7 @@ static int psci_cpu_off(u32 state)
>  
>  static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point)
>  {
> +	struct device *dev;
>  	int err;
>  	u32 fn;
>  
> @@ -216,6 +229,13 @@ static int psci_cpu_on(unsigned long cpuid, unsigned long entry_point)
>  	err = invoke_psci_fn(fn, cpuid, entry_point, 0);
>  	/* Clear the domain state to start fresh. */
>  	psci_set_domain_state(0);
> +
> +	/* Increase runtime PM usage count if the hierarchical CPU toplogy. */
> +	if (!err && psci_dt_topology) {
> +		dev = get_cpu_device(cpuid);

I do not like adding this code in the cpu_{on/off} method themselves, I will
have a look at the patchset as whole to see how we can restructure it.

More to the point, using cpuid as a logical cpu id is wrong, it is a
physical id that you should convert to a logical id through
get_logical_index().

Lorenzo

> +		pm_runtime_get_sync(dev);
> +	}
> +
>  	return psci_to_linux_errno(err);
>  }
>  
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ