All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron via <qemu-arm@nongnu.org>
To: Jonathan Cameron via <qemu-devel@nongnu.org>
Cc: Ankit Agrawal <ankita@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"clg@redhat.com" <clg@redhat.com>,
	"shannon.zhaosl@gmail.com" <shannon.zhaosl@gmail.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"ani@anisinha.ca" <ani@anisinha.ca>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"eduardo@habkost.net" <eduardo@habkost.net>,
	"imammedo@redhat.com" <imammedo@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"david@redhat.com" <david@redhat.com>,
	"gshan@redhat.com" <gshan@redhat.com>,
	 Zhi Wang <zhiw@nvidia.com>, "Matt Ochs" <mochs@nvidia.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	Aniket Agashe <aniketa@nvidia.com>, Neo Jia <cjia@nvidia.com>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	"Tarun Gupta (SW-GPU)" <targupta@nvidia.com>,
	Vikram Sethi <vsethi@nvidia.com>,
	Andy Currid <acurrid@nvidia.com>,
	Dheeraj Nigam <dnigam@nvidia.com>, Uday Dhoke <udhoke@nvidia.com>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>
Subject: Re: [PATCH v7 2/2] hw/acpi: Implement the SRAT GI affinity structure
Date: Thu, 29 Feb 2024 15:59:10 +0000	[thread overview]
Message-ID: <20240229155910.00005186@huawei.com> (raw)
In-Reply-To: <20240227173621.00003694@Huawei.com>

On Tue, 27 Feb 2024 17:36:21 +0000
Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:

> On Tue, 27 Feb 2024 17:11:15 +0000
> Jonathan Cameron via <qemu-devel@nongnu.org> wrote:
> 
> > On Tue, 27 Feb 2024 08:37:15 +0000
> > Ankit Agrawal <ankita@nvidia.com> wrote:
> >   
> > > Thanks Jonathan for reviewing the change.
> > > 
> > > Comments inline.
> > >     
> > > >> The structure needs a PCI device handle [2] that consists of the device BDF.
> > > >> The vfio-pci device corresponding to the acpi-generic-initiator object is
> > > >> located to determine the BDF.
> > > >>
> > > >> [1] ACPI Spec 6.3, Section 5.2.16.6
> > > >> [2] ACPI Spec 6.3, Table 5.80
> > > >>
> > > >> Signed-off-by: Ankit Agrawal <ankita@nvidia.com>      
> > > >Hi Ankit,
> > > >
> > > > As the code stands the use of a list seems overkill.      
> > > 
> > > Yeah, I will try out your suggestion.
> > >     
> > > > Otherwise looks good to me.  I need Generic Ports support for CXL
> > > > stuff so will copy your approach for that as it's ended up nice
> > > > and simple.
> > > > 
> > > > Jonathan      
> > > 
> > > Nice, would be good to have uniform implementations.    
> > 
> > I've been messing around with this today.
> > 
> > They differ only very trivially.
> > 2 Options.
> > 1) Have acpi-generic-port inherit from acpi-generic-initiator.
> >    Works but implies a relationship that isn't really true.
> > 2) Add an abstract base class. I've called it acpi-generic-node
> >    and have bother acpi-generic-initiator and acpi-generic-port
> >    inherit from it.
> > 
> > The second feels more natural but is a tiny bit more code (a few
> > more empty init / finalize functions.
> > 
> > If we are going to end up with an abstract base 'object' it
> > will be cleaner to do this all as one series if you don't mind
> > carrying the generic port stuff as well? Or I can smash the
> > two series together and send out an updated version that hopefully
> > meets both our requirements (+ tests etc).
> > 
> > I'm just running tests against the CXL qos / generic port code
> > but assuming all goes well can share my additional changes
> > in next day or two.
> > 
> > Jonathan  
> 
> One more thing.  Right now we can't use Generic Initiators as
> HMAT initiators.  That also wants fixing given that's their
> normal usecase rather than what you are using them for so it
> should 'work'.

Something along the lines of this will do the job.


diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index 4173ef2afa..825cfe86bc 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -41,6 +41,7 @@ struct NodeInfo {
     struct HostMemoryBackend *node_memdev;
     bool present;
     bool has_cpu;
+    bool has_gi;
     uint8_t lb_info_provided;
     uint16_t initiator;
     uint8_t distance[MAX_NODES];
diff --git a/hw/acpi/acpi-generic-initiator.c b/hw/acpi/acpi-generic-initiator.c
index 9179590a42..8a67300320 100644
--- a/hw/acpi/acpi-generic-initiator.c
+++ b/hw/acpi/acpi-generic-initiator.c
@@ -6,6 +6,7 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/acpi-generic-initiator.h"
 #include "hw/pci/pci_device.h"
+#include "hw/boards.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qapi/visitor.h"
@@ -58,6 +59,7 @@ static void acpi_generic_node_set_node(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
+    MachineState *ms = MACHINE(qdev_get_machine());
     AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
     uint32_t value;
 
@@ -72,6 +74,10 @@ static void acpi_generic_node_set_node(Object *obj, Visitor *v,
     }
 
     gn->node = value;
+
+    if (object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) {
+        ms->numa_state->nodes[gn->node].has_gi = true;
+    }
 }
 
 static void acpi_generic_node_class_init(ObjectClass *oc, void *data)
diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
index b933ae3c06..9b1662b6b8 100644
--- a/hw/acpi/hmat.c
+++ b/hw/acpi/hmat.c
@@ -225,7 +225,7 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
     }
 
     for (i = 0; i < numa_state->num_nodes; i++) {
-        if (numa_state->nodes[i].has_cpu) {
+        if (numa_state->nodes[i].has_cpu || numa_state->nodes[i].has_gi) {
             initiator_list[num_initiator++] = i;
         }
     }
diff --git a/hw/core/numa.c b/hw/core/numa.c
index f08956ddb0..58a32f1564 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -229,7 +229,8 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node,
                    node->target, numa_state->num_nodes);
         return;
     }
