All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema
@ 2022-02-21 19:21 Peter Maydell
  2022-02-21 19:21 ` [PATCH v2 1/3] " Peter Maydell
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Peter Maydell @ 2022-02-21 19:21 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

This patchset moves RTC_CHANGE back to misc.json, effectively
reverting commit 183e4281a30962, which moved the RTC_CHANGE event to
the target schema.  That change was an attempt to make the event
target-specific to improve introspection, but the event isn't really
target-specific: it's machine or device specific.  Putting RTC_CHANGE
in the target schema with an ifdef list reduces maintainability (by
adding an if: list with a long list of targets that needs to be
manually updated as architectures are added or removed or as new
devices gain the RTC_CHANGE functionality) and increases compile time
(by preventing RTC devices which emit the event from being "compile
once" rather than "compile once per target", because
qapi-events-misc-target.h uses TARGET_* ifdefs, which are poisoned in
"compile once" files.)

Patch 2 fixes some minor documentation issues for the RTC_CHANGE
event, noticed during development of the patchset.

Patch 3 makes the pl031 a build-once file again, which was the
initial motivation for the series.

Changes v1->v2:
 * patch 1 needs to change the #include line for pl031.c, now that
   the change to make that device emit RTC_CHANGE has landed upstream
 * patch 2 now also notes in the RTC_CHANGE documentation that
   not all devices/systems will emit the event (suggested by Markus)
 * patch 3 is new

My default assumption is that this series will go in via the
qapi tree; let me know if you'd prefer me to take it via
target-arm instead.

thanks
-- PMM

Peter Maydell (3):
  qapi: Move RTC_CHANGE back out of target schema
  qapi: Document some missing details of RTC_CHANGE event
  hw/rtc: Compile pl031 once-only

 qapi/misc-target.json | 33 ---------------------------------
 qapi/misc.json        | 24 ++++++++++++++++++++++++
 hw/ppc/spapr_rtc.c    |  2 +-
 hw/rtc/mc146818rtc.c  |  2 +-
 hw/rtc/pl031.c        |  2 +-
 hw/rtc/meson.build    |  2 +-
 6 files changed, 28 insertions(+), 37 deletions(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/3] qapi: Move RTC_CHANGE back out of target schema
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
@ 2022-02-21 19:21 ` Peter Maydell
  2022-02-21 19:27   ` Philippe Mathieu-Daudé
  2022-02-21 19:21 ` [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event Peter Maydell
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2022-02-21 19:21 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

This commit effectively reverts commit 183e4281a30962, which moved
the RTC_CHANGE event to the target schema.  That change was an
attempt to make the event target-specific to improve introspection,
but the event isn't really target-specific: it's machine or device
specific.  Putting RTC_CHANGE in the target schema with an ifdef list
reduces maintainability (by adding an if: list with a long list of
targets that needs to be manually updated as architectures are added
or removed or as new devices gain the RTC_CHANGE functionality) and
increases compile time (by preventing RTC devices which emit the
event from being "compile once" rather than "compile once per
target", because qapi-events-misc-target.h uses TARGET_* ifdefs,
which are poisoned in "compile once" files.)

Move RTC_CHANGE back to misc.json.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Greg Kurz <groug@kaod.org>
---
 qapi/misc-target.json | 33 ---------------------------------
 qapi/misc.json        | 22 ++++++++++++++++++++++
 hw/ppc/spapr_rtc.c    |  2 +-
 hw/rtc/mc146818rtc.c  |  2 +-
 hw/rtc/pl031.c        |  2 +-
 5 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/qapi/misc-target.json b/qapi/misc-target.json
index 4bc45d24741..036c5e4a914 100644
--- a/qapi/misc-target.json
+++ b/qapi/misc-target.json
@@ -2,39 +2,6 @@
 # vim: filetype=python
 #
 
-##
-# @RTC_CHANGE:
-#
-# Emitted when the guest changes the RTC time.
-#
-# @offset: offset between base RTC clock (as specified by -rtc base), and
-#          new RTC clock value
-#
-# Note: This event is rate-limited.
-#
-# Since: 0.13
-#
-# Example:
-#
-# <-   { "event": "RTC_CHANGE",
-#        "data": { "offset": 78 },
-#        "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
-#
-##
-{ 'event': 'RTC_CHANGE',
-  'data': { 'offset': 'int' },
-  'if': { 'any': [ 'TARGET_ALPHA',
-                   'TARGET_ARM',
-                   'TARGET_HPPA',
-                   'TARGET_I386',
-                   'TARGET_MIPS',
-                   'TARGET_MIPS64',
-                   'TARGET_PPC',
-                   'TARGET_PPC64',
-                   'TARGET_S390X',
-                   'TARGET_SH4',
-                   'TARGET_SPARC' ] } }
-
 ##
 # @rtc-reset-reinjection:
 #
diff --git a/qapi/misc.json b/qapi/misc.json
index e8054f415b2..7a70eaa3ffc 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -527,3 +527,25 @@
  'data': { '*option': 'str' },
  'returns': ['CommandLineOptionInfo'],
  'allow-preconfig': true }
