From: Robert Hoo <robert.hu@linux.intel.com>
To: xiaoguangrong.eric@gmail.com, mst@redhat.com,
imammedo@redhat.com, ani@anisinha.ca, qemu-devel@nongnu.org
Cc: jingqi.liu@intel.com, dan.j.williams@intel.com,
Robert Hoo <robert.hu@linux.intel.com>,
robert.hu@intel.com
Subject: [PATCH 1/2] acpi/nvdimm: Create _LS{I,R,W} method for NVDIMM device
Date: Tue, 12 Apr 2022 14:57:52 +0800 [thread overview]
Message-ID: <20220412065753.3216538-2-robert.hu@linux.intel.com> (raw)
In-Reply-To: <20220412065753.3216538-1-robert.hu@linux.intel.com>
Since ACPI 6.2, previous NVDIMM/_DSM funcions "Get Namespace Label Data
Size (function index 4)", "Get Namespace Label Data (function index 5)",
"Set Namespace Label Data (function index 6)" has been deprecated by ACPI
standard method _LSI, _LSR, _LSW respectively. Functions semantics are
almost identical, so my implementation is to reuse existing _DSMs, just
create _LS{I,R,W} interfaces and constructs parameters and call _DSMs.
Only child NVDIMM devices has these methods, rather Root device.
By this patch, new NVDIMM sub device in ACPI namespace will be like this:
Device (NV00)
{
Name (_ADR, One) // _ADR: Address
Method (_LSI, 0, NotSerialized) // _LSI: Label Storage Information
{
Return (NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), 0x02, 0x04, Zero, One))
}
Method (_LSR, 2, Serialized) // _LSR: Label Storage Read
{
CreateDWordField (BUFF, Zero, DWD0)
CreateDWordField (BUFF, 0x04, DWD1)
Name (PKG1, Package (0x01)
{
BUFF
})
DWD0 = Arg0
DWD1 = Arg1
Return (NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), 0x02, 0x05, PKG1, One))
}
Method (_LSW, 3, Serialized) // _LSW: Label Storage Write
{
CreateDWordField (BUFF, Zero, DWD0)
CreateDWordField (BUFF, 0x04, DWD1)
CreateField (BUFF, 0x40, 0x7FA0, FILD)
Name (PKG1, Package (0x01)
{
BUFF
})
DWD0 = Arg0
DWD1 = Arg1
FILD = Arg2
Return (NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), 0x02, 0x06, PKG1, One))
}
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
{
Return (NCAL (Arg0, Arg1, Arg2, Arg3, One))
}
}
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
Reviewed-by: Jingqi Liu<jingqi.liu@intel.com>
---
hw/acpi/nvdimm.c | 56 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 52 insertions(+), 4 deletions(-)
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 0d43da19ea..7cc419401b 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -848,10 +848,10 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
nvdimm_debug("Revision 0x%x Handler 0x%x Function 0x%x.\n", in->revision,
in->handle, in->function);
-
- if (in->revision != 0x1 /* Currently we only support DSM Spec Rev1. */) {
- nvdimm_debug("Revision 0x%x is not supported, expect 0x%x.\n",
- in->revision, 0x1);
+ /* Currently we only support DSM Spec Rev1 and Rev2. */
+ if (in->revision != 0x1 && in->revision != 0x2) {
+ nvdimm_debug("Revision 0x%x is not supported, expect 0x1 or 0x2.\n",
+ in->revision);
nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_addr);
goto exit;
}
@@ -1247,6 +1247,11 @@ static void nvdimm_build_fit(Aml *dev)
static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
{
uint32_t slot;
+ Aml *method, *pkg, *buff;
+
+ /* Build common shared buffer for params pass in/out */
+ buff = aml_buffer(4096, NULL);
+ aml_append(root_dev, aml_name_decl("BUFF", buff));
for (slot = 0; slot < ram_slots; slot++) {
uint32_t handle = nvdimm_slot_to_handle(slot);
@@ -1264,6 +1269,49 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
*/
aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle)));
+ /* Build _LSI, _LSR, _LSW */
+ method = aml_method("_LSI", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_return(aml_call5(NVDIMM_COMMON_DSM,
+ aml_touuid("4309AC30-0D11-11E4-9191-0800200C9A66"),
+ aml_int(2), aml_int(4), aml_int(0),
+ aml_int(handle))));
+ aml_append(nvdimm_dev, method);
+
+ method = aml_method("_LSR", 2, AML_SERIALIZED);
+ aml_append(method,
+ aml_create_dword_field(aml_name("BUFF"), aml_int(0), "DWD0"));
+ aml_append(method,
+ aml_create_dword_field(aml_name("BUFF"), aml_int(4), "DWD1"));
+ pkg = aml_package(1);
+ aml_append(pkg, aml_name("BUFF"));
+ aml_append(method, aml_name_decl("PKG1", pkg));
+ aml_append(method, aml_store(aml_arg(0), aml_name("DWD0")));
+ aml_append(method, aml_store(aml_arg(1), aml_name("DWD1")));
+ aml_append(method, aml_return(aml_call5(NVDIMM_COMMON_DSM,
+ aml_touuid("4309AC30-0D11-11E4-9191-0800200C9A66"),
+ aml_int(2), aml_int(5), aml_name("PKG1"),
+ aml_int(handle))));
+ aml_append(nvdimm_dev, method);
+
+ method = aml_method("_LSW", 3, AML_SERIALIZED);
+ aml_append(method,
+ aml_create_dword_field(aml_name("BUFF"), aml_int(0), "DWD0"));
+ aml_append(method,
+ aml_create_dword_field(aml_name("BUFF"), aml_int(4), "DWD1"));
+ aml_append(method,
+ aml_create_field(aml_name("BUFF"), aml_int(64), aml_int(32672), "FILD"));
+ pkg = aml_package(1);
+ aml_append(pkg, aml_name("BUFF"));
+ aml_append(method, aml_name_decl("PKG1", pkg));
+ aml_append(method, aml_store(aml_arg(0), aml_name("DWD0")));
+ aml_append(method, aml_store(aml_arg(1), aml_name("DWD1")));
+ aml_append(method, aml_store(aml_arg(2), aml_name("FILD")));
+ aml_append(method, aml_return(aml_call5(NVDIMM_COMMON_DSM,
+ aml_touuid("4309AC30-0D11-11E4-9191-0800200C9A66"),
+ aml_int(2), aml_int(6), aml_name("PKG1"),
+ aml_int(handle))));
+ aml_append(nvdimm_dev, method);
+
nvdimm_build_device_dsm(nvdimm_dev, handle);
aml_append(root_dev, nvdimm_dev);
}
--
2.31.1
next prev parent reply other threads:[~2022-04-12 7:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 6:57 [RESEND][PATCH 0/2] acpi/nvdimm: support NVDIMM _LS{I,R,W} methods Robert Hoo
2022-04-12 6:57 ` Robert Hoo [this message]
2022-04-27 14:34 ` [PATCH 1/2] acpi/nvdimm: Create _LS{I,R,W} method for NVDIMM device Igor Mammedov
2022-04-29 9:01 ` Robert Hoo
2022-05-03 8:27 ` Igor Mammedov
2022-05-05 3:07 ` Robert Hoo
2022-05-05 8:50 ` Igor Mammedov
2022-05-05 13:26 ` Robert Hoo
2022-05-06 9:23 ` Igor Mammedov
2022-05-18 0:20 ` Robert Hoo
2022-05-19 12:35 ` Igor Mammedov
2022-04-12 6:57 ` [PATCH 2/2] acpi/nvdimm: Fix aml_or() and aml_and() in if clause Robert Hoo
2022-04-27 7:38 ` Igor Mammedov
2022-05-13 12:39 ` Michael S. Tsirkin
2022-04-20 5:18 ` [RESEND][PATCH 0/2] acpi/nvdimm: support NVDIMM _LS{I,R,W} methods Robert Hoo
2022-04-27 14:39 ` Igor Mammedov
2022-04-29 9:02 ` Robert Hoo
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=20220412065753.3216538-2-robert.hu@linux.intel.com \
--to=robert.hu@linux.intel.com \
--cc=ani@anisinha.ca \
--cc=dan.j.williams@intel.com \
--cc=imammedo@redhat.com \
--cc=jingqi.liu@intel.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=robert.hu@intel.com \
--cc=xiaoguangrong.eric@gmail.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).