From: Igor Mammedov <imammedo@redhat.com>
To: <ankita@nvidia.com>
Cc: <jgg@nvidia.com>, <alex.williamson@redhat.com>, <clg@redhat.com>,
<shannon.zhaosl@gmail.com>, <peter.maydell@linaro.org>,
<ani@anisinha.ca>, <aniketa@nvidia.com>, <cjia@nvidia.com>,
<kwankhede@nvidia.com>, <targupta@nvidia.com>,
<vsethi@nvidia.com>, <acurrid@nvidia.com>, <qemu-arm@nongnu.org>,
<qemu-devel@nongnu.org>
Subject: Re: [PATCH v1 4/4] acpi/gpex: patch guest DSDT for dev mem information
Date: Fri, 15 Sep 2023 17:13:13 +0200 [thread overview]
Message-ID: <20230915171313.1a6cb98b@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <20230915024559.6565-5-ankita@nvidia.com>
On Thu, 14 Sep 2023 19:45:59 -0700
<ankita@nvidia.com> wrote:
> From: Ankit Agrawal <ankita@nvidia.com>
>
> To add the memory in the guest as NUMA nodes, it needs the PXM node index
> and the total count of nodes associated with the memory. The range of
> proximity domains are communicated to the VM as part of the guest ACPI
> using the nvidia,gpu-mem-pxm-start and nvidia,gpu-mem-pxm-count DSD
above examples should use devices that are (or to be) available in QEMU,
not some out of tree ones.
> properties. These value respectively represent the staring proximity
> domain id and the count. Kernel modules can then fetch this information
> and determine the numa node id using pxm_to_node().
>
> Signed-off-by: Ankit Agrawal <ankita@nvidia.com>
> ---
> hw/pci-host/gpex-acpi.c | 69 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
> index 7c7316bc96..0548feace1 100644
> --- a/hw/pci-host/gpex-acpi.c
> +++ b/hw/pci-host/gpex-acpi.c
> @@ -49,6 +49,72 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)
> }
> }
>
> +static void acpi_dsdt_add_cohmem_device(Aml *dev, int32_t devfn,
> + uint64_t dev_mem_pxm_start,
> + uint64_t dev_mem_pxm_count)
> +{
> + Aml *memdev = aml_device("CMD%X", PCI_SLOT(devfn));
> + Aml *pkg = aml_package(2);
> + Aml *pkg1 = aml_package(2);
> + Aml *pkg2 = aml_package(2);
> + Aml *dev_pkg = aml_package(2);
> + Aml *UUID;
> +
> + aml_append(memdev, aml_name_decl("_ADR", aml_int(PCI_SLOT(devfn) << 16)));
PCI devices (especially endpoints) are typically enumerated by
bus specific means (i.e not by ACPI).
And whether OSPM will honor the remainder of AML here is very questionable.
> +
> + aml_append(pkg1, aml_string("dev-mem-pxm-start"));
> + aml_append(pkg1, aml_int(dev_mem_pxm_start));
> +
> + aml_append(pkg2, aml_string("dev-mem-pxm-count"));
> + aml_append(pkg2, aml_int(dev_mem_pxm_count));
> +
> + aml_append(pkg, pkg1);
> + aml_append(pkg, pkg2);
> +
> + UUID = aml_touuid("DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301");
I'm not a fun of free form UUIDs and above one seems to be the case:
https://uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
looking at above doc this UUID also requires HID/ACPI ID
to describe data structure definition which this patch is missing.
It's also questionable whether _HID and _ADR are allowed to go together.
PS:
Commit message and comments here should have appropriate pointers
to relevant specs.
> + aml_append(dev_pkg, UUID);
> + aml_append(dev_pkg, pkg);
> +
> + aml_append(memdev, aml_name_decl("_DSD", dev_pkg));
> + aml_append(dev, memdev);
> +}
> +
> +static void find_mem_device(PCIBus *bus, PCIDevice *pdev,
> + void *opaque)
> +{
> + Aml *dev = (Aml *)opaque;
> +
> + if (bus == NULL) {
> + return;
> + }
> +
> + if (pdev->has_coherent_memory) {
> + Object *po = OBJECT(pdev);
> +
> + if (po == NULL) {
> + return;
> + }
> +
> + uint64_t pxm_start
> + = object_property_get_uint(po, "dev_mem_pxm_start", NULL);
> + uint64_t pxm_count
> + = object_property_get_uint(po, "dev_mem_pxm_count", NULL);
> +
> + acpi_dsdt_add_cohmem_device(dev, pdev->devfn, pxm_start, pxm_count);
> + }
> +}
> +
> +static void acpi_dsdt_find_and_add_cohmem_device(PCIBus *bus, Aml *dev)
> +{
> + if (bus == NULL) {
> + return;
> + }
> +
> + pci_for_each_device_reverse(bus, pci_bus_num(bus),
> + find_mem_device, dev);
> +
> +}
> +
> static void acpi_dsdt_add_pci_osc(Aml *dev)
> {
> Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf;
> @@ -207,7 +273,10 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
>
> acpi_dsdt_add_pci_route_table(dev, cfg->irq);
>
> + acpi_dsdt_find_and_add_cohmem_device(cfg->bus, dev);
> +
> method = aml_method("_CBA", 0, AML_NOTSERIALIZED);
> +
> aml_append(method, aml_return(aml_int(cfg->ecam.base)));
> aml_append(dev, method);
>
next prev parent reply other threads:[~2023-09-15 15:13 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 2:45 [PATCH v1 0/4] vfio: report NUMA nodes for device memory ankita
2023-09-15 2:45 ` [PATCH v1 1/4] vfio: new command line params for device memory NUMA nodes ankita
2023-09-15 14:25 ` Jonathan Cameron via
2023-09-15 14:48 ` Igor Mammedov
2023-09-22 5:44 ` Ankit Agrawal
2023-09-25 14:08 ` Jonathan Cameron via
2023-09-15 2:45 ` [PATCH v1 2/4] vfio: assign default values to node params ankita
2023-09-15 2:45 ` [PATCH v1 3/4] hw/arm/virt-acpi-build: patch guest SRAT for NUMA nodes ankita
2023-09-15 14:37 ` Jonathan Cameron via
2023-09-22 5:49 ` Ankit Agrawal
2023-09-25 13:54 ` Jonathan Cameron via
2023-09-25 14:03 ` Jason Gunthorpe
2023-09-25 14:53 ` Jonathan Cameron via
2023-09-25 16:00 ` Jason Gunthorpe
2023-09-25 17:00 ` Jonathan Cameron via
2023-09-26 14:54 ` Ankit Agrawal
2023-09-27 7:06 ` Ankit Agrawal
2023-09-27 11:01 ` Jonathan Cameron via
2023-09-15 14:52 ` Igor Mammedov
2023-09-15 15:49 ` David Hildenbrand
2023-09-15 2:45 ` [PATCH v1 4/4] acpi/gpex: patch guest DSDT for dev mem information ankita
2023-09-15 15:13 ` Igor Mammedov [this message]
2023-09-27 11:42 ` Jonathan Cameron via
2023-09-15 14:19 ` [PATCH v1 0/4] vfio: report NUMA nodes for device memory Cédric Le Goater
2023-09-15 14:47 ` Alex Williamson
2023-09-15 18:34 ` David Hildenbrand
2023-09-22 8:11 ` Ankit Agrawal
2023-09-22 8:15 ` David Hildenbrand
2023-09-26 14:52 ` Ankit Agrawal
2023-09-26 16:54 ` David Hildenbrand
2023-09-26 19:14 ` Alex Williamson
2023-09-27 7:14 ` Ankit Agrawal
2023-09-27 11:33 ` Jonathan Cameron via
2023-09-27 13:53 ` Jason Gunthorpe
2023-09-27 14:24 ` Alex Williamson
2023-09-27 15:03 ` Vikram Sethi
2023-09-27 15:42 ` Jason Gunthorpe
2023-09-28 16:15 ` Jonathan Cameron via
2023-09-27 16:37 ` Alex Williamson
2023-09-28 16:29 ` Jonathan Cameron via
2023-09-28 16:04 ` 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=20230915171313.1a6cb98b@imammedo.users.ipa.redhat.com \
--to=imammedo@redhat.com \
--cc=acurrid@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=ani@anisinha.ca \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=cjia@nvidia.com \
--cc=clg@redhat.com \
--cc=jgg@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=targupta@nvidia.com \
--cc=vsethi@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 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).