Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Check invalid align earlier in pbus_size_mem()

Check for invalid align before any bridge window sizing actions in
pbus_size_mem() to avoid need to roll back any sizing calculations.

Placing the check earlier will make it easier to add more optional size
related calculations at where the SR-IOV logic currently is in
pbus_size_mem().

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-13-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
c10fe0c0 9629f717

+12 -13
+12 -13
drivers/pci/setup-bus.c
··· 19 19 #include <linux/bug.h> 20 20 #include <linux/init.h> 21 21 #include <linux/kernel.h> 22 + #include <linux/minmax.h> 22 23 #include <linux/module.h> 23 24 #include <linux/pci.h> 24 25 #include <linux/errno.h> ··· 1312 1311 continue; 1313 1312 1314 1313 r_size = resource_size(r); 1315 - 1316 - /* Put SRIOV requested res to the optional list */ 1317 - if (realloc_head && pci_resource_is_optional(dev, i)) { 1318 - add_align = max(pci_resource_alignment(dev, r), add_align); 1319 - add_to_list(realloc_head, dev, r, 0, 0 /* Don't care */); 1320 - children_add_size += r_size; 1321 - continue; 1322 - } 1323 - 1314 + align = pci_resource_alignment(dev, r); 1324 1315 /* 1325 1316 * aligns[0] is for 1MB (since bridge memory 1326 1317 * windows are always at least 1MB aligned), so 1327 1318 * keep "order" from being negative for smaller 1328 1319 * resources. 1329 1320 */ 1330 - align = pci_resource_alignment(dev, r); 1331 - order = __ffs(align) - __ffs(SZ_1M); 1332 - if (order < 0) 1333 - order = 0; 1321 + order = max_t(int, __ffs(align) - __ffs(SZ_1M), 0); 1334 1322 if (order >= ARRAY_SIZE(aligns)) { 1335 1323 pci_warn(dev, "%s %pR: disabling; bad alignment %#llx\n", 1336 1324 r_name, r, (unsigned long long) align); 1337 1325 r->flags = 0; 1338 1326 continue; 1339 1327 } 1328 + 1329 + /* Put SRIOV requested res to the optional list */ 1330 + if (realloc_head && pci_resource_is_optional(dev, i)) { 1331 + add_align = max(align, add_align); 1332 + add_to_list(realloc_head, dev, r, 0, 0 /* Don't care */); 1333 + children_add_size += r_size; 1334 + continue; 1335 + } 1336 + 1340 1337 size += max(r_size, align); 1341 1338 1342 1339 aligns[order] += align;