From patchwork Thu Mar 8 04:56:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130959 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6121456lja; Wed, 7 Mar 2018 22:58:06 -0800 (PST) X-Google-Smtp-Source: AG47ELuqm2dfT11k4DISBgVmtTP1mv3SZfg69YSIybqI3HgAT6Wgu6vm4MXo6g25BoXqfDHE4zcZ X-Received: by 2002:a17:902:4827:: with SMTP id s36-v6mr22897363pld.269.1520492285846; Wed, 07 Mar 2018 22:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520492285; cv=none; d=google.com; s=arc-20160816; b=LOfu4TWx7kbzqfq9maC/sgz/kHAWXGVDzZ3CL7rgifq6veI8cFjr49NlNwYoKidZ9a 0rgiURkLFBoJ8DNzLy8pdP/OVy8DIWaR2wURkxLxOVRXw8Wah6dCfJ6kzTFH/6xYY6c9 4KZvIotfFI68xyOvUkX1PfV+zuiw3CCkFSJ/fyDo3JFPj0eHzZXOsVpDsVLG+Pcuj033 BWovb2MDSRcDM9L4kxN0BkHsgdENH4Y1LHegLrfRZflejXqjbHXgQV6qxphf6xpNrqt0 xCN0Cn1+Achscz2r2oKYYySyRjCIoT9AzUfdUinU0/JBNNbFOWsSfK0XrVygRuE2oacz vJUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=uN5TA/SyZJwMUSQ49Vvyvk5AnrCWSOXaKlbuFaHdkH0=; b=Vew6uzXsjT2feE8yeVN9GcfNziULc19DpXpfLJuOWBNJjuvkMYT+gcwhkKv54DXM2q xExr/xUIiKggZrdnfUAVOENabuC8a+mD4wCijWKejyHanXD+naRjj7i4Eq60EzUTRBqd xasHO4aZPjdtYe0GJ587hhkWNrDxXrytDddceGY0EwU2bUbMFeb6Lax9YqzwrVmt2Lxa lvNxiAvqUXVpEyl1UQY+9GICTboU8esYpgbXbgS1XV5WKMwxctiOlXs6gm942+GCjuo3 flnKtvcRxL5vLP7CVNbv+Eb2I367WAmSuCuRYxRapX/Be/+fbVHUQgYO5NZXu3javR1N W4mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=l/ls2EkH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i70si12641077pgc.264.2018.03.07.22.58.05; Wed, 07 Mar 2018 22:58:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=l/ls2EkH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965194AbeCHG6D (ORCPT + 28 others); Thu, 8 Mar 2018 01:58:03 -0500 Received: from mail-sn1nam02on0119.outbound.protection.outlook.com ([104.47.36.119]:9666 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935053AbeCHE50 (ORCPT ); Wed, 7 Mar 2018 23:57:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uN5TA/SyZJwMUSQ49Vvyvk5AnrCWSOXaKlbuFaHdkH0=; b=l/ls2EkH90WlbR47tSv8cAWduDwWQ5vcoo3Hv4F/lzZWRCkO9Rusc1yUai2xvTmbJacL7h8XSh+OSLGhgA/MxXg37UB1FumsbpTQ/D/qsUC7CAGhBoSOWtzOSO/rbhZiu9OlpxTs/3WzVKLkpAGiGXOkW25lx51szwfEuIsXDpI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:57:16 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:57:16 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Jerome Brunet , Michael Turquette , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 59/78] clk: use round rate to bail out early in set_rate Thread-Topic: [PATCH AUTOSEL for 4.15 59/78] clk: use round rate to bail out early in set_rate Thread-Index: AQHTtpnQSzrgscDpe0KxX935nC77iA== Date: Thu, 8 Mar 2018 04:56:27 +0000 Message-ID: <20180308045525.7662-59-alexander.levin@microsoft.com> References: <20180308045525.7662-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045525.7662-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB1032; 7:q/VXbi1zbX5tce0mdXdciqeGYOjcrEhHXOTfV5NZkeWtQcVpzYnut/9B9hlciRJuGZjpeWvsQkUsYqO9un+rDXHQ/OTLSF6R47MZkoEXbClh3GazUxH73q+1lSOyGR08WfNVIRTb1AUMVexMeTEvJxfRbrbt8EFEWdLQNoibb2JrPjBIxYCnlaI9NrExbOiLsBocHdGURuGSIO6tLXOYIQZsefH1vPYP/T1kxiVQV3yNdy8btT1wEjpXkNRofcWc; 20:wmUJWK/w0pgIcH6tLw653nwdKXWKjZkPMgXTZoxRq2hEflouHvIVg/YQ/XLmqLQsvU8pmwRF9yqmp23Tf5zyMhdjPP7FNOR5sNDSVz3/nRyOL1F6dw8dPqhn7a4vJd1zUTjfXEruIJYZMNjzWJwikSc2tzuV1fQ3n14zjv8jQWA= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 89281b8e-1632-442b-2d65-08d584b110bf x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(58145275503218)(42068640409301); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB1032; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1032; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(39860400002)(39380400002)(366004)(396003)(199004)(189003)(97736004)(36756003)(8936002)(105586002)(2950100002)(2501003)(6666003)(186003)(8676002)(5250100002)(86362001)(2900100001)(3846002)(5660300001)(6116002)(10090500001)(2906002)(7736002)(22452003)(81156014)(26005)(6506007)(1076002)(102836004)(59450400001)(81166006)(305945005)(3280700002)(72206003)(110136005)(86612001)(54906003)(99286004)(10290500003)(316002)(107886003)(4326008)(25786009)(68736007)(6486002)(6436002)(6512007)(53936002)(76176011)(66066001)(3660700001)(478600001)(14454004)(106356001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1032; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 582KmFuuUnTbWQ+c5v3ZQLQu1QL6xXHkjLWX2W1nf0jCWYfE7DQl4O/LwUSTsMNebDf2cbw3SU+kmFB8VpmeqNkjTVJJbOowIt48MQI9ctMZw9Qhn4me7V2Tsk3vkcAq0x1J1XJskYr6GiR2JVDKcS0jVTTuRX4m2Opb7rQoTx/exLJoyec/ASzTs6r+VQIBh4XPrFEDzVF9L6pvZqcPlFXmNKacQ0sYo0e5FqMDwBXBR24AfXN//8dypSNM4seiWmKrWSBFkPmWqm7RI1QUtplKPbIH/g6aDpAVIGnDbqQZXEhAiktpg9XPXdO3ZuMOecXze6fr4YPoaKXn0akRhA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89281b8e-1632-442b-2d65-08d584b110bf X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:56:27.2459 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet [ Upstream commit ca5e089a32c5ffba6c5101fdabdd6dea18041c34 ] The current implementation of clk_core_set_rate_nolock() bails out early if the requested rate is exactly the same as the one set. It should bail out if the request would not result in a rate a change. This is important when the rate is not exactly what is requested, which is fairly common with PLLs. Ex: provider able to give any rate with steps of 100Hz - 1st consumer request 48000Hz and gets it. - 2nd consumer request 48010Hz as well. If we were to perform the usual mechanism, we would get 48000Hz as well. The clock would not change so there is no point performing any checks to make sure the clock can change, we know it won't. This is important to prepare the addition of the clock protection mechanism Acked-by: Linus Walleij Tested-by: Quentin Schulz Tested-by: Maxime Ripard Acked-by: Michael Turquette Signed-off-by: Jerome Brunet Signed-off-by: Michael Turquette Link: lkml.kernel.org/r/20171201215200.23523-6-jbrunet@baylibre.com Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) -- 2.14.1 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 12180049a42a..0cca063f70e7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1642,16 +1642,37 @@ static void clk_change_rate(struct clk_core *core) clk_pm_runtime_put(core); } +static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core, + unsigned long req_rate) +{ + int ret; + struct clk_rate_request req; + + lockdep_assert_held(&prepare_lock); + + if (!core) + return 0; + + clk_core_get_boundaries(core, &req.min_rate, &req.max_rate); + req.rate = req_rate; + + ret = clk_core_round_rate_nolock(core, &req); + + return ret ? 0 : req.rate; +} + static int clk_core_set_rate_nolock(struct clk_core *core, unsigned long req_rate) { struct clk_core *top, *fail_clk; - unsigned long rate = req_rate; + unsigned long rate; int ret = 0; if (!core) return 0; + rate = clk_core_req_round_rate_nolock(core, req_rate); + /* bail early if nothing to do */ if (rate == clk_core_get_rate_nolock(core)) return 0; @@ -1660,7 +1681,7 @@ static int clk_core_set_rate_nolock(struct clk_core *core, return -EBUSY; /* calculate new rates and get the topmost changed clock */ - top = clk_calc_new_rates(core, rate); + top = clk_calc_new_rates(core, req_rate); if (!top) return -EINVAL;