From patchwork Mon Nov 26 12:20:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 152037 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5605046ljp; Mon, 26 Nov 2018 04:21:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/V2MrBvv5FaF4PXmmymn3VyNNrYffYzr2zWK2ZW/494aIPWQKsyThdog8HFNWnU/QmkLNvB X-Received: by 2002:a63:d513:: with SMTP id c19mr24749667pgg.287.1543234887501; Mon, 26 Nov 2018 04:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543234887; cv=none; d=google.com; s=arc-20160816; b=P7bGu1hzQHVhRstuClsK1axt1YpWVZA6I7ywLffC6zOJZubZRDh6rlqu6EGtJxOccy MO2qa/CrHGvT0jv9hbkTUH2f/fOGkZ/O+tF63zhnaCLcKbjajN7G3XirLmmxxChLo95p yBZi6YQlSy04W86sKT4eYo0MCcMHMG0WP7t4SRiPw3+V0lX0cJBPIE8G0ndlPUilzmRx BY3yqTVC3EbLbmE+Ww/6VaD/crkFI173apikMZD12xTqCiQi+o9TUDYhtcYLyFHZBv1p KJtaphyDCfLR8oFX6iWNS3Qae8zN6R8jkxMISvCXSLEiWnlpLIQRBhB43gayyqGsh4SI D13g== 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=abLiOL6He8MFbX9WjSZ+2m54aIn+aGbFhoF9OKEmlgQ=; b=z29d96k6GIegVqJiyHs0m9uSQOztzgZjxSNOF9N9IH8rgaMRcg5GF9ivj/OQTmhlt3 RE3rYTzmMbH7UY0M/Rk6Ncpndp3yVixjTI3/BG6WkZWYQu0567zbvVfmhYnA9Y8QxRk9 1CpB0MNZQB7/E/vXSY/JQgfpTx9hxprqo2ZvIahVKLYW6qObHoY9gN2usIKWH9VCI6q0 qLCLjAvMsa08GtsBiBadh7QKt5Ka+lfZN4+/n/f84e5pazkNoV3dKue3qxlLgdUwkzxr 6j3kxLrK/xd6f3dqrYi2Zw0UDSIKEtyaFLLiE7fDXItuO90/DHAztCqnURHARMQurBbK vZgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d27OAhIk; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 14si136744pgo.511.2018.11.26.04.21.20; Mon, 26 Nov 2018 04:21:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=d27OAhIk; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1726308AbeKZXPL (ORCPT + 6 others); Mon, 26 Nov 2018 18:15:11 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35648 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeKZXPL (ORCPT ); Mon, 26 Nov 2018 18:15:11 -0500 Received: by mail-wm1-f68.google.com with SMTP id c126so18140856wmh.0 for ; Mon, 26 Nov 2018 04:21:12 -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=abLiOL6He8MFbX9WjSZ+2m54aIn+aGbFhoF9OKEmlgQ=; b=d27OAhIkqIEYMn86QK8N/esaK8HPkoaRPnvQg3JdQZbvf5DmQuURNIZ8C5uRCvetg6 kyLjk8VHlkJ2PeY9g7GK7hS4QtjUDztrB6G//kVy2DdabFkM44ayF4IPZDp59/FbNYzw Woxpw6tOqJ6haxa8j7wYZ+Z8QI6dyYTCTJIqg= 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=abLiOL6He8MFbX9WjSZ+2m54aIn+aGbFhoF9OKEmlgQ=; b=rwtuwcnVHeU0erp2kKFxGH1iF0fsKygr+XBPbhnJ9B9/oLlCMDGFEhZwVuGlDx04Oo cemvGDFXacZmaUUSCNOMyHTcYpnCucrraveicj5Elt0cC/UmKfXJ/3blE8Dc/E4Woaiy QBM5743KrONLTBLFhjgNe0VgpW++wE04F+NXFQxDqrVpBcykHliMwXXAdxQuUx+2hX/M ziuUhICfUJ8uVGbEMt2w+rE02dr5cdpto3ePWRrgM63LVgbPuCqV9YuaMNGCVKQg+MnX qUJIRt78BC94j7UuJZL88EoVKnijvZHIN066xj3DsetThmZGSIdsEn5Trl4+bX6GKpOz k0UQ== X-Gm-Message-State: AGRZ1gLMC6xJowodkdbFXTBPz7wPYhlRQnxfpA15b2VqSdYi2Td7wxX0 +0mmZuFr4tvGRUVyA9XwqE2EIA== X-Received: by 2002:a1c:be11:: with SMTP id o17mr23003771wmf.111.1543234872086; Mon, 26 Nov 2018 04:21:12 -0800 (PST) Received: from localhost.localdomain (72.224.136.77.rev.sfr.net. [77.136.224.72]) by smtp.gmail.com with ESMTPSA id r76-v6sm797816wmb.21.2018.11.26.04.21.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Nov 2018 04:21:11 -0800 (PST) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, viresh.kumar@linaro.org, Chris Redpath , Quentin Perret , Amit Kucheria , Nicolas Dechesne , Niklas Cassel , Rob Herring , Mark Rutland , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Li Yang , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH V4 2/2] base/drivers/arch_topology: Default dmips-mhz if they are not set in DT Date: Mon, 26 Nov 2018 13:20:43 +0100 Message-Id: <1543234847-21611-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543234847-21611-1-git-send-email-daniel.lezcano@linaro.org> References: <1543234847-21611-1-git-send-email-daniel.lezcano@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In the case of asymmetric SoC with the same micro-architecture, we have a group of CPUs with smaller OPPs than the other group. One example is the 96boards dragonboard 820c. There is no dmips/MHz difference between both groups, so no need to specify the values in the DT. Unfortunately, without these defined, there is no scaling capacity computation triggered, so we need to write 'capacity-dmips-mhz' for each CPU with the same value in order to force the scaled capacity computation. In order to fix this situation, allocate 'raw_capacity' so the pointer is set and the init_cpu_capacity_callback() function can be called. This was tested on db820c: - specified values in the DT (correct results) - partial values defined in the DT (error + fallback to defaults) - no specified values in the DT (correct results) correct results are: cat /sys/devices/system/cpu/cpu*/cpu_capacity 758 758 1024 1024 ... respectively for CPU0, CPU1, CPU2 and CPU3. That reflects the capacity for the max frequencies 1593600 and 2150400. Cc: Chris Redpath Cc: Quentin Perret Cc: Viresh Kumar Cc: Amit Kucheria Cc: Nicolas Dechesne Cc: Niklas Cassel Reviewed-by: Viresh Kumar Signed-off-by: Daniel Lezcano --- Documentation/devicetree/bindings/arm/cpu-capacity.txt | 6 ++++++ drivers/base/arch_topology.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) -- 2.7.4 Tested-by: Quentin Perret diff --git a/Documentation/devicetree/bindings/arm/cpu-capacity.txt b/Documentation/devicetree/bindings/arm/cpu-capacity.txt index 84262cd..f53a3c9 100644 --- a/Documentation/devicetree/bindings/arm/cpu-capacity.txt +++ b/Documentation/devicetree/bindings/arm/cpu-capacity.txt @@ -54,6 +54,12 @@ fall back to the default capacity value for every CPU. If cpufreq is not available, final capacities are calculated by directly using capacity-dmips- mhz values (normalized w.r.t. the highest value found while parsing the DT). +If capacity-dmips-mhz is not specified or if the parsing fails, the +default capacity value will be computed against the highest frequency. +When all CPUs have the same OPP, they will have the same capacity +value otherwise the capacity will be scaled down for CPUs having lower +frequencies. + =========================================== 4 - Examples =========================================== diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index fd5325b..e0c5b60 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -243,9 +243,20 @@ static int __init register_cpufreq_notifier(void) * until we have the necessary code to parse the cpu capacity, so * skip registering cpufreq notifier. */ - if (!acpi_disabled || !raw_capacity) + if (!acpi_disabled) return -EINVAL; + if (!raw_capacity) { + + pr_info("cpu_capacity: No capacity defined in DT, set default " + "values to %ld\n", SCHED_CAPACITY_SCALE); + + raw_capacity = kmalloc_array(num_possible_cpus(), + sizeof(*raw_capacity), GFP_KERNEL); + if (!raw_capacity) + return -ENOMEM; + } + if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) { pr_err("cpu_capacity: failed to allocate memory for cpus_to_visit\n"); return -ENOMEM;