mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Ian Munsie <imunsie@au1.ibm.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	benh@kernel.crashing.org, paulus@samba.org,
	Wolfram Sang <w.sang@pengutronix.de>,
	Michal Simek <monstr@monstr.eu>,
	Jeremy Kerr <jeremy.kerr@canonical.com>,
	devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness
Date: Sat, 2 Oct 2010 21:15:55 -0600	[thread overview]
Message-ID: <20101003031555.GB28565@angua.secretlab.ca> (raw)
In-Reply-To: <1285916771-18033-10-git-send-email-imunsie@au1.ibm.com>

On Fri, Oct 01, 2010 at 05:06:02PM +1000, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> On PowerPC the device tree is always big endian, but the CPU could be
> either, so add be32_to_cpu where appropriate and change the types of
> device tree data to __be32 etc to allow sparse to locate endian issues.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

Acked-by: Grant Likely <grant.likely@secretlab.ca>

But I won't merge this through my tree unless Ben asks me to.

g.

> ---
>  arch/powerpc/kernel/prom.c |   60 ++++++++++++++++++++++----------------------
>  1 files changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index fed9bf6..9b9ebb2 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -188,16 +188,16 @@ static void __init check_cpu_pa_features(unsigned long node)
>  #ifdef CONFIG_PPC_STD_MMU_64
>  static void __init check_cpu_slb_size(unsigned long node)
>  {
> -	u32 *slb_size_ptr;
> +	__be32 *slb_size_ptr;
>  
>  	slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
>  	if (slb_size_ptr != NULL) {
> -		mmu_slb_size = *slb_size_ptr;
> +		mmu_slb_size = be32_to_cpup(slb_size_ptr);
>  		return;
>  	}
>  	slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
>  	if (slb_size_ptr != NULL) {
> -		mmu_slb_size = *slb_size_ptr;
> +		mmu_slb_size = be32_to_cpup(slb_size_ptr);
>  	}
>  }
>  #else
> @@ -252,11 +252,11 @@ static void __init check_cpu_feature_properties(unsigned long node)
>  {
>  	unsigned long i;
>  	struct feature_property *fp = feature_properties;
> -	const u32 *prop;
> +	const __be32 *prop;
>  
>  	for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) {
>  		prop = of_get_flat_dt_prop(node, fp->name, NULL);
> -		if (prop && *prop >= fp->min_value) {
> +		if (prop && be32_to_cpup(prop) >= fp->min_value) {
>  			cur_cpu_spec->cpu_features |= fp->cpu_feature;
>  			cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftr;
>  		}
> @@ -269,8 +269,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
>  {
>  	static int logical_cpuid = 0;
>  	char *type = of_get_flat_dt_prop(node, "device_type", NULL);
> -	const u32 *prop;
> -	const u32 *intserv;
> +	const __be32 *prop;
> +	const __be32 *intserv;
>  	int i, nthreads;
>  	unsigned long len;
>  	int found = 0;
> @@ -297,9 +297,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
>  		 * version 2 of the kexec param format adds the phys cpuid of
>  		 * booted proc.
>  		 */
> -		if (initial_boot_params && initial_boot_params->version >= 2) {
> -			if (intserv[i] ==
> -					initial_boot_params->boot_cpuid_phys) {
> +		if (initial_boot_params && be32_to_cpu(initial_boot_params->version) >= 2) {
> +			if (be32_to_cpu(intserv[i]) ==
> +					be32_to_cpu(initial_boot_params->boot_cpuid_phys)) {
>  				found = 1;
>  				break;
>  			}
> @@ -324,9 +324,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
>  
>  	if (found) {
>  		DBG("boot cpu: logical %d physical %d\n", logical_cpuid,
> -			intserv[i]);
> +			be32_to_cpu(intserv[i]));
>  		boot_cpuid = logical_cpuid;
> -		set_hard_smp_processor_id(boot_cpuid, intserv[i]);
> +		set_hard_smp_processor_id(boot_cpuid, be32_to_cpu(intserv[i]));
>  
>  		/*
>  		 * PAPR defines "logical" PVR values for cpus that
> @@ -343,8 +343,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
>  		 * it uses 0x0f000001.
>  		 */
>  		prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
> -		if (prop && (*prop & 0xff000000) == 0x0f000000)
> -			identify_cpu(0, *prop);
> +		if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
> +			identify_cpu(0, be32_to_cpup(prop));
>  
>  		identical_pvr_fixup(node);
>  	}
> @@ -365,7 +365,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
>  
>  void __init early_init_dt_scan_chosen_arch(unsigned long node)
>  {
> -	unsigned long *lprop;
> +	unsigned long *lprop; /* All these set by kernel, so no need to convert endian */
>  
>  #ifdef CONFIG_PPC64
>  	/* check if iommu is forced on or off */
> @@ -524,16 +524,16 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
>  static void __init early_reserve_mem(void)
>  {
>  	u64 base, size;
> -	u64 *reserve_map;
> +	__be64 *reserve_map;
>  	unsigned long self_base;
>  	unsigned long self_size;
>  
> -	reserve_map = (u64 *)(((unsigned long)initial_boot_params) +
> -					initial_boot_params->off_mem_rsvmap);
> +	reserve_map = (__be64 *)(((unsigned long)initial_boot_params) +
> +			be32_to_cpu(initial_boot_params->off_mem_rsvmap));
>  
>  	/* before we do anything, lets reserve the dt blob */
>  	self_base = __pa((unsigned long)initial_boot_params);
> -	self_size = initial_boot_params->totalsize;
> +	self_size = be32_to_cpu(initial_boot_params->totalsize);
>  	memblock_reserve(self_base, self_size);
>  
>  #ifdef CONFIG_BLK_DEV_INITRD
> @@ -547,13 +547,13 @@ static void __init early_reserve_mem(void)
>  	 * Handle the case where we might be booting from an old kexec
>  	 * image that setup the mem_rsvmap as pairs of 32-bit values
>  	 */
> -	if (*reserve_map > 0xffffffffull) {
> +	if (be64_to_cpup(reserve_map) > 0xffffffffull) {
>  		u32 base_32, size_32;
> -		u32 *reserve_map_32 = (u32 *)reserve_map;
> +		__be32 *reserve_map_32 = (__be32 *)reserve_map;
>  
>  		while (1) {
> -			base_32 = *(reserve_map_32++);
> -			size_32 = *(reserve_map_32++);
> +			base_32 = be32_to_cpup(reserve_map_32++);
> +			size_32 = be32_to_cpup(reserve_map_32++);
>  			if (size_32 == 0)
>  				break;
>  			/* skip if the reservation is for the blob */
> @@ -566,8 +566,8 @@ static void __init early_reserve_mem(void)
>  	}
>  #endif
>  	while (1) {
> -		base = *(reserve_map++);
> -		size = *(reserve_map++);
> +		base = be64_to_cpup(reserve_map++);
> +		size = be64_to_cpup(reserve_map++);
>  		if (size == 0)
>  			break;
>  		DBG("reserving: %llx -> %llx\n", base, size);
> @@ -860,7 +860,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
>  	hardid = get_hard_smp_processor_id(cpu);
>  
>  	for_each_node_by_type(np, "cpu") {
> -		const u32 *intserv;
> +		const __be32 *intserv;
>  		unsigned int plen, t;
>  
>  		/* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
> @@ -869,10 +869,10 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
>  		intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
>  				&plen);
>  		if (intserv == NULL) {
> -			const u32 *reg = of_get_property(np, "reg", NULL);
> +			const __be32 *reg = of_get_property(np, "reg", NULL);
>  			if (reg == NULL)
>  				continue;
> -			if (*reg == hardid) {
> +			if (be32_to_cpup(reg) == hardid) {
>  				if (thread)
>  					*thread = 0;
>  				return np;
> @@ -880,7 +880,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
>  		} else {
>  			plen /= sizeof(u32);
>  			for (t = 0; t < plen; t++) {
> -				if (hardid == intserv[t]) {
> +				if (hardid == be32_to_cpu(intserv[t])) {
>  					if (thread)
>  						*thread = t;
>  					return np;
> @@ -900,7 +900,7 @@ static int __init export_flat_device_tree(void)
>  	struct dentry *d;
>  
>  	flat_dt_blob.data = initial_boot_params;
> -	flat_dt_blob.size = initial_boot_params->totalsize;
> +	flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize);
>  
>  	d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
>  				powerpc_debugfs_root, &flat_dt_blob);
> -- 
> 1.7.1
> 

  reply	other threads:[~2010-10-03  3:16 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-01  7:05 Introduce support for little endian PowerPC Ian Munsie
2010-10-01  7:05 ` [PATCH 01/18] powerpc: Add ability to build little endian kernels Ian Munsie
2010-10-01  9:18   ` Kumar Gala
2010-10-01 11:28     ` Josh Boyer
2010-10-01 12:09       ` Benjamin Herrenschmidt
2010-10-01 11:40   ` Josh Boyer
2010-10-01 12:22     ` Benjamin Herrenschmidt
2010-10-01  7:05 ` [PATCH 02/18] powerpc: Add CROSSBE_COMPILE to build big endian boot wrapper Ian Munsie
2010-10-01  7:13   ` Geert Uytterhoeven
2010-10-01  7:19     ` Ian Munsie
2010-10-01  7:05 ` [PATCH 03/18] powerpc: Support parsing a little endian kernel from zImage wrapper Ian Munsie
2010-10-01  7:05 ` [PATCH 04/18] powerpc: Allow taishan platform to boot a little endian kernel Ian Munsie
2010-10-01  7:05 ` [PATCH 05/18] powerpc: Wire up 44x little endian boot for remaining 44x targets Ian Munsie
2010-10-01 11:27   ` Josh Boyer
2010-10-06  1:28     ` Ian Munsie
2010-10-06  1:55       ` Josh Boyer
2010-10-06  2:10         ` Sean MacLennan
2010-10-01  7:05 ` [PATCH 06/18] powerpc 44x: Set E bit in TLBs and PTEs when CPU is in little endian mode Ian Munsie
2010-10-01  7:06 ` [PATCH 07/18] powerpc: Use generic bitops for little endian bitmap operations Ian Munsie
2010-10-01  7:06 ` [PATCH 08/18] powerpc: Include the appropriate endianness header Ian Munsie
2010-10-01  7:06 ` [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness Ian Munsie
2010-10-03  3:15   ` Grant Likely [this message]
2010-10-03  6:22     ` Benjamin Herrenschmidt
2010-10-01  7:06 ` [PATCH 10/18] powerpc: Support endian agnostic MMIO Ian Munsie
2010-10-01  7:06 ` [PATCH 11/18] powerpc: Make assembly endian agnostic when accessing 64bit values Ian Munsie
2010-10-01  7:06 ` [PATCH 12/18] powerpc 44x: Handle TLB miss regardless of endianness Ian Munsie
2010-10-01  7:06 ` [PATCH 13/18] powerpc 44x: Make DCR endianness agnostic Ian Munsie
2010-10-01  7:06 ` [PATCH 14/18] powerpc, of_serial: Endianness issues setting up the serial ports Ian Munsie
2010-10-07 23:23   ` Grant Likely
2010-10-01  7:06 ` [PATCH 15/18] mtd: Fix endianness issues from device tree Ian Munsie
2010-10-01 19:29   ` Artem Bityutskiy
2010-10-01  7:06 ` [PATCH 16/18] powerpc: Fix endianness issues in alignment handler Ian Munsie
2010-10-01  7:06 ` [PATCH 17/18] net: Fix endianess issues in IBM newemac driver Ian Munsie
2010-10-01  7:06 ` [PATCH 18/18] powerpc: Fix jiffies variable on little endian Ian Munsie
2010-10-01  9:02 ` Introduce support for little endian PowerPC Kumar Gala
2010-10-01 11:30   ` Josh Boyer
2010-10-01 11:55     ` Gary Thomas
2010-10-01 12:15       ` Benjamin Herrenschmidt
2010-10-01 12:37         ` Gary Thomas
2010-10-01 12:14     ` Benjamin Herrenschmidt
2010-10-01 16:20       ` Michel Dänzer
2010-10-01 20:50         ` Benjamin Herrenschmidt
2010-10-04 10:30           ` Michel Dänzer
2010-10-04 22:50             ` Benjamin Herrenschmidt
2010-10-01 17:59       ` Kumar Gala
2010-10-01 20:51         ` Benjamin Herrenschmidt
2010-10-01 22:03           ` Olof Johansson
2010-10-01 22:28             ` Benjamin Herrenschmidt
2010-10-07 16:25             ` Hollis Blanchard
2010-10-01 11:36 ` Josh Boyer
2010-10-01 12:21   ` Benjamin Herrenschmidt
2010-10-06  1:04   ` Ian Munsie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101003031555.GB28565@angua.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=benh@kernel.crashing.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=imunsie@au1.ibm.com \
    --cc=jeremy.kerr@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=monstr@monstr.eu \
    --cc=paulus@samba.org \
    --cc=w.sang@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®