From patchwork Wed Oct 28 22:26:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 537380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D56E7140E31 for ; Thu, 29 Oct 2015 01:43:16 +1100 (AEDT) Received: from localhost ([::1]:38414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrRwY-0006Ci-RW for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 10:43:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrRmh-0006G7-CL for qemu-devel@nongnu.org; Wed, 28 Oct 2015 10:33:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrRme-0002Zj-IP for qemu-devel@nongnu.org; Wed, 28 Oct 2015 10:33:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:15622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrRme-00028A-E8 for qemu-devel@nongnu.org; Wed, 28 Oct 2015 10:33:00 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 28 Oct 2015 07:32:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,210,1444719600"; d="scan'208";a="589668555" 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:54 -0700 From: Xiao Guangrong To: pbonzini@redhat.com, imammedo@redhat.com Date: Wed, 28 Oct 2015 22:26:28 +0000 Message-Id: <1446071191-62591-31-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Cc: Xiao Guangrong , ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, dan.j.williams@intel.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH v5 30/33] nvdimm acpi: support Set Namespace Label Data function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Function 6 is used to set Namespace Label Data Signed-off-by: Xiao Guangrong --- hw/acpi/nvdimm.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 5b621ed..5e72ca8 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -572,6 +572,44 @@ 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, + nvdimm_dsm_in *in, GArray *out) +{ + NVDIMMClass *nvc = NVDIMM_GET_CLASS(nvdimm); + nvdimm_func_in_set_label_data *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); + + if (nvdimm->label_size < set_label_data->offset + set_label_data->length) { + nvdimm_debug("position %#x is beyond label data (len = %#lx).\n", + set_label_data->offset + set_label_data->length, + nvdimm->label_size); + status = NVDIMM_DSM_DEV_STATUS_INVALID_PARAS; + goto exit; + } + + if (set_label_data->length > nvdimm_get_max_xfer_label_size()) { + nvdimm_debug("set length (%#x) is larger than max_xfer (%#x).\n", + set_label_data->length, nvdimm_get_max_xfer_label_size()); + status = NVDIMM_DSM_DEV_STATUS_INVALID_PARAS; + goto exit; + } + + status = NVDIMM_DSM_STATUS_SUCCESS; + 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(nvdimm_dsm_in *in, GArray *out) { GSList *list = nvdimm_get_plugged_device_list(); @@ -602,6 +640,9 @@ static void nvdimm_dsm_device(nvdimm_dsm_in *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; };