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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 2DB41C433E0 for ; Fri, 15 May 2020 10:32:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04E20206B6 for ; Fri, 15 May 2020 10:32:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vcmQAMrE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728371AbgEOKcc (ORCPT ); Fri, 15 May 2020 06:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728144AbgEOKca (ORCPT ); Fri, 15 May 2020 06:32:30 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F754C061A0C; Fri, 15 May 2020 03:32:29 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id h10so2074784iob.10; Fri, 15 May 2020 03:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=vcmQAMrEzsV4FG1L5QpLXkqBOrQ5OWuYdGlR8+ygcxJg+F5fPgRqdFWYKvqJJgU4mT zG2aAW2Aaxx8HmPIlfVGBlGU+Tu3x3HW3wNhOb0imgignadU5yAYy5edOXWWGXi/0Na4 0SCSsnOjKh6NZ89GJ/Z1th6BYn3bZVjgPzwjCcYTGdFvmRZ+d8292zz6Fa+rLu1nDRVS nqtULSE9iytN1Ux/XqwoX0F6IiuTkU6cBgvLoTaXjmrYNhB/2fbpLk/00zSQBHvVF91s Hv+b2E+JxXaSCT1p0PXKvweG2iD7xl6BSOXRJs6N8uGBGhhsdZ7fLsuZ6pWRxwXozdGD zlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=tIxLynNDKCBNNubK2SV154a6aqgDs+TLD79/uYoyXwykQBAl08x80bK1Rzbpg09eMf Lw0EYB9dGstitqYlA1JgmGr3yuXNnFOW4vm9gV62UYLT1/+/xow9EOje4kT8US1LXB9M O5DFGNDpeLtdpx1YAOE1wtcubFaVGjqXKul+aoXG+0LNFmYV2eNTfE4bg+hTL7kS7KAk TMAm8pWVN6gkakdyEkBEQ1XVmsgGL+xyzu2yJucpsAYVZgstbT92kGd9b3b8Gx6zV909 N/g92dAjO6zyeSD6BptW1cxk1zhs4PGMsiW4sSFUGspqMHr60lwFbRhNClYYTrSty+4R 5SuA== X-Gm-Message-State: AOAM530dhGc5N3Vtd8zmP2vyWO8UeqfMo+DNxoWhAjTk1k4INdNDbJZC TbX4JPAPpbo682l9DibMZt3kL1PJZJmeOLQCkYM= X-Google-Smtp-Source: ABdhPJySFDwer7KjH89ACOdbQCrAFJYmz3PmcTnEmry2cPWkqSChoUu+TiNgN9tnSrdVOfv81ypAYcyv/WXFLRq7XEE= X-Received: by 2002:a02:ac1:: with SMTP id 184mr2566280jaw.137.1589538748835; Fri, 15 May 2020 03:32:28 -0700 (PDT) MIME-Version: 1.0 References: <1589267017-17294-1-git-send-email-dillon.minfei@gmail.com> <1589267017-17294-5-git-send-email-dillon.minfei@gmail.com> <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> In-Reply-To: <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> From: dillon min Date: Fri, 15 May 2020 18:31:52 +0800 Message-ID: Subject: Re: [PATCH v3 4/5] clk: stm32: Fix stm32f429 ltdc driver loading hang in clk set rate. keep ltdc clk running after kernel startup To: Stephen Boyd Cc: Dave Airlie , Alexandre Torgue , Daniel Vetter , Maxime Coquelin , Michael Turquette , Rob Herring , Sam Ravnborg , thierry.reding@gmail.com, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-stm32@st-md-mailman.stormreply.com, Linux ARM , linux-kernel@vger.kernel.org, "open list:DRM PANEL DRIVERS" , linux-clk Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, thanks for reviewing. On Fri, May 15, 2020 at 5:02 AM Stephen Boyd wrote: > > Quoting dillon.minfei@gmail.com (2020-05-12 00:03:36) > > From: dillon min > > > > as store stm32f4_rcc_register_pll return to the wrong offset of clks, > > Use () on functions, i.e. stm32f4_rcc_register_pll(). ok > > > so ltdc gate clk is null. need change clks[PLL_VCO_SAI] to clks[PLL_SAI] > > And quote variables like 'clks[PLL_VCO_SAI]' ok > > > > > add CLK_IGNORE_UNUSED for ltdc to make sure clk not be freed by > > clk_disable_unused > > clk_disable_unused() doesn't free anything. Why does ltdc not need to be > turned off if it isn't used? Is it critical to system operation? Should > it be marked with the critical clk flag then? The CLK_IGNORE_UNUSED flag > is almost always wrong to use. Yes, you are right. thanks. CLK_IGNORE_UNUSED just hide the root cause. after deeper debugging. i need to drop the last changes , they are not the root cause. post diff and analyse here first, i will resubmit clk's changes in next patchset with gyro and ili9341. --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -129,8 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", - CLK_IGNORE_UNUSED }, }; static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { @@ -558,13 +556,13 @@ static const struct clk_div_table post_divr_table[] = { #define MAX_POST_DIV 3 static const struct stm32f4_pll_post_div_data post_div_data[MAX_POST_DIV] = { - { CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q", + { CLK_I2SQ_PDIV, PLL_VCO_I2S, "plli2s-q-div", "plli2s-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 0, 5, 0, NULL}, - { CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q", + { CLK_SAIQ_PDIV, PLL_VCO_SAI, "pllsai-q-div", "pllsai-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 8, 5, 0, NULL }, - { NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, + { NO_IDX, PLL_VCO_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 16, 2, 0, post_divr_table }, }; @@ -1758,7 +1756,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[1], &stm32f4_clk_lock); - clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", + clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); for (n = 0; n < MAX_POST_DIV; n++) { issue 1: ili9341 hang in clk set rate, the root cause should be PLL_VCO_SAI, PLL_SAI mismatch for 'clks[]' 1, first at stm32f4_rcc_init() , clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); the clk_hw from stm32f4_rcc_register_pll() is store to 'clks[7]', defined in 'include/dt-bindings/clock/stm32fx-clock.h' 2, next hw = clk_register_pll_div(post_div->name, post_div->parent, post_div->flag, base + post_div->offset, post_div->shift, post_div->width, post_div->flag_div, post_div->div_table, clks[post_div->pll_num], &stm32f4_clk_lock); the 'clks[post_div->pll_num]', the pll_num is PLL_SAI, the value is 2, defined at enum { PLL, PLL_I2S, PLL_SAI, }; 'post_div_data[]' so 7 != 2 offset of 'clks[]', input the wrong 'clks[]' to clk_register_pll_div. cause to_clk_gate result is null, crashed in ltdc driver's loading. issue 2: clk_disable_unused() turn off ltdc clock. 1, ltdc clk is defined in 'stm32f429_gates[]', register to clk core, but there is no user to use it. ltdc driver use dts binding name "lcd", connect to CLK_LCD, then aux clk 'lcd-tft ' 2, as no one use 'stm32f429_gates[]' s ltdc clock , so the enable_count is zero, after kernel startup it's been turn off by clk_disable_unused() is fine. my chages for this is remove the ltdc from 'stm32f429_gates[]' but this modification still need 'clk-stm32f4.c''s maintainer to check if there is side effect. > > > > > Signed-off-by: dillon min > > --- > > drivers/clk/clk-stm32f4.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c > > index 18117ce..0ba73de 100644 > > --- a/drivers/clk/clk-stm32f4.c > > +++ b/drivers/clk/clk-stm32f4.c > > @@ -129,7 +129,8 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { > > { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, > > - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div" }, > > + { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", > > + CLK_IGNORE_UNUSED }, > > }; > > > > static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { > > @@ -1757,7 +1758,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) > > clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[1], &stm32f4_clk_lock); > > > > - clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", > > + clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[2], &stm32f4_clk_lock); > > > > for (n = 0; n < MAX_POST_DIV; n++) { 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=-6.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 63DA7C433DF for ; Fri, 15 May 2020 10:32:45 +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 1FC89206B6 for ; Fri, 15 May 2020 10:32:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UaNjUe8c"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vcmQAMrE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FC89206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oSsDU0x0CB7LSmxhWHbn8ZxkXJLB3aUb5AgnjLUHO+U=; b=UaNjUe8cGE/4vc ChixPra9MThJfHoHP6KANApq4n+5+N1s5c5jvs2gc446TWSR6TBEtwJeYQ/lSez8g6dsP7uMj/f2h V2k98fvZoGTd6OTaIfMdBcz9RXCl39DYFyIKvqR9o6EbrOlTFK2a54yNWN1wgyoJrWO97e0wE2PUL iHLLAHjol7HcWcqZ7eE5kpfIhLFGxXc1tPGm85OFCDQ183vTDhfmNiPY5SrWaYfZ83djUmfOJ2eJS E5EvxpBt9PdNvWFyyhl0VsZYqncLa57j7qG/sN6ZEKDUxPMGMyoDYhJSJqR8DDGNU3fUpbdJDogWj 6ZtvKl94XiydhL1L37sQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZXdp-0006Ll-MK; Fri, 15 May 2020 10:32:33 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZXdm-0006LD-41 for linux-arm-kernel@lists.infradead.org; Fri, 15 May 2020 10:32:31 +0000 Received: by mail-io1-xd42.google.com with SMTP id f3so2161640ioj.1 for ; Fri, 15 May 2020 03:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=vcmQAMrEzsV4FG1L5QpLXkqBOrQ5OWuYdGlR8+ygcxJg+F5fPgRqdFWYKvqJJgU4mT zG2aAW2Aaxx8HmPIlfVGBlGU+Tu3x3HW3wNhOb0imgignadU5yAYy5edOXWWGXi/0Na4 0SCSsnOjKh6NZ89GJ/Z1th6BYn3bZVjgPzwjCcYTGdFvmRZ+d8292zz6Fa+rLu1nDRVS nqtULSE9iytN1Ux/XqwoX0F6IiuTkU6cBgvLoTaXjmrYNhB/2fbpLk/00zSQBHvVF91s Hv+b2E+JxXaSCT1p0PXKvweG2iD7xl6BSOXRJs6N8uGBGhhsdZ7fLsuZ6pWRxwXozdGD zlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=TJ+26ttjgSZ/RHhLQVcqtfzkHwk6dzjJlkwnmdj19OKCBLosxIrplpVnpuCDQIBJBD dTeYcxvbvZ276HHRWfk3gVsv++apsw/FQVd7H/YQuWenDZvIiqlL4NyY00jMpDJvUvqv HjyW8P7RI/ZkfPDNwPsSPNku6Q8x0DXNhz+NMlFflNwHBfMXJPYNdOjqQ2WgIZM+N/5g qcBYsBInEWeBbav1Epzz5+7VNbo97yZzaIU41yMwThBmzIFg4AIaQ7Jk3hBJ5OWS+knJ DkvW19xjwcyDefziVf5FwuIuk5JKfsoaygZOowd9Ft1r6dv1H7DzipypIWbgype5JICN xkCg== X-Gm-Message-State: AOAM530MB4kLztktURjGLCr2Z+WkPbZ+yB01z4udthM4LZA+AjGuQL4i jilKugeuUn040HNT5vDGr16RTJ6ST1wBSKT17Is= X-Google-Smtp-Source: ABdhPJySFDwer7KjH89ACOdbQCrAFJYmz3PmcTnEmry2cPWkqSChoUu+TiNgN9tnSrdVOfv81ypAYcyv/WXFLRq7XEE= X-Received: by 2002:a02:ac1:: with SMTP id 184mr2566280jaw.137.1589538748835; Fri, 15 May 2020 03:32:28 -0700 (PDT) MIME-Version: 1.0 References: <1589267017-17294-1-git-send-email-dillon.minfei@gmail.com> <1589267017-17294-5-git-send-email-dillon.minfei@gmail.com> <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> In-Reply-To: <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> From: dillon min Date: Fri, 15 May 2020 18:31:52 +0800 Message-ID: Subject: Re: [PATCH v3 4/5] clk: stm32: Fix stm32f429 ltdc driver loading hang in clk set rate. keep ltdc clk running after kernel startup To: Stephen Boyd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200515_033230_187289_F511B567 X-CRM114-Status: GOOD ( 22.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Alexandre Torgue , Dave Airlie , Michael Turquette , linux-kernel@vger.kernel.org, "open list:DRM PANEL DRIVERS" , linux-clk , Rob Herring , thierry.reding@gmail.com, Maxime Coquelin , Daniel Vetter , Sam Ravnborg , linux-stm32@st-md-mailman.stormreply.com, Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Stephen, thanks for reviewing. On Fri, May 15, 2020 at 5:02 AM Stephen Boyd wrote: > > Quoting dillon.minfei@gmail.com (2020-05-12 00:03:36) > > From: dillon min > > > > as store stm32f4_rcc_register_pll return to the wrong offset of clks, > > Use () on functions, i.e. stm32f4_rcc_register_pll(). ok > > > so ltdc gate clk is null. need change clks[PLL_VCO_SAI] to clks[PLL_SAI] > > And quote variables like 'clks[PLL_VCO_SAI]' ok > > > > > add CLK_IGNORE_UNUSED for ltdc to make sure clk not be freed by > > clk_disable_unused > > clk_disable_unused() doesn't free anything. Why does ltdc not need to be > turned off if it isn't used? Is it critical to system operation? Should > it be marked with the critical clk flag then? The CLK_IGNORE_UNUSED flag > is almost always wrong to use. Yes, you are right. thanks. CLK_IGNORE_UNUSED just hide the root cause. after deeper debugging. i need to drop the last changes , they are not the root cause. post diff and analyse here first, i will resubmit clk's changes in next patchset with gyro and ili9341. --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -129,8 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", - CLK_IGNORE_UNUSED }, }; static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { @@ -558,13 +556,13 @@ static const struct clk_div_table post_divr_table[] = { #define MAX_POST_DIV 3 static const struct stm32f4_pll_post_div_data post_div_data[MAX_POST_DIV] = { - { CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q", + { CLK_I2SQ_PDIV, PLL_VCO_I2S, "plli2s-q-div", "plli2s-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 0, 5, 0, NULL}, - { CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q", + { CLK_SAIQ_PDIV, PLL_VCO_SAI, "pllsai-q-div", "pllsai-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 8, 5, 0, NULL }, - { NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, + { NO_IDX, PLL_VCO_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 16, 2, 0, post_divr_table }, }; @@ -1758,7 +1756,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[1], &stm32f4_clk_lock); - clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", + clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); for (n = 0; n < MAX_POST_DIV; n++) { issue 1: ili9341 hang in clk set rate, the root cause should be PLL_VCO_SAI, PLL_SAI mismatch for 'clks[]' 1, first at stm32f4_rcc_init() , clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); the clk_hw from stm32f4_rcc_register_pll() is store to 'clks[7]', defined in 'include/dt-bindings/clock/stm32fx-clock.h' 2, next hw = clk_register_pll_div(post_div->name, post_div->parent, post_div->flag, base + post_div->offset, post_div->shift, post_div->width, post_div->flag_div, post_div->div_table, clks[post_div->pll_num], &stm32f4_clk_lock); the 'clks[post_div->pll_num]', the pll_num is PLL_SAI, the value is 2, defined at enum { PLL, PLL_I2S, PLL_SAI, }; 'post_div_data[]' so 7 != 2 offset of 'clks[]', input the wrong 'clks[]' to clk_register_pll_div. cause to_clk_gate result is null, crashed in ltdc driver's loading. issue 2: clk_disable_unused() turn off ltdc clock. 1, ltdc clk is defined in 'stm32f429_gates[]', register to clk core, but there is no user to use it. ltdc driver use dts binding name "lcd", connect to CLK_LCD, then aux clk 'lcd-tft ' 2, as no one use 'stm32f429_gates[]' s ltdc clock , so the enable_count is zero, after kernel startup it's been turn off by clk_disable_unused() is fine. my chages for this is remove the ltdc from 'stm32f429_gates[]' but this modification still need 'clk-stm32f4.c''s maintainer to check if there is side effect. > > > > > Signed-off-by: dillon min > > --- > > drivers/clk/clk-stm32f4.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c > > index 18117ce..0ba73de 100644 > > --- a/drivers/clk/clk-stm32f4.c > > +++ b/drivers/clk/clk-stm32f4.c > > @@ -129,7 +129,8 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { > > { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, > > - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div" }, > > + { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", > > + CLK_IGNORE_UNUSED }, > > }; > > > > static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { > > @@ -1757,7 +1758,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) > > clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[1], &stm32f4_clk_lock); > > > > - clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", > > + clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[2], &stm32f4_clk_lock); > > > > for (n = 0; n < MAX_POST_DIV; n++) { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-6.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 250EDC433DF for ; Sat, 16 May 2020 09:59:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 E82D4206D4 for ; Sat, 16 May 2020 09:59:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vcmQAMrE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E82D4206D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 95B906E128; Sat, 16 May 2020 09:59:00 +0000 (UTC) Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88D4C6EC6A for ; Fri, 15 May 2020 10:32:29 +0000 (UTC) Received: by mail-io1-xd44.google.com with SMTP id h10so2074787iob.10 for ; Fri, 15 May 2020 03:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=vcmQAMrEzsV4FG1L5QpLXkqBOrQ5OWuYdGlR8+ygcxJg+F5fPgRqdFWYKvqJJgU4mT zG2aAW2Aaxx8HmPIlfVGBlGU+Tu3x3HW3wNhOb0imgignadU5yAYy5edOXWWGXi/0Na4 0SCSsnOjKh6NZ89GJ/Z1th6BYn3bZVjgPzwjCcYTGdFvmRZ+d8292zz6Fa+rLu1nDRVS nqtULSE9iytN1Ux/XqwoX0F6IiuTkU6cBgvLoTaXjmrYNhB/2fbpLk/00zSQBHvVF91s Hv+b2E+JxXaSCT1p0PXKvweG2iD7xl6BSOXRJs6N8uGBGhhsdZ7fLsuZ6pWRxwXozdGD zlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mp1O72Xdq00O8JgDXWC/mDotxQHEbyc0hg/iAsVvAgY=; b=gImY5f2sQilAaW3WSZnGlBDVDOxsYwQ43Dn+HHOY5o76rh071zk1X08BuB78I1yuNj AodbEPm/X/jVpBBDQJHAUINODJEcJFnx6Cwk7T9qKdTaIi83nEaYIwVxx2tYRTZdP/0o +SVZn+pBjItNQsxXPcgqVHwUTCwQ8Ovp7YUaxNnWFzj00/aSxivVDRe2IRaJU9m6JFYs MqJxV0nJuCasJxUSjPaqPldatAJHX1L6+F9aSJSA2K4qIDrnMRDU0nTGmdBxUHKnz/W9 8yjLGd2KmyS7g1SBvm+l8T0YI9gt2ePEMSmVxV48aZfFt8XxLdZtBNCTjbPjTKkJqxWc 2tBg== X-Gm-Message-State: AOAM533Wp7HcNe2rOBYhsYiQnJJq/yrt73SJL2eLntLhrZum8umaFPkm OCZ1LCPG5uM/wB7iEuxxlhu+eev8NUvSMPQ0rzExllWGLjQ= X-Google-Smtp-Source: ABdhPJySFDwer7KjH89ACOdbQCrAFJYmz3PmcTnEmry2cPWkqSChoUu+TiNgN9tnSrdVOfv81ypAYcyv/WXFLRq7XEE= X-Received: by 2002:a02:ac1:: with SMTP id 184mr2566280jaw.137.1589538748835; Fri, 15 May 2020 03:32:28 -0700 (PDT) MIME-Version: 1.0 References: <1589267017-17294-1-git-send-email-dillon.minfei@gmail.com> <1589267017-17294-5-git-send-email-dillon.minfei@gmail.com> <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> In-Reply-To: <158949014721.215346.12197373767247910756@swboyd.mtv.corp.google.com> From: dillon min Date: Fri, 15 May 2020 18:31:52 +0800 Message-ID: Subject: Re: [PATCH v3 4/5] clk: stm32: Fix stm32f429 ltdc driver loading hang in clk set rate. keep ltdc clk running after kernel startup To: Stephen Boyd X-Mailman-Approved-At: Sat, 16 May 2020 09:58:59 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Alexandre Torgue , Dave Airlie , Michael Turquette , linux-kernel@vger.kernel.org, "open list:DRM PANEL DRIVERS" , linux-clk , Rob Herring , thierry.reding@gmail.com, Maxime Coquelin , Sam Ravnborg , linux-stm32@st-md-mailman.stormreply.com, Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Stephen, thanks for reviewing. On Fri, May 15, 2020 at 5:02 AM Stephen Boyd wrote: > > Quoting dillon.minfei@gmail.com (2020-05-12 00:03:36) > > From: dillon min > > > > as store stm32f4_rcc_register_pll return to the wrong offset of clks, > > Use () on functions, i.e. stm32f4_rcc_register_pll(). ok > > > so ltdc gate clk is null. need change clks[PLL_VCO_SAI] to clks[PLL_SAI] > > And quote variables like 'clks[PLL_VCO_SAI]' ok > > > > > add CLK_IGNORE_UNUSED for ltdc to make sure clk not be freed by > > clk_disable_unused > > clk_disable_unused() doesn't free anything. Why does ltdc not need to be > turned off if it isn't used? Is it critical to system operation? Should > it be marked with the critical clk flag then? The CLK_IGNORE_UNUSED flag > is almost always wrong to use. Yes, you are right. thanks. CLK_IGNORE_UNUSED just hide the root cause. after deeper debugging. i need to drop the last changes , they are not the root cause. post diff and analyse here first, i will resubmit clk's changes in next patchset with gyro and ili9341. --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -129,8 +129,6 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", - CLK_IGNORE_UNUSED }, }; static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { @@ -558,13 +556,13 @@ static const struct clk_div_table post_divr_table[] = { #define MAX_POST_DIV 3 static const struct stm32f4_pll_post_div_data post_div_data[MAX_POST_DIV] = { - { CLK_I2SQ_PDIV, PLL_I2S, "plli2s-q-div", "plli2s-q", + { CLK_I2SQ_PDIV, PLL_VCO_I2S, "plli2s-q-div", "plli2s-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 0, 5, 0, NULL}, - { CLK_SAIQ_PDIV, PLL_SAI, "pllsai-q-div", "pllsai-q", + { CLK_SAIQ_PDIV, PLL_VCO_SAI, "pllsai-q-div", "pllsai-q", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 8, 5, 0, NULL }, - { NO_IDX, PLL_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, + { NO_IDX, PLL_VCO_SAI, "pllsai-r-div", "pllsai-r", CLK_SET_RATE_PARENT, STM32F4_RCC_DCKCFGR, 16, 2, 0, post_divr_table }, }; @@ -1758,7 +1756,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[1], &stm32f4_clk_lock); - clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", + clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); for (n = 0; n < MAX_POST_DIV; n++) { issue 1: ili9341 hang in clk set rate, the root cause should be PLL_VCO_SAI, PLL_SAI mismatch for 'clks[]' 1, first at stm32f4_rcc_init() , clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[2], &stm32f4_clk_lock); the clk_hw from stm32f4_rcc_register_pll() is store to 'clks[7]', defined in 'include/dt-bindings/clock/stm32fx-clock.h' 2, next hw = clk_register_pll_div(post_div->name, post_div->parent, post_div->flag, base + post_div->offset, post_div->shift, post_div->width, post_div->flag_div, post_div->div_table, clks[post_div->pll_num], &stm32f4_clk_lock); the 'clks[post_div->pll_num]', the pll_num is PLL_SAI, the value is 2, defined at enum { PLL, PLL_I2S, PLL_SAI, }; 'post_div_data[]' so 7 != 2 offset of 'clks[]', input the wrong 'clks[]' to clk_register_pll_div. cause to_clk_gate result is null, crashed in ltdc driver's loading. issue 2: clk_disable_unused() turn off ltdc clock. 1, ltdc clk is defined in 'stm32f429_gates[]', register to clk core, but there is no user to use it. ltdc driver use dts binding name "lcd", connect to CLK_LCD, then aux clk 'lcd-tft ' 2, as no one use 'stm32f429_gates[]' s ltdc clock , so the enable_count is zero, after kernel startup it's been turn off by clk_disable_unused() is fine. my chages for this is remove the ltdc from 'stm32f429_gates[]' but this modification still need 'clk-stm32f4.c''s maintainer to check if there is side effect. > > > > > Signed-off-by: dillon min > > --- > > drivers/clk/clk-stm32f4.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c > > index 18117ce..0ba73de 100644 > > --- a/drivers/clk/clk-stm32f4.c > > +++ b/drivers/clk/clk-stm32f4.c > > @@ -129,7 +129,8 @@ static const struct stm32f4_gate_data stm32f429_gates[] __initconst = { > > { STM32F4_RCC_APB2ENR, 20, "spi5", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 21, "spi6", "apb2_div" }, > > { STM32F4_RCC_APB2ENR, 22, "sai1", "apb2_div" }, > > - { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div" }, > > + { STM32F4_RCC_APB2ENR, 26, "ltdc", "apb2_div", > > + CLK_IGNORE_UNUSED }, > > }; > > > > static const struct stm32f4_gate_data stm32f469_gates[] __initconst = { > > @@ -1757,7 +1758,7 @@ static void __init stm32f4_rcc_init(struct device_node *np) > > clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[1], &stm32f4_clk_lock); > > > > - clks[PLL_VCO_SAI] = stm32f4_rcc_register_pll("vco_in", > > + clks[PLL_SAI] = stm32f4_rcc_register_pll("vco_in", > > &data->pll_data[2], &stm32f4_clk_lock); > > > > for (n = 0; n < MAX_POST_DIV; n++) { _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel