resource: Use list_head to link sibling resource
Subsystems (19)
v4 cover resource: Use list_head to link sibling resource
This patchset is doing:
1) Replace struct resource's sibling list from singly linked list to list_head. Clearing out those pointer operation within singly linked list for better code readability.
2) Based on list_head replacement, add a new function walk_system_ram_res_rev() which can does reversed iteration on iomem_resource's siblings.
3) Change kexec_file loading to search system RAM top down for kernel loadin, using walk_system_ram_res_rev().
Note:
This patchset passed testing on my kvm guest, x86_64 arch with network enabling. The thing we need pay attetion to is that a root resource's child member need be initialized specifically with LIST_HEAD_INIT() if statically defined or INIT_LIST_HEAD() for dynamically definition. Here Just like we do for iomem_resource/ioport_resource, or the change in get_pci_domain_busn_res().
Links of the old posting(Boris pointed out that we should use
https://lkml.kernel.org/r/Message-ID, while it can't be opened from my side, so paste all of them here.):
v3:
https://lkml.kernel.org/r/20180419001848.3041-1-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
https://lkml.org/lkml/2018/4/18/767
v2:
https://lkml.kernel.org/r/20180408024724.16812-1-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
https://lkml.org/lkml/2018/4/7/169
v1:
https://lkml.kernel.org/r/20180322033722.9279-1-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
https://lkml.org/lkml/2018/3/21/952
Changelog:v3->v4:
Fix several bugs test robot reported. Rewrite cover letter and patch log according to reviewer's comment.
v2->v3:
Rename resource functions first_child() and sibling() to resource_first_chils() and resource_sibling(). Dan suggested this.
Move resource_first_chils() and resource_sibling() to linux/ioport.h and make them as inline function. Rob suggested this. Accordingly add linux/list.h including in linux/ioport.h, please help review if this bring efficiency degradation or code redundancy.
The change on struct resource {} bring two pointers of size increase, mention this in git log to make it more specifically, Rob suggested this.
v1->v2:
Use list_head instead to link resource siblings. This is suggested by Andrew.
Rewrite walk_system_ram_res_rev() after list_head is taken to link resouce siblings.
Baoquan He (3):
resource: Use list_head to link sibling resource
resource: add walk_system_ram_res_rev()
kexec_file: Load kernel at top of system RAM if required
arch/microblaze/pci/pci-common.c | 31 ++-- arch/sparc/kernel/ioport.c | 2 +- arch/xtensa/include/asm/pci-bridge.h | 4 +- drivers/eisa/eisa-bus.c | 2 + drivers/gpu/drm/drm_memory.c | 3 +- drivers/gpu/drm/gma500/gtt.c | 5 +- drivers/hv/vmbus_drv.c | 52 +++---- drivers/input/joystick/iforce/iforce-main.c | 4 +- drivers/nvdimm/e820.c | 2 +- drivers/nvdimm/namespace_devs.c | 6 +- drivers/nvdimm/nd.h | 5 +- drivers/of/address.c | 4 +- drivers/parisc/lba_pci.c | 4 +- drivers/pci/host/vmd.c | 8 +- drivers/pci/probe.c | 2 + drivers/pci/setup-bus.c | 2 +- include/linux/ioport.h | 20 ++- kernel/kexec_file.c | 2 + kernel/resource.c | 221 ++++++++++++++++------------ 19 files changed, 215 insertions(+), 164 deletions(-)
Signature · 1 line
2.13.6
PATCH v4 1/3 resource: Use list_head to link sibling resource
The struct resource uses singly linked list to link siblings, implemented by pointer operation. Replace it with list_head for better code readability.
Based on this list_head replacement, it will be very easy to do reverse iteration on iomem_resource's sibling list in later patch.
Besides, type of member variables of struct resource, sibling and child, are changed from 'struct resource *' to 'struct list_head'. This brings two pointers of size increase.
---v3->v4:
Fix several bugs test robot reported. And change patch log.
v2->v3:
Rename resource functions first_child() and sibling() to resource_first_chils() and resource_sibling(). Dan suggested this.
Move resource_first_chils() and resource_sibling() to linux/ioport.h and make them as inline function. Rob suggested this. Accordingly add linux/list.h including in linux/ioport.h, please help review if this bring efficiency degradation or code redundancy.
The change on struct resource {} bring two pointers of size increase, mention this in git log to make it more specifically, Rob suggested this.
arch/microblaze/pci/pci-common.c | 31 +++-- arch/sparc/kernel/ioport.c | 2 +- arch/xtensa/include/asm/pci-bridge.h | 4 +- drivers/eisa/eisa-bus.c | 2 + drivers/gpu/drm/drm_memory.c | 3 +- drivers/gpu/drm/gma500/gtt.c | 5 +- drivers/hv/vmbus_drv.c | 52 ++++---- drivers/input/joystick/iforce/iforce-main.c | 4 +- drivers/nvdimm/e820.c | 2 +- drivers/nvdimm/namespace_devs.c | 6 +- drivers/nvdimm/nd.h | 5 +- drivers/of/address.c | 4 +- drivers/parisc/lba_pci.c | 4 +- drivers/pci/host/vmd.c | 8 +- drivers/pci/probe.c | 2 + drivers/pci/setup-bus.c | 2 +- include/linux/ioport.h | 17 ++- kernel/resource.c | 181 +++++++++++++--------------- 18 files changed, 170 insertions(+), 164 deletions(-)
arch/microblaze/pci/pci-common.c +18 -13
@@ -533,7 +533,9 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose, res->flags = range.flags; res->start = range.cpu_addr; res->end = range.cpu_addr + range.size -1 ; - res->parent = res->child = res->sibling =NULL ; + res->parent =NULL ; +INIT_LIST_HEAD (&res->child); +INIT_LIST_HEAD (&res->sibling); } }
@@ -625,28 +627,31 @@ EXPORT_SYMBOL(pcibios_add_device);static int __init reparent_resources (struct resource *parent,struct resource *res) { -struct resource *p, **pp; -struct resource **firstpp =NULL ; +struct resource *p, *first =NULL ; -for (pp = &parent->child; (p = *pp) !=NULL ; pp = &p->sibling) { +list_for_each_entry (p, &parent->child, sibling) {if (p->end < res->start)continue ;if (res->end < p->start)break ;if (p->start < res->start || p->end > res->end)return -1 ;/* not completely contained */ -if (firstpp ==NULL ) - firstpp = pp; +if (first ==NULL ) + first = p; } -if (firstpp ==NULL ) +if (first ==NULL )return -1 ;/* 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; +list_add (&res->sibling, &p->sibling.prev); +INIT_LIST_HEAD (&res->child); + +/* +* From first to p's previous sibling, they all fall into +* res's region, change them as res's children. +*/ +list_cut_position (&res->child, first->sibling.prev, res->sibling.prev); +list_for_each_entry (p, &new->child, sibling) { + p->parent = new; pr_debug("PCI: Reparented %s [%llx..%llx] under %s\n", p->name, (unsigned long long)p->start,
arch/sparc/kernel/ioport.c +1 -1
@@ -669,7 +669,7 @@ static int sparc_io_proc_show(struct seq_file *m, void *v)struct resource *root = m->private, *r;const char *nm; -for (r = root->child; r !=NULL ; r = r->sibling) { +list_for_each_entry (r, &root->child, sibling) {if ((nm = r->name) ==NULL ) nm ="???" ; seq_printf(m, "%016llx-%016llx: %s\n", (unsigned long long)r->start,
arch/xtensa/include/asm/pci-bridge.h +2 -2
@@ -71,8 +71,8 @@ static inline void pcibios_init_resource(struct resource *res, res->flags = flags; res->name = name; res->parent =NULL ; - res->sibling =NULL ; - res->child =NULL ; +INIT_LIST_HEAD (&res->child); +INIT_LIST_HEAD (&res->sibling); }
drivers/eisa/eisa-bus.c +2 -0
@@ -408,6 +408,8 @@ static struct resource eisa_root_res = { .start = 0, .end = 0xffffffff, .flags = IORESOURCE_IO, + .sibling = LIST_HEAD_INIT(eisa_root_res.sibling), + .child = LIST_HEAD_INIT(eisa_root_res.child), };static int eisa_bus_count;
drivers/gpu/drm/drm_memory.c +1 -2
@@ -155,9 +155,8 @@ u64 drm_get_max_iomem(void)struct resource *tmp;resource_size_t max_iomem =0 ; -for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) { +list_for_each_entry (tmp, &iomem_resource.child, sibling) max_iomem =max (max_iomem, tmp->end); - }return max_iomem; }
drivers/gpu/drm/gma500/gtt.c +2 -3
@@ -565,7 +565,7 @@ int psb_gtt_init(struct drm_device *dev, int resume)int psb_gtt_restore (struct drm_device *dev) {struct drm_psb_private *dev_priv = dev->dev_private; -struct resource *r = dev_priv->gtt_mem->child; +struct resource *r;struct gtt_range *range;unsigned int restored =0 , total =0 , size =0 ;
@@ -573,14 +573,13 @@ int psb_gtt_restore(struct drm_device *dev)mutex_lock (&dev_priv->gtt_mutex);psb_gtt_init (dev,1 ); -while (r !=NULL ) { +list_for_each_entry (r, &dev_priv->gtt_mem->child, sibling) { range = container_of(r, struct gtt_range, resource);if (range->pages) {psb_gtt_insert (dev, range,1 ); size += range->resource.end - range->resource.start; restored++; } - r = r->sibling; total++; }mutex_unlock (&dev_priv->gtt_mutex);
drivers/hv/vmbus_drv.c +22 -30
99 lines not on this page · raw message
drivers/input/joystick/iforce/iforce-main.c +2 -2
@@ -305,8 +305,8 @@ int iforce_init_device(struct iforce *iforce) iforce->device_memory.end =200 ; iforce->device_memory.flags =IORESOURCE_MEM ; iforce->device_memory.parent =NULL ; - iforce->device_memory.child =NULL ; - iforce->device_memory.sibling =NULL ; +INIT_LIST_HEAD (&iforce->device_memory.child); +INIT_LIST_HEAD (&iforce->device_memory.sibling);/* * Wait until device ready - until it sends its first response.
drivers/nvdimm/e820.c +1 -1
@@ -53,7 +53,7 @@ static int e820_pmem_probe(struct platform_device *pdev) goto err;platform_set_drvdata (pdev, nvdimm_bus); -for (p = iomem_resource.child; p ; p = p->sibling) { +list_for_each_entry (p, &iomem_resource.child, sibling) {struct nd_region_desc ndr_desc;if (p->desc !=IORES_DESC_PERSISTENT_MEMORY_LEGACY )
drivers/nvdimm/namespace_devs.c +3 -3
@@ -637,7 +637,7 @@ static resource_size_t scan_allocate(struct nd_region *nd_region, retry: first =0 ;for_each_dpa_resource (ndd, res) { -struct resource *next = res->sibling, *new_res =NULL ; +struct resource *next =resource_sibling (res), *new_res =NULL ;resource_size_t allocate, available =0 ;enum alloc_loc loc =ALLOC_ERR ;const char *action;
@@ -763,7 +763,7 @@ static resource_size_t scan_allocate(struct nd_region *nd_region,* an initial "pmem-reserve pass". Only do an initial BLK allocation * when none of the DPA space is reserved. */ -if ((is_pmem || !ndd->dpa.child) && n == to_allocate) +if ((is_pmem ||list_empty (&ndd->dpa.child)) && n == to_allocate)return init_dpa_allocation (label_id, nd_region, nd_mapping, n);return n; }
@@ -779,7 +779,7 @@ static int merge_dpa(struct nd_region *nd_region, retry:for_each_dpa_resource (ndd, res) {int rc; -struct resource *next = res->sibling; +struct resource *next =resource_sibling (res);resource_size_t end = res->start +resource_size (res); if (!next || strcmp(res->name, label_id->id) != 0
drivers/nvdimm/nd.h +2 -3
@@ -102,11 +102,10 @@ unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd); (unsigned long long) (res ? res->start : 0), ##arg)#define for_each_dpa_resource (ndd, res) \ - for (res = (ndd)->dpa.child; res; res = res->sibling) + list_for_each_entry(res, &(ndd)->dpa.child, sibling)#define for_each_dpa_resource_safe (ndd, res, next) \ - for (res = (ndd)->dpa.child, next = res ? res->sibling : NULL; \ - res; res = next, next = next ? next->sibling : NULL) + list_for_each_entry_safe(res, next, &(ndd)->dpa.child, sibling)struct nd_percpu_lane {int count;
drivers/of/address.c +3 -1
@@ -330,7 +330,9 @@ int of_pci_range_to_resource(struct of_pci_range *range, {int err; res->flags = range->flags; - res->parent = res->child = res->sibling =NULL ; + res->parent =NULL ; +INIT_LIST_HEAD (&res->child); +INIT_LIST_HEAD (&res->sibling); res->name = np->full_name;if (res->flags &IORESOURCE_IO ) {
drivers/parisc/lba_pci.c +2 -2
@@ -170,8 +170,8 @@ lba_dump_res(struct resource *r, int d)for (i = d; i ; --i)printk (" " );printk (KERN_DEBUG "%p [%lx,%lx]/%lx\n" , r, (long )r->start, (long )r->end, r->flags); -lba_dump_res (r->child, d+2 ); -lba_dump_res (r->sibling, d); +lba_dump_res (resource_first_child (&r->child), d+2 ); +lba_dump_res (resource_sibling (r), d); }
drivers/pci/host/vmd.c +4 -4
@@ -520,14 +520,14 @@ static struct pci_ops vmd_ops = {static void vmd_attach_resources (struct vmd_dev *vmd) { - vmd->dev->resource[VMD_MEMBAR1 ].child = &vmd->resources[1 ]; - vmd->dev->resource[VMD_MEMBAR2 ].child = &vmd->resources[2 ]; +list_add (&vmd->resources[1 ].sibling, &vmd->dev->resource[VMD_MEMBAR1 ].child); +list_add (&vmd->resources[2 ].sibling, &vmd->dev->resource[VMD_MEMBAR2 ].child); }static void vmd_detach_resources (struct vmd_dev *vmd) { - vmd->dev->resource[VMD_MEMBAR1 ].child =NULL ; - vmd->dev->resource[VMD_MEMBAR2 ].child =NULL ; +INIT_LIST_HEAD (&vmd->dev->resource[VMD_MEMBAR1 ].child); +INIT_LIST_HEAD (&vmd->dev->resource[VMD_MEMBAR2 ].child); }/*
drivers/pci/probe.c +2 -0
@@ -59,6 +59,8 @@ static struct resource *get_pci_domain_busn_res(int domain_nr) r->res.start =0 ; r->res.end =0xff ; r->res.flags =IORESOURCE_BUS |IORESOURCE_PCI_FIXED ; +INIT_LIST_HEAD (&r->res.child); +INIT_LIST_HEAD (&r->res.sibling);list_add_tail (&r->list, &pci_domain_busn_res_list);
drivers/pci/setup-bus.c +1 -1
@@ -2107,7 +2107,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type)continue ;/* Ignore BARs which are still in use */ -if (res->child) +if (!list_empty (&res->child))continue ; ret =add_to_list (&saved, bridge, res,0 ,0 );
include/linux/ioport.h +15 -2
@@ -12,6 +12,7 @@#ifndef __ASSEMBLY__#include <linux/compiler.h> #include <linux/types.h> +#include <linux/list.h> /* * Resources are tree-like, allowing * nesting etc..
@@ -22,7 +23,8 @@ struct resource {const char *name;unsigned long flags;unsigned long desc; -struct resource *parent, *sibling, *child; +struct list_head child, sibling; +struct resource *parent; };/*
@@ -215,7 +217,6 @@ static inline bool resource_contains(struct resource *r1, struct resource *r2)return r1->start <= r2->start && r1->end >= r2->end; } -/* Convenience shorthand with allocation */ #define request_region (start,n,name) __request_region(&ioport_resource, (start), (n), (name), 0)#define request_muxed_region (start,n,name) __request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED)
@@ -286,6 +287,18 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)return (r1->start <= r2->end && r1->end >= r2->start); } +static inline struct resource *resource_sibling (struct resource *res) +{ +if (res->parent && !list_is_last (&res->sibling, &res->parent->child)) +return list_next_entry (res, sibling); +return NULL ; +} + +static inline struct resource *resource_first_child (struct list_head *head) +{ + return list_first_entry_or_null(head, struct resource, sibling); +} +#endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */
kernel/resource.c +87 -94
435 lines not on this page · raw message
Signature · 6 lines
2.13.6 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Baoquan,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.17-rc4 next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180507-144345
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
All errors (new ones prefixed by >>):
arch/powerpc/kernel/pci-common.c: In function 'pci_process_bridge_OF_ranges':
>> arch/powerpc/kernel/pci-common.c:764:44: error: incompatible types when assigning to type 'struct list_head' from type 'void *'
res->parent = res->child = res->sibling = NULL;
^
arch/powerpc/kernel/pci-common.c: In function 'reparent_resources':
>> arch/powerpc/kernel/pci-common.c:1100:10: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) {
^
arch/powerpc/kernel/pci-common.c:1100:50: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) {
^
>> arch/powerpc/kernel/pci-common.c:1113:13: error: incompatible types when assigning to type 'struct list_head' from type 'struct resource *'
res->child = *firstpp;
^
arch/powerpc/kernel/pci-common.c:1114:15: error: incompatible types when assigning to type 'struct list_head' from type 'struct resource *'
res->sibling = *pp;
^
>> arch/powerpc/kernel/pci-common.c:1117:9: error: incompatible types when assigning to type 'struct resource *' from type 'struct list_head'
for (p = res->child; p != NULL; p = p->sibling) {
^
arch/powerpc/kernel/pci-common.c:1117:36: error: incompatible types when assigning to type 'struct resource *' from type 'struct list_head'
for (p = res->child; p != NULL; p = p->sibling) {
^cc1: all warnings being treated as errors
vim +764 arch/powerpc/kernel/pci-common.c
13dccb9e Benjamin Herrenschmidt 2007-12-11 642
13dccb9e Benjamin Herrenschmidt 2007-12-11 643 /**
13dccb9e Benjamin Herrenschmidt 2007-12-11 644 * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree
13dccb9e Benjamin Herrenschmidt 2007-12-11 645 * @hose: newly allocated pci_controller to be setup
13dccb9e Benjamin Herrenschmidt 2007-12-11 646 * @dev: device node of the host bridge
13dccb9e Benjamin Herrenschmidt 2007-12-11 647 * @primary: set if primary bus (32 bits only, soon to be deprecated)
13dccb9e Benjamin Herrenschmidt 2007-12-11 648 *
13dccb9e Benjamin Herrenschmidt 2007-12-11 649 * This function will parse the "ranges" property of a PCI host bridge device
13dccb9e Benjamin Herrenschmidt 2007-12-11 650 * node and setup the resource mapping of a pci controller based on its
13dccb9e Benjamin Herrenschmidt 2007-12-11 651 * content.
13dccb9e Benjamin Herrenschmidt 2007-12-11 652 *
13dccb9e Benjamin Herrenschmidt 2007-12-11 653 * Life would be boring if it wasn't for a few issues that we have to deal
13dccb9e Benjamin Herrenschmidt 2007-12-11 654 * with here:
13dccb9e Benjamin Herrenschmidt 2007-12-11 655 *
13dccb9e Benjamin Herrenschmidt 2007-12-11 656 * - We can only cope with one IO space range and up to 3 Memory space
13dccb9e Benjamin Herrenschmidt 2007-12-11 657 * ranges. However, some machines (thanks Apple !) tend to split their
13dccb9e Benjamin Herrenschmidt 2007-12-11 658 * space into lots of small contiguous ranges. So we have to coalesce.
13dccb9e Benjamin Herrenschmidt 2007-12-11 659 *
13dccb9e Benjamin Herrenschmidt 2007-12-11 660 * - Some busses have IO space not starting at 0, which causes trouble with
13dccb9e Benjamin Herrenschmidt 2007-12-11 661 * the way we do our IO resource renumbering. The code somewhat deals with
13dccb9e Benjamin Herrenschmidt 2007-12-11 662 * it for 64 bits but I would expect problems on 32 bits.
13dccb9e Benjamin Herrenschmidt 2007-12-11 663 *
13dccb9e Benjamin Herrenschmidt 2007-12-11 664 * - Some 32 bits platforms such as 4xx can have physical space larger than
13dccb9e Benjamin Herrenschmidt 2007-12-11 665 * 32 bits so we need to use 64 bits values for the parsing
13dccb9e Benjamin Herrenschmidt 2007-12-11 666 */
cad5cef6 Greg Kroah-Hartman 2012-12-21 667 void pci_process_bridge_OF_ranges(struct pci_controller *hose,
cad5cef6 Greg Kroah-Hartman 2012-12-21 668 struct device_node *dev, int primary)
13dccb9e Benjamin Herrenschmidt 2007-12-11 669 {
858957ab Kevin Hao 2013-05-16 670 int memno = 0;
13dccb9e Benjamin Herrenschmidt 2007-12-11 671 struct resource *res;
654837e8 Andrew Murray 2014-02-25 672 struct of_pci_range range;
654837e8 Andrew Murray 2014-02-25 673 struct of_pci_range_parser parser;
13dccb9e Benjamin Herrenschmidt 2007-12-11 674
b7c670d6 Rob Herring 2017-08-21 675 printk(KERN_INFO "PCI host bridge %pOF %s ranges:\n",
b7c670d6 Rob Herring 2017-08-21 676 dev, primary ? "(primary)" : "");
13dccb9e Benjamin Herrenschmidt 2007-12-11 677
654837e8 Andrew Murray 2014-02-25 678 /* Check for ranges property */
654837e8 Andrew Murray 2014-02-25 679 if (of_pci_range_parser_init(&parser, dev))
13dccb9e Benjamin Herrenschmidt 2007-12-11 680 return;
13dccb9e Benjamin Herrenschmidt 2007-12-11 681
13dccb9e Benjamin Herrenschmidt 2007-12-11 682 /* Parse it */
654837e8 Andrew Murray 2014-02-25 683 for_each_of_pci_range(&parser, &range) {
e9f82cb7 Benjamin Herrenschmidt 2008-10-14 684 /* If we failed translation or got a zero-sized region
e9f82cb7 Benjamin Herrenschmidt 2008-10-14 685 * (some FW try to feed us with non sensical zero sized regions
e9f82cb7 Benjamin Herrenschmidt 2008-10-14 686 * such as power3 which look like some kind of attempt at exposing
e9f82cb7 Benjamin Herrenschmidt 2008-10-14 687 * the VGA memory hole)
e9f82cb7 Benjamin Herrenschmidt 2008-10-14 688 */
654837e8 Andrew Murray 2014-02-25 689 if (range.cpu_addr == OF_BAD_ADDR || range.size == 0)
13dccb9e Benjamin Herrenschmidt 2007-12-11 690 continue;
13dccb9e Benjamin Herrenschmidt 2007-12-11 691
13dccb9e Benjamin Herrenschmidt 2007-12-11 692 /* Act based on address space type */
13dccb9e Benjamin Herrenschmidt 2007-12-11 693 res = NULL;
654837e8 Andrew Murray 2014-02-25 694 switch (range.flags & IORESOURCE_TYPE_BITS) {
654837e8 Andrew Murray 2014-02-25 695 case IORESOURCE_IO:
13dccb9e Benjamin Herrenschmidt 2007-12-11 696 printk(KERN_INFO
13dccb9e Benjamin Herrenschmidt 2007-12-11 697 " IO 0x%016llx..0x%016llx -> 0x%016llx\n",
654837e8 Andrew Murray 2014-02-25 698 range.cpu_addr, range.cpu_addr + range.size - 1,
654837e8 Andrew Murray 2014-02-25 699 range.pci_addr);
13dccb9e Benjamin Herrenschmidt 2007-12-11 700
13dccb9e Benjamin Herrenschmidt 2007-12-11 701 /* We support only one IO range */
13dccb9e Benjamin Herrenschmidt 2007-12-11 702 if (hose->pci_io_size) {
13dccb9e Benjamin Herrenschmidt 2007-12-11 703 printk(KERN_INFO
13dccb9e Benjamin Herrenschmidt 2007-12-11 704 " \\--> Skipped (too many) !\n");
13dccb9e Benjamin Herrenschmidt 2007-12-11 705 continue;
13dccb9e Benjamin Herrenschmidt 2007-12-11 706 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 707 #ifdef CONFIG_PPC32
13dccb9e Benjamin Herrenschmidt 2007-12-11 708 /* On 32 bits, limit I/O space to 16MB */
654837e8 Andrew Murray 2014-02-25 709 if (range.size > 0x01000000)
654837e8 Andrew Murray 2014-02-25 710 range.size = 0x01000000;
13dccb9e Benjamin Herrenschmidt 2007-12-11 711
13dccb9e Benjamin Herrenschmidt 2007-12-11 712 /* 32 bits needs to map IOs here */
654837e8 Andrew Murray 2014-02-25 713 hose->io_base_virt = ioremap(range.cpu_addr,
654837e8 Andrew Murray 2014-02-25 714 range.size);
13dccb9e Benjamin Herrenschmidt 2007-12-11 715
13dccb9e Benjamin Herrenschmidt 2007-12-11 716 /* Expect trouble if pci_addr is not 0 */
13dccb9e Benjamin Herrenschmidt 2007-12-11 717 if (primary)
13dccb9e Benjamin Herrenschmidt 2007-12-11 718 isa_io_base =
13dccb9e Benjamin Herrenschmidt 2007-12-11 719 (unsigned long)hose->io_base_virt;
13dccb9e Benjamin Herrenschmidt 2007-12-11 720 #endif /* CONFIG_PPC32 */
13dccb9e Benjamin Herrenschmidt 2007-12-11 721 /* pci_io_size and io_base_phys always represent IO
13dccb9e Benjamin Herrenschmidt 2007-12-11 722 * space starting at 0 so we factor in pci_addr
13dccb9e Benjamin Herrenschmidt 2007-12-11 723 */
654837e8 Andrew Murray 2014-02-25 724 hose->pci_io_size = range.pci_addr + range.size;
654837e8 Andrew Murray 2014-02-25 725 hose->io_base_phys = range.cpu_addr - range.pci_addr;
13dccb9e Benjamin Herrenschmidt 2007-12-11 726
13dccb9e Benjamin Herrenschmidt 2007-12-11 727 /* Build resource */
13dccb9e Benjamin Herrenschmidt 2007-12-11 728 res = &hose->io_resource;
654837e8 Andrew Murray 2014-02-25 729 range.cpu_addr = range.pci_addr;
13dccb9e Benjamin Herrenschmidt 2007-12-11 730 break;
654837e8 Andrew Murray 2014-02-25 731 case IORESOURCE_MEM:
13dccb9e Benjamin Herrenschmidt 2007-12-11 732 printk(KERN_INFO
13dccb9e Benjamin Herrenschmidt 2007-12-11 733 " MEM 0x%016llx..0x%016llx -> 0x%016llx %s\n",
654837e8 Andrew Murray 2014-02-25 734 range.cpu_addr, range.cpu_addr + range.size - 1,
654837e8 Andrew Murray 2014-02-25 735 range.pci_addr,
654837e8 Andrew Murray 2014-02-25 736 (range.pci_space & 0x40000000) ?
654837e8 Andrew Murray 2014-02-25 737 "Prefetch" : "");
13dccb9e Benjamin Herrenschmidt 2007-12-11 738
13dccb9e Benjamin Herrenschmidt 2007-12-11 739 /* We support only 3 memory ranges */
13dccb9e Benjamin Herrenschmidt 2007-12-11 740 if (memno >= 3) {
13dccb9e Benjamin Herrenschmidt 2007-12-11 741 printk(KERN_INFO
13dccb9e Benjamin Herrenschmidt 2007-12-11 742 " \\--> Skipped (too many) !\n");
13dccb9e Benjamin Herrenschmidt 2007-12-11 743 continue;
13dccb9e Benjamin Herrenschmidt 2007-12-11 744 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 745 /* Handles ISA memory hole space here */
654837e8 Andrew Murray 2014-02-25 746 if (range.pci_addr == 0) {
13dccb9e Benjamin Herrenschmidt 2007-12-11 747 if (primary || isa_mem_base == 0)
654837e8 Andrew Murray 2014-02-25 748 isa_mem_base = range.cpu_addr;
654837e8 Andrew Murray 2014-02-25 749 hose->isa_mem_phys = range.cpu_addr;
654837e8 Andrew Murray 2014-02-25 750 hose->isa_mem_size = range.size;
13dccb9e Benjamin Herrenschmidt 2007-12-11 751 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 752
13dccb9e Benjamin Herrenschmidt 2007-12-11 753 /* Build resource */
654837e8 Andrew Murray 2014-02-25 754 hose->mem_offset[memno] = range.cpu_addr -
654837e8 Andrew Murray 2014-02-25 755 range.pci_addr;
13dccb9e Benjamin Herrenschmidt 2007-12-11 756 res = &hose->mem_resources[memno++];
13dccb9e Benjamin Herrenschmidt 2007-12-11 757 break;
13dccb9e Benjamin Herrenschmidt 2007-12-11 758 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 759 if (res != NULL) {
aeba3731 Michael Ellerman 2014-10-16 760 res->name = dev->full_name;
aeba3731 Michael Ellerman 2014-10-16 761 res->flags = range.flags;
aeba3731 Michael Ellerman 2014-10-16 762 res->start = range.cpu_addr;
aeba3731 Michael Ellerman 2014-10-16 763 res->end = range.cpu_addr + range.size - 1;
aeba3731 Michael Ellerman 2014-10-16 @764 res->parent = res->child = res->sibling = NULL;
13dccb9e Benjamin Herrenschmidt 2007-12-11 765 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 766 }
13dccb9e Benjamin Herrenschmidt 2007-12-11 767 }fa462f2d Benjamin Herrenschmidt 2007-12-20 768
:::::: The code at line 764 was first introduced by commit
:::::: aeba3731b150188685225b510886f1370d8814de powerpc/pci: Fix IO space breakage after of_pci_range_to_resource() change
:::::: TO: Michael Ellerman <mpe-Gsx/[email protected]> :::::: CC: Michael Ellerman <mpe-Gsx/[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 17 lines · kbuild test robot
Hi Baoquan,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.17-rc4 next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180507-144345
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
Quoted 5 lines
All errors (new ones prefixed by >>):
arch/powerpc/kernel/pci-common.c: In function 'pci_process_bridge_OF_ranges':Quoted 1 line
Quoted 1 line
arch/powerpc/kernel/pci-common.c:764:44: error: incompatible types when assigning to type 'structlist_head' from type 'void *'res->parent = res->child = res->sibling = NULL;
Pasted code can fix above error.
arch/powerpc/kernel/pci-common.c +3 -1
@@ -761,7 +761,9 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose, res->flags = range.flags; res->start = range.cpu_addr; res->end = range.cpu_addr + range.size -1 ; - res->parent = res->child = res->sibling =NULL ; + res->parent =NULL ; +INIT_LIST_HEAD (&res->child); +INIT_LIST_HEAD (&res->sibling); } } }
Quoted 5 lines
^
arch/powerpc/kernel/pci-common.c: In function 'reparent_resources':Quoted 1 line
Quoted 1 line
arch/powerpc/kernel/pci-common.c:1100:10: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) { ^
This reparent_resources() function is duplicated with the one in arch/microblaze/pci/pci-common.c which has been fixed in v4. I planned to move it to kernel/resource.c in a separate patch since it's shared by different ARCH, then fix it in this patch.
Quoted 156 lines
arch/powerpc/kernel/pci-common.c:1100:50: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types] for (pp = &parent->child; (p = *pp) != NULL; pp = &p->sibling) { ^Quoted 1 line
Quoted 1 line
arch/powerpc/kernel/pci-common.c:1113:13: error: incompatible types when assigning to type 'structlist_head' from type 'struct resource *'res->child = *firstpp; ^ arch/powerpc/kernel/pci-common.c:1114:15: error: incompatible types when assigning to type 'struct list_head' from type 'struct resource *' res->sibling = *pp; ^Quoted 1 line
Quoted 1 line
arch/powerpc/kernel/pci-common.c:1117:9: error: incompatible types when assigning to type 'struct resource *' from type 'structlist_head'for (p = res->child; p != NULL; p = p->sibling) { ^ arch/powerpc/kernel/pci-common.c:1117:36: error: incompatible types when assigning to type 'struct resource *' from type 'struct list_head' for (p = res->child; p != NULL; p = p->sibling) { ^cc1: all warnings being treated as errors
vim +764
arch/powerpc/kernel/pci-common.c13dccb9e Benjamin Herrenschmidt 2007-12-11 642 13dccb9e Benjamin Herrenschmidt 2007-12-11 643 /** 13dccb9e Benjamin Herrenschmidt 2007-12-11 644 * pci_process_bridge_OF_ranges - Parse PCI bridge resources from device tree 13dccb9e Benjamin Herrenschmidt 2007-12-11 645 * @hose: newly allocated pci_controller to be setup 13dccb9e Benjamin Herrenschmidt 2007-12-11 646 * @dev: device node of the host bridge 13dccb9e Benjamin Herrenschmidt 2007-12-11 647 * @primary: set if primary bus (32 bits only, soon to be deprecated) 13dccb9e Benjamin Herrenschmidt 2007-12-11 648 * 13dccb9e Benjamin Herrenschmidt 2007-12-11 649 * This function will parse the "ranges" property of a PCI host bridge device 13dccb9e Benjamin Herrenschmidt 2007-12-11 650 * node and setup the resource mapping of a pci controller based on its 13dccb9e Benjamin Herrenschmidt 2007-12-11 651 * content. 13dccb9e Benjamin Herrenschmidt 2007-12-11 652 * 13dccb9e Benjamin Herrenschmidt 2007-12-11 653 * Life would be boring if it wasn't for a few issues that we have to deal 13dccb9e Benjamin Herrenschmidt 2007-12-11 654 * with here: 13dccb9e Benjamin Herrenschmidt 2007-12-11 655 * 13dccb9e Benjamin Herrenschmidt 2007-12-11 656 * - We can only cope with one IO space range and up to 3 Memory space 13dccb9e Benjamin Herrenschmidt 2007-12-11 657 * ranges. However, some machines (thanks Apple !) tend to split their 13dccb9e Benjamin Herrenschmidt 2007-12-11 658 * space into lots of small contiguous ranges. So we have to coalesce. 13dccb9e Benjamin Herrenschmidt 2007-12-11 659 * 13dccb9e Benjamin Herrenschmidt 2007-12-11 660 * - Some busses have IO space not starting at 0, which causes trouble with 13dccb9e Benjamin Herrenschmidt 2007-12-11 661 * the way we do our IO resource renumbering. The code somewhat deals with 13dccb9e Benjamin Herrenschmidt 2007-12-11 662 * it for 64 bits but I would expect problems on 32 bits. 13dccb9e Benjamin Herrenschmidt 2007-12-11 663 * 13dccb9e Benjamin Herrenschmidt 2007-12-11 664 * - Some 32 bits platforms such as 4xx can have physical space larger than 13dccb9e Benjamin Herrenschmidt 2007-12-11 665 * 32 bits so we need to use 64 bits values for the parsing 13dccb9e Benjamin Herrenschmidt 2007-12-11 666 */ cad5cef6 Greg Kroah-Hartman 2012-12-21 667 void pci_process_bridge_OF_ranges(struct pci_controller *hose, cad5cef6 Greg Kroah-Hartman 2012-12-21 668 struct device_node *dev, int primary) 13dccb9e Benjamin Herrenschmidt 2007-12-11 669 { 858957ab Kevin Hao 2013-05-16 670 int memno = 0; 13dccb9e Benjamin Herrenschmidt 2007-12-11 671 struct resource *res; 654837e8 Andrew Murray 2014-02-25 672 struct of_pci_range range; 654837e8 Andrew Murray 2014-02-25 673 struct of_pci_range_parser parser; 13dccb9e Benjamin Herrenschmidt 2007-12-11 674 b7c670d6 Rob Herring 2017-08-21 675 printk(KERN_INFO "PCI host bridge %pOF %s ranges:\n", b7c670d6 Rob Herring 2017-08-21 676 dev, primary ? "(primary)" : ""); 13dccb9e Benjamin Herrenschmidt 2007-12-11 677 654837e8 Andrew Murray 2014-02-25 678 /* Check for ranges property */ 654837e8 Andrew Murray 2014-02-25 679 if (of_pci_range_parser_init(&parser, dev)) 13dccb9e Benjamin Herrenschmidt 2007-12-11 680 return; 13dccb9e Benjamin Herrenschmidt 2007-12-11 681 13dccb9e Benjamin Herrenschmidt 2007-12-11 682 /* Parse it */ 654837e8 Andrew Murray 2014-02-25 683 for_each_of_pci_range(&parser, &range) { e9f82cb7 Benjamin Herrenschmidt 2008-10-14 684 /* If we failed translation or got a zero-sized region e9f82cb7 Benjamin Herrenschmidt 2008-10-14 685 * (some FW try to feed us with non sensical zero sized regions e9f82cb7 Benjamin Herrenschmidt 2008-10-14 686 * such as power3 which look like some kind of attempt at exposing e9f82cb7 Benjamin Herrenschmidt 2008-10-14 687 * the VGA memory hole) e9f82cb7 Benjamin Herrenschmidt 2008-10-14 688 */ 654837e8 Andrew Murray 2014-02-25 689 if (range.cpu_addr == OF_BAD_ADDR || range.size == 0) 13dccb9e Benjamin Herrenschmidt 2007-12-11 690 continue; 13dccb9e Benjamin Herrenschmidt 2007-12-11 691 13dccb9e Benjamin Herrenschmidt 2007-12-11 692 /* Act based on address space type */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 693 res = NULL; 654837e8 Andrew Murray 2014-02-25 694 switch (range.flags & IORESOURCE_TYPE_BITS) { 654837e8 Andrew Murray 2014-02-25 695 case IORESOURCE_IO: 13dccb9e Benjamin Herrenschmidt 2007-12-11 696 printk(KERN_INFO 13dccb9e Benjamin Herrenschmidt 2007-12-11 697 " IO 0x%016llx..0x%016llx -> 0x%016llx\n", 654837e8 Andrew Murray 2014-02-25 698 range.cpu_addr, range.cpu_addr + range.size - 1, 654837e8 Andrew Murray 2014-02-25 699 range.pci_addr); 13dccb9e Benjamin Herrenschmidt 2007-12-11 700 13dccb9e Benjamin Herrenschmidt 2007-12-11 701 /* We support only one IO range */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 702 if (hose->pci_io_size) { 13dccb9e Benjamin Herrenschmidt 2007-12-11 703 printk(KERN_INFO 13dccb9e Benjamin Herrenschmidt 2007-12-11 704 " \\--> Skipped (too many) !\n"); 13dccb9e Benjamin Herrenschmidt 2007-12-11 705 continue; 13dccb9e Benjamin Herrenschmidt 2007-12-11 706 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 707 #ifdef CONFIG_PPC32 13dccb9e Benjamin Herrenschmidt 2007-12-11 708 /* On 32 bits, limit I/O space to 16MB */ 654837e8 Andrew Murray 2014-02-25 709 if (range.size > 0x01000000) 654837e8 Andrew Murray 2014-02-25 710 range.size = 0x01000000; 13dccb9e Benjamin Herrenschmidt 2007-12-11 711 13dccb9e Benjamin Herrenschmidt 2007-12-11 712 /* 32 bits needs to map IOs here */ 654837e8 Andrew Murray 2014-02-25 713 hose->io_base_virt = ioremap(range.cpu_addr, 654837e8 Andrew Murray 2014-02-25 714 range.size); 13dccb9e Benjamin Herrenschmidt 2007-12-11 715 13dccb9e Benjamin Herrenschmidt 2007-12-11 716 /* Expect trouble if pci_addr is not 0 */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 717 if (primary) 13dccb9e Benjamin Herrenschmidt 2007-12-11 718 isa_io_base = 13dccb9e Benjamin Herrenschmidt 2007-12-11 719 (unsigned long)hose->io_base_virt; 13dccb9e Benjamin Herrenschmidt 2007-12-11 720 #endif /* CONFIG_PPC32 */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 721 /* pci_io_size and io_base_phys always represent IO 13dccb9e Benjamin Herrenschmidt 2007-12-11 722 * space starting at 0 so we factor in pci_addr 13dccb9e Benjamin Herrenschmidt 2007-12-11 723 */ 654837e8 Andrew Murray 2014-02-25 724 hose->pci_io_size = range.pci_addr + range.size; 654837e8 Andrew Murray 2014-02-25 725 hose->io_base_phys = range.cpu_addr - range.pci_addr; 13dccb9e Benjamin Herrenschmidt 2007-12-11 726 13dccb9e Benjamin Herrenschmidt 2007-12-11 727 /* Build resource */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 728 res = &hose->io_resource; 654837e8 Andrew Murray 2014-02-25 729 range.cpu_addr = range.pci_addr; 13dccb9e Benjamin Herrenschmidt 2007-12-11 730 break; 654837e8 Andrew Murray 2014-02-25 731 case IORESOURCE_MEM: 13dccb9e Benjamin Herrenschmidt 2007-12-11 732 printk(KERN_INFO 13dccb9e Benjamin Herrenschmidt 2007-12-11 733 " MEM 0x%016llx..0x%016llx -> 0x%016llx %s\n", 654837e8 Andrew Murray 2014-02-25 734 range.cpu_addr, range.cpu_addr + range.size - 1, 654837e8 Andrew Murray 2014-02-25 735 range.pci_addr, 654837e8 Andrew Murray 2014-02-25 736 (range.pci_space & 0x40000000) ? 654837e8 Andrew Murray 2014-02-25 737 "Prefetch" : ""); 13dccb9e Benjamin Herrenschmidt 2007-12-11 738 13dccb9e Benjamin Herrenschmidt 2007-12-11 739 /* We support only 3 memory ranges */ 13dccb9e Benjamin Herrenschmidt 2007-12-11 740 if (memno >= 3) { 13dccb9e Benjamin Herrenschmidt 2007-12-11 741 printk(KERN_INFO 13dccb9e Benjamin Herrenschmidt 2007-12-11 742 " \\--> Skipped (too many) !\n"); 13dccb9e Benjamin Herrenschmidt 2007-12-11 743 continue; 13dccb9e Benjamin Herrenschmidt 2007-12-11 744 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 745 /* Handles ISA memory hole space here */ 654837e8 Andrew Murray 2014-02-25 746 if (range.pci_addr == 0) { 13dccb9e Benjamin Herrenschmidt 2007-12-11 747 if (primary || isa_mem_base == 0) 654837e8 Andrew Murray 2014-02-25 748 isa_mem_base = range.cpu_addr; 654837e8 Andrew Murray 2014-02-25 749 hose->isa_mem_phys = range.cpu_addr; 654837e8 Andrew Murray 2014-02-25 750 hose->isa_mem_size = range.size; 13dccb9e Benjamin Herrenschmidt 2007-12-11 751 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 752 13dccb9e Benjamin Herrenschmidt 2007-12-11 753 /* Build resource */ 654837e8 Andrew Murray 2014-02-25 754 hose->mem_offset[memno] = range.cpu_addr - 654837e8 Andrew Murray 2014-02-25 755 range.pci_addr; 13dccb9e Benjamin Herrenschmidt 2007-12-11 756 res = &hose->mem_resources[memno++]; 13dccb9e Benjamin Herrenschmidt 2007-12-11 757 break; 13dccb9e Benjamin Herrenschmidt 2007-12-11 758 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 759 if (res != NULL) { aeba3731 Michael Ellerman 2014-10-16 760 res->name = dev->full_name; aeba3731 Michael Ellerman 2014-10-16 761 res->flags = range.flags; aeba3731 Michael Ellerman 2014-10-16 762 res->start = range.cpu_addr; aeba3731 Michael Ellerman 2014-10-16 763 res->end = range.cpu_addr + range.size - 1; aeba3731 Michael Ellerman 2014-10-16 @764 res->parent = res->child = res->sibling = NULL; 13dccb9e Benjamin Herrenschmidt 2007-12-11 765 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 766 } 13dccb9e Benjamin Herrenschmidt 2007-12-11 767 }
fa462f2dBenjamin Herrenschmidt 2007-12-20 768:::::: The code at line 764 was first introduced by commit
::::::aeba3731b150188685225b510886f1370d8814depowerpc/pci: Fix IO space breakage afterof_pci_range_to_resource()change:::::: TO: Michael Ellerman <mpe-Gsx/[email protected]> :::::: CC: Michael Ellerman <mpe-Gsx/[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Baoquan,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.17-rc4 next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180507-144345
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All errors (new ones prefixed by >>):
arch/arm/plat-samsung/pm-check.c: In function 's3c_pm_run_res':
>> arch/arm/plat-samsung/pm-check.c:49:18: error: invalid operands to binary != (have 'struct list_head' and 'void *')
if (ptr->child != NULL)
~~~~~~~~~~ ^~
>> arch/arm/plat-samsung/pm-check.c:50:19: error: incompatible type for argument 1 of 's3c_pm_run_res'
s3c_pm_run_res(ptr->child, fn, arg);
^~~
arch/arm/plat-samsung/pm-check.c:46:13: note: expected 'struct resource *' but argument is of type 'struct list_head'
static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
^~~~~~~~~~~~~~
>> arch/arm/plat-samsung/pm-check.c:60:7: error: incompatible types when assigning to type 'struct resource *' from type 'struct list_head'
ptr = ptr->sibling;
^vim +49 arch/arm/plat-samsung/pm-check.c
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 45
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 46 static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 47 {
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 48 while (ptr != NULL) {
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @49 if (ptr->child != NULL)
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @50 s3c_pm_run_res(ptr->child, fn, arg);
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 51
05fee7cf arch/arm/plat-samsung/pm-check.c Toshi Kani 2016-01-26 52 if ((ptr->flags & IORESOURCE_SYSTEM_RAM)
05fee7cf arch/arm/plat-samsung/pm-check.c Toshi Kani 2016-01-26 53 == IORESOURCE_SYSTEM_RAM) {
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 54 S3C_PMDBG("Found system RAM at %08lx..%08lx\n",
840eeeb8 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 55 (unsigned long)ptr->start,
840eeeb8 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 56 (unsigned long)ptr->end);
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 57 arg = (fn)(ptr, arg);
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 58 }
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 59
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @60 ptr = ptr->sibling;
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 61 }
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 62 }
549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 63 :::::: The code at line 49 was first introduced by commit
:::::: 549c7e33aeb9bfe441ecf68639d2227bb90978e7 [ARM] S3C: Split the resume memory check code from pm.c
:::::: TO: Ben Dooks <[email protected]> :::::: CC: Ben Dooks <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 17 lines · kbuild test robot
Hi Baoquan,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.17-rc4 next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Baoquan-He/resource-Use-list_head-to-link-sibling-resource/20180507-144345
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
Quoted 1 line
All errors (new ones prefixed by >>):
Thanks, below patch can fix it:
arch/arm/plat-samsung/pm-check.c +3 -3
@@ -46,8 +46,8 @@ typedef u32 *(run_fn_t)(struct resource *ptr, u32 *arg);static void s3c_pm_run_res (struct resource *ptr,run_fn_t fn,u32 *arg) {while (ptr !=NULL ) { -if (ptr->child !=NULL ) -s3c_pm_run_res (ptr->child, fn, arg); +if (!list_empty (&ptr->child)) +s3c_pm_run_res (resource_first_child (&ptr->child), fn, arg);if ((ptr->flags &IORESOURCE_SYSTEM_RAM ) ==IORESOURCE_SYSTEM_RAM ) {
@@ -57,7 +57,7 @@ static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg) arg = (fn)(ptr, arg); } - ptr = ptr->sibling; + ptr =resource_sibling (ptr); } }
Quoted 46 lines
arch/arm/plat-samsung/pm-check.c: In function 's3c_pm_run_res':Quoted 1 line
Quoted 1 line
arch/arm/plat-samsung/pm-check.c:49:18: error: invalid operands to binary != (have 'structlist_head' and 'void *')if (ptr->child != NULL) ~~~~~~~~~~ ^~Quoted 1 line
Quoted 1 line
arch/arm/plat-samsung/pm-check.c:50:19: error: incompatible type for argument 1 of 's3c_pm_run_res's3c_pm_run_res(ptr->child, fn, arg); ^~~
arch/arm/plat-samsung/pm-check.c:46:13: note: expected 'struct resource *' but argument is of type 'structlist_head'
static voids3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
^~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
arch/arm/plat-samsung/pm-check.c:60:7: error: incompatible types when assigning to type 'struct resource *' from type 'structlist_head'ptr = ptr->sibling; ^vim +49
arch/arm/plat-samsung/pm-check.c549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 45 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 46 static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg) 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 47 { 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 48 while (ptr != NULL) { 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @49 if (ptr->child != NULL) 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @50 s3c_pm_run_res(ptr->child, fn, arg); 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 51 05fee7cf arch/arm/plat-samsung/pm-check.c Toshi Kani 2016-01-26 52 if ((ptr->flags & IORESOURCE_SYSTEM_RAM) 05fee7cf arch/arm/plat-samsung/pm-check.c Toshi Kani 2016-01-26 53 == IORESOURCE_SYSTEM_RAM) { 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 54 S3C_PMDBG("Found system RAM at %08lx..%08lx\n", 840eeeb8 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 55 (unsigned long)ptr->start, 840eeeb8 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 56 (unsigned long)ptr->end); 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 57 arg = (fn)(ptr, arg); 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 58 } 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 59 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 @60 ptr = ptr->sibling; 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 61 } 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 62 } 549c7e33 arch/arm/plat-s3c/pm-check.c Ben Dooks 2008-12-12 63:::::: The code at line 49 was first introduced by commit
::::::549c7e33aeb9bfe441ecf68639d2227bb90978e7[ARM] S3C: Split the resume memory check code frompm.c:::::: TO: Ben Dooks <[email protected]> :::::: CC: Ben Dooks <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v4 2/3 resource: add walk_system_ram_res_rev()
In reply to Baoquan HeThis function, being a variant of walk_system_ram_res() introduced in commit 8c86e70acead ("resource: provide new functions to walk through resources"), walks through a list of all the resources of System RAM in reversed order, i.e., from higher to lower.
It will be used in kexec_file code.
--- include/linux/ioport.h | 3 +++ kernel/resource.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
include/linux/ioport.h +3 -0
@@ -278,6 +278,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *));extern int +walk_system_ram_res_rev (u64 start,u64 end,void *arg, +int (*func)(struct resource *,void *)); +extern int walk_iomem_res_desc (unsigned long desc,unsigned long flags,u64 start,u64 end,void *arg,int (*func)(struct resource *,void *));
kernel/resource.c +40 -0
@@ -23,6 +23,8 @@#include <linux/pfn.h> #include <linux/mm.h> #include <linux/resource_ext.h> +#include <linux/string.h> +#include <linux/vmalloc.h> #include <asm/io.h>
@@ -475,6 +477,44 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, }/* +* This function, being a variant of walk_system_ram_res(), calls the @func +* callback against all memory ranges of type System RAM which are marked as +* IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY in reversed order, i.e., from +* higher to lower. +*/ +int walk_system_ram_res_rev (u64 start,u64 end,void *arg, +int (*func)(struct resource *,void *)) +{ +unsigned long flags; +struct resource *res; +int ret =-1 ; + + flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; + +read_lock (&resource_lock); +list_for_each_entry_reverse (res, &iomem_resource.child, sibling) { +if (start >= end) +break ; +if ((res->flags & flags) != flags) +continue ; +if (res->desc !=IORES_DESC_NONE ) +continue ; +if (res->end < start) +break ; + +if ((res->end >= start) && (res->start < end)) { + ret = (*func)(res, arg); +if (ret) +break ; + } + end = res->start -1 ; + + } +read_unlock (&resource_lock); +return ret; +} + +/* * This function calls the @func callback against all memory ranges, which * are ranges marked as IORESOURCE_MEM and IORESOUCE_BUSY. */
Signature · 6 lines
2.13.6 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH v4 3/3 kexec_file: Load kernel at top of system RAM if required
In reply to Baoquan HeFor kexec_file loading, if kexec_buf.top_down is 'true', the memory which is used to load kernel/initrd/purgatory is supposed to be allocated from top to down. This is what we have been doing all along in the old kexec loading interface and the kexec loading is still default setting in some distributions. However, the current kexec_file loading interface doesn't do likt this. The function arch_kexec_walk_mem() it calls ignores checking kexec_buf.top_down, but calls walk_system_ram_res() directly to go through all resources of System RAM from bottom to up, to try to find memory region which can contain the specific kexec buffer, then call locate_mem_hole_callback() to allocate memory in that found memory region from top to down. This brings confusion especially when KASLR is widely supported , users have to make clear why kexec/kdump kernel loading position is different between these two interfaces in order to exclude unnecessary noises. Hence these two interfaces need be unified on behaviour.
Here add checking if kexec_buf.top_down is 'true' in arch_kexec_walk_mem(), if yes, call the newly added walk_system_ram_res_rev() to find memory region from top to down to load kernel.
--- kernel/kexec_file.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/kexec_file.c +2 -0
@@ -518,6 +518,8 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , crashk_res.start, crashk_res.end, kbuf, func); + else if (kbuf->top_down) + return walk_system_ram_res_rev(0, ULONG_MAX, kbuf, func); else return walk_system_ram_res(0, ULONG_MAX, kbuf, func); }
Signature · 1 line
2.13.6