-    if (!numa_info[node->initiator].has_cpu) {
+    if (!numa_info[node->initiator].has_cpu &&
+        !numa_info[node->initiator].has_gi) {
         error_setg(errp, "Invalid initiator=%d, it isn't an "
                    "initiator proximity domain", node->initiator);
         return;

> 
> Jonathan
> 
> > 
> > 
> >   
> 


WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Jonathan Cameron via <qemu-devel@nongnu.org>
Cc: Ankit Agrawal <ankita@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"clg@redhat.com" <clg@redhat.com>,
	"shannon.zhaosl@gmail.com" <shannon.zhaosl@gmail.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"ani@anisinha.ca" <ani@anisinha.ca>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"eduardo@habkost.net" <eduardo@habkost.net>,
	"imammedo@redhat.com" <imammedo@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"david@redhat.com" <david@redhat.com>,
	"gshan@redhat.com" <gshan@redhat.com>,
	 Zhi Wang <zhiw@nvidia.com>, "Matt Ochs" <mochs@nvidia.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	Aniket Agashe <aniketa@nvidia.com>, Neo Jia <cjia@nvidia.com>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	"Tarun Gupta (SW-GPU)" <targupta@nvidia.com>,
	Vikram Sethi <vsethi@nvidia.com>,
	Andy Currid <acurrid@nvidia.com>,
	Dheeraj Nigam <dnigam@nvidia.com>, Uday Dhoke <udhoke@nvidia.com>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>
Subject: Re: [PATCH v7 2/2] hw/acpi: Implement the SRAT GI affinity structure
Date: Thu, 29 Feb 2024 15:59:10 +0000	[thread overview]
Message-ID: <20240229155910.00005186@huawei.com> (raw)
In-Reply-To: <20240227173621.00003694@Huawei.com>

On Tue, 27 Feb 2024 17:36:21 +0000
Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:

> On Tue, 27 Feb 2024 17:11:15 +0000
> Jonathan Cameron via <qemu-devel@nongnu.org> wrote:
> 
> > On Tue, 27 Feb 2024 08:37:15 +0000
> > Ankit Agrawal <ankita@nvidia.com> wrote:
> >   
> > > Thanks Jonathan for reviewing the change.
> > > 
> > > Comments inline.
> > >     
> > > >> The structure needs a PCI device handle [2] that consists of the device BDF.
> > > >> The vfio-pci device corresponding to the acpi-generic-initiator object is
> > > >> located to determine the BDF.
> > > >>
> > > >> [1] ACPI Spec 6.3, Section 5.2.16.6
> > > >> [2] ACPI Spec 6.3, Table 5.80
> > > >>
> > > >> Signed-off-by: Ankit Agrawal <ankita@nvidia.com>      
> > > >Hi Ankit,
> > > >
> > > > As the code stands the use of a list seems overkill.      
> > > 
> > > Yeah, I will try out your suggestion.
> > >     
> > > > Otherwise looks good to me.  I need Generic Ports support for CXL
> > > > stuff so will copy your approach for that as it's ended up nice
> > > > and simple.
> > > > 
> > > > Jonathan      
> > > 
> > > Nice, would be good to have uniform implementations.    
> > 
> > I've been messing around with this today.
> > 
> > They differ only very trivially.
> > 2 Options.
> > 1) Have acpi-generic-port inherit from acpi-generic-initiator.
> >    Works but implies a relationship that isn't really true.
> > 2) Add an abstract base class. I've called it acpi-generic-node
> >    and have bother acpi-generic-initiator and acpi-generic-port
> >    inherit from it.
> > 
> > The second feels more natural but is a tiny bit more code (a few
> > more empty init / finalize functions.
> > 
> > If we are going to end up with an abstract base 'object' it
> > will be cleaner to do this all as one series if you don't mind
> > carrying the generic port stuff as well? Or I can smash the
> > two series together and send out an updated version that hopefully
> > meets both our requirements (+ tests etc).
> > 
> > I'm just running tests against the CXL qos / generic port code
> > but assuming all goes well can share my additional changes
> > in next day or two.
> > 
> > Jonathan  
> 
> One more thing.  Right now we can't use Generic Initiators as
> HMAT initiators.  That also wants fixing given that's their
> normal usecase rather than what you are using them for so it
> should 'work'.

Something along the lines of this will do the job.


diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index 4173ef2afa..825cfe86bc 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -41,6 +41,7 @@ struct NodeInfo {
     struct HostMemoryBackend *node_memdev;
     bool present;
     bool has_cpu;
+    bool has_gi;
     uint8_t lb_info_provided;
     uint16_t initiator;
     uint8_t distance[MAX_NODES];
diff --git a/hw/acpi/acpi-generic-initiator.c b/hw/acpi/acpi-generic-initiator.c
index 9179590a42..8a67300320 100644
--- a/hw/acpi/acpi-generic-initiator.c
+++ b/hw/acpi/acpi-generic-initiator.c
@@ -6,6 +6,7 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/acpi-generic-initiator.h"
 #include "hw/pci/pci_device.h"
+#include "hw/boards.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qapi/visitor.h"
@@ -58,6 +59,7 @@ static void acpi_generic_node_set_node(Object *obj, Visitor *v,
                                        const char *name, void *opaque,
                                        Error **errp)
 {
+    MachineState *ms = MACHINE(qdev_get_machine());
     AcpiGenericNode *gn = ACPI_GENERIC_NODE(obj);
     uint32_t value;
 
@@ -72,6 +74,10 @@ static void acpi_generic_node_set_node(Object *obj, Visitor *v,
     }
 
     gn->node = value;
+
+    if (object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) {
+        ms->numa_state->nodes[gn->node].has_gi = true;
+    }
 }
 
 static void acpi_generic_node_class_init(ObjectClass *oc, void *data)
diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
index b933ae3c06..9b1662b6b8 100644
--- a/hw/acpi/hmat.c
+++ b/hw/acpi/hmat.c
@@ -225,7 +225,7 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
     }
 
     for (i = 0; i < numa_state->num_nodes; i++) {
-        if (numa_state->nodes[i].has_cpu) {
+        if (numa_state->nodes[i].has_cpu || numa_state->nodes[i].has_gi) {
             initiator_list[num_initiator++] = i;
         }
     }
diff --git a/hw/core/numa.c b/hw/core/numa.c
index f08956ddb0..58a32f1564 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -229,7 +229,8 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node,
                    node->target, numa_state->num_nodes);
         return;
     }
