Skip to content

Commit 161c51c

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: pm-cps: Drop manual cache-line alignment of ready_count
We allocate memory for a ready_count variable per-CPU, which is accessed via a cached non-coherent TLB mapping to perform synchronisation between threads within the core using LL/SC instructions. In order to ensure that the variable is contained within its own data cache line we allocate 2 lines worth of memory & align the resulting pointer to a line boundary. This is however unnecessary, since kmalloc is guaranteed to return memory which is at least cache-line aligned (see ARCH_DMA_MINALIGN). Stop the redundant manual alignment. Besides cleaning up the code & avoiding needless work, this has the side effect of avoiding an arithmetic error found by Bryan on 64 bit systems due to the 32 bit size of the former dlinesz. This led the ready_count variable to have its upper 32b cleared erroneously for MIPS64 kernels, causing problems when ready_count was later used on MIPS64 via cpuidle. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Fixes: 3179d37 ("MIPS: pm-cps: add PM state entry code for CPS systems") Reported-by: Bryan O'Donoghue <bryan.odonoghue@imgtec.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@imgtec.com> Tested-by: Bryan O'Donoghue <bryan.odonoghue@imgtec.com> Cc: linux-mips@linux-mips.org Cc: stable <stable@vger.kernel.org> # v3.16+ Patchwork: https://patchwork.linux-mips.org/patch/15383/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent ddbfff7 commit 161c51c

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

‎arch/mips/kernel/pm-cps.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ DECLARE_BITMAP(state_support, CPS_PM_STATE_COUNT);
5656
* state. Actually per-core rather than per-CPU.
5757
*/
5858
static DEFINE_PER_CPU_ALIGNED(u32*, ready_count);
59-
static DEFINE_PER_CPU_ALIGNED(void*, ready_count_alloc);
6059

6160
/* Indicates online CPUs coupled with the current CPU */
6261
static DEFINE_PER_CPU_ALIGNED(cpumask_t, online_coupled);
@@ -642,7 +641,6 @@ static int cps_pm_online_cpu(unsigned int cpu)
642641
{
643642
enum cps_pm_state state;
644643
unsigned core = cpu_data[cpu].core;
645-
unsigned dlinesz = cpu_data[cpu].dcache.linesz;
646644
void *entry_fn, *core_rc;
647645

648646
for (state = CPS_PM_NC_WAIT; state < CPS_PM_STATE_COUNT; state++) {
@@ -662,16 +660,11 @@ static int cps_pm_online_cpu(unsigned int cpu)
662660
}
663661

664662
if (!per_cpu(ready_count, core)) {
665-
core_rc = kmalloc(dlinesz * 2, GFP_KERNEL);
663+
core_rc = kmalloc(sizeof(u32), GFP_KERNEL);
666664
if (!core_rc) {
667665
pr_err("Failed allocate core %u ready_count\n", core);
668666
return -ENOMEM;
669667
}
670-
per_cpu(ready_count_alloc, core) = core_rc;
671-
672-
/* Ensure ready_count is aligned to a cacheline boundary */
673-
core_rc += dlinesz - 1;
674-
core_rc = (void *)((unsigned long)core_rc & ~(dlinesz - 1));
675668
per_cpu(ready_count, core) = core_rc;
676669
}
677670

0 commit comments

Comments
 (0)