+
+##
+# @RTC_CHANGE:
+#
+# Emitted when the guest changes the RTC time.
+#
+# @offset: offset between base RTC clock (as specified by -rtc base), and
+#          new RTC clock value
+#
+# Note: This event is rate-limited.
+#
+# Since: 0.13
+#
+# Example:
+#
+# <-   { "event": "RTC_CHANGE",
+#        "data": { "offset": 78 },
+#        "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
+#
+##
+{ 'event': 'RTC_CHANGE',
+  'data': { 'offset': 'int' } }
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 94a5510e4eb..79677cf5503 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -32,7 +32,7 @@
 #include "hw/ppc/spapr.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
-#include "qapi/qapi-events-misc-target.h"
+#include "qapi/qapi-events-misc.h"
 #include "qemu/cutils.h"
 #include "qemu/module.h"
 
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index e61a0cced4c..57c514e15c5 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -40,7 +40,7 @@
 #include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
-#include "qapi/qapi-events-misc-target.h"
+#include "qapi/qapi-events-misc.h"
 #include "qapi/visitor.h"
 #include "hw/rtc/mc146818rtc_regs.h"
 
diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c
index 38d9d3c2f38..60167c778f2 100644
--- a/hw/rtc/pl031.c
+++ b/hw/rtc/pl031.c
@@ -24,7 +24,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "trace.h"
-#include "qapi/qapi-events-misc-target.h"
+#include "qapi/qapi-events-misc.h"
 
 #define RTC_DR      0x00    /* Data read register */
 #define RTC_MR      0x04    /* Match register */
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
  2022-02-21 19:21 ` [PATCH v2 1/3] " Peter Maydell
@ 2022-02-21 19:21 ` Peter Maydell
  2022-02-21 19:28   ` Philippe Mathieu-Daudé
  2022-02-22 11:22   ` Markus Armbruster
  2022-02-21 19:21 ` [PATCH v2 3/3] hw/rtc: Compile pl031 once-only Peter Maydell
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 18+ messages in thread
From: Peter Maydell @ 2022-02-21 19:21 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

The RTC_CHANGE event's documentation is missing some details:
 * the offset argument is in units of seconds
 * it isn't guaranteed that the RTC will implement the event

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
v1->v2: add the "RTC might not implement this" note
---
 qapi/misc.json | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 7a70eaa3ffc..0ab235e41f7 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -533,10 +533,12 @@
 #
 # Emitted when the guest changes the RTC time.
 #
-# @offset: offset between base RTC clock (as specified by -rtc base), and
-#          new RTC clock value
+# @offset: offset in seconds between base RTC clock (as specified
+#          by -rtc base), and new RTC clock value
 #
 # Note: This event is rate-limited.
+#       It is not guaranteed that the RTC in the system implements
+#       this event, or even that the system has an RTC at all.
 #
 # Since: 0.13
 #
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/3] hw/rtc: Compile pl031 once-only
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
  2022-02-21 19:21 ` [PATCH v2 1/3] " Peter Maydell
  2022-02-21 19:21 ` [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event Peter Maydell
@ 2022-02-21 19:21 ` Peter Maydell
  2022-02-21 19:28   ` Philippe Mathieu-Daudé
  2022-02-21 20:11 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Eric Auger
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2022-02-21 19:21 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

Now that the RTC_CHANGE event is no longer target-specific,
we can move the pl031 back to a compile-once source file
rather than a compile-per-target one.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/rtc/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/rtc/meson.build b/hw/rtc/meson.build
index 8fd8d8f9a71..7cecdee5ddb 100644
--- a/hw/rtc/meson.build
+++ b/hw/rtc/meson.build
@@ -2,7 +2,7 @@
 softmmu_ss.add(when: 'CONFIG_DS1338', if_true: files('ds1338.c'))
 softmmu_ss.add(when: 'CONFIG_M41T80', if_true: files('m41t80.c'))
 softmmu_ss.add(when: 'CONFIG_M48T59', if_true: files('m48t59.c'))
-specific_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c'))
+softmmu_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c'))
 softmmu_ss.add(when: 'CONFIG_TWL92230', if_true: files('twl92230.c'))
 softmmu_ss.add(when: ['CONFIG_ISA_BUS', 'CONFIG_M48T59'], if_true: files('m48t59-isa.c'))
 softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-rtc.c'))
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/3] qapi: Move RTC_CHANGE back out of target schema
  2022-02-21 19:21 ` [PATCH v2 1/3] " Peter Maydell
