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,
Keith Busch <keith.busch@intel.com>,
Max Filippov <jcmvbkbc@gmail.com>,
Paul Mackerras <paulus@samba.org>,
baiyaowei@cmss.chinamobile.com,
Frank Rowand <frowand.list@gmail.com>,
Dan Williams <dan.j.williams@intel.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>,
Vivek Goyal <vgoyal@redhat.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Maarten
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
next prev parent 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
[not found] ` <20180718024944.577-1-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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]
[not found] ` <CAHp75VdO88ydJQ9GHdaDUmAmzL6QHR=US6JiXZ1R_EEA-xWR1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-07-18 16:37 ` Andy Shevchenko
[not found] ` <CAHp75Vf2yEwHhEhhQH2XN+pOQ=-skiAHZ=FgLnfVV8vcm59qeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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
[not found] ` <20180718153326.b795e9ea7835432a56cd7011-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2018-07-19 15:17 ` Baoquan He
[not found] ` <20180719151753.GB7147-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2018-07-19 19:44 ` Andrew Morton
[not found] ` <20180719124444.c893712cca2e6f2649d1bc0d-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2018-07-25 2:21 ` Baoquan He
2018-07-23 14:34 ` Michal Hocko
[not found] ` <20180723143443.GD18181-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-07-25 6:48 ` Baoquan He
2018-07-26 12:59 ` Michal Hocko
[not found] ` <20180726125957.GH28386-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-07-26 13:09 ` Baoquan He
2018-07-26 13:12 ` Michal Hocko
[not found] ` <20180726131242.GI28386-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-07-26 13:14 ` Michal Hocko
[not found] ` <20180726131420.GJ28386-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
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=baiyaowei@cmss.chinamobile.com \
--cc=bhe@redhat.com \
--cc=bp@suse.de \
--cc=brijesh.singh@amd.com \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dyoung@redhat.com \
--cc=frowand.list@gmail.com \
--cc=gustavo@padovan.org \
--cc=haiyangz@microsoft.com \
--cc=jcmvbkbc@gmail.com \
--cc=keith.busch@intel.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--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=sthemmin@microsoft.com \
--cc=thomas.lendacky@amd.com \
--cc=vgoyal@redhat.com \
/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).