Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2462939rdb; Wed, 15 Nov 2023 01:07:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGDpFXmIVHMrqMGoQ/1ZH/2JTE5LcRUNwfI2QbnBlE8jp7SaoR5+YprGBA8nbpgl35SjIX X-Received: by 2002:a05:6a20:3c91:b0:17b:3438:cf95 with SMTP id b17-20020a056a203c9100b0017b3438cf95mr11310772pzj.14.1700039251931; Wed, 15 Nov 2023 01:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700039251; cv=none; d=google.com; s=arc-20160816; b=VDdqgK7kYhDGZ6Pe63NkN0yx7rRqVsiS1ZvE4gUxMr2zbQ0sXS0M+qU/p2Vz0NLaVx iN05mfF7uEqmcRaSaQyH1okmll5+/7eF/VNGdJM/uKzT3Z7YHYEaRoaueWeAD12heWkH dWsFZB+iPZBRVjGmrUNwbQgMmEW9V1cdlD5+nktRpz+HiSXfCUX3ctXrKUk9/U2mq7uP oWHx7j8LhwsBzI6BSfbhrwAIrBDt1T8p966jAX+igzPMH3DcDPPnjgSNT9r3H918xmch Mxh1Vmd/c57ubu5P/dHtMA3t8IB0p+48VbXxty3+mtUa/oA6cDdjD1LB4fhZY0vZBzwS 2VAQ== 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 :in-reply-to:content-language:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=4c/MecdrukIl8E9ts4Zem79Sv0ehscpjzOJZLIR48xc=; fh=3I/saVJv6Kud9NwZwxbvXH1ThXkhzjiZjdxPf94mq6I=; b=yRxgS8EgD520FKDAAq0d7V3qt0HdwOsoF4q7t/ZsB5+pOULXBpAzibQPpEtNEn9hAo Vph3wfAHSLPyaouU1/yYmi8fjAGUtSGDuLrzFkY++aWtT3Wg0WpClZO5S0h6ufvHFsez EF45zFE0p5hic8a3PXpny+EeXO4nSEMsbLUSDNeEgRD9HljycpG7Tgx3zVMwxjDnAqV9 gx9esYBlwEu9F8VmkhMON79mmDdHRWV1f5KufhhzwX9bNdIdT/xHPpCtCdjTXwkgoQai ILQ37OQ4kAsQ4YfO+wrxjGmmhk3EhC8TNHO32B38SkVuxj7knY+Ei3vDb26hsjLdOxEG 0aUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="rc/Tojdn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c14-20020a056a00248e00b006c4ad151a62si10111088pfv.266.2023.11.15.01.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 01:07:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="rc/Tojdn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8C27E8093429; Wed, 15 Nov 2023 01:07:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234694AbjKOJHI (ORCPT + 99 others); Wed, 15 Nov 2023 04:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234680AbjKOJHH (ORCPT ); Wed, 15 Nov 2023 04:07:07 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34686BC for ; Wed, 15 Nov 2023 01:07:04 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231115090702euoutp028a163d699be07af1ff8458218908839c~XwKqF1Fzj2182621826euoutp02l for ; Wed, 15 Nov 2023 09:07:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231115090702euoutp028a163d699be07af1ff8458218908839c~XwKqF1Fzj2182621826euoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1700039223; bh=4c/MecdrukIl8E9ts4Zem79Sv0ehscpjzOJZLIR48xc=; h=Date:From:Subject:To:Cc:In-Reply-To:References:From; b=rc/Tojdn6BAxp/29cnd5fY3mynIRPr6kYL7HaEZYsapypX/pTJACzggHjjV0ac1Yb a1p7ChaOdnutgSqUb7uIXqtAkN9lNhKiGLRrrAA1Nq12TCusIhbQmosYBpcXi/nT0m UEQM7wO+zrARnqad0rm75ku3SQeX0XS0LZD4C44I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231115090702eucas1p232cc8bd41af130a7b076e2a93967815a~XwKpqfXja0817608176eucas1p2S; Wed, 15 Nov 2023 09:07:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 27.5C.09539.63A84556; Wed, 15 Nov 2023 09:07:02 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231115090701eucas1p1f759f3cd2e79837bf3778295bcedd20e~XwKpKG7Ln1373313733eucas1p19; Wed, 15 Nov 2023 09:07:01 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231115090701eusmtrp21e7508f04f040a8830e581f2c8ceb885~XwKpFjQbr0212702127eusmtrp2B; Wed, 15 Nov 2023 09:07:01 +0000 (GMT) X-AuditID: cbfec7f2-515ff70000002543-64-65548a364c15 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 75.0A.09274.53A84556; Wed, 15 Nov 2023 09:07:01 +0000 (GMT) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231115090701eusmtip1733fe67bb7aef9bed6dd4f8148c206e5~XwKoSqeCm1311813118eusmtip1Q; Wed, 15 Nov 2023 09:07:00 +0000 (GMT) Message-ID: Date: Wed, 15 Nov 2023 10:07:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Marek Szyprowski Subject: Re: [PATCH] PCI: exynos: Adapt to clk_bulk_* APIs To: Shradha Todi , 'Manivannan Sadhasivam' Cc: jingoohan1@gmail.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.dubey@samsung.com Content-Language: en-US In-Reply-To: <000b01da178e$a43088d0$ec919a70$@samsung.com> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDKsWRmVeSWpSXmKPExsWy7djPc7pmXSGpBr+3S1g8mLeNzWJJU4bF ii8z2S32vt7KbtHQ85vVYtPja6wWl3fNYbM4O+84m8WM8/uYLFr+tLBY3G3pZLV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FGoqEWc1FxIgANAsPNcQMAAA== X-CMS-MailID: 20231115090701eucas1p1f759f3cd2e79837bf3778295bcedd20e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20231009062222epcas5p36768b75c13c7c79965b5863521361a64 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231009062222epcas5p36768b75c13c7c79965b5863521361a64 References: <20231009062216.6729-1-shradha.t@samsung.com> <20231027134849.GA23716@thinkpad> <000b01da178e$a43088d0$ec919a70$@samsung.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 01:07:28 -0800 (PST) Hi! On 15.11.2023 07:40, Shradha Todi wrote: >> -----Original Message----- >> From: Manivannan Sadhasivam [mailto:manivannan.sadhasivam@linaro.org] >> Sent: 27 October 2023 19:19 >> To: Shradha Todi >> Cc:jingoohan1@gmail.com;lpieralisi@kernel.org;kw@linux.com; >> robh@kernel.org;bhelgaas@google.com;krzysztof.kozlowski@linaro.org; >> alim.akhtar@samsung.com;linux-pci@vger.kernel.org; linux-arm- >> kernel@lists.infradead.org;linux-samsung-soc@vger.kernel.org; linux- >> kernel@vger.kernel.org;pankaj.dubey@samsung.com >> Subject: Re: [PATCH] PCI: exynos: Adapt to clk_bulk_* APIs >> >> On Mon, Oct 09, 2023 at 11:52:16AM +0530, Shradha Todi wrote: >>> There is no need to hardcode the clock info in the driver as driver >>> can rely on the devicetree to supply the clocks required for the >>> functioning of the peripheral. Get rid of the static clock info and >>> obtain the platform supplied clocks. The total number of clocks >>> supplied is obtained using the devm_clk_bulk_get_all() API and used >>> for the rest of the clk_bulk_* APIs. >>> >>> Signed-off-by: Shradha Todi >>> --- >>> drivers/pci/controller/dwc/pci-exynos.c | 46 >>> ++++++------------------- >>> 1 file changed, 11 insertions(+), 35 deletions(-) >>> >>> diff --git a/drivers/pci/controller/dwc/pci-exynos.c >>> b/drivers/pci/controller/dwc/pci-exynos.c >>> index 9e42cfcd99cc..023cf41fccd7 100644 >>> --- a/drivers/pci/controller/dwc/pci-exynos.c >>> +++ b/drivers/pci/controller/dwc/pci-exynos.c >>> @@ -54,8 +54,8 @@ >>> struct exynos_pcie { >>> struct dw_pcie pci; >>> void __iomem *elbi_base; >>> - struct clk *clk; >>> - struct clk *bus_clk; >>> + struct clk_bulk_data *clks; >>> + int clk_cnt; >>> struct phy *phy; >>> struct regulator_bulk_data supplies[2]; >>> }; >>> @@ -65,30 +65,18 @@ static int exynos_pcie_init_clk_resources(struct >> exynos_pcie *ep) >>> struct device *dev = ep->pci.dev; >>> int ret; >>> >>> - ret = clk_prepare_enable(ep->clk); >>> - if (ret) { >>> - dev_err(dev, "cannot enable pcie rc clock"); >>> + ret = devm_clk_bulk_get_all(dev, &ep->clks); >>> + if (ret < 0) >> Please use !(ret) here and below to be consistent with the driver. >> > In this case, only negative values indicate failure. Hence we cannot use (!ret) here. > >>> return ret; >>> - } >>> >>> - ret = clk_prepare_enable(ep->bus_clk); >>> - if (ret) { >>> - dev_err(dev, "cannot enable pcie bus clock"); >>> - goto err_bus_clk; >>> - } >>> + ep->clk_cnt = ret; >> Since clk_cnt is "int", you can just use it directly instead of "ret". >> > Thanks for this suggestion! Will take care in v2. > >>> - return 0; >>> - >>> -err_bus_clk: >>> - clk_disable_unprepare(ep->clk); >>> - >>> - return ret; >>> + return clk_bulk_prepare_enable(ep->clk_cnt, ep->clks); >>> } >>> >>> static void exynos_pcie_deinit_clk_resources(struct exynos_pcie *ep) >>> { >>> - clk_disable_unprepare(ep->bus_clk); >>> - clk_disable_unprepare(ep->clk); >>> + clk_bulk_disable_unprepare(ep->clk_cnt, ep->clks); >>> } >>> >>> static void exynos_pcie_writel(void __iomem *base, u32 val, u32 reg) >>> @@ -332,17 +320,9 @@ static int exynos_pcie_probe(struct >> platform_device *pdev) >>> if (IS_ERR(ep->elbi_base)) >>> return PTR_ERR(ep->elbi_base); >>> >>> - ep->clk = devm_clk_get(dev, "pcie"); >>> - if (IS_ERR(ep->clk)) { >>> - dev_err(dev, "Failed to get pcie rc clock\n"); >>> - return PTR_ERR(ep->clk); >>> - } >>> - >>> - ep->bus_clk = devm_clk_get(dev, "pcie_bus"); >>> - if (IS_ERR(ep->bus_clk)) { >>> - dev_err(dev, "Failed to get pcie bus clock\n"); >>> - return PTR_ERR(ep->bus_clk); >>> - } >>> + ret = exynos_pcie_init_clk_resources(ep); >>> + if (ret < 0) >>> + return ret; >>> >>> ep->supplies[0].supply = "vdd18"; >>> ep->supplies[1].supply = "vdd10"; >>> @@ -351,10 +331,6 @@ static int exynos_pcie_probe(struct >> platform_device *pdev) >>> if (ret) >>> return ret; >>> >>> - ret = exynos_pcie_init_clk_resources(ep); >>> - if (ret) >>> - return ret; >>> - >>> ret = regulator_bulk_enable(ARRAY_SIZE(ep->supplies), ep- >>> supplies); >>> if (ret) >> You need to disable_unprepare() clocks in error path here and above. >> > Thanks for pointing out! Will take care in v2. Maybe it would make sense to add devm_clk_bulk_get_all_enabled() to clock framework, similar to the existing devm_clk_get_enabled()? It is really a common pattern to get all clocks and enable them for the time of driver operation. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland