From patchwork Thu Jul 7 03:43:03 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: 9217757 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 9F3B160467 for ; Thu, 7 Jul 2016 03:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A66828681 for ; Thu, 7 Jul 2016 03:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ED4028682; Thu, 7 Jul 2016 03:45:27 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B53A128686 for ; Thu, 7 Jul 2016 03:45:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C8DAE1A1DF3; Wed, 6 Jul 2016 20:46:06 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pa0-x242.google.com (mail-pa0-x242.google.com [IPv6:2607:f8b0:400e:c03::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C2B811A1DF3 for ; Wed, 6 Jul 2016 20:46:05 -0700 (PDT) Received: by mail-pa0-x242.google.com with SMTP id ib6so608593pad.3 for ; Wed, 06 Jul 2016 20:45:24 -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=H9BJd4/jNZjCJTPGPcCTEBWNi+Fskf3C3iWzdS3GhpU=; b=hjT2uD3GQLMm+Kp9zMXGMmGc4WTgxlqJvWK2yQtnvdqwigBRr2fTiDTiFdkNyGt6Yp 5hyUyEmzwXb4UsG5GbLBt5pH9/J6O3gGyfxCsl7t292EDw1JUDnAQhK7HoKShWdhp+1O h11UdWS0cVew6X1nZYLXVgeGeps20peLNAzQ6nQtKYaIP6ffwz/a4kQOce6R9HkIdXg9 1ubgbkCkV0P/kHTSDbSPEL5EavzwzGdUpDAkjqByptySFlgrMnMrESuLfuwco0ucxxGv HjjTu1pqInOc57Kfme0HU8eT2AgX+wc2BX5t+aQFQwmNbmM1BZ1bQVj70fyZz8hDLBr9 7w1g== 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=H9BJd4/jNZjCJTPGPcCTEBWNi+Fskf3C3iWzdS3GhpU=; b=ZTDgnaeAV7cOPpqVWLZRz+Sr0E1Xu2GLHPxNeWBOD/lO3ar+m160vUR8zPNxG95DN0 9Xn+Tiw9MKKeDOpWHxTJygDulnDiJim0P2is6YgQ6T20aD3SXFWfL10ptH0Mz2k5ydl1 cEes44YLXCPz6niaszI08CSqsQ6J4ePN5Jl1H8DJUkmklEr7fBPCqEvc55IGwb5DVD2J qnXY5GoWcmQvcfhqliQYq9DpIOGeH6f0gorFtbIanJZn6I+BuYRrbTEzLoxyP2Ven+xX rgivvG63CYDUfeGK0XocgOhfUaX88pY/8jE1XAklHPriVG2Oj7hbs+Cc6QuhcnveID0B SIig== X-Gm-Message-State: ALyK8tI1/oZeBWrD03II4qvWC4LPOCf8y2H2jHQduHO4rNDhA1ufRz5kN7jSjompG1SUmg== X-Received: by 10.66.65.109 with SMTP id w13mr48656802pas.142.1467863124386; Wed, 06 Jul 2016 20:45:24 -0700 (PDT) Received: from linux-rxt1.site ([203.192.156.9]) by smtp.gmail.com with ESMTPSA id o68sm645587pfb.18.2016.07.06.20.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 20:45:23 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Ross Zwisler , Dan Williams , "Rafael J. Wysocki" , Linda Knippers Subject: [PATCH v4] acpi, nfit: treat virtual ramdisk SPA as pmem region Date: Thu, 7 Jul 2016 11:43:03 +0800 Message-Id: <1467862983-32452-1-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.8.4.5 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Lee, Chun-Yi" , linux-acpi@vger.kernel.org, Gary Lin , linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds logic to treat virtual ramdisk SPA as pmem region, then ramdisk's /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 virtual SPA shall be set to zero. That means virtual 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 way to not associate a SPA range is to never reference it from a "flush hint", "interleave", or "control region" table. After testing on OVMF, pmem driver can support the region that it doesn't assoicate to any NVDIMM mapping. So, treat VCD like pmem is a idea to get a pmem block device that it contains iso. v4: Instoduce nfit_spa_is_virtual() to check virtual ramdisk SPA and create pmem region. v3: To simplify patch, removed useless VCD region in libnvdimm. 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(-) Index: linux/drivers/acpi/nfit.c =================================================================== --- linux.orig/drivers/acpi/nfit.c +++ linux/drivers/acpi/nfit.c @@ -1980,6 +1980,14 @@ static int acpi_nfit_init_mapping(struct return 0; } +static bool nfit_spa_is_virtual(struct acpi_nfit_system_address *spa) +{ + return (nfit_spa_type(spa) == NFIT_SPA_VDISK || + nfit_spa_type(spa) == NFIT_SPA_VCD || + nfit_spa_type(spa) == NFIT_SPA_PDISK || + nfit_spa_type(spa) == NFIT_SPA_PCD); +} + static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, struct nfit_spa *nfit_spa) { @@ -1995,7 +2003,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_is_virtual(spa)) { dev_dbg(acpi_desc->dev, "%s: detected invalid spa index\n", __func__); return 0; @@ -2059,6 +2067,11 @@ static int acpi_nfit_register_region(str ndr_desc); if (!nfit_spa->nd_region) rc = -ENOMEM; + } else if (nfit_spa_is_virtual(spa)) { + nfit_spa->nd_region = nvdimm_pmem_region_create(nvdimm_bus, + ndr_desc); + if (!nfit_spa->nd_region) + rc = -ENOMEM; } out: