From patchwork Mon Nov 2 09:13:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 7535081 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 0AB2EBEEA4 for ; Mon, 2 Nov 2015 09:21:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2AFD2205E9 for ; Mon, 2 Nov 2015 09:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C72A2052C for ; Mon, 2 Nov 2015 09:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753406AbbKBJVa (ORCPT ); Mon, 2 Nov 2015 04:21:30 -0500 Received: from mga02.intel.com ([134.134.136.20]:42286 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbbKBJVL (ORCPT ); Mon, 2 Nov 2015 04:21:11 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 02 Nov 2015 01:20:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,234,1444719600"; d="scan'208";a="840963515" Received: from xiaoreal1.sh.intel.com (HELO xiaoreal1.sh.intel.com.sh.intel.com) ([10.239.48.79]) by fmsmga002.fm.intel.com with ESMTP; 02 Nov 2015 01:20:22 -0800 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, vsementsov@virtuozzo.com, eblake@redhat.com, Xiao Guangrong Subject: [PATCH v7 32/35] nvdimm acpi: support Set Namespace Label Data function Date: Mon, 2 Nov 2015 17:13:34 +0800 Message-Id: <1446455617-129562-33-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1446455617-129562-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1446455617-129562-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 6 is used to set Namespace Label Data Reviewed-by: Stefan Hajnoczi Signed-off-by: Xiao Guangrong --- hw/acpi/nvdimm.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index f30e2ff..2553be9 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -587,6 +587,34 @@ exit: nvdimm_dsm_write_status(out, status); } +/* + * DSM Spec Rev1 4.6 Set Namespace Label Data (Function Index 6). + */ +static void nvdimm_dsm_func_set_label_data(NVDIMMDevice *nvdimm, + NvdimmDsmIn *in, GArray *out) +{ + NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm); + NvdimmFuncInSetLabelData *set_label_data = &in->func_set_label_data; + uint32_t status; + + le32_to_cpus(&set_label_data->offset); + le32_to_cpus(&set_label_data->length); + + nvdimm_debug("Write Label Data: offset %#x length %#x.\n", + set_label_data->offset, set_label_data->length); + + status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset, + set_label_data->length); + if (status != NVDIMM_DSM_STATUS_SUCCESS) { + goto exit; + } + + nvc->write_label_data(nvdimm, set_label_data->in_buf, + set_label_data->length, set_label_data->offset); +exit: + nvdimm_dsm_write_status(out, status); +} + static void nvdimm_dsm_device(NvdimmDsmIn *in, GArray *out) { GSList *list = nvdimm_get_plugged_device_list(); @@ -617,6 +645,9 @@ static void nvdimm_dsm_device(NvdimmDsmIn *in, GArray *out) case 0x5 /* Get Namespace Label Data */: nvdimm_dsm_func_get_label_data(nvdimm, in, out); goto free; + case 0x6 /* Set Namespace Label Data */: + nvdimm_dsm_func_set_label_data(nvdimm, in, out); + goto free; default: status = NVDIMM_DSM_STATUS_NOT_SUPPORTED; };