All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
To: pbonzini@redhat.com, imammedo@redhat.com
Cc: gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com,
	mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
	dan.j.williams@intel.com, kvm@vger.kernel.org,
	qemu-devel@nongnu.org,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>
Subject: [PATCH v8 4/5] nvdimm acpi: build ACPI nvdimm devices
Date: Mon, 16 Nov 2015 18:51:02 +0800	[thread overview]
Message-ID: <1447671063-92665-5-git-send-email-guangrong.xiao@linux.intel.com> (raw)
In-Reply-To: <1447671063-92665-1-git-send-email-guangrong.xiao@linux.intel.com>

NVDIMM devices is defined in ACPI 6.0 9.20 NVDIMM Devices

There is a root device under \_SB and specified NVDIMM devices are under the
root device. Each NVDIMM device has _ADR which returns its handle used to
associate MEMDEV structure in NFIT

Currently, we do not support any function on _DSM, that means, NVDIMM
label data has not been supported yet

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
---
 hw/acpi/nvdimm.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 98c004d..abe0daa 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -367,6 +367,90 @@ static void nvdimm_build_nfit(GSList *device_list, GArray *table_offsets,
     g_array_free(structures, true);
 }
 
+static void nvdimm_build_common_dsm(Aml *root_dev)
+{
+    Aml *method, *ifctx, *function;
+    uint8_t byte_list[1];
+
+    method = aml_method("NCAL", 4);
+    {
+        function = aml_arg(2);
+
+        /*
+         * function 0 is called to inquire what functions are supported by
+         * OSPM
+         */
+        ifctx = aml_if(aml_equal(function, aml_int(0)));
+        byte_list[0] = 0 /* No function Supported */;
+        aml_append(ifctx, aml_return(aml_buffer(1, byte_list)));
+        aml_append(method, ifctx);
+
+        /* No function is supported yet. */
+        byte_list[0] = 1 /* Not Supported */;
+        aml_append(method, aml_return(aml_buffer(1, byte_list)));
+    }
+    aml_append(root_dev, method);
+}
+
+static void nvdimm_build_nvdimm_devices(GSList *device_list, Aml *root_dev)
+{
+    for (; device_list; device_list = device_list->next) {
+        DeviceState *dev = device_list->data;
+        int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
+                                           NULL);
+        uint32_t handle = nvdimm_slot_to_handle(slot);
+        Aml *nvdimm_dev, *method;
+
+        nvdimm_dev = aml_device("NV%02X", slot);
+        aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle)));
+
+        method = aml_method("_DSM", 4);
+        {
+            aml_append(method, aml_return(aml_call4("NCAL", aml_arg(0),
+                       aml_arg(1), aml_arg(2), aml_arg(3))));
+        }
+        aml_append(nvdimm_dev, method);
+
+        aml_append(root_dev, nvdimm_dev);
+    }
+}
+
+static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets,
+                              GArray *table_data, GArray *linker)
+{
+    Aml *ssdt, *sb_scope, *dev, *method;
+
+    acpi_add_table(table_offsets, table_data);
+
+    ssdt = init_aml_allocator();
+    acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
+
+    sb_scope = aml_scope("\\_SB");
+
+    dev = aml_device("NVDR");
+    aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012")));
+
+    nvdimm_build_common_dsm(dev);
+    method = aml_method("_DSM", 4);
+    {
+        aml_append(method, aml_return(aml_call4("NCAL", aml_arg(0),
+                   aml_arg(1), aml_arg(2), aml_arg(3))));
+    }
+    aml_append(dev, method);
+
+    nvdimm_build_nvdimm_devices(device_list, dev);
+
+    aml_append(sb_scope, dev);
+
+    aml_append(ssdt, sb_scope);
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - ssdt->buf->len),
+        "SSDT", ssdt->buf->len, 1, "NVDIMM");
+    free_aml_allocator();
+}
+
 void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
                        GArray *linker)
 {
@@ -378,5 +462,6 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
         return;
     }
     nvdimm_build_nfit(device_list, table_offsets, table_data, linker);
+    nvdimm_build_ssdt(device_list, table_offsets, table_data, linker);
     g_slist_free(device_list);
 }
-- 
1.8.3.1


WARNING: multiple messages have this Message-ID (diff)
From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
To: pbonzini@redhat.com, imammedo@redhat.com
Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com,
	gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org,
	stefanha@redhat.com, dan.j.williams@intel.com, rth@twiddle.net
Subject: [Qemu-devel] [PATCH v8 4/5] nvdimm acpi: build ACPI nvdimm devices
Date: Mon, 16 Nov 2015 18:51:02 +0800	[thread overview]
Message-ID: <1447671063-92665-5-git-send-email-guangrong.xiao@linux.intel.com> (raw)
In-Reply-To: <1447671063-92665-1-git-send-email-guangrong.xiao@linux.intel.com>

NVDIMM devices is defined in ACPI 6.0 9.20 NVDIMM Devices

There is a root device under \_SB and specified NVDIMM devices are under the
root device. Each NVDIMM device has _ADR which returns its handle used to
associate MEMDEV structure in NFIT

Currently, we do not support any function on _DSM, that means, NVDIMM
label data has not been supported yet

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
---
 hw/acpi/nvdimm.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 98c004d..abe0daa 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -367,6 +367,90 @@ static void nvdimm_build_nfit(GSList *device_list, GArray *table_offsets,
     g_array_free(structures, true);
 }
 
+static void nvdimm_build_common_dsm(Aml *root_dev)
+{
+    Aml *method, *ifctx, *function;
+    uint8_t byte_list[1];
+
+    method = aml_method("NCAL", 4);
+    {
+        function = aml_arg(2);
+
+        /*
+         * function 0 is called to inquire what functions are supported by
+         * OSPM
+         */
+        ifctx = aml_if(aml_equal(function, aml_int(0)));
+        byte_list[0] = 0 /* No function Supported */;
+        aml_append(ifctx, aml_return(aml_buffer(1, byte_list)));
+        aml_append(method, ifctx);
+
+        /* No function is supported yet. */
+        byte_list[0] = 1 /* Not Supported */;
+        aml_append(method, aml_return(aml_buffer(1, byte_list)));
+    }
+    aml_append(root_dev, method);
+}
+
+static void nvdimm_build_nvdimm_devices(GSList *device_list, Aml *root_dev)
+{
+    for (; device_list; device_list = device_list->next) {
+        DeviceState *dev = device_list->data;
+        int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
+                                           NULL);
+        uint32_t handle = nvdimm_slot_to_handle(slot);
+        Aml *nvdimm_dev, *method;
+
+        nvdimm_dev = aml_device("NV%02X", slot);
+        aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle)));
+
+        method = aml_method("_DSM", 4);
+        {
+            aml_append(method, aml_return(aml_call4("NCAL", aml_arg(0),
+                       aml_arg(1), aml_arg(2), aml_arg(3))));
+        }
+        aml_append(nvdimm_dev, method);
+
+        aml_append(root_dev, nvdimm_dev);
+    }
+}
+
+static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets,
+                              GArray *table_data, GArray *linker)
+{
+    Aml *ssdt, *sb_scope, *dev, *method;
+
+    acpi_add_table(table_offsets, table_data);
+
+    ssdt = init_aml_allocator();
+    acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
+
+    sb_scope = aml_scope("\\_SB");
+
+    dev = aml_device("NVDR");
+    aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012")));
+
+    nvdimm_build_common_dsm(dev);
+    method = aml_method("_DSM", 4);
+    {
+        aml_append(method, aml_return(aml_call4("NCAL", aml_arg(0),
+                   aml_arg(1), aml_arg(2), aml_arg(3))));
+    }
+    aml_append(dev, method);
+
+    nvdimm_build_nvdimm_devices(device_list, dev);
+
+    aml_append(sb_scope, dev);
+
+    aml_append(ssdt, sb_scope);
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - ssdt->buf->len),
+        "SSDT", ssdt->buf->len, 1, "NVDIMM");
+    free_aml_allocator();
+}
+
 void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
                        GArray *linker)
 {
@@ -378,5 +462,6 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
         return;
     }
     nvdimm_build_nfit(device_list, table_offsets, table_data, linker);
+    nvdimm_build_ssdt(device_list, table_offsets, table_data, linker);
     g_slist_free(device_list);
 }
