From patchwork Sun Oct 11 03:53:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 7368211 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 653DEBEEA4 for ; Sat, 10 Oct 2015 19:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99D0520929 for ; Sat, 10 Oct 2015 19:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA1422091D for ; Sat, 10 Oct 2015 19:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbbJJT7k (ORCPT ); Sat, 10 Oct 2015 15:59:40 -0400 Received: from mga03.intel.com ([134.134.136.65]:64232 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752775AbbJJT7a (ORCPT ); Sat, 10 Oct 2015 15:59:30 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 10 Oct 2015 12:59:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,664,1437462000"; d="scan'208";a="661783241" Received: from xiaoreal1.sh.intel.com (HELO xiaoreal1.sh.intel.com.sh.intel.com) ([10.239.48.79]) by orsmga003.jf.intel.com with ESMTP; 10 Oct 2015 12:59:25 -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 v3 30/32] nvdimm: support DSM_CMD_SET_NAMESPACE_LABEL_DATA Date: Sun, 11 Oct 2015 11:53:02 +0800 Message-Id: <1444535584-18220-31-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1444535584-18220-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1444535584-18220-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, 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 Signed-off-by: Xiao Guangrong --- hw/mem/nvdimm/acpi.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hw/mem/nvdimm/acpi.c b/hw/mem/nvdimm/acpi.c index e0a37cb..6f05b37 100644 --- a/hw/mem/nvdimm/acpi.c +++ b/hw/mem/nvdimm/acpi.c @@ -424,6 +424,11 @@ struct cmd_out_get_label_data { } QEMU_PACKED; typedef struct cmd_out_get_label_data cmd_out_get_label_data; +struct cmd_out_set_label_data { + uint32_t status; +}; +typedef struct cmd_out_set_label_data cmd_out_set_label_data; + struct dsm_out { /* the size of buffer filled by QEMU. */ uint16_t len; @@ -433,6 +438,7 @@ struct dsm_out { cmd_out_implemented cmd_implemented; cmd_out_label_size cmd_label_size; cmd_out_get_label_data cmd_get_label_data; + cmd_out_set_label_data cmd_set_label_data; }; } QEMU_PACKED; typedef struct dsm_out dsm_out; @@ -534,6 +540,33 @@ exit: return status; } +static uint32_t +dsm_cmd_set_label_data(NVDIMMDevice *nvdimm, dsm_in *in, dsm_out *out) +{ + cmd_in_set_label_data *cmd_in = &in->cmd_set_label_data; + uint32_t length, offset, status; + + length = cmd_in->length; + offset = cmd_in->offset; + le32_to_cpus(&length); + le32_to_cpus(&offset); + + nvdebug("Write Label Data: offset %#x length %#x.\n", offset, length); + if (nvdimm->label_size < length + offset) { + nvdebug("position %#x is beyond config data (len = %#lx).\n", + length + offset, nvdimm->label_size); + out->len = sizeof(out->status); + status = DSM_STATUS_INVALID_PARAS; + goto exit; + } + + status = DSM_STATUS_SUCCESS; + memcpy(nvdimm->label_data + offset, cmd_in->in_buf, length); + out->len = sizeof(status); +exit: + return status; +} + static void dsm_write_nvdimm(MemoryRegion *dsm_ram_mr, uint32_t handle, uint32_t function, dsm_in *in, dsm_out *out) { @@ -559,6 +592,9 @@ static void dsm_write_nvdimm(MemoryRegion *dsm_ram_mr, uint32_t handle, case DSM_CMD_GET_NAMESPACE_LABEL_DATA: status = dsm_cmd_get_label_data(nvdimm, in, out); break; + case DSM_CMD_SET_NAMESPACE_LABEL_DATA: + status = dsm_cmd_set_label_data(nvdimm, in, out); + break; default: out->len = sizeof(out->status); status = DSM_STATUS_NOT_SUPPORTED;