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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_2 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 09466C41514 for ; Mon, 29 Jul 2019 03:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D75472147A for ; Mon, 29 Jul 2019 03:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfG2DjY (ORCPT ); Sun, 28 Jul 2019 23:39:24 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:59753 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726312AbfG2DjX (ORCPT ); Sun, 28 Jul 2019 23:39:23 -0400 X-UUID: 7d8b31c80a0946a4b0520df025bb2c97-20190729 X-UUID: 7d8b31c80a0946a4b0520df025bb2c97-20190729 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 450280008; Mon, 29 Jul 2019 11:39:15 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 29 Jul 2019 11:39:15 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 29 Jul 2019 11:39:15 +0800 Message-ID: <1564371555.18434.11.camel@mtksdaap41> Subject: Re: [PATCH 6/8] PM / OPP: Support adjusting OPP voltages at runtime From: Roger Lu To: Viresh Kumar , Stephen Boyd CC: Andrew-sh Cheng =?UTF-8?Q?=28=E9=84=AD=E5=BC=8F=E5=8B=B3=29?= , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Rob Herring , Mark Rutland , Matthias Brugger , "Rafael J. Wysocki" , Nishanth Menon , Stephen Boyd , "linux-pm@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mediatek@lists.infradead.org" , "linux-kernel@vger.kernel.org" , srv_heupstream , Fan Chen =?UTF-8?Q?=28=E9=99=B3=E5=87=A1=29?= , Date: Mon, 29 Jul 2019 11:39:15 +0800 In-Reply-To: <20190520044704.unftq6q5vy73z5bo@vireshk-i7> References: <1557997725-12178-1-git-send-email-andrew-sh.cheng@mediatek.com> <1557997725-12178-7-git-send-email-andrew-sh.cheng@mediatek.com> <20190520044704.unftq6q5vy73z5bo@vireshk-i7> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Stephen Boyd, This patch is derived from [1]. Please kindly shares the suggestion to us. Thanks very much. [1]: https://lore.kernel.org/patchwork/patch/599279/ Dear Viresh, I followed _opp_set_availability() coding style to refine dev_pm_opp_adjust_voltage() from this patch. Is this refinement suitable for OPP core? Thanks a lot. On Mon, 2019-05-20 at 12:47 +0800, Viresh Kumar wrote: > On 16-05-19, 17:08, Andrew-sh.Cheng wrote: > > From: Stephen Boyd > > > > On some SoCs the Adaptive Voltage Scaling (AVS) technique is > > employed to optimize the operating voltage of a device. At a > > given frequency, the hardware monitors dynamic factors and either > > makes a suggestion for how much to adjust a voltage for the > > current frequency, or it automatically adjusts the voltage > > without software intervention. Add an API to the OPP library for > > the former case, so that AVS type devices can update the voltages > > for an OPP when the hardware determines the voltage should > > change. The assumption is that drivers like CPUfreq or devfreq > > will register for the OPP notifiers and adjust the voltage > > according to suggestions that AVS makes. > > > > This patch is devired from [1] submitted by Stephen. > > [1] https://lore.kernel.org/patchwork/patch/599279/ > > > > Signed-off-by: Stephen Boyd > > Signed-off-by: Roger Lu > > --- > > drivers/opp/core.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > include/linux/pm_opp.h | 11 +++++++ > > 2 files changed, 89 insertions(+) > > This is an rcu implementation which got removed long back from OPP core. Please > align this with the latest changes. > /** * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP * @dev: device for which we do this operation * @freq: OPP frequency to adjust voltage of * @u_volt: new OPP voltage * * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the * copy operation, returns 0 if no modifcation was done OR modification was * successful. */ int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, unsigned long u_volt) { struct opp_table *opp_table; struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); int r = 0; /* Find the opp_table */ opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { r = PTR_ERR(opp_table); dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); return r; } mutex_lock(&opp_table->lock); /* Do we have the frequency? */ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { if (tmp_opp->rate == freq) { opp = tmp_opp; break; } } if (IS_ERR(opp)) { r = PTR_ERR(opp); goto adjust_unlock; } /* Is update really needed? */ if (opp->supplies->u_volt == u_volt) goto adjust_unlock; opp->supplies->u_volt = u_volt; dev_pm_opp_get(opp); mutex_unlock(&opp_table->lock); /* Notify the voltage change of the OPP */ blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, opp); dev_pm_opp_put(opp); goto adjust_put_table; adjust_unlock: mutex_unlock(&opp_table->lock); adjust_put_table: dev_pm_opp_put_opp_table(opp_table); return r; } Sincerely, Roger Lu. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Lu Subject: Re: [PATCH 6/8] PM / OPP: Support adjusting OPP voltages at runtime Date: Mon, 29 Jul 2019 11:39:15 +0800 Message-ID: <1564371555.18434.11.camel@mtksdaap41> References: <1557997725-12178-1-git-send-email-andrew-sh.cheng@mediatek.com> <1557997725-12178-7-git-send-email-andrew-sh.cheng@mediatek.com> <20190520044704.unftq6q5vy73z5bo@vireshk-i7> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190520044704.unftq6q5vy73z5bo@vireshk-i7> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Viresh Kumar , Stephen Boyd Cc: Mark Rutland , Nishanth Menon , Andrew-sh Cheng =?UTF-8?Q?=28=E9=84=AD=E5=BC=8F=E5=8B=B3=29?= , srv_heupstream , "linux-pm@vger.kernel.org" , Stephen Boyd , "Rafael J. Wysocki" , "linux-kernel@vger.kernel.org" , Rob Herring , yt.lee@mediatek.com, Chanwoo Choi , Kyungmin Park , MyungJoo Ham , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , Matthias Brugger , Fan Chen =?UTF-8?Q?=28=E9=99=B3=E5=87=A1=29?= , "devicetree@vger.kernel.org" List-Id: devicetree@vger.kernel.org Dear Stephen Boyd, This patch is derived from [1]. Please kindly shares the suggestion to us. Thanks very much. [1]: https://lore.kernel.org/patchwork/patch/599279/ Dear Viresh, I followed _opp_set_availability() coding style to refine dev_pm_opp_adjust_voltage() from this patch. Is this refinement suitable for OPP core? Thanks a lot. On Mon, 2019-05-20 at 12:47 +0800, Viresh Kumar wrote: > On 16-05-19, 17:08, Andrew-sh.Cheng wrote: > > From: Stephen Boyd > > > > On some SoCs the Adaptive Voltage Scaling (AVS) technique is > > employed to optimize the operating voltage of a device. At a > > given frequency, the hardware monitors dynamic factors and either > > makes a suggestion for how much to adjust a voltage for the > > current frequency, or it automatically adjusts the voltage > > without software intervention. Add an API to the OPP library for > > the former case, so that AVS type devices can update the voltages > > for an OPP when the hardware determines the voltage should > > change. The assumption is that drivers like CPUfreq or devfreq > > will register for the OPP notifiers and adjust the voltage > > according to suggestions that AVS makes. > > > > This patch is devired from [1] submitted by Stephen. > > [1] https://lore.kernel.org/patchwork/patch/599279/ > > > > Signed-off-by: Stephen Boyd > > Signed-off-by: Roger Lu > > --- > > drivers/opp/core.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > include/linux/pm_opp.h | 11 +++++++ > > 2 files changed, 89 insertions(+) > > This is an rcu implementation which got removed long back from OPP core. Please > align this with the latest changes. > /** * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP * @dev: device for which we do this operation * @freq: OPP frequency to adjust voltage of * @u_volt: new OPP voltage * * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the * copy operation, returns 0 if no modifcation was done OR modification was * successful. */ int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, unsigned long u_volt) { struct opp_table *opp_table; struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); int r = 0; /* Find the opp_table */ opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { r = PTR_ERR(opp_table); dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); return r; } mutex_lock(&opp_table->lock); /* Do we have the frequency? */ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { if (tmp_opp->rate == freq) { opp = tmp_opp; break; } } if (IS_ERR(opp)) { r = PTR_ERR(opp); goto adjust_unlock; } /* Is update really needed? */ if (opp->supplies->u_volt == u_volt) goto adjust_unlock; opp->supplies->u_volt = u_volt; dev_pm_opp_get(opp); mutex_unlock(&opp_table->lock); /* Notify the voltage change of the OPP */ blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, opp); dev_pm_opp_put(opp); goto adjust_put_table; adjust_unlock: mutex_unlock(&opp_table->lock); adjust_put_table: dev_pm_opp_put_opp_table(opp_table); return r; } Sincerely, Roger Lu. 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=-5.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_2 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 78E50C433FF for ; Mon, 29 Jul 2019 03:39:38 +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 4ACF62070D for ; Mon, 29 Jul 2019 03:39:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HO/h077z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4ACF62070D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L/lpJO4i2IauEX8YV1tv02Gm7D8yJR3kl2qTgvGvGks=; b=HO/h077zdZSmjP s5GIuhYbwrA7m2l0OVpJRyccdbk/wvbJXhnYJXdlw0mrtxw35yIDqX1+WIw1xlLDOsEQYJ2tg2GIF HWBQFO1/ZsMhK3d2G6WcORkuS81aA5CrddFDRbPvwMw3tVyZ0mjRTJGPD0VvWRr2UpOEVoP/bc9U4 U9PkXb5yaazLHGWQieCwLUjxrmBno4oDQhH80YQYDHk2AHI2dO+ZtZPY00sEiOm8Ujbvh0GEypNp/ 1Hy9cFq+IXepE1E6IQVMKuoAib1Ff/piLFnTwaKHNFUlKmuhrFd2AoICHZlgUZtFE+/EX1otaxtOX zrwrRjNrYzBynmLSGmew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hrwVd-0005G0-H1; Mon, 29 Jul 2019 03:39:37 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hrwVZ-0005ET-AI; Mon, 29 Jul 2019 03:39:35 +0000 X-UUID: 56d8e11694b74698becf194ce65d0a80-20190728 X-UUID: 56d8e11694b74698becf194ce65d0a80-20190728 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 2068137772; Sun, 28 Jul 2019 19:39:25 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 28 Jul 2019 20:39:23 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 29 Jul 2019 11:39:15 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 29 Jul 2019 11:39:15 +0800 Message-ID: <1564371555.18434.11.camel@mtksdaap41> Subject: Re: [PATCH 6/8] PM / OPP: Support adjusting OPP voltages at runtime From: Roger Lu To: Viresh Kumar , Stephen Boyd Date: Mon, 29 Jul 2019 11:39:15 +0800 In-Reply-To: <20190520044704.unftq6q5vy73z5bo@vireshk-i7> References: <1557997725-12178-1-git-send-email-andrew-sh.cheng@mediatek.com> <1557997725-12178-7-git-send-email-andrew-sh.cheng@mediatek.com> <20190520044704.unftq6q5vy73z5bo@vireshk-i7> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190728_203933_364997_673BB801 X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Nishanth Menon , Andrew-sh Cheng =?UTF-8?Q?=28=E9=84=AD=E5=BC=8F=E5=8B=B3=29?= , srv_heupstream , "linux-pm@vger.kernel.org" , Stephen Boyd , "Rafael J. Wysocki" , "linux-kernel@vger.kernel.org" , Rob Herring , yt.lee@mediatek.com, Chanwoo Choi , Kyungmin Park , MyungJoo Ham , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , Matthias Brugger , Fan Chen =?UTF-8?Q?=28=E9=99=B3=E5=87=A1=29?= , "devicetree@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dear Stephen Boyd, This patch is derived from [1]. Please kindly shares the suggestion to us. Thanks very much. [1]: https://lore.kernel.org/patchwork/patch/599279/ Dear Viresh, I followed _opp_set_availability() coding style to refine dev_pm_opp_adjust_voltage() from this patch. Is this refinement suitable for OPP core? Thanks a lot. On Mon, 2019-05-20 at 12:47 +0800, Viresh Kumar wrote: > On 16-05-19, 17:08, Andrew-sh.Cheng wrote: > > From: Stephen Boyd > > > > On some SoCs the Adaptive Voltage Scaling (AVS) technique is > > employed to optimize the operating voltage of a device. At a > > given frequency, the hardware monitors dynamic factors and either > > makes a suggestion for how much to adjust a voltage for the > > current frequency, or it automatically adjusts the voltage > > without software intervention. Add an API to the OPP library for > > the former case, so that AVS type devices can update the voltages > > for an OPP when the hardware determines the voltage should > > change. The assumption is that drivers like CPUfreq or devfreq > > will register for the OPP notifiers and adjust the voltage > > according to suggestions that AVS makes. > > > > This patch is devired from [1] submitted by Stephen. > > [1] https://lore.kernel.org/patchwork/patch/599279/ > > > > Signed-off-by: Stephen Boyd > > Signed-off-by: Roger Lu > > --- > > drivers/opp/core.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > include/linux/pm_opp.h | 11 +++++++ > > 2 files changed, 89 insertions(+) > > This is an rcu implementation which got removed long back from OPP core. Please > align this with the latest changes. > /** * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP * @dev: device for which we do this operation * @freq: OPP frequency to adjust voltage of * @u_volt: new OPP voltage * * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the * copy operation, returns 0 if no modifcation was done OR modification was * successful. */ int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, unsigned long u_volt) { struct opp_table *opp_table; struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); int r = 0; /* Find the opp_table */ opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { r = PTR_ERR(opp_table); dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); return r; } mutex_lock(&opp_table->lock); /* Do we have the frequency? */ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { if (tmp_opp->rate == freq) { opp = tmp_opp; break; } } if (IS_ERR(opp)) { r = PTR_ERR(opp); goto adjust_unlock; } /* Is update really needed? */ if (opp->supplies->u_volt == u_volt) goto adjust_unlock; opp->supplies->u_volt = u_volt; dev_pm_opp_get(opp); mutex_unlock(&opp_table->lock); /* Notify the voltage change of the OPP */ blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, opp); dev_pm_opp_put(opp); goto adjust_put_table; adjust_unlock: mutex_unlock(&opp_table->lock); adjust_put_table: dev_pm_opp_put_opp_table(opp_table); return r; } Sincerely, Roger Lu. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel