From patchwork Fri Apr 9 06:23:53 2021 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: 1464182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=KuSpfrH9; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGp6M5mhNz9sVt for ; Fri, 9 Apr 2021 16:25:46 +1000 (AEST) Received: from localhost ([::1]:55864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkaN-0004UX-MC for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:25:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZ0-0004QI-8n; Fri, 09 Apr 2021 02:24:18 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:41493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkYs-0001Oq-Rn; Fri, 09 Apr 2021 02:24:16 -0400 Received: by mail-ej1-x633.google.com with SMTP id g17so4075689ejp.8; Thu, 08 Apr 2021 23:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+QFZRjfiDBXxrw9xt50MWOZpl0I5gXE/SA7o167QDWg=; b=KuSpfrH94JzrHSUNpQx8QtXxszv230tbET93dTvso5XdxyyYyDCLZpwDdOA+fnmTow qnEuYIJRi6Llc3zkVn18tdWA44/eXFdHs/gtZIaZ/p4GmV7FUbtSDA0c71iZCpqMDnj8 vg1SZ3DSmfEwBLHktCW95CMBQldQZ1gK6j2P6XlCG0IRY6dDrLyRNCMQmF6M40hWeApz VGfpvy/Vs71w7AdtRLzSbm+BzYUdriVkvVflOdQjiSbJyR6sLb3tFUYGMiHPttcNtmiG sNgTVsgj1aMRU0BsEx6rghWf1JoKiAZOF1cG2pOSE3ncFzVVSLkhnCb376AZovGj/DXo 0vFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+QFZRjfiDBXxrw9xt50MWOZpl0I5gXE/SA7o167QDWg=; b=UOHFal/yUztkOdraeuPy1sb062wcuKPDmsvw6lDt4ZqjEbWltxcqyJZwIRLVveCJUc ohaCzFXV/Q7oh1sqKfuWFZtzR+lqx16vNaIPw4e1CNn40o2rUie/KJXEe64TWXCow2xG 5BCdhGwLzt4fILxxAHiVXW5gVgaWRfmII2dbr8JEvXdJJBmnrdR/SxV8V4g+ntVq+E2G 8w+fr7LaN158EKmN8RbeF3vDhIWojrjf4mAK03VAyhcdBifeXlrehu/GTeNcmrzDfuWm tHpYsm2KAprGZ9kx+NuxvWnM+qmAaLg9qq6I0gc61ekDa0bPlwZgGsCgdjWanGI7MfNK Y4zQ== X-Gm-Message-State: AOAM531Jk5tVIdrDxVB4Eke2WCDQ6qQvtriNaoEOKvrGDJEb8wuJ4x0Y PAOvnpsf46ygdxKmOGRpvSkrZJB9CbgpgQ== X-Google-Smtp-Source: ABdhPJzoLV+Oosakh2S6h+GLl7oCSkXiwvb3bJBI7O38WoHm3OyQT1CFj8S7kpuE6HA6ENaSFIQvyg== X-Received: by 2002:a17:907:984a:: with SMTP id jj10mr14474275ejc.180.1617949448673; Thu, 08 Apr 2021 23:24:08 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id y2sm721771ejf.30.2021.04.08.23.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 1/9] hw/core/clock: Increase clock propagation trace events verbosity Date: Fri, 9 Apr 2021 08:23:53 +0200 Message-Id: <20210409062401.2350436-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Move the 'clock_propagate' trace event to clock_propagate_period() to display the recursive propagation, and add 'propagate_children' event to closely look at the clock propagation for each children in the clock tree. Signed-off-by: Philippe Mathieu-Daudé --- hw/core/clock.c | 8 +++++++- hw/core/trace-events | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/core/clock.c b/hw/core/clock.c index fc5a99683f8..a42dc3c3d29 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -79,7 +79,14 @@ static void clock_propagate_period(Clock *clk, bool call_callbacks) { Clock *child; + trace_clock_propagate(CLOCK_PATH(clk), + CLOCK_PERIOD_TO_HZ(clk->period), + call_callbacks); QLIST_FOREACH(child, &clk->children, sibling) { + trace_clock_propagate_children(CLOCK_PATH(clk), + CLOCK_PERIOD_TO_HZ(clk->period), + CLOCK_PATH(child), + CLOCK_PERIOD_TO_HZ(child->period)); if (child->period != clk->period) { if (call_callbacks) { clock_call_callback(child, ClockPreUpdate); @@ -99,7 +106,6 @@ static void clock_propagate_period(Clock *clk, bool call_callbacks) void clock_propagate(Clock *clk) { assert(clk->source == NULL); - trace_clock_propagate(CLOCK_PATH(clk)); clock_propagate_period(clk, true); } diff --git a/hw/core/trace-events b/hw/core/trace-events index 360ddeb2c87..22df6789918 100644 --- a/hw/core/trace-events +++ b/hw/core/trace-events @@ -32,5 +32,6 @@ resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)" clock_set_source(const char *clk, const char *src) "'%s', src='%s'" clock_disconnect(const char *clk) "'%s'" clock_set(const char *clk, uint64_t old, uint64_t new) "'%s', %"PRIu64"Hz->%"PRIu64"Hz" -clock_propagate(const char *clk) "'%s'" +clock_propagate(const char *src, uint64_t src_hz, int cb) "src='%s' val=%"PRIu64"Hz cb=%d" +clock_propagate_children(const char *src, uint64_t src_hz, const char *clk, uint64_t clk_hz) "src='%s'@%"PRIu64"Hz -> clk='%s'@%"PRIu64"Hz" clock_update(const char *clk, const char *src, uint64_t hz, int cb) "'%s', src='%s', val=%"PRIu64"Hz cb=%d" From patchwork Fri Apr 9 06:23:54 2021 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: 1464185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=qxd+RzbM; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGp9y67Ytz9sPf for ; Fri, 9 Apr 2021 16:28:54 +1000 (AEST) Received: from localhost ([::1]:36334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkdQ-0008Pc-Om for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:28:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZ4-0004T3-1Y; Fri, 09 Apr 2021 02:24:22 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:35683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZ0-0001R4-Nx; Fri, 09 Apr 2021 02:24:21 -0400 Received: by mail-ej1-x635.google.com with SMTP id u17so6872816ejk.2; Thu, 08 Apr 2021 23:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zv8F1mVV51iuCp3WfDxO+akUI3QLMou50E1/QnZlhLk=; b=qxd+RzbM5kMKgsvTyLiyNQgr71qrrYTmogHq0FfpuhG+Z3388PwJTdpgz0BAA9q3HH gY5ixnpIn3/gAfn/7axlIoG28w9O23qJkEENiko+LHkKz2NUR3A5/kJAaL4GnFr/qaL1 X0RekDtZA88dYcv8cUVPFXCrkPKR4QlGaxjEiBaMLOajIpzf9zyHrvR01HC+Fokp2Zax ULzANGijajblICV5vDONcOpLAFZTkLQ8ZQSqeCqjGT8J+X0qbXDJXwrIpvMH6T4/Jq42 r+R4gD4/9qkJfwVAU3P9dSX5Rr5l6M3UwW9CRaPxW+lT2JsHQ1/SrFswd4VWONxcIS68 +1/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Zv8F1mVV51iuCp3WfDxO+akUI3QLMou50E1/QnZlhLk=; b=hoZozFaDFlj9RpysN/YBIOwXWh23/d1kGggSeYqVoGRJszsb49PAqdTn9lb1JW4Wog KipvvmK19F48M8nX00xUuqOyjTpbOk6I0ETdk2xnBi2/1SDDM+eRdws3lHtZHqG8QLfv JQl5BQfgB5cOgdv+3+uH8Oi3f1ZavaYPGsunFaEDw8w67F/S//apzpucJIQKlJ9eRub3 AK4a/pLW4vhdfhImK/eEoCD3UQWtbyDkGXrpTG0BpC6hcTpWwZ+udHcGhMpduoMMrxa7 fmEOrG/2cdIgqQRRhmeLR5qzaDSoqWhnYAWMPo+oOuxz8S1YVbxX9D85RsN8XxBMaqvD hxYw== X-Gm-Message-State: AOAM5324tuJPUv/1jm9yash/HnNXrOql/BIWXPTehmlwCFaYghCOZmBN /FV/H4uLHbMCSI5niK7pK/xQKwHqzGowqA== X-Google-Smtp-Source: ABdhPJxfff6Eo8NnUprk30XCkBTgoUGGNgk01dY+gvIRfX5cGKSCFsBL+IYvVazeTQ8rOduo7SxKBw== X-Received: by 2002:a17:906:6b8c:: with SMTP id l12mr14409061ejr.511.1617949453870; Thu, 08 Apr 2021 23:24:13 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id b24sm719251ejq.75.2021.04.08.23.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 2/9] hw/core/machine: Add machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:54 +0200 Message-Id: <20210409062401.2350436-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Boards usually have crystal oscillators (at fixed frequency) feeding their various clocked components. Add a helper to create such constant clocks in the machine. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/boards.h | 17 +++++++++++++++++ hw/core/machine.c | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index ad6c8fd5376..c8100f7a33a 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -11,6 +11,7 @@ #include "qemu/module.h" #include "qom/object.h" #include "hw/core/cpu.h" +#include "hw/clock.h" #define TYPE_MACHINE_SUFFIX "-machine" @@ -83,6 +84,22 @@ bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); MemoryRegion *machine_consume_memdev(MachineState *machine, HostMemoryBackend *backend); +/** + * machine_create_constant_clock: + * @machine: the parent machine + * @name: the clock object name + * @freq_hz: the clock frequency (in Hz) + * + * Helper function to create a new constant clock (fixed frequency + * of @freq_hz) and parent it to @machine. There is no need to call + * clock_setup_canonical_path on the returned clock as it is done + * by this function. + * + * @return the newly created clock + */ +Clock *machine_create_constant_clock(MachineState *machine, + const char *name, unsigned freq_hz); + /** * CPUArchId: * @arch_id - architecture-dependent CPU ID of present or possible CPU diff --git a/hw/core/machine.c b/hw/core/machine.c index 40def78183a..41baf80559d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1233,6 +1233,17 @@ void machine_run_board_init(MachineState *machine) phase_advance(PHASE_MACHINE_INITIALIZED); } +Clock *machine_create_constant_clock(MachineState *machine, + const char *name, unsigned freq_hz) +{ + Clock *clk; + + clk = clock_new(OBJECT(machine), name); + clock_set_hz(clk, freq_hz); + + return clk; +} + static NotifierList machine_init_done_notifiers = NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); From patchwork Fri Apr 9 06:23:55 2021 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: 1464184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sFsdBlHq; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGp9f738Zz9sSC for ; Fri, 9 Apr 2021 16:28:38 +1000 (AEST) Received: from localhost ([::1]:35326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkdA-00081a-W5 for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZ5-0004V7-ED; Fri, 09 Apr 2021 02:24:23 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:46907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZ3-0001SS-3j; Fri, 09 Apr 2021 02:24:23 -0400 Received: by mail-ej1-x62c.google.com with SMTP id u21so6814776ejo.13; Thu, 08 Apr 2021 23:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KM2bACU647mjpsDpzpNgymCuMSg/hlg69APP0D5FAlI=; b=sFsdBlHqI21NWowVevVCbm58EHUNmABa9M6WocYFi0KlG8UcktrHQ6dA24yFL9Kfut AGiwUyj51uwNwKBMADtr2QtgftcEzFSQEeP4rLDEmGs5KhG6aq1JOB1TKc9217SujshR /DrYAK6bYKUk7fp3PUwZ/ipDa7Kf7qjOIzzZAe3v9Ov4tou288F6U08Hnw1ifN7cxjzm H04m9Ed+rzkoxNM/uo0szEazltGW1TG1mU9IXbJv4dveMd0kzwPHy5bVqLCbQLDyiRgk 5NoRdDFn/rXkTqnVtPDrXSp7o1EjpMWsFIOspacJrtKqFk9CLjLxvhizxOYJJqvDjmkF 7jkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KM2bACU647mjpsDpzpNgymCuMSg/hlg69APP0D5FAlI=; b=kR2qbPq+Ziw8+v6SI4J3W10L4ex9hAPF/iwaPP0fLNLnfCr66Ihmq7LuYWnTxD7ZgZ CZe/OC4HSX5wR5QV5kxk9RUHXtbGht1tDcv/4IYtzGlCirLf0uh9XNqkUGOyuPAJXyT6 GwRtcsz9k8kebZQMt90kcx0bZEGqzEcQORb3Nho1xUWWQFfSKMjml5HjD1b21PjvL69H 5OnkL1KEsfCI6HYtBIjUXIPRdwykgaVvnn4BIm7R5rmYHCfZvbiMSNmJKw82Y64RaeYS iZp4Hs4T9CJq8qpRo2Zw1nSV/MGYzPZ7C9RlFhB7Bf4g+lYCqYQbCvIKrmIVHdl5wnZw xi5A== X-Gm-Message-State: AOAM532IXY9p1lZBrUToq0mb//MRAV6ZB++w2l5chvN6FFVMBFvdyBwr VW3ebQDC6N56OX4ybYmPYP9vceg0079mQw== X-Google-Smtp-Source: ABdhPJwiRa54IKzddTIhrI/nF3QxHryStq4E2A8ggC91kqfZ0uZGo4RAzlzbujk3D5oF0Py4M6iagA== X-Received: by 2002:a17:906:eb88:: with SMTP id mh8mr14958512ejb.74.1617949459153; Thu, 08 Apr 2021 23:24:19 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id a9sm846600eda.13.2021.04.08.23.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 3/9] hw/arm: Use new machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:55 +0200 Message-Id: <20210409062401.2350436-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use the newly added machine_create_constant_clock() helper to create the SYSCLKs. Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/mps2-tz.c | 6 ++---- hw/arm/mps2.c | 3 +-- hw/arm/musca.c | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index 3fbe3d29f95..86481fbe40d 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -740,10 +740,8 @@ static void mps2tz_common_init(MachineState *machine) } /* These clocks don't need migration because they are fixed-frequency */ - mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, mmc->sysclk_frq); - mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); - clock_set_hz(mms->s32kclk, S32KCLK_FRQ); + mms->sysclk = machine_create_constant_clock(machine, "SYSCLK", mmc->sysclk_frq); + mms->s32kclk = machine_create_constant_clock(machine, "S32KCLK", S32KCLK_FRQ); object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit, mmc->armsse_type); diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index 81413b7133e..5d9250da615 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -143,8 +143,7 @@ static void mps2_common_init(MachineState *machine) } /* This clock doesn't need migration because it is fixed-frequency */ - mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, SYSCLK_FRQ); + mms->sysclk = machine_create_constant_clock(machine, "SYSCLK", SYSCLK_FRQ); /* The FPGA images have an odd combination of different RAMs, * because in hardware they are different implementations and diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 7a83f7dda7d..e15149f3a27 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -372,10 +372,8 @@ static void musca_init(MachineState *machine) exit(1); } - mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); - clock_set_hz(mms->sysclk, SYSCLK_FRQ); - mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); - clock_set_hz(mms->s32kclk, S32KCLK_FRQ); + mms->sysclk = machine_create_constant_clock(machine, "SYSCLK", SYSCLK_FRQ); + mms->s32kclk = machine_create_constant_clock(machine, "S32KCLK", S32KCLK_FRQ); object_initialize_child(OBJECT(machine), "sse-200", &mms->sse, TYPE_SSE200); From patchwork Fri Apr 9 06:23:56 2021 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: 1464188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=jZtsq9Fa; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGpFX4mNRz9sPf for ; Fri, 9 Apr 2021 16:32:00 +1000 (AEST) Received: from localhost ([::1]:42910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkgQ-0002mC-Mj for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:31:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZA-0004aD-3T; Fri, 09 Apr 2021 02:24:29 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:43800) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZ8-0001W1-Jr; Fri, 09 Apr 2021 02:24:27 -0400 Received: by mail-ed1-x533.google.com with SMTP id e7so5168244edu.10; Thu, 08 Apr 2021 23:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zRoQYNlkLYyE9AlFcEvCS75qivi0ECZWMEXZijy0geo=; b=jZtsq9FagTXfsvqDf7W34eslAdCA4mGEvi2srm/7/nc6zymz7fBhbd7tT+4090WqQ7 RNVKiEaLFwYUqEOOGDgwwzEVTB/qgNKRNnqHO/UJyiNiiQHOiL9h+El+jVjh75LrEAXg oPaDjM51orhXfYGwrQUnzsINS7hPjwfyaHv+m7Ox2qefMSheSaGUUstZHZXZoKbQPJR+ 6g/elCbzJpocQoUSiady8qamz0sFai1WheOpOjBGb5tYv8p0Td4pe2YZr67HM4VNf45z rYk4nQqsGZPs0uLXF2xuErE75GsuwSEDXrVr8TzLA/ym5ScTillo03rkbMgNO4ExKQwO ilPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zRoQYNlkLYyE9AlFcEvCS75qivi0ECZWMEXZijy0geo=; b=LBSYwbYR9fCFT6pfyRrWC3bI66KvxQz2+2BwwNjtYb9hrr3Ee35ITyr3EQDHECt4Sv IvYcwwXtTyPK8kogoZFI4NyY1hKvSaREQ6S5OLoYTeXLw+yq7LKYg2OiTXGddblxsZ5H xHWfy0e47iltyYLz9LBGbuaUQLHCsE350+FIJg1vMJBevtydhtfjmvv5GVQCFf+6y9fg QAwj1UKhp0Cd5fJNLTXKwuvj3chmi+OU6lMfxMqRb7L3VYeP8w9Qv01RAReTKBWbs0qA hbBOFPzI5115E/pokcbQZy/H9EyaWOSYHbzEhWnu0H0FRoU8K7U19l44n8aa4d1q7tor Vf9g== X-Gm-Message-State: AOAM532MjIJwouHgbjOgIJ0lxzZcjAkenk2fj4C+yZfehQjhLcFLq4o2 DS6ufwREbl7Ym9n35itozoreOsB8kHfTrg== X-Google-Smtp-Source: ABdhPJycFP3DeWWCiB4FHpmElahwDBNZmZFiZYI0x7QKzBFgxbcU9Ri82gmB1RG/SGZ237kKc9X3IQ== X-Received: by 2002:a05:6402:26c9:: with SMTP id x9mr15630569edd.322.1617949464597; Thu, 08 Apr 2021 23:24:24 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id 28sm816854edw.82.2021.04.08.23.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 4/9] hw/mips: Use new machine_create_constant_clock() helper Date: Fri, 9 Apr 2021 08:23:56 +0200 Message-Id: <20210409062401.2350436-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x533.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Aleksandar Rikalo , Luc Michel , Eduardo Habkost , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, =?utf-8?q?Herv=C3=A9_Poussineau?= , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use the newly added machine_create_constant_clock() helper to create the CPU reference clocks. Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/fuloong2e.c | 4 ++-- hw/mips/jazz.c | 6 +++--- hw/mips/loongson3_virt.c | 4 ++-- hw/mips/mipssim.c | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 4f61f2c873b..72dc5702727 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -259,8 +259,8 @@ static void mips_fuloong2e_init(MachineState *machine) CPUMIPSState *env; DeviceState *dev; - cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, 533080000); /* ~533 MHz */ + cpuclk = machine_create_constant_clock(machine, "cpu-refclk", + 533080000); /* ~533 MHz */ /* init CPUs */ cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk); diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 1a0888a0fd5..3c220b4df6b 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -185,9 +185,9 @@ static void mips_jazz_init(MachineState *machine, exit(EXIT_FAILURE); } - cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, ext_clk[jazz_model].freq_hz - * ext_clk[jazz_model].pll_mult); + cpuclk = machine_create_constant_clock(machine, "cpu-refclk", + ext_clk[jazz_model].freq_hz + * ext_clk[jazz_model].pll_mult); /* init CPUs */ cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk); diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index b15071defc6..b9f18ecd911 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -530,8 +530,8 @@ static void mips_loongson3_virt_init(MachineState *machine) sysbus_create_simple("goldfish_rtc", virt_memmap[VIRT_RTC].base, qdev_get_gpio_in(liointc, RTC_IRQ)); - cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); - clock_set_hz(cpuclk, DEF_LOONGSON3_FREQ); + cpuclk = machine_create_constant_clock(machine, "cpu-refclk", + DEF_LOONGSON3_FREQ); for (i = 0; i < machine->smp.cpus; i++) { int ip; diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index f5d0da05aa1..af11cf9ac25 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -153,11 +153,12 @@ mips_mipssim_init(MachineState *machine) ResetData *reset_info; int bios_size; - cpuclk = clock_new(OBJECT(machine), "cpu-refclk"); #ifdef TARGET_MIPS64 - clock_set_hz(cpuclk, 6000000); /* 6 MHz */ + cpuclk = machine_create_constant_clock(machine, "cpu-refclk", + 6000000); /* 6 MHz */ #else - clock_set_hz(cpuclk, 12000000); /* 12 MHz */ + cpuclk = machine_create_constant_clock(machine, "cpu-refclk", + 12000000); /* 12 MHz */ #endif /* Init CPUs. */ From patchwork Fri Apr 9 06:23:57 2021 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: 1464190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=SFfzj4vF; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGpJF6DZLz9sPf for ; Fri, 9 Apr 2021 16:34:21 +1000 (AEST) Received: from localhost ([::1]:48798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkih-0005FT-TM for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:34:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZF-0004c1-Tk; Fri, 09 Apr 2021 02:24:36 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:42698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZD-0001Z5-JF; Fri, 09 Apr 2021 02:24:32 -0400 Received: by mail-ed1-x534.google.com with SMTP id r22so5166168edq.9; Thu, 08 Apr 2021 23:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1QJK5YsqEWkcz1+zXEQOYzQ3PdzprOwAmBARKtOH8jU=; b=SFfzj4vFkxKHFw7I2WM5bwbS612EFrpySvYmokQA6PhgvkhyNBRVwSRzN/yal9TlTh haAU0c18LOjMWa2lHdIcpYxkQ+zDwjf1Nw+UHhLlQqd9VdNzl32rLZLQm+eO8TErD/FA 7OWnuwUQZLo/7eGDwh/SC0ncctEgyqYmS5pNJS+95fZpk+s8P6YFveOur5ad5bSTng4u HarUk8pCRZ0kxu7uY9tv2VXDgnldftzu4OxSJ4aKB19wAo04Cs+8AELq22FwCPK09azB TafJrTsukB66R1l2yVOvzAPXdV8qNPg475aBxle+1uozY/TwBearXLLuInTT89cd8vk1 oV7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1QJK5YsqEWkcz1+zXEQOYzQ3PdzprOwAmBARKtOH8jU=; b=s27+TfqMXYD+P3fDQm/7/eFMSg/5kjWPlc46Y2fcj4xlnlKbyb8z4ytGV6Wt0KK4+V MJHmbtnnyXolnH+5muGzIx/u2MM/IWEaFEylv7H/VGppsBix6Jt08+DH69rhhCir0u9F 7Y7ZDvdO5vKrxlGOqcottqxPwYmQcgzAXoKI7PFDLyZCX2OB1Oc6F4UTwGxgCOhO/yFb FQ8OgIzNzcRL7Dtm9K2vs/l8CQnQYjVkyIFoBGrwwkHU7NCvsuxXEbBBZ6MsWfPldGQJ BN0iLLh9LTL+ba3ToQ//PDdNU8Tgnq8ZK9YyrjWs7FwncRB55KC0AC91dlcaHJCUSApQ zfAg== X-Gm-Message-State: AOAM531F/B5JbHWlKdbY6uv5+PkGxIBEW75ZdnDiM4jCUSjwbnDWLecX hcn+EUnSXxLuK7xFl7MmZ/WETumRljVhTQ== X-Google-Smtp-Source: ABdhPJznfibeaFD5ex6/UkoMzabT/fJR93l2LnzgcBxyv2MHxV51NWXNqFBqnC7pvpoUSASRUfCG/w== X-Received: by 2002:a05:6402:35cd:: with SMTP id z13mr16107830edc.21.1617949469778; Thu, 08 Apr 2021 23:24:29 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id t7sm820410edq.42.2021.04.08.23.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper Date: Fri, 9 Apr 2021 08:23:57 +0200 Message-Id: <20210409062401.2350436-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, =?utf-8?q?Daniel?= =?utf-8?q?_P=2E_Berrang=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Clocks are rarely left unconnected, but rather connected to ground plane to avoid noise. When representing the clock tree, we want to see such ground clock. As we might reuse this clock on various boards, introduce the qdev_ground_clock() which return a singleton ground clock. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/qdev-clock.h | 9 +++++++++ hw/core/qdev-clock.c | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h index ffa0f7ba09e..2f2d2da6cd6 100644 --- a/include/hw/qdev-clock.h +++ b/include/hw/qdev-clock.h @@ -161,4 +161,13 @@ typedef struct ClockPortInitElem ClockPortInitArray[]; */ void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks); +/** + * qdev_ground_clock: + * @returns: a pointer to the ground clock + * + * Get the special 'ground' clock. This clock can be used as input + * (unclocked) or output. + */ +Clock *qdev_ground_clock(void); + #endif /* QDEV_CLOCK_H */ diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index 117f4c6ea4a..a46384a84b7 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -210,3 +210,14 @@ void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source) assert(!dev->realized); clock_set_source(qdev_get_clock_in(dev, name), source); } + +Clock *qdev_ground_clock(void) +{ + static Clock *gnd_clk; + + if (!gnd_clk) { + gnd_clk = clock_new(qdev_get_machine(), "gnd"); + } + + return gnd_clk; +} From patchwork Fri Apr 9 06:23:58 2021 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: 1464191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ltZ+3820; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGpLK4qS0z9sPf for ; Fri, 9 Apr 2021 16:36:07 +1000 (AEST) Received: from localhost ([::1]:52956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkkP-0006y3-1f for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:36:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZM-0004ff-0c; Fri, 09 Apr 2021 02:24:40 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:46053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZJ-0001bZ-Rr; Fri, 09 Apr 2021 02:24:39 -0400 Received: by mail-ej1-x62b.google.com with SMTP id mh7so6822290ejb.12; Thu, 08 Apr 2021 23:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OEqLEQHCmytseRt1FhXxp+Rob399wNsde0XeRnkGgQ=; b=ltZ+3820lLw6oC8xOjK05tEQA2ZV7Fjzd8OCarI9OfHsTY+NUKyaoYnOxRPhtsSRQm 8uGBBx3oMvSTowr3SN33+jgx5Wp+bCKEKx4LqgyNCmlQISba3rl04LV+cot9vw8rNO92 NobHeCeMMbo9VZFaZZl3Foopgh42a555jALD5/rqJ1fO7k8VwVdoQ3IRh/30Mcwor4l6 sRCR2ONs8ovaSJGtwNawSnhFxVgd9K4ZdP3FI1t/ZDtpy9z4m8mhy5kkFLr5YpwoaJeF Cbd9OTiZCfRkCWBGki4i8JE31x093/IQUIwLmvu/PnzjT6F4BSZwXsK+8KVHL+wHyCBQ EHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/OEqLEQHCmytseRt1FhXxp+Rob399wNsde0XeRnkGgQ=; b=WMkVUPNypia5wYXssGgnQKJugGjE7XUurjxu74acreS70t9nTBrRLWZabwP4G7I0bm IoQCxpD8T3Y2V5vpnW/L4sYOUMETj0QZ4UGSEfvBQpLGEby9V5Jr6THlaXDloPk8Lvl7 okLtYThEujMisblNYaWNo2lOsbQ2YWwVFzk11p1syXqd+rVeJOw+HKkgGOXXV0wJjHp7 wzyafrXnrNN5SsCbXWtkqhWveOGv8gNwgwRdO7/7OzXklzv73L8NtYpS+m1v7yjfXBLN oSEiFB8jouCwhcVBL9xykSZZGnNzgvjVUl4eAZbvv2z5FGELkW5PiUHF5WtHOkQxuGtu F5ww== X-Gm-Message-State: AOAM530dypJuvtEwn80wHsqMFxgTWCrkKXI/81k+hKpxC5vI0UoyhVhl 9gy2h1rGrappENpXXE2MmuAF2cBlWey2EA== X-Google-Smtp-Source: ABdhPJyXnHdzktWS6AwWRoja1N2Z48ZZJD7qGZxm922GmRaCtBWzMTSguBD/9KCt+SZT4bgDl6OVMg== X-Received: by 2002:a17:906:170d:: with SMTP id c13mr14302431eje.491.1617949474885; Thu, 08 Apr 2021 23:24:34 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id ay3sm845372edb.2.2021.04.08.23.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 6/9] hw/misc/bcm2835_cprman: Use qdev_ground_clock() helper Date: Fri, 9 Apr 2021 08:23:58 +0200 Message-Id: <20210409062401.2350436-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The ground clock isn't really an internal component of the CPRMAN peripheral. Use the qdev_ground_clock() helper to access the board ground plane. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/misc/bcm2835_cprman.h | 1 - hw/misc/bcm2835_cprman.c | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h index 3df4ceedd2e..2996ccb4632 100644 --- a/include/hw/misc/bcm2835_cprman.h +++ b/include/hw/misc/bcm2835_cprman.h @@ -204,7 +204,6 @@ struct BCM2835CprmanState { uint32_t xosc_freq; Clock *xosc; - Clock *gnd; }; #endif diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c index 75e6c574d46..5039b7632b4 100644 --- a/hw/misc/bcm2835_cprman.c +++ b/hw/misc/bcm2835_cprman.c @@ -678,9 +678,6 @@ static void cprman_init(Object *obj) } s->xosc = clock_new(obj, "xosc"); - s->gnd = clock_new(obj, "gnd"); - - clock_set(s->gnd, 0); memory_region_init_io(&s->iomem, obj, &cprman_ops, s, "bcm2835-cprman", 0x2000); @@ -697,7 +694,7 @@ static void connect_mux_sources(BCM2835CprmanState *s, /* For sources from 0 to 3. Source 4 to 9 are mux specific */ Clock * const CLK_SRC_MAPPING[] = { - [CPRMAN_CLOCK_SRC_GND] = s->gnd, + [CPRMAN_CLOCK_SRC_GND] = qdev_ground_clock(), [CPRMAN_CLOCK_SRC_XOSC] = s->xosc, [CPRMAN_CLOCK_SRC_TD0] = td0, [CPRMAN_CLOCK_SRC_TD1] = td1, @@ -708,7 +705,7 @@ static void connect_mux_sources(BCM2835CprmanState *s, Clock *src; if (mapping == CPRMAN_CLOCK_SRC_FORCE_GROUND) { - src = s->gnd; + src = qdev_ground_clock(); } else if (mapping == CPRMAN_CLOCK_SRC_DSI0HSCK) { src = s->dsi0hsck_mux.out; } else if (i < CPRMAN_CLOCK_SRC_PLLA) { From patchwork Fri Apr 9 06:23:59 2021 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: 1464189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sqI6xGXA; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGpHS2mqmz9sPf for ; Fri, 9 Apr 2021 16:33:40 +1000 (AEST) Received: from localhost ([::1]:46072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUki2-00048W-Ex for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:33:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZQ-0004ho-T7; Fri, 09 Apr 2021 02:24:47 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:35687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZN-0001eo-VY; Fri, 09 Apr 2021 02:24:44 -0400 Received: by mail-ej1-x633.google.com with SMTP id u17so6874201ejk.2; Thu, 08 Apr 2021 23:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ge+UwN7N+4mN3C6ng3RtkaVCXw7LRu2ISOzslpilhag=; b=sqI6xGXAI0n0K+8BjBLgH9G7oD1OPFoSjYfbLCqgasErypf378fdNteeFfrbYbaryn fe6HJhebGQQmAU+PKCfWAIhDwL5DnOpLx0Jglp52aGcNoLE6YxpzcjtuNY03p7LISz6v cBI4GmOcXbCywe/Jh77OjuGR/4ilEYSoZgld+e8D8/ZBmU8Cwd4eXiyvjv1Wmh3/Mcw+ 5vzCNTpLC7yZ/ocK2pxYeufZXCjqLzcrRf28eEWspmV9rhHUYXwOop6t4WgdX6yebilW Lbt18y9/DhknaRcb3TOobaL0srBo+IzheDZfL1rO5glGqs13PdVWp3Gkm7smuR+MTVSl v3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ge+UwN7N+4mN3C6ng3RtkaVCXw7LRu2ISOzslpilhag=; b=FAg75yKF1gg5gX+tNDEH1lhBfo+Nd0UHNV2d1MT6Ncppk+01T5zKRtbnTIwYe1BEyY +QjWs0RlPTi30uKDl0kD3Vs1ojx7l9N8zLDwC4I8UO4sVJrHVFeYmjD48mgmegAWzTWn N7TqmPalXwA9C9bAVui5Ed5ocJDX11mFz9mSuv43s+7jNdrO5X6UPWdNTQSnkJmzHfH1 5SNYPkEB0FD+aNlr6R5chGIcwQ0yE1Ec1fUxGa48RvvVn5xyM7qUqzQBD1DVxrEjoQH4 +Mr8wgQlxlfTa5yt+qAFUyByHZwU1oP1qcA6e0fNxbtjkpxybAZbbCitQBTi1nY62Fck R3WQ== X-Gm-Message-State: AOAM533LeNX2jUkNO/kUopcHM+yeeIMtNEmL8smNuw70XQljmFntZBXb XxGuStGY/mzAjlRTAQRZvo6hhp9mN0PKqg== X-Google-Smtp-Source: ABdhPJyDUfeN6H/klQeGg95tmYz3oRaFLhxDxpus26sJoIAX5Ug2xbEEgp9xVqR8PaYzAT4NjQo3Kg== X-Received: by 2002:a17:907:93a:: with SMTP id au26mr14718110ejc.47.1617949480146; Thu, 08 Apr 2021 23:24:40 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id g26sm705658ejz.70.2021.04.08.23.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board Date: Fri, 9 Apr 2021 08:23:59 +0200 Message-Id: <20210409062401.2350436-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The XOsc signal isn't a part of the CPRMAN, but comes from a crystal oscillator external to the SoC. Create the oscillator on the board, and propagate it to the CPRMAN. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- include/hw/misc/bcm2835_cprman.h | 1 - hw/arm/bcm2835_peripherals.c | 1 + hw/arm/bcm2836.c | 1 + hw/arm/raspi.c | 4 ++++ hw/misc/bcm2835_cprman.c | 5 +---- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/hw/misc/bcm2835_cprman.h b/include/hw/misc/bcm2835_cprman.h index 2996ccb4632..52f76489f36 100644 --- a/include/hw/misc/bcm2835_cprman.h +++ b/include/hw/misc/bcm2835_cprman.h @@ -201,7 +201,6 @@ struct BCM2835CprmanState { CprmanDsi0HsckMuxState dsi0hsck_mux; uint32_t regs[CPRMAN_NUM_REGS]; - uint32_t xosc_freq; Clock *xosc; }; diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index dcff13433e5..a82f2b42f5a 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -123,6 +123,7 @@ static void bcm2835_peripherals_init(Object *obj) /* CPRMAN clock manager */ object_initialize_child(obj, "cprman", &s->cprman, TYPE_BCM2835_CPRMAN); + qdev_alias_clock(DEVICE(&s->cprman), "xosc-in", DEVICE(s), "xosc-in"); object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", OBJECT(&s->gpu_bus_mr)); diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index de7ade2878e..6c238ecb949 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -63,6 +63,7 @@ static void bcm2836_init(Object *obj) "board-rev"); object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), "vcram-size"); + qdev_alias_clock(DEVICE(&s->peripherals), "xosc-in", DEVICE(s), "xosc-in"); } static bool bcm283x_common_realize(DeviceState *dev, Error **errp) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 990509d3852..a89f7e17c3a 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -40,6 +40,7 @@ struct RaspiMachineState { /*< private >*/ MachineState parent_obj; /*< public >*/ + Clock *xosc; BCM283XState soc; struct arm_boot_info binfo; }; @@ -277,12 +278,15 @@ static void raspi_machine_init(MachineState *machine) memory_region_add_subregion_overlap(get_system_memory(), 0, machine->ram, 0); + s->xosc = machine_create_constant_clock(machine, "xosc", 19200000); + /* Setup the SOC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, board_soc_type(board_rev)); object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram)); object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev, &error_abort); + qdev_connect_clock_in(DEVICE(&s->soc), "xosc-in", s->xosc); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* Create and plug in the SD cards */ diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c index 5039b7632b4..33f15d99f63 100644 --- a/hw/misc/bcm2835_cprman.c +++ b/hw/misc/bcm2835_cprman.c @@ -637,8 +637,6 @@ static void cprman_reset(DeviceState *dev) for (i = 0; i < CPRMAN_NUM_CLOCK_MUX; i++) { device_cold_reset(DEVICE(&s->clock_muxes[i])); } - - clock_update_hz(s->xosc, s->xosc_freq); } static void cprman_init(Object *obj) @@ -677,7 +675,7 @@ static void cprman_init(Object *obj) g_free(alias); } - s->xosc = clock_new(obj, "xosc"); + s->xosc = qdev_init_clock_in(DEVICE(obj), "xosc-in", NULL, s, ClockUpdate); memory_region_init_io(&s->iomem, obj, &cprman_ops, s, "bcm2835-cprman", 0x2000); @@ -776,7 +774,6 @@ static const VMStateDescription cprman_vmstate = { }; static Property cprman_properties[] = { - DEFINE_PROP_UINT32("xosc-freq-hz", BCM2835CprmanState, xosc_freq, 19200000), DEFINE_PROP_END_OF_LIST() }; From patchwork Fri Apr 9 06:24:00 2021 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: 1464183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=uuS4Pk/V; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGp7V3Gfsz9sPf for ; Fri, 9 Apr 2021 16:26:46 +1000 (AEST) Received: from localhost ([::1]:58624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkbM-0005oh-EG for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:26:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZX-0004me-CK; Fri, 09 Apr 2021 02:24:51 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:44935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZT-0001hJ-PY; Fri, 09 Apr 2021 02:24:50 -0400 Received: by mail-ej1-x62d.google.com with SMTP id e14so6828213ejz.11; Thu, 08 Apr 2021 23:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=uuS4Pk/VAJDOp6Pwxln8iW/mJ4KnaTDRn50NXb+1N5XW12GifvULQ/vjj0op//bMN7 LkAj7c+hNguynBubJgAGCMtSqcXeqwzU8Lmv/GvTxql7KWHFodLx6pLXHBGM2+1PPuZR bfp/fDE5JrTqZ4cznaVDktC2aFy763BbFLvHcOWIMY29k+RvphJ3OEO5fDrfUJsvmMHm /I/IlUxBd8J6ts3c2rxPitHPTCXyogm2DpZ7HKnnQpI9PT1iI/T9d+iwsFtWI9bdU5aV 0kDhAi9dMXLgqAFr03CWuSNjEy2us7nTo42cd+/iYlWT/3AD2MVabsaqyxhyxKfeKB/w 714Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nDFbUJf+zSiSog/LYin0LAf7wyvK1G5JKV9wmLaTU9M=; b=PqQYJzJnhidbsAxLEU+0f3LK/MDUTk1VE/xCX+PM0lhIL+5roZZT4vgsPZHTxup+m+ FBbZEkoMoGE1841F0eos7G5vncCKCh26S5kFzhZ4VWAtwPz22EnsRp4VvZ3uID5tAUnP VJ+Dk34sVS0WkGLvK3GO7tI1fejtkWEXCtwdJ//W0fG+AXGk+tErhM+9ApRlSJTESQtz q3MKMIZ0SP3AA17DKdzUq3PvyAnawQOoQxnkq3NI18fvgHE51sl5q0TAVk9egNLuV30h BbtFbGtLpYQ8e0hVVvrmWa3FtJoIcfxw1z3dIXJ5QnsWQ6q5jOHw/fPFBbr5VQTgUqZy o5VQ== X-Gm-Message-State: AOAM53053BwLNk2dwH8ZXyASsjZzDwcmH1nUuxJzaOX2hXCDjEB9ncVr Hewi1oqQiRZkrHHPHvqn6S/dyswYwCW9Gw== X-Google-Smtp-Source: ABdhPJxo+77+8B6ZlCyBZlhyE6lnabwzE/4mu9v6/6AQ6+Trohef5kPe/Q2tCvpfrpxcUzPkBATJUg== X-Received: by 2002:a17:906:e0b:: with SMTP id l11mr14989236eji.111.1617949485397; Thu, 08 Apr 2021 23:24:45 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id b21sm711872ejz.123.2021.04.08.23.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally Date: Fri, 9 Apr 2021 08:24:00 +0200 Message-Id: <20210409062401.2350436-9-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, =?utf-8?q?Daniel?= =?utf-8?q?_P=2E_Berrang=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" To enforce correct API usage, restrict the clock creation to hw/core/. The only possible ways to create a clock are: - Constant clock at the board level Using machine_create_constant_clock() in machine_init() - Propagated clock in QDev Using qdev_init_clock_in() or qdev_init_clock_out() in TYPE_DEVICE instance_init(). Signed-off-by: Philippe Mathieu-Daudé --- hw/core/clock-internal.h | 32 ++++++++++++++++++++++++++++++++ include/hw/clock.h | 13 ------------- hw/core/clock.c | 1 + hw/core/machine.c | 1 + hw/core/qdev-clock.c | 1 + MAINTAINERS | 1 + 6 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 hw/core/clock-internal.h diff --git a/hw/core/clock-internal.h b/hw/core/clock-internal.h new file mode 100644 index 00000000000..2207be74c0f --- /dev/null +++ b/hw/core/clock-internal.h @@ -0,0 +1,32 @@ +/* + * Hardware Clocks + * + * Copyright GreenSocs 2016-2020 + * + * Authors: + * Frederic Konrad + * Damien Hedde + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_HW_CLOCK_INTERNAL_H +#define QEMU_HW_CLOCK_INTERNAL_H + +#include "hw/clock.h" + +/** + * clock_new: + * @parent: the clock parent + * @name: the clock object name + * + * Helper function to create a new clock and parent it to @parent. There is no + * need to call clock_setup_canonical_path on the returned clock as it is done + * by this function. + * + * @return the newly created clock + */ +Clock *clock_new(Object *parent, const char *name); + +#endif diff --git a/include/hw/clock.h b/include/hw/clock.h index a7187eab95e..47cb65edb32 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -109,19 +109,6 @@ extern const VMStateDescription vmstate_clock; */ void clock_setup_canonical_path(Clock *clk); -/** - * clock_new: - * @parent: the clock parent - * @name: the clock object name - * - * Helper function to create a new clock and parent it to @parent. There is no - * need to call clock_setup_canonical_path on the returned clock as it is done - * by this function. - * - * @return the newly created clock - */ -Clock *clock_new(Object *parent, const char *name); - /** * clock_set_callback: * @clk: the clock to register the callback into diff --git a/hw/core/clock.c b/hw/core/clock.c index a42dc3c3d29..bfa54ca0a93 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "hw/clock.h" +#include "clock-internal.h" #include "trace.h" #define CLOCK_PATH(_clk) (_clk->canonical_path) diff --git a/hw/core/machine.c b/hw/core/machine.c index 41baf80559d..e8bdcd10854 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,6 +35,7 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" +#include "clock-internal.h" GlobalProperty hw_compat_5_2[] = { { "ICH9-LPC", "smm-compat", "on"}, diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c index a46384a84b7..09e14009fcd 100644 --- a/hw/core/qdev-clock.c +++ b/hw/core/qdev-clock.c @@ -16,6 +16,7 @@ #include "hw/qdev-clock.h" #include "hw/qdev-core.h" #include "qapi/error.h" +#include "clock-internal.h" /* * qdev_init_clocklist: diff --git a/MAINTAINERS b/MAINTAINERS index 58f342108e9..2b10744169c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2925,6 +2925,7 @@ S: Maintained F: include/hw/clock.h F: include/hw/qdev-clock.h F: hw/core/clock.c +F: hw/core/clock-internal.h F: hw/core/clock-vmstate.c F: hw/core/qdev-clock.c F: docs/devel/clocks.rst From patchwork Fri Apr 9 06:24:01 2021 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: 1464186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AKqMgHWJ; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4FGpBx6M9Gz9sPf for ; Fri, 9 Apr 2021 16:29:45 +1000 (AEST) Received: from localhost ([::1]:38888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUkeF-00011c-U3 for incoming@patchwork.ozlabs.org; Fri, 09 Apr 2021 02:29:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUkZZ-0004ty-TR; Fri, 09 Apr 2021 02:24:53 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:46060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUkZY-0001k3-FI; Fri, 09 Apr 2021 02:24:53 -0400 Received: by mail-ej1-x62e.google.com with SMTP id mh7so6823201ejb.12; Thu, 08 Apr 2021 23:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eG5k+RY3W5mxHR/DqHIpbCfVA2UEY0rp9HYfHHycg/Y=; b=AKqMgHWJ0Dqoft8I68l+hHmWod18M96s8AQnYgCnFdnj16WSwkn3EmOf7PMSXBysus xeKhkfdDG6paOAyl7YUvFC9r34cPqf7appmaSXxTiU90eUD2P4sQYkJpR3YCYxiHQOFT ErH43D/swNpqz2cE+/YMxuqmSEivM0i6EHdv4pH22eMSFnQp+UpaDQKuLahbWOwUB9Ri usp9u2ZpWKbJowtblXTEOC1d3ceyGyUdURLJ7eAnQCvaIzD+3j4E88Rp4jIp2HRUzJFF 0p/O/mGra2b464Xh8FQePIHCwj3fRk7Lb6ijBbbaAEGKKva42NT9RDMwFxjpm4LfQY1Y iA1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=eG5k+RY3W5mxHR/DqHIpbCfVA2UEY0rp9HYfHHycg/Y=; b=n6QYPJQZqPoOPJZ4IdYBlgFAIIv5QfGFWLl0L/MoREV7VqTXtwAQm87Gci+ywoqjHf frTP6EmIY3KJmGSzYfQP8qQI2qJth6piHE6oQHAnmA1VAWgZRbAS6XrYGuBCYKja5HRZ 5dlc/uj9073tnDSNy+gJdqHNUiD3oPILzgMiWOL/3+390PnwXF1/et5akPvafzQLizut CszT2/7oFvXgLiUS2MCA7j4wC0WD9khKlDe7pCiPEv+5WNjifM4FCrTb7IVIHfyo+D1/ kLUchu3I7xiNaFBwjtOmGr035WBGNHw9ktQBgmKIDHcBZxFKyIEAi5gg8POFeOd/nPmU LuDA== X-Gm-Message-State: AOAM530/R8vF1o4wW/voE6YcGoGBwb8V+VUVRPLwCEzAIX0WoIYMLwAF P4v24FpmCcxnjsZQey6BNd2w9iYLs2jYmw== X-Google-Smtp-Source: ABdhPJx5kAPr4OgDeOSgUmG90BXSCAhUQ2ByiPvx1WfHMVigRm5yRX97xnI0Zn6bGIEnLl4N26IeAQ== X-Received: by 2002:a17:906:ff41:: with SMTP id zo1mr14664036ejb.19.1617949490535; Thu, 08 Apr 2021 23:24:50 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id u15sm834765edx.34.2021.04.08.23.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 23:24:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset() Date: Fri, 9 Apr 2021 08:24:01 +0200 Message-Id: <20210409062401.2350436-10-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210409062401.2350436-1-f4bug@amsat.org> References: <20210409062401.2350436-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Luc Michel , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" While the documentation mentions: Note that if you are creating a clock with a fixed period which will never change (for example the main clock source of a board), then you'll have nothing else to do. This value will be propagated to other clocks when connecting the clocks together and devices will fetch the right value during the first reset. the clocks created in machine_init() aren't propagating their value because they are never reset (not part of the reset tree, such TYPE_DEVICE). Register a generic reset handler to have them properly reset. Signed-off-by: Philippe Mathieu-Daudé --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index e8bdcd10854..2817fe6a567 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1234,6 +1234,13 @@ void machine_run_board_init(MachineState *machine) phase_advance(PHASE_MACHINE_INITIALIZED); } +static void constant_clock_reset(void *opaque) +{ + Clock *clk = opaque; + + clock_propagate(clk); +} + Clock *machine_create_constant_clock(MachineState *machine, const char *name, unsigned freq_hz) { @@ -1241,6 +1248,7 @@ Clock *machine_create_constant_clock(MachineState *machine, clk = clock_new(OBJECT(machine), name); clock_set_hz(clk, freq_hz); + qemu_register_reset(constant_clock_reset, clk); return clk; }