@ 2022-02-21 19:27   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 19:27 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

On 21/2/22 20:21, Peter Maydell wrote:
> This commit effectively reverts commit 183e4281a30962, which moved
> the RTC_CHANGE event to the target schema.  That change was an
> attempt to make the event target-specific to improve introspection,
> but the event isn't really target-specific: it's machine or device
> specific.  Putting RTC_CHANGE in the target schema with an ifdef list
> reduces maintainability (by adding an if: list with a long list of
> targets that needs to be manually updated as architectures are added
> or removed or as new devices gain the RTC_CHANGE functionality) and
> increases compile time (by preventing RTC devices which emit the
> event from being "compile once" rather than "compile once per
> target", because qapi-events-misc-target.h uses TARGET_* ifdefs,
> which are poisoned in "compile once" files.)
> 
> Move RTC_CHANGE back to misc.json.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Acked-by: Greg Kurz <groug@kaod.org>
> ---
>   qapi/misc-target.json | 33 ---------------------------------
>   qapi/misc.json        | 22 ++++++++++++++++++++++
>   hw/ppc/spapr_rtc.c    |  2 +-
>   hw/rtc/mc146818rtc.c  |  2 +-
>   hw/rtc/pl031.c        |  2 +-
>   5 files changed, 25 insertions(+), 36 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event
  2022-02-21 19:21 ` [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event Peter Maydell
@ 2022-02-21 19:28   ` Philippe Mathieu-Daudé
  2022-02-22 11:22   ` Markus Armbruster
  1 sibling, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 19:28 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

On 21/2/22 20:21, Peter Maydell wrote:
> The RTC_CHANGE event's documentation is missing some details:
>   * the offset argument is in units of seconds
>   * it isn't guaranteed that the RTC will implement the event
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> v1->v2: add the "RTC might not implement this" note
> ---
>   qapi/misc.json | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/3] hw/rtc: Compile pl031 once-only
  2022-02-21 19:21 ` [PATCH v2 3/3] hw/rtc: Compile pl031 once-only Peter Maydell
@ 2022-02-21 19:28   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-21 19:28 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

On 21/2/22 20:21, Peter Maydell wrote:
> Now that the RTC_CHANGE event is no longer target-specific,
> we can move the pl031 back to a compile-once source file
> rather than a compile-per-target one.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/rtc/meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
                   ` (2 preceding siblings ...)
  2022-02-21 19:21 ` [PATCH v2 3/3] hw/rtc: Compile pl031 once-only Peter Maydell
