From patchwork Mon Mar 25 15:28:24 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: 782344 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1235638wrt; Mon, 25 Mar 2024 08:29:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5pBWpsMPI0i6WjH4AnDb5zJs1iYqM5XLxpRMeVvzUpdLmIwlUG4bNV18ifYzvvNNMMpn9xcQ/YGRDXPQ04Fsj X-Google-Smtp-Source: AGHT+IHb1CSBFVT7eHQ5YMJykuCd5AJdLtpWlD6XpVrdmWa1OmlPwoj/5g3kuT5hR1SYuMYUgh5j X-Received: by 2002:a05:6808:1306:b0:3c3:8517:3472 with SMTP id y6-20020a056808130600b003c385173472mr9321551oiv.41.1711380592249; Mon, 25 Mar 2024 08:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711380592; cv=none; d=google.com; s=arc-20160816; b=OVonWjKcsg+58kkN4SsRjbexJ84dSlSDhkN5QcZz5UwihaBCRdXUNEI8kTr9FU9e6T 810rZag8YG8i795FZ1DJxXGiv0Z5v1X7NbM9T5TwCX7zTYywQvdES3S4+0orEWvj2QMD 539t0HjKxz3QHHftYw4I09mEA+cw35WrTtwPNMhDEWnkeoK0CC6M7qD6IkCmqH7b82+7 WVJO7t8Ycf8XByqcdkSIo1RbbgjYtU+qEep+3a/7M2pgbv73EZ1WkK1xqso5Dpti9bUt 36RxjTphLEbOFyAUgkuNei0CGcZYmprBl2vPANETEYSkspARKgfgfB5AmCJqvcCrn5Tg +fOA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XGixc8/beFlJTVTR97uUt5Nz0tk7RL3jZppYJHNPExI=; fh=Vnpc6sAZ683hqmTcdvG596lAL6GFS9SeeG7OE8u/W1Q=; b=oDSaIyEnbgsNSZnjrYclvn1mQGNyP7ima0O2HaJOz9O1FXqh/+Vgaa7+abet/qnppb WeWjIWzEzxz+qY/gihKY5aw0E0zwc2naBKRsu6g5fR4ddsjq9setT+CUfXP637ttYi1U hW7iVFY5yYMwTPnvjVwWQOfBmnYUQ50fhjRIJYdSVRV1tfXHp6x4antCeVDklDnPhIjF iZlsDWpD+JJ7bFPrAhvGAPY019BAepBm52Vja4xK2M+YIywQifhSW/1NRwZVhxO/1Qtc WX6Y1Q1aOr17ffvPT5R3lqx3DVonIS3ziW1WdOi9e7HvzAu8uml11O+ja5Ceg0QzyqoI iw6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zUO5lcGH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s18-20020ac85cd2000000b00431166b9fb1si5555837qta.88.2024.03.25.08.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 08:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=@linaro.org header.s=google header.b=zUO5lcGH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1romFc-0002jc-IE; Mon, 25 Mar 2024 11:28:40 -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 1romFb-0002j0-3y for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:39 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1romFZ-0000Eu-Jx for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:38 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33ec7e38b84so3217101f8f.1 for ; Mon, 25 Mar 2024 08:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711380515; x=1711985315; 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=XGixc8/beFlJTVTR97uUt5Nz0tk7RL3jZppYJHNPExI=; b=zUO5lcGH+H3miZ8LyQYp7HMTlvl8rHp7dhA2m+VJQ8b94V+Tx8h3L7CTecgVGSgycO kOUUwLwMIjJSRY2BX7uOB4Vh1SgbeB+gN6LM2k0adBB+sNQ/Ih0Gz7Ul+G/eQW5nSLjU 1Yujyp0UrA5TpOc1dpajKHuXsARD58aPE0hJLULpZY8MWAqLp9i7N8UWQ/ve7p5PGTut w6s5YxZ6rkN5V8R7bH9GK074wVZWLbpIOcLyEHgNlKlWcXAMajKp/xlsQO4Y/neT9Zp0 Lgtmh5zebll45NwsGxFmRhPEp0GCb3z/xYR4YV1pFgwV5hjlnW/30CzJkhpfyHEKzzxN dVPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380515; x=1711985315; 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=XGixc8/beFlJTVTR97uUt5Nz0tk7RL3jZppYJHNPExI=; b=fP6SpaMsCD6YNJMwp8HeugZPQJ22lWMAfUHUotJ8ByJ2HkCuGGl2Ji7vA0U07ZlqtQ DF5W+6kj0WfFY65NImMAfKQ0hPzDlJSaNIk61t2wJQGrRhyVJk5WEtVqfHew6QgCGtsf pwtpLM5Xlkpx5xJ6+riWayGiAhFCjSrcZRzoXBS+hCokIKW2qGP0Pzu7NHZtWh/YM9hl hqaX8aBplPo9Sbl51Q3APDwket1CnWnqXiB+QgprKJp9ix5XjXUgizlrfkOLF6mmFaWI 6JSC0xdLKcqgTdBN4V4f5sLDn56WcBI2g1MlSd/ihoxHvGOXLHYdxsy6dmTgN3xh7snN X5wg== X-Gm-Message-State: AOJu0YwwAmIMQCtwFl/xW/lopleCCzz06eMS6wdqxqwHK/qCgFp5zvJu 0XyUwjNFOf+RW4AbnDihRnQfJaDDadc7n7SSlDbpe3bJ5w+KbvZnQ7gVNfQk8jFOZAO09NBEDa7 3Gig= X-Received: by 2002:a5d:52c6:0:b0:33e:b1e7:742a with SMTP id r6-20020a5d52c6000000b0033eb1e7742amr3826539wrv.10.1711380515517; Mon, 25 Mar 2024 08:28:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.208.214]) by smtp.gmail.com with ESMTPSA id df10-20020a5d5b8a000000b0033e756ed840sm9759377wrb.47.2024.03.25.08.28.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 25 Mar 2024 08:28:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?In=C3=A8s_Varhol?= , Alistair Francis , qemu-arm@nongnu.org, Arnaud Minier , Damien Hedde , Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v3 1/3] hw/clock: Let clock_set_mul_div() return a boolean value Date: Mon, 25 Mar 2024 16:28:24 +0100 Message-ID: <20240325152827.73817-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240325152827.73817-1-philmd@linaro.org> References: <20240325152827.73817-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Let clock_set_mul_div() return a boolean value whether the clock has been updated or not, similarly to clock_set(). Return early when clock_set_mul_div() is called with same mul/div values the clock has. Acked-by: Luc Michel Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- docs/devel/clocks.rst | 4 ++++ include/hw/clock.h | 4 +++- hw/core/clock.c | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst index c4d14bde04..b2d1148cdb 100644 --- a/docs/devel/clocks.rst +++ b/docs/devel/clocks.rst @@ -279,6 +279,10 @@ You can change the multiplier and divider of a clock at runtime, so you can use this to model clock controller devices which have guest-programmable frequency multipliers or dividers. +Similary to ``clock_set()``, ``clock_set_mul_div()`` returns ``true`` if +the clock state was modified; that is, if the multiplier or the diviser +or both were changed by the call. + Note that ``clock_set_mul_div()`` does not automatically call ``clock_propagate()``. If you make a runtime change to the multiplier or divider you must call clock_propagate() yourself. 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 Mon Mar 25 15:28:25 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: 782341 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1235367wrt; Mon, 25 Mar 2024 08:29:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFecEZhFxK4iNOLZ4EkM7txT9FyAIeJU6k8kvjoeCn9lPG1OEu8SxJTqXL1yzVyBobL40666Nn+vlrEVucEj6x X-Google-Smtp-Source: AGHT+IHjW+D0WjkN1yPXYOB+Tzc3h2pq641GCReAvk4jKbgULILfeSwrd0I4VzE1v+7RwJMcr8UZ X-Received: by 2002:a05:6830:22cc:b0:6e6:8c6d:68a5 with SMTP id q12-20020a05683022cc00b006e68c6d68a5mr8941778otc.21.1711380558238; Mon, 25 Mar 2024 08:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711380558; cv=none; d=google.com; s=arc-20160816; b=W/v1nnTY/vqTlUgZ06REqiTKApWpOnl+kv8Jskeqw6OajDXtN3ijrbvw3UiUsstLii 9j0nYPAFeblVuk+7U0hKsHu2uwyNwpuwGJZT4fNeJ9JoA8FfZ7DmhQ6tzl33gDija4AR XdJzLoxc8WHoQ8WZ4KDnfyFezilDFUKt3xTMg/EzfCmPS2XoF5LSyc0m7niP3BcWX9gJ Wbv85ukSOY4I7NZXLBtw8FOR/g97FDZJLcU/HjJqD1NQwT4hDF4iI6ukqEyce7UtUIBY wARoLEXsCM7GwloL/4i3400Lw6PucHsetvZxBV4FJeUmOYHz2DQ7OaRaDQ1SxpadUJqk qMAg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8n9QPEOuM1pBugupKeEtDOMCt4itsUe/QSxWC8eJVGs=; fh=Vnpc6sAZ683hqmTcdvG596lAL6GFS9SeeG7OE8u/W1Q=; b=k8ubl1oDCdRABSfZqy4eqBJL2X7aAEqIVKZSC/ZchOBWo/YKhf7XPfNpmZDRH9nmYY tIz/S5TGcT0pTR/MGpvcK0JCbMwFHamElMqgoIxN81D/jKHP8CG3pJjmqLrIpQVvJb32 iA1bVUxYFa1G+tAV7/H6QCND6NnS16sWcC1exhCCnvP9iSwXFzNAsSSxU17WVqaWG91D MzOhnMmSbvZLFGAr2dKUH+Sgr5oMq9ZdvqvfFeIovQJXXgiG/3oJn8lOO+tzR9u/Fry/ TvmDhuW5NawIsqIRHV3R0VGYdQ7krSPQfG95R54os0/Qk5tFE1sWjlpckrhjKcgL9Jrc w67Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q09GVRf8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gd14-20020a05622a5c0e00b004311ea48155si5943401qtb.389.2024.03.25.08.29.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 08:29:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=@linaro.org header.s=google header.b=q09GVRf8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1romFj-0002kd-4t; Mon, 25 Mar 2024 11:28:47 -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 1romFh-0002jz-5w for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:45 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1romFf-0000FN-Jf for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:44 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4148c2a3a3fso2442715e9.3 for ; Mon, 25 Mar 2024 08:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711380521; x=1711985321; 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=8n9QPEOuM1pBugupKeEtDOMCt4itsUe/QSxWC8eJVGs=; b=q09GVRf8AwVxR5MS0TPchAdJaDRMzVURCtc9cuYVI+V+V1Hg1z7+d47Ux37CrcjbLo Ow9pNs+gf/pL9cwyaueMJzKdXtT45PRMLM45Rh+cpqR4VEffLaP2f4c6J6w4uikfNezX LwlRzbqaXfOHV9YNHmqpjNFVdRqEUrD0+V56rCNhqFW4dV5kK41Q/64JdZe2RGs9GPQ2 nbN/vIjhFBxPYR+ROB7Q4w/H5T2ki0GJbrVf6528KhZY+WC0NjbRAaKjnVW1SkHBV5SC NtQvMUSb10uqj8dMgmYfvpza5eY022zTiahARWLeRHlSmtAbb4eQKtZGeEqo8gRCqh+I fGqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380521; x=1711985321; 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=8n9QPEOuM1pBugupKeEtDOMCt4itsUe/QSxWC8eJVGs=; b=oOg9xlK8Y6DrAWGvDVfJAJ72qtB8jnPGr/YJTUrd231o4Zikq+p0KbusPi8qBBhuNs izYCFgyGGBb1XpolDBSKw86I6TRWrcnP3Y18NYoHYLPRw5d8/ikD5CQp9O1qcSDS9tDw oi2bq0HHJW+7RuZqI3eyn0yRLnGHZqslDdapuGk07lHgt4QnAE613ik8r1pn+VWhPWDI 0B8b1R81Ga/sX4dWq1cTzCAjvLzy+q/iNvKhvUIdd0jh4Pe5+QmdgJQGNturT4wn5ddZ EFJQQzTePy7QlyhwoZ4aJsxI76dyBEiaR8D0rDtQe2KMYQVIARwTWYbKJ5ks/tVnyGSn nnoA== X-Gm-Message-State: AOJu0YyPYS1/djUawDTjG2NP5qBA1AswTzs26ov+K//5atp/UboC1ZHs WH48TRUsD3uEEW6BZpPuyw24YieaXWnIqzcX09eucwVhROfHK+aQlxv2jOYJO5el/vVl3/dkGKg W+RU= X-Received: by 2002:a05:600c:1395:b0:413:133c:b9c8 with SMTP id u21-20020a05600c139500b00413133cb9c8mr5519116wmf.33.1711380521437; Mon, 25 Mar 2024 08:28:41 -0700 (PDT) Received: from m1x-phil.lan ([176.187.208.214]) by smtp.gmail.com with ESMTPSA id fc19-20020a05600c525300b0041401eb021asm8763725wmb.24.2024.03.25.08.28.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 25 Mar 2024 08:28:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?In=C3=A8s_Varhol?= , Alistair Francis , qemu-arm@nongnu.org, Arnaud Minier , Damien Hedde , Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v3 2/3] hw/misc/stm32l4x5_rcc: Inline clock_update() in clock_mux_update() Date: Mon, 25 Mar 2024 16:28:25 +0100 Message-ID: <20240325152827.73817-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240325152827.73817-1-philmd@linaro.org> References: <20240325152827.73817-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Trivial inlining in preliminary patch to make the next one easier to review. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- hw/misc/stm32l4x5_rcc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c index bc2d63528b..49b90afdf0 100644 --- a/hw/misc/stm32l4x5_rcc.c +++ b/hw/misc/stm32l4x5_rcc.c @@ -48,6 +48,8 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source) uint64_t src_freq; Clock *current_source = mux->srcs[mux->src]; uint32_t freq_multiplier = 0; + bool clk_changed = false; + /* * To avoid rounding errors, we use the clock period instead of the * frequency. @@ -60,7 +62,10 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source) } clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier); - clock_update(mux->out, clock_get(current_source)); + clk_changed |= clock_set(mux->out, clock_get(current_source)); + if (clk_changed) { + clock_propagate(mux->out); + } src_freq = clock_get_hz(current_source); /* TODO: can we simply detect if the config changed so that we reduce log spam ? */ From patchwork Mon Mar 25 15:28:26 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: 782342 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1235542wrt; Mon, 25 Mar 2024 08:29:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLklK/YXSe282qo8MK/Ppj4rieL3fMtKdkYkx1F0pyz58FFcS7a8P0djuOV3HSFzk25Tn0UOG2XZCdSwTeZujt X-Google-Smtp-Source: AGHT+IF/1J05du6mu0AiRQ+LuEv1mTdw/sXNBW3cynKmt7qddU2nlqXe11tFZgStdztlHnOY+xnp X-Received: by 2002:a25:b41a:0:b0:dc7:4639:55d1 with SMTP id n26-20020a25b41a000000b00dc7463955d1mr5102943ybj.18.1711380576318; Mon, 25 Mar 2024 08:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711380576; cv=none; d=google.com; s=arc-20160816; b=gagubSYygvhcfE8VlzVumGy2yxDk5Y8ywVV2FsKSvrZhN/Wtizpp5s+qFd+Iaz7CDI C411dVQUiPA9GEjzZ7b4BtQ32b2wTExXbyVIyxN3X19uwZ5zmkAgP/7guhamKmcbhm6s 8zUXsTlauTPV6/U5RwODWB7edwsCOVRBwWUKEsFKgqMeBGI/x3FDgt75QTK1k/Mo2kBI buzV3Yws8koTLS9T+T/LhODuvPapCs//z4LantZYgK8AocUnHjzKrqQ+SFFIYgf8Qt7t UHkgaXM/RqVvEXJaJrrNxSqWjGLLeQJswvB+Vb2il4hY3CTPxRumaYAbQIgAUbQlJaBW uz9g== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=egg5Mtyn99cCwmy/P18xKwdXOjmaICInZ6LaE2Awphc=; fh=Vnpc6sAZ683hqmTcdvG596lAL6GFS9SeeG7OE8u/W1Q=; b=hI364WnKArwQv0oYjJrFOyZzK8x5rIpg0ZPVdHxzxCceL5Mcwun0MFEax/KFw6z1S5 D8uPhpitZX62TuV8bRM5Q8bJH9p+1T1cH0i4tH5DEjH69JgoaYW3/08ldIm0NnNhND9H MZ8GElFn0F5ZMrmYq13ff5/ptnD/Ygu1uXdrplF0zEv18YpLkHOnzm90jnsLWMNkLNho lVZGffCKut0t1Iekv9R44usdrbvnV0p+GRzZpJa/3uVTKqBTy7LVvWRuvBCcloc9rCh+ MeKSu1CfnprNOmxHaFt5PQ9ozAhOfq6YIxGKsh+EnjCvsSvRuDFKWlmFeHG1UBkb530j 1+uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QAoft+Zp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q2-20020a05621419e200b0069675b1262esi5917875qvc.17.2024.03.25.08.29.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 08:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=@linaro.org header.s=google header.b=QAoft+Zp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1romFo-0002lp-NU; Mon, 25 Mar 2024 11:28:52 -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 1romFn-0002lD-6K for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:51 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1romFl-0000Fr-Pb for qemu-devel@nongnu.org; Mon, 25 Mar 2024 11:28:50 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-414859830f2so10021835e9.0 for ; Mon, 25 Mar 2024 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711380527; x=1711985327; 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=egg5Mtyn99cCwmy/P18xKwdXOjmaICInZ6LaE2Awphc=; b=QAoft+ZpjFuEqdkyjeyCnyG/tB7/55Q5ZnGyqVwppwa2xdKm+ZDMzSxhIXs8t0o4SB yUmzcikKumFABwufuHZO/6db4qZNk7pD3rPHt0BA2AVDn+rqTewJ7Fh0dj3AQC488KhB aapV0dojbhBoXFZ6n9Y5GvlwR6SflnOmSOa5IF7iTsn6yk8704K9QwjrS3fTEQKXl1nm xrn/cBfMV7JALe7RtABz+s8ewZbLHVKd/5Evpk7gp72vxa8B61kqZJodjDX6U1d8iIZV eWSicqIk+1DJxVtzkMw5PGlqbz0BrspjgsRfdxm2sK+TCKaU9CD0UdGrED3Oo3WZA3Ow 00Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380527; x=1711985327; 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=egg5Mtyn99cCwmy/P18xKwdXOjmaICInZ6LaE2Awphc=; b=tLwqkSfKBv5Jbfq0Z7Hhe3B/xcocxiQ/xDQe1vNE4Ke/Ze2z5cFEJPRk4SMvF0Xn/V inTg5HvFkazUGkRzt2qR/WtVu32jAgpihr1L3+Fj433tx3psON+8Yw8Kc1LfcHnw5iAt eLtOks39QZZetio/cTO9E/nrMdPGtNC2TYNah/Hx4McMW5E1nX/kzoRtiPuc+NzibPZx pB8hxWSkEqSMlvy+WbAqErOQLVEDJqpQo1eFulCfs+X5Rh7ub8x4oCSsxYnLNHhuA4Vg XgH+COiPvh0blZZ1vU+WB/pElRAJ6DqwVDNtP6LA9UtYkajLAQJqJBl2mkTxNbUSCN3/ Fe8w== X-Gm-Message-State: AOJu0YzuP5XtvSzh8i7WTWugGuBJXJkga7POOWvXZauXtQ8vTW0Po4R+ ijV1Kxq2s8wKxxBEZkuN/AfDi5EkBqY7uZGmAtfjPhcAOjB2CphcT0I5GxULztD4Y43owIVcsFw ozi8= X-Received: by 2002:a05:600c:4f01:b0:414:8948:621c with SMTP id l1-20020a05600c4f0100b004148948621cmr2566601wmq.8.1711380527317; Mon, 25 Mar 2024 08:28:47 -0700 (PDT) Received: from m1x-phil.lan ([176.187.208.214]) by smtp.gmail.com with ESMTPSA id j28-20020a05600c1c1c00b004146c769c79sm8799861wms.0.2024.03.25.08.28.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 25 Mar 2024 08:28:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?In=C3=A8s_Varhol?= , Alistair Francis , qemu-arm@nongnu.org, Arnaud Minier , Damien Hedde , Peter Maydell , Luc Michel , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v3 3/3] hw/misc/stm32l4x5_rcc: Propagate period when enabling a clock Date: Mon, 25 Mar 2024 16:28:26 +0100 Message-ID: <20240325152827.73817-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240325152827.73817-1-philmd@linaro.org> References: <20240325152827.73817-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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é Reviewed-by: Alistair Francis --- hw/misc/stm32l4x5_rcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c index 49b90afdf0..ed2dbd9dc3 100644 --- a/hw/misc/stm32l4x5_rcc.c +++ b/hw/misc/stm32l4x5_rcc.c @@ -61,7 +61,7 @@ static void clock_mux_update(RccClockMuxState *mux, bool bypass_source) freq_multiplier = mux->divider; } - clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier); + clk_changed |= clock_set_mul_div(mux->out, freq_multiplier, mux->multiplier); clk_changed |= clock_set(mux->out, clock_get(current_source)); if (clk_changed) { clock_propagate(mux->out);