qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qdev: not add devices to bus in reverse order
@ 2024-01-09  9:52 kai.kang
  2024-01-17  4:23 ` Kai
  0 siblings, 1 reply; 9+ messages in thread
From: kai.kang @ 2024-01-09  9:52 UTC (permalink / raw)
  To: qemu-devel

From: Kai Kang <kai.kang@windriver.com>

When this section of source codes were added via commit:

* 02e2da45c4 Add common BusState

it added devices to bus with LIST_INSERT_HEAD() which operated on the
single direction list. It didn't have something like LIST_INSERT_TAIL()
at that time and kept that way when turned to QTAILQ.

Then it causes the fist device in qemu command line inserted at the end
of the bus child link list. And when realize them, the first device will
be the last one to be realized.

Replace QTAILQ_INSERT_HEAD_RCU() with QTAILQ_INSERT_TAIL_RCU() to make
sure that devices are added to bus with the sequence in the command
line.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 hw/core/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 43d863b0c5..5e2ff43715 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -89,7 +89,7 @@ static void bus_add_child(BusState *bus, DeviceState *child)
     kid->child = child;
     object_ref(OBJECT(kid->child));
 
-    QTAILQ_INSERT_HEAD_RCU(&bus->children, kid, sibling);
+    QTAILQ_INSERT_TAIL_RCU(&bus->children, kid, sibling);
 
     /* This transfers ownership of kid->child to the property.  */
     snprintf(name, sizeof(name), "child[%d]", kid->index);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH] qdev: not add devices to bus in reverse order
@ 2024-01-09  9:20 Kai Kang
  2024-01-17 17:31 ` Peter Maydell
  0 siblings, 1 reply; 9+ messages in thread
From: Kai Kang @ 2024-01-09  9:20 UTC (permalink / raw)
  To: qemu-devel

When this section of source codes were added via commit:

* 02e2da45c4 Add common BusState

it added devices to bus with LIST_INSERT_HEAD() which operated on the
single direction list. It didn't have something like LIST_INSERT_TAIL()
at that time and kept that way when turned to QTAILQ.

Then it causes the fist device in qemu command line inserted at the end
of the bus child link list. And when realize them, the first device will
be the last one to be realized.

Replace QTAILQ_INSERT_HEAD_RCU() with QTAILQ_INSERT_TAIL_RCU() to make
sure that devices are added to bus with the sequence in the command
line.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 hw/core/qdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 43d863b0c5..5e2ff43715 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -89,7 +89,7 @@ static void bus_add_child(BusState *bus, DeviceState *child)
     kid->child = child;
     object_ref(OBJECT(kid->child));
 
-    QTAILQ_INSERT_HEAD_RCU(&bus->children, kid, sibling);
+    QTAILQ_INSERT_TAIL_RCU(&bus->children, kid, sibling);
 
     /* This transfers ownership of kid->child to the property.  */
     snprintf(name, sizeof(name), "child[%d]", kid->index);
-- 
2.34.1



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

end of thread, other threads:[~2024-01-24 16:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-09  9:52 [PATCH] qdev: not add devices to bus in reverse order kai.kang
2024-01-17  4:23 ` Kai
  -- strict thread matches above, loose matches on Subject: below --
2024-01-09  9:20 Kai Kang
2024-01-17 17:31 ` Peter Maydell
2024-01-18  6:48   ` Kai
2024-01-18 10:05     ` Peter Maydell
2024-01-18 12:07     ` Igor Mammedov
2024-01-22  1:59       ` Kai
2024-01-24 16:11         ` Igor Mammedov

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).