From patchwork Thu Nov 29 17:46:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152448 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2672684ljp; Thu, 29 Nov 2018 09:47:52 -0800 (PST) X-Received: by 2002:a19:f813:: with SMTP id a19mr1594176lff.67.1543513672293; Thu, 29 Nov 2018 09:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513672; cv=none; d=google.com; s=arc-20160816; b=xf8OJim7GBr2bD2twEgG46cDBWhsg/SbrDeLBMqpxFdoUdwdQCFEVPFmHD6fitOo+J PHC0E/nJCSPHgkeH0VY9aBLPOKg0gP20C1J9WBaCUGXC3L1f5W/iH/G4qtyw+W5C7MrO 9vhTnLh1xInAnrnHpgUst+n92Pfrdk1a6Dnk9MtBZZ2U00SHe7xEIawkxw5H7M9OKy50 Dk8lvoVachFIkGzFH9rDKvnYQxh7joYkTuDck5nl7XZ2f2TBAUkapO/xZZix2IGvG2FG 59paTc0np2NGVnANVS7NHq45eeod6C+b8cJskeOgz6a2p08spTdldwq4Jg4ZwUgTZi0i EaEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8XcXgSMicdNFExYNvXv93BQqc4PUMWszq8Q+N0PwQJQ=; b=CYWzOkrA9wtuzn6+H+K/de9VZEFw8zxZmG1fnAxrImBxm/2fq0br0EutBaci2NZ1bD WaaMzbjvYLZlc9FP8Tu1fnxCkNh+v4TRD0XaA9Ga1taLFYLikcOYW9XkkQvPwGIO6pRA h6yy8gXPT9TdsO3U5Wgr8Yft6hE+M2rqc2oOcj9aCOKaDb0nO5jvq4Ewj4KL4btS24wg 9EafD/i6FMMcsWKkUJisqpj00ZoscFf/spCmbzYXqXm3Ib6/q1WutY0f0ZBfXU9WztBM edtQbdWo9HSFAXqgmwhm4gJ9byA8JTEuY3hv2COztkhvfT/aR0tmpaq4tXQmpr6lbZrY SSVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UPPBOHan; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k25sor797399lfj.26.2018.11.29.09.47.52 for (Google Transport Security); Thu, 29 Nov 2018 09:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UPPBOHan; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=s3cCe/3HYJ+MpGTIgrHk7TYbGI3uC1lHvBuySW0kLX+QD3VBp5ONWQLrGm56uBiAVL ZhHtI+hZATzE4tNcNQOlFsczq2YCNrvnlnOMJzyBHbqsdwnrzXtJr1yfP3u+CsQss4H2 oI9JX861vN4bE2W/xk75hqoI3sCvYyPd5F+0DHt5gSHN0MCKxibKpl0EhQlwEoSl0pzX XTmDTBTXirHWFxocnjoFXK2hUIzcxgo5mZsvCNGFysZBUlvF9MnefKwkWP8GtGRc1160 qU4ilENNHaZUTfvuMResQM4o9pcbDmjrIF2ovYCoY4Su73EFB8NtL1mx8OLrl7PYJ7+f xFDw== X-Gm-Message-State: AA+aEWY8SCemHHgneECmIVjceIRle9d8zq23kXS48JVDE8DQkw62BSrb NbluuSDVH2jGF5J/1o1wixeuuA4s X-Google-Smtp-Source: AFSGD/Vv4orDwR+nTAJgZv7KcoNBHuFUfJ1RXoB3WL0hhWGM6CeGAm1v2qYblWtvCG+N9/GJet3jBw== X-Received: by 2002:a19:2d16:: with SMTP id k22mr1586183lfj.12.1543513671100; Thu, 29 Nov 2018 09:47:51 -0800 (PST) Return-Path: 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> 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(+) -- 2.17.1 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); }