From nobody Tue Feb 10 11:23:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557297092; cv=none; d=zoho.com; s=zohoarc; b=WrDJI+zc4zoj5twBHyxYyrDoG21wln2o3MCZzcgaLLnv8wv3qwvkZIUvdDhuv9O+jk1BUqKtEwQL3S5lwHeewnL1VjV7FXdnEFNMDcDZXzIyteFQn4Maqi6+EHxnHbC7BemjlyESIEiV4ZJcyzcojkiKqeb5UvAK5oR66S9+HpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557297092; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xEpg9SeesKbks5+ptz7aEuEdY821yjFHWlznrOrgFMM=; b=E60bP3n0es90MuSbAoM7WxhQ1c1aU1t4ORmZ7pdlZ8K/VH5b3gge0gIXFDL9RZsnYGeHSu93zqElVGhghu6l/o28qrTewzFDX8qqhBtyOu0C4wa8+x7CaIZNsDJtKpadlY45NJS7Klo3uxhBcM+KUcpSZjdDK/Q3F0sDBrYQOiI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557297092928682.4910926026968; Tue, 7 May 2019 23:31:32 -0700 (PDT) Received: from localhost ([127.0.0.1]:60289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOG6z-0007Zv-Rs for importer@patchew.org; Wed, 08 May 2019 02:31:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOFw9-0005GQ-GW for qemu-devel@nongnu.org; Wed, 08 May 2019 02:20:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOFw8-0000JL-0Q for qemu-devel@nongnu.org; Wed, 08 May 2019 02:20:17 -0400 Received: from mga05.intel.com ([192.55.52.43]:57358) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hOFw7-00005t-HU for qemu-devel@nongnu.org; Wed, 08 May 2019 02:20:15 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2019 23:20:13 -0700 Received: from tao-optiplex-7060.sh.intel.com ([10.239.13.92]) by fmsmga005.fm.intel.com with ESMTP; 07 May 2019 23:20:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 From: Tao Xu To: imammedo@redhat.com, mst@redhat.com, eblake@redhat.com, ehabkost@redhat.com, xiaoguangrong.eric@gmail.com Date: Wed, 8 May 2019 14:17:25 +0800 Message-Id: <20190508061726.27631-11-tao3.xu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190508061726.27631-1-tao3.xu@intel.com> References: <20190508061726.27631-1-tao3.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.43 Subject: [Qemu-devel] [PATCH v4 10/11] acpi: introduce build_acpi_aml_common for NFIT generalizations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, tao3.xu@intel.com, jingqi.liu@intel.com, qemu-devel@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The aim of this patch is to move some of the NFIT Aml-build codes into build_acpi_aml_common(), and then NFIT and HMAT can both use it. Reviewed-by: Liu Jingqi Signed-off-by: Tao Xu --- Changes in v4 -> v3: - Split 8/8 of patch v3 into two parts, introduces NFIT generalizations (build_acpi_aml_common) --- hw/acpi/nvdimm.c | 49 +++++++++++++++++++++++++++-------------- include/hw/mem/nvdimm.h | 6 +++++ 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 9fdad6dc3f..e2be79a8b7 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1140,12 +1140,11 @@ static void nvdimm_build_device_dsm(Aml *dev, uint3= 2_t handle) =20 static void nvdimm_build_fit(Aml *dev) { - Aml *method, *pkg, *buf, *buf_size, *offset, *call_result; - Aml *whilectx, *ifcond, *ifctx, *elsectx, *fit; + Aml *method, *pkg, *buf, *buf_name, *buf_size, *call_result; =20 buf =3D aml_local(0); buf_size =3D aml_local(1); - fit =3D aml_local(2); + buf_name =3D aml_local(2); =20 aml_append(dev, aml_name_decl(NVDIMM_DSM_RFIT_STATUS, aml_int(0))); =20 @@ -1164,6 +1163,22 @@ static void nvdimm_build_fit(Aml *dev) aml_int(1) /* Revision 1 */, aml_int(0x1) /* Read FIT */, pkg, aml_int(NVDIMM_QEMU_RSVD_HANDLE_ROOT)); + + build_acpi_aml_common(method, buf, buf_size, + call_result, buf_name, dev, + "RFIT", "_FIT", + NVDIMM_DSM_RET_STATUS_SUCCESS, + NVDIMM_DSM_RET_STATUS_FIT_CHANGED); +} + +void build_acpi_aml_common(Aml *method, Aml *buf, Aml *buf_size, + Aml *call_result, Aml *buf_name, Aml *dev, + const char *help_function, const char *method_n= ame, + int ret_status_success, + int ret_status_changed) +{ + Aml *offset, *whilectx, *ifcond, *ifctx, *elsectx; + aml_append(method, aml_store(call_result, buf)); =20 /* handle _DSM result. */ @@ -1174,7 +1189,7 @@ static void nvdimm_build_fit(Aml *dev) aml_name(NVDIMM_DSM_RFIT_STATUS))); =20 /* if something is wrong during _DSM. */ - ifcond =3D aml_equal(aml_int(NVDIMM_DSM_RET_STATUS_SUCCESS), + ifcond =3D aml_equal(aml_int(ret_status_success), aml_name("STAU")); ifctx =3D aml_if(aml_lnot(ifcond)); aml_append(ifctx, aml_return(aml_buffer(0, NULL))); @@ -1185,7 +1200,7 @@ static void nvdimm_build_fit(Aml *dev) aml_int(4) /* the size of "STAU" */, buf_size)); =20 - /* if we read the end of fit. */ + /* if we read the end of fit or hma. */ ifctx =3D aml_if(aml_equal(buf_size, aml_int(0))); aml_append(ifctx, aml_return(aml_buffer(0, NULL))); aml_append(method, ifctx); @@ -1196,38 +1211,38 @@ static void nvdimm_build_fit(Aml *dev) aml_append(method, aml_return(aml_name("BUFF"))); aml_append(dev, method); =20 - /* build _FIT. */ - method =3D aml_method("_FIT", 0, AML_SERIALIZED); + /* build _FIT or _HMA. */ + method =3D aml_method(method_name, 0, AML_SERIALIZED); offset =3D aml_local(3); =20 - aml_append(method, aml_store(aml_buffer(0, NULL), fit)); + aml_append(method, aml_store(aml_buffer(0, NULL), buf_name)); aml_append(method, aml_store(aml_int(0), offset)); =20 whilectx =3D aml_while(aml_int(1)); - aml_append(whilectx, aml_store(aml_call1("RFIT", offset), buf)); + aml_append(whilectx, aml_store(aml_call1(help_function, offset), buf)); aml_append(whilectx, aml_store(aml_sizeof(buf), buf_size)); =20 /* - * if fit buffer was changed during RFIT, read from the beginning - * again. + * if buffer was changed during RFIT or RHMA, + * read from the beginning again. */ ifctx =3D aml_if(aml_equal(aml_name(NVDIMM_DSM_RFIT_STATUS), - aml_int(NVDIMM_DSM_RET_STATUS_FIT_CHANGED))); - aml_append(ifctx, aml_store(aml_buffer(0, NULL), fit)); + aml_int(ret_status_changed))); + aml_append(ifctx, aml_store(aml_buffer(0, NULL), buf_name)); aml_append(ifctx, aml_store(aml_int(0), offset)); aml_append(whilectx, ifctx); =20 elsectx =3D aml_else(); =20 - /* finish fit read if no data is read out. */ + /* finish fit or hma read if no data is read out. */ ifctx =3D aml_if(aml_equal(buf_size, aml_int(0))); - aml_append(ifctx, aml_return(fit)); + aml_append(ifctx, aml_return(buf_name)); aml_append(elsectx, ifctx); =20 /* update the offset. */ aml_append(elsectx, aml_add(offset, buf_size, offset)); - /* append the data we read out to the fit buffer. */ - aml_append(elsectx, aml_concatenate(fit, buf, fit)); + /* append the data we read out to the fit or hma buffer. */ + aml_append(elsectx, aml_concatenate(buf_name, buf, buf_name)); aml_append(whilectx, elsectx); aml_append(method, whilectx); =20 diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index 523a9b3d4a..6f04eddb40 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -25,6 +25,7 @@ =20 #include "hw/mem/pc-dimm.h" #include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/aml-build.h" =20 #define NVDIMM_DEBUG 0 #define nvdimm_debug(fmt, ...) \ @@ -150,4 +151,9 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *t= able_data, uint32_t ram_slots); void nvdimm_plug(NVDIMMState *state); void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev); +void build_acpi_aml_common(Aml *method, Aml *buf, Aml *buf_size, + Aml *call_result, Aml *buf_name, Aml *dev, + const char *help_function, const char *method_n= ame, + int ret_status_success, + int ret_status_changed); #endif --=20 2.17.1