From patchwork Tue Sep 1 10:27:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248841 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4091035ilg; Tue, 1 Sep 2020 03:27:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYA+yTSBA018qgCrInEzaPJh/0DUTmpyyLL+iFGgYJRLYgPFVDP5RcBzpsAfL5KwaY6cmk X-Received: by 2002:a17:907:94cf:: with SMTP id dn15mr899005ejc.114.1598956050662; Tue, 01 Sep 2020 03:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598956050; cv=none; d=google.com; s=arc-20160816; b=BXTWQSfJ+zw/kDjpsMRVrDRec38AbOldgMvGYzGTUc8qqVrfQJeHftsRih+J4l1tyX VFdgadJTmyggUH04B5SORLxsYeSc9MhkOQ+FrJPz2juTXXoPeDRMovA8dvnxe2zuJHIK nDSXAR01cefTkxpnywTAdWK/oYxhK9qWUoMSc8dCBqE+Hjp5A4P1GPvGmDLAvcoLLX02 bGZjV4tc2C8APaZyi7UAdb1hmqWDMDH4IPiQLsbVS9M5bC9ftej/Q3R0Lj0qlTcHtvhX ZccOCUGQ1jsSZnA1KJeVUG2sBj9TB5ZObwZldgWhEVHjZcadSAB1ZJ0yh4tT3cswmCpV ELXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rpn9D/5jf8Cl22DmcPIsP0D+8jPdGfJ5t9xD++zoV1Y=; b=bWl4qOG26vjZhBYrXcADMgq2ieKk6e6oUPzdp21ZBZXyB8N87J+kMp+zasH+ocrkcn HM7K3kN+exuCqR97Asg/Viqm8Eo/dS1O4s8sFqIQOTZ9TxA7bDANdkg10pWpJ28vyq02 9U6+CnBnX+bGk/By9rA3CEmTSsXXd4ay43PjfIgiIaJkFAYMxf7bXCqe/B0wulcx7ZfK ovAwsJMNOLucMagf+pfWY8vQ/hwPAQIcVCdomzllQAGb+uK2AvxfR9HFjZZR8ew2MBOa GMQks0dYMihmK+6fBi7uLWaxkXKdZmP4HR/TmiM0VFxr9SYLWnleWmdjGHPiVZpJ65a3 LRaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tk/7VJW1"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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. [23.128.96.18]) by mx.google.com with ESMTP id b16si419426ejc.244.2020.09.01.03.27.30; Tue, 01 Sep 2020 03:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tk/7VJW1"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1726126AbgIAK12 (ORCPT + 10 others); Tue, 1 Sep 2020 06:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgIAK11 (ORCPT ); Tue, 1 Sep 2020 06:27:27 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C2DC061245 for ; Tue, 1 Sep 2020 03:27:26 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id o68so545024pfg.2 for ; Tue, 01 Sep 2020 03:27:26 -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:mime-version :content-transfer-encoding; bh=rpn9D/5jf8Cl22DmcPIsP0D+8jPdGfJ5t9xD++zoV1Y=; b=tk/7VJW1f+B+d95M0Sy7avts3U1k6DUjgFMhJuU1znFnZ+74BtL+25cGrXcRehXyX+ 3oBs28+vr+MiH7bp1nKwcRuK8fqq5HZoZ5aUojM2/4bF4Hh8aoNHubPGlMZkEzr/AHtH N3eISZ78fEOZPQbtjjLM59p97evtmvWwMieOYQrQEM1bwxPogJq8m3n0s3axUTkMAV0i GI82DiLS2enBEh4KJKTnyRljMFBHIp5jb68ZrDBBUGiQKCpDXJJfX0aDMqJ51+ITJY8n I8BSLwfr9A1aYCOKzMMYtB3GueAvRNZR26g8vI0/IrMknt4YGwkg6xq+8VJET5ea/vT1 bnZA== 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:mime-version :content-transfer-encoding; bh=rpn9D/5jf8Cl22DmcPIsP0D+8jPdGfJ5t9xD++zoV1Y=; b=oGOkb3cW34wmvYO5XO2rEfj/5Fx8bYtVAKPScfeysR+HM2MxDoKpYJQaefszavZR3Z 9RRv8RUySbXrVRHLa3mdnJxlavdwMWrhaNsVO7PpdYoWxjIlrwhjmMnGY3DLexezhJ8D QqWP7YE/KRNKmMOoJR3fLaSsA76cs4g0HCTgyUysU8siCEtz04ndIHIHWy2Gh8Qpbskv mi7tyQn7MeSOZEsB6CTqdHjsvTY/dTaSoIMKU2eS5Gq2nDym8fQmWowAF5Hb43/wEiYN 2gQSiikvdc4QinoaQNnSWn0yJdlUghTo/BJL+s3NxG9il7SfiXilJ9mzw5PiznZO0VLi sqSA== X-Gm-Message-State: AOAM532K2B/AaV6TdF4NHcKtiUp21/kznuiMywOlv09j22nmYW2DYKBd 95OM6UzzUQWyVsz1ieQqnjxc0w== X-Received: by 2002:a63:4401:: with SMTP id r1mr881229pga.331.1598956046238; Tue, 01 Sep 2020 03:27:26 -0700 (PDT) Received: from localhost ([122.167.135.199]) by smtp.gmail.com with ESMTPSA id h11sm1419135pfq.101.2020.09.01.03.27.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2020 03:27:25 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , stephan@gerhold.net, Marek Szyprowski , linux-kernel@vger.kernel.org Subject: [PATCH] opp: Handle multiple calls for same OPP table in _of_add_opp_table_v1() Date: Tue, 1 Sep 2020 15:57:18 +0530 Message-Id: <99f1c7ff37b00d2f59fbce9d934abf23932363c5.1598956021.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Until now for V1 OPP bindings we used to call dev_pm_opp_of_cpumask_add_table() first and then dev_pm_opp_set_sharing_cpus() in the cpufreq-dt driver. A later patch will though update the cpufreq-dt driver to optimize the code a bit and we will call dev_pm_opp_set_sharing_cpus() first followed by dev_pm_opp_of_cpumask_add_table(), which doesn't work well today as it tries to re parse the OPP entries. This should work nevertheless for V1 bindings as the same works for V2 bindings. Adapt the same approach from V2 bindings and fix this. Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/of.c b/drivers/opp/of.c index d8b623cc015a..6fc56660fa52 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -886,6 +886,16 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) const __be32 *val; int nr, ret = 0; + mutex_lock(&opp_table->lock); + if (opp_table->parsed_static_opps) { + opp_table->parsed_static_opps++; + mutex_unlock(&opp_table->lock); + return 0; + } + + opp_table->parsed_static_opps = 1; + mutex_unlock(&opp_table->lock); + prop = of_find_property(dev->of_node, "operating-points", NULL); if (!prop) return -ENODEV; @@ -902,10 +912,6 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) return -EINVAL; } - mutex_lock(&opp_table->lock); - opp_table->parsed_static_opps = 1; - mutex_unlock(&opp_table->lock); - val = prop->value; while (nr) { unsigned long freq = be32_to_cpup(val++) * 1000;