From patchwork Fri Jun 24 07:51:50 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: 9196879 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 9A13C6075F for ; Fri, 24 Jun 2016 07:54:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88D2F28499 for ; Fri, 24 Jun 2016 07:54:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CE2A2849E; Fri, 24 Jun 2016 07:54:59 +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 727ED28499 for ; Fri, 24 Jun 2016 07:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166AbcFXHyz (ORCPT ); Fri, 24 Jun 2016 03:54:55 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33685 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750874AbcFXHyy (ORCPT ); Fri, 24 Jun 2016 03:54:54 -0400 Received: by mail-pf0-f195.google.com with SMTP id c74so8627859pfb.0; Fri, 24 Jun 2016 00:54:53 -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=dHsO+Fpot8HQH64OGs74rkHA9kM7bEfntu5q/E7S5r4=; b=AlT76AgJy2x5QZBxN4EpdG2dxHEla67M276DHhPn2NhGmS9lu4lXMuzxVSDVdCS0Kn 0XJEKqPv35CkUW9Ucz6WUINv7omPhzm0pH4/LlGSDpyzJX2we2FwcVzeUu+vasN6rDn4 yc28y0AxT3nKyU5WlCspAk6XuGyOz4oQ1g2Wkoi0ljmHS5bchSUTS/rzWcwKpL6tXiTe FsEr3W3ATLmjzbLZ2/UGoHUqAgzL7y0RIclv39snW4oPu6UQK3BJ+DBDHoGbXFA9qtOL ODZp94ME82vcXq3FzbGuSv+kqerkkhUoTtMg9Dnz8ahXm2qfaSBuS/7Qjnp6Y5JrNCwh dX/w== 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=dHsO+Fpot8HQH64OGs74rkHA9kM7bEfntu5q/E7S5r4=; b=ZTSkuOinEuz1edgV/0aRADzTxBT1T+PxDbR90urB4Pvo3ns3J43bRjYuRRPnFipChd ulzubWmROGUcEiNsW8m4FcDgNuQ+n+W2Qh3FGLbRtx8xdMihqMVLCcFrv6rQOZ5L4j5y C7cEnrG9+co1HGtFQV5qy0+0SWA0OFEQsus/WPXxo0vbwsnZtHezCiXtyYeV/c+wW57U 78KylMGfWFNxrdFwqkm6P6hypz7wdszY+sQlVhQZugoh2K2CvN7vyhl3cdIwF9K/CkRL ixSUq/FbElhQS1D/fFvE7vykFrHP5wXBYdqrpC+VDjaQWtYBqQSof3S7cXyE+zD3P8ck 8kdQ== X-Gm-Message-State: ALyK8tKnz2I8rBKoF66U3Br/8aA6fyxhF/TdrvWf3WfZalatUGUZXgTrJW4ImApG5cyc+g== X-Received: by 10.98.40.4 with SMTP id o4mr4845711pfo.165.1466754893159; Fri, 24 Jun 2016 00:54:53 -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 k9sm5376566pao.19.2016.06.24.00.54.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jun 2016 00:54:52 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Ross Zwisler , Dan Williams , "Rafael J. Wysocki" , Linda Knippers Cc: linux-nvdimm@lists.01.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Gary Lin Subject: [PATCH v2] libnvdimm, nfit: treat volatile virtual CD region as pmem Date: Fri, 24 Jun 2016 15:51:50 +0800 Message-Id: <1466754710-5948-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 logic to treat volatile virtual CD region as pmem region, then /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 The ramdisk function in EDK2/OVMF generates a ACPI0012 root device that it contains empty _STA but without _DSM: DefinitionBlock ("ssdt2.aml", "SSDT", 2, "INTEL ", "RamDisk ", 0x00001000) { Scope (\_SB) { Device (NVDR) { Name (_HID, "ACPI0012") // _HID: Hardware ID Name (_STR, Unicode ("NVDIMM Root Device")) // _STR: Description String Method (_STA, 0, NotSerialized) // _STA: Status { Return (0x0F) } } } } In section 5.2.25.2 of ACPI 6.1 spec, it mentions that the "SPA Range Structure Index" of VCD SPA shall be set to zero. That means VCD SPA will not be associated by any NVDIMM region mapping. The VCD's SPA Range Structure in NFIT is similar to virtual disk region as following: [028h 0040 2] Subtable Type : 0000 [System Physical Address Range] [02Ah 0042 2] Length : 0038 [02Ch 0044 2] Range Index : 0000 [02Eh 0046 2] Flags (decoded below) : 0000 Add/Online Operation Only : 0 Proximity Domain Valid : 0 [030h 0048 4] Reserved : 00000000 [034h 0052 4] Proximity Domain : 00000000 [038h 0056 16] Address Range GUID : 77AB535A-45FC-624B-5560-F7B281D1F96E [048h 0072 8] Address Range Base : 00000000B6ABD018 [050h 0080 8] Address Range Length : 0000000005500000 [058h 0088 8] Memory Map Attribute : 0000000000000000 The range index set to zero that means the VCD region not associated by any NVDIMM region mapping, and it will not assoicate to "flush hint", "interleave" or "control region". After testing on OVMF, pmem driver can support the region that it doesn't assoicate to any NVDIMM mapping. So, treat VCD as pmem is a idea to get a pmem block device that it containts iso. v2 Removed the code for setting VCD to a read-only region. Cc: Gary Lin Cc: Dan Williams Cc: Ross Zwisler Cc: "Rafael J. Wysocki" Cc: Linda Knippers Signed-off-by: Lee, Chun-Yi --- drivers/acpi/nfit.c | 8 +++++++- drivers/nvdimm/region_devs.c | 26 +++++++++++++++++++++++++- include/linux/libnvdimm.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/drivers/acpi/nfit.c =================================================================== --- linux.orig/drivers/acpi/nfit.c +++ linux/drivers/acpi/nfit.c @@ -1995,7 +1995,7 @@ static int acpi_nfit_register_region(str 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 +2059,11 @@ static int acpi_nfit_register_region(str 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: Index: linux/drivers/nvdimm/region_devs.c =================================================================== --- linux.orig/drivers/nvdimm/region_devs.c +++ linux/drivers/nvdimm/region_devs.c @@ -56,9 +56,19 @@ static struct device_type nd_volatile_de .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) @@ -774,6 +784,14 @@ struct nd_region *nvdimm_pmem_region_cre } 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) { Index: linux/include/linux/libnvdimm.h =================================================================== --- linux.orig/include/linux/libnvdimm.h +++ linux/include/linux/libnvdimm.h @@ -145,6 +145,8 @@ u32 nd_cmd_out_size(struct nvdimm *nvdim 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,