Skip to content

Commit 35d5936

Browse files
committed
Automatic merge of 'next' into merge (2024-02-15 23:53)
2 parents cd4470c + 14ce0db commit 35d5936

File tree

12 files changed

+107
-55
lines changed

12 files changed

+107
-55
lines changed

arch/powerpc/include/asm/ibmebus.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
struct platform_driver;
5050

51-
extern struct bus_type ibmebus_bus_type;
51+
extern const struct bus_type ibmebus_bus_type;
5252

5353
int ibmebus_register_driver(struct platform_driver *drv);
5454
void ibmebus_unregister_driver(struct platform_driver *drv);

arch/powerpc/include/asm/macio.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <linux/of.h>
77
#include <linux/platform_device.h>
88

9-
extern struct bus_type macio_bus_type;
9+
extern const struct bus_type macio_bus_type;
1010

1111
/* MacIO device driver is defined later */
1212
struct macio_driver;

arch/powerpc/include/asm/mpic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct mpic
336336
#endif
337337
};
338338

339-
extern struct bus_type mpic_subsys;
339+
extern const struct bus_type mpic_subsys;
340340

341341
/*
342342
* MPIC flags (passed to mpic_alloc)

arch/powerpc/include/asm/smp.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
extern int boot_cpuid;
2929
extern int boot_cpu_hwid; /* PPC64 only */
30+
extern int boot_core_hwid;
3031
extern int spinning_secondaries;
3132
extern u32 *cpu_to_phys_id;
3233
extern bool coregroup_enabled;

arch/powerpc/include/asm/vio.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
#define VIO_CMO_MIN_ENT 1562624
4141

42-
extern struct bus_type vio_bus_type;
42+
extern const struct bus_type vio_bus_type;
4343

4444
struct iommu_table;
4545

arch/powerpc/include/asm/vmalloc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
88

99
#define arch_vmap_pud_supported arch_vmap_pud_supported
10-
static inline bool arch_vmap_pud_supported(pgprot_t prot)
10+
static __always_inline bool arch_vmap_pud_supported(pgprot_t prot)
1111
{
1212
/* HPT does not cope with large pages in the vmalloc area */
1313
return radix_enabled();
1414
}
1515

1616
#define arch_vmap_pmd_supported arch_vmap_pmd_supported
17-
static inline bool arch_vmap_pmd_supported(pgprot_t prot)
17+
static __always_inline bool arch_vmap_pmd_supported(pgprot_t prot)
1818
{
1919
return radix_enabled();
2020
}

arch/powerpc/kernel/prom.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,31 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
368368
if (found < 0)
369369
return 0;
370370

371-
DBG("boot cpu: logical %d physical %d\n", found,
372-
be32_to_cpu(intserv[found_thread]));
373371
boot_cpuid = found;
374372

375373
if (IS_ENABLED(CONFIG_PPC64))
376374
boot_cpu_hwid = be32_to_cpu(intserv[found_thread]);
377375

