From patchwork Fri Mar 22 15:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13600274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45F5EC47DD9 for ; Fri, 22 Mar 2024 15:59:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnhHp-0001AJ-8A; Fri, 22 Mar 2024 11:58:29 -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 1rnhHk-00017o-4z for qemu-devel@nongnu.org; Fri, 22 Mar 2024 11:58:24 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnhHi-0005cE-8P for qemu-devel@nongnu.org; Fri, 22 Mar 2024 11:58:23 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-41477e77151so10493935e9.2 for ; Fri, 22 Mar 2024 08:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711123100; x=1711727900; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2TU+ztvKvf1LMC2G6CQqJztGFsXq/Nhw2cglRUoGn74=; b=IRj4kd+GPrthWtyOnlnyX43CyFb4Te1FWMpz+4OyGJqkZnyFynoLvD/46mcWJ2E25y UXM3+3XM69RmdSLX5FyOJ+xmEFbJrt6bD4iR4KqYYp2UERTwPuwNwZXuQO5i5GULOc4M ocTeNcnLEH45R0NTTTd6CxTQEFlEDsXMEP82u6aK0Yt1MH/GZlcsl5m7YxhatXUf5rJi fU1FpqCeLSfB61gU4vuNqCX6P39HejAxA3KuUCpwhW2ztUw6KX39gIpu1xizd7YKxTlA HdIVUAAKlLdkNqfbCI9MthZ4putL6Ww3FvJiE1E047gfypzs1XiIZe9ZwojBNAhYiYaJ wYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711123100; x=1711727900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2TU+ztvKvf1LMC2G6CQqJztGFsXq/Nhw2cglRUoGn74=; b=h0YQFs3udpzbDZjpwK3sNQtUHxYV924oxXQUsRBURG0SR3NBhojG5FH2ZfU7ob9w8q Fq4GBZ8YWTxW1Qr/7QBN+OhhFWeAIern6lJCePJ16g2bR3MzfwbUpn05Gfiwsv93w+qv X0X9xPYb9NJ1/vetDifxkQEI9SvaTrq4PYTWqogkVcnOvjlE7918dkHco2UQv9RV8tjs F6ECBmopDRZOXqlVk+Rgw8RHmW2g/tktQlN/l+lwMhnKVUKBWU+T3QqnO2tRUA9Fh2b+ 0jPfvjcSNOaSFdAHyfjn8kU2pQeTpgNGBLvHah+I8wTcwmnmZ5wH2fuMyM/ZhPqdtv+t eLqg== X-Gm-Message-State: AOJu0YySUFCUHTnRt6TibqVuQ8TBd0WoFZXXgthN+5FtKF3PEFabBVIJ qMwz4B/z6OWv9xm6RVDbvxFc8G/hYRBtR2CSKpRPOmDazJ/pcv6FFrfOtZiMRfYd3GiPouhdab/ 5 X-Google-Smtp-Source: AGHT+IFBwoa0F4DIGhMdnfgG4ZL0wD0js7Yzi82TYLRbo+BUNVB6BylmcSSkRnm/710W4SQfaw+BMA== X-Received: by 2002:a05:6000:884:b0:33d:4966:fa8f with SMTP id cs4-20020a056000088400b0033d4966fa8fmr1957943wrb.46.1711123099991; Fri, 22 Mar 2024 08:58:19 -0700 (PDT) Received: from m1x-phil.lan ([176.176.178.251]) by smtp.gmail.com with ESMTPSA id v9-20020a5d43c9000000b0033ec9007bacsm2331559wrr.20.2024.03.22.08.58.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 22 Mar 2024 08:58:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Luc Michel , Damien Hedde , =?utf-8?q?In=C3=A8s_Varhol?= , Arnaud Minier , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 1/2] hw/clock: Let clock_set_mul_div() return boolean value Date: Fri, 22 Mar 2024 16:58:09 +0100 Message-ID: <20240322155810.5733-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240322155810.5733-1-philmd@linaro.org> References: <20240322155810.5733-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Let clock_set_mul_div() return a boolean value whether the clock has been updated or not, similarly to clock_set(). Signed-off-by: Philippe Mathieu-Daudé Acked-by: Luc Michel --- include/hw/clock.h | 4 +++- hw/core/clock.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/hw/clock.h b/include/hw/clock.h index bb12117f67..eb58599131 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -357,6 +357,8 @@ char *clock_display_freq(Clock *clk); * @multiplier: multiplier value * @divider: divider value * + * @return: true if the clock is changed. + * * By default, a Clock's children will all run with the same period * as their parent. This function allows you to adjust the multiplier * and divider used to derive the child clock frequency. @@ -374,6 +376,6 @@ char *clock_display_freq(Clock *clk); * Note that this function does not call clock_propagate(); the * caller should do that if necessary. */ -void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider); +bool clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider); #endif /* QEMU_HW_CLOCK_H */ diff --git a/hw/core/clock.c b/hw/core/clock.c index d82e44cd1a..a19c7db7df 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -143,14 +143,20 @@ char *clock_display_freq(Clock *clk) return freq_to_str(clock_get_hz(clk)); } -void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider) +bool clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider) { assert(divider != 0); + if (clk->multiplier == multiplier && clk->divider == divider) { + return false; + } + trace_clock_set_mul_div(CLOCK_PATH(clk), clk->multiplier, multiplier, clk->divider, divider); clk->multiplier = multiplier; clk->divider = divider; + + return true; } static void clock_initfn(Object *obj) From patchwork Fri Mar 22 15:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13600276 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C7E1C54E71 for ; Fri, 22 Mar 2024 15:59:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnhHt-0001Cj-GC; Fri, 22 Mar 2024 11:58:33 -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 1rnhHq-0001Av-TH for qemu-devel@nongnu.org; Fri, 22 Mar 2024 11:58:31 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnhHo-0005eQ-E4 for qemu-devel@nongnu.org; Fri, 22 Mar 2024 11:58:30 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d228a132acso31043861fa.0 for ; Fri, 22 Mar 2024 08:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711123106; x=1711727906; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UxjY8qQEnjtbAhkgYiOeCHJsc+3HFQ5wgndLMK/z5QQ=; b=R8r5hRY6gwbZVFB1TBsELt667RJ6iOqB98kN5CMLlnMD5ufnNEOZArHovNoWw7R63I wO9L/NLD0TNQSiE/lGgYYwH8D5IXPMyu3wT8yhPj0Qffl96HmY5E3rMo97+wmY+8oyqS RCInRUQNNJoUuBxyfmkRL503TD1fcSoTVmjwRrZmheak9oq84i2nJzGFbjPtOSeCdgIi +VeThnHK/yL8Mui08oaJui16LH1ROUnxT8NRnXEsaaC3pQJ9ftZUKbv33wHQnYJTaS0U wSkjynO3Vk2z2MujaDaaWP3M8NeAtNCEAtlyk6/I4itHa4fuSv4R5Rb+5TecmGKoU1Xm aIHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711123106; x=1711727906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UxjY8qQEnjtbAhkgYiOeCHJsc+3HFQ5wgndLMK/z5QQ=; b=Vp2BoLZM6gzbFXRJKd1piwyh2NkSsRECoEqN7IyZWzeUeXG4PnDHRNlsWIUMT4kE/v q4en2dvuCmgarkcBPEbP1k+NEZpI3lQMTgJXbIfbzED6fZyJr354gNo+OK1iGp8E3bSe 0W9sc7I6BWDHpzE/D1+HPet2rbWdvjDxJTi9DqKaz9a5Axmv7VpW9vyjaLX1YmQLHUxN KSklVWTimC+M/66JY+6aJxzVDvmaagwWC0wA7jWQUpHlnZFQqr963nGs14XXGHJvukEO X6LFpjT38XuG297VTJgWQK/mw5kFeSw79KyxG5GIuRy7XTdjXOCR4cpd+1YmxdNhEfQR OH2Q== X-Gm-Message-State: AOJu0YyrIU/RGfaVLzvNwUA7NnI9BfarlEjoQeGAeBZLY7UfdiWml0ny CHbkXOkSIhdaiX8wHmKAHZ+EYMUn0jMKd+0TGFcDNp0omjf2fLlB7NpYilp9iXmAITmml+kPDFu G X-Google-Smtp-Source: AGHT+IHXhS4889qWr4Ii6oVGUkJJ0++U/LkjLyALa8fhLMG3pbP0sG9Iip0qsRNrN5JEjBH4KFdiNg== X-Received: by 2002:a2e:8ed1:0:b0:2d4:74c5:2cd3 with SMTP id e17-20020a2e8ed1000000b002d474c52cd3mr2166352ljl.41.1711123106159; Fri, 22 Mar 2024 08:58:26 -0700 (PDT) Received: from m1x-phil.lan ([176.176.178.251]) by smtp.gmail.com with ESMTPSA id h11-20020a05600c350b00b0041477e76ec6sm3486777wmq.2.2024.03.22.08.58.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 22 Mar 2024 08:58:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Luc Michel , Damien Hedde , =?utf-8?q?In=C3=A8s_Varhol?= , Arnaud Minier , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 2/2] hw/misc/stm32l4x5_rcc: Propagate period when enabling a clock Date: Fri, 22 Mar 2024 16:58:10 +0100 Message-ID: <20240322155810.5733-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240322155810.5733-1-philmd@linaro.org> References: <20240322155810.5733-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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)); src_freq = clock_get_hz(current_source);