Commit 8154c5d2 authored by Paul Mackerras's avatar Paul Mackerras Committed by Benjamin Herrenschmidt

powerpc: Abstract indexing of lppaca structs

Currently we have the lppaca structs as a simple array of NR_CPUS
entries, taking up space in the data section of the kernel image.
In future we would like to allocate them dynamically, so this
abstracts out the accesses to the array, making it easier to
change how we locate the lppaca for a given cpu in future.
Specifically, lppaca[cpu] changes to lppaca_of(cpu).
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent e1f0ece1
...@@ -153,6 +153,8 @@ struct lppaca { ...@@ -153,6 +153,8 @@ struct lppaca {
extern struct lppaca lppaca[]; extern struct lppaca lppaca[];
#define lppaca_of(cpu) (lppaca[cpu])
/* /*
* SLB shadow buffer structure as defined in the PAPR. The save_area * SLB shadow buffer structure as defined in the PAPR. The save_area
* contains adjacent ESID and VSID pairs for each shadowed SLB. The * contains adjacent ESID and VSID pairs for each shadowed SLB. The
......
...@@ -56,7 +56,7 @@ static unsigned long get_purr(void) ...@@ -56,7 +56,7 @@ static unsigned long get_purr(void)
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (firmware_has_feature(FW_FEATURE_ISERIES)) if (firmware_has_feature(FW_FEATURE_ISERIES))
sum_purr += lppaca[cpu].emulated_time_base; sum_purr += lppaca_of(cpu).emulated_time_base;
else { else {
struct cpu_usage *cu; struct cpu_usage *cu;
...@@ -263,7 +263,7 @@ static void parse_ppp_data(struct seq_file *m) ...@@ -263,7 +263,7 @@ static void parse_ppp_data(struct seq_file *m)
ppp_data.active_system_procs); ppp_data.active_system_procs);
/* pool related entries are apropriate for shared configs */ /* pool related entries are apropriate for shared configs */
if (lppaca[0].shared_proc) { if (lppaca_of(0).shared_proc) {
unsigned long pool_idle_time, pool_procs; unsigned long pool_idle_time, pool_procs;
seq_printf(m, "pool=%d\n", ppp_data.pool_num); seq_printf(m, "pool=%d\n", ppp_data.pool_num);
...@@ -460,8 +460,8 @@ static void pseries_cmo_data(struct seq_file *m) ...@@ -460,8 +460,8 @@ static void pseries_cmo_data(struct seq_file *m)
return; return;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
cmo_faults += lppaca[cpu].cmo_faults; cmo_faults += lppaca_of(cpu).cmo_faults;
cmo_fault_time += lppaca[cpu].cmo_fault_time; cmo_fault_time += lppaca_of(cpu).cmo_fault_time;
} }
seq_printf(m, "cmo_faults=%lu\n", cmo_faults); seq_printf(m, "cmo_faults=%lu\n", cmo_faults);
...@@ -479,8 +479,8 @@ static void splpar_dispatch_data(struct seq_file *m) ...@@ -479,8 +479,8 @@ static void splpar_dispatch_data(struct seq_file *m)
unsigned long dispatch_dispersions = 0; unsigned long dispatch_dispersions = 0;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
dispatches += lppaca[cpu].yield_count; dispatches += lppaca_of(cpu).yield_count;
dispatch_dispersions += lppaca[cpu].dispersion_count; dispatch_dispersions += lppaca_of(cpu).dispersion_count;
} }
seq_printf(m, "dispatches=%lu\n", dispatches); seq_printf(m, "dispatches=%lu\n", dispatches);
...@@ -545,7 +545,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) ...@@ -545,7 +545,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
seq_printf(m, "partition_potential_processors=%d\n", seq_printf(m, "partition_potential_processors=%d\n",
partition_potential_processors); partition_potential_processors);
seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc); seq_printf(m, "shared_processor_mode=%d\n", lppaca_of(0).shared_proc);
seq_printf(m, "slb_size=%d\n", mmu_slb_size); seq_printf(m, "slb_size=%d\n", mmu_slb_size);
......
...@@ -34,7 +34,7 @@ void __spin_yield(arch_spinlock_t *lock) ...@@ -34,7 +34,7 @@ void __spin_yield(arch_spinlock_t *lock)
return; return;
holder_cpu = lock_value & 0xffff; holder_cpu = lock_value & 0xffff;
BUG_ON(holder_cpu >= NR_CPUS); BUG_ON(holder_cpu >= NR_CPUS);
yield_count = lppaca[holder_cpu].yield_count; yield_count = lppaca_of(holder_cpu).yield_count;
if ((yield_count & 1) == 0) if ((yield_count & 1) == 0)
return; /* virtual cpu is currently running */ return; /* virtual cpu is currently running */
rmb(); rmb();
...@@ -65,7 +65,7 @@ void __rw_yield(arch_rwlock_t *rw) ...@@ -65,7 +65,7 @@ void __rw_yield(arch_rwlock_t *rw)
return; /* no write lock at present */ return; /* no write lock at present */
holder_cpu = lock_value & 0xffff; holder_cpu = lock_value & 0xffff;
BUG_ON(holder_cpu >= NR_CPUS); BUG_ON(holder_cpu >= NR_CPUS);
yield_count = lppaca[holder_cpu].yield_count; yield_count = lppaca_of(holder_cpu).yield_count;
if ((yield_count & 1) == 0) if ((yield_count & 1) == 0)
return; /* virtual cpu is currently running */ return; /* virtual cpu is currently running */
rmb(); rmb();
......
...@@ -243,7 +243,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt) ...@@ -243,7 +243,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt)
pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE); pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
for (i = 0; i < NR_CPUS; i++) { for (i = 0; i < NR_CPUS; i++) {
if (lppaca[i].dyn_proc_status >= 2) if (lppaca_of(i).dyn_proc_status >= 2)
continue; continue;
snprintf(p, 32 - (p - buf), "@%d", i); snprintf(p, 32 - (p - buf), "@%d", i);
...@@ -251,7 +251,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt) ...@@ -251,7 +251,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt)
dt_prop_str(dt, "device_type", device_type_cpu); dt_prop_str(dt, "device_type", device_type_cpu);
index = lppaca[i].dyn_hv_phys_proc_index; index = lppaca_of(i).dyn_hv_phys_proc_index;
d = &xIoHriProcessorVpd[index]; d = &xIoHriProcessorVpd[index];
dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024); dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024);
......
...@@ -91,7 +91,7 @@ static void smp_iSeries_kick_cpu(int nr) ...@@ -91,7 +91,7 @@ static void smp_iSeries_kick_cpu(int nr)
BUG_ON((nr < 0) || (nr >= NR_CPUS)); BUG_ON((nr < 0) || (nr >= NR_CPUS));
/* Verify that our partition has a processor nr */ /* Verify that our partition has a processor nr */
if (lppaca[nr].dyn_proc_status >= 2) if (lppaca_of(nr).dyn_proc_status >= 2)
return; return;
/* The processor is currently spinning, waiting /* The processor is currently spinning, waiting
......
...@@ -107,14 +107,14 @@ static int dtl_enable(struct dtl *dtl) ...@@ -107,14 +107,14 @@ static int dtl_enable(struct dtl *dtl)
} }
/* set our initial buffer indices */ /* set our initial buffer indices */
dtl->last_idx = lppaca[dtl->cpu].dtl_idx = 0; dtl->last_idx = lppaca_of(dtl->cpu).dtl_idx = 0;
/* ensure that our updates to the lppaca fields have occurred before /* ensure that our updates to the lppaca fields have occurred before
* we actually enable the logging */ * we actually enable the logging */
smp_wmb(); smp_wmb();
/* enable event logging */ /* enable event logging */
lppaca[dtl->cpu].dtl_enable_mask = dtl_event_mask; lppaca_of(dtl->cpu).dtl_enable_mask = dtl_event_mask;
return 0; return 0;
} }
...@@ -123,7 +123,7 @@ static void dtl_disable(struct dtl *dtl) ...@@ -123,7 +123,7 @@ static void dtl_disable(struct dtl *dtl)
{ {
int hwcpu = get_hard_smp_processor_id(dtl->cpu); int hwcpu = get_hard_smp_processor_id(dtl->cpu);
lppaca[dtl->cpu].dtl_enable_mask = 0x0; lppaca_of(dtl->cpu).dtl_enable_mask = 0x0;
unregister_dtl(hwcpu, __pa(dtl->buf)); unregister_dtl(hwcpu, __pa(dtl->buf));
...@@ -171,7 +171,7 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len, ...@@ -171,7 +171,7 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
/* actual number of entries read */ /* actual number of entries read */
n_read = 0; n_read = 0;
cur_idx = lppaca[dtl->cpu].dtl_idx; cur_idx = lppaca_of(dtl->cpu).dtl_idx;
last_idx = dtl->last_idx; last_idx = dtl->last_idx;
if (cur_idx - last_idx > dtl->buf_entries) { if (cur_idx - last_idx > dtl->buf_entries) {
......
...@@ -250,9 +250,9 @@ void vpa_init(int cpu) ...@@ -250,9 +250,9 @@ void vpa_init(int cpu)
long ret; long ret;
if (cpu_has_feature(CPU_FTR_ALTIVEC)) if (cpu_has_feature(CPU_FTR_ALTIVEC))
lppaca[cpu].vmxregs_in_use = 1; lppaca_of(cpu).vmxregs_in_use = 1;
addr = __pa(&lppaca[cpu]); addr = __pa(&lppaca_of(cpu));
ret = register_vpa(hwcpu, addr); ret = register_vpa(hwcpu, addr);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment