Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1889378ybv; Sun, 23 Feb 2020 17:43:27 -0800 (PST) X-Google-Smtp-Source: APXvYqz29ohzoWe2LN7XfXpaKgCZ7b3qDPZySVYEzQP6rXWDcMwKcNJbeJ0U+eGnCyTlASp4iWaW X-Received: by 2002:a9d:7999:: with SMTP id h25mr37955323otm.347.1582508607650; Sun, 23 Feb 2020 17:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582508607; cv=none; d=google.com; s=arc-20160816; b=Uv2djKLIfRLn9voBilEYuckzYINIqgLIn8KPi9A4drtNP3Li/gMrreLXSsbsV/XzTb VAbwUj8CFhJwQOaqWmy54oj04lMIAbZZDL664qUvwEtSwm9jle0X92cLlHUXwDk54irY xFZkk2bCPH0A8rNIT2vhnhEW79M46bT+tPF4CLTarHuuZTUVH+ovSi08rMqbqwfr8Di6 h9RMwbRy/jx0cqzeEQQ1l9MNWWEkcgBCKkl0TyZAxECzYZ4tTjTQn1mXM3jkbY+G+aZm 5z27xmq03SR20D3xxqhCTfEzTxPD7Hzo0KUoRN1nud130zakmwn2Fb8NZZDb1/AWq46T 2TZQ== 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=YhVgmjRGEwVCyeThkvJVHxfg3EG7YiNfvIKBv+nVMeI=; b=jQA/CrNVrDP3rPRWNwee4ydcr4fgGCL7Q8pw+xo6FGyqQ2U7nSN0sDYXkSlo/bQhMG 9UXprgWP4CSyD1guvkoqEDP9T7lR+xF9zqG0NtHN62PmPnVp8qiZFvVdiYYcpjwZXvNo kx9RRlRqem9Y2aB5fOjBcfpuijwL8T2PttMq3/Zu5s61/zf5HiUIW6psUtOsSsYapvTE Qd4xfUyRdU11F3EG2fNQ53GUJikLtFUZQZqVariMpGuYcbUIwD8Bh76bu3iSLbcnhjHM 2LSgvefl4e1uOi0fjaIVSfIqpKddxZcuz4nSC6kQpmSgfCoefMz+VtWnEkmvrLNfRIfO BhFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="LUV/rPwj"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h125si4745522oia.253.2020.02.23.17.43.15; Sun, 23 Feb 2020 17:43:27 -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=@gmail.com header.s=20161025 header.b="LUV/rPwj"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727215AbgBXBmD (ORCPT + 99 others); Sun, 23 Feb 2020 20:42:03 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:38430 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727180AbgBXBmD (ORCPT ); Sun, 23 Feb 2020 20:42:03 -0500 Received: by mail-io1-f65.google.com with SMTP id s24so8599909iog.5; Sun, 23 Feb 2020 17:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YhVgmjRGEwVCyeThkvJVHxfg3EG7YiNfvIKBv+nVMeI=; b=LUV/rPwj6sFkk08tsYihfkSiIOu8DvPGR9ALzpZ9KEjJ6cm9TWhEVZs9gZjyFmGljq hvNoZ9u8VINM0NVs03UyvMhfM790FRf3XJ9AZydNYvoRqSiwaLNqSenynHYtCoED8LCw 179biq4AALGeC06TKxnhDnmaLqwcFsmVT6PgPICaHH6IyXnfkpOLiO8VIMGa4vT3so6s sG9GWsbxFay4pd/LRS9RapfOb0zBs3zUbaQWcf3L9pLU+tg5xg50TvzBrsMJXzpRb42X xOzQlLVWgHVWo6GAxPE+ZZ7vcy20LfDsT+MM6IXZi4WpSxVePSAyytGXAuuWemRY/A91 ArpQ== 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=YhVgmjRGEwVCyeThkvJVHxfg3EG7YiNfvIKBv+nVMeI=; b=qCY1ebVaaV3XmUyxitSk0rYZfvCCv961I5YY5ta/HToS/zp45Pus+PS7noaldhiP1I EAFYDYwoyBDerLS5xugIkxVm0lGLH7k+LyAx4iYc9ZaaQlaM+9kumtl338XcfQZ86GzZ Ml9Dgrk8E9x8oRP0Qc6JisQHDv/YY4Uk6ssEkkcQBFA/Gzsi1ZoRWiJiFiiVcpAVqLsn ccBFlq3r7TnlmDQCgHUMOdW9y7EZHcnFVX5o06YD5bHNhpRwsTSc7xdFBd168Vgdk59k q4rZZoP0n3vsfP7gh2Q1nNCn3sneWINpevW1MDAz5ILIefWA1M5Dsn0Hu7+vO753LOQR RC5w== X-Gm-Message-State: APjAAAUkgbgWnnzZqlcCqMapc28R/HJpKGDpkC2hQQ2d8leFwPzoiQZz N7643DZV2RykL7DfusYdkVlxdUBB2tCsIbTi8CqEti2b+V0= X-Received: by 2002:a5d:87ca:: with SMTP id q10mr49147056ios.192.1582508522424; Sun, 23 Feb 2020 17:42:02 -0800 (PST) MIME-Version: 1.0 References: <20200222183010.197844-1-adelva@google.com> <20200223145635.GB29607@iweiny-DESK2.sc.intel.com> In-Reply-To: <20200223145635.GB29607@iweiny-DESK2.sc.intel.com> From: "Oliver O'Halloran" Date: Mon, 24 Feb 2020 12:41:51 +1100 Message-ID: Subject: Re: [PATCH 1/2] libnvdimm/of_pmem: handle memory-region in DT To: Ira Weiny Cc: Alistair Delva , 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 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. > > Ira > > } > > > > return 0; > > -- > > 2.25.0.265.gbab2e86ba0-goog > >