Skip to content

Commit 179c0ac

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull Sparc fixes from David Miller: "Hook up the memfd syscall, and properly claim all PCI resources discovered when building the PCI device tree" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc: Hook up memfd_create system call. sparc64: Properly claim resources as each PCI bus is probed. sparc64: Skip bogus PCI bridge ranges. sparc64: Expand PCI bridge probing debug logging.
2 parents ad15afb + 10cf15e commit 179c0ac

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

arch/sparc/include/uapi/asm/unistd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@
413413
#define __NR_renameat2 345
414414
#define __NR_seccomp 346
415415
#define __NR_getrandom 347
416+
#define __NR_memfd_create 348
416417

417-
#define NR_syscalls 348
418+
#define NR_syscalls 349
418419

419420
/* Bitmask values returned from kern_features system call. */
420421
#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001

arch/sparc/kernel/pci.c

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
432432
node->full_name);
433433
return;
434434
}
435+
436+
if (ofpci_verbose)
437+
printk(" Bridge bus range [%u --> %u]\n",
438+
busrange[0], busrange[1]);
439+
435440
ranges = of_get_property(node, "ranges", &len);
436441
simba = 0;
437442
if (ranges == NULL) {
@@ -451,6 +456,10 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
451456
pci_bus_insert_busn_res(bus, busrange[0], busrange[1]);
452457
bus->bridge_ctl = 0;
453458

459+
if (ofpci_verbose)
460+
printk(" Bridge ranges[%p] simba[%d]\n",
461+
ranges, simba);
462+
454463
/* parse ranges property, or cook one up by hand for Simba */
455464
/* PCI #address-cells == 3 and #size-cells == 2 always */
456465
res = &dev->resource[PCI_BRIDGE_RESOURCES];
@@ -468,10 +477,29 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
468477
}
469478
i = 1;
470479
for (; len >= 32; len -= 32, ranges += 8) {
480+
u64 start;
481+
482+
if (ofpci_verbose)
483+
printk(" RAW Range[%08x:%08x:%08x:%08x:%08x:%08x:"
484+
"%08x:%08x]\n",
485+
ranges[0], ranges[1], ranges[2], ranges[3],
486+
ranges[4], ranges[5], ranges[6], ranges[7]);
487+
471488
flags = pci_parse_of_flags(ranges[0]);
472489
size = GET_64BIT(ranges, 6);
473490
if (flags == 0 || size == 0)
474491
continue;
492+
493+
/* On PCI-Express systems, PCI bridges that have no devices downstream
494+
* have a bogus size value where the first 32-bit cell is 0xffffffff.
495+
* This results in a bogus range where start + size overflows.
496+
*
497+
* Just skip these otherwise the kernel will complain when the resource
498+
* tries to be claimed.
499+
*/
500+
if (size >> 32 == 0xffffffff)
501+
continue;
502+
475503
if (flags & IORESOURCE_IO) {
476504
res = bus->resource[0];
477505
if (res->flags) {
@@ -490,8 +518,13 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
490518
}
491519

492520
res->flags = flags;
493-
region.start = GET_64BIT(ranges, 1);
521+
region.start = start = GET_64BIT(ranges, 1);
494522
region.end = region.start + size - 1;
523+
524+
if (ofpci_verbose)
525+
printk(" Using flags[%08x] start[%016llx] size[%016llx]\n",
526+
flags, start, size);
527+
495528
pcibios_bus_to_resource(dev->bus, res, &region);
496529
}
497530
after_ranges:
@@ -584,6 +617,36 @@ static void pci_bus_register_of_sysfs(struct pci_bus *bus)
584617
pci_bus_register_of_sysfs(child_bus);
585618
}
586619

620+
static void pci_claim_bus_resources(struct pci_bus *bus)
621+
{
622+
struct pci_bus *child_bus;
623+
struct pci_dev *dev;
624+
625+
list_for_each_entry(dev, &bus->devices, bus_list) {
626+
int i;
627+
628+
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
629+
struct resource *r = &dev->resource[i];
630+
631+
if (r->parent || !r->start || !r->flags)
632+
continue;
633+
634+
if (ofpci_verbose)
635+
printk("PCI: Claiming %s: "
636+
"Resource %d: %016llx..%016llx [%x]\n",
637+
pci_name(dev), i,
638+
(unsigned long long)r->start,
639+
(unsigned long long)r->end,
640+
(unsigned int)r->flags);
641+
642+
pci_claim_resource(dev, i);
643+
}
644+
}
645+
646+
list_for_each_entry(child_bus, &bus->children, node)
647+
pci_claim_bus_resources(child_bus);
648+
}
649+
587650
struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
588651
struct device *parent)
589652
{
@@ -614,6 +677,8 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
614677
pci_bus_add_devices(bus);
615678
pci_bus_register_of_sysfs(bus);
616679

680+
pci_claim_bus_resources(bus);
681+
617682
return bus;
618683
}
619684

arch/sparc/kernel/systbls_32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ sys_call_table:
8686
/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
8787
/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
8888
/*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
89-
/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom
89+
/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create

arch/sparc/kernel/systbls_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ sys_call_table32:
8787
/*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime
8888
.word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev
8989
/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
90-
.word sys32_renameat2, sys_seccomp, sys_getrandom
90+
.word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create
9191

9292
#endif /* CONFIG_COMPAT */
9393

@@ -166,4 +166,4 @@ sys_call_table:
166166
/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
167167
.word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
168168
/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
169-
.word sys_renameat2, sys_seccomp, sys_getrandom
169+
.word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create

0 commit comments

Comments
 (0)