@ 2022-02-21 20:11 ` Eric Auger
  2022-02-22 12:02 ` [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path Markus Armbruster
  2022-02-25  8:38 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Markus Armbruster
  5 siblings, 0 replies; 18+ messages in thread
From: Eric Auger @ 2022-02-21 20:11 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Eric Blake, Markus Armbruster

Hi Peter,

On 2/21/22 8:21 PM, Peter Maydell wrote:
> This patchset moves RTC_CHANGE back to misc.json, effectively
> reverting commit 183e4281a30962, which moved the RTC_CHANGE event to
> the target schema.  That change was an attempt to make the event
> target-specific to improve introspection, but the event isn't really
> target-specific: it's machine or device specific.  Putting RTC_CHANGE
> in the target schema with an ifdef list reduces maintainability (by
> adding an if: list with a long list of targets that needs to be
> manually updated as architectures are added or removed or as new
> devices gain the RTC_CHANGE functionality) and increases compile time
> (by preventing RTC devices which emit the event from being "compile
> once" rather than "compile once per target", because
> qapi-events-misc-target.h uses TARGET_* ifdefs, which are poisoned in
> "compile once" files.)
> 
> Patch 2 fixes some minor documentation issues for the RTC_CHANGE
> event, noticed during development of the patchset.
> 
> Patch 3 makes the pl031 a build-once file again, which was the
> initial motivation for the series.
> 
> Changes v1->v2:
>  * patch 1 needs to change the #include line for pl031.c, now that
>    the change to make that device emit RTC_CHANGE has landed upstream
>  * patch 2 now also notes in the RTC_CHANGE documentation that
>    not all devices/systems will emit the event (suggested by Markus)
>  * patch 3 is new

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks!

Eric
> 
> My default assumption is that this series will go in via the
> qapi tree; let me know if you'd prefer me to take it via
> target-arm instead.
> 
> thanks
> -- PMM
> 
> Peter Maydell (3):
>   qapi: Move RTC_CHANGE back out of target schema
>   qapi: Document some missing details of RTC_CHANGE event
>   hw/rtc: Compile pl031 once-only
> 
>  qapi/misc-target.json | 33 ---------------------------------
>  qapi/misc.json        | 24 ++++++++++++++++++++++++
>  hw/ppc/spapr_rtc.c    |  2 +-
>  hw/rtc/mc146818rtc.c  |  2 +-
>  hw/rtc/pl031.c        |  2 +-
>  hw/rtc/meson.build    |  2 +-
>  6 files changed, 28 insertions(+), 37 deletions(-)
> 



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event
  2022-02-21 19:21 ` [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event Peter Maydell
  2022-02-21 19:28   ` Philippe Mathieu-Daudé
@ 2022-02-22 11:22   ` Markus Armbruster
  1 sibling, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2022-02-22 11:22 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, Eric Blake, qemu-devel

Peter Maydell <peter.maydell@linaro.org> writes:

> The RTC_CHANGE event's documentation is missing some details:
>  * the offset argument is in units of seconds
>  * it isn't guaranteed that the RTC will implement the event
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> v1->v2: add the "RTC might not implement this" note
> ---
>  qapi/misc.json | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 7a70eaa3ffc..0ab235e41f7 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -533,10 +533,12 @@
>  #
>  # Emitted when the guest changes the RTC time.
>  #
> -# @offset: offset between base RTC clock (as specified by -rtc base), and
> -#          new RTC clock value
> +# @offset: offset in seconds between base RTC clock (as specified
> +#          by -rtc base), and new RTC clock value
>  #
>  # Note: This event is rate-limited.
> +#       It is not guaranteed that the RTC in the system implements
> +#       this event, or even that the system has an RTC at all.
>  #
>  # Since: 0.13
>  #

Reviewed-by: Markus Armbruster <armbru@redhat.com>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
                   ` (3 preceding siblings ...)
  2022-02-21 20:11 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Eric Auger
@ 2022-02-22 12:02 ` Markus Armbruster
  2022-02-22 12:56   ` Philippe Mathieu-Daudé
  2022-02-23 13:46   ` Markus Armbruster
  2022-02-25  8:38 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Markus Armbruster
  5 siblings, 2 replies; 18+ messages in thread
From: Markus Armbruster @ 2022-02-22 12:02 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Peter Maydell, Michael S. Tsirkin, Daniel Henrique Barboza,
	qemu-devel, Greg Kurz, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
the RTC supports the event).  What if there's more than one RTC?
Which one changed?  New @qom-path identifies it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
RFC because it's compile-tested only.  Worthwhile?  Let me know what you
think.

 qapi/misc.json       | 4 +++-
 hw/ppc/spapr_rtc.c   | 4 +++-
 hw/rtc/mc146818rtc.c | 3 ++-
 hw/rtc/pl031.c       | 3 ++-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/qapi/misc.json b/qapi/misc.json
index 0ab235e41f..b83cc39029 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -536,6 +536,8 @@
 # @offset: offset in seconds between base RTC clock (as specified
 #          by -rtc base), and new RTC clock value
 #
+# @qom-path: path to the RTC object in the QOM tree
+#
 # Note: This event is rate-limited.
 #       It is not guaranteed that the RTC in the system implements
 #       this event, or even that the system has an RTC at all.
@@ -550,4 +552,4 @@
 #
 ##
 { 'event': 'RTC_CHANGE',
-  'data': { 'offset': 'int' } }
+  'data': { 'offset': 'int', 'qom-path': 'str' } }
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 79677cf550..d55b4b0c50 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -97,6 +97,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, SpaprMachineState *spapr,
                                  uint32_t nret, target_ulong rets)
 {
     SpaprRtcState *rtc = &spapr->rtc;
+    g_autofree const char *qom_path = NULL;
     struct tm tm;
     time_t new_s;
     int64_t host_ns;
@@ -120,7 +121,8 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, SpaprMachineState *spapr,
     }
 
     /* Generate a monitor event for the change */
-    qapi_event_send_rtc_change(qemu_timedate_diff(&tm));
+    qom_path = object_get_canonical_path(OBJECT(rtc));
+    qapi_event_send_rtc_change(qemu_timedate_diff(&tm), qom_path);
 
     host_ns = qemu_clock_get_ns(rtc_clock);
 
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 57c514e15c..ac9a60c90e 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -611,12 +611,13 @@ static void rtc_get_time(RTCState *s, struct tm *tm)
 static void rtc_set_time(RTCState *s)
 {
     struct tm tm;
+    g_autofree const char *qom_path = object_get_canonical_path(OBJECT(s));
 
     rtc_get_time(s, &tm);
     s->base_rtc = mktimegm(&tm);
     s->last_update = qemu_clock_get_ns(rtc_clock);
 
-    qapi_event_send_rtc_change(qemu_timedate_diff(&tm));
+    qapi_event_send_rtc_change(qemu_timedate_diff(&tm), qom_path);
 }
 
 static void rtc_set_cmos(RTCState *s, const struct tm *tm)
diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c
index 60167c778f..b01d0e75d1 100644
--- a/hw/rtc/pl031.c
+++ b/hw/rtc/pl031.c
@@ -138,12 +138,13 @@ static void pl031_write(void * opaque, hwaddr offset,
 
     switch (offset) {
     case RTC_LR: {
+        g_autofree const char *qom_path = object_get_canonical_path(opaque);
         struct tm tm;
 
         s->tick_offset += value - pl031_get_count(s);
 
         qemu_get_timedate(&tm, s->tick_offset);
-        qapi_event_send_rtc_change(qemu_timedate_diff(&tm));
+        qapi_event_send_rtc_change(qemu_timedate_diff(&tm), qom_path);
 
         pl031_set_alarm(s);
         break;
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 12:02 ` [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path Markus Armbruster
@ 2022-02-22 12:56   ` Philippe Mathieu-Daudé
  2022-02-22 13:06     ` Peter Maydell
  2022-02-22 15:04     ` Markus Armbruster
  2022-02-23 13:46   ` Markus Armbruster
  1 sibling, 2 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-22 12:56 UTC (permalink / raw)
  To: Markus Armbruster, Peter Maydell
  Cc: Michael S. Tsirkin, Daniel Henrique Barboza, Greg Kurz,
	qemu-devel, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

Hi Markus,

On 22/2/22 13:02, Markus Armbruster wrote:
> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
> the RTC supports the event).  What if there's more than one RTC?

w.r.t. RTC, a machine having multiple RTC devices is silly...

Assuming one wants to emulate that; shouldn't all QMP events have a
qom-path by default? Or have a generic "event-from-multiple-sources"
flag which automatically add this field?

> Which one changed?  New @qom-path identifies it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> RFC because it's compile-tested only.  Worthwhile?  Let me know what you
> think.
> 
>   qapi/misc.json       | 4 +++-
>   hw/ppc/spapr_rtc.c   | 4 +++-
>   hw/rtc/mc146818rtc.c | 3 ++-
>   hw/rtc/pl031.c       | 3 ++-
>   4 files changed, 10 insertions(+), 4 deletions(-)


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 12:56   ` Philippe Mathieu-Daudé
@ 2022-02-22 13:06     ` Peter Maydell
  2022-02-22 15:47       ` Philippe Mathieu-Daudé
  2022-02-23 18:00       ` Cédric Le Goater
  2022-02-22 15:04     ` Markus Armbruster
  1 sibling, 2 replies; 18+ messages in thread
From: Peter Maydell @ 2022-02-22 13:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Michael S. Tsirkin, Markus Armbruster, Daniel Henrique Barboza,
	qemu-devel, Greg Kurz, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

On Tue, 22 Feb 2022 at 12:56, Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
> On 22/2/22 13:02, Markus Armbruster wrote:
> > Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
> > the RTC supports the event).  What if there's more than one RTC?
>
> w.r.t. RTC, a machine having multiple RTC devices is silly...

I don't think we have any examples in the tree currently, but
I bet real hardware like that does exist: the most plausible
thing would be a board where there's an RTC built into the SoC
but the board designers put an external RTC on the board (perhaps
because it was better/more accurate/easier to make battery-backed).

In fact, here's an old bug report from a user trying to get
their Debian system to use the battery-backed RTC as the
"real" one rather than the non-battery-backed RTC device
that's also part of the arm board they're using:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445

-- PMM


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 12:56   ` Philippe Mathieu-Daudé
  2022-02-22 13:06     ` Peter Maydell
@ 2022-02-22 15:04     ` Markus Armbruster
  2022-02-22 15:47       ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 18+ messages in thread
From: Markus Armbruster @ 2022-02-22 15:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Daniel Henrique Barboza,
	Greg Kurz, qemu-devel, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> writes:

> Hi Markus,
>
> On 22/2/22 13:02, Markus Armbruster wrote:
>> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
>> the RTC supports the event).  What if there's more than one RTC?
>
> w.r.t. RTC, a machine having multiple RTC devices is silly...
>
> Assuming one wants to emulate that; shouldn't all QMP events have a
> qom-path by default? Or have a generic "event-from-multiple-sources"
> flag which automatically add this field?

