From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3FAC07E99 for ; Mon, 12 Jul 2021 07:18:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9804661166 for ; Mon, 12 Jul 2021 07:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343490AbhGLHTu (ORCPT ); Mon, 12 Jul 2021 03:19:50 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:56384 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234153AbhGLGzT (ORCPT ); Mon, 12 Jul 2021 02:55:19 -0400 X-Greylist: delayed 460 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 Jul 2021 02:55:18 EDT Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 3CCC240615 for ; Mon, 12 Jul 2021 06:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626072290; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type; b=br/iqPO48s/Z3W9tLoJ24RW3B1DWXwDbbJMk3Ha/uEeMwKlLR31ReJRayF3Wh04+p eE6bxgxe0VQws1G10V1Casu5CgFOocOEfJp4eunsgLxlC8ZBkI7+j8VPYFWsPpwIja xCIoi62S3F3aA/XfOP5KyjHMBYlYT1jPVkW5C94Qv+ZRz8Y52TUSKLC9GNfmdfyFqg 1/BszlrnHDo8UcyQHL8JbULf93HDRnTVMKOmcgrYilD/mowQw9Utu/HMf2oDX5RemW 6OaxAdvJewFgSzuqu2GJDq696ccWeVAbvzLM8cTpfBVpfX83eKfVmVi7wmhBFMXS+R 2u8NmB4iKr1cg== Received: by mail-wm1-f69.google.com with SMTP id p3-20020a05600c3583b02901f55d71e34aso5887468wmq.4 for ; Sun, 11 Jul 2021 23:44:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; b=nQeRNi9CnVQz0eWEcSsjSmU4g838o7zs6gVAFIH5scWLiflrPgxVkv1NX463f9lKRp HBv0HaUqnmEluQAbCx3MDHHw0opgMkygmS3doRjLhWAFJXJ+qtfQpIwGqufhbxI679UI MX/YqBj6PHS+XmQoW4JMIiiupcKt/Nhm2D0GqeLZI+YII7FTdqwS3zW1advAZhpIRG1v 3fNxBNszPdw0w5QBSz98D6FS6faIMwhrOP/W9+jsYBuHMv0YawrX9PyGUgawonVDT/CN CBYnWsBNSk/Jia4gh79nu7ngyI0ZHBnCv6cCHzmvR0wveFBcP8iDA1BiQKOWLdYtGtv9 fUtg== X-Gm-Message-State: AOAM532ze6w/A6e6pcIRzHa/6N+jMvq9a+sHz5Wliw4bNZiF0CS9D8UZ IixaBrjspEh5fLzs0GoFAn+WSZu+IRIPDzcsNuT8FF7mAWypbA9m21tf2nTffhvhLC5wB7e+roA EAT2FHBxAqCAx3OoUfoyK1kdXVK1/kl17ORi2GvCl2A== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338998wmu.171.1626072289645; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySU0D9B7fRMXEvgvy6Ati/eZuKcVknMxNOdcIIsbPvm/GJGLKf3jsMbB7YcvqNiHnDrw1oEw== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338983wmu.171.1626072289515; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Received: from [192.168.3.211] (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id o7sm15468284wrv.72.2021.07.11.23.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Subject: Re: [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops To: Yong Wu Cc: Rob Herring , Matthias Brugger , Krzysztof Kozlowski , Joerg Roedel , Will Deacon , Robin Murphy , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, anan.sun@mediatek.com, ming-fan.chen@mediatek.com, yi.kuo@mediatek.com, anthony.huang@mediatek.com References: <20210616114346.18812-1-yong.wu@mediatek.com> <20210616114346.18812-4-yong.wu@mediatek.com> <4047dfaf-f2f8-b6b2-52fd-41821475b162@canonical.com> <1625992199.22309.15.camel@mhfsdcap03> From: Krzysztof Kozlowski Message-ID: Date: Mon, 12 Jul 2021 08:44:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1625992199.22309.15.camel@mhfsdcap03> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/2021 10:29, Yong Wu wrote: > On Thu, 2021-07-08 at 11:32 +0200, Krzysztof Kozlowski wrote: >> On 16/06/2021 13:43, Yong Wu wrote: >>> smi have many clocks: apb/smi/gals. >>> This patch use clk_bulk interface instead of the orginal one to simply >>> the code. >>> >>> gals is optional clk(some larbs may don't have gals). use clk_bulk_optional >>> instead. and then remove the has_gals flag. >>> >>> Also remove clk fail logs since bulk interface already output fail log. >>> >>> Signed-off-by: Yong Wu >>> --- >>> drivers/memory/mtk-smi.c | 124 +++++++++++---------------------------- >>> 1 file changed, 34 insertions(+), 90 deletions(-) >>> >>> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c >>> index c5fb51f73b34..bcd2bf130655 100644 >>> --- a/drivers/memory/mtk-smi.c >>> +++ b/drivers/memory/mtk-smi.c >>> @@ -60,9 +60,18 @@ enum mtk_smi_gen { >>> MTK_SMI_GEN2 >>> }; >>> >>> +#define MTK_SMI_CLK_NR_MAX 4 >>> + >>> +static const char * const mtk_smi_common_clocks[] = { >>> + "apb", "smi", "gals0", "gals1", /* glas is optional */ >> >> Typo here - glas. > > Will Fix. Thanks. > >> >>> +}; >>> + > > [snip] > >>> @@ -493,7 +449,7 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> struct mtk_smi *common; >>> struct resource *res; >>> - int ret; >>> + int i, ret; >>> >>> common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL); >>> if (!common) >>> @@ -501,23 +457,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> common->dev = dev; >>> common->plat = of_device_get_match_data(dev); >>> >>> - common->clk_apb = devm_clk_get(dev, "apb"); >>> - if (IS_ERR(common->clk_apb)) >>> - return PTR_ERR(common->clk_apb); >>> - >>> - common->clk_smi = devm_clk_get(dev, "smi"); >>> - if (IS_ERR(common->clk_smi)) >>> - return PTR_ERR(common->clk_smi); >>> + common->clk_num = ARRAY_SIZE(mtk_smi_common_clocks); >>> + for (i = 0; i < common->clk_num; i++) >>> + common->clks[i].id = mtk_smi_common_clocks[i]; >>> >>> - if (common->plat->has_gals) { >>> - common->clk_gals0 = devm_clk_get(dev, "gals0"); >>> - if (IS_ERR(common->clk_gals0)) >>> - return PTR_ERR(common->clk_gals0); >>> - >>> - common->clk_gals1 = devm_clk_get(dev, "gals1"); >>> - if (IS_ERR(common->clk_gals1)) >>> - return PTR_ERR(common->clk_gals1); >>> - } >>> + ret = devm_clk_bulk_get_optional(dev, common->clk_num, common->clks); >>> + if (ret) >>> + return ret; >> >> How do you handle now missing required clocks? > > It looks this is a common issue for this function which supports all the > clocks could be optional. Is there common suggestion for this? > > For our case, the apb/smi clocks are required while "gals" are optional. > > thus, we should use devm_clk_bulk_get for the necessary clocks and > devm_clk_bulk_get_optional for the optional ones. right? Yes, I think that's the solution. Otherwise you might not have proper clocks leading to accesses to disabled/gated hardware. Best regards, Krzysztof From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7D58C11F70 for ; Mon, 12 Jul 2021 06:52:37 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77F3B6127C for ; Mon, 12 Jul 2021 06:52:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77F3B6127C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 469A040118; Mon, 12 Jul 2021 06:52:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kc8OGJ5TZJyj; Mon, 12 Jul 2021 06:52:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0F4B7400CB; Mon, 12 Jul 2021 06:52:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D7D65C0010; Mon, 12 Jul 2021 06:52:33 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 71140C000E for ; Mon, 12 Jul 2021 06:52:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5809D82437 for ; Mon, 12 Jul 2021 06:52:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=canonical.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fcPL0t5gUI9M for ; Mon, 12 Jul 2021 06:52:32 +0000 (UTC) X-Greylist: delayed 00:07:39 by SQLgrey-1.8.0 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by smtp1.osuosl.org (Postfix) with ESMTPS id 86D4D823E0 for ; Mon, 12 Jul 2021 06:52:32 +0000 (UTC) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id 05CB0404A0 for ; Mon, 12 Jul 2021 06:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626072290; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type; b=br/iqPO48s/Z3W9tLoJ24RW3B1DWXwDbbJMk3Ha/uEeMwKlLR31ReJRayF3Wh04+p eE6bxgxe0VQws1G10V1Casu5CgFOocOEfJp4eunsgLxlC8ZBkI7+j8VPYFWsPpwIja xCIoi62S3F3aA/XfOP5KyjHMBYlYT1jPVkW5C94Qv+ZRz8Y52TUSKLC9GNfmdfyFqg 1/BszlrnHDo8UcyQHL8JbULf93HDRnTVMKOmcgrYilD/mowQw9Utu/HMf2oDX5RemW 6OaxAdvJewFgSzuqu2GJDq696ccWeVAbvzLM8cTpfBVpfX83eKfVmVi7wmhBFMXS+R 2u8NmB4iKr1cg== Received: by mail-wm1-f71.google.com with SMTP id m6-20020a05600c4f46b0290205f5e73b37so5903903wmq.3 for ; Sun, 11 Jul 2021 23:44:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; b=Bd05xShFaJrLP4q2PUfRiFMBlU/a73pIPX4gxqmlLPZRPdPU4MwSIjVfc/2fEzId+K /WRPf9PJpZrOjtdXyjhBtTWNWtnz1KrdwUdk5yk383ynp1guYnd5yN2jmlxmSjdZlRkL XqBlU3/iXEH0kTDkivqmpPuZvXTYKzoMMEi/dMRMdjEuSHCh4uRHqi0+EQvUGST64uYO Su67XaCICI3dknhM0Dr2WqbkvENJfiDNKUU1Yr4X+AyFP1rA47nZ+wU8m2uxC22c/qSx gPERzxzDRONBpFoAjOHYarztCG58LS0M61z+YbuZ3gGFDPRIe7JCtjrZ6OTOJjy3OHC4 2BRw== X-Gm-Message-State: AOAM532uM0pzNjyGqa4/hORCwNOFoTvjM9Cr0JO9MhNK9TkS75GUgdX7 I+XtORi4Iy7CP6C5bko1dWQL6gOsRcDpb5BZgMa1r1SL9WqtHJXDpEwli4B/D1xgNQ1Q/ozkJ6+ Qb/zFMrvHb2XUEzmafUt7PIV94zmazDtakfXOWrlcH2JCrak= X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3339009wmu.171.1626072289679; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySU0D9B7fRMXEvgvy6Ati/eZuKcVknMxNOdcIIsbPvm/GJGLKf3jsMbB7YcvqNiHnDrw1oEw== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338983wmu.171.1626072289515; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Received: from [192.168.3.211] (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id o7sm15468284wrv.72.2021.07.11.23.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Subject: Re: [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops To: Yong Wu References: <20210616114346.18812-1-yong.wu@mediatek.com> <20210616114346.18812-4-yong.wu@mediatek.com> <4047dfaf-f2f8-b6b2-52fd-41821475b162@canonical.com> <1625992199.22309.15.camel@mhfsdcap03> From: Krzysztof Kozlowski Message-ID: Date: Mon, 12 Jul 2021 08:44:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1625992199.22309.15.camel@mhfsdcap03> Content-Language: en-US Cc: youlin.pei@mediatek.com, anan.sun@mediatek.com, srv_heupstream@mediatek.com, Will Deacon , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , iommu@lists.linux-foundation.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , anthony.huang@mediatek.com, ming-fan.chen@mediatek.com, yi.kuo@mediatek.com, Robin Murphy , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 11/07/2021 10:29, Yong Wu wrote: > On Thu, 2021-07-08 at 11:32 +0200, Krzysztof Kozlowski wrote: >> On 16/06/2021 13:43, Yong Wu wrote: >>> smi have many clocks: apb/smi/gals. >>> This patch use clk_bulk interface instead of the orginal one to simply >>> the code. >>> >>> gals is optional clk(some larbs may don't have gals). use clk_bulk_optional >>> instead. and then remove the has_gals flag. >>> >>> Also remove clk fail logs since bulk interface already output fail log. >>> >>> Signed-off-by: Yong Wu >>> --- >>> drivers/memory/mtk-smi.c | 124 +++++++++++---------------------------- >>> 1 file changed, 34 insertions(+), 90 deletions(-) >>> >>> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c >>> index c5fb51f73b34..bcd2bf130655 100644 >>> --- a/drivers/memory/mtk-smi.c >>> +++ b/drivers/memory/mtk-smi.c >>> @@ -60,9 +60,18 @@ enum mtk_smi_gen { >>> MTK_SMI_GEN2 >>> }; >>> >>> +#define MTK_SMI_CLK_NR_MAX 4 >>> + >>> +static const char * const mtk_smi_common_clocks[] = { >>> + "apb", "smi", "gals0", "gals1", /* glas is optional */ >> >> Typo here - glas. > > Will Fix. Thanks. > >> >>> +}; >>> + > > [snip] > >>> @@ -493,7 +449,7 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> struct mtk_smi *common; >>> struct resource *res; >>> - int ret; >>> + int i, ret; >>> >>> common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL); >>> if (!common) >>> @@ -501,23 +457,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> common->dev = dev; >>> common->plat = of_device_get_match_data(dev); >>> >>> - common->clk_apb = devm_clk_get(dev, "apb"); >>> - if (IS_ERR(common->clk_apb)) >>> - return PTR_ERR(common->clk_apb); >>> - >>> - common->clk_smi = devm_clk_get(dev, "smi"); >>> - if (IS_ERR(common->clk_smi)) >>> - return PTR_ERR(common->clk_smi); >>> + common->clk_num = ARRAY_SIZE(mtk_smi_common_clocks); >>> + for (i = 0; i < common->clk_num; i++) >>> + common->clks[i].id = mtk_smi_common_clocks[i]; >>> >>> - if (common->plat->has_gals) { >>> - common->clk_gals0 = devm_clk_get(dev, "gals0"); >>> - if (IS_ERR(common->clk_gals0)) >>> - return PTR_ERR(common->clk_gals0); >>> - >>> - common->clk_gals1 = devm_clk_get(dev, "gals1"); >>> - if (IS_ERR(common->clk_gals1)) >>> - return PTR_ERR(common->clk_gals1); >>> - } >>> + ret = devm_clk_bulk_get_optional(dev, common->clk_num, common->clks); >>> + if (ret) >>> + return ret; >> >> How do you handle now missing required clocks? > > It looks this is a common issue for this function which supports all the > clocks could be optional. Is there common suggestion for this? > > For our case, the apb/smi clocks are required while "gals" are optional. > > thus, we should use devm_clk_bulk_get for the necessary clocks and > devm_clk_bulk_get_optional for the optional ones. right? Yes, I think that's the solution. Otherwise you might not have proper clocks leading to accesses to disabled/gated hardware. Best regards, Krzysztof _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AA11C07E99 for ; Mon, 12 Jul 2021 06:45:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B72161209 for ; Mon, 12 Jul 2021 06:45:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B72161209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3X5heGxZYxBVNj3CY0MZoK/vl4cRSmqZ3xp0gUWGTpQ=; b=qwXT+oEU4O9SfnF1c/KCrdhmOC 3jYcZwH6CtqWYS16Y9ui9aZCq8wdgf4vqyo+cl1DKQh9uJo3hZi4u/cHuu2/Za1Luomp5xLgLEey3 TvZU1ieLUmqlYJpYxXx4FC3VVmJj+3VOtaLTzRuTeFAXaXXt77LeP1z67tbV4gm8f4es7JhdJZ3JM urhxKI8R/Dvbx3nzEUtnyfoExf5cVB8OkYZMr1tbB/zUmQB7jw/LzrPYvE2h8U7Ff+Pn6XVw7T6bL 9v1xLHkzPTQRF6HizwkFcfCB6EughXSKzVSfDnlE/hPIlOknFQ6JPzZJYZUi+FQGeCXzVldGixyxl 9XIJTeog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2pgp-0069iw-E7; Mon, 12 Jul 2021 06:45:15 +0000 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2pga-0069fG-Gs for linux-mediatek@lists.infradead.org; Mon, 12 Jul 2021 06:45:02 +0000 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id B62E64061F for ; Mon, 12 Jul 2021 06:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626072292; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type; b=hBUymzOYjO0+mRELEtavZJk/YNNokfJYII2FZaO/0D2sRCpPLJX1g3UfbGO0GwjFX 5H6VEZtHxVwhxBpIoLIcPM/lmipcoX0ZNHwnfPxZ7uAkbflSxxB2OXLfr578LwJkZ/ 8W9aFrtmwm3tYLktymsYJXlafJY5ZfHQAOJHbL37pVGVBCiVadWWzXHkPA4mH6D+qg xWGnzd4F7lIAWzdOiWwZDqHDU7iTzAcADcS30pf7KIpdWRO3vCONkU+7ldbmkUgwoA 7y1Qou9qF9chmgXVgDB0mkaHrK1od++36grkn4wa2SpuRB0xtXVCNI5DR/Of62bhFd ipjiD13HEuaCA== Received: by mail-wr1-f72.google.com with SMTP id g4-20020a5d64e40000b029013398ce8904so6735953wri.16 for ; Sun, 11 Jul 2021 23:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; b=c8kXzIGqti3T7VpaXm6QvAXDzNhP6f2rE7hxovyLe0OJEY+fYhVN0x4LvG9B4zKLyN WqwrjzLXQbyXkuP1O+NCqa4GkR0y0aljhlZ+zOlpytOCsCplD7puO/B9jxc2v5SyWN2n gi9ec2vmxW17hjlf4NocfBBCc3py9WEp729xmq3Qi0QP6j9mhJ8354pHYEH+2PexNANg 8aYUb9Cgt89a6zyX65UkpCZ/IGNA6CTwXUWbPeQ4PZjK8X6I2tk5WtQo8MS0Cud4++zF qGS6IpLOpLUMc05HBO4Uz04JgVdZGteRQUqGRZptaLO/LJLA6keT/rJJYeCl+62OvPUZ sKtw== X-Gm-Message-State: AOAM531Vd7xN5sglzGE7imgQaOx9+S8bbXjBFnwSfxLlUb6qdP03j93G ZAVsinScxuVgDqsoynOGByhUIxw0+oYVgPQcfMeW3qrxoikq9wGwAr/8DEOMUX1BiWs1urJNDVj aCTZA7k2Dj9VZu7h1LF6mIxrgb4ll2aApwcAjB/cnhQqdFuAr7Q== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3339015wmu.171.1626072289748; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySU0D9B7fRMXEvgvy6Ati/eZuKcVknMxNOdcIIsbPvm/GJGLKf3jsMbB7YcvqNiHnDrw1oEw== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338983wmu.171.1626072289515; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Received: from [192.168.3.211] (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id o7sm15468284wrv.72.2021.07.11.23.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Subject: Re: [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops To: Yong Wu Cc: Rob Herring , Matthias Brugger , Krzysztof Kozlowski , Joerg Roedel , Will Deacon , Robin Murphy , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, anan.sun@mediatek.com, ming-fan.chen@mediatek.com, yi.kuo@mediatek.com, anthony.huang@mediatek.com References: <20210616114346.18812-1-yong.wu@mediatek.com> <20210616114346.18812-4-yong.wu@mediatek.com> <4047dfaf-f2f8-b6b2-52fd-41821475b162@canonical.com> <1625992199.22309.15.camel@mhfsdcap03> From: Krzysztof Kozlowski Message-ID: Date: Mon, 12 Jul 2021 08:44:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1625992199.22309.15.camel@mhfsdcap03> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210711_234500_725212_BB3D88F7 X-CRM114-Status: GOOD ( 26.14 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On 11/07/2021 10:29, Yong Wu wrote: > On Thu, 2021-07-08 at 11:32 +0200, Krzysztof Kozlowski wrote: >> On 16/06/2021 13:43, Yong Wu wrote: >>> smi have many clocks: apb/smi/gals. >>> This patch use clk_bulk interface instead of the orginal one to simply >>> the code. >>> >>> gals is optional clk(some larbs may don't have gals). use clk_bulk_optional >>> instead. and then remove the has_gals flag. >>> >>> Also remove clk fail logs since bulk interface already output fail log. >>> >>> Signed-off-by: Yong Wu >>> --- >>> drivers/memory/mtk-smi.c | 124 +++++++++++---------------------------- >>> 1 file changed, 34 insertions(+), 90 deletions(-) >>> >>> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c >>> index c5fb51f73b34..bcd2bf130655 100644 >>> --- a/drivers/memory/mtk-smi.c >>> +++ b/drivers/memory/mtk-smi.c >>> @@ -60,9 +60,18 @@ enum mtk_smi_gen { >>> MTK_SMI_GEN2 >>> }; >>> >>> +#define MTK_SMI_CLK_NR_MAX 4 >>> + >>> +static const char * const mtk_smi_common_clocks[] = { >>> + "apb", "smi", "gals0", "gals1", /* glas is optional */ >> >> Typo here - glas. > > Will Fix. Thanks. > >> >>> +}; >>> + > > [snip] > >>> @@ -493,7 +449,7 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> struct mtk_smi *common; >>> struct resource *res; >>> - int ret; >>> + int i, ret; >>> >>> common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL); >>> if (!common) >>> @@ -501,23 +457,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> common->dev = dev; >>> common->plat = of_device_get_match_data(dev); >>> >>> - common->clk_apb = devm_clk_get(dev, "apb"); >>> - if (IS_ERR(common->clk_apb)) >>> - return PTR_ERR(common->clk_apb); >>> - >>> - common->clk_smi = devm_clk_get(dev, "smi"); >>> - if (IS_ERR(common->clk_smi)) >>> - return PTR_ERR(common->clk_smi); >>> + common->clk_num = ARRAY_SIZE(mtk_smi_common_clocks); >>> + for (i = 0; i < common->clk_num; i++) >>> + common->clks[i].id = mtk_smi_common_clocks[i]; >>> >>> - if (common->plat->has_gals) { >>> - common->clk_gals0 = devm_clk_get(dev, "gals0"); >>> - if (IS_ERR(common->clk_gals0)) >>> - return PTR_ERR(common->clk_gals0); >>> - >>> - common->clk_gals1 = devm_clk_get(dev, "gals1"); >>> - if (IS_ERR(common->clk_gals1)) >>> - return PTR_ERR(common->clk_gals1); >>> - } >>> + ret = devm_clk_bulk_get_optional(dev, common->clk_num, common->clks); >>> + if (ret) >>> + return ret; >> >> How do you handle now missing required clocks? > > It looks this is a common issue for this function which supports all the > clocks could be optional. Is there common suggestion for this? > > For our case, the apb/smi clocks are required while "gals" are optional. > > thus, we should use devm_clk_bulk_get for the necessary clocks and > devm_clk_bulk_get_optional for the optional ones. right? Yes, I think that's the solution. Otherwise you might not have proper clocks leading to accesses to disabled/gated hardware. Best regards, Krzysztof _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 496E4C07E99 for ; Mon, 12 Jul 2021 06:46:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1728061004 for ; Mon, 12 Jul 2021 06:46:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1728061004 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vW1jrWvO8pH6bjJUWXVSefnD6txRdCHrR4OJmjNBb3k=; b=mFtyJaFL5zA1t9UktdS/tdu+A2 yZ9F1ndO30Ouoa44JMRz0OB9OfjGB/weGiIOyNYFMV7YU8mgub9b4ZypJkd0SRlXkwQmYK0KqJ6wk cB/a2j4Dek+IXhOwkGTxuoBWIkRV8v5uYXCGrXpN0Ns97vs7Miotd9GJys4ct1WO+KR7UCs8rSndB NN0sXbOBn0clLD5zMWth6dWX2RTgKrmVVQHki50SXdH6I1H50WilPJAm6mI2VkxMQDNmQEZgU0oPf kvf340m2OzU2Qo+2lLUzrwl+akSrkMkHv9IT1tJ2KpqVXNOKOiylsu/H5M7gPOW5PRqX9BEzHy5IA CN3rxoOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2pgd-0069gu-NM; Mon, 12 Jul 2021 06:45:03 +0000 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2pgZ-0069fF-W2 for linux-arm-kernel@lists.infradead.org; Mon, 12 Jul 2021 06:45:01 +0000 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 61C304057E for ; Mon, 12 Jul 2021 06:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626072292; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type; b=hBUymzOYjO0+mRELEtavZJk/YNNokfJYII2FZaO/0D2sRCpPLJX1g3UfbGO0GwjFX 5H6VEZtHxVwhxBpIoLIcPM/lmipcoX0ZNHwnfPxZ7uAkbflSxxB2OXLfr578LwJkZ/ 8W9aFrtmwm3tYLktymsYJXlafJY5ZfHQAOJHbL37pVGVBCiVadWWzXHkPA4mH6D+qg xWGnzd4F7lIAWzdOiWwZDqHDU7iTzAcADcS30pf7KIpdWRO3vCONkU+7ldbmkUgwoA 7y1Qou9qF9chmgXVgDB0mkaHrK1od++36grkn4wa2SpuRB0xtXVCNI5DR/Of62bhFd ipjiD13HEuaCA== Received: by mail-wm1-f69.google.com with SMTP id i3-20020a05600c3543b02902075ed92710so6988365wmq.0 for ; Sun, 11 Jul 2021 23:44:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OR0zgeaONK2MupeyE6Ocj/7EocddRmlmkKFDNFfG1NY=; b=e5WpX7+XnmVgHfKbwPPJNwwmK4uWGLoQfBOl8Gw4+O3IenkGBJ0XPQUbpM6Dj5ykP0 warRhMq/rkxT/XrVygUYFRaXsfZ/7Y1AJN4b6Ga1zEQYiWe8DHyr3mBAhzisLt3QFlCI 8XgMQWp5fWrbtiPzWo4hepXyZeWzbVEW32XJsYxCE8bNsGlnH9LGVZ4XPEgAQqr5bFmG ZgvP+Vl8vfVKSTs8MwZgeRkbc9SgppVclaDS5K9Oet9UHJPyCnasoBgnjboYA9Xpd0Bk r9nvo5SdZLwZwRKVHZ0DkJZrQ6vIWXicSNEgd13qv9cwXr7Eu6fgmFNmGaBMwOQrebqb 6ljg== X-Gm-Message-State: AOAM533ShJzQ4FfG8U+IJhXTtnH5vokSj4y3McdIF2NZdsS80YrCELC4 7WDIVbMpXkOxycW6yc1vwO+K3VjfdOwtF/xtWwCDmg42hLhmMMSWGxhYtzBAr4HwlFIBBwcBaRR 0n3lsFTyacpLsuM5PXK2UzAT7DpUTbbnwCKyevT0FVa0/I/VoJpZq X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338996wmu.171.1626072289645; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySU0D9B7fRMXEvgvy6Ati/eZuKcVknMxNOdcIIsbPvm/GJGLKf3jsMbB7YcvqNiHnDrw1oEw== X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr3338983wmu.171.1626072289515; Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Received: from [192.168.3.211] (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id o7sm15468284wrv.72.2021.07.11.23.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Jul 2021 23:44:49 -0700 (PDT) Subject: Re: [PATCH 3/9] memory: mtk-smi: Use clk_bulk instead of the clk ops To: Yong Wu Cc: Rob Herring , Matthias Brugger , Krzysztof Kozlowski , Joerg Roedel , Will Deacon , Robin Murphy , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, anan.sun@mediatek.com, ming-fan.chen@mediatek.com, yi.kuo@mediatek.com, anthony.huang@mediatek.com References: <20210616114346.18812-1-yong.wu@mediatek.com> <20210616114346.18812-4-yong.wu@mediatek.com> <4047dfaf-f2f8-b6b2-52fd-41821475b162@canonical.com> <1625992199.22309.15.camel@mhfsdcap03> From: Krzysztof Kozlowski Message-ID: Date: Mon, 12 Jul 2021 08:44:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1625992199.22309.15.camel@mhfsdcap03> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210711_234500_302504_D6AA5B36 X-CRM114-Status: GOOD ( 27.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/07/2021 10:29, Yong Wu wrote: > On Thu, 2021-07-08 at 11:32 +0200, Krzysztof Kozlowski wrote: >> On 16/06/2021 13:43, Yong Wu wrote: >>> smi have many clocks: apb/smi/gals. >>> This patch use clk_bulk interface instead of the orginal one to simply >>> the code. >>> >>> gals is optional clk(some larbs may don't have gals). use clk_bulk_optional >>> instead. and then remove the has_gals flag. >>> >>> Also remove clk fail logs since bulk interface already output fail log. >>> >>> Signed-off-by: Yong Wu >>> --- >>> drivers/memory/mtk-smi.c | 124 +++++++++++---------------------------- >>> 1 file changed, 34 insertions(+), 90 deletions(-) >>> >>> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c >>> index c5fb51f73b34..bcd2bf130655 100644 >>> --- a/drivers/memory/mtk-smi.c >>> +++ b/drivers/memory/mtk-smi.c >>> @@ -60,9 +60,18 @@ enum mtk_smi_gen { >>> MTK_SMI_GEN2 >>> }; >>> >>> +#define MTK_SMI_CLK_NR_MAX 4 >>> + >>> +static const char * const mtk_smi_common_clocks[] = { >>> + "apb", "smi", "gals0", "gals1", /* glas is optional */ >> >> Typo here - glas. > > Will Fix. Thanks. > >> >>> +}; >>> + > > [snip] > >>> @@ -493,7 +449,7 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> struct device *dev = &pdev->dev; >>> struct mtk_smi *common; >>> struct resource *res; >>> - int ret; >>> + int i, ret; >>> >>> common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL); >>> if (!common) >>> @@ -501,23 +457,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev) >>> common->dev = dev; >>> common->plat = of_device_get_match_data(dev); >>> >>> - common->clk_apb = devm_clk_get(dev, "apb"); >>> - if (IS_ERR(common->clk_apb)) >>> - return PTR_ERR(common->clk_apb); >>> - >>> - common->clk_smi = devm_clk_get(dev, "smi"); >>> - if (IS_ERR(common->clk_smi)) >>> - return PTR_ERR(common->clk_smi); >>> + common->clk_num = ARRAY_SIZE(mtk_smi_common_clocks); >>> + for (i = 0; i < common->clk_num; i++) >>> + common->clks[i].id = mtk_smi_common_clocks[i]; >>> >>> - if (common->plat->has_gals) { >>> - common->clk_gals0 = devm_clk_get(dev, "gals0"); >>> - if (IS_ERR(common->clk_gals0)) >>> - return PTR_ERR(common->clk_gals0); >>> - >>> - common->clk_gals1 = devm_clk_get(dev, "gals1"); >>> - if (IS_ERR(common->clk_gals1)) >>> - return PTR_ERR(common->clk_gals1); >>> - } >>> + ret = devm_clk_bulk_get_optional(dev, common->clk_num, common->clks); >>> + if (ret) >>> + return ret; >> >> How do you handle now missing required clocks? > > It looks this is a common issue for this function which supports all the > clocks could be optional. Is there common suggestion for this? > > For our case, the apb/smi clocks are required while "gals" are optional. > > thus, we should use devm_clk_bulk_get for the necessary clocks and > devm_clk_bulk_get_optional for the optional ones. right? Yes, I think that's the solution. Otherwise you might not have proper clocks leading to accesses to disabled/gated hardware. Best regards, Krzysztof _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel