qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Ani Sinha <anisinha@redhat.com>
Subject: [PULL 32/46] hw/acpi: Insert an acpi-generic-node base under acpi-generic-initiator
Date: Tue, 4 Jun 2024 15:07:51 -0400	[thread overview]
Message-ID: <e786b417b7bb2207ad1833d0d64abe57043de8f5.1717527933.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1717527933.git.mst@redhat.com>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

This will simplify reuse when adding acpi-generic-port.
Note that some error_printf() messages will now print acpi-generic-node
whereas others will move to type specific cases in next patch so
are left alone for now.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20240524100507.32106-3-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/acpi/acpi_generic_initiator.h | 15 ++++-
 hw/acpi/acpi_generic_initiator.c         | 80 +++++++++++++++---------
 2 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acpi_generic_initiator.h
index a304bad73e..dd4be19c8f 100644
--- a/include/hw/acpi/acpi_generic_initiator.h
+++ b/include/hw/acpi/acpi_generic_initiator.h
@@ -8,15 +8,26 @@
 
 #include "qom/object_interfaces.h"
 
-#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator"
+/*
+ * Abstract type to be used as base for
+ * - acpi-generic-initiator
+ * - acpi-generic-port
+ */
+#define TYPE_ACPI_GENERIC_NODE "acpi-generic-node"
 
