From mboxrd@z Thu Jan 1 00:00:00 1970 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 859C7C433E6 for ; Wed, 23 Dec 2020 06:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49A9322518 for ; Wed, 23 Dec 2020 06:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbgLWGBp (ORCPT ); Wed, 23 Dec 2020 01:01:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727160AbgLWGBp (ORCPT ); Wed, 23 Dec 2020 01:01:45 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 072D4C06179C for ; Tue, 22 Dec 2020 22:01:05 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id x18so8603637pln.6 for ; Tue, 22 Dec 2020 22:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=WvDRkmfxJVkbMxrPHfQO3jIIP0y/4x9UMXb4LToUg0c0YVvY1v4RZrwNlueMl3TxUA LhGgJdJ92dhnRdqfHs6g8anfNRbf1l3Kmc9/pX6fAPYlRtoT262w08UsgSlWlqjwupim 2rTRdJaJfAcBRk7WFZGXpnHhMzcnnfOVRchCFyriNz+u0XQ8rIHPtECtKub6jjl2X1+5 u0ItXOKm5ZnduCP8Cm7CrIEnXL9xd920+5LPpI6GbeLhPSxVFzdGqmDFUxmXoFqjPlZL qvMtwOzbFqkFpFexgWWO5Tdjz5PhXaRJUfKZ1KFBLp0LcE39lWeRM19YL0vgg7wtne1B Yrtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=ckoYYdSzQo8T9Hzq0MQEmmJDVbIkipu7CI3RRpOmAAURG9N9/3CkPDez3UgCftY/oR pqQeCBRrQzOK/SPnxKd91agfQXHbdHyW+u30y+dL9cRt4dBPg81pzR8T+3TseRjf4OE2 PEjZvCCxSvtbLyfu/l9W5AjV2gVWM1EN4+TRDg5RlA4ZkJINo6nRItSLzuWzk+kZqDFo XHLz2LpdrVrjiKR+tgtLblFtQGL8QsaJTNOt3vpV36gFxvaAMNxDN/L9oqc0Ar7rHJ+Z idijkcAIF4SDIhOuc/hww/IzIUCFkAh7DJGL4E8OvpxN5KfcDfH58Vmo7pG9V5BeMsoi Vk+w== X-Gm-Message-State: AOAM530WZZEeeFya6snkxL9wEWTqGMQx36wNrjGxMkrbTB2RIButLQ8L kcAVC2XdRKz0XevpdUGqjkIjtQ== X-Google-Smtp-Source: ABdhPJyh2KPTGU4ayTa1XNiz400Y+zyRHMud7qFaV0QD/t+nRNJvznyZNbPeqd5VSc3ukQwC7r4DkA== X-Received: by 2002:a17:90b:16cd:: with SMTP id iy13mr24835386pjb.182.1608703264363; Tue, 22 Dec 2020 22:01:04 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id y27sm22645455pfr.78.2020.12.22.22.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 22:01:03 -0800 (PST) Date: Wed, 23 Dec 2020 11:31:01 +0530 From: Viresh Kumar To: Dmitry Osipenko Cc: 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 , 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: Re: [PATCH v2 15/48] opp: Support set_opp() customization without requiring to use regulators Message-ID: <20201223060101.v2qihvvgsmpahg24@vireshk-i7> References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-16-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201217180638.22748-16-digetx@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On 17-12-20, 21:06, Dmitry Osipenko wrote: > 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; > + } > + We should use the same structure, you can add some checks but not replace the structure altogether. > 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 -- viresh From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 AE831C433E0 for ; Wed, 23 Dec 2020 06:01:13 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 63B1322518 for ; Wed, 23 Dec 2020 06:01:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63B1322518 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 439EA85D4B; Wed, 23 Dec 2020 06:01:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mj3psNQ9lv85; Wed, 23 Dec 2020 06:01:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1F28985D44; Wed, 23 Dec 2020 06:01:10 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 337F61BF41B for ; Wed, 23 Dec 2020 06:01:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2FEED86FF8 for ; Wed, 23 Dec 2020 06:01:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x3I4E4gyNdx1 for ; Wed, 23 Dec 2020 06:01:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8318386FC8 for ; Wed, 23 Dec 2020 06:01:04 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id g3so8609169plp.2 for ; Tue, 22 Dec 2020 22:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=WvDRkmfxJVkbMxrPHfQO3jIIP0y/4x9UMXb4LToUg0c0YVvY1v4RZrwNlueMl3TxUA LhGgJdJ92dhnRdqfHs6g8anfNRbf1l3Kmc9/pX6fAPYlRtoT262w08UsgSlWlqjwupim 2rTRdJaJfAcBRk7WFZGXpnHhMzcnnfOVRchCFyriNz+u0XQ8rIHPtECtKub6jjl2X1+5 u0ItXOKm5ZnduCP8Cm7CrIEnXL9xd920+5LPpI6GbeLhPSxVFzdGqmDFUxmXoFqjPlZL qvMtwOzbFqkFpFexgWWO5Tdjz5PhXaRJUfKZ1KFBLp0LcE39lWeRM19YL0vgg7wtne1B Yrtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=Y5RZzMlC7gtY/3MJL117S9/HM0Ony0N0ZHz59lUhlUlVvyN8VGEmUOaSpsSUzwzLYy JdjgQGxRBzrZ91incDpBXeSzUx/KjQcJdhIFrE872WthINbsfICqoo/TH4kdLF69xtSE H2WAgR1Zxp2ZJF+osMotigKse6JTkZ0psSPa3kfIS79fQ0fG10BNPiRSZ25MuSalaVrp GZCP4sMHetQI6gCkZiT5/oZJoiXP/Sy2qw/8qf1mAL1rav3Hr0G73p+w+Uagm00b1qZj /E+ZSl3Uku2i/3Y8alNUPbwv6kPvt0gEHXbeVRtAGLSlTSPmq7HeswHCfc8jSMUds1z8 bZjQ== X-Gm-Message-State: AOAM532G6d+GHI7GaV8z8N9UNIF6x9CTfeFtjGEawKICG8axW5hRLFdN Bj2hzOPblRR2hL+5xrttPKE4zQ== X-Google-Smtp-Source: ABdhPJyh2KPTGU4ayTa1XNiz400Y+zyRHMud7qFaV0QD/t+nRNJvznyZNbPeqd5VSc3ukQwC7r4DkA== X-Received: by 2002:a17:90b:16cd:: with SMTP id iy13mr24835386pjb.182.1608703264363; Tue, 22 Dec 2020 22:01:04 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id y27sm22645455pfr.78.2020.12.22.22.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 22:01:03 -0800 (PST) Date: Wed, 23 Dec 2020 11:31:01 +0530 From: Viresh Kumar To: Dmitry Osipenko Subject: Re: [PATCH v2 15/48] opp: Support set_opp() customization without requiring to use regulators Message-ID: <20201223060101.v2qihvvgsmpahg24@vireshk-i7> References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-16-digetx@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201217180638.22748-16-digetx@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Michael Turquette , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thierry Reding , linux-clk@vger.kernel.org, devel@driverdev.osuosl.org, Kevin Hilman , Nicolas Chauvet , Viresh Kumar , Krzysztof Kozlowski , Jonathan Hunter , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , linux-tegra@vger.kernel.org, Mauro Carvalho Chehab , Stephen Boyd , Peter De Schrijver , "Rafael J. Wysocki" , Liam Girdwood , Mark Brown , Peter Geis Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" On 17-12-20, 21:06, Dmitry Osipenko wrote: > 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; > + } > + We should use the same structure, you can add some checks but not replace the structure altogether. > 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 -- viresh _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 0C18CC433E6 for ; Wed, 23 Dec 2020 10:52:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 CD09B207F7 for ; Wed, 23 Dec 2020 10:52:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD09B207F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DBEE6E8EF; Wed, 23 Dec 2020 10:52:03 +0000 (UTC) Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by gabe.freedesktop.org (Postfix) with ESMTPS id B692C6E8C6 for ; Wed, 23 Dec 2020 06:01:04 +0000 (UTC) Received: by mail-pj1-x1036.google.com with SMTP id hk16so2611714pjb.4 for ; Tue, 22 Dec 2020 22:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=WvDRkmfxJVkbMxrPHfQO3jIIP0y/4x9UMXb4LToUg0c0YVvY1v4RZrwNlueMl3TxUA LhGgJdJ92dhnRdqfHs6g8anfNRbf1l3Kmc9/pX6fAPYlRtoT262w08UsgSlWlqjwupim 2rTRdJaJfAcBRk7WFZGXpnHhMzcnnfOVRchCFyriNz+u0XQ8rIHPtECtKub6jjl2X1+5 u0ItXOKm5ZnduCP8Cm7CrIEnXL9xd920+5LPpI6GbeLhPSxVFzdGqmDFUxmXoFqjPlZL qvMtwOzbFqkFpFexgWWO5Tdjz5PhXaRJUfKZ1KFBLp0LcE39lWeRM19YL0vgg7wtne1B Yrtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4NTrNWSzSRmqwCvEQTSp0+nnEx8m/nIQOMiO0uIjc1c=; b=CJr3zEvddzjbliv+PUcrEGJSfB5hftiXjmKsYdF7oLoLv0aU9oX23aYcUKzq6KjJ3/ 2zevKIbpCVzHu4tdcX0pLeghBxaMaP1W90Lm0lmpuKVlNZsFGFIvta1CZkPPZaqS3e1Y bjP6z7NBUHJgNRPS4jVfAGbR9ku2KFxQpAaN6qIB9PBNolQG5Hv3eD+PV3+6Q7sDyXiD DykCBcsLZMpLCjaaRC9lsvHL/Co8gtuGUksHc22gRpWXdt53JUsbA6IdADQMOWEW+Nuu UDr3SlFZZZxE8IXYmMvUDYlVgZUwAYuEptFDVEAr6WFJ7LjAsrF2+dou2YbxFbLTnca6 J3Gw== X-Gm-Message-State: AOAM531Dm8J95zSgmZ6awnybMAtDHrJCVkAKleQ9eDeaKImFvtN3IE8Q jmIHMsV07j2/2r2u6tOTHrfGlw== X-Google-Smtp-Source: ABdhPJyh2KPTGU4ayTa1XNiz400Y+zyRHMud7qFaV0QD/t+nRNJvznyZNbPeqd5VSc3ukQwC7r4DkA== X-Received: by 2002:a17:90b:16cd:: with SMTP id iy13mr24835386pjb.182.1608703264363; Tue, 22 Dec 2020 22:01:04 -0800 (PST) Received: from localhost ([122.172.20.109]) by smtp.gmail.com with ESMTPSA id y27sm22645455pfr.78.2020.12.22.22.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 22:01:03 -0800 (PST) Date: Wed, 23 Dec 2020 11:31:01 +0530 From: Viresh Kumar To: Dmitry Osipenko Subject: Re: [PATCH v2 15/48] opp: Support set_opp() customization without requiring to use regulators Message-ID: <20201223060101.v2qihvvgsmpahg24@vireshk-i7> References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-16-digetx@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201217180638.22748-16-digetx@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 X-Mailman-Approved-At: Wed, 23 Dec 2020 10:51:31 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Michael Turquette , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thierry Reding , linux-clk@vger.kernel.org, devel@driverdev.osuosl.org, Kevin Hilman , Nicolas Chauvet , Viresh Kumar , Krzysztof Kozlowski , Jonathan Hunter , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , linux-tegra@vger.kernel.org, Mauro Carvalho Chehab , Stephen Boyd , Peter De Schrijver , "Rafael J. Wysocki" , Liam Girdwood , Mark Brown , Peter Geis Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 17-12-20, 21:06, Dmitry Osipenko wrote: > 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; > + } > + We should use the same structure, you can add some checks but not replace the structure altogether. > 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 -- viresh _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel