Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp448110pxb; Wed, 15 Sep 2021 05:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7SXRMNuPUf+cDZgHVKME5pUQ+UyWIlwHGLvDsDTNNdBfQHOYo7aJsUO9/C8T+up0/sApL X-Received: by 2002:a05:6638:1347:: with SMTP id u7mr19429183jad.34.1631710473765; Wed, 15 Sep 2021 05:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631710473; cv=none; d=google.com; s=arc-20160816; b=PJs9RTMOT+L/FTiAAMTglJNrB8v4AYtqLci5qnT16bpUxAIEzHnBvCpotOJdqu3g2u t3R/5WE/I2ediw3PC42qs5UvNSJhw3Wmi9rjtSu/oYVxlPP+VR6G/1Fhf5P0OVMgzBme 8/IKyIhgBSC3l2fnW3b/xYokzKApCY2rPVFpCKR4YCWUSwJFZ48s7v4/nHeyCfCcMCl7 u3PkZZGwJDHXdkjuYUwNI7cGLy8GWSV3X3d5EgWYGVsNaiKsMx5LEdypEqdPLJzESNck gnh9rCUtehattZZmeiQwnwczhkFmDEhTU2EH3aCocz0TCyh98NACwdixt0EB5ijYM7mt veBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=03ujAQ/c7ECVsa5KofPPIAP+m4Mo6XF14OM04r2XKJw=; b=jReTXEq7roSJnU9gcM4U36ES6H8xPRGf1BcEkIC9sWeaiV8U77QRTZNVwsrgn5RWmD I445ti6AplA2k2/4JB7+1Jwqmj9qI1AI0EnRQ4UaBJxwpb86kh2dugvX9/8yMTq5RqVl QInhjn06m0P1M/5bX4AOITSnL1takeV9Cd7w+phi1eILC32q9Oqs4p0jRKCrA9J103TL lqi2+ymM1opt4GQsHgw4ySLr4kJ1JhKA/T8chcEf6ij0mcNZnVgfb+OadW61Nf4kMIOG CdzyeYBblMfyKxKN5lTVyUdEmIy4VEbxjyLcXaIC5sqWPb7S7k0V6m+Mopk9W20h1bR3 xo6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mTmqiXMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si15618319ioa.93.2021.09.15.05.54.21; Wed, 15 Sep 2021 05:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mTmqiXMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233918AbhIOMxS (ORCPT + 99 others); Wed, 15 Sep 2021 08:53:18 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:23576 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbhIOMxQ (ORCPT ); Wed, 15 Sep 2021 08:53:16 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210915125156euoutp02441e5909ff179b6bafd2e10b4c7835f5~k-_NKis8t2082020820euoutp02Y for ; Wed, 15 Sep 2021 12:51:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210915125156euoutp02441e5909ff179b6bafd2e10b4c7835f5~k-_NKis8t2082020820euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1631710316; bh=03ujAQ/c7ECVsa5KofPPIAP+m4Mo6XF14OM04r2XKJw=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=mTmqiXMlKCFzFaFmdj7kpvbKxAJqJwQv/djdI5QoSFCt+fb3r5s1J7mY6s0Sa5mAz nD9H6d8R/ovBiPwuPAJYQLsHstL4JK8m1vH2qOMjIXsDAb4J36nbafq8R1weowtvpI YebgNbwNN+29Rn1TtWXa1gH5a/UE7aVP5Qn9L36Y= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210915125156eucas1p12243ad632605b39bf97dfd841fb56e7c~k-_Mw66VD2997129971eucas1p1S; Wed, 15 Sep 2021 12:51:56 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id EF.BF.56448.C6CE1416; Wed, 15 Sep 2021 13:51:56 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210915125155eucas1p204553084818cc0e14ea20acc295519cb~k-_MLv-By0821808218eucas1p2U; Wed, 15 Sep 2021 12:51:55 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210915125155eusmtrp1213fd6a52fe4c505cb90093d4c500a95~k-_MKuv6W1149811498eusmtrp1K; Wed, 15 Sep 2021 12:51:55 +0000 (GMT) X-AuditID: cbfec7f5-d53ff7000002dc80-7c-6141ec6cf2b2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AF.69.20981.B6CE1416; Wed, 15 Sep 2021 13:51:55 +0100 (BST) Received: from [106.210.134.141] (unknown [106.210.134.141]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210915125154eusmtip2f8cac74da6df926a2f4be386cad6fd07~k-_LLOEb62365823658eusmtip2O; Wed, 15 Sep 2021 12:51:54 +0000 (GMT) Subject: Re: [PATCH 1/6] clk: samsung: Enable bus clock on init To: Sam Protsenko , Krzysztof Kozlowski , =?UTF-8?Q?Pawe=c5=82_Chmiel?= , Chanwoo Choi , Tomasz Figa Cc: Ryu Euiyoul , Tom Gall , Sumit Semwal , John Stultz , Amit Pundir , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Michael Turquette , Stephen Boyd , Rob Herring From: Sylwester Nawrocki Message-ID: Date: Wed, 15 Sep 2021 14:51:54 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210914155607.14122-2-semen.protsenko@linaro.org> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SfUwbZRjfe3e9XiutR5npE5iOtDOyJYPhTHZGh5CM5Ga2ZRsuMSSOXdiF FVogLR9OpzJwCBUQcWOug0DJHF0lQ75HxUWgWNdWKg7pwvjaSsAwiTTMpPtode3FyH+/r+d5 3l/yUrjiviiW0uQX8fp8TqsipUT/T488O7V/pnG7bNMSZs3Shhjvw2UR02IfFzHuJzuZrtUA xnT7pkSMv2ZOxNy2NZHM156bGDPhTGcCjjqcOfeDXcxcCEyTTGiqi2CW656Zztl1MTPprsIY q+0pSlWwf905J2ZNZbUkO2iaFbPd1mqSnZkaItmeK5+wdb1WxK53v3SYypS+eZLXakp4fVLK CempW5U2VNikfN85OycuQzMKI6IooF+DgUCmEUkpBW1BMDR4UyyQhwh+Di1hAllHYPNex41I EpkwL9xFgtGOoNf8CyEQP4JrZi8RTsXQb0HLmC8yvpkOILDf9kdGcHoKh/m+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9t2MRbMEa84dfceewPjHaEuRk4OCQETiYUPbjN2MXJxCAksZZTY f6GHrYuRAyghJTG/RQmiRljiz7UuNoia94wS7/etYAFJCAvYS8w/+pgJJCEi8INR4uCV38wg DrPANWaJLft+sEK0nGSUOPG3jxGkhU3AUKL3KITNK2An0X59O9goFgFViRU9IDs4OUQFkiXe vv7OBFEjKHFy5hOwGk4BB4kFa44zg9jMAuoSf+ZdgrLFJW49mc8EYctLbH87h3kCo9AsJO2z kLTMQtIyC0nLAkaWVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIHxv+3Yzy07GFe++qh3iJGJ g/EQowQHs5II74Uax0Qh3pTEyqrUovz4otKc1OJDjKZA/0xklhJNzgcmoLySeEMzA1NDEzNL A1NLM2MlcV6TI2vihQTSE0tSs1NTC1KLYPqYODilGpgC3+g8nPaf61PWlrUzX8TMYtv7VnvV 5zjvLyum2J97kL2DgzvS/tDFXJ9zJeX7F7Mu+ZlpsWLecumNj1+/fXbzac350ocFpSLObxcy 3PPk8HJedGG6PvOsuvX+ifpmJ0xPin8umOvcd/CDSUe8dPHG1rbJeSpaasH18441eun/cf2/ MZBFu73yTMLG65kp/oc3r/L8czBVzuLwtWS+W2fU63b2KClff2r1ULlVMDTgobv19h9mlwU2 epk6uDjqSIlZJ21N/Fm+7f5cbu4CBUF1jievMxpcNKcFXUh53+ST9YrvieGBlUnLQu7cEXqa WM1fY/ttNYfGx8gz68K+WrlozrfZpl4768rKLm1RTS8lluKMREMt5qLiRACKwJ3piAMAAA== X-CMS-MailID: 20210915125155eucas1p204553084818cc0e14ea20acc295519cb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20210914155621eucas1p18e0f1f50fe42af4f8048ed88507219ed X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210914155621eucas1p18e0f1f50fe42af4f8048ed88507219ed References: <20210914155607.14122-1-semen.protsenko@linaro.org> <20210914155607.14122-2-semen.protsenko@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 14.09.2021 17:56, Sam Protsenko wrote: > By default if bus clock has no users its "enable count" value is 0. It > might be actually running if it's already enabled in bootloader, but > then in some cases it can be disabled by mistake. For example, such case > was observed when dw_mci_probe() enabled bus clock, then failed to do > something and disabled that bus clock on error path. After that even > attempt to read the 'clk_summary' file in DebugFS freezed forever, as > CMU bus clock ended up being disabled and it wasn't possible to access > CMU registers anymore. > > To avoid such cases, CMU driver must increment the ref count for that > bus clock by running clk_prepare_enable(). There is already existing > '.clk_name' field in struct samsung_cmu_info, exactly for that reason. > It was added in commit 523d3de41f02 ("clk: samsung: exynos5433: Add > support for runtime PM"). But the clock is actually enabled only in > Exynos5433 clock driver. Let's mimic what is done there in generic > samsung_cmu_register_one() function, so other drivers can benefit from > that `.clk_name' field. As was described above, it might be helpful not > only for PM reasons, but also to prevent possible erroneous clock gating > on error paths. > > Another way to workaround that issue would be to use CLOCK_IS_CRITICAL > flag for corresponding gate clocks. But that might be not very good > design decision, as we might still want to disable that bus clock, e.g. > on PM suspend. > > Signed-off-by: Sam Protsenko > --- > drivers/clk/samsung/clk.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c > index 1949ae7851b2..da65149fa502 100644 > --- a/drivers/clk/samsung/clk.c > +++ b/drivers/clk/samsung/clk.c > @@ -357,6 +357,19 @@ struct samsung_clk_provider * __init samsung_cmu_register_one( > > ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids); > > + /* Keep bus clock running, so it's possible to access CMU registers */ > + if (cmu->clk_name) { > + struct clk *bus_clk; > + > + bus_clk = __clk_lookup(cmu->clk_name); > + if (bus_clk) { > + clk_prepare_enable(bus_clk); > + } else { > + pr_err("%s: could not find bus clock %s\n", __func__, > + cmu->clk_name); > + } > + } > + > if (cmu->pll_clks) > samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks, > reg_base); I would suggest to implement runtime PM ops in your driver instead, even though those would initially only contain single clk enable/disable. Things like the clk_summary will work then thanks to runtime PM support in the clk core (see clk_pm_runtime_* calls). We could also make common runtime PM suspend/resume helpers but I wouldn't focus on that too much now, it could well be done later. And please avoid introducing new __clk_lookup() calls. -- Regards, Sylwester