Not all events originate from a device, or even a QOM object.

The ones that do could all use a qom-path member, I guess.

[...]



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 15:04     ` Markus Armbruster
@ 2022-02-22 15:47       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-22 15:47 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Peter Maydell, Michael S. Tsirkin, Daniel Henrique Barboza,
	Greg Kurz, qemu-devel, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

On 22/2/22 16:04, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> writes:
> 
>> Hi Markus,
>>
>> On 22/2/22 13:02, Markus Armbruster wrote:
>>> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
>>> the RTC supports the event).  What if there's more than one RTC?
>>
>> w.r.t. RTC, a machine having multiple RTC devices is silly...
>>
>> Assuming one wants to emulate that; shouldn't all QMP events have a
>> qom-path by default? Or have a generic "event-from-multiple-sources"
>> flag which automatically add this field?
> 
> Not all events originate from a device, or even a QOM object.

OK.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> The ones that do could all use a qom-path member, I guess.
> 
> [...]
> 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 13:06     ` Peter Maydell
@ 2022-02-22 15:47       ` Philippe Mathieu-Daudé
  2022-02-23 18:00       ` Cédric Le Goater
  1 sibling, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-22 15:47 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Michael S. Tsirkin, Markus Armbruster, Daniel Henrique Barboza,
	qemu-devel, Greg Kurz, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

