From patchwork Mon Feb 6 06:12:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang yuantian X-Patchwork-Id: 9557123 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7820A604DC for ; Mon, 6 Feb 2017 06:12:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ABAD26E39 for ; Mon, 6 Feb 2017 06:12:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F3A727F82; Mon, 6 Feb 2017 06:12:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C43C26E39 for ; Mon, 6 Feb 2017 06:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751114AbdBFGMr (ORCPT ); Mon, 6 Feb 2017 01:12:47 -0500 Received: from mail-he1eur01on0068.outbound.protection.outlook.com ([104.47.0.68]:34275 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750973AbdBFGMq (ORCPT ); Mon, 6 Feb 2017 01:12:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6dnGQLMd03p2YrNnbXTeqxnx5vFkwLdwJ6YswGmK29A=; b=AnhdMLNERP8wDDhcVYzzbjQf04FngtB6crJET271oQ1SXn/lekUtDuZHEaJzQtnQqOmF8YpmyQ1ET2zG+utOl6IMnh5wmH+akGGaetsggMlUMv4FMW7fbI5KtrGuCZtLp70k+Ws2dyJQfj7RmsYVeWadnC8BQP7tqo/gBl7BQ5Y= Received: from DB6PR0402MB2837.eurprd04.prod.outlook.com (10.172.247.9) by AM5PR0401MB2468.eurprd04.prod.outlook.com (10.169.244.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Mon, 6 Feb 2017 06:12:42 +0000 Received: from DB6PR0402MB2837.eurprd04.prod.outlook.com ([10.172.247.9]) by DB6PR0402MB2837.eurprd04.prod.outlook.com ([10.172.247.9]) with mapi id 15.01.0888.025; Mon, 6 Feb 2017 06:12:40 +0000 From: "Y.T. Tang" To: Leo Li CC: Scott Wood , Michael Turquette , Russell King , Stephen Boyd , Viresh Kumar , "Rafael J. Wysocki" , "linux-clk@vger.kernel.org" , "linux-pm@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , Leo Li , "X.F. Ren" Subject: RE: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock implementation details Thread-Topic: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock implementation details Thread-Index: AQHRx5daHI8s7Cj51kaqFvzTktiblqAMTw2AgAAtkoCAAXRnAIABORoAgBGtByCBNpk/AIAFf0mg Date: Mon, 6 Feb 2017 06:12:40 +0000 Message-ID: References: <1466058085-19353-1-git-send-email-oss@buserror.net> <1466058085-19353-2-git-send-email-oss@buserror.net> <146785501714.73491.8643317356949121718@resonance> <1467864803.32358.63.camel@buserror.net> <146794477678.73491.8244253339435407853@resonance> <1468012014.32358.74.camel@buserror.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yuantian.tang@nxp.com; x-originating-ip: [192.158.241.86] x-microsoft-exchange-diagnostics: 1; AM5PR0401MB2468; 7:u1OtBXa/dn+NOg2KgYpWgtB39VVhgJnUB3NMIYICT4N9ni2NwyiiNp1t8Egv3FnQO/AevLyuA8E9/GwGb7VX3quiSDYH0u5BLdFko2Vn0aewBoJ4QA9uKax40Q4VWtmoksjBbmp+Ak/nNnUL5qkow74FQ9vAaGFC9K/3xUpbQ3zQROncBc1AKm/jpTY1i2WTMDNBNpqbqNo+FHofck+Qcu9c79PNwDNB7axAwsuGz/CtaJean9RPjg8iAemDbno7cahYcfyam1MM8+SlfiP9uusNLU+hziHAW3XuyltuOiGFkGomcxYdXF1RRE47g19npHYIavnjjaqOMUexqCTFcTDd2FSS3Pp1rsszHl7sPtArg+9vsKigFEHiDHxfmmgcEnmYhdsbaKCdZmqeN6XJ9K0bi0XlDniD9eS2BiUiQExOeoj8J74SGCokVMGJxaHf+kw/FQjLneJtvUCwUu6SwXihE6BgyaCK46BmJCJBGDB/DKfFp3KnQAG1bEgec1aWcxNSjhopbGefxc0Gd1ecyA== x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39450400003)(39860400002)(39850400002)(39410400002)(39840400002)(13464003)(189002)(199003)(377454003)(377424004)(24454002)(86362001)(38730400001)(39060400001)(68736007)(7696004)(6436002)(229853002)(25786008)(3660700001)(33656002)(81166006)(6246003)(8676002)(53936002)(6506006)(77096006)(81156014)(189998001)(8936002)(3280700002)(92566002)(101416001)(122556002)(74316002)(7416002)(4326007)(5660300001)(6916009)(6116002)(2950100002)(9686003)(102836003)(106116001)(66066001)(3846002)(76176999)(106356001)(50986999)(54356999)(5890100001)(110136003)(2906002)(99936001)(93886004)(55016002)(99286003)(305945005)(2900100001)(105586002)(97736004)(7736002)(54906002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0401MB2468; H:DB6PR0402MB2837.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; x-ms-office365-filtering-correlation-id: 72450e18-f34b-4292-2b72-08d44e572817 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:AM5PR0401MB2468; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(65623756079841)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040375)(601004)(2401047)(20170203043)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:AM5PR0401MB2468; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0401MB2468; x-forefront-prvs: 0210479ED8 received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2017 06:12:40.7170 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2468 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > -----Original Message----- > From: Leo Li [mailto:pku.leo@gmail.com] > Sent: Friday, February 03, 2017 2:12 AM > To: Y.T. Tang > Cc: Scott Wood ; Michael Turquette > ; Russell King ; > Stephen Boyd ; Viresh Kumar > ; Rafael J. Wysocki ; linux- > clk@vger.kernel.org; linux-pm@vger.kernel.org; linuxppc- > dev@lists.ozlabs.org; Leo Li ; X.F. Ren > > Subject: Re: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock > implementation details > > On Tue, Jul 19, 2016 at 10:02 PM, Yuantian Tang > wrote: > > > > PING. > > > > Regards, > > Yuantian > > > > > -----Original Message----- > > > From: Scott Wood [mailto:oss@buserror.net] > > > Sent: Saturday, July 09, 2016 5:07 AM > > > To: Michael Turquette ; Russell King > > > ; Stephen Boyd ; > Viresh > > > Kumar ; Rafael J. Wysocki > > > > > > Cc: linux-clk@vger.kernel.org; linux-pm@vger.kernel.org; linuxppc- > > > dev@lists.ozlabs.org; Yuantian Tang ; > > > Yang-Leo Li ; Xiaofeng Ren > > > > > > Subject: Re: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock > > > implementation details > > > > > > On Thu, 2016-07-07 at 19:26 -0700, Michael Turquette wrote: > > > > Quoting Scott Wood (2016-07-06 21:13:23) > > > > > > > > > > On Wed, 2016-07-06 at 18:30 -0700, Michael Turquette wrote: > > > > > > > > > > > > Quoting Scott Wood (2016-06-15 23:21:25) > > > > > > > > > > > > > > > > > > > > > -static struct device_node *cpu_to_clk_node(int cpu) > > > > > > > +static struct clk *cpu_to_clk(int cpu) > > > > > > > { > > > > > > > - struct device_node *np, *clk_np; > > > > > > > + struct device_node *np; > > > > > > > + struct clk *clk; > > > > > > > > > > > > > > if (!cpu_present(cpu)) > > > > > > > return NULL; @@ -112,37 +80,28 @@ static > > > > > > > struct device_node *cpu_to_clk_node(int > > > > > > > cpu) > > > > > > > if (!np) > > > > > > > return NULL; > > > > > > > > > > > > > > - clk_np = of_parse_phandle(np, "clocks", 0); > > > > > > > - if (!clk_np) > > > > > > > - return NULL; > > > > > > > - > > > > > > > + clk = of_clk_get(np, 0); > > > > > > Why not use devm_clk_get here? > > > > > devm_clk_get() is a wrapper around clk_get() which is not the > > > > > same as of_clk_get(). What device would you pass to > > > > > devm_clk_get(), and what name would you pass? > > > > I'm fuzzy on whether or not you get a struct device from a cpufreq > > > > driver. If so, then that would be the one to use. I would hope > > > > that cpufreq drivers model cpus as devices, but I'm really not > > > > sure without looking into the code. > > > > > > It's not the cpufreq code that provides it, but get_cpu_device() > > > could be used. > > > > > > Do you have any comments on the first patch of this set? > > > Any action on this patch? This patch is still a dependency for cpufreq to work > on all QorIQ platforms. > This patch can be accepted on condition that the attached patch is accepted. But unfortunately, the attached patch has been sent for a really long time and no feedback. Regards, Yuantian > Regards, > Leo From: Scott Wood Commit fc4a05d4b0eb ("clk: Remove unused provider APIs") removed __clk_get_num_parents() and clk_hw_get_parent_by_index(), leaving only true provider API versions that operate on struct clk_hw. qoriq-cpufreq needs these functions in order to determine the options it has for calling clk_set_parent() and thus populate the cpufreq table, so revive them as legitimate consumer APIs. Signed-off-by: Scott Wood --- Previously sent as http://patchwork.ozlabs.org/patch/519803/ Russell, could you please either ACK this or comment, as CLK API maintainer? drivers/clk/clk.c | 19 +++++++++++++++++++ include/linux/clk.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) -- 2.5.0 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d584004..d61a3fe 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -290,6 +290,12 @@ struct clk_hw *__clk_get_hw(struct clk *clk) } EXPORT_SYMBOL_GPL(__clk_get_hw); +unsigned int clk_get_num_parents(struct clk *clk) +{ + return !clk ? 0 : clk->core->num_parents; +} +EXPORT_SYMBOL_GPL(clk_get_num_parents); + unsigned int clk_hw_get_num_parents(const struct clk_hw *hw) { return hw->core->num_parents; @@ -358,6 +364,19 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core, return core->parents[index]; } +struct clk *clk_get_parent_by_index(struct clk *clk, unsigned int index) +{ + struct clk_core *parent; + + if (!clk) + return NULL; + + parent = clk_core_get_parent_by_index(clk->core, index); + + return !parent ? NULL : parent->hw->clk; +} +EXPORT_SYMBOL_GPL(clk_get_parent_by_index); + struct clk_hw * clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index) { diff --git a/include/linux/clk.h b/include/linux/clk.h index 0df4a51..937de0e 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -392,6 +392,26 @@ int clk_set_parent(struct clk *clk, struct clk *parent); struct clk *clk_get_parent(struct clk *clk); /** + * clk_get_parent_by_index - get a possible parent clock by index + * @clk: clock source + * @index: index into the array of possible parents of this clock + * + * Returns struct clk corresponding to the requested possible + * parent clock source, or NULL. + */ +struct clk *clk_get_parent_by_index(struct clk *clk, + unsigned int index); + +/** + * clk_get_num_parents - get number of possible parents + * @clk: clock source + * + * Returns the number of possible parents of this clock, + * which can then be enumerated using clk_get_parent_by_index(). + */ +unsigned int clk_get_num_parents(struct clk *clk); + +/** * clk_get_sys - get a clock based upon the device name * @dev_id: device name * @con_id: connection ID @@ -461,6 +481,17 @@ static inline struct clk *clk_get_parent(struct clk *clk) return NULL; } +struct clk *clk_get_parent_by_index(struct clk *clk, + unsigned int index) +{ + return NULL; +} + +unsigned int clk_get_num_parents(struct clk *clk) +{ + return 0; +} + #endif /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */