Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3829476ybi; Fri, 19 Jul 2019 09:45:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5R+rHEAOEzy7GX3LH8b7AMGs30LJG2itc97KyrJsAJJdg6shIU+IcBSq1BlfFcNs35h8I X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr58957795plz.38.1563554704814; Fri, 19 Jul 2019 09:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563554704; cv=none; d=google.com; s=arc-20160816; b=pxQN9+G+QlOBHaSALkBMesuZRqvY3xMfNpD1mePKlbaPLfNFp3beYDRvxiI66bAgfz pmc8xM8wIZ1sewBOUzq6lGM6CRGk3vSxyozUlhJzhbnsEOpx9TArn7ge9GcwRaAiIjfn ifL4w2nVfd8YQpga+irbbYWPm3A3rUDSISNhHXv0S+swrDGZQTjf9E8AepxFs8jXhz7l nxBBjYE/dw/wmzPenoYraZj3GtRWcVo/RKlrDFuHZUq9Q3vVSlmD3F8gBosv6vxEOsiU FJrxlpRNj3vBQXolbPDax35A0+1qt+gsdthRwWA8HHbSM6I9bvwr7Uiqi5ivFwQuQ7wK d3EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=a1WebjF2OCLaB+DQY5uyD0tPKoaanwf9vnr7gRJblR0=; b=vyzaZMliNmTxCEdkX7Jpg1/RFbzOSAYWUQz+HGIB7MMPagLu8f+wVwQMzRR6kYR756 fxjzd4r29/oWM/wECs5ZTV7hrEh77TLqqyPiEmR8R+I/6l42go7X1gVYHwixqy2q3tVV IdrGsD4QBQQNs2NsA2S4wykM2P55sz2DfjQfoKOM0ktW3Fr9JRU4p0IUNnZOrL5opmE/ yMK6GIaWeNYl3pjLEW7rhS2i8DVBW9M+v4VNh3qKkfeO0EKEZk6s3mb8m1Qvo/ftrLa8 v2EiJRc2fqBgbOvfwe/78fLuuorbGSV3J5PDhK/siRV6/pECEkgacp4cx82WfzNt5cP6 ZsHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=goeb8seW; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si1068079pfn.99.2019.07.19.09.44.49; Fri, 19 Jul 2019 09:45:04 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b=goeb8seW; 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=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729880AbfGSPF5 (ORCPT + 99 others); Fri, 19 Jul 2019 11:05:57 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40833 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729791AbfGSPF4 (ORCPT ); Fri, 19 Jul 2019 11:05:56 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190719150555euoutp026034862ecebf1bd1688b9e50b86630c2~y108X55Wh1346813468euoutp02K for ; Fri, 19 Jul 2019 15:05:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190719150555euoutp026034862ecebf1bd1688b9e50b86630c2~y108X55Wh1346813468euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563548755; bh=a1WebjF2OCLaB+DQY5uyD0tPKoaanwf9vnr7gRJblR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goeb8seWqSnnhARcvPSacU2hwbVYQqLpmeqhPWT/0ST96OLA9oS94kJfvwSKVnxMQ nwlfcxJSTUl4bYlqzrbzgAWXFky94SwGgOh8QUhPbhRCrf/N7WktO7azAZDm+lMTHM DhlF/d/pN6PIl6ahfny4ebpdJe2/a6vIcDcEj4SM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190719150554eucas1p1693f01d005c30f29c8ef1a3d774d6b3c~y10717Hgp0634306343eucas1p17; Fri, 19 Jul 2019 15:05:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D0.19.04377.25CD13D5; Fri, 19 Jul 2019 16:05:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851~y1066L7oI3265032650eucas1p1T; Fri, 19 Jul 2019 15:05:53 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190719150553eusmtrp2288792d67239db11e8a0629d1f8087f4~y106pXSji3123131231eusmtrp2L; Fri, 19 Jul 2019 15:05:53 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-73-5d31dc52c077 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FF.8F.04146.15CD13D5; Fri, 19 Jul 2019 16:05:53 +0100 (BST) Received: from AMDC3218.DIGITAL.local (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190719150552eusmtip100d326709c0801bfea6ad15e33e67358~y1057cU3u2866928669eusmtip1B; Fri, 19 Jul 2019 15:05:52 +0000 (GMT) From: k.konieczny@partner.samsung.com To: k.konieczny@partner.samsung.com Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , Mark Rutland , MyungJoo Ham , Nishanth Menon , Rob Herring , Stephen Boyd , Viresh Kumar , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v3 1/5] devfreq: exynos-bus: correct clock enable sequence Date: Fri, 19 Jul 2019 17:05:31 +0200 Message-Id: <20190719150535.15501-2-k.konieczny@partner.samsung.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190719150535.15501-1-k.konieczny@partner.samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAKsWRmVeSWpSXmKPExsWy7djP87pBdwxjDc5PlbDYOGM9q8X1L89Z LeYfOcdq0bfvP6NF/+PXzBbnz29gtzjb9IbdYtPja6wWl3fNYbP43HuE0WLG+X1MFmuP3GW3 WHr9IpPF7cYVbBZvfpxlsmjde4Td4t+1jSwWmx8cY3MQ8lgzbw2jx6ZVnWwem5fUexx8t4fJ o2/LKkaP4ze2M3l83iQXwB7FZZOSmpNZllqkb5fAlbG99zprwVeFitbHa5gaGFdKdTFyckgI mEj0TFvF1MXIxSEksIJRom3iSijnC6PEif9/GCGcz4wSJ7vPMMO0XFv7hQ0isZxR4u/zqaxw LQ+3vmcEqWITUJXYMuMlO4gtIqAsMfnedGaQImaBnywSGy5vBEsIC3hJLHl5iAXEZgFq2Phq GlicV8BF4sOxRlaIdfISnTt2g9VwCrhKfDn4HqpGUOLkzCdgcWagmuats8EWSAi8ZZfo3P8D 6lYXi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kFjEyrGEVSS4tz03OLDfWKE3OLS/PS9ZLz czcxAuNy27Gfm3cwXtoYfIhRgINRiYf3wy3DWCHWxLLiytxDjBIczEoivLdf6scK8aYkVlal FuXHF5XmpBYfYjQFemIis5Rocj4wZeSVxBuaGppbWBqaG5sbm1koifN2CByMERJITyxJzU5N LUgtgulj4uCUamCsmuLtNqsvcdWbt9YHfrKs+XrWtOp/4OMPkgtndk/zs/jaeP/qtvZDbzKN 79he2ZI1i/mU0sQap+vnP5478njORespdg/jWefO1TuTcSr+2MaPpcJObzauT3JvvpP9+Lyx b1L2x7p9FzqtsjIlL5pZWpolXfOpNN579UWf0dzfel4Ccd8Ox3s2KrEUZyQaajEXFScCACJB st7hAgAA X-CMS-MailID: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190719150553eucas1p1665462f3fc0e06fc9c082e258be3a851 References: <20190719150535.15501-1-k.konieczny@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Regulators should be enabled before clocks to avoid h/w hang. This require change in exynos_bus_probe() to move exynos_bus_parse_of() after exynos_bus_parent_parse_of() and change in enabling sequence of regulator and clock in exynos_bus_parse_of(). Similar change is needed in exynos_bus_exit() where clock should be disabled first. Signed-off-by: Kamil Konieczny --- This patch is new to this series. --- drivers/devfreq/exynos-bus.c | 58 ++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c index 486cc5b422f1..f391044aa39d 100644 --- a/drivers/devfreq/exynos-bus.c +++ b/drivers/devfreq/exynos-bus.c @@ -194,11 +194,11 @@ static void exynos_bus_exit(struct device *dev) if (ret < 0) dev_warn(dev, "failed to disable the devfreq-event devices\n"); + clk_disable_unprepare(bus->clk); if (bus->regulator) regulator_disable(bus->regulator); dev_pm_opp_of_remove_table(dev); - clk_disable_unprepare(bus->clk); } /* @@ -326,8 +326,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np, return ret; } -static int exynos_bus_parse_of(struct device_node *np, - struct exynos_bus *bus) +static int exynos_bus_parse_of(struct exynos_bus *bus) { struct device *dev = bus->dev; struct dev_pm_opp *opp; @@ -341,36 +340,35 @@ static int exynos_bus_parse_of(struct device_node *np, return PTR_ERR(bus->clk); } - ret = clk_prepare_enable(bus->clk); + /* Get the freq and voltage from OPP table to scale the bus freq */ + ret = dev_pm_opp_of_add_table(dev); if (ret < 0) { - dev_err(dev, "failed to get enable clock\n"); + dev_err(dev, "failed to get OPP table\n"); return ret; } - /* Get the freq and voltage from OPP table to scale the bus freq */ - ret = dev_pm_opp_of_add_table(dev); + ret = clk_prepare_enable(bus->clk); if (ret < 0) { - dev_err(dev, "failed to get OPP table\n"); + dev_err(dev, "failed to enable clock\n"); goto err_clk; } - rate = clk_get_rate(bus->clk); opp = devfreq_recommended_opp(dev, &rate, 0); if (IS_ERR(opp)) { dev_err(dev, "failed to find dev_pm_opp\n"); ret = PTR_ERR(opp); - goto err_opp; + goto err; } bus->curr_freq = dev_pm_opp_get_freq(opp); dev_pm_opp_put(opp); return 0; -err_opp: - dev_pm_opp_of_remove_table(dev); -err_clk: +err: clk_disable_unprepare(bus->clk); +err_clk: + dev_pm_opp_of_remove_table(dev); return ret; } @@ -386,6 +384,7 @@ static int exynos_bus_probe(struct platform_device *pdev) struct exynos_bus *bus; int ret, max_state; unsigned long min_freq, max_freq; + bool passive = false; if (!np) { dev_err(dev, "failed to find devicetree node\n"); @@ -399,27 +398,31 @@ static int exynos_bus_probe(struct platform_device *pdev) bus->dev = &pdev->dev; platform_set_drvdata(pdev, bus); - /* Parse the device-tree to get the resource information */ - ret = exynos_bus_parse_of(np, bus); - if (ret < 0) - return ret; - profile = devm_kzalloc(dev, sizeof(*profile), GFP_KERNEL); - if (!profile) { - ret = -ENOMEM; - goto err; - } + if (!profile) + return -ENOMEM; node = of_parse_phandle(dev->of_node, "devfreq", 0); if (node) { of_node_put(node); - goto passive; + passive = true; } else { ret = exynos_bus_parent_parse_of(np, bus); + if (ret < 0) + return ret; } - if (ret < 0) - goto err; + /* Parse the device-tree to get the resource information */ + ret = exynos_bus_parse_of(bus); + if (ret < 0) { + if (!passive) + regulator_disable(bus->regulator); + + return ret; + } + + if (passive) + goto passive; /* Initialize the struct profile and governor data for parent device */ profile->polling_ms = 50; @@ -508,8 +511,11 @@ static int exynos_bus_probe(struct platform_device *pdev) return 0; err: - dev_pm_opp_of_remove_table(dev); clk_disable_unprepare(bus->clk); + if (!passive) + regulator_disable(bus->regulator); + + dev_pm_opp_of_remove_table(dev); return ret; } -- 2.22.0