On 22/2/22 14:06, Peter Maydell wrote:
> On Tue, 22 Feb 2022 at 12:56, Philippe Mathieu-Daudé
> <philippe.mathieu.daude@gmail.com> wrote:
>> On 22/2/22 13:02, Markus Armbruster wrote:
>>> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
>>> the RTC supports the event).  What if there's more than one RTC?
>>
>> w.r.t. RTC, a machine having multiple RTC devices is silly...
> 
> I don't think we have any examples in the tree currently, but
> I bet real hardware like that does exist: the most plausible
> thing would be a board where there's an RTC built into the SoC
> but the board designers put an external RTC on the board (perhaps
> because it was better/more accurate/easier to make battery-backed).
> 
> In fact, here's an old bug report from a user trying to get
> their Debian system to use the battery-backed RTC as the
> "real" one rather than the non-battery-backed RTC device
> that's also part of the arm board they're using:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445

OK, thanks for this pointer.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 12:02 ` [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path Markus Armbruster
  2022-02-22 12:56   ` Philippe Mathieu-Daudé
@ 2022-02-23 13:46   ` Markus Armbruster
  1 sibling, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2022-02-23 13:46 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Michael S. Tsirkin, Daniel Henrique Barboza, qemu-devel,
	Greg Kurz, qemu-arm, qemu-ppc, Cédric Le Goater,
	Paolo Bonzini, Eric Blake, David Gibson

Markus Armbruster <armbru@redhat.com> writes:

> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
> the RTC supports the event).  What if there's more than one RTC?
> Which one changed?  New @qom-path identifies it.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> RFC because it's compile-tested only.  Worthwhile?  Let me know what you
> think.

Passes manual testing with mc146818rtc.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
  2022-02-22 13:06     ` Peter Maydell
  2022-02-22 15:47       ` Philippe Mathieu-Daudé
@ 2022-02-23 18:00       ` Cédric Le Goater
  1 sibling, 0 replies; 18+ messages in thread