376+
if (nr_cpu_ids % nthreads != 0) {
377+
set_nr_cpu_ids(ALIGN(nr_cpu_ids, nthreads));
378+
pr_warn("nr_cpu_ids was not a multiple of threads_per_core, adjusted to %d\n",
379+
nr_cpu_ids);
380+
}
381+
382+
if (boot_cpuid >= nr_cpu_ids) {
383+
// Remember boot core for smp_setup_cpu_maps()
384+
boot_core_hwid = be32_to_cpu(intserv[0]);
385+
386+
pr_warn("Boot CPU %d (core hwid %d) >= nr_cpu_ids, adjusted boot CPU to %d\n",
387+
boot_cpuid, boot_core_hwid, found_thread);
388+
389+
// Adjust boot CPU to appear on logical core 0
390+
boot_cpuid = found_thread;
391+
}
392+
393+
DBG("boot cpu: logical %d physical %d\n", boot_cpuid,
394+
be32_to_cpu(intserv[found_thread]));
395+
378396
/*
379397
* PAPR defines "logical" PVR values for cpus that
380398
* meet various levels of the architecture:

arch/powerpc/kernel/setup-common.c

+41-17
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ EXPORT_SYMBOL(machine_id);
8585

8686
int boot_cpuid = -1;
8787
EXPORT_SYMBOL_GPL(boot_cpuid);
88+
int __initdata boot_core_hwid = -1;
8889

8990
#ifdef CONFIG_PPC64
9091
int boot_cpu_hwid = -1;
@@ -411,6 +412,25 @@ static void __init cpu_init_thread_core_maps(int tpc)
411412

412413
u32 *cpu_to_phys_id = NULL;
413414

415+
static int assign_threads(unsigned int cpu, unsigned int nthreads, bool present,
416+
const __be32 *hw_ids)
417+
{
418+
for (int i = 0; i < nthreads && cpu < nr_cpu_ids; i++) {
419+
__be32 hwid;
420+
421+
hwid = be32_to_cpu(hw_ids[i]);
422+
423+
DBG(" thread %d -> cpu %d (hard id %d)\n", i, cpu, hwid);
424+
425+
set_cpu_present(cpu, present);
426+
set_cpu_possible(cpu, true);
427+
cpu_to_phys_id[cpu] = hwid;
428+
cpu++;
429+
}
430+
431+
return cpu;
432+
}
433+
414434
/**
415435
* setup_cpu_maps - initialize the following cpu maps:
416436
* cpu_possible_mask
@@ -446,7 +466,7 @@ void __init smp_setup_cpu_maps(void)
446466
for_each_node_by_type(dn, "cpu") {
447467
const __be32 *intserv;
448468
__be32 cpu_be;
449-
int j, len;
469+
int len;
450470

451471
DBG(" * %pOF...\n", dn);
452472

@@ -468,27 +488,31 @@ void __init smp_setup_cpu_maps(void)
468488

469489
nthreads = len / sizeof(int);
470490

471-
for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
472-
bool avail;
491+
bool avail = of_device_is_available(dn);
492+
if (!avail)
493+
avail = !of_property_match_string(dn,
494+
"enable-method", "spin-table");
473495

474-
DBG(" thread %d -> cpu %d (hard id %d)\n",
475-
j, cpu, be32_to_cpu(intserv[j]));
476-
477-
avail = of_device_is_available(dn);
478-
if (!avail)
479-
avail = !of_property_match_string(dn,
480-
"enable-method", "spin-table");
481-
482-
set_cpu_present(cpu, avail);
483-
set_cpu_possible(cpu, true);
484-
cpu_to_phys_id[cpu] = be32_to_cpu(intserv[j]);
485-
cpu++;
486-
}
496+
if (boot_core_hwid >= 0) {
497+
if (cpu == 0) {
498+
pr_info("Skipping CPU node %pOF to allow for boot core.\n", dn);
499+
cpu = nthreads;
500+
continue;
501+
}
487502

488-
if (cpu >= nr_cpu_ids) {
503+
if (be32_to_cpu(intserv[0]) == boot_core_hwid) {
504+
pr_info("Renumbered boot core %pOF to logical 0\n", dn);
505+
assign_threads(0, nthreads, avail, intserv);
506+
of_node_put(dn);
507+
break;
508+
}
509+
} else if (cpu >= nr_cpu_ids) {
489510
of_node_put(dn);
490511
break;
491512
}
513+
514+
if (cpu < nr_cpu_ids)
515+
cpu = assign_threads(cpu, nthreads, avail, intserv);
492516
}
493517

494518
/* If no SMT supported, nthreads is forced to 1 */

arch/powerpc/platforms/pseries/ibmebus.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct device ibmebus_bus_device = { /* fake "parent" device */
5555
.init_name = "ibmebus",
5656
};
5757

58-
struct bus_type ibmebus_bus_type;
58+
const struct bus_type ibmebus_bus_type;
5959

