From patchwork Sat Aug 28 15:01:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Yuan X-Patchwork-Id: 12463555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D84DCC432BE for ; Sat, 28 Aug 2021 15:02:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A281F606A5 for ; Sat, 28 Aug 2021 15:02:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A281F606A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ryrAJ+LB5PywJ5ctBCIb8tnkyldey+u+FaHxUKZg8bk=; b=sD4VmehYfEMN0i WjPB5d8thOgjNgVOY1HKZ/XFvtka+AZXN6KdGonfnPdtizp22sKWbtE9nFKgAqTasJxunspxWQEaE PSCnQHs+u7MAYWYwoliG2qU6luZX/RDxpxQ5PWjUNYkkIsUnPNzYyElzIppl/cHjsdATc/Sr5BcgA o+YaOvdt9vyGIMKS9X73njTAFbmFNgquqdGGDu/IHmQO/rg7zU2UJRwgI2dCttctuaw+maSMBh5GT dD8IRNKHLVibk91893FN+sBvS0AU3kDTZ8gcu6uQqDSjAaDtvymgX2y4tackv+3R0DQlk1ot5lxB2 XjyZjmJAD+5ku9P8gNRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJzqE-00ENc2-7w; Sat, 28 Aug 2021 15:01:54 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJzpm-00ENX2-5Z; Sat, 28 Aug 2021 15:01:30 +0000 X-UUID: d9ddb158a2164c64bb3490e165f98194-20210828 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=1rdYNLSDcZK4EpIxHQykgJn4EheFgieS/Qvy5O+V+nE=; b=P8E5LFaDPcQkW5b/leQe+q9zFdVXdcSzuW21T5pE4Y2avnX8PuHo6gyGCVbFksAV5h5SC7+Bj4sbYILLAKWFANi3y94jEWihtkKMhOJG/8l2t4At//rgK8Ai1oB1k8YZqbrCieZG7a0q73eECI6pwLGxHdw0t2MT4BOFAI+qtLE=; X-UUID: d9ddb158a2164c64bb3490e165f98194-20210828 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1574201840; Sat, 28 Aug 2021 08:01:20 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 28 Aug 2021 08:01:18 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 28 Aug 2021 23:01:17 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 28 Aug 2021 23:01:17 +0800 From: Hector Yuan To: , , , "Rafael J. Wysocki" , Viresh Kumar , "Rob Herring" , CC: , , Subject: [PATCH v14 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Date: Sat, 28 Aug 2021 23:01:11 +0800 Message-ID: <1630162872-25452-3-git-send-email-hector.yuan@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1630162872-25452-1-git-send-email-hector.yuan@mediatek.com> References: <1630162872-25452-1-git-send-email-hector.yuan@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210828_080126_260856_47AB3689 X-CRM114-Status: GOOD ( 12.06 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: "Hector.Yuan" Add of_perf_domain_get_sharing_cpumask function to group cpu to specific performance domain. Signed-off-by: Hector.Yuan --- include/linux/cpufreq.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9fd7194..4916d70 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -1036,6 +1038,43 @@ void arch_set_freq_scale(const struct cpumask *cpus, } #endif +#ifdef CONFIG_CPU_FREQ +static inline int of_perf_domain_get_sharing_cpumask(int index, const char *list_name, + const char *cell_name, + struct cpumask *cpumask) +{ + struct device_node *cpu_np; + struct of_phandle_args args; + int cpu, ret; + + for_each_possible_cpu(cpu) { + cpu_np = of_cpu_device_node_get(cpu); + if (!cpu_np) + continue; + + ret = of_parse_phandle_with_args(cpu_np, list_name, + cell_name, 0, + &args); + + of_node_put(cpu_np); + if (ret < 0) + continue; + + if (index == args.args[0]) + cpumask_set_cpu(cpu, cpumask); + } + + return 0; +} +#else +static inline int of_perf_domain_get_sharing_cpumask(int index, const char *list_name, + const char *cell_name, + struct cpumask *cpumask) +{ + return 0; +} +#endif + /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;