nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Baoquan He <bhe@redhat.com>
Cc: "Nicolas Pitre" <nicolas.pitre@linaro.org>,
	brijesh.singh@amd.com, devicetree <devicetree@vger.kernel.org>,
	"David Airlie" <airlied@linux.ie>,
	linux-pci@vger.kernel.org, richard.weiyang@gmail.com,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Paul Mackerras" <paulus@samba.org>,
	baiyaowei@cmss.chinamobile.com,
	"KY Srinivasan" <kys@microsoft.com>,
	"Frank Rowand" <frowand.list@gmail.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Stephen Hemminger" <sthemmin@microsoft.com>,
	linux-nvdimm@lists.01.org,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Patrik Jakobsson" <patrik.r.jakobsson@gmail.com>,
	linux-input <linux-input@vger.kernel.org>,
	"Gustavo Padovan" <gustavo@padovan.org>,
	"Borislav Petkov" <bp@suse.de>, "Dave Young" <dyoung@redhat.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Josh Triplett" <josh@joshtriplett.org>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Sean Paul" <seanpaul@chromium.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Yinghai Lu" <yinghai@kernel.org>,
	"Jon Derrick" <jonathan.derrick@intel.com>,
	"Chris Zankel" <chris@zankel.net>,
	"Michal Simek" <monstr@monstr.eu>,
	linux-parisc@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
	"Eric Biederman" <ebiederm@xmission.com>,
	devel@linuxdriverproject.org,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"kbuild test robot" <fengguang.wu@intel.com>,
	"open list:LINUX FOR POWERPC PA SEMI PWRFICIENT"
	<linuxppc-dev@lists.ozlabs.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v7 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public
Date: Wed, 18 Jul 2018 19:36:17 +0300	[thread overview]
Message-ID: <CAHp75VdO88ydJQ9GHdaDUmAmzL6QHR=US6JiXZ1R_EEA-xWR1Q@mail.gmail.com> (raw)
In-Reply-To: <20180718024944.577-2-bhe@redhat.com>

On Wed, Jul 18, 2018 at 5:49 AM, Baoquan He <bhe@redhat.com> wrote:
> reparent_resources() is duplicated in arch/microblaze/pci/pci-common.c
> and arch/powerpc/kernel/pci-common.c, so move it to kernel/resource.c
> so that it's shared.

Some minor stuff.

> +/**
> + * reparent_resources - reparent resource children of parent that res covers
> + * @parent: parent resource descriptor
> + * @res: resource descriptor desired by caller
> + *
> + * Returns 0 on success, -ENOTSUPP if child resource is not completely
> + * contained by 'res', -ECANCELED if no any conflicting entry found.

'res' -> @res

> + *
> + * Reparent resource children of 'parent' that conflict with 'res'

Ditto + 'parent' -> @parent

> + * under 'res', and make 'res' replace those children.

Ditto.

> + */
> +int reparent_resources(struct resource *parent, struct resource *res)
> +{
> +       struct resource *p, **pp;
> +       struct resource **firstpp = NULL;
> +
> +       for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) {
> +               if (p->end < res->start)
> +                       continue;
> +               if (res->end < p->start)
> +                       break;
> +               if (p->start < res->start || p->end > res->end)
> +                       return -ENOTSUPP;       /* not completely contained */
> +               if (firstpp == NULL)
> +                       firstpp = pp;
> +       }
> +       if (firstpp == NULL)
> +               return -ECANCELED; /* didn't find any conflicting entries? */
> +       res->parent = parent;
> +       res->child = *firstpp;
> +       res->sibling = *pp;
> +       *firstpp = res;
> +       *pp = NULL;
> +       for (p = res->child; p != NULL; p = p->sibling) {
> +               p->parent = res;

> +               pr_debug("PCI: Reparented %s %pR under %s\n",
> +                        p->name, p, res->name);

Now, PCI is a bit confusing here.

> +       }
> +       return 0;
> +}
> +EXPORT_SYMBOL(reparent_resources);
> +
>  static void __init __reserve_region_with_split(struct resource *root,
>                 resource_size_t start, resource_size_t end,
>                 const char *name)
> --
> 2.13.6
>



-- 
With Best Regards,
Andy Shevchenko
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-07-18 16:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  2:49 [PATCH v7 0/4] resource: Use list_head to link sibling resource Baoquan He
2018-07-18  2:49 ` [PATCH v7 1/4] resource: Move reparent_resources() to kernel/resource.c and make it public Baoquan He
2018-07-18 16:36   ` Andy Shevchenko [this message]
2018-07-18 16:37     ` Andy Shevchenko
2018-07-19 15:18       ` Baoquan He
2018-07-18  2:49 ` [PATCH v7 2/4] resource: Use list_head to link sibling resource Baoquan He
2018-07-18  2:49 ` [PATCH v7 3/4] resource: add walk_system_ram_res_rev() Baoquan He
2018-07-18  2:49 ` [PATCH v7 4/4] kexec_file: Load kernel at top of system RAM if required Baoquan He
2018-07-18 22:33   ` Andrew Morton
2018-07-19 15:17     ` Baoquan He
2018-07-19 19:44       ` Andrew Morton
2018-07-25  2:21         ` Baoquan He
2018-07-23 14:34       ` Michal Hocko
2018-07-25  6:48         ` Baoquan He
2018-07-26 12:59           ` Michal Hocko
2018-07-26 13:09             ` Baoquan He
2018-07-26 13:12               ` Michal Hocko
2018-07-26 13:14                 ` Michal Hocko
2018-07-26 13:37                   ` Baoquan He
2018-07-26 14:01                     ` Michal Hocko
2018-07-26 15:10                       ` Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHp75VdO88ydJQ9GHdaDUmAmzL6QHR=US6JiXZ1R_EEA-xWR1Q@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=baiyaowei@cmss.chinamobile.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhe@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=chris@zankel.net \
    --cc=davem@davemloft.net \
    --cc=devel@linuxdriverproject.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=fengguang.wu@intel.com \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@padovan.org \
    --cc=haiyangz@microsoft.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jglisse@redhat.com \
    --cc=jonathan.derrick@intel.com \
    --cc=josh@joshtriplett.org \
    --cc=kys@microsoft.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=monstr@monstr.eu \
    --cc=mpe@ellerman.id.au \
    --cc=nicolas.pitre@linaro.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=paulus@samba.org \
    --cc=richard.weiyang@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=seanpaul@chromium.org \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).