Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2762658imu; Thu, 29 Nov 2018 09:49:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/WJcbW56MU33Zsnds0SIGjpD1F4YQ/ELXvMjy7/aiA+Cd7mtFFuLqFfxUevvapXum3AFw0v X-Received: by 2002:a17:902:74c1:: with SMTP id f1mr2330170plt.273.1543513765840; Thu, 29 Nov 2018 09:49:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513765; cv=none; d=google.com; s=arc-20160816; b=u2QnWohrFRPm2EcpBjNCO2iwAS5lj1J2wD+HWep28ZP/XvylyE8FQdNAkWaMxe3QMm R5uUCc3iHN8L6A8rkmo7X4nkSadOIcY8F6RecTjxsbCzEl4aYp5eJjeIjk9+fmLWwpsO JItVIYwIOsgk3OxAPIDGzTX+NGWC/NMXWGDlzEgQhzk12Ve3CAX9P5m4VnI2MMkEhkI5 h22c+CzR3V/qD8H7nS2+G3DA5zERRuwg9rrHNj+zGAToJXcgxXvMiFnzWvkDYge0Tjbj nDSqhUkxhvAW6qKkWSTTx1bgFv38YCMR9ySzLPhgdPA56EVmGhCfp1TrrWD6BLMHs1jy ZRFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=dM1WpwRCEoJjJc8mZBTrjnerxq4AZwOZEaE4+VxrRIkOLSesVh8VIq3vc17ilizwwK ulrCoOGNfcD3DOfBP/5QKZlmQ28WebFr0xNMW9kZ9MNf7rLVNUkIwlpxoF0AeW2Y/I1e gLllABAB4TP/FFvfDZSNqbIYf+ibYjKsBDU975QvjHtCflGeeONlkdG27Fybn+yfaepi FQy8GigRjW0DUkUAKvRdjZN7jHMy6iXHfwcZNgDt5ogJrWhfVBr1MqufXqGdr1NZIEt6 FIMHQbOciv8HDOP8Uc6uEh42dHTFAPPRqfpgstlmsf/1+8l1In3EKb/UH/W4g4Y8sYGs IsoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UPPBOHan; 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 61si2676011plc.364.2018.11.29.09.49.11; Thu, 29 Nov 2018 09:49: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; dkim=pass header.i=@linaro.org header.s=google header.b=UPPBOHan; 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 S1731167AbeK3EyF (ORCPT + 99 others); Thu, 29 Nov 2018 23:54:05 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41866 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731138AbeK3EyE (ORCPT ); Thu, 29 Nov 2018 23:54:04 -0500 Received: by mail-lf1-f65.google.com with SMTP id c16so2097897lfj.8 for ; Thu, 29 Nov 2018 09:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=UPPBOHaniBcnAzLge02a1Ved7MDAgwg3PT63fbQBxmWP6r7IUNmB9wBF+cpdUregbU YNpOhRm0kjRcXF6xnbJ01Ca2Erys97CKhH7FfDfbIj5YdHlt1zhk9sD+G18xFUEPnTeG o/6qnFNHOkaoXtqDBngZxRNXPyWTOoR/EGa+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=tNbJ+9un/JDcFWkSZbOgj7OvDShq9bYNVKg8xLXh3MhjKLUMI48IKPpJb3AYUpym5q pejBTqxdAyo2F2q8uxjrTroimoiJNCKwDtcNTvWPljz8DVEDPeFpcCHqdFKSOjZw/JEe EjKuQsJUufNneCZzOsgmJvrbpkco1mQEmabUIjv7C56VI/KuvPHcXEDnik0Ni8XoMuIb GXh629iQooJ1AF33sEMt59ext43RVohD5bQzW0EF6ANc9aA2eNd7fxgOL19zqJukh3Ae PhHlddDsD/+FQxnuHMNnA6sxTRbZShv6kAHwfusiyzIo8QJrapdRRDm4lYNxFU2Ea7I5 grHQ== X-Gm-Message-State: AA+aEWYjX4HVVgSmAN44JeMpI+4OL5TDkNEl9e04HtXa0s8U58NZrBwU YvL1bHVyTYMy5Ucb3OijJjnrzA== X-Received: by 2002:a19:2d16:: with SMTP id k22mr1586183lfj.12.1543513671100; Thu, 29 Nov 2018 09:47:51 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:50 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 24/27] drivers: firmware: psci: Support CPU hotplug for the hierarchical model Date: Thu, 29 Nov 2018 18:46:57 +0100 Message-Id: <20181129174700.16585-25-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include +#include #include #include #include @@ -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); + pm_runtime_get_sync(dev); + } + return psci_to_linux_errno(err); } -- 2.17.1