-    if (!numa_info[node->initiator].has_cpu) {
+    if (!numa_info[node->initiator].has_cpu &&
+        !numa_info[node->initiator].has_gi) {
         error_setg(errp, "Invalid initiator=%d, it isn't an "
                    "initiator proximity domain", node->initiator);
         return;

> 
> Jonathan
> 
> > 
> > 
> >   
> 



  reply	other threads:[~2024-02-29 16:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 12:42 [PATCH v7 0/2] acpi: report numa nodes for device memory using GI ankita
2024-02-23 12:42 ` [PATCH v7 1/2] qom: new object to associate device to numa node ankita
2024-02-27 13:00   ` Jonathan Cameron via
2024-02-27 13:00     ` Jonathan Cameron via
2024-02-28  5:35     ` Ankit Agrawal
2024-02-28  7:35   ` Markus Armbruster
2024-02-28 13:55     ` Jonathan Cameron via
2024-02-28 13:55       ` Jonathan Cameron via
2024-02-28 16:08       ` Markus Armbruster
2024-02-28 16:50         ` Ankit Agrawal
2024-02-29 10:22           ` Jonathan Cameron via
2024-02-29 10:22             ` Jonathan Cameron via
2024-02-29 13:00             ` Ankit Agrawal
2024-02-29 16:32               ` Jonathan Cameron via
2024-02-29 16:32                 ` Jonathan Cameron via
2024-03-01  8:33                 ` Ankit Agrawal
2024-03-01 16:13                   ` Alex Williamson
2024-02-23 12:42 ` [PATCH v7 2/2] hw/acpi: Implement the SRAT GI affinity structure ankita
2024-02-26 16:34   ` Jonathan Cameron via
2024-02-26 16:34     ` Jonathan Cameron via
2024-02-26 16:42   ` Jonathan Cameron via
2024-02-26 16:42     ` Jonathan Cameron via
2024-02-27  8:37     ` Ankit Agrawal
2024-02-27 17:11       ` Jonathan Cameron via
2024-02-27 17:11         ` Jonathan Cameron via
2024-02-27 17:36         ` Jonathan Cameron via
2024-02-27 17:36           ` Jonathan Cameron via
2024-02-29 15:59           ` Jonathan Cameron via [this message]
2024-02-29 15:59             ` Jonathan Cameron via
2024-03-01  8:30             ` Ankit Agrawal
2024-02-29 11:43     ` Ankit Agrawal
2024-02-29 12:17       ` Jonathan Cameron via
2024-02-29 12:17         ` Jonathan Cameron via
2024-02-29 12:24         ` Ankit Agrawal
2024-03-05  5:59     ` Ankit Agrawal
2024-03-05  7:11       ` Cédric Le Goater
2024-03-05  8:17         ` Ankit Agrawal
2024-03-05 10:38           ` Jonathan Cameron via
2024-03-06 10:33             ` Ankit Agrawal
2024-03-06 11:46               ` Jonathan Cameron via
2024-03-05 21:06       ` Alex Williamson
2024-03-06 10:36         ` Ankit Agrawal
2024-03-06  9:12     ` Jonathan Cameron via
2024-03-06  9:12       ` Jonathan Cameron via
2024-03-06 10:41       ` Ankit Agrawal
2024-02-27 12:53   ` Jonathan Cameron via
2024-02-27 12:53     ` Jonathan Cameron via
2024-02-29 11:46     ` Ankit Agrawal
2024-02-29 12:20       ` Jonathan Cameron via

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=20240229155910.00005186@huawei.com \
    --to=qemu-arm@nongnu.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=acurrid@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=aniketa@nvidia.com \
    --cc=ankita@nvidia.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=cjia@nvidia.com \
    --cc=clg@redhat.com \
    --cc=david@redhat.com \
    --cc=dnigam@nvidia.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=gshan@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=kwankhede@nvidia.com \
    --cc=mochs@nvidia.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhaosl@gmail.com \
    --cc=targupta@nvidia.com \
    --cc=udhoke@nvidia.com \
    --cc=vsethi@nvidia.com \
    --cc=zhiw@nvidia.com \
    /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 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.