From patchwork Sat Feb 22 18:30:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Delva X-Patchwork-Id: 11398283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C4B7930 for ; Sat, 22 Feb 2020 18:30:19 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDA2520702 for ; Sat, 22 Feb 2020 18:30:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="rbOWC4VR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDA2520702 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A413A1007A84E; Sat, 22 Feb 2020 10:31:10 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::f49; helo=mail-qv1-xf49.google.com; envelope-from=3nxnrxgykdfo256dn28gg8d6.4gedafmp-fn5aeedaklk.st.gj8@flex--adelva.bounces.google.com; receiver= Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EA49D1007B1FC for ; Sat, 22 Feb 2020 10:31:07 -0800 (PST) Received: by mail-qv1-xf49.google.com with SMTP id g6so3663943qvp.0 for ; Sat, 22 Feb 2020 10:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=1SCGFJcdT57UM9g569dFzCXIAoXI2cL9T0Egcs4At5A=; b=rbOWC4VRcR9Ei8+SP5+fapjsG7JlPOKlvg+6qkAOKcy6S/PxZg8y9o8/iIVVyJzQkW 9ip7Q7kYYyXMXXXHv88LopTajfUnbdYyt5OkA+tLHFSAE90ujIrBQjaMBXPPp3jSfvC/ DVzVECbEepl/OuWA/FGV1dp5oEP9g6coMxU0VY7VWgdnJigkNDeJpwObPa47iOzjo3at qMKV56vuAatorqaL/0c60rV+QnIljtSwi795S+MLa3Y7gsohW1qCnzUjKct0OM33VHCm PxSouKW+/VhINbMOOj1hyCHu3RxI4zYU7SmlVsv+iSMtdW/a8qWiRR6aBgUJXOg8kr/B yTcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1SCGFJcdT57UM9g569dFzCXIAoXI2cL9T0Egcs4At5A=; b=n0nJnuFaSDSmiRotkP9Dd8KMmzgZ1GmNWFQ5j32ZEALb45UWboMaSaBvBGAH5XdHxM xzlzIBRqN8Q0lZv0HLTdDpY6EiiTioSBe0HPb4ZX8QCNQVUkc5emz8E9L9vs6uZ+Oluf hwq7htH+Ldp8WItjhYSePe0PEAABMgMF+iCTTcV4GTjygKeRCs9n7pj3Brg8+lTtbmIJ tFTrwpe+4lg25IFk6vMNWLkof2KnXQK6G3m1ERR0z/Yk6xV7A1pZHDpA8BD3hjaDrw+1 +vGhCUMbtwpHM5iNlni2T/8WMzCISZyP6uLXptF2iVGM70p43j4t2LgAKlX1VLQhwQGA BjJg== X-Gm-Message-State: APjAAAUX7fezOp43oDCCTPqys7KLUBQJSsPVYWzVpjydX4hT/84ztzPw prPzqHo0JU1PeXlrzD/4eznxzw5LRUA= X-Google-Smtp-Source: APXvYqyI0nbEkK8t5PqjH2XUeMtXnlvIm2qcZEUezASmjw62vNPGTkH8/bD15V7Jh7dUFdFSRS3DMwUqrcY= X-Received: by 2002:ac8:835:: with SMTP id u50mr38957444qth.15.1582396213599; Sat, 22 Feb 2020 10:30:13 -0800 (PST) Date: Sat, 22 Feb 2020 10:30:09 -0800 Message-Id: <20200222183010.197844-1-adelva@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH 1/2] libnvdimm/of_pmem: handle memory-region in DT From: Alistair Delva To: linux-kernel@vger.kernel.org Message-ID-Hash: 3EM2JAO24TNUV4CFLLRVANDNZX26FXHW X-Message-ID-Hash: 3EM2JAO24TNUV4CFLLRVANDNZX26FXHW X-MailFrom: 3NXNRXgYKDFo256DN28GG8D6.4GEDAFMP-FN5AEEDAKLK.ST.GJ8@flex--adelva.bounces.google.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Kenny Root , Rob Herring , devicetree@vger.kernel.org, linux-nvdimm@lists.01.org, kernel-team@android.com X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kenny Root Add support for parsing the 'memory-region' DT property in addition to the 'reg' DT property. This enables use cases where the pmem region is not in I/O address space or dedicated memory (e.g. a bootloader carveout). Signed-off-by: Kenny Root Signed-off-by: Alistair Delva Cc: "Oliver O'Halloran" Cc: Rob Herring Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Cc: devicetree@vger.kernel.org Cc: linux-nvdimm@lists.01.org Cc: kernel-team@android.com Reviewed-by: Oliver O'Halloran --- drivers/nvdimm/of_pmem.c | 75 ++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c index 8224d1431ea9..a68e44fb0041 100644 --- a/drivers/nvdimm/of_pmem.c +++ b/drivers/nvdimm/of_pmem.c @@ -14,13 +14,47 @@ struct of_pmem_private { struct nvdimm_bus *bus; }; +static void of_pmem_register_region(struct platform_device *pdev, + struct nvdimm_bus *bus, + struct device_node *np, + struct resource *res, bool is_volatile) +{ + struct nd_region_desc ndr_desc; + struct nd_region *region; + + /* + * NB: libnvdimm copies the data from ndr_desc into it's own + * structures so passing a stack pointer is fine. + */ + memset(&ndr_desc, 0, sizeof(ndr_desc)); + ndr_desc.numa_node = dev_to_node(&pdev->dev); + ndr_desc.target_node = ndr_desc.numa_node; + ndr_desc.res = res; + ndr_desc.of_node = np; + set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); + + if (is_volatile) + region = nvdimm_volatile_region_create(bus, &ndr_desc); + else + region = nvdimm_pmem_region_create(bus, &ndr_desc); + + if (!region) + dev_warn(&pdev->dev, + "Unable to register region %pR from %pOF\n", + ndr_desc.res, np); + else + dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n", + ndr_desc.res, np); +} + static int of_pmem_region_probe(struct platform_device *pdev) { struct of_pmem_private *priv; - struct device_node *np; + struct device_node *mrp, *np; struct nvdimm_bus *bus; + struct resource res; bool is_volatile; - int i; + int i, ret; np = dev_of_node(&pdev->dev); if (!np) @@ -46,31 +80,22 @@ static int of_pmem_region_probe(struct platform_device *pdev) is_volatile ? "volatile" : "non-volatile", np); for (i = 0; i < pdev->num_resources; i++) { - struct nd_region_desc ndr_desc; - struct nd_region *region; - - /* - * NB: libnvdimm copies the data from ndr_desc into it's own - * structures so passing a stack pointer is fine. - */ - memset(&ndr_desc, 0, sizeof(ndr_desc)); - ndr_desc.numa_node = dev_to_node(&pdev->dev); - ndr_desc.target_node = ndr_desc.numa_node; - ndr_desc.res = &pdev->resource[i]; - ndr_desc.of_node = np; - set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); - - if (is_volatile) - region = nvdimm_volatile_region_create(bus, &ndr_desc); - else - region = nvdimm_pmem_region_create(bus, &ndr_desc); + of_pmem_register_region(pdev, bus, np, &pdev->resource[i], + is_volatile); + } - if (!region) - dev_warn(&pdev->dev, "Unable to register region %pR from %pOF\n", - ndr_desc.res, np); + i = 0; + while ((mr_np = of_parse_phandle(np, "memory-region", i++))) { + ret = of_address_to_resource(mr_np, 0, &res); + if (ret) + dev_warn( + &pdev->dev, + "Unable to acquire memory-region from %pOF: %d\n", + mr_np, ret); else - dev_dbg(&pdev->dev, "Registered region %pR from %pOF\n", - ndr_desc.res, np); + of_pmem_register_region(pdev, bus, np, &res, + is_volatile); + of_node_put(mr_np); } return 0; From patchwork Sat Feb 22 18:30:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Delva X-Patchwork-Id: 11398285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 512C117F0 for ; Sat, 22 Feb 2020 18:30:19 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FC66206E2 for ; Sat, 22 Feb 2020 18:30:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="PgQzLg8q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FC66206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B70B510FC3361; Sat, 22 Feb 2020 10:31:10 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::54a; helo=mail-pg1-x54a.google.com; envelope-from=3ohnrxgykdf0589gq5bjjbg9.7jhgdips-iq8dhhgdnon.vw.jmb@flex--adelva.bounces.google.com; receiver= Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C787A1007B1FC for ; Sat, 22 Feb 2020 10:31:08 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id l17so3160488pgh.21 for ; Sat, 22 Feb 2020 10:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=LqkliWMqkbYqRIuupuOLJ6kzkCRKDL/XTv8pUZxzvKQ=; b=PgQzLg8qKzkyhPyxTmoaNbnjNiSyl7EAdKe9zlgr7TFwxMb8ScYriPIQUviohO4BSk nUR9tkQzOmQFjuXA1r1vnn/cKgcN9herEGiD+8RcQ5/kjryJFb1QCWQB68vGKhtmmgH/ sDAHhKQrgYrgoL3KjmL3XDRC4b/vmMsjwr48xg6ZF82kNigCID53t8L0ht6mg+ro4qoc /WfCokur3PuPbHVzNIO3SE6niOinINt9R1b06lNInZVj1C5XUBd+v9ygMq3wQe/e/6p8 8E+UZTx4ZMxQKRikHlAw/aYtrrZSsf7C++C1js0gybHMgS+8OWKW7jMi9NcWaOXrRPaX 3bcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LqkliWMqkbYqRIuupuOLJ6kzkCRKDL/XTv8pUZxzvKQ=; b=pvz+qSpVlxtMYcpdCLHIh6qkVqhhhhrh2tDqRUL+ngTxbnZOn0n1yUolDaLz/kg9+P 7s1I5Vq5m5sJONxJJ2+P/dj7CFvX9Sa2vNoxOUeg96koZTRPtEOSFIKTnVp2ktFNoxXs 4ulxwTBVuDsnpWP2qmUMiBywgRKoIgWNrk5f8FvShVJbmOftkgAZC7+H9KVrIHP2Qxlb jh19gymSu9FwtIZoLejNGtJUan8iJ46JqyUWIFOO0mhkoUA9Pqx2RJZiAY0UhqKhXObf y/UFFC68AdeWQ/1LkyMTe9Si4+fha2wq8ZtobdEvEJkMa0/q0BYyeRQpCBwhBS74P//B EXZA== X-Gm-Message-State: APjAAAXZ36CGnKb3IVhnKL+W4Z0cJwrnw/aY4VzJhKR22HHBXezIcx30 l/JqDsOFCTwoTQKXENOTdybaI6NRqCw= X-Google-Smtp-Source: APXvYqzQdQgHQ6fWCJuIXWIAgYGxlrY2CrH849Fe3I+ATdbmceKERzMpxkHMUK63twO0nuNjfUKmQrh7v4U= X-Received: by 2002:a63:120f:: with SMTP id h15mr46221489pgl.235.1582396216132; Sat, 22 Feb 2020 10:30:16 -0800 (PST) Date: Sat, 22 Feb 2020 10:30:10 -0800 In-Reply-To: <20200222183010.197844-1-adelva@google.com> Message-Id: <20200222183010.197844-2-adelva@google.com> Mime-Version: 1.0 References: <20200222183010.197844-1-adelva@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH 2/2] dt-bindings: pmem-region: Document memory-region From: Alistair Delva To: linux-kernel@vger.kernel.org Message-ID-Hash: N6E7KE2LUNQMI7Y3YNPE24FU4XCBMOSQ X-Message-ID-Hash: N6E7KE2LUNQMI7Y3YNPE24FU4XCBMOSQ X-MailFrom: 3OHNRXgYKDF0589GQ5BJJBG9.7JHGDIPS-IQ8DHHGDNON.VW.JMB@flex--adelva.bounces.google.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Kenny Root , Rob Herring , devicetree@vger.kernel.org, linux-nvdimm@lists.01.org, kernel-team@android.com X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kenny Root Add documentation and example for memory-region in pmem. Signed-off-by: Kenny Root Signed-off-by: Alistair Delva Cc: "Oliver O'Halloran" Cc: Rob Herring Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Ira Weiny Cc: devicetree@vger.kernel.org Cc: linux-nvdimm@lists.01.org Cc: kernel-team@android.com --- .../devicetree/bindings/pmem/pmem-region.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/pmem/pmem-region.txt b/Documentation/devicetree/bindings/pmem/pmem-region.txt index 5cfa4f016a00..851ffa71967e 100644 --- a/Documentation/devicetree/bindings/pmem/pmem-region.txt +++ b/Documentation/devicetree/bindings/pmem/pmem-region.txt @@ -29,6 +29,18 @@ Required properties: in a separate device node. Having multiple address ranges in a node implies no special relationship between the two ranges. + This property may be replaced or supplemented with a + memory-region property. Only one of reg or memory-region + properties is required. + + - memory-region: + Reference to the reserved memory node. The reserved memory + node should be defined as per the bindings in + reserved-memory.txt + + This property may be replaced or supplemented with a reg + property. Only one of reg or memory-region is required. + Optional properties: - Any relevant NUMA assocativity properties for the target platform. @@ -63,3 +75,21 @@ Examples: volatile; }; + + /* + * This example uses a reserved-memory entry instead of + * specifying the memory region directly in the node. + */ + + reserved-memory { + pmem_1: pmem@5000 { + no-map; + reg = <0x00005000 0x00001000>; + }; + }; + + pmem@1 { + compatible = "pmem-region"; + memory-region = <&pmem_1>; + }; +