From patchwork Fri Jun 3 07:13:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 9151967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 144C86074E for ; Fri, 3 Jun 2016 07:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 043ED26C9B for ; Fri, 3 Jun 2016 07:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EACA3282EE; Fri, 3 Jun 2016 07:15:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E68726C9B for ; Fri, 3 Jun 2016 07:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537AbcFCHPq (ORCPT ); Fri, 3 Jun 2016 03:15:46 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:34809 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbcFCHPp (ORCPT ); Fri, 3 Jun 2016 03:15:45 -0400 Received: by mail-pa0-f67.google.com with SMTP id x1so5287178pav.1; Fri, 03 Jun 2016 00:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wg58b8QSRq1CzTJzRJ6OX0yhpDcqaWgoJAZTwPBzp4Y=; b=No8wnkarHstQVDF71y84lH00r80x9IVmIPPWJvtc6TfIZGK04NiOxxo6GtnTIuro1D RtRy5jZf2hweH+kwNVA9RSEGTmvL2iR6qN+e3glqNJb4QnCPBQ1u2tIWLtDYhT65J1Z6 Hb0cSOJTFh3mDUSMc7YbOKdC2QMInRynPcpTAoln2n1jCwFU/m02uemU91Uz20eShd4C UQmvXrDteCb80ozJsUEJY3qWHzjuL66ugtOTCJCkufhCUekN51vL//zRPFoLjfptS4+k mLanO89z3Pv8Nflu+5jsB0u/Ye3pazpvTtX5aCrQkyfSpGQ5XTQ0OsL0QpSqHkvVAyyi EsDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wg58b8QSRq1CzTJzRJ6OX0yhpDcqaWgoJAZTwPBzp4Y=; b=KOfNIpuv/oTCaQVj3eEmGdPBsh8rDzBodphFw0N/8MGBwB1XmH67NqQ7LmJhOt4FAI bbQ9S97jyCm3KMv7PRg0IK4QKRe3YC4smdKyAxmOUtJogZFFmYdRp7/qmAENX8xA8jsS kTMd9IR+9HBg4tsiJ2fygTBNU7yuf3StLwmj0FOwcaLlr6YgloHnG9amjJEwisT8PogF N0Qez6MNxd01OKbI0RKrP6Ld8OuwwnndoIllYTo+8yKsG3qSvZPCkYQV9QjbomxZ8fYH vyqPqHRk+uCrhwALfFlljU2Yj9xHOgtBZcVi6hRSFKur6q7nosva1yckUfHQ0mAbMDmy 1WIA== X-Gm-Message-State: ALyK8tK6KCfFxMC4pCGWpqhrfDkOlbjkIuBNx4Bg4c25lcxFD4IZWyhHtOQ9LBN4AVlwjw== X-Received: by 10.66.166.176 with SMTP id zh16mr3312170pab.42.1464938144259; Fri, 03 Jun 2016 00:15:44 -0700 (PDT) Received: from linux-rxt1.site (59-124-67-67.HINET-IP.hinet.net. [59.124.67.67]) by smtp.gmail.com with ESMTPSA id xt1sm3224523pac.7.2016.06.03.00.15.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2016 00:15:43 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Ross Zwisler , Dan Williams , "Rafael J. Wysocki" Cc: linux-nvdimm@lists.01.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Gary Lin Subject: [PATCH] libnvdimm, nfit: treat volatile virtual CD region as read-only pmem Date: Fri, 3 Jun 2016 15:13:35 +0800 Message-Id: <1464938015-5489-1-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.8.4.5 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds codes to treat a volatile virtual CD region as a read-only pmem region, then read-only /dev/pmem* device can be mounted with iso9660. It's useful to work with the httpboot in EFI firmware to pull a remote ISO file to the local memory region for booting and installation. Wiki page of UEFI HTTPBoot with OVMF: https://en.opensuse.org/UEFI_HTTPBoot_with_OVMF Signed-off-by: Lee, Chun-Yi Cc: Gary Lin Cc: Dan Williams Cc: Ross Zwisler Cc: "Rafael J. Wysocki" --- drivers/acpi/nfit.c | 8 +++++++- drivers/nvdimm/region_devs.c | 26 +++++++++++++++++++++++++- include/linux/libnvdimm.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index 2215fc8..b100a17 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -1949,6 +1949,7 @@ static int acpi_nfit_init_mapping(struct acpi_nfit_desc *acpi_desc, switch (nfit_spa_type(spa)) { case NFIT_SPA_PM: case NFIT_SPA_VOLATILE: + case NFIT_SPA_VCD: nd_mapping->start = memdev->address; nd_mapping->size = memdev->region_size; break; @@ -1995,7 +1996,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, if (nfit_spa->nd_region) return 0; - if (spa->range_index == 0) { + if (spa->range_index == 0 && nfit_spa_type(spa) != NFIT_SPA_VCD) { dev_dbg(acpi_desc->dev, "%s: detected invalid spa index\n", __func__); return 0; @@ -2059,6 +2060,11 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, ndr_desc); if (!nfit_spa->nd_region) rc = -ENOMEM; + } else if (nfit_spa_type(spa) == NFIT_SPA_VCD) { + nfit_spa->nd_region = nvdimm_vcd_region_create(nvdimm_bus, + ndr_desc); + if (!nfit_spa->nd_region) + rc = -ENOMEM; } out: diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 40fcfea..f155941 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -56,9 +56,19 @@ static struct device_type nd_volatile_device_type = { .release = nd_region_release, }; +static struct device_type nd_vcd_device_type = { + .name = "nd_vcd", + .release = nd_region_release, +}; + +bool is_nd_vcd(struct device *dev) +{ + return dev ? dev->type == &nd_vcd_device_type : false; +} + bool is_nd_pmem(struct device *dev) { - return dev ? dev->type == &nd_pmem_device_type : false; + return dev ? dev->type == &nd_pmem_device_type || is_nd_vcd(dev) : false; } bool is_nd_blk(struct device *dev) @@ -338,6 +348,9 @@ static ssize_t read_only_store(struct device *dev, int rc = strtobool(buf, &ro); struct nd_region *nd_region = to_nd_region(dev); + if (is_nd_vcd(dev)) + return -ENXIO; + if (rc) return rc; @@ -687,6 +700,9 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, ro = 1; } + if (dev_type == &nd_vcd_device_type) + ro = 1; + if (dev_type == &nd_blk_device_type) { struct nd_blk_region_desc *ndbr_desc; struct nd_blk_region *ndbr; @@ -774,6 +790,14 @@ struct nd_region *nvdimm_pmem_region_create(struct nvdimm_bus *nvdimm_bus, } EXPORT_SYMBOL_GPL(nvdimm_pmem_region_create); +struct nd_region *nvdimm_vcd_region_create(struct nvdimm_bus *nvdimm_bus, + struct nd_region_desc *ndr_desc) +{ + return nd_region_create(nvdimm_bus, ndr_desc, &nd_vcd_device_type, + __func__); +} +EXPORT_SYMBOL_GPL(nvdimm_vcd_region_create); + struct nd_region *nvdimm_blk_region_create(struct nvdimm_bus *nvdimm_bus, struct nd_region_desc *ndr_desc) { diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index 0c3c30c..0a1f949 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -145,6 +145,8 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd, int nvdimm_bus_check_dimm_count(struct nvdimm_bus *nvdimm_bus, int dimm_count); struct nd_region *nvdimm_pmem_region_create(struct nvdimm_bus *nvdimm_bus, struct nd_region_desc *ndr_desc); +struct nd_region *nvdimm_vcd_region_create(struct nvdimm_bus *nvdimm_bus, + struct nd_region_desc *ndr_desc); struct nd_region *nvdimm_blk_region_create(struct nvdimm_bus *nvdimm_bus, struct nd_region_desc *ndr_desc); struct nd_region *nvdimm_volatile_region_create(struct nvdimm_bus *nvdimm_bus,