Received: by 2002:a17:906:f85:b0:a47:c39e:cbe with SMTP id q5csp565344ejj; Mon, 25 Mar 2024 01:57:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWz/ZCItQYcDJoZokF5A4F1zeS7v6hvwYXIkdmz4RRqD1OMGo5CiarEaigD1NfMmQZv6HSaaCbAmU67kw1Ylu9Uuui3Jgwo X-Google-Smtp-Source: AGHT+IFI9MqyuTqOV5ZpEtMUkPV0lInO8GMLLkBntkcanoh8rrUPky5mML88CZsOjLKXeSEYkLSo X-Received: by 2002:a05:620a:5a43:b0:78a:5c8f:cfe1 with SMTP id wx3-20020a05620a5a4300b0078a5c8fcfe1mr400497qkn.50.1711357021245; Mon, 25 Mar 2024 01:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711357021; cv=none; d=google.com; s=arc-20160816; b=RKW+FMuPx1xBaYnEBl4k9+/9ngeEwzH8HGtnB9PkpN5dyStQviQ9QThhvoDwb1lFj0 +BS3K6VOeYZPVaDjWfSCcxgdDeQefP4kiBDRMO4l+bEPO+HgExt/mRdrJNIjpsW4U6ad r8nySiy7EETxpGo7u1y5yeIAXBlAirdaUjifnyUrqzLq2VqIS2pgWD9YqcRTORGOedRU 5+0oNzCrUdAwMHMDqUE8AajW0b3nBREdL2rkfupl0MAhvt4eKxo/CVwR5A0cxmwiSfJg Ds3lR2OI6ySJg9RV0EEX/Rkw7cN4/FEd2jfisF6R7+bbkQetNEtt5e/8vNxiersuCCN8 stLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tPHKlcMjIAG9i8s53/hAPdDcGiPubMh2yTJuSv7Vaqc=; fh=gYaU5B7DUzD2XWl4jAUZyCZJ3a/tOgViNRdwGsU5HFs=; b=eEpEPwfNMxLXsKY77pZdFDoNKUqhd2japiVxoM6F9AC6aclcvkLDbcTr+gcJrnfGou kd2IR/j02yGjUotUB2oW/QhAIvBba6Eo9zP334z8fTzLw3AFjoKOOWr0lsSUcemlHAcb DUu2q5grXtkQ1UdTAuA3N2zh2zuLbag03XmCr6mm+26MYjOzthD0tzutgMIu4ShAPVME ZO2vAmCndzVAh9EhpHrCNJCjLMqtnnWRvVVc4fPofHRUGCyYjyeIwf0c6jWJ7TM3DYo+ 4TSmev1maT85Ga56fHR2Y83yq9cmiheyCZGdUW+K66BoMJocUom4Jvr5ds5pb7nd9vta z2RQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lmichel.fr header.s=pharaoh header.b=EMvhUfwc; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lmichel.fr Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c7-20020a05620a200700b0078a5c8821a8si269508qka.688.2024.03.25.01.57.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 01:57:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@lmichel.fr header.s=pharaoh header.b=EMvhUfwc; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lmichel.fr Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rog8M-0002r3-FX; Mon, 25 Mar 2024 04:56:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rog8K-0002qB-P2; Mon, 25 Mar 2024 04:56:44 -0400 Received: from pharaoh.lmichel.fr ([149.202.28.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rog8I-0008UY-Hk; Mon, 25 Mar 2024 04:56:44 -0400 Received: from localhost (sekoia-laptop.home.lmichel.fr [192.168.61.102]) by pharaoh.lmichel.fr (Postfix) with ESMTPSA id 0DAF0C60172; Mon, 25 Mar 2024 09:56:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lmichel.fr; s=pharaoh; t=1711357000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tPHKlcMjIAG9i8s53/hAPdDcGiPubMh2yTJuSv7Vaqc=; b=EMvhUfwc6vwqaCreCJma+9Ft+o6b+wO21TgsgXe5neYOYRLbSoFFAjg2ylfvudUNipo2QY byeP0a/bbF1nTlEGLn8QsnxtiSknkxnSVx76yfH6pca1X5KK2C9ZGeVRd1w84ui0ic6hSp NGAsT/OOK2DlyDgNwn5+qJvHqDYy52NgOIk/o5W+0omOrpewu5pNCEeOvHrsCzzgBvHX93 phti3gwMOocK1gVhaMhWAjnOB3GcGSA4iaAOu7nMJgsvMSHXxyzjHMxn+ob14TLOyTySvf O0NOtAMT5sEf92mJW6YLr9pqFXiX0tV+iBz9uXHFEJvatHj7wK+TbPcQIC3Skw== Date: Mon, 25 Mar 2024 09:56:39 +0100 From: Luc Michel To: Peter Maydell Cc: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Luc Michel , Damien Hedde , =?utf-8?B?SW7DqHM=?= Varhol , Arnaud Minier , qemu-arm@nongnu.org Subject: Re: [PATCH-for-9.0 2/2] hw/misc/stm32l4x5_rcc: Propagate period when enabling a clock Message-ID: References: <20240322155810.5733-1-philmd@linaro.org> <20240322155810.5733-3-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Received-SPF: pass client-ip=149.202.28.74; envelope-from=luc@lmichel.fr; helo=pharaoh.lmichel.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: OsTru3DifOOq On 16:39 Fri 22 Mar , Peter Maydell wrote: > On Fri, 22 Mar 2024 at 15:59, Philippe Mathieu-Daudé wrote: > > > > From: Arnaud Minier > > > > The "clock_set_mul_div" function doesn't propagate the clock period > > to the children if it is changed (e.g. by enabling/disabling a clock > > multiplexer). > > This was overlooked during the implementation due to late changes. > > > > This commit propagates the change if the multiplier or divider changes. > > > > Fixes: ec7d83acbd ("hw/misc/stm32l4x5_rcc: Add an internal clock multiplexer object") > > Signed-off-by: Arnaud Minier > > Signed-off-by: Inès Varhol > > Message-ID: <20240317103918.44375-2-arnaud.minier@telecom-paris.fr> > > [PMD: Check clock_set_mul_div() return value] > > Signed-off-by: Philippe Mathieu-Daudé > > --- > > hw/misc/stm32l4x5_rcc.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c > > index bc2d63528b..7ad628b296 100644 > > --- a/hw/misc/stm32l4x5_rcc.c > > +++ b/hw/misc/stm32l4x5_rcc.c > > @@ -59,7 +59,10 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source) > > freq_multiplier = mux->divider; > > } > > > > - clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier); > > + if (clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier)) { > > + clock_propagate(mux->out); > > + } > > + > > clock_update(mux->out, clock_get(current_source)); > > clock_update() also calls clock_propagate(), so this doesn't > seem entirely right: shouldn't we figure out whether we need to > do a clock_propagate() and do it once? (Maybe what seems odd to me > is that clock_set() does clock_propagate() for you but > clock_set_mul_div() does not...) clock_set() does not call clock_propagate(). clock_update() is a clock_set() followed by a clock_propagate() if the period changed. I think this is where the problem comes from here. clock_update() call won't call clock_propagate() if the clock period does not change. I think you'll want something like: bool changed; changed = clock_set_mul_div(mux->out, freq_multiplier, mux->multiplexer); changed ||= clock_set(clock_get(current_source)); if (changed) { clock_propagate(mux->out); } Thanks, -- Luc > > (Also I think we should have the information we need now to be able > to do the "reduce log spam" in the comment -- if neither > clock_set_mul_div() nor clock_update() needed to do anything > then we didn't actually change the config.) > > -- PMM --