From patchwork Fri Dec 1 21:51:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 120389 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1678247qgn; Fri, 1 Dec 2017 13:52:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMYgteMCZbrn0cYuQFIGFFHyU0vj4OJH02iYl2b0wB9jmsnjkg0S3/jbTQfGSWcAZWdmtTKG X-Received: by 10.99.160.100 with SMTP id u36mr7242695pgn.22.1512165133951; Fri, 01 Dec 2017 13:52:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512165133; cv=none; d=google.com; s=arc-20160816; b=a6wroO8HsJ8pYhlnwPbWn+zdHt2WugbYvZfFfHUrRH9Iz/jTxCEAYWWa6zSZuB1wou ezNUM836ikkRz26Vk5RVU3a84a3XsLWAXyQZt1WPfPWBLzEierRjyoqVV4HUS9bo9rHq 6/Oj3wvMNGCGB51Mr5ITAXKi/nQ4fNlnpPO23izJArfkZG8NbJxnTr+pDamTSvnWNFfO hazFpSILMoLLEkEJ7MuOOsVbwTRl+N/c2guxMuadgX6oJg0KetnNa/AEGmlnrwdGMf8h uU9Cq0lhIrPMrraXfA1IWY7tkaIp2tO5qLDeD6ffkSt3DJ0w2+KV++cT4gOHGlwjNe7d aiPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=+X7F6Vewrtf90z3JsoJB/GMsSYei6fJYJuiuw2vCrpM=; b=NSnlaQa56WMFiJHpqhZdDyCL32k76//IDCTBeYnOlVo3x/q4iUF95H6p5AuPD9dqtC am7yW4Apev6g74qfiXq+yLts2qFqzqgBEt9dTwMMmNpSP8eB7TW9hIi9QYbH3sMG0zJk j6o7Gq2rHdpoEmF4D2kdDyPL9e5SHc9IxG9q4jAIBovcDxMYZ+Zcw/caHnUyD3Iv9+HH agIyTWBFFjUDWr9wQ8GpyXFHknnz+iY5KgmOAbAvE5097JspwBvK3PWENU7aiJFHitkz te4QL1IUG54zpvLMn0xjrIucDielv4iIWzijSsreeaC7+Ml19LkO5fFfX0aEdZZVMDuB ASSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=N+HXQIui; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si5448373pgd.666.2017.12.01.13.52.13; Fri, 01 Dec 2017 13:52:13 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=N+HXQIui; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751534AbdLAVwK (ORCPT + 28 others); Fri, 1 Dec 2017 16:52:10 -0500 Received: from mail-wr0-f181.google.com ([209.85.128.181]:33265 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750921AbdLAVwI (ORCPT ); Fri, 1 Dec 2017 16:52:08 -0500 Received: by mail-wr0-f181.google.com with SMTP id v22so11516569wrb.0 for ; Fri, 01 Dec 2017 13:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=+X7F6Vewrtf90z3JsoJB/GMsSYei6fJYJuiuw2vCrpM=; b=N+HXQIuiw/IWAc+GI13vACoAEU9BjbbvAy0uWZP0+qdoXt0xS6ifkpxSczzv3yckfl ayI7a66JWbuhU1E4xf/QFFO5K8/O+Cwp5x+ekQn27opW++JFviAK3WKC7JcY2zA0LmoI E1VYUaCqoKt0E+4BHajfrQAaZK5LN2b8MwffnY3TImC27lEq7v5NP6EJjeeV1LszDacT lff0HXQE+JdcezLDBh9zkY4sv7xvFPKXqWAWmmboPa6tigGMIE1O49yv5bednjAJl6/T 9fJHZATyrYXtcP/bgrEpA8vlnSVHl5JnRDA4D+M/nRA4neI5SmBnuPqEmgugpetj+3vi C9oQ== 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; bh=+X7F6Vewrtf90z3JsoJB/GMsSYei6fJYJuiuw2vCrpM=; b=Nh9r5+Wc0ZOwNGNxEsQlHfZkaCZTbbNgJ3STufvc1gVQ6n5oB2919N45r2RYtKTix/ byqix+fUKf9qZOZM+5qD0fmQdfOizovpZnRlS4pC1KsiBTPKceW43T+mL87AW4Du48tp QjYU40lPiyu6tNuZUbtFSPKylXiheRMuHNYNm6PVSEJ1siMVI763FVH2JfrImi2z8Gh4 x71Obk1dcqc/hSlO8l+0zOgB0SP7MLwbRg+VRbgNF/12xWfI1BAqIHJvMjUEtrkKxS4E 5weVM0hTgFI6FzgAHfsvABgkCoNdV9DMzru/3HcRuhC+DrT0S98L07dspNghV4/49I2u kPBQ== X-Gm-Message-State: AJaThX4ExoXBhJiTw8Lnoz4bYe3Zz3m27goWe96HkIvuiT0WYC7XSJLq g5avfrSHIE3AotPNKQ0MW2Iovw== X-Received: by 10.223.128.195 with SMTP id 61mr2606890wrl.122.1512165126798; Fri, 01 Dec 2017 13:52:06 -0800 (PST) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id m134sm2078804wmg.6.2017.12.01.13.52.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Dec 2017 13:52:06 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , Linus Walleij , Quentin Schulz , Kevin Hilman , Maxime Ripard Subject: [PATCH v5 00/10] clk: implement clock rate protection mechanism Date: Fri, 1 Dec 2017 22:51:50 +0100 Message-Id: <20171201215200.23523-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This Patchset is related the RFC [0] and the discussion around CLK_SET_RATE_GATE available here [1] This patchset introduce clock protection to the CCF core. This can then be used for: * Provide a way for a consumer to claim exclusivity over the rate control of a provider. Some clock consumers require that a clock rate must not deviate from its selected frequency. There can be several reasons for this, not least of which is that some hardware may not be able to handle or recover from a glitch caused by changing the clock rate while the hardware is in operation. For such HW, The ability to get exclusive control of a clock's rate, and release that exclusivity, could be seen as a fundamental clock rate control primitive. The exclusivity is not preemptible, so when claimed more than once, is rate is effectively locked. * Provide a similar functionality to providers themselves, fixing CLK_SET_RATE_GATE flag (enforce clock gating along the tree). While there might still be a few platforms relying the broken implementation, tests done has shown this change to be pretty safe. Changes since v4: [4] - Fixup documentation comments - Fix error on exclusive API when CCF is disabled Changes since v3: [3] - Reorder patches following Stephen comments - Add before/after examples to the cosmetic change - Remove loops around protection where possible - Rename the API from "protect" to "exclusive" which decribe what the code better Changes since v2: [2] - Fix issues reported by Adriana Reus (Thanks !) - Dropped patch "clk: move CLK_SET_RATE_GATE protection from prepare to enable". This was broken as the protect count, like the prepare_count should only be accessed under the prepare_lock. Changes since v1: [1] - Check if the rate would actually change before continuing, and bail-out early if not. Changes since RFC: [0] - s/clk_protect/clk_rate_protect - Request rework around core_nolock function - Add clk_set_rate_protect - Reword clk_rate_protect and clk_unprotect documentation - Add few comments to explain the code - Add fixes for CLK_SET_RATE_GATE This was tested with the audio use case mentioned in [1] [0]: https://lkml.kernel.org/r/20170321183330.26722-1-jbrunet@baylibre.com [1]: https://lkml.kernel.org/r/148942423440.82235.17188153691656009029@resonance [2]: https://lkml.kernel.org/r/20170521215958.19743-1-jbrunet@baylibre.com [3]: https://lkml.kernel.org/r/20170612194438.12298-1-jbrunet@baylibre.com [4]: https://lkml.kernel.org/r/20170924200030.6227-1-jbrunet@baylibre.com Jerome Brunet (10): clk: fix incorrect usage of ENOSYS clk: take the prepare lock out of clk_core_set_parent clk: add clk_core_set_phase_nolock function clk: rework calls to round and determine rate callbacks clk: use round rate to bail out early in set_rate clk: add clock protection mechanism to clk core clk: cosmetic changes to clk_summary debugfs entry clk: fix CLK_SET_RATE_GATE with clock rate protection clk: add clk_rate_exclusive api clk: fix set_rate_range when current rate is out of range drivers/clk/clk.c | 509 +++++++++++++++++++++++++++++++++++++------ include/linux/clk-provider.h | 1 + include/linux/clk.h | 62 ++++++ 3 files changed, 502 insertions(+), 70 deletions(-) -- 2.14.3