From patchwork Wed Oct 28 22:26:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 7512491 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CBFC0BF90C for ; Wed, 28 Oct 2015 14:33:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07EA4206E6 for ; Wed, 28 Oct 2015 14:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 218F820827 for ; Wed, 28 Oct 2015 14:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966601AbbJ1Oc5 (ORCPT ); Wed, 28 Oct 2015 10:32:57 -0400 Received: from mga14.intel.com ([192.55.52.115]:7411 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966594AbbJ1Ocy (ORCPT ); Wed, 28 Oct 2015 10:32:54 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 28 Oct 2015 07:32:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,210,1444719600"; d="scan'208";a="589668517" Received: from xiaoreal1.sh.intel.com (HELO xiaoreal1.sh.intel.com.sh.intel.com) ([10.239.48.79]) by FMSMGA003.fm.intel.com with ESMTP; 28 Oct 2015 07:32:52 -0700 From: Xiao Guangrong 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 Subject: [PATCH v5 29/33] nvdimm acpi: support Get Namespace Label Data function Date: Wed, 28 Oct 2015 22:26:27 +0000 Message-Id: <1446071191-62591-30-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1446071191-62591-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1446071191-62591-1-git-send-email-guangrong.xiao@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Function 5 is used to get Namespace Label Data Signed-off-by: Xiao Guangrong --- hw/acpi/nvdimm.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 72203d2..5b621ed 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -428,6 +428,7 @@ struct nvdimm_dsm_in { union { uint8_t arg3[0]; nvdimm_func_in_set_label_data func_set_label_data; + nvdimm_func_in_get_label_data func_get_label_data; }; } QEMU_PACKED; typedef struct nvdimm_dsm_in nvdimm_dsm_in; @@ -527,6 +528,50 @@ static void nvdimm_dsm_func_label_size(NVDIMMDevice *nvdimm, GArray *out) g_array_append_vals(out, &func_label_size, sizeof(func_label_size)); } +/* + * DSM Spec Rev1 4.5 Get Namespace Label Data (Function Index 5). + */ +static void nvdimm_dsm_func_get_label_data(NVDIMMDevice *nvdimm, + nvdimm_dsm_in *in, GArray *out) +{ + NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm); + nvdimm_func_in_get_label_data *get_label_data = &in->func_get_label_data; + void *buf; + uint32_t status = NVDIMM_DSM_STATUS_SUCCESS; + + le32_to_cpus(&get_label_data->offset); + le32_to_cpus(&get_label_data->length); + + nvdimm_debug("Read Label Data: offset %#x length %#x.\n", + get_label_data->offset, get_label_data->length); + + if (nvdimm->label_size < get_label_data->offset + get_label_data->length) { + nvdimm_debug("position %#x is beyond label data (len = %#lx).\n", + get_label_data->offset + get_label_data->length, + nvdimm->label_size); + status = NVDIMM_DSM_DEV_STATUS_INVALID_PARAS; + goto exit; + } + + if (get_label_data->length > nvdimm_get_max_xfer_label_size()) { + nvdimm_debug("get length (%#x) is larger than max_xfer (%#x).\n", + get_label_data->length, nvdimm_get_max_xfer_label_size()); + status = NVDIMM_DSM_DEV_STATUS_INVALID_PARAS; + goto exit; + } + + /* write nvdimm_func_out_get_label_data.status. */ + nvdimm_dsm_write_status(out, status); + /* write nvdimm_func_out_get_label_data.out_buf. */ + buf = acpi_data_push(out, get_label_data->length); + nvc->read_label_data(nvdimm, buf, get_label_data->length, + get_label_data->offset); + return; + +exit: + nvdimm_dsm_write_status(out, status); +} + static void nvdimm_dsm_device(nvdimm_dsm_in *in, GArray *out) { GSList *list = nvdimm_get_plugged_device_list(); @@ -554,6 +599,9 @@ static void nvdimm_dsm_device(nvdimm_dsm_in *in, GArray *out) case 0x4 /* Get Namespace Label Size */: nvdimm_dsm_func_label_size(nvdimm, out); goto free; + case 0x5 /* Get Namespace Label Data */: + nvdimm_dsm_func_get_label_data(nvdimm, in, out); + goto free; default: status = NVDIMM_DSM_STATUS_NOT_SUPPORTED; };