Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fd26a77 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

[S390] smp: introduce LC_ORDER and simplify lowcore handling



Removes a couple of simple code duplications. But before I have to do
this again, just simplify it.

Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 07805ac8
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,12 @@ union save_area {
#define SAVE_AREA_BASE SAVE_AREA_BASE_S390X
#define SAVE_AREA_BASE SAVE_AREA_BASE_S390X
#endif
#endif


#ifndef __s390x__
#define LC_ORDER 0
#else
#define LC_ORDER 1
#endif

struct _lowcore
struct _lowcore
{
{
#ifndef __s390x__
#ifndef __s390x__
+4 −10
Original line number Original line Diff line number Diff line
@@ -475,10 +475,8 @@ static int __cpuinit smp_alloc_lowcore(int cpu)
{
{
	unsigned long async_stack, panic_stack;
	unsigned long async_stack, panic_stack;
	struct _lowcore *lowcore;
	struct _lowcore *lowcore;
	int lc_order;


	lc_order = sizeof(long) == 8 ? 1 : 0;
	lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, LC_ORDER);
	lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, lc_order);
	if (!lowcore)
	if (!lowcore)
		return -ENOMEM;
		return -ENOMEM;
	async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
	async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
@@ -509,16 +507,14 @@ static int __cpuinit smp_alloc_lowcore(int cpu)
out:
out:
	free_page(panic_stack);
	free_page(panic_stack);
	free_pages(async_stack, ASYNC_ORDER);
	free_pages(async_stack, ASYNC_ORDER);
	free_pages((unsigned long) lowcore, lc_order);
	free_pages((unsigned long) lowcore, LC_ORDER);
	return -ENOMEM;
	return -ENOMEM;
}
}


static void smp_free_lowcore(int cpu)
static void smp_free_lowcore(int cpu)
{
{
	struct _lowcore *lowcore;
	struct _lowcore *lowcore;
	int lc_order;


	lc_order = sizeof(long) == 8 ? 1 : 0;
	lowcore = lowcore_ptr[cpu];
	lowcore = lowcore_ptr[cpu];
#ifndef CONFIG_64BIT
#ifndef CONFIG_64BIT
	if (MACHINE_HAS_IEEE)
	if (MACHINE_HAS_IEEE)
@@ -528,7 +524,7 @@ static void smp_free_lowcore(int cpu)
#endif
#endif
	free_page(lowcore->panic_stack - PAGE_SIZE);
	free_page(lowcore->panic_stack - PAGE_SIZE);
	free_pages(lowcore->async_stack - ASYNC_SIZE, ASYNC_ORDER);
	free_pages(lowcore->async_stack - ASYNC_SIZE, ASYNC_ORDER);
	free_pages((unsigned long) lowcore, lc_order);
	free_pages((unsigned long) lowcore, LC_ORDER);
	lowcore_ptr[cpu] = NULL;
	lowcore_ptr[cpu] = NULL;
}
}


@@ -664,7 +660,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
	unsigned long async_stack, panic_stack;
	unsigned long async_stack, panic_stack;
	struct _lowcore *lowcore;
	struct _lowcore *lowcore;
	unsigned int cpu;
	unsigned int cpu;
	int lc_order;


	smp_detect_cpus();
	smp_detect_cpus();


@@ -674,8 +669,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
	print_cpu_info();
	print_cpu_info();


	/* Reallocate current lowcore, but keep its contents. */
	/* Reallocate current lowcore, but keep its contents. */
	lc_order = sizeof(long) == 8 ? 1 : 0;
	lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, LC_ORDER);
	lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, lc_order);
	panic_stack = __get_free_page(GFP_KERNEL);
	panic_stack = __get_free_page(GFP_KERNEL);
	async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
	async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
	BUG_ON(!lowcore || !panic_stack || !async_stack);
	BUG_ON(!lowcore || !panic_stack || !async_stack);