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

Commit 4baeb964 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

[S390] topology: cleanup z10 topology handling



Cleanup z10 topology handling. This adds some more code but hopefully
the result is more readable and easier to maintain.

Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent f32269a0
Loading
Loading
Loading
Loading
+48 −29
Original line number Original line Diff line number Diff line
/*
/*
 *    Copyright IBM Corp. 2007
 *    Copyright IBM Corp. 2007,2011
 *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
 *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
 */
 */


@@ -72,7 +72,7 @@ static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
					  struct mask_info *book,
					  struct mask_info *book,
					  struct mask_info *core,
					  struct mask_info *core,
					  int z10)
					  int one_core_per_cpu)
{
{
	unsigned int cpu;
	unsigned int cpu;


@@ -89,7 +89,7 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
			cpumask_set_cpu(lcpu, &book->mask);
			cpumask_set_cpu(lcpu, &book->mask);
			cpu_book_id[lcpu] = book->id;
			cpu_book_id[lcpu] = book->id;
			cpumask_set_cpu(lcpu, &core->mask);
			cpumask_set_cpu(lcpu, &core->mask);
			if (z10) {
			if (one_core_per_cpu) {
				cpu_core_id[lcpu] = rcpu;
				cpu_core_id[lcpu] = rcpu;
				core = core->next;
				core = core->next;
			} else {
			} else {
@@ -124,56 +124,75 @@ static union topology_entry *next_tle(union topology_entry *tle)
	return (union topology_entry *)((struct topology_container *)tle + 1);
	return (union topology_entry *)((struct topology_container *)tle + 1);
}
}


static void tl_to_cores(struct sysinfo_15_1_x *info)
static void __tl_to_cores_generic(struct sysinfo_15_1_x *info)
{
{
	struct mask_info *core = &core_info;
	struct mask_info *core = &core_info;
	struct mask_info *book = &book_info;
	struct mask_info *book = &book_info;
	union topology_entry *tle, *end;
	union topology_entry *tle, *end;
	struct cpuid cpu_id;
	int z10 = 0;


	get_cpu_id(&cpu_id);
	z10 = cpu_id.machine == 0x2097 || cpu_id.machine == 0x2098;
	spin_lock_irq(&topology_lock);
	clear_masks();
	tle = info->tle;
	tle = info->tle;
	end = (union topology_entry *)((unsigned long)info + info->length);
	end = (union topology_entry *)((unsigned long)info + info->length);
	while (tle < end) {
	while (tle < end) {
		if (z10) {
		switch (tle->nl) {
		switch (tle->nl) {
			case 1:
		case 2:
			book = book->next;
			book = book->next;
			book->id = tle->container.id;
			book->id = tle->container.id;
			break;
			break;
		case 1:
			core = core->next;
			core->id = tle->container.id;
			break;
		case 0:
		case 0:
				core = add_cpus_to_mask(&tle->cpu, book, core, z10);
			add_cpus_to_mask(&tle->cpu, book, core, 0);
			break;
			break;
		default:
		default:
			clear_masks();
			clear_masks();
				goto out;
			return;
		}
		}
		tle = next_tle(tle);
		tle = next_tle(tle);
			continue;
	}
	}
}

static void __tl_to_cores_z10(struct sysinfo_15_1_x *info)
{
	struct mask_info *core = &core_info;
	struct mask_info *book = &book_info;
	union topology_entry *tle, *end;

	tle = info->tle;
	end = (union topology_entry *)((unsigned long)info + info->length);
	while (tle < end) {
		switch (tle->nl) {
		switch (tle->nl) {
		case 2:
		case 1:
			book = book->next;
			book = book->next;
			book->id = tle->container.id;
			book->id = tle->container.id;
			break;
			break;
		case 1:
			core = core->next;
			core->id = tle->container.id;
			break;
		case 0:
		case 0:
			add_cpus_to_mask(&tle->cpu, book, core, z10);
			core = add_cpus_to_mask(&tle->cpu, book, core, 1);
			break;
			break;
		default:
		default:
			clear_masks();
			clear_masks();
			goto out;
			return;
		}
		}
		tle = next_tle(tle);
		tle = next_tle(tle);
	}
	}
out:
}

static void tl_to_cores(struct sysinfo_15_1_x *info)
{
	struct cpuid cpu_id;

	get_cpu_id(&cpu_id);
	spin_lock_irq(&topology_lock);
	clear_masks();
	switch (cpu_id.machine) {
	case 0x2097:
	case 0x2098:
		__tl_to_cores_z10(info);
		break;
	default:
		__tl_to_cores_generic(info);
	}
	spin_unlock_irq(&topology_lock);
	spin_unlock_irq(&topology_lock);
}
}