Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1451940pxu; Thu, 17 Dec 2020 10:13:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7a9KemiPjp8FiBMfnhY8/bDbg68HozmfilVHbWWzIMukd+3tDGV6Q1lgeazIsjOk8dSIS X-Received: by 2002:a05:6402:158:: with SMTP id s24mr623290edu.19.1608228802443; Thu, 17 Dec 2020 10:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608228802; cv=none; d=google.com; s=arc-20160816; b=KLtknxye+bFlkiye69/A16z1m23aXgl8fQBDuIpWkPJtxVKGWDVyXZ23znSxEyZROQ /xATXx6bF11JmDpH1eqr348TfnPdA39pHgRor5Qik/8DqdIigeQNkeTNChuER6Opq27z VbimmCVGqS5jxUeF1eo6lqJFx1jt6t8WYLr0NDiwZ7cqJ36wqeBUupd7CbtNlpurPYWa TZMQh0/AM/jSudxwa52CTRMaZrcviL6UUUmuE4BKGQVh3nNwNFEnG/qPtNmxtBIbEf3H gPHaXdY24xAI6hYnl0odabE5V/a+MrrAOo07+xrTzrcJyreQO08mys+va0wD0JjmI/f7 oQyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NlDMl6XjPevCn3rRvWT/f1VR4LdbuUD4/E02zVLuVCI=; b=TDSv7OwIxrvCL3M3hvzcHmi/G780HBpO9HKXEICfwCDJu+VZV2dZrPncTfPA8LN51T Aj0JVV494vPFC7sPzFFdebqil4wg4YHtDVePjPuQtSFgz0yEUANmOglScnosWYBY1t7f BcyarUPZ1MvWM+S/bSNRP2Pbnu0tit9DJ1bxDJ7ge2O3rAtNqAcAlS52EhE4yDTDt8US 77qmZWWxHrk9aJ6qsnkrHPqYR4MF0mAH5HFV7F0znGQZc5/viAYdE9FkLfL1Dzn2FPx4 UFOkqYqUYTkJimxfRGTGTl/1vSw9GNBZ9yuD7bnX+CV8v7MyjkqnpAHkHT0IK/O/I41d uBVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RTWkhu3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si3114591ejw.117.2020.12.17.10.12.58; Thu, 17 Dec 2020 10:13:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=RTWkhu3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731641AbgLQSLm (ORCPT + 99 others); Thu, 17 Dec 2020 13:11:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730867AbgLQSJJ (ORCPT ); Thu, 17 Dec 2020 13:09:09 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE56EC0619D2; Thu, 17 Dec 2020 10:07:38 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id a9so59799937lfh.2; Thu, 17 Dec 2020 10:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NlDMl6XjPevCn3rRvWT/f1VR4LdbuUD4/E02zVLuVCI=; b=RTWkhu3VqMqpDCA4Qo24BTJf+2HuJmLcparbZ+4myGwK1DNAzIGrgipPwwDKIIjrKS ePerczxp+6zHrPN6Dqn9OXFrwkqgqVZKTxDtaFeEELTEv5tlBstMf0P3QwYRzM20vWTM BliaLVxvI1nhJVyskHZ3FMESXBjgr+oWdWqVqRNm2rlei11rc3wpmZbdQ4odalL2zKWD GwaPJoY/LSJ0dqPxg3Bq/HrsjDS7nXr5Uxa2HsKYjBt0fe7/MWnpeLhAWQ//k18Hkb4W Qgu8Q7C+KU3jCZyrFKxqARUQD6npMHl2BNPx+eMXU587ADHJ5fD/w80+TTFH/cNU5wLn gbKQ== 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:mime-version:content-transfer-encoding; bh=NlDMl6XjPevCn3rRvWT/f1VR4LdbuUD4/E02zVLuVCI=; b=G7jf1bFIuhwN4SatgeYauYCcWNpDkKAKZNP4v/Br7tH1xLeMZ73g8EE6aD/gr+hs3V 43EPV509HSnhBqughvICoAv6R9DLoAnWkmgKmov3SN0/KJDz0ThAZxaw2rk+nonJI0l5 waYM3D1WI5vAeEuPQVqgfnVBqLWWQkfGGKaLWRm7EfaMbeUoRIbdXYw1ypsXEsFpnMhH m0R1Vs9pgTPFKLR5H4q8izPBET7sKT/FXJhOvYwppSMyDfXcmUl1u1RzX9Q3i+f3dO6q MVde+pMTcKlzrWg0G+KibpZMsUKEkKYoCLlxOaxfAtKSvvPAUuw9ZKmueVpJJR9c8fry hIbg== X-Gm-Message-State: AOAM533yqW7Sf1lcW9m+t8tw9RIBsK5kfxphR/VoRt7hZI712xxyA1ks 9aYzSAEmyArtFM+ZXFmvKrk= X-Received: by 2002:a05:651c:2dc:: with SMTP id f28mr207871ljo.13.1608228457280; Thu, 17 Dec 2020 10:07:37 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:07:36 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 15/48] opp: Support set_opp() customization without requiring to use regulators Date: Thu, 17 Dec 2020 21:06:05 +0300 Message-Id: <20201217180638.22748-16-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support set_opp() customization without requiring to use regulators. This is needed by drivers which want to use dev_pm_opp_set_rate() for changing rates of a multiple clocks and don't need to touch regulator. One example is NVIDIA Tegra30/114 SoCs which have two sibling 3D hardware units which should be use to the same clock rate, meanwhile voltage scaling is done using a power domain. In this case OPP table doesn't have a regulator, causing a NULL dereference in _set_opp_custom(). Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3d02fe33630b..625dae7a5ecb 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -828,17 +828,25 @@ static int _set_opp_custom(const struct opp_table *opp_table, struct dev_pm_opp_supply *old_supply, struct dev_pm_opp_supply *new_supply) { - struct dev_pm_set_opp_data *data; + struct dev_pm_set_opp_data *data, tmp_data; + unsigned int regulator_count; int size; - data = opp_table->set_opp_data; + if (opp_table->set_opp_data) { + data = opp_table->set_opp_data; + regulator_count = opp_table->regulator_count; + } else { + data = &tmp_data; + regulator_count = 0; + } + data->regulators = opp_table->regulators; - data->regulator_count = opp_table->regulator_count; + data->regulator_count = regulator_count; data->clk = opp_table->clk; data->dev = dev; data->old_opp.rate = old_freq; - size = sizeof(*old_supply) * opp_table->regulator_count; + size = sizeof(*old_supply) * regulator_count; if (!old_supply) memset(data->old_opp.supplies, 0, size); else -- 2.29.2