From patchwork Mon Oct 29 16:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 149685 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4348685ljp; Mon, 29 Oct 2018 09:24:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5c54evI6VYn+1DOza7CPQkrxaFpwFYz0BqVpFZ9922XnfbIvOF6jtYsP4MfH2H4FhMZJ7Hp X-Received: by 2002:a63:d52:: with SMTP id 18-v6mr14642836pgn.107.1540830243219; Mon, 29 Oct 2018 09:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540830243; cv=none; d=google.com; s=arc-20160816; b=HcRZkeGKznXvyRIJZsNh05ucFpcXR/F2Degnq/RPlY0WEYhCYvglD0zEDtRW9ZBNaP OQPHAny+HGmvd8iccFJi3DuPJSEm9ECzip37hlVldUywBoHQmBNUcvzFOSfi8/50WnYH I1D4SbJ9+XzRGHX9jzBdkup3O+oZ2t4xrkR9oiSxkt8tdyffyisV9eTUapSp+OkkdYUl yUl8YaTq9i6fdN/jdtIrVN60eDVRZ9BTLwbsJb2GqWzsRVptzHfhxQs56Fhb2y6fSCqy 9ivciAiogQYS8M/AcqKIZ82o1tCYK5aCoZybvZusNrrXx3aCUq45LYXHvu841jO9pfSs zYdQ== 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=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=ZCtCH08iHL/6Tc0PcwXhd6z5NfcAeZ3lMxCp7YGA5VsX4JK2LSSGuauluB8n9uPRIK QjHrpQuPPEfETgbMV/QWj2sBX8a4li0a2fAK2JRWs4e1T5kuTx6BDI53EjBSyRYEgVGL RfhUBJBeWlpqlu/Ut6INebypLL7dms3zIq2TOzPt1ugDgqC/kW/iaIgTReIFkSNgi+7/ 33wQAopmXSQX0cHWegQK4+LgIPeqXM2q4jzgs3dKHJ4YrbN6ZcttXJOBrOKchCzaE2G6 hvpHfgyDEZpXRobDWwxoOJrxS89l//R82K8F0Opl3Er03ec06yJ1vZefp6DPQt0wAUUA NBrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=du4esRFM; 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 63-v6si20701245pfg.178.2018.10.29.09.24.02; Mon, 29 Oct 2018 09:24:03 -0700 (PDT) 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=du4esRFM; 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 S1728130AbeJ3BNT (ORCPT + 32 others); Mon, 29 Oct 2018 21:13:19 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37103 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbeJ3BNS (ORCPT ); Mon, 29 Oct 2018 21:13:18 -0400 Received: by mail-wr1-f68.google.com with SMTP id g9-v6so9385199wrq.4 for ; Mon, 29 Oct 2018 09:23:59 -0700 (PDT) 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=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=du4esRFMfsG/CHN+tAw+Upgcaeh4mGCj+P/HX/DLpbrWe1SWcZNq92SMA+NmWYcrjf dDuFTN/RB/KhTo6vZnSgXxtTQ9eeE/oMZxaXmsBqUAZMbtUJn57+/WFt97KEypsQu2he npIR3XBuoZfKUpCzVXusp+Yt//RuxWOchtKak= 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=EHn6ZSQVTOKaLg/bsltnbcaMuQIuilo+eLx553lzoE4=; b=UGtefS/DIPOYgWTXg5jHml45778JNLv9m7AFIVtGevhFkPdItAehWejZqb2/oCqY5F /S0WcTgd+tYPGvtgceTHjH/iTycfFij1+UYxwzw3w9N8BSIfpINMvZ/9hTKcdHnuDBYF 10DUoEirvNS/duzI9HLJNyrUF3k0FcdgmDqsPiGj043hvuts5RUiqhEyzYWPCLvsvYOi NSJ91Z6FQMDhw1ilyMTnNRlWV/C+e5++ZovHbq3k+mpIjwOigbRhAEQGf/TLneCLtOmW M+4YRbg6TubvdKMM+2uW0aelvq0DHVR3hZi6ll7ftXRs6D82fT6m9jb+GtjvTtFBbVzY YEAg== X-Gm-Message-State: AGRZ1gKzLFBxAHJ6nErbrPBfeWAALkZtVxK3XhxA30LISsY26F8j/Sy2 EN4X4ewEhz+kPNUvQNEPFWhM4g== X-Received: by 2002:a05:6000:51:: with SMTP id k17mr14542750wrx.114.1540830238967; Mon, 29 Oct 2018 09:23:58 -0700 (PDT) Received: from localhost.localdomain (137.55.88.92.rev.sfr.net. [92.88.55.137]) by smtp.gmail.com with ESMTPSA id y19-v6sm28150499wra.60.2018.10.29.09.23.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Oct 2018 09:23:58 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, Chris Redpath , Quentin Perret , Viresh Kumar , Amit Kucheria , Nicolas Dechesne , Niklas Cassel , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 4/4] base/drivers/topology: Default dmpis-mhz if they are not set in DT Date: Mon, 29 Oct 2018 17:23:20 +0100 Message-Id: <1540830201-2947-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> References: <1540830201-2947-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the case of assymetric 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 comutation triggered, so we need to write 'capacity-dmips-mhz' for each CPU with the same value in order to force the scaled capacity computation. Fix this by setting a default capacity to SCHED_CAPACITY_SCALE, if no 'capacity-dmips-mhz' is defined in the DT. 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 Signed-off-by: Daniel Lezcano --- drivers/base/arch_topology.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 7311641..7d594a6 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -205,6 +205,21 @@ static struct notifier_block init_cpu_capacity_notifier = { .notifier_call = init_cpu_capacity_callback, }; +static int topology_set_default_capacity(void) +{ + int cpu; + + raw_capacity = kzalloc(num_possible_cpus() * sizeof(*raw_capacity), + GFP_KERNEL); + if (!raw_capacity) + return -ENOMEM; + + for_each_possible_cpu(cpu) + raw_capacity[cpu] = SCHED_CAPACITY_SCALE; + + return 0; +} + static int __init register_cpufreq_notifier(void) { int ret; @@ -214,9 +229,19 @@ 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); + + ret = topology_set_default_capacity(); + if (ret) + return ret; + } + if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) { pr_err("cpu_capacity: failed to allocate memory for cpus_to_visit\n"); return -ENOMEM;