qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Damien Hedde <damien.hedde@greensocs.com>
To: qemu-devel@nongnu.org
Cc: Damien Hedde <damien.hedde@greensocs.com>,
	peter.maydell@linaro.org, edgar.iglesias@xilinx.com,
	berrange@redhat.com, ehabkost@redhat.com,
	mark.burton@greensocs.com, pbonzini@redhat.com,
	philmd@redhat.com, david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH v4 10/10] docs/devel/reset.txt: add documentation about warm reset
Date: Wed, 21 Aug 2019 18:33:41 +0200	[thread overview]
Message-ID: <20190821163341.16309-11-damien.hedde@greensocs.com> (raw)
In-Reply-To: <20190821163341.16309-1-damien.hedde@greensocs.com>

Complete the documentation with the handling of several reset types
(cold and warm).

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
 docs/devel/reset.txt | 55 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/docs/devel/reset.txt b/docs/devel/reset.txt
index 77ff29b3d7..ed1a72566d 100644
--- a/docs/devel/reset.txt
+++ b/docs/devel/reset.txt
@@ -31,16 +31,21 @@ makes no difference. But there can be some; some configuration may be kept when
 applying a warm reset for example.
 
 The Resettable interface handles reset kinds with an enum. For now only cold
-reset is defined, others may be added later.
+and warm reset are defined, others may be added later.
 ```
 typedef enum ResetType {
     RESET_TYPE_COLD,
+    RESET_TYPE_WARM,
 } ResetType;
 ```
 
 In qemu, RESET_TYPE_COLD means we reset to the initial state corresponding to
 the start of qemu; this might differs from what is a read hardware cold reset.
 
+Although the interface can handle several kind of resets, these are not totally
+independant and disjoint. There are some constraints; these are explained below
+in the "multi-phase" section.
+
 
 Triggering reset
 ----------------
@@ -49,21 +54,41 @@ This section documents the APIs which "users" of a resettable object should use
 to control it. All resettable control functions must be called while holding
 the iothread lock.
 
-You can trigger a reset event on a resettable object with resettable_reset().
-The object will be instantly reset.
+A resettable object can be put into its "in reset" state and held there
+indefinitely.
+
+You must call resettable_assert_reset() to put an object in reset. It will stay
+in this state until you eventually call resettable_deassert_reset(). Care must
+be taken to call resettable_deassert_reset() once and only once per call of
+resettable_assert_reset().
+
+```resettable_assert_reset(Object *obj, ResetType type);```
+The parameter "obj" is an object implementing the Resettable interface.
+The parameter "type" gives the type of reset you want to trigger.
+
+```resettable_deassert_reset(Object *obj);```
+The parameter "obj" is an object implementing the Resettable interface.
+
+If you want to just trigger a reset event but not leave the object in reset for
+any period of time, you can use resettable_reset(), which is a convenience
+function identical in behaviour to calling resettable_assert() and then
+immediately calling resettable_deassert().
 
 ```void resettable_reset(Object *obj, ResetType type);```
 The parameter "obj" is an object implementing the Resettable interface.
 The parameter "type" gives the type of reset you want to trigger.
 
 It is possible to interleave multiple calls to
+ - resettable_assert_reset(),
+ - resettable_deassert_reset(),
  - resettable_reset().
 
 There may be several reset sources/controllers of a given object. The interface
 handles everything and the different reset controllers do not need to know
 anything about each others. The object will leave reset state only when each
 other controllers end their reset operation. This point is handled by
-maintaining a count of reset.
+maintaining a count of reset; this is why resettable_deassert_reset() must be
+called once and only once per resettable_assert_reset().
 
 Note that it is a programming error to call a resettable function on a
 non-Resettable object and it will trigger a run time assert error. Since most
@@ -74,6 +99,8 @@ For Devices and Buses, the following helper functions exists:
 ```
 void device_cold_reset(Device *dev);
 void bus_cold_reset(Bus *bus);
+void device_warm_reset(Device *dev);
+void bus_warm_reset(Bus *bus);
 ```
 
 These are simple wrappers around resettable_reset() function; they only cast the
@@ -123,6 +150,25 @@ The exit phase is executed only when the last reset operation ends. Therefore
 the object has not to care how many reset controllers it has and how many of
 them have started a reset.
 
+An exception to that is when entering a new reset type AND if there was no
+previous cold reset; in that case, init and hold methods are executed again
+because the different reset type may reset more things than the previous one
+has done.
+
+For example if some controller has started a RESET_TYPE_WARM with
+resettable_assert_reset() on a device and another controller does a
+device_cold_reset() on the same object, then the init phase is executed with
+RESET_TYPE_COLD as an argument and then the hold phase.
+If the first reset was a cold reset, then the warm reset would have triggered
+nothing because the cold reset is "stronger".
+
+Note also that the exit phase will never be executed twice; it will only be
+executed when all reset operation are closed, independently of the number of
+reset types that were issued. This is a limitation of the interface, there is
+only a global count of reset (not a count per reset type). The consequence is
+that the different reset types must be close enough in behavior to not require
+different exit phases.
+
 
 Handling reset in a new resettable object
 -----------------------------------------
@@ -203,6 +249,7 @@ interface.
 typedef struct ResetState {
     uint32_t count;
     bool hold_phase_needed;
+    ResetType type;
 } ResetState;
 
 typedef ResetState *(*ResettableGetState)(Object *obj);
-- 
2.22.0



  parent reply	other threads:[~2019-08-21 16:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 16:33 [Qemu-devel] [PATCH v4 00/10] Multi-phase reset mechanism Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 01/10] add device_legacy_reset function to prepare for reset api change Damien Hedde
2019-08-24  9:50   ` David Gibson
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 02/10] hw/core: create Resettable QOM interface Damien Hedde
2019-09-11  8:06   ` David Gibson
2019-09-11 14:56     ` Damien Hedde
2019-09-18  9:11       ` David Gibson
2019-09-24 11:21         ` Damien Hedde
2019-09-27 13:07           ` Peter Maydell
2019-10-10  9:18             ` Damien Hedde
2024-04-11 13:43   ` Peter Maydell
2024-04-11 17:23     ` Philippe Mathieu-Daudé
2024-04-12 13:05       ` Peter Maydell
2024-04-12 13:38         ` Edgar E. Iglesias
2024-04-12 16:12           ` Peter Maydell
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 03/10] hw/core: add Resettable interface in Bus and Device classes Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 04/10] docs/devel/reset.txt: create doc about Resettable interface Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 05/10] vl.c: replace deprecated qbus_reset_all registration Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 06/10] hw/s390x/ipl.c: " Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 07/10] hw/core/qdev: replace deprecated device_legacy_reset when hotplugging device Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 08/10] hw/core/resettable: add support for warm reset Damien Hedde
2020-05-10 20:17   ` Philippe Mathieu-Daudé
2020-05-11  9:37     ` Damien Hedde
2019-08-21 16:33 ` [Qemu-devel] [PATCH v4 09/10] hw/core/: add warm reset helpers for devices and buses Damien Hedde
2019-08-21 16:33 ` Damien Hedde [this message]
2019-08-21 17:09 ` [Qemu-devel] [PATCH v4 00/10] Multi-phase reset mechanism no-reply
2019-09-10 10:33 ` Damien Hedde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190821163341.16309-11-damien.hedde@greensocs.com \
    --to=damien.hedde@greensocs.com \
    --cc=berrange@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=edgar.iglesias@xilinx.com \
    --cc=ehabkost@redhat.com \
    --cc=mark.burton@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).