summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2025-12-19 20:40:22 +0300
committerBjorn Helgaas <bhelgaas@google.com>2026-01-28 01:36:51 +0300
commite112fbb26b66b183d9387017b29e5d0b62986eed (patch)
treeadd0394ff9cb9ca5bd46ae0632ada93653e5c6e3
parent4bee4fc0f4ee1086e498f9d197352237a0232598 (diff)
downloadlinux-e112fbb26b66b183d9387017b29e5d0b62986eed.tar.xz
PCI: Fetch dev_res to local var in __assign_resources_sorted()
__assign_resources_sorted() calls get_res_add_size() and get_res_add_align(), each walking through the realloc_head list to relocate the corresponding pci_dev_resource entry. Fetch the pci_dev_resource entry into a local variable to avoid double walk. In addition, reverse logic to reduce indentation level. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20251219174036.16738-10-ilpo.jarvinen@linux.intel.com
-rw-r--r--drivers/pci/setup-bus.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 09cc225bf107..41417084ddf8 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -596,11 +596,11 @@ static void __assign_resources_sorted(struct list_head *head,
LIST_HEAD(local_fail_head);
LIST_HEAD(dummy_head);
struct pci_dev_resource *save_res;
- struct pci_dev_resource *dev_res, *tmp_res, *dev_res2;
+ struct pci_dev_resource *dev_res, *tmp_res, *dev_res2, *addsize_res;
struct resource *res;
struct pci_dev *dev;
unsigned long fail_type;
- resource_size_t add_align, align;
+ resource_size_t align;
if (!realloc_head)
realloc_head = &dummy_head;
@@ -621,8 +621,11 @@ static void __assign_resources_sorted(struct list_head *head,
list_for_each_entry_safe(dev_res, tmp_res, head, list) {
res = dev_res->res;
- res->end += get_res_add_size(realloc_head, res);
+ addsize_res = res_to_dev_res(realloc_head, res);
+ if (!addsize_res)
+ continue;
+ res->end += addsize_res->add_size;
/*
* There are two kinds of additional resources in the list:
* 1. bridge resource -- IORESOURCE_STARTALIGN
@@ -632,8 +635,8 @@ static void __assign_resources_sorted(struct list_head *head,
if (!(res->flags & IORESOURCE_STARTALIGN))
continue;
- add_align = get_res_add_align(realloc_head, res);
-
+ if (addsize_res->min_align <= res->start)
+ continue;
/*
* The "head" list is sorted by alignment so resources with
* bigger alignment will be assigned first. After we
@@ -641,17 +644,15 @@ static void __assign_resources_sorted(struct list_head *head,
* need to reorder the list by alignment to make it
* consistent.
*/
- if (add_align > res->start) {
- resource_set_range(res, add_align, resource_size(res));
-
- list_for_each_entry(dev_res2, head, list) {
- align = pci_resource_alignment(dev_res2->dev,
- dev_res2->res);
- if (add_align > align) {
- list_move_tail(&dev_res->list,
- &dev_res2->list);
- break;
- }
+ resource_set_range(res, addsize_res->min_align,
+ resource_size(res));
+
+ list_for_each_entry(dev_res2, head, list) {
+ align = pci_resource_alignment(dev_res2->dev,
+ dev_res2->res);
+ if (addsize_res->min_align > align) {
+ list_move_tail(&dev_res->list, &dev_res2->list);
+ break;
}
}