-- 
1.8.3.1

  parent reply	other threads:[~2015-11-16 10:56 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16 10:50 [PATCH v8 0/5] implement vNVDIMM Xiao Guangrong
2015-11-16 10:50 ` [Qemu-devel] " Xiao Guangrong
2015-11-16 10:50 ` [PATCH v8 1/5] nvdimm: implement NVDIMM device abstract Xiao Guangrong
2015-11-16 10:50   ` [Qemu-devel] " Xiao Guangrong
2015-11-16 10:51 ` [PATCH v8 2/5] acpi: support specified oem table id for build_header Xiao Guangrong
2015-11-16 10:51   ` [Qemu-devel] " Xiao Guangrong
2015-11-16 10:51 ` [PATCH v8 3/5] nvdimm acpi: build ACPI NFIT table Xiao Guangrong
2015-11-16 10:51   ` [Qemu-devel] " Xiao Guangrong
2015-11-30 10:30   ` Michael S. Tsirkin
2015-11-30 10:30     ` [Qemu-devel] " Michael S. Tsirkin
2015-11-30 12:29     ` Xiao Guangrong
2015-11-30 12:29       ` [Qemu-devel] " Xiao Guangrong
2015-11-16 10:51 ` Xiao Guangrong [this message]
2015-11-16 10:51   ` [Qemu-devel] [PATCH v8 4/5] nvdimm acpi: build ACPI nvdimm devices Xiao Guangrong
2015-11-30 10:30   ` Michael S. Tsirkin
2015-11-30 10:30     ` [Qemu-devel] " Michael S. Tsirkin
2015-11-30 12:21     ` Xiao Guangrong
2015-11-30 12:21       ` [Qemu-devel] " Xiao Guangrong
2015-11-30 10:32   ` Michael S. Tsirkin
2015-11-30 10:32     ` [Qemu-devel] " Michael S. Tsirkin
2015-11-30 12:31     ` Xiao Guangrong
2015-11-30 12:31       ` [Qemu-devel] " Xiao Guangrong
2015-11-16 10:51 ` [PATCH v8 5/5] nvdimm: add maintain info Xiao Guangrong
2015-11-16 10:51   ` [Qemu-devel] " Xiao Guangrong
2015-11-18  1:59 ` [PATCH v8 0/5] implement vNVDIMM Xiao Guangrong
2015-11-18  1:59   ` [Qemu-devel] " Xiao Guangrong
2015-11-18 19:18   ` Eduardo Habkost
2015-11-18 19:18     ` [Qemu-devel] " Eduardo Habkost
2015-11-18 20:44     ` Michael S. Tsirkin
2015-11-18 20:44       ` [Qemu-devel] " Michael S. Tsirkin
2015-11-19  2:39       ` Xiao Guangrong
2015-11-19  2:39         ` [Qemu-devel] " Xiao Guangrong
2015-11-19  8:21         ` Michael S. Tsirkin
2015-11-19  8:21           ` [Qemu-devel] " Michael S. Tsirkin
2015-11-23  8:53         ` Stefan Hajnoczi
2015-11-23  8:53           ` [Qemu-devel] " Stefan Hajnoczi
2015-11-30  8:51 ` Stefan Hajnoczi
2015-11-30  8:51   ` [Qemu-devel] " Stefan Hajnoczi
2015-11-30 12:34   ` Xiao Guangrong
2015-11-30 12:34     ` [Qemu-devel] " Xiao Guangrong
2015-11-30 10:38 ` Michael S. Tsirkin
2015-11-30 10:38   ` [Qemu-devel] " Michael S. Tsirkin
2015-11-30 12:33   ` Xiao Guangrong
2015-11-30 12:33     ` [Qemu-devel] " Xiao Guangrong
2015-12-04 16:38 ` Vladimir Sementsov-Ogievskiy
2015-12-04 16:38   ` Vladimir Sementsov-Ogievskiy
2015-12-05  4:29   ` Xiao Guangrong
2015-12-05  4:29     ` [Qemu-devel] " Xiao Guangrong

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=1447671063-92665-5-git-send-email-guangrong.xiao@linux.intel.com \
    --to=guangrong.xiao@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=gleb@kernel.org \
    --cc=imammedo@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.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.