* [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness
[not found] <1285916771-18033-1-git-send-email-imunsie@au1.ibm.com>
@ 2010-10-01 7:06 ` Ian Munsie
2010-10-03 3:15 ` Grant Likely
2010-10-01 7:06 ` [PATCH 13/18] powerpc 44x: Make DCR endianness agnostic Ian Munsie
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Ian Munsie @ 2010-10-01 7:06 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, benh
Cc: paulus, Ian Munsie, Grant Likely, Wolfram Sang, Michal Simek,
Jeremy Kerr, devicetree-discuss
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>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 13/18] powerpc 44x: Make DCR endianness agnostic
[not found] <1285916771-18033-1-git-send-email-imunsie@au1.ibm.com>
2010-10-01 7:06 ` [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness Ian Munsie
@ 2010-10-01 7:06 ` Ian Munsie
2010-10-01 7:06 ` [PATCH 14/18] powerpc, of_serial: Endianness issues setting up the serial ports Ian Munsie
2010-10-01 7:06 ` [PATCH 17/18] net: Fix endianess issues in IBM newemac driver Ian Munsie
3 siblings, 0 replies; 7+ messages in thread
From: Ian Munsie @ 2010-10-01 7:06 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, benh
Cc: paulus, Ian Munsie, Josh Boyer, Stefan Roese, Thomas Gleixner,
Peter Zijlstra, Anton Blanchard, Geoff Levand, Grant Likely,
devicetree-discuss
From: Ian Munsie <imunsie@au1.ibm.com>
The Device Control Register accesses parse the device tree and therefore
need to handle the possible differences of endianness between the CPU
and device tree.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/powerpc/sysdev/dcr.c | 18 +++++++++---------
arch/powerpc/sysdev/ppc4xx_soc.c | 16 ++++++++--------
arch/powerpc/sysdev/uic.c | 6 +++---
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index bb44aa9..7f91e8a 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -27,7 +27,7 @@
static struct device_node *find_dcr_parent(struct device_node *node)
{
struct device_node *par, *tmp;
- const u32 *p;
+ const __be32 *p;
for (par = of_node_get(node); par;) {
if (of_get_property(par, "dcr-controller", NULL))
@@ -37,7 +37,7 @@ static struct device_node *find_dcr_parent(struct device_node *node)
if (p == NULL)
par = of_get_parent(par);
else
- par = of_find_node_by_phandle(*p);
+ par = of_find_node_by_phandle(be32_to_cpup(p));
of_node_put(tmp);
}
return par;
@@ -128,24 +128,24 @@ unsigned int dcr_resource_start(const struct device_node *np,
unsigned int index)
{
unsigned int ds;
- const u32 *dr = of_get_property(np, "dcr-reg", &ds);
+ const __be32 *dr = of_get_property(np, "dcr-reg", &ds);
if (dr == NULL || ds & 1 || index >= (ds / 8))
return 0;
- return dr[index * 2];
+ return be32_to_cpu(dr[index * 2]);
}
EXPORT_SYMBOL_GPL(dcr_resource_start);
unsigned int dcr_resource_len(const struct device_node *np, unsigned int index)
{
unsigned int ds;
- const u32 *dr = of_get_property(np, "dcr-reg", &ds);
+ const __be32 *dr = of_get_property(np, "dcr-reg", &ds);
if (dr == NULL || ds & 1 || index >= (ds / 8))
return 0;
- return dr[index * 2 + 1];
+ return be32_to_cpu(dr[index * 2 + 1]);
}
EXPORT_SYMBOL_GPL(dcr_resource_len);
@@ -156,7 +156,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
unsigned int *out_stride)
{
struct device_node *dp;
- const u32 *p;
+ const __be32 *p;
unsigned int stride;
u64 ret = OF_BAD_ADDR;
@@ -166,7 +166,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
/* Stride is not properly defined yet, default to 0x10 for Axon */
p = of_get_property(dp, "dcr-mmio-stride", NULL);
- stride = (p == NULL) ? 0x10 : *p;
+ stride = (p == NULL) ? 0x10 : be32_to_cpup(p);
/* XXX FIXME: Which property name is to use of the 2 following ? */
p = of_get_property(dp, "dcr-mmio-range", NULL);
@@ -176,7 +176,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
goto done;
/* Maybe could do some better range checking here */
- ret = of_translate_address(dp, p);
+ ret = of_translate_address(dp, be32_to_cpup(p));
if (ret != OF_BAD_ADDR)
ret += (u64)(stride) * (u64)dcr_n;
if (out_stride)
diff --git a/arch/powerpc/sysdev/ppc4xx_soc.c b/arch/powerpc/sysdev/ppc4xx_soc.c
index d3d6ce3..e5a7554 100644
--- a/arch/powerpc/sysdev/ppc4xx_soc.c
+++ b/arch/powerpc/sysdev/ppc4xx_soc.c
@@ -76,10 +76,10 @@ static int __init ppc4xx_l2c_probe(void)
u32 r;
unsigned long flags;
int irq;
- const u32 *dcrreg;
+ const __be32 *dcrreg;
u32 dcrbase_isram;
int len;
- const u32 *prop;
+ const __be32 *prop;
u32 l2_size;
np = of_find_compatible_node(NULL, NULL, "ibm,l2-cache");
@@ -93,7 +93,7 @@ static int __init ppc4xx_l2c_probe(void)
of_node_put(np);
return -ENODEV;
}
- l2_size = prop[0];
+ l2_size = be32_to_cpu(prop[0]);
/* Map DCRs */
dcrreg = of_get_property(np, "dcr-reg", &len);
@@ -103,8 +103,8 @@ static int __init ppc4xx_l2c_probe(void)
of_node_put(np);
return -ENODEV;
}
- dcrbase_isram = dcrreg[0];
- dcrbase_l2c = dcrreg[2];
+ dcrbase_isram = be32_to_cpu(dcrreg[0]);
+ dcrbase_l2c = be32_to_cpu(dcrreg[2]);
/* Get and map irq number from device tree */
irq = irq_of_parse_and_map(np, 0);
@@ -198,7 +198,7 @@ void ppc4xx_reset_system(char *cmd)
{
struct device_node *np;
u32 reset_type = DBCR0_RST_SYSTEM;
- const u32 *prop;
+ const __be32 *prop;
np = of_find_node_by_type(NULL, "cpu");
if (np) {
@@ -210,8 +210,8 @@ void ppc4xx_reset_system(char *cmd)
* 2 - PPC4xx chip reset
* 3 - PPC4xx system reset (default)
*/
- if ((prop) && ((prop[0] >= 1) && (prop[0] <= 3)))
- reset_type = prop[0] << 28;
+ if ((prop) && ((be32_to_cpu(prop[0]) >= 1) && (be32_to_cpu(prop[0]) <= 3)))
+ reset_type = be32_to_cpu(prop[0]) << 28;
}
mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | reset_type);
diff --git a/arch/powerpc/sysdev/uic.c b/arch/powerpc/sysdev/uic.c
index 0038fb7..e2f7de8 100644
--- a/arch/powerpc/sysdev/uic.c
+++ b/arch/powerpc/sysdev/uic.c
@@ -253,7 +253,7 @@ uic_irq_ret:
static struct uic * __init uic_init_one(struct device_node *node)
{
struct uic *uic;
- const u32 *indexp, *dcrreg;
+ const __be32 *indexp, *dcrreg;
int len;
BUG_ON(! of_device_is_compatible(node, "ibm,uic"));
@@ -269,7 +269,7 @@ static struct uic * __init uic_init_one(struct device_node *node)
"cell-index property\n", node->full_name);
return NULL;
}
- uic->index = *indexp;
+ uic->index = be32_to_cpup(indexp);
dcrreg = of_get_property(node, "dcr-reg", &len);
if (!dcrreg || (len != 2*sizeof(u32))) {
@@ -277,7 +277,7 @@ static struct uic * __init uic_init_one(struct device_node *node)
"dcr-reg property\n", node->full_name);
return NULL;
}
- uic->dcrbase = *dcrreg;
+ uic->dcrbase = be32_to_cpup(dcrreg);
uic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
NR_UIC_INTS, &uic_host_ops, -1);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 14/18] powerpc, of_serial: Endianness issues setting up the serial ports
[not found] <1285916771-18033-1-git-send-email-imunsie@au1.ibm.com>
2010-10-01 7:06 ` [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness Ian Munsie
2010-10-01 7:06 ` [PATCH 13/18] powerpc 44x: Make DCR endianness agnostic Ian Munsie
@ 2010-10-01 7:06 ` Ian Munsie
[not found] ` <1285916771-18033-15-git-send-email-imunsie-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2010-10-01 7:06 ` [PATCH 17/18] net: Fix endianess issues in IBM newemac driver Ian Munsie
3 siblings, 1 reply; 7+ messages in thread
From: Ian Munsie @ 2010-10-01 7:06 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, benh
Cc: paulus, Ian Munsie, Stefan Weil, Jiri Kosina, Grant Likely,
Sean MacLennan, Greg Kroah-Hartman, Michal Simek, David S. Miller,
devicetree-discuss
From: Ian Munsie <imunsie@au1.ibm.com>
The speed and clock of the serial ports is retrieved from the device
tree in both the PowerPC legacy serial code and the Open Firmware serial
driver, therefore they need to handle the fact that the device tree is
always big endian, while the CPU may not be.
Also fix other device tree references in the legacy serial code.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
arch/powerpc/kernel/legacy_serial.c | 22 +++++++++++-----------
drivers/serial/of_serial.c | 12 ++++++------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index c1fd0f9..c834757 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
phys_addr_t taddr, unsigned long irq,
upf_t flags, int irq_check_parent)
{
- const u32 *clk, *spd;
+ const __be32 *clk, *spd;
u32 clock = BASE_BAUD * 16;
int index;
/* get clock freq. if present */
clk = of_get_property(np, "clock-frequency", NULL);
if (clk && *clk)
- clock = *clk;
+ clock = be32_to_cpup(clk);
/* get default speed if present */
spd = of_get_property(np, "current-speed", NULL);
@@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
legacy_serial_infos[index].taddr = taddr;
legacy_serial_infos[index].np = of_node_get(np);
legacy_serial_infos[index].clock = clock;
- legacy_serial_infos[index].speed = spd ? *spd : 0;
+ legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
legacy_serial_infos[index].irq_check_parent = irq_check_parent;
printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
@@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
static int __init add_legacy_isa_port(struct device_node *np,
struct device_node *isa_brg)
{
- const u32 *reg;
+ const __be32 *reg;
const char *typep;
int index = -1;
u64 taddr;
@@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
return -1;
/* Verify it's an IO port, we don't support anything else */
- if (!(reg[0] & 0x00000001))
+ if (!(be32_to_cpu(reg[0]) & 0x00000001))
return -1;
/* Now look for an "ibm,aix-loc" property that gives us ordering
@@ -202,7 +202,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
taddr = 0;
/* Add port, irq will be dealt with later */
- return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr,
+ return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
NO_IRQ, UPF_BOOT_AUTOCONF, 0);
}
@@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
* we get to their "reg" property
*/
if (np != pci_dev) {
- const u32 *reg = of_get_property(np, "reg", NULL);
- if (reg && (*reg < 4))
- index = lindex = *reg;
+ const __be32 *reg = of_get_property(np, "reg", NULL);
+ if (reg && (be32_to_cpup(reg) < 4))
+ index = lindex = be32_to_cpup(reg);
}
/* Local index means it's the Nth port in the PCI chip. Unfortunately
@@ -507,7 +507,7 @@ static int __init check_legacy_serial_console(void)
struct device_node *prom_stdout = NULL;
int i, speed = 0, offset = 0;
const char *name;
- const u32 *spd;
+ const __be32 *spd;
DBG(" -> check_legacy_serial_console()\n");
@@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
}
spd = of_get_property(prom_stdout, "current-speed", NULL);
if (spd)
- speed = *spd;
+ speed = be32_to_cpup(spd);
if (strcmp(name, "serial") != 0)
goto not_found;
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 2af8fd1..17849dc 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -31,8 +31,8 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
{
struct resource resource;
struct device_node *np = ofdev->dev.of_node;
- const unsigned int *clk, *spd;
- const u32 *prop;
+ const __be32 *clk, *spd;
+ const __be32 *prop;
int ret, prop_size;
memset(port, 0, sizeof *port);
@@ -55,23 +55,23 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
/* Check for shifted address mapping */
prop = of_get_property(np, "reg-offset", &prop_size);
if (prop && (prop_size == sizeof(u32)))
- port->mapbase += *prop;
+ port->mapbase += be32_to_cpup(prop);
/* Check for registers offset within the devices address range */
prop = of_get_property(np, "reg-shift", &prop_size);
if (prop && (prop_size == sizeof(u32)))
- port->regshift = *prop;
+ port->regshift = be32_to_cpup(prop);
port->irq = irq_of_parse_and_map(np, 0);
port->iotype = UPIO_MEM;
port->type = type;
- port->uartclk = *clk;
+ port->uartclk = be32_to_cpup(clk);
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
| UPF_FIXED_PORT | UPF_FIXED_TYPE;
port->dev = &ofdev->dev;
/* If current-speed was set, then try not to change it. */
if (spd)
- port->custom_divisor = *clk / (16 * (*spd));
+ port->custom_divisor = be32_to_cpup(clk) / (16 * (be32_to_cpup(spd)));
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 17/18] net: Fix endianess issues in IBM newemac driver
[not found] <1285916771-18033-1-git-send-email-imunsie@au1.ibm.com>
` (2 preceding siblings ...)
2010-10-01 7:06 ` [PATCH 14/18] powerpc, of_serial: Endianness issues setting up the serial ports Ian Munsie
@ 2010-10-01 7:06 ` Ian Munsie
3 siblings, 0 replies; 7+ messages in thread
From: Ian Munsie @ 2010-10-01 7:06 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, benh
Cc: paulus, Ian Munsie, David S. Miller, Grant Likely, Jiri Pirko,
Sean MacLennan, Tejun Heo, netdev, devicetree-discuss
From: Ian Munsie <imunsie@au1.ibm.com>
This patch fixes all the device tree and ring buffer accesses in the IBM
newemac driver.
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
drivers/net/ibm_newemac/core.c | 68 ++++++++++++++++++++--------------------
drivers/net/ibm_newemac/mal.c | 6 ++--
drivers/net/ibm_newemac/mal.h | 6 ++--
3 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 3506fd6..67238b8 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -981,12 +981,12 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
* to simplify error recovery in the case of allocation failure later.
*/
for (i = 0; i < NUM_RX_BUFF; ++i) {
- if (dev->rx_desc[i].ctrl & MAL_RX_CTRL_FIRST)
+ if (dev->rx_desc[i].ctrl & cpu_to_be16(MAL_RX_CTRL_FIRST))
++dev->estats.rx_dropped_resize;
dev->rx_desc[i].data_len = 0;
- dev->rx_desc[i].ctrl = MAL_RX_CTRL_EMPTY |
- (i == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0);
+ dev->rx_desc[i].ctrl = cpu_to_be16(MAL_RX_CTRL_EMPTY |
+ (i == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0));
}
/* Reallocate RX ring only if bigger skb buffers are required */
@@ -1005,9 +1005,9 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
dev_kfree_skb(dev->rx_skb[i]);
skb_reserve(skb, EMAC_RX_SKB_HEADROOM + 2);
- dev->rx_desc[i].data_ptr =
+ dev->rx_desc[i].data_ptr = cpu_to_be32(
dma_map_single(&dev->ofdev->dev, skb->data - 2, rx_sync_size,
- DMA_FROM_DEVICE) + 2;
+ DMA_FROM_DEVICE) + 2);
dev->rx_skb[i] = skb;
}
skip:
@@ -1067,7 +1067,7 @@ static void emac_clean_tx_ring(struct emac_instance *dev)
if (dev->tx_skb[i]) {
dev_kfree_skb(dev->tx_skb[i]);
dev->tx_skb[i] = NULL;
- if (dev->tx_desc[i].ctrl & MAL_TX_CTRL_READY)
+ if (dev->tx_desc[i].ctrl & cpu_to_be16(MAL_TX_CTRL_READY))
++dev->estats.tx_dropped;
}
dev->tx_desc[i].ctrl = 0;
@@ -1104,12 +1104,12 @@ static inline int emac_alloc_rx_skb(struct emac_instance *dev, int slot,
dev->rx_desc[slot].data_len = 0;
skb_reserve(skb, EMAC_RX_SKB_HEADROOM + 2);
- dev->rx_desc[slot].data_ptr =
+ dev->rx_desc[slot].data_ptr = cpu_to_be32(
dma_map_single(&dev->ofdev->dev, skb->data - 2, dev->rx_sync_size,
- DMA_FROM_DEVICE) + 2;
+ DMA_FROM_DEVICE) + 2);
wmb();
- dev->rx_desc[slot].ctrl = MAL_RX_CTRL_EMPTY |
- (slot == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0);
+ dev->rx_desc[slot].ctrl = cpu_to_be16(MAL_RX_CTRL_EMPTY |
+ (slot == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0));
return 0;
}
@@ -1373,12 +1373,12 @@ static int emac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
DBG2(dev, "xmit(%u) %d" NL, len, slot);
dev->tx_skb[slot] = skb;
- dev->tx_desc[slot].data_ptr = dma_map_single(&dev->ofdev->dev,
+ dev->tx_desc[slot].data_ptr = cpu_to_be32(dma_map_single(&dev->ofdev->dev,
skb->data, len,
- DMA_TO_DEVICE);
- dev->tx_desc[slot].data_len = (u16) len;
+ DMA_TO_DEVICE));
+ dev->tx_desc[slot].data_len = cpu_to_be16(len);
wmb();
- dev->tx_desc[slot].ctrl = ctrl;
+ dev->tx_desc[slot].ctrl = cpu_to_be16(ctrl);
return emac_xmit_finish(dev, len);
}
@@ -1399,9 +1399,9 @@ static inline int emac_xmit_split(struct emac_instance *dev, int slot,
ctrl |= MAL_TX_CTRL_WRAP;
dev->tx_skb[slot] = NULL;
- dev->tx_desc[slot].data_ptr = pd;
- dev->tx_desc[slot].data_len = (u16) chunk;
- dev->tx_desc[slot].ctrl = ctrl;
+ dev->tx_desc[slot].data_ptr = cpu_to_be32(pd);
+ dev->tx_desc[slot].data_len = cpu_to_be16(chunk);
+ dev->tx_desc[slot].ctrl = cpu_to_be16(ctrl);
++dev->tx_cnt;
if (!len)
@@ -1442,9 +1442,9 @@ static int emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev)
/* skb data */
dev->tx_skb[slot] = NULL;
chunk = min(len, MAL_MAX_TX_SIZE);
- dev->tx_desc[slot].data_ptr = pd =
- dma_map_single(&dev->ofdev->dev, skb->data, len, DMA_TO_DEVICE);
- dev->tx_desc[slot].data_len = (u16) chunk;
+ dev->tx_desc[slot].data_ptr = cpu_to_be32(pd =
+ dma_map_single(&dev->ofdev->dev, skb->data, len, DMA_TO_DEVICE));
+ dev->tx_desc[slot].data_len = cpu_to_be16(chunk);
len -= chunk;
if (unlikely(len))
slot = emac_xmit_split(dev, slot, pd + chunk, len, !nr_frags,
@@ -1473,7 +1473,7 @@ static int emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev)
if (dev->tx_slot == NUM_TX_BUFF - 1)
ctrl |= MAL_TX_CTRL_WRAP;
wmb();
- dev->tx_desc[dev->tx_slot].ctrl = ctrl;
+ dev->tx_desc[dev->tx_slot].ctrl = cpu_to_be16(ctrl);
dev->tx_slot = (slot + 1) % NUM_TX_BUFF;
return emac_xmit_finish(dev, skb->len);
@@ -1541,7 +1541,7 @@ static void emac_poll_tx(void *param)
u16 ctrl;
int slot = dev->ack_slot, n = 0;
again:
- ctrl = dev->tx_desc[slot].ctrl;
+ ctrl = be16_to_cpu(dev->tx_desc[slot].ctrl);
if (!(ctrl & MAL_TX_CTRL_READY)) {
struct sk_buff *skb = dev->tx_skb[slot];
++n;
@@ -1583,8 +1583,8 @@ static inline void emac_recycle_rx_skb(struct emac_instance *dev, int slot,
dev->rx_desc[slot].data_len = 0;
wmb();
- dev->rx_desc[slot].ctrl = MAL_RX_CTRL_EMPTY |
- (slot == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0);
+ dev->rx_desc[slot].ctrl = cpu_to_be16(MAL_RX_CTRL_EMPTY |
+ (slot == (NUM_RX_BUFF - 1) ? MAL_RX_CTRL_WRAP : 0));
}
static void emac_parse_rx_error(struct emac_instance *dev, u16 ctrl)
@@ -1628,7 +1628,7 @@ static inline void emac_rx_csum(struct emac_instance *dev,
static inline int emac_rx_sg_append(struct emac_instance *dev, int slot)
{
if (likely(dev->rx_sg_skb != NULL)) {
- int len = dev->rx_desc[slot].data_len;
+ int len = be16_to_cpu(dev->rx_desc[slot].data_len);
int tot_len = dev->rx_sg_skb->len + len;
if (unlikely(tot_len + 2 > dev->rx_skb_size)) {
@@ -1659,14 +1659,14 @@ static int emac_poll_rx(void *param, int budget)
while (budget > 0) {
int len;
struct sk_buff *skb;
- u16 ctrl = dev->rx_desc[slot].ctrl;
+ u16 ctrl = be16_to_cpu(dev->rx_desc[slot].ctrl);
if (ctrl & MAL_RX_CTRL_EMPTY)
break;
skb = dev->rx_skb[slot];
mb();
- len = dev->rx_desc[slot].data_len;
+ len = be16_to_cpu(dev->rx_desc[slot].data_len);
if (unlikely(!MAL_IS_SINGLE_RX(ctrl)))
goto sg;
@@ -1757,7 +1757,7 @@ static int emac_poll_rx(void *param, int budget)
if (unlikely(budget && test_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags))) {
mb();
- if (!(dev->rx_desc[slot].ctrl & MAL_RX_CTRL_EMPTY)) {
+ if (!(dev->rx_desc[slot].ctrl & cpu_to_be16(MAL_RX_CTRL_EMPTY))) {
DBG2(dev, "rx restart" NL);
received = 0;
goto again;
@@ -1783,7 +1783,7 @@ static int emac_peek_rx(void *param)
{
struct emac_instance *dev = param;
- return !(dev->rx_desc[dev->rx_slot].ctrl & MAL_RX_CTRL_EMPTY);
+ return !(dev->rx_desc[dev->rx_slot].ctrl & cpu_to_be16(MAL_RX_CTRL_EMPTY));
}
/* NAPI poll context */
@@ -1793,7 +1793,7 @@ static int emac_peek_rx_sg(void *param)
int slot = dev->rx_slot;
while (1) {
- u16 ctrl = dev->rx_desc[slot].ctrl;
+ u16 ctrl = be16_to_cpu(dev->rx_desc[slot].ctrl);
if (ctrl & MAL_RX_CTRL_EMPTY)
return 0;
else if (ctrl & MAL_RX_CTRL_LAST)
@@ -2367,14 +2367,14 @@ static int __devinit emac_read_uint_prop(struct device_node *np, const char *nam
u32 *val, int fatal)
{
int len;
- const u32 *prop = of_get_property(np, name, &len);
+ const __be32 *prop = of_get_property(np, name, &len);
if (prop == NULL || len < sizeof(u32)) {
if (fatal)
printk(KERN_ERR "%s: missing %s property\n",
np->full_name, name);
return -ENODEV;
}
- *val = *prop;
+ *val = be32_to_cpup(prop);
return 0;
}
@@ -3013,7 +3013,7 @@ static void __init emac_make_bootlist(void)
/* Collect EMACs */
while((np = of_find_all_nodes(np)) != NULL) {
- const u32 *idx;
+ const __be32 *idx;
if (of_match_node(emac_match, np) == NULL)
continue;
@@ -3022,7 +3022,7 @@ static void __init emac_make_bootlist(void)
idx = of_get_property(np, "cell-index", NULL);
if (idx == NULL)
continue;
- cell_indices[i] = *idx;
+ cell_indices[i] = be32_to_cpup(idx);
emac_boot_list[i++] = of_node_get(np);
if (i >= EMAC_BOOT_LIST_SIZE) {
of_node_put(np);
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c
index d5717e2..9e4939e 100644
--- a/drivers/net/ibm_newemac/mal.c
+++ b/drivers/net/ibm_newemac/mal.c
@@ -524,7 +524,7 @@ static int __devinit mal_probe(struct platform_device *ofdev,
int err = 0, i, bd_size;
int index = mal_count++;
unsigned int dcr_base;
- const u32 *prop;
+ const __be32 *prop;
u32 cfg;
unsigned long irqflags;
irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde;
@@ -550,7 +550,7 @@ static int __devinit mal_probe(struct platform_device *ofdev,
err = -ENODEV;
goto fail;
}
- mal->num_tx_chans = prop[0];
+ mal->num_tx_chans = be32_to_cpu(prop[0]);
prop = of_get_property(ofdev->dev.of_node, "num-rx-chans", NULL);
if (prop == NULL) {
@@ -560,7 +560,7 @@ static int __devinit mal_probe(struct platform_device *ofdev,
err = -ENODEV;
goto fail;
}
- mal->num_rx_chans = prop[0];
+ mal->num_rx_chans = be32_to_cpu(prop[0]);
dcr_base = dcr_resource_start(ofdev->dev.of_node, 0);
if (dcr_base == 0) {
diff --git a/drivers/net/ibm_newemac/mal.h b/drivers/net/ibm_newemac/mal.h
index 6608421..b8ee413 100644
--- a/drivers/net/ibm_newemac/mal.h
+++ b/drivers/net/ibm_newemac/mal.h
@@ -147,9 +147,9 @@ static inline int mal_tx_chunks(int len)
/* MAL Buffer Descriptor structure */
struct mal_descriptor {
- u16 ctrl; /* MAL / Commac status control bits */
- u16 data_len; /* Max length is 4K-1 (12 bits) */
- u32 data_ptr; /* pointer to actual data buffer */
+ __be16 ctrl; /* MAL / Commac status control bits */
+ __be16 data_len; /* Max length is 4K-1 (12 bits) */
+ __be32 data_ptr; /* pointer to actual data buffer */
};
/* the following defines are for the MadMAL status and control registers. */
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness
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
2010-10-03 6:22 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2010-10-03 3:15 UTC (permalink / raw)
To: Ian Munsie
Cc: linux-kernel, linuxppc-dev, benh, paulus, Wolfram Sang,
Michal Simek, Jeremy Kerr, devicetree-discuss
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 09/18] powerpc: Support device tree regardless of CPU endianness
2010-10-03 3:15 ` Grant Likely
@ 2010-10-03 6:22 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2010-10-03 6:22 UTC (permalink / raw)
To: Grant Likely
Cc: Michal Simek, devicetree-discuss, linux-kernel, paulus,
Ian Munsie, Jeremy Kerr, linuxppc-dev
On Sat, 2010-10-02 at 21:15 -0600, Grant Likely wrote:
>
> But I won't merge this through my tree unless Ben asks me to.
Being careful heh ? :-)
I'll take care of these.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 14/18] powerpc, of_serial: Endianness issues setting up the serial ports
[not found] ` <1285916771-18033-15-git-send-email-imunsie-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
@ 2010-10-07 23:23 ` Grant Likely
0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2010-10-07 23:23 UTC (permalink / raw)
To: Ian Munsie
Cc: Greg Kroah-Hartman, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
Sean MacLennan, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Weil,
Jiri Kosina, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, David S. Miller
On Fri, Oct 01, 2010 at 05:06:07PM +1000, Ian Munsie wrote:
> From: Ian Munsie <imunsie-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
>
> The speed and clock of the serial ports is retrieved from the device
> tree in both the PowerPC legacy serial code and the Open Firmware serial
> driver, therefore they need to handle the fact that the device tree is
> always big endian, while the CPU may not be.
>
> Also fix other device tree references in the legacy serial code.
>
> Signed-off-by: Ian Munsie <imunsie-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
Applied, thanks.
I'm picking up this one because it is also needed by Microblaze.
Michal Simek also posted a patch that does the same thing, but this
one is better so I'm dropping his in favour of this one.
As for the other patches, they all look good to me (at least for the
bits that I care about), but I'll leave them for Ben to pick up so the
series doesn't get too fragmented.
g.
> ---
> arch/powerpc/kernel/legacy_serial.c | 22 +++++++++++-----------
> drivers/serial/of_serial.c | 12 ++++++------
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
> index c1fd0f9..c834757 100644
> --- a/arch/powerpc/kernel/legacy_serial.c
> +++ b/arch/powerpc/kernel/legacy_serial.c
> @@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
> phys_addr_t taddr, unsigned long irq,
> upf_t flags, int irq_check_parent)
> {
> - const u32 *clk, *spd;
> + const __be32 *clk, *spd;
> u32 clock = BASE_BAUD * 16;
> int index;
>
> /* get clock freq. if present */
> clk = of_get_property(np, "clock-frequency", NULL);
> if (clk && *clk)
> - clock = *clk;
> + clock = be32_to_cpup(clk);
>
> /* get default speed if present */
> spd = of_get_property(np, "current-speed", NULL);
> @@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
> legacy_serial_infos[index].taddr = taddr;
> legacy_serial_infos[index].np = of_node_get(np);
> legacy_serial_infos[index].clock = clock;
> - legacy_serial_infos[index].speed = spd ? *spd : 0;
> + legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
> legacy_serial_infos[index].irq_check_parent = irq_check_parent;
>
> printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
> @@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
> static int __init add_legacy_isa_port(struct device_node *np,
> struct device_node *isa_brg)
> {
> - const u32 *reg;
> + const __be32 *reg;
> const char *typep;
> int index = -1;
> u64 taddr;
> @@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
> return -1;
>
> /* Verify it's an IO port, we don't support anything else */
> - if (!(reg[0] & 0x00000001))
> + if (!(be32_to_cpu(reg[0]) & 0x00000001))
> return -1;
>
> /* Now look for an "ibm,aix-loc" property that gives us ordering
> @@ -202,7 +202,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
> taddr = 0;
>
> /* Add port, irq will be dealt with later */
> - return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr,
> + return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
> NO_IRQ, UPF_BOOT_AUTOCONF, 0);
>
> }
> @@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
> * we get to their "reg" property
> */
> if (np != pci_dev) {
> - const u32 *reg = of_get_property(np, "reg", NULL);
> - if (reg && (*reg < 4))
> - index = lindex = *reg;
> + const __be32 *reg = of_get_property(np, "reg", NULL);
> + if (reg && (be32_to_cpup(reg) < 4))
> + index = lindex = be32_to_cpup(reg);
> }
>
> /* Local index means it's the Nth port in the PCI chip. Unfortunately
> @@ -507,7 +507,7 @@ static int __init check_legacy_serial_console(void)
> struct device_node *prom_stdout = NULL;
> int i, speed = 0, offset = 0;
> const char *name;
> - const u32 *spd;
> + const __be32 *spd;
>
> DBG(" -> check_legacy_serial_console()\n");
>
> @@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
> }
> spd = of_get_property(prom_stdout, "current-speed", NULL);
> if (spd)
> - speed = *spd;
> + speed = be32_to_cpup(spd);
>
> if (strcmp(name, "serial") != 0)
> goto not_found;
> diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
> index 2af8fd1..17849dc 100644
> --- a/drivers/serial/of_serial.c
> +++ b/drivers/serial/of_serial.c
> @@ -31,8 +31,8 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> {
> struct resource resource;
> struct device_node *np = ofdev->dev.of_node;
> - const unsigned int *clk, *spd;
> - const u32 *prop;
> + const __be32 *clk, *spd;
> + const __be32 *prop;
> int ret, prop_size;
>
> memset(port, 0, sizeof *port);
> @@ -55,23 +55,23 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> /* Check for shifted address mapping */
> prop = of_get_property(np, "reg-offset", &prop_size);
> if (prop && (prop_size == sizeof(u32)))
> - port->mapbase += *prop;
> + port->mapbase += be32_to_cpup(prop);
>
> /* Check for registers offset within the devices address range */
> prop = of_get_property(np, "reg-shift", &prop_size);
> if (prop && (prop_size == sizeof(u32)))
> - port->regshift = *prop;
> + port->regshift = be32_to_cpup(prop);
>
> port->irq = irq_of_parse_and_map(np, 0);
> port->iotype = UPIO_MEM;
> port->type = type;
> - port->uartclk = *clk;
> + port->uartclk = be32_to_cpup(clk);
> port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
> | UPF_FIXED_PORT | UPF_FIXED_TYPE;
> port->dev = &ofdev->dev;
> /* If current-speed was set, then try not to change it. */
> if (spd)
> - port->custom_divisor = *clk / (16 * (*spd));
> + port->custom_divisor = be32_to_cpup(clk) / (16 * (be32_to_cpup(spd)));
>
> return 0;
> }
> --
> 1.7.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-10-07 23:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1285916771-18033-1-git-send-email-imunsie@au1.ibm.com>
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
2010-10-03 6:22 ` Benjamin Herrenschmidt
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
[not found] ` <1285916771-18033-15-git-send-email-imunsie-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2010-10-07 23:23 ` Grant Likely
2010-10-01 7:06 ` [PATCH 17/18] net: Fix endianess issues in IBM newemac driver Ian Munsie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox