Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1889904ybv; Sun, 23 Feb 2020 17:44:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxIk+9bKflBnnmwWgJgQAjVQwn/XOSdy9hE4K4ZIElp6sgPkPXh1ucCcDaJATiPKBDa1bOv X-Received: by 2002:a9d:443:: with SMTP id 61mr11070736otc.357.1582508655193; Sun, 23 Feb 2020 17:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582508655; cv=none; d=google.com; s=arc-20160816; b=yjga6nfZsQQM9pKDcwz2exkhFBnyTAh9VJlrtV0n3lkXL4brKOblzvJvH93mVgu0Nn rwInUYptkZWMrw4yFIhLJ/wzVQVRUWuE2qAA0Y1sIjOG7wXP1sYHYiUiIxwbbDfz5fwN drefoee0T1c12lZ/laNuZu4e170d6QuE3k5rQEIaWP5gE7U4ATikWNw5yzPUexhLdYBO Jov3tpvOHnvq4QBE602/5DxmcwIelp6JX+4wCh4J0hdesdV/CjJ+M5BzSrFN9mzknO/p 0vytii8FAFlUlqGGu5NtG7Ho0bDsAF8LPbO0T6OhchdISa48JSvgsbT+7ZNQ2+2InWTO RAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/tDUe/596kLQOTI3w8zi8SEzFY93PKMz1mi66rU0+Hs=; b=KEV6VVzUkgYQ5Etpl/BWAoAeJRZzs0G62AgC9ZBCwzd2M3VZwysMfMH8iwsyxsEtGY pxW8G4usCPsNpyEHvj9SG63wo6WXCc2ZBmH1fWJSVqtxvznA21TS5/mJaw5ty8JFZOfI N+1ACCXoRcra2gCRj9RDx8wGgex8T+Fl/vt5b7yLx8jspputvg9aF1EBguZwo2FcICck xBiLDThUNV3vWJakkPFy9mx1y6wLOxA0SkGP0fGnxEv/tLSoZWFhmP8MFLcJDLHj4AcM TWAuTo4wNaOnUCABt1T5sSOXMOYEwk6XDLp7LBn+KK7TNo/DF87x15MVyc2wrVFvdyAC 3Hjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=odvADANg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si5516269otl.133.2020.02.23.17.44.02; Sun, 23 Feb 2020 17:44:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=odvADANg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbgBXBnn (ORCPT + 99 others); Sun, 23 Feb 2020 20:43:43 -0500 Received: from mail-vk1-f194.google.com ([209.85.221.194]:40116 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbgBXBnm (ORCPT ); Sun, 23 Feb 2020 20:43:42 -0500 Received: by mail-vk1-f194.google.com with SMTP id c129so2096096vkh.7 for ; Sun, 23 Feb 2020 17:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/tDUe/596kLQOTI3w8zi8SEzFY93PKMz1mi66rU0+Hs=; b=odvADANgVGTTfCRvnRE2ojhtUfO+STbMJFvaug7W5NcEtwaHV2bzfquurK62hxfoxz J1WGUscx/FqcJyd2LKg0uW/ayUJhMz9gW4laps101NC0y7kosjR2vtcLKWV5HCwLaVXZ 55q8ZXghnSNGEp1J+fcMyICppzh9rikjzkwxhEZjC9Q33G6d4jZafMi9JMz3Tpocwicf ZKssWuh3fB05xobe3VJud4FR6mqwnA8UcC5XiVkFAT8aT3bmApl0EtWQGrD/KIvtlBGx xQpPlASjuOcmfu9RllWf90OuQBMIYy75dsmFnMc9rbZkj0Ote8ki0v0nu1zQ3Zilf1wF pipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/tDUe/596kLQOTI3w8zi8SEzFY93PKMz1mi66rU0+Hs=; b=UcOCLGW3cSwg+30hK/cfWyS65NDr6QRFtxPEk94K8hVdDMKeEjRRYD/NM8q+ynu4jQ mQouBUICMknu4v/vVo2ca4fR9FnyfyQokSGBOtdGp+s7jQaNm0Vz0F5oUSNrouNVmA2N rLjYN0A9MY5WaIKhi3waLNELhWDZrESQ/dYFFmFigd0JeaT1pNFlDtkWcaMYYa6QJywA zWbx8wRiGsiTgkOLsZcQAUZUzhP/CJPNSRdXmgu9gLdhppUaO32h9h6SWCf9SvOmMbcl Y/vKJYp2ZrYK8CqO+f+ao2OEej8dhmkqh8pefm7LVo3c6WN/qsUtlaeHvNb6rRiSaK+5 VyWw== X-Gm-Message-State: APjAAAWmAnjP4m1HKpFRqLRlq2HN6gbqBIvVxYtFE5z9y8i25Eo+k0nf DYNFsU7S+Zhj0MHCN1tWSIVQ2FeE//3ocMeBoRcw6w== X-Received: by 2002:a1f:90d4:: with SMTP id s203mr22035473vkd.65.1582508620766; Sun, 23 Feb 2020 17:43:40 -0800 (PST) MIME-Version: 1.0 References: <20200222183010.197844-1-adelva@google.com> <20200223145635.GB29607@iweiny-DESK2.sc.intel.com> In-Reply-To: From: Alistair Delva Date: Sun, 23 Feb 2020 17:43:29 -0800 Message-ID: Subject: Re: [PATCH 1/2] libnvdimm/of_pmem: handle memory-region in DT To: "Oliver O'Halloran" Cc: Ira Weiny , Linux Kernel Mailing List , Kenny Root , Rob Herring , Dan Williams , Vishal Verma , Dave Jiang , Device Tree , "linux-nvdimm@lists.01.org" , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 23, 2020 at 5:42 PM Oliver O'Halloran wrote: > > On Mon, Feb 24, 2020 at 1:56 AM Ira Weiny wrote: > > > > On Sat, Feb 22, 2020 at 10:30:09AM -0800, Alistair Delva wrote: > > > 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 > > > --- > > > 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) > > > > FWIW it would be easier to review if this was splut into a patch which created > > the helper of_pmem_register_region() without the new logic. Then added the new > > logic here. > > Yeah, that wouldn't hurt. > > *snip* > > > > + 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); > > > > Why of_node_put()? > > "memory-region" is an array of pointers to nodes in /reserved-memory/ > which describe the actual memory region. of_parse_phandle() elevates > the refcount of the returned node and we need to balance that. That was my understanding too. Thanks both for the review and sorry for the last minute untested variable rename! I'll fix both and split the refactoring out in v2. > > > > Ira > > > } > > > > > > return 0; > > > -- > > > 2.25.0.265.gbab2e86ba0-goog > > >