From patchwork Tue Apr 26 07:48:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 8935641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2DE5C9F1C1 for ; Tue, 26 Apr 2016 07:50:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4589A200F3 for ; Tue, 26 Apr 2016 07:50:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5668F200ED for ; Tue, 26 Apr 2016 07:50:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auxkC-0005Ir-7u; Tue, 26 Apr 2016 07:49:16 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auxk7-00056v-7L; Tue, 26 Apr 2016 07:49:12 +0000 Received: from msmac.intern.sperl.org (account martin@sperl.org [10.10.10.11] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6439034; Tue, 26 Apr 2016 07:48:48 +0000 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: [PATCH 3/6] clk: bcm2835: enable clocks that have been enabled by firmware From: Martin Sperl In-Reply-To: <87bn6dt13o.fsf@eliezer.anholt.net> Date: Tue, 26 Apr 2016 09:48:47 +0200 Message-Id: References: <1456745963-2403-1-git-send-email-kernel@martin.sperl.org> <1456745963-2403-4-git-send-email-kernel@martin.sperl.org> <87vb575ld9.fsf@eliezer.anholt.net> <87poutf1gv.fsf@eliezer.anholt.net> <19B78DCB-23E2-4600-ABF6-177AFACF159D@martin.sperl.org> <87bn6dt13o.fsf@eliezer.anholt.net> To: Eric Anholt X-Mailer: Apple Mail (2.2104) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160426_004911_639414_889EE747 X-CRM114-Status: GOOD ( 12.33 ) X-Spam-Score: -0.9 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Warren , Michael Turquette , Lee Jones , Stephen Boyd , linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > On 17.03.2016, at 19:23, Eric Anholt wrote: > > Martin Sperl writes: >> >> See that separate thread that triggered this: >> serial: clk: bcm2835: Strange effects when using aux-uart in console >> and this patch fixes this issue. >> >> To summarize the situation figured in the thread: >> * you load the module >> >> * you start using the tty (say by using "stty -F /dev/ttyAMA0") >> * this opens the device >> * this prepare the relevant clock (usage = 1) >> * this prepares the parent pll-divider (usage = 1) >> * this prepares the parent pll (usage = 1) >> >> * you stop using the tty (stty closes the device) >> * this release the clock >> * usage count drops to 0, so disable the clock >> * this releases the parent pll-divider >> * usage count drops to 0, so disable the pll-div >> * this releases the parent pll (and disables it as usage = 0) >> * usage count drops to 0, so disable the pll-div >> >> * system crashes (with a bit of delay) >> >> The prepare should just increase the usage so it never gets to a count of 0. >> >> Maybe we need to use those "CLK_IS_CRITICAL” “HANDS_OFF” flags instead? >> (when/if they become available) >> >> How do you want to solve that - I have not got a DSI display, >> but HDMI continues to work... > > We should just prepare the necessary divider, not the leaf clocks that > we actually want to control at runtime. So how are we continuing here? The reason why I am asking is that switching downstream to use the clock driver result in the lockups also when using i2s/pcm. I have seen that CLK_IS_CRITICAL has made it into the clk-next tree. Should we use that for plls (or pll_dividers) that are running? Something like this: At least for downstream this does work and gives the following messages: [ 2.861321] bcm2835-clk 20101000.cprman: found enabled pll_div plla_core - marking it as critical [ 2.875917] bcm2835-clk 20101000.cprman: found enabled pll_div pllb_arm - marking it as critical [ 2.961250] bcm2835-clk 20101000.cprman: found enabled pll_div pllc_core0 - marking it as critical [ 2.977317] bcm2835-clk 20101000.cprman: found enabled pll_div pllc_per - marking it as critical [ 2.993226] bcm2835-clk 20101000.cprman: found enabled pll_div plld_core - marking it as critical [ 3.010189] bcm2835-clk 20101000.cprman: found enabled pll_div plld_per - marking it as critical [ 3.024993] bcm2835-clk 20101000.cprman: found enabled pll_div pllh_pix - marking it as critical Martin diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 35f8de7..c17019f 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1200,6 +1200,15 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman, divider->cprman = cprman; divider->data = data; + /* if the pll-divider is running, then mark is as critical */ + if ((cprman_read(cprman, data->a2w_reg) & + A2W_PLL_CHANNEL_DISABLE) == 0) { + dev_info(cprman->dev, + "found enabled pll_div %s - marking it as critical\n", + data->name); + init.flags |= CLK_IS_CRITICAL; + } + clk = devm_clk_register(cprman->dev, ÷r->div.hw); if (IS_ERR(clk)) return clk;