Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755011AbbG3KmP (ORCPT ); Thu, 30 Jul 2015 06:42:15 -0400 Received: from eusmtp01.atmel.com ([212.144.249.242]:4629 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753418AbbG3KmO (ORCPT ); Thu, 30 Jul 2015 06:42:14 -0400 Message-ID: <55B9FF43.2070101@atmel.com> Date: Thu, 30 Jul 2015 12:41:07 +0200 From: Nicolas Ferre Organization: atmel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Boris Brezillon CC: , , , , Alexandre Belloni , Ludovic Desroches , Josh Wu , Subject: Re: [PATCH v4] clk: at91: add generated clock driver References: <1438099685-5592-1-git-send-email-nicolas.ferre@atmel.com> <20150729091531.2f167170@bbrezillon> In-Reply-To: <20150729091531.2f167170@bbrezillon> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.161.30.18] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2235 Lines: 64 Le 29/07/2015 09:15, Boris Brezillon a ?crit : > Hi Nicolas, > > On Tue, 28 Jul 2015 18:08:05 +0200 > Nicolas Ferre wrote: > > >> +static void clk_generated_startup(struct clk_generated *gck) >> +{ >> + struct at91_pmc *pmc = gck->pmc; >> + u32 tmp; >> + >> + pmc_lock(pmc); >> + pmc_write(pmc, AT91_PMC_PCR, (gck->id & AT91_PMC_PCR_PID_MASK)); >> + tmp = pmc_read(pmc, AT91_PMC_PCR); >> + pmc_unlock(pmc); >> + >> + gck->parent_id = (tmp & AT91_PMC_PCR_GCKCSS_MASK) >> + >> AT91_PMC_PCR_GCKCSS_OFFSET; >> + /* >> + * make sure that what we read in hardware is coherent with >> + * what we've just probed >> + */ >> + if (gck->parent_id >= __clk_get_num_parents(gck->hw.clk)) >> + gck->parent_id = 0; > > Hm, I'm not sure this is correct. Here, you're just faking the > fact that your current parent is the first one in the parent list while > it actually points to the 6th entry. Not only your rate will be false > (the one calculated in ->round_rate()), but you're also changing the > behavior of the clk_set_rate() and clk_set_parent() operation (AFAIR, > if you try to change to the first parent, the core code will think it's > already properly configured and will never call ->set_parent()). Well, as the values are actually used from the cached local structure all the way to the "enable" function, I suspect it won't break the core behavior. And making sure that this clock is not enabled before Linux is run makes this change work. But I admit it is somehow weird, as a workaround :-\ > This leaves 2 solutions here: > - implement the missing clk driver and add an entry in the parent > list Yes, I'll do this. > - select the 1st parent clk (I mean, change the register value) if the > hardware points to the 6th one. This is not safer than what I proposed hereunder. So, I remove this change in the v4 and send you a v5 that reverts this modification and adds a WARN_ON the condition, to ease debugging... Bye, -- Nicolas Ferre -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/