-typedef struct AcpiGenericInitiator {
+typedef struct AcpiGenericNode {
     /* private */
     Object parent;
 
     /* public */
     char *pci_dev;
     uint16_t node;
+} AcpiGenericNode;
+
+#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator"
+
+typedef struct AcpiGenericInitiator {
+    AcpiGenericNode parent;
 } AcpiGenericInitiator;
 
 /*
diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c
index 18a939b0e5..c054e0e27d 100644
--- a/hw/acpi/acpi_generic_initiator.c
+++ b/hw/acpi/acpi_generic_initiator.c
@@ -10,45 +10,61 @@
 #include "hw/pci/pci_device.h"
 #include "qemu/error-report.h"
 
-typedef struct AcpiGenericInitiatorClass {
+typedef struct AcpiGenericNodeClass {
     ObjectClass parent_class;
+} AcpiGenericNodeClass;
+
+typedef struct AcpiGenericInitiatorClass {
+     AcpiGenericNodeClass parent_class;
 } AcpiGenericInitiatorClass;
 
+OBJECT_DEFINE_ABSTRACT_TYPE(AcpiGenericNode, acpi_generic_node,
+                            ACPI_GENERIC_NODE, OBJECT)
+
+OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericNode, ACPI_GENERIC_NODE)
+
 OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator,
-                   ACPI_GENERIC_INITIATOR, OBJECT,
+                   ACPI_GENERIC_INITIATOR, ACPI_GENERIC_NODE,
                    { TYPE_USER_CREATABLE },
                    { NULL })
 
 OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR)
 
+static void acpi_generic_node_init(Object *obj)
+{
+    AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
+
+    gn->node = MAX_NODES;
+    gn->pci_dev = NULL;
+}
+
 static void acpi_generic_initiator_init(Object *obj)
 {
-    AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
+}
 
-    gi->node = MAX_NODES;
-    gi->pci_dev = NULL;
+static void acpi_generic_node_finalize(Object *obj)
+{
+    AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
+
+    g_free(gn->pci_dev);
 }
 
 static void acpi_generic_initiator_finalize(Object *obj)
 {
-    AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
-
-    g_free(gi->pci_dev);
 }
 
-static void acpi_generic_initiator_set_pci_device(Object *obj, const char *val,
-                                                  Error **errp)
+static void acpi_generic_node_set_pci_device(Object *obj, const char *val,
+                                             Error **errp)
 {
-    AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
+    AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
 
-    gi->pci_dev = g_strdup(val);
+    gn->pci_dev = g_strdup(val);
 }
-
-static void acpi_generic_initiator_set_node(Object *obj, Visitor *v,
-                                            const char *name, void *opaque,
-                                            Error **errp)
+static void acpi_generic_node_set_node(Object *obj, Visitor *v,
+                                       const char *name, void *opaque,
+                                       Error **errp)
 {
-    AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
+    AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
     MachineState *ms = MACHINE(qdev_get_machine());
     uint32_t value;
 
@@ -58,20 +74,24 @@ static void acpi_generic_initiator_set_node(Object *obj, Visitor *v,
 
     if (value >= MAX_NODES) {
         error_printf("%s: Invalid NUMA node specified\n",
-                     TYPE_ACPI_GENERIC_INITIATOR);
+                     TYPE_ACPI_GENERIC_NODE);
         exit(1);
     }
 
-    gi->node = value;
-    ms->numa_state->nodes[gi->node].has_gi = true;
+    gn->node = value;
+    ms->numa_state->nodes[gn->node].has_gi = true;
+}
+
+static void acpi_generic_node_class_init(ObjectClass *oc, void *data)
+{
+    object_class_property_add_str(oc, "pci-dev", NULL,
+        acpi_generic_node_set_pci_device);
+    object_class_property_add(oc, "node", "int", NULL,
+        acpi_generic_node_set_node, NULL, NULL);
 }
 
 static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data)
 {
-    object_class_property_add_str(oc, "pci-dev", NULL,
-        acpi_generic_initiator_set_pci_device);
-    object_class_property_add(oc, "node", "int", NULL,
-        acpi_generic_initiator_set_node, NULL, NULL);
 }
 
 /*
@@ -104,9 +124,9 @@ build_srat_generic_pci_initiator_affinity(GArray *table_data, int node,
 static int build_all_acpi_generic_initiators(Object *obj, void *opaque)
 {
     MachineState *ms = MACHINE(qdev_get_machine());
-    AcpiGenericInitiator *gi;
     GArray *table_data = opaque;
     PCIDeviceHandle dev_handle;
+    AcpiGenericNode *gn;
     PCIDevice *pci_dev;
     Object *o;
 
@@ -114,14 +134,14 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque)
         return 0;
     }
 
-    gi = ACPI_GENERIC_INITIATOR(obj);
-    if (gi->node >= ms->numa_state->num_nodes) {
+    gn = ACPI_GENERIC_NODE(obj);
+    if (gn->node >= ms->numa_state->num_nodes) {
         error_printf("%s: Specified node %d is invalid.\n",
-                     TYPE_ACPI_GENERIC_INITIATOR, gi->node);
+                     TYPE_ACPI_GENERIC_INITIATOR, gn->node);
         exit(1);
     }
 
-    o = object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL);
+    o = object_resolve_path_type(gn->pci_dev, TYPE_PCI_DEVICE, NULL);
     if (!o) {
         error_printf("%s: Specified device must be a PCI device.\n",
                      TYPE_ACPI_GENERIC_INITIATOR);
@@ -135,7 +155,7 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque)
                                    pci_dev->devfn);
 
     build_srat_generic_pci_initiator_affinity(table_data,
-                                              gi->node, &dev_handle);
+                                              gn->node, &dev_handle);
 
     return 0;
 }
-- 
MST



  parent reply	other threads:[~2024-06-04 19:11 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 19:05 [PULL 00/46] virtio: features,fixes Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 01/46] vhost: dirty log should be per backend type Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 02/46] vhost: Perform memory section dirty scans once per iteration Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 03/46] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 04/46] virtio-pci: Fix the use of an uninitialized irqfd Michael S. Tsirkin
2024-06-05  7:27   ` Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 05/46] virtio/virtio-pci: Handle extra notification data Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 06/46] virtio: Prevent creation of device using notification-data with ioeventfd Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 07/46] virtio-mmio: Handle extra notification data Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 08/46] virtio-ccw: " Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 09/46] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 10/46] Fix vhost user assertion when sending more than one fd Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 11/46] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 12/46] hw/virtio: Fix obtain the buffer id from the last descriptor Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 13/46] virtio-pci: only reset pm state during resetting Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 14/46] vhost-user-gpu: fix import of DMABUF Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 15/46] Revert "vhost-user: fix lost reconnect" Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 16/46] vhost-user: fix lost reconnect again Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 17/46] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Michael S. Tsirkin
2024-06-04 19:06 ` [PULL 18/46] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 19/46] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 20/46] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 21/46] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 22/46] hw/mem/cxl_type3: Add support to create DC regions to " Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 23/46] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 24/46] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 25/46] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 26/46] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 27/46] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 28/46] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 29/46] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 30/46] hw/mem/cxl_type3: Allow to release extent superset in QMP interface Michael S. Tsirkin
2024-06-04 19:07 ` [PULL 31/46] hw/acpi/GI: Fix trivial parameter alignment issue Michael S. Tsirkin
2024-06-04 19:07 ` Michael S. Tsirkin [this message]
2024-06-04 19:07 ` [PULL 33/46] hw/acpi: Generic Port Affinity Structure support Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 34/46] bios-tables-test: Allow for new acpihmat-generic-x test data Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 35/46] bios-tables-test: Add complex SRAT / HMAT test for GI GP Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 36/46] bios-tables-test: Add data for complex numa test (GI, GP etc) Michael S. Tsirkin
2024-06-05 14:39   ` Richard Henderson
2024-06-05 15:27     ` Jonathan Cameron via
2024-06-05 15:49       ` Jonathan Cameron via
2024-06-05 16:01       ` Richard Henderson
2024-06-05 16:08         ` Jonathan Cameron via
2024-06-05 16:11           ` Jonathan Cameron via
2024-06-05 16:54             ` Richard Henderson
2024-06-05 17:19               ` Jonathan Cameron via
2024-06-04 19:08 ` [PULL 37/46] scripts/update-linux-headers: Copy setup_data.h to correct directory Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 38/46] linux-headers: update to 6.10-rc1 Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 39/46] hw/misc/pvpanic: centralize definition of supported events Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 40/46] tests/qtest/pvpanic: use centralized " Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 41/46] hw/misc/pvpanic: add support for normal shutdowns Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 42/46] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 43/46] tests/qtest/pvpanic: add tests for pvshutdown event Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 44/46] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 45/46] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() Michael S. Tsirkin
2024-06-04 19:08 ` [PULL 46/46] hw/cxl: Fix read from bogus memory Michael S. Tsirkin
2024-06-05  7:27 ` [PULL 00/46] virtio: features,fixes Michael S. Tsirkin
2024-06-05 14:44   ` Richard Henderson
2024-06-25 13:06 ` Peter Maydell
2024-06-25 14:01   ` Michael S. Tsirkin

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=e786b417b7bb2207ad1833d0d64abe57043de8f5.1717527933.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=anisinha@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).