From: Cédric Le Goater @ 2022-02-23 18:00 UTC (permalink / raw)
  To: Peter Maydell, Philippe Mathieu-Daudé
  Cc: Michael S. Tsirkin, Markus Armbruster, Daniel Henrique Barboza,
	qemu-devel, Greg Kurz, qemu-arm, qemu-ppc, Paolo Bonzini,
	Eric Blake, David Gibson

On 2/22/22 14:06, Peter Maydell wrote:
> On Tue, 22 Feb 2022 at 12:56, Philippe Mathieu-Daudé
> <philippe.mathieu.daude@gmail.com> wrote:
>> On 22/2/22 13:02, Markus Armbruster wrote:
>>> Event RTC_CHANGE is "emitted when the guest changes the RTC time" (and
>>> the RTC supports the event).  What if there's more than one RTC?
>>
>> w.r.t. RTC, a machine having multiple RTC devices is silly...
> 
> I don't think we have any examples in the tree currently, but
> I bet real hardware like that does exist: the most plausible
> thing would be a board where there's an RTC built into the SoC
> but the board designers put an external RTC on the board (perhaps
> because it was better/more accurate/easier to make battery-backed).

Yes. like Aspeed machines.

C.


> 
> In fact, here's an old bug report from a user trying to get
> their Debian system to use the battery-backed RTC as the
> "real" one rather than the non-battery-backed RTC device
> that's also part of the arm board they're using:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445
> 
> -- PMM



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema
  2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
                   ` (4 preceding siblings ...)
  2022-02-22 12:02 ` [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path Markus Armbruster
@ 2022-02-25  8:38 ` Markus Armbruster
  5 siblings, 0 replies; 18+ messages in thread
From: Markus Armbruster @ 2022-02-25  8:38 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, Eric Blake, qemu-devel, Markus Armbruster

Peter Maydell <peter.maydell@linaro.org> writes:

> This patchset moves RTC_CHANGE back to misc.json, effectively
> reverting commit 183e4281a30962, which moved the RTC_CHANGE event to
> the target schema.  That change was an attempt to make the event
> target-specific to improve introspection, but the event isn't really
> target-specific: it's machine or device specific.  Putting RTC_CHANGE
> in the target schema with an ifdef list reduces maintainability (by
> adding an if: list with a long list of targets that needs to be
> manually updated as architectures are added or removed or as new
> devices gain the RTC_CHANGE functionality) and increases compile time
> (by preventing RTC devices which emit the event from being "compile
> once" rather than "compile once per target", because
> qapi-events-misc-target.h uses TARGET_* ifdefs, which are poisoned in
> "compile once" files.)
>
> Patch 2 fixes some minor documentation issues for the RTC_CHANGE
> event, noticed during development of the patchset.
>
> Patch 3 makes the pl031 a build-once file again, which was the
> initial motivation for the series.

Queued including my PATCH 4.  Happy to unqueue it if there are
objections, or the entire thing if you'd rather take it through the ARM
tree.  Thanks!



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-25  9:54 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 19:21 [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Peter Maydell
2022-02-21 19:21 ` [PATCH v2 1/3] " Peter Maydell
2022-02-21 19:27   ` Philippe Mathieu-Daudé
2022-02-21 19:21 ` [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event Peter Maydell
2022-02-21 19:28   ` Philippe Mathieu-Daudé
2022-02-22 11:22   ` Markus Armbruster
2022-02-21 19:21 ` [PATCH v2 3/3] hw/rtc: Compile pl031 once-only Peter Maydell
2022-02-21 19:28   ` Philippe Mathieu-Daudé
2022-02-21 20:11 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Eric Auger
2022-02-22 12:02 ` [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path Markus Armbruster
2022-02-22 12:56   ` Philippe Mathieu-Daudé
2022-02-22 13:06     ` Peter Maydell
2022-02-22 15:47       ` Philippe Mathieu-Daudé
2022-02-23 18:00       ` Cédric Le Goater
2022-02-22 15:04     ` Markus Armbruster
2022-02-22 15:47       ` Philippe Mathieu-Daudé
2022-02-23 13:46   ` Markus Armbruster
2022-02-25  8:38 ` [PATCH v2 0/3] qapi: Move RTC_CHANGE back out of target schema Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.