6060
/* These devices will automatically be added to the bus during init */
6161
static const struct of_device_id ibmebus_matches[] __initconst = {
@@ -432,7 +432,7 @@ static int ibmebus_bus_modalias(const struct device *dev, struct kobj_uevent_env
432432
return of_device_uevent_modalias(dev, env);
433433
}
434434

435-
struct bus_type ibmebus_bus_type = {
435+
const struct bus_type ibmebus_bus_type = {
436436
.name = "ibmebus",
437437
.uevent = ibmebus_bus_modalias,
438438
.bus_groups = ibmbus_bus_groups,

arch/powerpc/platforms/pseries/vio.c

+35-26
Original file line numberDiff line numberDiff line change
@@ -991,18 +991,6 @@ static DEVICE_ATTR_RO(cmo_allocated);
991991
static DEVICE_ATTR_RW(cmo_desired);
992992
static DEVICE_ATTR_RW(cmo_allocs_failed);
993993

994-
static struct attribute *vio_cmo_dev_attrs[] = {
995-
&dev_attr_name.attr,
996-
&dev_attr_devspec.attr,
997-
&dev_attr_modalias.attr,
998-
&dev_attr_cmo_entitled.attr,
999-
&dev_attr_cmo_allocated.attr,
1000-
&dev_attr_cmo_desired.attr,
1001-
&dev_attr_cmo_allocs_failed.attr,
1002-
NULL,
1003-
};
1004-
ATTRIBUTE_GROUPS(vio_cmo_dev);
1005-
1006994
/* sysfs bus functions and data structures for CMO */
1007995

1008996
#define viobus_cmo_rd_attr(name) \
@@ -1062,11 +1050,7 @@ static struct attribute *vio_bus_attrs[] = {
10621050
};
10631051
ATTRIBUTE_GROUPS(vio_bus);
10641052

1065-
static void __init vio_cmo_sysfs_init(void)
1066-
{
1067-
vio_bus_type.dev_groups = vio_cmo_dev_groups;
1068-
vio_bus_type.bus_groups = vio_bus_groups;
1069-
}
1053+
static void __init vio_cmo_sysfs_init(void) { }
10701054
#else /* CONFIG_PPC_SMLPAR */
10711055
int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
10721056
void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
@@ -1584,14 +1568,6 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
15841568
}
15851569
static DEVICE_ATTR_RO(modalias);
15861570

1587-
static struct attribute *vio_dev_attrs[] = {
1588-
&dev_attr_name.attr,
1589-
&dev_attr_devspec.attr,
1590-
&dev_attr_modalias.attr,
1591-
NULL,
1592-
};
1593-
ATTRIBUTE_GROUPS(vio_dev);
1594-
15951571
void vio_unregister_device(struct vio_dev *viodev)
15961572
{
15971573
device_unregister(&viodev->dev);
@@ -1626,7 +1602,39 @@ static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
16261602
return 0;
16271603
}
16281604

1629-
struct bus_type vio_bus_type = {
1605+
#ifdef CONFIG_PPC_SMLPAR
1606+
static struct attribute *vio_cmo_dev_attrs[] = {
1607+
&dev_attr_name.attr,
1608+
&dev_attr_devspec.attr,
1609+
&dev_attr_modalias.attr,
1610+
&dev_attr_cmo_entitled.attr,
1611+
&dev_attr_cmo_allocated.attr,
1612+
&dev_attr_cmo_desired.attr,
1613+
&dev_attr_cmo_allocs_failed.attr,
1614+
NULL,
1615+
};
1616+
ATTRIBUTE_GROUPS(vio_cmo_dev);
1617+
1618+
const struct bus_type vio_bus_type = {
1619+
.name = "vio",
1620+
.dev_groups = vio_cmo_dev_groups,
1621+
.bus_groups = vio_bus_groups,
1622+
.uevent = vio_hotplug,
1623+
.match = vio_bus_match,
1624+
.probe = vio_bus_probe,
1625+
.remove = vio_bus_remove,
1626+
.shutdown = vio_bus_shutdown,
1627+
};
1628+
#else /* CONFIG_PPC_SMLPAR */
1629+
static struct attribute *vio_dev_attrs[] = {
1630+
&dev_attr_name.attr,
1631+
&dev_attr_devspec.attr,
1632+
&dev_attr_modalias.attr,
1633+
NULL,
1634+
};
1635+
ATTRIBUTE_GROUPS(vio_dev);
1636+
1637+
const struct bus_type vio_bus_type = {
16301638
.name = "vio",
16311639
.dev_groups = vio_dev_groups,
16321640
.uevent = vio_hotplug,
@@ -1635,6 +1643,7 @@ struct bus_type vio_bus_type = {
16351643
.remove = vio_bus_remove,
16361644
.shutdown = vio_bus_shutdown,
16371645
};
1646+
#endif /* CONFIG_PPC_SMLPAR */
16381647

16391648
/**
16401649
* vio_get_attribute: - get attribute for virtual device

arch/powerpc/sysdev/mpic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#define DBG(fmt...)
5050
#endif
5151

52-
struct bus_type mpic_subsys = {
52+
const struct bus_type mpic_subsys = {
5353
.name = "mpic",
5454
.dev_name = "mpic",
5555
};

drivers/macintosh/macio_asic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int macio_device_modalias(const struct device *dev, struct kobj_uevent_en
136136

137137
extern const struct attribute_group *macio_dev_groups[];
138138

139-
struct bus_type macio_bus_type = {
139+
const struct bus_type macio_bus_type = {
140140
.name = "macio",
141141
.match = macio_bus_match,
142142
.uevent = macio_device_modalias,

0 commit comments

Comments
 (0)