[REGRESSION 2.6.27] i2c-mpc not probing on linkstation (was Re: [PATCH] powerpc: enable heap randomization for linkstations)

2008-10-20 Thread Guennadi Liakhovetski
On Mon, 20 Oct 2008, Jon Smirl wrote:

> On Mon, Oct 20, 2008 at 1:55 AM, Guennadi Liakhovetski
> <[EMAIL PROTECTED]> wrote:
> > On Sun, 19 Oct 2008, Jon Smirl wrote:
> >
> >> Is i2c-mpc built into your kernel? It's not going to module auto-load
> >> because the names don't match - fsl-i2c and i2c-mpc.
> >
> > It is built into the kernel.
> 
> Put a printk in it's init function to make sure it is initializing.

I don't need that, I see it here:

/sys/bus/of_platform/drivers/mpc-i2c

> Next thing I do is put printks over in arch/powerpc/.. to tell me
> which strings from the device tree are being looked for.
> 
> You can also look in /proc/device_tree and make sure fsl-i2c is in there.
> 
> When you find the problem is will probably be something simple like a
> mismatch between _ and -. I have been down this path before and spent
> a day figuring out why a module wouldn't load and it was a simple
> typo.

Thanks, I know, that I can find the reason and, probably, a fix after a 
day of printk debugging. The thing is - I don't have this day, and I am 
sure there are people on this list, who can spot and fix the problem 
within minutes, that's why I posted it here after I realised, that 2 hours 
of me searching for the problem didn't bring any result.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Bug in "genirq: record trigger type"

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 22:05 +, Linux Kernel Mailing List wrote:
> Gitweb: 
> http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0c5d1eb77a8be917b638344a22afe1398236482b
> Commit: 0c5d1eb77a8be917b638344a22afe1398236482b
> Parent: d6d5aeb661fc14655c417f3582ae7ec52985d2a8
> Author: David Brownell <[EMAIL PROTECTED]>
> AuthorDate: Wed Oct 1 14:46:18 2008 -0700
> Committer:  Ingo Molnar <[EMAIL PROTECTED]>
> CommitDate: Thu Oct 2 10:24:09 2008 +0200

This one is obviously broken and breaks booting on a whole bunch of
machines (including powermac's and thus my G5, it's never good when my
own machine breaks !).

Nice to see 3 SOB's and one Ack and nobody caught the obvious bug :-)

>   desc = irq_desc + irq;
> - if (desc->chip->set_type) {
> - spin_lock_irqsave(&desc->lock, flags);
> - ret = desc->chip->set_type(irq, type);
> - spin_unlock_irqrestore(&desc->lock, flags);
> - }
> + if (type == IRQ_TYPE_NONE)
> + return 0;
> +
> + spin_lock_irqsave(&desc->lock, flags);
> + ret = __irq_set_trigger(desc, irq, flags);
  type maybe ?

> + spin_unlock_irqrestore(&desc->lock, flags);
>   return ret;
>  }

I have to run so no patch until tomorrow unless somebody beats me to it.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: powerpc: delete prom_strtoul and prom_memparse

2008-10-20 Thread Michael Ellerman
On Mon, 2008-10-20 at 23:03 -0500, Milton Miller wrote:
> These functions should have been static, and inspection shows they
> are no longer used.   (We used to parse mem= but we now defer that
> to early_param).

Actually the last user was the crashkernel= handling, but that was
removed a while ago too, my bad.

Acked-by: Michael Ellerman <[EMAIL PROTECTED]>

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH] igb: add IGB_DCA instead of selecting INTEL_IOATDMA

2008-10-20 Thread Jeff Garzik

Jeff Kirsher wrote:

Add a bool IGB_DCA defined to y if IGB and DCA are enabled, but IGB isn't y 
while DCA=m.  And thus remove the need to select INTEL_IOATDMA when IGB is 
enabled, so that non-x86 architectures can build the igb driver.
Based on work/patch from Brice Goglin <[EMAIL PROTECTED]>

Signed-off-by: Jeff Kirsher <[EMAIL PROTECTED]>


applied


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] ehea: Fix memory hotplug support

2008-10-20 Thread Jeff Garzik

Hannes Hering wrote:

This patch implements the memory notifier to update the busmap instantly
instead of rebuilding the whole map. This is necessary because
walk_memory_resource provides different information than required during memory
hotplug.

Signed-off-by: Hannes Hering <[EMAIL PROTECTED]>
---
Jeff, as requested, this patch is now based on davem's net-2.6.git.


applied


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Support for relocatable kdump kernel

2008-10-20 Thread Michael Ellerman
On Mon, 2008-10-20 at 15:04 +0530, Mohan Kumar M wrote:
> Michael Ellerman wrote:
> >>>  #ifdef CONFIG_CRASH_DUMP
> >>> +#ifdef CONFIG_RELOCATABLE
> >>> +
> >>> +static inline void reserve_kdump_trampoline(void) { ; }
> >>> +static inline void setup_kdump_trampoline(void) { ; }
> >>> +
> >>> +#else
> >>>  
> >>>  extern void reserve_kdump_trampoline(void);
> >>>  extern void setup_kdump_trampoline(void);
> >>>  
> >>> +#endif /* CONFIG_RELOCATABLE */
> > 
> > You've disabled the else case with your Kconfig changes, so you should
> > just rip all that code out.
> 
> I made Kconfig changes only to the 64 bit powerpc path and still the 32 
> bit powerpc code uses the legacy kdump code. So we need to retain some 
> of legacy kdump code.

Does it? I see CONFIG_CRASH_DUMP depending on PPC64, so there is no
32-bit kdump possible. Or is someone working on it out-of-tree?

> >>> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> >>> index e409338..5b12b10 100644
> >>> --- a/arch/powerpc/kernel/head_64.S
> >>> +++ b/arch/powerpc/kernel/head_64.S
> >>> @@ -97,6 +97,14 @@ __secondary_hold_spinloop:
> >>>  __secondary_hold_acknowledge:
> >>>   .llong  0x0
> >>>  
> >>> + /* This flag is set only for kdump kernels so that */
> >>> + /* it will be relocatable. Purgatory code user space kexec-tools */
> >>> + /* sets this flag. Do not move this variable as purgatory code */
> >>> + /* relies on the position of this variables */
> >>> + .globl  __kdump_flag
> >>> +__kdump_flag:
> >>> + .llong  0x0
> > 
> > I guess the __ matches the other flags here, it's not the prettiest
> > though. For client code (like in iommu.c) it'd be nice to have static
> > inline, perhaps is_kdump_kernel() that hides this.
> > 
> Do you expect a function to do the checking in iommu.c?

You'd use the function in iommu.c, but it should be defined in some
header.

> >>>  #ifdef CONFIG_PPC_ISERIES
> >>>   /*
> >>>* At offset 0x20, there is a pointer to iSeries LPAR data.
> >>> @@ -1384,8 +1392,13 @@ _STATIC(__after_prom_start)
> >>>   /* process relocations for the final address of the kernel */
> >>>   lis r25,[EMAIL PROTECTED]   /* compute virtual base of kernel */
> >>>   sldir25,r25,32
> >>> +#ifdef CONFIG_CRASH_DUMP
> >>> + ld  r7,__kdump_flag-_stext(r26)
> >>> + cmpldi  cr0,r7,1/* relocatable kernel ? */
> > 
> > You don't use the signature here?
> 
> kexec-tools check the signature and based on the signature it sets 
> __kdump_flag to 1 (or 0). So kernel code just checks whether its set or not.

OK. Does old purgatory ensure that the register is 0? Otherwise I think
it's possible that a new kernel could get confused by cruft left in that
register by an old purgatory - causing the 2nd kernel to think it's a
kdump kernel when it shouldn't be.

> >>> @@ -1401,9 +1414,21 @@ _STATIC(__after_prom_start)
> >>>   beq 9f  /* have already put us at zero */
> >>>   li  r6,0x100/* Start offset, the first 0x100 */
> >>>   /* bytes were copied earlier.*/
> >>> -#ifdef CONFIG_RELOCATABLE
> >>> +
> >>> +#ifdef CONFIG_CRASH_DUMP
> >>> +/*
> >>> + * Check if the kernel has to be running as relocatable kernel based on 
> >>> the
> >>> + * variable __kdump_flag, if it is set the kernel is treated as 
> >>> relocatble
> >>> + * kernel, otherwise it will be moved to PHYSICAL_START
> >>> + */
> >>> + ld  r7,__kdump_flag-_stext(r26)
> >>> + cmpldi  cr0,r7,1
> >>> + bne regular
> >>> +
> >>>   li  r5,__end_interrupts - _stext/* just copy interrupts */
> >>> -#else
> >>> + b   5f
> >>> +regular:
> >>> +#endif
> >>>   lis r5,(copy_to_here - _stext)@ha
> >>>   addir5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */
> > 
> > I'm jet lagged to hell, so I'm not sure I can trust my parsing of this.
> > But I think this definitely breaks CONFIG_RELOCATABLE without
> > CRASH_DUMP, and I'm not sure it's right otherwise.
> >
> Hmmm, I compiled and tried the kernel with 3 config option combinations: 
> 1. CONFIG_RELOCATABLE and CONFIG_CRASH_DUMP 2. CONFIG_RELOCATABLE 3. 
> Without CONFIG_RELOCATABLE (without CONFIG_CRASH_DUMP)
> 
> All of the above 3 combinations worked. This patch relies on Pauls' 
> patch5 in the relocatable kernel patcheset.

OK if you've tested.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: device tree variations

2008-10-20 Thread Benjamin Herrenschmidt

> Thanks.  The fdt_del_node approach works pretty nicely.  I added a
> dt_ops hook since fdt is static in libfdt-wrapper.c.

 .../...

David says your patch is ok, However it's not in the right form. Could
you repost it please with a proper changeset comment and signed-off-by:
line ?

Thanks !

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: build failure on powerpc with current -git

2008-10-20 Thread Paul Mackerras
Chris Friesen writes:

> The current -git fails to build on 64-bit powerpc (failure log below) . 
>   Initially I tried using my older toolchain, when I first saw the 
> problem I built a new toolchain with crosstool (gcc 4.1.2 and binutils 
> 2.16.1) and tried again but got the same problem.

It's a bug in older versions of ld (including 2.16.1) that's fixed in
the current version (2.18).  However, this patch appears to work
around the problem - at least, it let me build a 32-bit kernel with a
cross-toolchain including a 2.16.1 ld.  Let me know if this gets it
working for you.

Paul.

diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 25fe9d6..e8acee2 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -284,6 +284,8 @@ if [ -n "$dtb" ]; then
 if [ -n "$dts" ]; then
rm $dtb
 fi
+else
+addsec $tmp /dev/null .kernel:dtb
 fi
 
 if [ "$platform" != "miboot" ]; then
diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index b39c27e..384dca5 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -187,6 +187,7 @@ SECTIONS
*(.machine.desc)
__machine_desc_end = . ;
}
+#ifdef CONFIG_RELOCATABLE
. = ALIGN(8);
.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) { *(.dynsym) }
.dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
@@ -202,6 +203,7 @@ SECTIONS
__rela_dyn_start = .;
*(.rela*)
}
+#endif
 
/* Fake ELF header containing RPA note; for addnote */
.fakeelf : AT(ADDR(.fakeelf) - LOAD_OFFSET) { *(.fakeelf) }
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] ibm_newemac: Fix new MAL feature handling

2008-10-20 Thread Jeff Garzik

Benjamin Herrenschmidt wrote:

On Thu, 2008-10-16 at 10:38 -0400, Josh Boyer wrote:

On Thu, Oct 16, 2008 at 03:56:50PM +1100, Benjamin Herrenschmidt wrote:

drivers/net/ibm_newemac/mal.c: In function 'mal_txeob':
drivers/net/ibm_newemac/mal.c:284: error: implicit declaration of function 
'mtdcri'
drivers/net/ibm_newemac/mal.c:284: error: 'SDR0' undeclared (first use in this 
function)
drivers/net/ibm_newemac/mal.c:284: error: (Each undeclared identifier is 
reported only once
drivers/net/ibm_newemac/mal.c:284: error: for each function it appears in.)
drivers/net/ibm_newemac/mal.c:285: error: implicit declaration of function 
'mfdcri'
drivers/net/ibm_newemac/mal.c: In function 'mal_rxeob':
drivers/net/ibm_newemac/mal.c:302: error: 'SDR0' undeclared (first use in this 
function)

That's annoying, I'll have a look.

Support for new features needed by the PPC 405EZ boards
introduced some errors in the MAL and EMAC feature handling.
This broke 'allmodconfig' builds as CONFIG_PPC_DCR_NATIVE is
not set for those.

This patch fixes these errors by wrapping the code in the
appropriate #ifdefs.

Signed-off-by: Josh Boyer <[EMAIL PROTECTED]>


Acked-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
---

Jeff, this breaks build, I'll put it in powerpc.git for a merge today,


ACK


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] powerpc/83xx: add DS1339 RTC support for MPC8349E-mITX boards

2008-10-20 Thread Kumar Gala


On Oct 17, 2008, at 1:56 PM, Anton Vorontsov wrote:

The RTC is sitting on the I2C2 bus at address 0x68. RTC interrupt  
signal
is connected to the IPIC's EXT2 interrupt line, the line is shared  
with

Vitesse 8201 Ethernet PHY.

Signed-off-by: Anton Vorontsov <[EMAIL PROTECTED]>
---
arch/powerpc/boot/dts/mpc8349emitx.dts   |8 
arch/powerpc/boot/dts/mpc8349emitxgp.dts |8 
2 files changed, 16 insertions(+), 0 deletions(-)


applied

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2/2] powerpc/83xx: add support for MCU on 8349emitx, 837xrdb and 8315erdb boards

2008-10-20 Thread Kumar Gala


On Oct 17, 2008, at 1:57 PM, Anton Vorontsov wrote:


MCU is an external Freescale MC9S08QG8 microcontroller, mainly used to
provide soft power-off function, but also exports two GPIOs (wired to
the LEDs and also available from the external headers).

Signed-off-by: Anton Vorontsov <[EMAIL PROTECTED]>
---
arch/powerpc/boot/dts/mpc8315erdb.dts  |8 
arch/powerpc/boot/dts/mpc8349emitx.dts |8 
arch/powerpc/boot/dts/mpc8377_rdb.dts  |8 
arch/powerpc/boot/dts/mpc8378_rdb.dts  |8 
arch/powerpc/boot/dts/mpc8379_rdb.dts  |8 
5 files changed, 40 insertions(+), 0 deletions(-)


applied

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[UPDATED] Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala
Please pull from 'for-2.6.28' branch of

master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28

to receive the following updates:

 Documentation/powerpc/booting-without-of.txt |2 +
 Documentation/powerpc/dts-bindings/fsl/board.txt |4 +--
 arch/powerpc/boot/dts/mpc8315erdb.dts|8 ++
 arch/powerpc/boot/dts/mpc832x_mds.dts|2 -
 arch/powerpc/boot/dts/mpc8349emitx.dts   |   16 +
 arch/powerpc/boot/dts/mpc8349emitxgp.dts |8 ++
 arch/powerpc/boot/dts/mpc834x_mds.dts|2 -
 arch/powerpc/boot/dts/mpc836x_mds.dts|2 -
 arch/powerpc/boot/dts/mpc8377_rdb.dts|8 ++
 arch/powerpc/boot/dts/mpc8378_rdb.dts|8 ++
 arch/powerpc/boot/dts/mpc8379_rdb.dts|8 ++
 arch/powerpc/boot/dts/mpc8536ds.dts  |   12 +-
 arch/powerpc/boot/dts/mpc8568mds.dts |2 -
 arch/powerpc/boot/dts/mpc8572ds.dts  |   27 +++
 drivers/i2c/busses/i2c-cpm.c |1
 drivers/of/of_spi.c  |2 +
 16 files changed, 85 insertions(+), 27 deletions(-)

Anton Vorontsov (3):
  powerpc: Remove device_type = "board_control" properties in .dts files
  powerpc/83xx: Add support for MCU microcontroller in .dts files
  powerpc/83xx: Add DS1339 RTC support for MPC8349E-mITX boards .dts

Ed Swarthout (1):
  powerpc/85xx: Fix mpc8536ds dma interrupt numbers

Jason Jin (1):
  powerpc/85xx: Enable enhanced functions for 8536 TSEC

Kumar Gala (1):
  powerpc/85xx: Move mpc8572ds.dts to address-cells/size-cells = <2>

Wolfgang Ocker (1):
  of/spi: Support specifying chip select as active high via device tree

Wolfram Sang (1):
  i2c-cpm: Suppress autoprobing for devices

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [1/1] powerpc: Update page in counter for CMM

2008-10-20 Thread Milton Miller
X-Patchwork-Id: 5144

On Mon Oct 20, 2008 near 12:19:21 GMT, Brian King wrote:
> 
> A new field has been added to the VPA as a method for
> the client OS to communicate to firmware the number of
> page ins it is performing when running collaborative
> memory overcommit. The hypervisor will use this information
> to better determine if a partition is experiencing memory
> pressure and needs more memory allocated to it.
> 
> Signed-off-by: Brian King <[EMAIL PROTECTED]>
> ---
> 
>  arch/powerpc/include/asm/lppaca.h |3 ++-
>  arch/powerpc/kernel/paca.c|1 +
>  arch/powerpc/mm/fault.c   |8 ++--
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff -puN arch/powerpc/mm/fault.c~powerpc_vrm_mm_pressure 
> arch/powerpc/mm/fault.c
> --- linux-2.6/arch/powerpc/mm/fault.c~powerpc_vrm_mm_pressure 2008-10-20 
> 17:13:25.0 -0500
> +++ linux-2.6-bjking1/arch/powerpc/mm/fault.c 2008-10-20 17:13:25.0 
> -0500
..
> @@ -318,9 +320,11 @@ good_area:
>   goto do_sigbus;
>   BUG();
>   }
> - if (ret & VM_FAULT_MAJOR)
> + if (ret & VM_FAULT_MAJOR) {
>   current->maj_flt++;
> - else
> + if (firmware_has_feature(FW_FEATURE_CMO))
> + atomic_inc((atomic_t *)(&(get_lppaca()->page_ins)));
> + } else
>   current->min_flt++;
>   up_read(&mm->mmap_sem);
>   return 0;

(1) why do we need atomic_inc and the hundreds or thousands of cycles to
do the atomic inc in a per-cpu area?

(2) assuming we make this a normal increment, should we keep the
feature test or just do it unconditionally (ie is the additional load
and branch worse that just doing the load and store of the counter --
the address was previously reserved, right?  (no question if
it has to be atomic).




Ben asked if we need to worry about the hypervisor clearing the
count.  If they treat it as a only-incrementing then we don't need
to worry.  And since its only an indicator, then we may not care
about a big count by them interrupting between the load and store

If we are worried about linux preemption, then we need to disable
it to avoid crossing cpu variables or  getting to this point multiple
times.  (I have not looked at the context to see if we are already
disabled).




milton
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Kernel Oops when run ifconfig on MPC8360MDS board

2008-10-20 Thread mike zheng
Oh, I forgot to metion just now. The linux is based on a custom built
kernel 2.4.22, not from Freescale.

On 10/20/08, mike zheng <[EMAIL PROTECTED]> wrote:
> On 10/20/08, Kim Phillips <[EMAIL PROTECTED]> wrote:
> > On Mon, 20 Oct 2008 15:00:33 -0700
> > "mike zheng" <[EMAIL PROTECTED]> wrote:
> >
> > > I have following kernel Oops when I run ifconfig to setup the UEC0 of
> > > MPC8360MDS board. There is no hardware problem, the UEC0 runs well
> > > under Uboot.
> >
> > does this occur on vanilla u-boot and kernel versions?  if so, which
> > ones, and on what board revision?
> >
> The kernel Oops happened under Linux when I try to use "ifconfig" to
> setup the eth0. Under Uboot, the UEC0 works fine. I am able to do
> ping, tftp via the ethernet port.
>
>
> > > Call backtrace:
> > > C0126890 C00D59D0 C00D761C C012F400 C0130DD4 C01746B4 C017712C
> > > C0127770 C004D8B0 C0005ABC  10001214 100023C4 0FEC4E00
> > > 
> >
> > might want to turn on verbose debugging while you're at it.
>
> Which flag shall I turned on? I am not formaliar to the network driver. 
> Thanks!
> >
> > Kim
> >
>
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Kernel Oops when run ifconfig on MPC8360MDS board

2008-10-20 Thread mike zheng
On 10/20/08, Kim Phillips <[EMAIL PROTECTED]> wrote:
> On Mon, 20 Oct 2008 15:00:33 -0700
> "mike zheng" <[EMAIL PROTECTED]> wrote:
>
> > I have following kernel Oops when I run ifconfig to setup the UEC0 of
> > MPC8360MDS board. There is no hardware problem, the UEC0 runs well
> > under Uboot.
>
> does this occur on vanilla u-boot and kernel versions?  if so, which
> ones, and on what board revision?
>
The kernel Oops happened under Linux when I try to use "ifconfig" to
setup the eth0. Under Uboot, the UEC0 works fine. I am able to do
ping, tftp via the ethernet port.


> > Call backtrace:
> > C0126890 C00D59D0 C00D761C C012F400 C0130DD4 C01746B4 C017712C
> > C0127770 C004D8B0 C0005ABC  10001214 100023C4 0FEC4E00
> > 
>
> might want to turn on verbose debugging while you're at it.

Which flag shall I turned on? I am not formaliar to the network driver. Thanks!
>
> Kim
>
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] powerpc/85xx: Move mpc8572ds.dts to address-cells/size-cells = <2>

2008-10-20 Thread Kumar Gala
Change the top-level #address-cells and #size-cells to <2> so the
mpc8572ds.dts is easier to deal with both a true 32-bit physical
or 36-bit physical address space.

Signed-off-by: Kumar Gala <[EMAIL PROTECTED]>
---
 arch/powerpc/boot/dts/mpc8572ds.dts |   27 +--
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8572ds.dts 
b/arch/powerpc/boot/dts/mpc8572ds.dts
index e124dd1..cadd465 100644
--- a/arch/powerpc/boot/dts/mpc8572ds.dts
+++ b/arch/powerpc/boot/dts/mpc8572ds.dts
@@ -13,8 +13,8 @@
 / {
model = "fsl,MPC8572DS";
compatible = "fsl,MPC8572DS";
-   #address-cells = <1>;
-   #size-cells = <1>;
+   #address-cells = <2>;
+   #size-cells = <2>;
 
aliases {
ethernet0 = &enet0;
@@ -61,7 +61,6 @@
 
memory {
device_type = "memory";
-   reg = <0x0 0x0>;// Filled by U-Boot
};
 
[EMAIL PROTECTED] {
@@ -69,8 +68,8 @@
#size-cells = <1>;
device_type = "soc";
compatible = "simple-bus";
-   ranges = <0x0 0xffe0 0x10>;
-   reg = <0xffe0 0x1000>;  // CCSRBAR & soc regs, remove 
once parse code for immrbase fixed
+   ranges = <0x0 0 0xffe0 0x10>;
+   reg = <0 0xffe0 0 0x1000>;  // CCSRBAR & soc regs, remove 
once parse code for immrbase fixed
bus-frequency = <0>;// Filled out by uboot.
 
[EMAIL PROTECTED] {
@@ -351,10 +350,10 @@
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
-   reg = <0xffe08000 0x1000>;
+   reg = <0 0xffe08000 0 0x1000>;
bus-range = <0 255>;
-   ranges = <0x200 0x0 0x8000 0x8000 0x0 0x2000
- 0x100 0x0 0x0 0xffc0 0x0 0x1>;
+   ranges = <0x200 0x0 0x8000 0 0x8000 0x0 0x2000
+ 0x100 0x0 0x 0 0xffc0 0x0 0x0001>;
clock-frequency = <>;
interrupt-parent = <&mpic>;
interrupts = <24 2>;
@@ -561,10 +560,10 @@
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
-   reg = <0xffe09000 0x1000>;
+   reg = <0 0xffe09000 0 0x1000>;
bus-range = <0 255>;
-   ranges = <0x200 0x0 0xa000 0xa000 0x0 0x2000
- 0x100 0x0 0x0 0xffc1 0x0 0x1>;
+   ranges = <0x200 0x0 0xa000 0 0xa000 0x0 0x2000
+ 0x100 0x0 0x 0 0xffc1 0x0 0x0001>;
clock-frequency = <>;
interrupt-parent = <&mpic>;
interrupts = <26 2>;
@@ -598,10 +597,10 @@
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
-   reg = <0xffe0a000 0x1000>;
+   reg = <0 0xffe0a000 0 0x1000>;
bus-range = <0 255>;
-   ranges = <0x200 0x0 0xc000 0xc000 0x0 0x2000
- 0x100 0x0 0x0 0xffc2 0x0 0x1>;
+   ranges = <0x200 0x0 0xc000 0 0xc000 0x0 0x2000
+ 0x100 0x0 0x 0 0xffc2 0x0 0x0001>;
clock-frequency = <>;
interrupt-parent = <&mpic>;
interrupts = <27 2>;
-- 
1.5.5.1

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala


On Oct 20, 2008, at 10:51 PM, Benjamin Herrenschmidt wrote:


On Mon, 2008-10-20 at 22:45 -0500, Kumar Gala wrote:


If you had conventions on naming this is the first I've heard of
them.  I know Paul asked about the [POWERPC] to powerpc: change on
list.


Well, they weren't official, but others seem to have picked them up,  
no

big deal but heh, here now you know about them :-)


I do so as well.  As stated above, if there are naming conventions
that are desired I'm happy to conform but just need to know what they
are.


Well, my aim is mostly consistency. If you don't like what I want, I'm
happy to discuss it, but I'd like basically to keep consistency in the
naming conventions. In some cases though, my comment also refers to  
the

subject being a tad too vague to my taste. I know there isn't a strict
definition of what is good enough or not and we definitely don't  
want a

3 lines novel there, but in the case of the .dts file update, it would
have been useful to highlight that fact for example.


As stated, I know now so I'm happy to conform.


The limit is based on trust.  I submitted all the other cleanup
patches to remove PPC_MERGE.  I think I can handle such a patch going
via my tree.


I would have still preferred if we had discussed it before hand...


Yeah, see my previous gripe about trivial patches and my tree :)

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


powerpc: delete prom_strtoul and prom_memparse

2008-10-20 Thread Milton Miller
These functions should have been static, and inspection shows they
are no longer used.   (We used to parse mem= but we now defer that
to early_param).

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
---
This version removes them

Index: next.git/arch/powerpc/kernel/prom_init.c
===
--- next.git.orig/arch/powerpc/kernel/prom_init.c   2008-10-20 
17:51:15.0 -0500
+++ next.git/arch/powerpc/kernel/prom_init.c2008-10-20 22:40:16.0 
-0500
@@ -487,67 +487,6 @@ static int __init prom_setprop(phandle n
return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd);
 }
 
-/* We can't use the standard versions because of RELOC headaches. */
-#define isxdigit(c)(('0' <= (c) && (c) <= '9') \
-|| ('a' <= (c) && (c) <= 'f') \
-|| ('A' <= (c) && (c) <= 'F'))
-
-#define isdigit(c) ('0' <= (c) && (c) <= '9')
-#define islower(c) ('a' <= (c) && (c) <= 'z')
-#define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c))
-
-unsigned long prom_strtoul(const char *cp, const char **endp)
-{
-   unsigned long result = 0, base = 10, value;
-
-   if (*cp == '0') {
-   base = 8;
-   cp++;
-   if (toupper(*cp) == 'X') {
-   cp++;
-   base = 16;
-   }
-   }
-
-   while (isxdigit(*cp) &&
-  (value = isdigit(*cp) ? *cp - '0' : toupper(*cp) - 'A' + 10) < 
base) {
-   result = result * base + value;
-   cp++;
-   }
-
-   if (endp)
-   *endp = cp;
-
-   return result;
-}
-
-unsigned long prom_memparse(const char *ptr, const char **retptr)
-{
-   unsigned long ret = prom_strtoul(ptr, retptr);
-   int shift = 0;
-
-   /*
-* We can't use a switch here because GCC *may* generate a
-* jump table which won't work, because we're not running at
-* the address we're linked at.
-*/
-   if ('G' == **retptr || 'g' == **retptr)
-   shift = 30;
-
-   if ('M' == **retptr || 'm' == **retptr)
-   shift = 20;
-
-   if ('K' == **retptr || 'k' == **retptr)
-   shift = 10;
-
-   if (shift) {
-   ret <<= shift;
-   (*retptr)++;
-   }
-
-   return ret;
-}
-
 /*
  * Early parsing of the command line passed to the kernel, used for
  * "mem=x" and the options that affect the iommu
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Further compile fixup for STRICT_MM_TYPECHECKS

2008-10-20 Thread David Gibson
A patch of mine was recently committed to fix up STRICT_MM_TYPECHECKS
behaviour on powerpc (f5ea64dcbad89875d130596df14c9b25d994a737).
However, something which breaks it again seems to have slipped in
afterwards.  So, here's another small fix.

Signed-off-by: David Gibson <[EMAIL PROTECTED]>

Index: working-2.6/arch/powerpc/kernel/pci-common.c
===
--- working-2.6.orig/arch/powerpc/kernel/pci-common.c   2008-10-21 
13:53:29.0 +1100
+++ working-2.6/arch/powerpc/kernel/pci-common.c2008-10-21 
13:53:52.0 +1100
@@ -610,7 +610,8 @@ int pci_mmap_legacy_page_range(struct pc
pr_debug(" -> mapping phys %llx\n", (unsigned long long)offset);
 
vma->vm_pgoff = offset >> PAGE_SHIFT;
-   vma->vm_page_prot |= _PAGE_NO_CACHE | _PAGE_GUARDED;
+   vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
+| _PAGE_NO_CACHE | _PAGE_GUARDED);
return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
   vma->vm_end - vma->vm_start,
   vma->vm_page_prot);

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 22:45 -0500, Kumar Gala wrote:
> 
> If you had conventions on naming this is the first I've heard of  
> them.  I know Paul asked about the [POWERPC] to powerpc: change on
> list.

Well, they weren't official, but others seem to have picked them up, no
big deal but heh, here now you know about them :-)

> I do so as well.  As stated above, if there are naming conventions  
> that are desired I'm happy to conform but just need to know what they
> are.

Well, my aim is mostly consistency. If you don't like what I want, I'm
happy to discuss it, but I'd like basically to keep consistency in the
naming conventions. In some cases though, my comment also refers to the
subject being a tad too vague to my taste. I know there isn't a strict
definition of what is good enough or not and we definitely don't want a
3 lines novel there, but in the case of the .dts file update, it would
have been useful to highlight that fact for example.

> The limit is based on trust.  I submitted all the other cleanup  
> patches to remove PPC_MERGE.  I think I can handle such a patch going
> via my tree.

I would have still preferred if we had discussed it before hand...

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala


On Oct 20, 2008, at 7:11 PM, Benjamin Herrenschmidt wrote:


On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:

Please pull from 'for-2.6.28' branch of

	master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git  
for-2.6.28


to receive the following updates:


Ok so I'm not too happy. Kumar, you need to be a little bit more  
careful

with your git tree. Here are a few things that are causing me problems
at the moment and making me not pull this one. Some of them I already
sent separate emails for but let's put it all together:

- First, please try to keep a consistent merge branch. Even if it ends
up merging separate branches from you internally.


Yeah, I got the message.


- Please use git request-pull or at least provide me with the merge
base in the email if it's not my current master or next HEAD, and  
since
it makes my life a bit harder too, please try to have your tree  
based on

mine unless you have some conflicts to sort out.


will do.


- Please spend a bit more time cleaning up the cset subjects and
comments. For example:

"powerpc: remove device_type = "boad_control"

There are a few problems with this one. Not everybody knows what
"device_type" is, it's not obvious that it's a device-tree change, and
you may notice that I've been trying to keep the first character after
the category: uppercase. I would have preferred something like:

	powerpc: Remove device_type = "board_control" properties in .dts  
files


Another one that doesn't pass my criteria is:

OF: SPI: specify chip select active high

I don't like caps, and it's not the generally accepted format. It  
should

be something like:

of/spi: Provide a way to specify chip select polarity

Nicer heh ?


If you had conventions on naming this is the first I've heard of  
them.  I know Paul asked about the [POWERPC] to powerpc: change on list.


I almost always rewrite subjects and sometimes fixup descriptions  
when I

merge patches. Please do so too.


I do so as well.  As stated above, if there are naming conventions  
that are desired I'm happy to conform but just need to know what they  
are.



- Finally, the Kconfig change shouldn't have been in your tree at all,
or at least not without my or paulus ack and prior argeement that it
should be merged that way. No big deal with this obviously correct
patch but where do we put the limit ?



The limit is based on trust.  I submitted all the other cleanup  
patches to remove PPC_MERGE.  I think I can handle such a patch going  
via my tree.


- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Benjamin Herrenschmidt

>  - Finally, the Kconfig change shouldn't have been in your tree at all,
> or at least not without my or paulus ack and prior argeement that it
> should be merged that way. No big deal with this obviously correct
> patch but where do we put the limit ?

Same with the CONFIG_RELOCATABLE build fix. I'll pick both from
patchwork into my bundle for linus and they shouldn't go through
your tree unless prior approval.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3] Revert to real-base = 12MB on 32-bit CHRP

2008-10-20 Thread Paul Mackerras
Commit 9b09c6d909dfd8de96b99b9b9c808b94b0a71614 ("powerpc: Change the
default link address for pSeries zImage kernels") changed the
real-base value in the CHRP note added by addnote to the zImage from
12MB to 32MB.  It turns out that this causes unnecessary extra reboots
on old 32-bit CHRP machines.  This therefore adds a -r flag to addnote
to allow us to specify what real-base value it should put in the CHRP
note, and adjusts the wrapper script to pass -r c0 to addnote when
making a zImage for a CHRP machine.  Also, CHRP machines ignore the
RPA note, so we don't need to arrange for it to be the same as the
kernel's.

Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
An extra change that I did for debugging purposes crept into v2.

diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index dcc9ab2..a43682e 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -11,7 +11,7 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  *
- * Usage: addnote zImage [note.elf]
+ * Usage: addnote [-r realbase] zImage [note.elf]
  *
  * If note.elf is supplied, it is the name of an ELF file that contains
  * an RPA note to use instead of the built-in one.  Alternatively, the
@@ -153,18 +153,31 @@ unsigned char *read_rpanote(const char *fname, int *nnp)
 int
 main(int ac, char **av)
 {
-   int fd, n, i;
+   int fd, n, i, ai;
int ph, ps, np;
int nnote, nnote2, ns;
unsigned char *rpap;
-
-   if (ac != 2 && ac != 3) {
-   fprintf(stderr, "Usage: %s elf-file [rpanote.elf]\n", av[0]);
+   char *p, *endp;
+
+   ai = 1;
+   if (ac >= ai + 2 && strcmp(av[ai], "-r") == 0) {
+   /* process -r realbase */
+   p = av[ai + 1];
+   descr[1] = strtol(p, &endp, 16);
+   if (endp == p || *endp != 0) {
+   fprintf(stderr, "Can't parse -r argument '%s' as hex\n",
+   p);
+   exit(1);
+   }
+   ai += 2;
+   }
+   if (ac != ai + 1 && ac != ai + 2) {
+   fprintf(stderr, "Usage: %s [-r realbase] elf-file 
[rpanote.elf]\n", av[0]);
exit(1);
}
-   fd = open(av[1], O_RDWR);
+   fd = open(av[ai], O_RDWR);
if (fd < 0) {
-   perror(av[1]);
+   perror(av[ai]);
exit(1);
}
 
@@ -184,12 +197,12 @@ main(int ac, char **av)
if (buf[E_IDENT+EI_CLASS] != ELFCLASS32
|| buf[E_IDENT+EI_DATA] != ELFDATA2MSB) {
fprintf(stderr, "%s is not a big-endian 32-bit ELF image\n",
-   av[1]);
+   av[ai]);
exit(1);
}
 
-   if (ac == 3)
-   rpap = read_rpanote(av[2], &nnote2);
+   if (ac == ai + 2)
+   rpap = read_rpanote(av[ai + 1], &nnote2);
 
ph = GET_32BE(buf, E_PHOFF);
ps = GET_16BE(buf, E_PHENTSIZE);
@@ -202,7 +215,7 @@ main(int ac, char **av)
for (i = 0; i < np; ++i) {
if (GET_32BE(buf, ph + PH_TYPE) == PT_NOTE) {
fprintf(stderr, "%s already has a note entry\n",
-   av[1]);
+   av[ai]);
exit(0);
}
ph += ps;
@@ -260,18 +273,18 @@ main(int ac, char **av)
exit(1);
}
if (i < n) {
-   fprintf(stderr, "%s: write truncated\n", av[1]);
+   fprintf(stderr, "%s: write truncated\n", av[ai]);
exit(1);
}
 
exit(0);
 
  notelf:
-   fprintf(stderr, "%s does not appear to be an ELF file\n", av[1]);
+   fprintf(stderr, "%s does not appear to be an ELF file\n", av[ai]);
exit(1);
 
  nospace:
fprintf(stderr, "sorry, I can't find space in %s to put the note\n",
-   av[1]);
+   av[ai]);
exit(1);
 }
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ee0dc41..f390735 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -306,11 +306,14 @@ fi
 
 # post-processing needed for some platforms
 case "$platform" in
-pseries|chrp)
+pseries)
 ${CROSS}objcopy -O binary -j .fakeelf "$kernel" "$ofile".rpanote
 $objbin/addnote "$ofile" "$ofile".rpanote
 rm -r "$ofile".rpanote
 ;;
+chrp)
+$objbin/addnote -r c0 "$ofile"
+;;
 coff)
 ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
 $objbin/hack-coff "$ofile"
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala


On Oct 20, 2008, at 6:37 PM, Benjamin Herrenschmidt wrote:


On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:

Please pull from 'for-2.6.28' branch of

	master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git  
for-2.6.28


to receive the following updates:


Argh, that's not based on my current powerpc, if you needed me to move
fwd, please ask first. It makes it harder for me to properly review  
and

make sure merges are clean if, when I pull josh, grant and your trees,
they don't all nicely base on my current tree.


It wasn't needed, but I've done this with Paul in the past w/o any  
issue.  I'll make sure to poke you in the future if needed.


- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala


On Oct 20, 2008, at 6:29 PM, Benjamin Herrenschmidt wrote:


On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:

Please pull from 'for-2.6.28' branch of

	master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git  
for-2.6.28


It would be nice if you didn't create new branches all the time so I
don't have to change my git remotes config :-)

Anyway, I'll add that one for now.

Cheers,
Ben.


That fine, but its a bit annoying having to deal with this two headed  
PPC maintainership.  Paul had certain things he would do things and  
you have certain ways you'd like to see things.   I understand that,  
but its a tad schizophrenic on a sub-maintainer.


- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v2] Revert to real-base = 12MB on 32-bit CHRP

2008-10-20 Thread Paul Mackerras
Commit 9b09c6d909dfd8de96b99b9b9c808b94b0a71614 ("powerpc: Change the
default link address for pSeries zImage kernels") changed the
real-base value in the CHRP note added by addnote to the zImage from
12MB to 32MB.  It turns out that this causes unnecessary extra reboots
on old 32-bit CHRP machines.  This therefore adds a -r flag to addnote
to allow us to specify what real-base value it should put in the CHRP
note, and adjusts the wrapper script to pass -r c0 to addnote when
making a zImage for a CHRP machine.  Also, CHRP machines ignore the
RPA note, so we don't need to arrange for it to be the same as the
kernel's.

Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
This version fixes a bug in the addnote argument parsing where we were
still checking ac == 3 to see if we had an RPA note file.

diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index dcc9ab2..a43682e 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -11,7 +11,7 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  *
- * Usage: addnote zImage [note.elf]
+ * Usage: addnote [-r realbase] zImage [note.elf]
  *
  * If note.elf is supplied, it is the name of an ELF file that contains
  * an RPA note to use instead of the built-in one.  Alternatively, the
@@ -55,7 +55,7 @@ unsigned int rpanote[N_RPA_DESCR] = {
1,  /* splpar */
-1, /* min_load */
1,  /* new_mem_def */
-   0,  /* ignore_my_client_config */
+   1,  /* ignore_my_client_config */
 };
 
 #define ROUNDUP(len)   (((len) + 3) & ~3)
@@ -153,18 +153,31 @@ unsigned char *read_rpanote(const char *fname, int *nnp)
 int
 main(int ac, char **av)
 {
-   int fd, n, i;
+   int fd, n, i, ai;
int ph, ps, np;
int nnote, nnote2, ns;
unsigned char *rpap;
-
-   if (ac != 2 && ac != 3) {
-   fprintf(stderr, "Usage: %s elf-file [rpanote.elf]\n", av[0]);
+   char *p, *endp;
+
+   ai = 1;
+   if (ac >= ai + 2 && strcmp(av[ai], "-r") == 0) {
+   /* process -r realbase */
+   p = av[ai + 1];
+   descr[1] = strtol(p, &endp, 16);
+   if (endp == p || *endp != 0) {
+   fprintf(stderr, "Can't parse -r argument '%s' as hex\n",
+   p);
+   exit(1);
+   }
+   ai += 2;
+   }
+   if (ac != ai + 1 && ac != ai + 2) {
+   fprintf(stderr, "Usage: %s [-r realbase] elf-file 
[rpanote.elf]\n", av[0]);
exit(1);
}
-   fd = open(av[1], O_RDWR);
+   fd = open(av[ai], O_RDWR);
if (fd < 0) {
-   perror(av[1]);
+   perror(av[ai]);
exit(1);
}
 
@@ -184,12 +197,12 @@ main(int ac, char **av)
if (buf[E_IDENT+EI_CLASS] != ELFCLASS32
|| buf[E_IDENT+EI_DATA] != ELFDATA2MSB) {
fprintf(stderr, "%s is not a big-endian 32-bit ELF image\n",
-   av[1]);
+   av[ai]);
exit(1);
}
 
-   if (ac == 3)
-   rpap = read_rpanote(av[2], &nnote2);
+   if (ac == ai + 2)
+   rpap = read_rpanote(av[ai + 1], &nnote2);
 
ph = GET_32BE(buf, E_PHOFF);
ps = GET_16BE(buf, E_PHENTSIZE);
@@ -202,7 +215,7 @@ main(int ac, char **av)
for (i = 0; i < np; ++i) {
if (GET_32BE(buf, ph + PH_TYPE) == PT_NOTE) {
fprintf(stderr, "%s already has a note entry\n",
-   av[1]);
+   av[ai]);
exit(0);
}
ph += ps;
@@ -260,18 +273,18 @@ main(int ac, char **av)
exit(1);
}
if (i < n) {
-   fprintf(stderr, "%s: write truncated\n", av[1]);
+   fprintf(stderr, "%s: write truncated\n", av[ai]);
exit(1);
}
 
exit(0);
 
  notelf:
-   fprintf(stderr, "%s does not appear to be an ELF file\n", av[1]);
+   fprintf(stderr, "%s does not appear to be an ELF file\n", av[ai]);
exit(1);
 
  nospace:
fprintf(stderr, "sorry, I can't find space in %s to put the note\n",
-   av[1]);
+   av[ai]);
exit(1);
 }
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ee0dc41..f390735 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -306,11 +306,14 @@ fi
 
 # post-processing needed for some platforms
 case "$platform" in
-pseries|chrp)
+pseries)
 ${CROSS}objcopy -O binary -j .fakeelf "$kernel" "$ofile".rpanote
 $objbin/addnote "$ofile" "$ofile".rpanote
 rm -r "$ofile".rpanote
 ;;
+chrp)
+$objbin/addnote -r c0 "$ofile"
+;;
 coff)
 ${CROSS

Re: [PATCH] Format string bug in drivers/of/of_i2c.c

2008-10-20 Thread Jon Smirl
Format string bug.  Not exploitable, as this is only writable by root,
but worth fixing all the same.

See 326f6a5c9c9e1a62aec37bdc0c3f8d53adabe77b

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---
 drivers/of/of_i2c.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index 6a98dc8..24bbef7 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -41,7 +41,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap,

info.addr = *addr;

-   request_module(info.type);
+   request_module("%s", info.type);

result = i2c_new_device(adap, &info);
if (result == NULL) {
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Format string bug in drivers/of/of_i2c.c

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 08:13 -0400, Jon Smirl wrote:
> Format string bug.  Not exploitable, as this is only writable by root,
> but worth fixing all the same.

Where is your signed-off-by ?

Cheers,
Ben.

> See 326f6a5c9c9e1a62aec37bdc0c3f8d53adabe77b
> ---
>  drivers/of/of_i2c.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
> index 6a98dc8..24bbef7 100644
> --- a/drivers/of/of_i2c.c
> +++ b/drivers/of/of_i2c.c
> @@ -41,7 +41,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
>  
>   info.addr = *addr;
>  
> - request_module(info.type);
> + request_module("%s", info.type);
>  
>   result = i2c_new_device(adap, &info);
>   if (result == NULL) {
> 
> ___
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: device tree variations

2008-10-20 Thread David Gibson
On Fri, Oct 17, 2008 at 07:14:05PM -0700, Mike Ditto wrote:
> David Gibson wrote:
> > Deleting the irrelevant parts or picking a device tree to pass to
> > fdt_init() are both reasonable solutions.  libfdt which is included in
> > the bootwrapper has functions for removing unwanted nodes: either
> > fdt_nop_node() or fdt_del_node() will suffice.  There isn't currently
> > a dt_ops hook to call though to those functions though.  You could
> > either add one, or (knowing that your platform always has a flat dt)
> > bypass the dt_ops hooks and call libfdt directly.
> 
> Thanks.  The fdt_del_node approach works pretty nicely.  I added a
> dt_ops hook since fdt is static in libfdt-wrapper.c.
> 
> At first I tried fdt_nop_node, fearing that find_node_by_prop_value()
> and fdt_del_node() would interact badly when deleting in
> mid-traversal,

Ah, yes, it would.

> but it turns out that fdt_nop_node() upsets find_node_by_prop_value()
> anyway.

Oh... it shouldn't, I think that's a bug.  I'll try to look into that
and fix it.

>  Plus, the kernel prints harmless but strange messages when
> there are NOPs in the tree.

We should probably fix that too.

>  So I use fdt_del_node() and rescan from
> the top each time I delete a node and it works fine.

Kind of ugly, but ok.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 14/16 v2] powerpc: expand vs demux ipi actions per message

2008-10-20 Thread Milton Miller
With the new generic smp call function helpers, I noticed the code in
smp_message_recv was a single function call in many cases.  While
getting the message number from the ipi data is easy, we can reduce
the path length by a function and data dependent switch by registering
separate ipi actions for these simple calls.

Originally I left the ipi action array exposed, but then I realized the
registration code should be common too.

The three users each had their own name array, so I made a fourth
to convert all users to use a common one.

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
---
v2: fix arg reversal noted by Geert Uytterhoeven.   This order is most
similar to request_irq and message in data field, but without casting.

Perhaps we should make the common code look like an ipi action handler
and remove this last call?  Currently we still have to allocate a stack
frame to load the return value.

Index: next.git/arch/powerpc/include/asm/smp.h
===
--- next.git.orig/arch/powerpc/include/asm/smp.h2008-10-05 
00:08:36.0 -0500
+++ next.git/arch/powerpc/include/asm/smp.h 2008-10-05 00:16:34.0 
-0500
@@ -81,6 +81,13 @@ extern int cpu_to_core_id(int cpu);
 #define PPC_MSG_CALL_FUNC_SINGLE   2
 #define PPC_MSG_DEBUGGER_BREAK  3
 
+/*
+ * irq controllers that have dedicated ipis per message and don't
+ * need additional code in the action handler may use this
+ */
+extern int smp_request_message_ipi(int virq, int message);
+extern const char *smp_ipi_name[];
+
 void smp_init_iSeries(void);
 void smp_init_pSeries(void);
 void smp_init_cell(void);
Index: next.git/arch/powerpc/kernel/smp.c
===
--- next.git.orig/arch/powerpc/kernel/smp.c 2008-10-05 00:08:38.0 
-0500
+++ next.git/arch/powerpc/kernel/smp.c  2008-10-05 00:19:12.0 -0500
@@ -123,6 +123,65 @@ void smp_message_recv(int msg)
}
 }
 
+static irqreturn_t call_function_action(int irq, void *data)
+{
+   generic_smp_call_function_interrupt();
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t reschedule_action(int irq, void *data)
+{
+   /* we just need the return path side effect of checking need_resched */
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t call_function_single_action(int irq, void *data)
+{
+   generic_smp_call_function_single_interrupt();
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t debug_ipi_action(int irq, void *data)
+{
+   smp_message_recv(PPC_MSG_DEBUGGER_BREAK);
+   return IRQ_HANDLED;
+}
+
+static irq_handler_t smp_ipi_action[] = {
+   [PPC_MSG_CALL_FUNCTION] =  call_function_action,
+   [PPC_MSG_RESCHEDULE] = reschedule_action,
+   [PPC_MSG_CALL_FUNC_SINGLE] = call_function_single_action,
+   [PPC_MSG_DEBUGGER_BREAK] = debug_ipi_action,
+};
+
+const char *smp_ipi_name[] = {
+   [PPC_MSG_CALL_FUNCTION] =  "ipi call function",
+   [PPC_MSG_RESCHEDULE] = "ipi reschedule",
+   [PPC_MSG_CALL_FUNC_SINGLE] = "ipi call function single",
+   [PPC_MSG_DEBUGGER_BREAK] = "ipi debugger",
+};
+
+/* optional function to request ipi, for controllers with >= 4 ipis */
+int smp_request_message_ipi(int virq, int msg)
+{
+   int err;
+
+   if (msg < 0 || msg > PPC_MSG_DEBUGGER_BREAK) {
+   return -EINVAL;
+   }
+#if !defined(CONFIG_DEBUGGER) && !defined(CONFIG_KEXEC)
+   if (msg == PPC_MSG_DEBUGGER_BREAK) {
+   return 1;
+   }
+#endif
+   err = request_irq(virq, smp_ipi_action[msg], IRQF_DISABLED|IRQF_PERCPU,
+ smp_ipi_name[msg], 0);
+   WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n",
+   virq, ipi_names[msg], err);
+
+   return err;
+}
+
 void smp_send_reschedule(int cpu)
 {
if (likely(smp_ops))
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


powerpc: find and destroy possible stale kernel added properties

2008-10-20 Thread Milton Miller
64 bit powerpc requires the kexec user space tools avoid overwriting
the static kernel image and translation hash table when choosing
where to put memory image data because it copies the data into place
using the kernels virtual memory system.  Kexec userspace determines
these and other areas blocked by reading properties the kernel adds,
but does not filter these properties when creating the device tree
for the next kernel.

When the second kernel tries to add its values for these properties,
the export via /proc/device-tree is hidden by the pre-existing but
stale values from the flat tree.  Kexec userspace reads the old
property, allocates the new kernel at the old kernel's end, and
gets rejected by the overlap check.

Search and remove these stale properties before adding the new values.

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
---
X-Patchwork-ID: 19579
tested in July, compile tested on next-20081017

While there is an override flag to tell kexec a minimum memory to use, that
is a crude and manual workaround; this should be applied to stable.


---
diff --git a/arch/powerpc/kernel/machine_kexec_64.c 
b/arch/powerpc/kernel/machine_kexec_64.c
index a168514..4bd8b4f 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -312,11 +312,24 @@ static struct property kernel_end_prop = {
 static void __init export_htab_values(void)
 {
struct device_node *node;
+   struct property *prop;
 
node = of_find_node_by_path("/chosen");
if (!node)
return;
 
+   /* remove any stale propertys so ours can be found */
+   prop = of_find_property(node, kernel_end_prop.name, NULL);
+   if (prop)
+   prom_remove_property(node, prop);
+   prop = of_find_property(node, htab_base_prop.name, NULL);
+   if (prop)
+   prom_remove_property(node, prop);
+   prop = of_find_property(node, htab_size_prop.name, NULL);
+   if (prop)
+   prom_remove_property(node, prop);
+
+   /* information needed by userspace when using default_machine_kexec */
kernel_end = __pa(_end);
prom_add_property(node, &kernel_end_prop);
 

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


powerpc: pseries, cell: use cpu_thread_in_core in smp_init for of_spin_map

2008-10-20 Thread Milton Miller
We used to assume that even numbered threads were the primary
threads, ie those that would be listed and started as a cpu from
open firmware.  Replace a left over is even (% 2) check with a check
for it being a primary thread and update the comments.

Tested with a debug print on pseries, identical code found for cell.

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
---
X-Patchwork-ID: 19578
Resend of July 11 patch, changelog edited.
Patch still applies to next-20081017.

Note: We assume the secondary threads are not spinning, but they are
actually spinning if we start via kexec.  This means that we call rtas to
spin up the secondary threads. If we get a bad return code from we skip
bringing the cpu online, leaving the thread spinning on the paca.  We don't
handle this case in kexec, and will leave the thread wild during another
kexec.  (I'm not changing this behavior in this patch).

---
diff --git a/arch/powerpc/platforms/cell/smp.c 
b/arch/powerpc/platforms/cell/smp.c
index efb3964..c0d86e1 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -54,8 +54,8 @@
 #endif
 
 /*
- * The primary thread of each non-boot processor is recorded here before
- * smp init.
+ * The Primary thread of each non-boot processor was started from the OF client
+ * interface by prom_hold_cpus and is spinning on secondary_hold_spinloop.
  */
 static cpumask_t of_spin_map;
 
@@ -208,11 +208,7 @@ void __init smp_init_cell(void)
/* Mark threads which are still spinning in hold loops. */
if (cpu_has_feature(CPU_FTR_SMT)) {
for_each_present_cpu(i) {
-   if (i % 2 == 0)
-   /*
-* Even-numbered logical cpus correspond to
-* primary threads.
-*/
+   if (cpu_thread_in_core(i) == 0)
cpu_set(i, of_spin_map);
}
} else {
diff --git a/arch/powerpc/platforms/pseries/smp.c 
b/arch/powerpc/platforms/pseries/smp.c
index 9d8f8c8..c9337c7 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -52,8 +52,8 @@
 
 
 /*
- * The primary thread of each non-boot processor is recorded here before
- * smp init.
+ * The Primary thread of each non-boot processor was started from the OF client
+ * interface by prom_hold_cpus and is spinning on secondary_hold_spinloop.
  */
 static cpumask_t of_spin_map;
 
@@ -191,8 +191,7 @@ static void __devinit smp_pSeries_kick_cpu(int nr)
 static int smp_pSeries_cpu_bootable(unsigned int nr)
 {
/* Special case - we inhibit secondary thread startup
-* during boot if the user requests it.  Odd-numbered
-* cpus are assumed to be secondary threads.
+* during boot if the user requests it.
 */
if (system_state < SYSTEM_RUNNING &&
cpu_has_feature(CPU_FTR_SMT) &&
@@ -229,11 +228,7 @@ static void __init smp_init_pseries(void)
/* Mark threads which are still spinning in hold loops. */
if (cpu_has_feature(CPU_FTR_SMT)) {
for_each_present_cpu(i) { 
-   if (i % 2 == 0)
-   /*
-* Even-numbered logical cpus correspond to
-* primary threads.
-*/
+   if (cpu_thread_in_core(i) == 0)
cpu_set(i, of_spin_map);
}
} else {

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


powerpc: add static and ifdef prom_strtoul and prom_memparse

2008-10-20 Thread Milton Miller
These functions should have been static, and inspection shows they
are no longer used.   (We used to parse mem= but now we defer that
to early_param, and move the initrd and move the device tree if
needed).

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
---
X-Patchwork-ID: 19580
Changelog edited, compile tested on next-20081017

Should we just remove them instead?


---
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 1ea8c8d..bf1f922 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -489,6 +489,7 @@ static int __init prom_setprop(phandle node, const char 
*nodename,
return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd);
 }
 
+#if 0
 /* We can't use the standard versions because of RELOC headaches. */
 #define isxdigit(c)(('0' <= (c) && (c) <= '9') \
 || ('a' <= (c) && (c) <= 'f') \
@@ -498,7 +499,7 @@ static int __init prom_setprop(phandle node, const char 
*nodename,
 #define islower(c) ('a' <= (c) && (c) <= 'z')
 #define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c))
 
-unsigned long prom_strtoul(const char *cp, const char **endp)
+static unsigned long prom_strtoul(const char *cp, const char **endp)
 {
unsigned long result = 0, base = 10, value;
 
@@ -523,7 +524,7 @@ unsigned long prom_strtoul(const char *cp, const char 
**endp)
return result;
 }
 
-unsigned long prom_memparse(const char *ptr, const char **retptr)
+static unsigned long prom_memparse(const char *ptr, const char **retptr)
 {
unsigned long ret = prom_strtoul(ptr, retptr);
int shift = 0;
@@ -549,6 +550,7 @@ unsigned long prom_memparse(const char *ptr, const char 
**retptr)
 
return ret;
 }
+#endif
 
 /*
  * Early parsing of the command line passed to the kernel, used for

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


powerpc: always trim to numa memory to lmb_end_of_DRAM

2008-10-20 Thread Milton Miller
numa_enforce_memory_limit tried to be smart and only call lmb_end_of_DRAM
when a memory limit was set via mem= on the command line.  However,
the early boot code will also limit memory added to the lmb system
when iommu=off is specified.  When this happens, the page allocator
is given pages not in the linear mapping and this results in a fatal
data reference to the unmapped page.

Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
--
X-Patchwork-ID: 19577
Changelog edited.  Patch compiled on next-20081017

A previous version of this patch, id 11774, also looked if if iommu=off
was specified, but it was requested that the check just be removed.

http://oldpatchwork.ozlabs.org/linuxppc/patch?id=11774


---
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index cf4bffb..590406c 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -472,12 +472,10 @@ static unsigned long __init 
numa_enforce_memory_limit(unsigned long start,
/*
 * We use lmb_end_of_DRAM() in here instead of memory_limit because
 * we've already adjusted it for the limit and it takes care of
-* having memory holes below the limit.
+* having memory holes below the limit.  Also, in the case of
+* iommu_is_off, memory_limit is not set but is implicitly enforced.
 */
 
-   if (! memory_limit)
-   return size;
-
if (start + size <= lmb_end_of_DRAM())
return size;
 

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[GIT PULL] Please pull spufs merge branch

2008-10-20 Thread Jeremy Kerr
Ben,

Please do a:

git pull \
  git://git.kernel.org/pub/scm/linux/kernel/git/jk/spufs.git merge

For a few more spufs changes for .28

Cheers,


Jeremy

---
diffstat:

 arch/powerpc/platforms/cell/spufs/file.c   |  155 ++
 arch/powerpc/platforms/cell/spufs/run.c|3 
 arch/powerpc/platforms/cell/spufs/sched.c  |   24 +
 arch/powerpc/platforms/cell/spufs/spufs.h  |1 
 arch/powerpc/platforms/cell/spufs/sputrace.c   |   37 ++
 5 files changed, 151 insertions(+), 69 deletions(-)

8 commits:

  powerpc/spufs: sputrace: Only enable logging on open(), prevent
multiple openers
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: sputrace: Don't block until the read buffer is full
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: Use state_mutex for switch_log locking, and prevent
multiple openers
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: Don't require full buffer in switch_log read
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: Don't spu_acquire_saved unnecessarily in regs read
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: Use kmalloc rather than kzalloc for switch log buffer
Jeremy Kerr <[EMAIL PROTECTED]>

  powerpc/spufs: Improve search of node for contexts with SPU affinity
Andre Detsch <[EMAIL PROTECTED]>

  powerpc/spufs: Explain conditional decrement of aff_sched_count
Andre Detsch <[EMAIL PROTECTED]>
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


mmc spi bindings

2008-10-20 Thread Jon Smirl
Anton, is your mmc_spi driver (of_mmc_spi.c) going in any time soon?
I've been running it in my local tree for several months.

-- 
Jon Smirl
[EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Kernel Oops when run ifconfig on MPC8360MDS board

2008-10-20 Thread Kim Phillips
On Mon, 20 Oct 2008 15:00:33 -0700
"mike zheng" <[EMAIL PROTECTED]> wrote:

> I have following kernel Oops when I run ifconfig to setup the UEC0 of
> MPC8360MDS board. There is no hardware problem, the UEC0 runs well
> under Uboot.

does this occur on vanilla u-boot and kernel versions?  if so, which
ones, and on what board revision?

> Call backtrace:
> C0126890 C00D59D0 C00D761C C012F400 C0130DD4 C01746B4 C017712C
> C0127770 C004D8B0 C0005ABC  10001214 100023C4 0FEC4E00
> 

might want to turn on verbose debugging while you're at it.

Kim
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] Add the of_find_i2c_device_by_node function.

2008-10-20 Thread Jon Smirl
Add the of_find_i2c_device_by_node function. This allows you to follow
a reference in the device tree to an i2c device node and then locate
the linux device instantiated by the device tree. Example use, an i2s
codec controlled by i2c.

Anton - this version is based off from your patches

Signed-off-by: Jon Smirl <[EMAIL PROTECTED]>
---
 drivers/of/of_i2c.c|   19 +++
 include/linux/of_i2c.h |3 +++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index e1b0ad6..fa65a2b 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -66,4 +66,23 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
 }
 EXPORT_SYMBOL(of_register_i2c_devices);
 
+static int of_dev_node_match(struct device *dev, void *data)
+{
+return dev_archdata_get_node(&dev->archdata) == data;
+}
+
+/* must call put_device() when done with returned i2c_client device */
+struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
+{
+   struct device *dev;
+
+   dev = bus_find_device(&i2c_bus_type, NULL, node,
+of_dev_node_match);
+   if (!dev)
+   return NULL;
+
+   return to_i2c_client(dev);
+}
+EXPORT_SYMBOL(of_find_i2c_device_by_node);
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
index bd2a870..34974b5 100644
--- a/include/linux/of_i2c.h
+++ b/include/linux/of_i2c.h
@@ -17,4 +17,7 @@
 void of_register_i2c_devices(struct i2c_adapter *adap,
 struct device_node *adap_node);
 
+/* must call put_device() when done with returned i2c_client device */
+struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
+
 #endif /* __LINUX_OF_I2C_H */

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:
> Please pull from 'for-2.6.28' branch of
> 
>   master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28
> 
> to receive the following updates:

Ok so I'm not too happy. Kumar, you need to be a little bit more careful
with your git tree. Here are a few things that are causing me problems
at the moment and making me not pull this one. Some of them I already
sent separate emails for but let's put it all together:

 - First, please try to keep a consistent merge branch. Even if it ends
up merging separate branches from you internally.

 - Please use git request-pull or at least provide me with the merge
base in the email if it's not my current master or next HEAD, and since
it makes my life a bit harder too, please try to have your tree based on
mine unless you have some conflicts to sort out.

 - Please spend a bit more time cleaning up the cset subjects and
comments. For example:

"powerpc: remove device_type = "boad_control"

There are a few problems with this one. Not everybody knows what
"device_type" is, it's not obvious that it's a device-tree change, and
you may notice that I've been trying to keep the first character after
the category: uppercase. I would have preferred something like:

powerpc: Remove device_type = "board_control" properties in .dts files

Another one that doesn't pass my criteria is:

OF: SPI: specify chip select active high

I don't like caps, and it's not the generally accepted format. It should
be something like:

of/spi: Provide a way to specify chip select polarity

Nicer heh ?

I almost always rewrite subjects and sometimes fixup descriptions when I
merge patches. Please do so too.

 - Finally, the Kconfig change shouldn't have been in your tree at all,
or at least not without my or paulus ack and prior argeement that it
should be merged that way. No big deal with this obviously correct
patch but where do we put the limit ?

Cheers,
Ben.
   

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 01/35] x86: clean up speedctep-centrino and reduce cpumask_t usage

2008-10-20 Thread Stephen Rothwell
Hi Mike,

Just a first small thing:

On Mon, 20 Oct 2008 10:03:20 -0700 Mike Travis <[EMAIL PROTECTED]> wrote:
>
> 1) The #ifdef CONFIG_HOTPLUG_CPU seems unnecessary these days.
> 2) The loop can simply skip over offline cpus, rather than creating a tmp 
> mask.
> 3) set_mask is set to either a single cpu or all online cpus in a policy.
>Since it's just used for set_cpus_allowed(), any offline cpus in a policy
>don't matter, so we can just use cpumask_of_cpu() or the policy->cpus.
> 
> From: Rusty Russell <[EMAIL PROTECTED]>
> Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
> Signed-off-by: Mike Travis <[EMAIL PROTECTED]>

The From: line should be the first nonempty line in the mail to get the
attribution correct.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgpFMcOVxrbvL.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: Please pull 'next' branch of 4xx tree

2008-10-20 Thread Josh Boyer
On Mon, Oct 20, 2008 at 09:14:02AM -0400, Josh Boyer wrote:
>Hi Ben,
>
>Please pull the 'next' branch of the 4xx tree to pick up what should be
>most of the remaining changes for 2.6.28.  Defconfig updates will come
>after -rc1.
>
>josh
>
>The following changes since commit 6dc6472581f693b5fc95aebedf67b4960fb85cf0:
>  Benjamin Herrenschmidt (1):
>Merge commit 'origin'
>
>are available in the git repository at:
>
>  git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/powerpc-4xx.git next

As we discussed, I added one more commit on top of this.  It's for the
EMAC build break and is the patch that Stephen has been carrying in
linux-next for the past few days.

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] powerpc: Remove Kconfig support for PPC_MERGE

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 13:03 -0500, Kumar Gala wrote:
> There are no users of PPC_MERGE in tree so we can get rid of it.
> It was a hold over from the arch/ppc days.

That's is all good but shouldn't be in your git tree for merge.

Ben.

> Signed-off-by: Kumar Gala <[EMAIL PROTECTED]>
> ---
>  arch/powerpc/Kconfig |3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 9391199..369d93e 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -19,9 +19,6 @@ config WORD_SIZE
>   default 64 if PPC64
>   default 32 if !PPC64
>  
> -config PPC_MERGE
> - def_bool y
> -
>  config ARCH_PHYS_ADDR_T_64BIT
> def_bool PPC64 || PHYS_64BIT
>  

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Enable enhanced functions for 8536 TSEC

2008-10-20 Thread Benjamin Herrenschmidt
On Thu, 2008-10-16 at 17:31 +0800, Jason Jin wrote:
> Signed-off-by: Jason Jin <[EMAIL PROTECTED]>
> ---
>  arch/powerpc/boot/dts/mpc8536ds.dts |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/boot/dts/mpc8536ds.dts 
> b/arch/powerpc/boot/dts/mpc8536ds.dts
> index 93fdd99..dce2f65 100644
> --- a/arch/powerpc/boot/dts/mpc8536ds.dts
> +++ b/arch/powerpc/boot/dts/mpc8536ds.dts
> @@ -180,7 +180,7 @@
>   enet0: [EMAIL PROTECTED] {
>   cell-index = <0>;
>   device_type = "network";
> - model = "TSEC";
> + model = "eTSEC";
>   compatible = "gianfar";
>   reg = <0x24000 0x1000>;
>   local-mac-address = [ 00 00 00 00 00 00 ];

While this works, this isn't quite "proper" use of the device-tree,
you should instead have something like

compatible="gianfar-eTSEC","gianfar" or something like that

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] ibm_newemac: Fix new MAL feature handling

2008-10-20 Thread Benjamin Herrenschmidt
On Thu, 2008-10-16 at 10:38 -0400, Josh Boyer wrote:
> On Thu, Oct 16, 2008 at 03:56:50PM +1100, Benjamin Herrenschmidt wrote:
> >> drivers/net/ibm_newemac/mal.c: In function 'mal_txeob':
> >> drivers/net/ibm_newemac/mal.c:284: error: implicit declaration of function 
> >> 'mtdcri'
> >> drivers/net/ibm_newemac/mal.c:284: error: 'SDR0' undeclared (first use in 
> >> this function)
> >> drivers/net/ibm_newemac/mal.c:284: error: (Each undeclared identifier is 
> >> reported only once
> >> drivers/net/ibm_newemac/mal.c:284: error: for each function it appears in.)
> >> drivers/net/ibm_newemac/mal.c:285: error: implicit declaration of function 
> >> 'mfdcri'
> >> drivers/net/ibm_newemac/mal.c: In function 'mal_rxeob':
> >> drivers/net/ibm_newemac/mal.c:302: error: 'SDR0' undeclared (first use in 
> >> this function)
> >
> >That's annoying, I'll have a look.
> 
> Support for new features needed by the PPC 405EZ boards
> introduced some errors in the MAL and EMAC feature handling.
> This broke 'allmodconfig' builds as CONFIG_PPC_DCR_NATIVE is
> not set for those.
> 
> This patch fixes these errors by wrapping the code in the
> appropriate #ifdefs.
> 
> Signed-off-by: Josh Boyer <[EMAIL PROTECTED]>

Acked-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
---

Jeff, this breaks build, I'll put it in powerpc.git for a merge today,

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:
> Please pull from 'for-2.6.28' branch of
> 
>   master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28
> 
> to receive the following updates:

Argh, that's not based on my current powerpc, if you needed me to move
fwd, please ask first. It makes it harder for me to properly review and
make sure merges are clean if, when I pull josh, grant and your trees,
they don't all nicely base on my current tree.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 13:04 -0500, Kumar Gala wrote:
> Please pull from 'for-2.6.28' branch of
> 
>   master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28

It would be nice if you didn't create new branches all the time so I
don't have to change my git remotes config :-)

Anyway, I'll add that one for now.

Cheers,
Ben.

> to receive the following updates:
> 
>  Documentation/powerpc/booting-without-of.txt |2 ++
>  Documentation/powerpc/dts-bindings/fsl/board.txt |4 ++--
>  arch/powerpc/Kconfig |3 ---
>  arch/powerpc/boot/dts/mpc832x_mds.dts|2 +-
>  arch/powerpc/boot/dts/mpc834x_mds.dts|2 +-
>  arch/powerpc/boot/dts/mpc836x_mds.dts|2 +-
>  arch/powerpc/boot/dts/mpc8536ds.dts  |   12 ++--
>  arch/powerpc/boot/dts/mpc8568mds.dts |2 +-
>  arch/powerpc/include/asm/page.h  |5 -
>  arch/powerpc/kernel/prom_init_check.sh   |2 +-
>  drivers/i2c/busses/i2c-cpm.c |1 -
>  drivers/of/of_spi.c  |2 ++
>  12 files changed, 21 insertions(+), 18 deletions(-)
> 
> Anton Vorontsov (1):
>   powerpc: remove device_type = "board-control"
> 
> Ed Swarthout (1):
>   powerpc/85xx: Fix mpc8536ds dma interrupt numbers
> 
> Jason Jin (1):
>   powerpc/85xx: Enable enhanced functions for 8536 TSEC
> 
> Kumar Gala (2):
>   powerpc: Fix build issue with CONFIG_RELOCATABLE=y
>   powerpc: Remove Kconfig support for PPC_MERGE
> 
> Wolfgang Ocker (1):
>   OF: SPI: specify chip select active high
> 
> Wolfram Sang (1):
>   i2c-cpm: Suppress autoprobing for devices

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [Fwd: [RFC PATCH 4/5] hvc_console: Add tty window resizing]

2008-10-20 Thread Benjamin Herrenschmidt
On Tue, 2008-10-21 at 10:21 +1100, Benjamin Herrenschmidt wrote:
> Didn't make it to patchwork initially, resending.

Ignore me, it made it and was superseeded...

Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC PATCH 0/5] patches for a network-based hvc backend (s390)

2008-10-20 Thread Benjamin Herrenschmidt
On Tue, 2008-10-14 at 11:12 +0200, Hendrik Brueckner wrote:
> Hello,
> 
> I work on a network-based hvc console backend for s390 that allows
> to get "full-screen" terminal access to z/VM guest machines.
> The solution consists of a HVC backend that provides the terminal interface;
> and a tool to connect to the terminal via a z/VM specific communication
> protocol.

 .../...

Hi !

What's the status with that patch serie ? Is this 2.6.28 material ?
Alan, are you ok with those ? Hendrik, have there been any respin other
than v2 of patch 4/5 ?

I can merge it via powerpc but it's getting late in the merge window...

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[Fwd: [RFC PATCH 4/5] hvc_console: Add tty window resizing]

2008-10-20 Thread Benjamin Herrenschmidt
Didn't make it to patchwork initially, resending.

 Forwarded Message 
From: Hendrik Brueckner <[EMAIL PROTECTED]>
To: Benjamin Herrenschmidt <[EMAIL PROTECTED]>, Linux PPC devel
, Jeremy Fitzhardinge <[EMAIL PROTECTED]>, Rusty
Russell <[EMAIL PROTECTED]>, Ryan S. Arnold <[EMAIL PROTECTED]>
Cc: LKML <[EMAIL PROTECTED]>, Christian Borntraeger
<[EMAIL PROTECTED]>, Heiko Carstens <[EMAIL PROTECTED]>,
Martin Schwidefsky <[EMAIL PROTECTED]>, Hendrik Brueckner
<[EMAIL PROTECTED]>
Subject: [RFC PATCH 4/5] hvc_console: Add tty window resizing
Date:   Tue, 14 Oct 2008 11:12:51 +0200

plain text document attachment (hvc)
From: Hendrik Brueckner <[EMAIL PROTECTED]>

The patch provides the hvc_resize() function to update the terminal
window dimensions (struct winsize) for a specified hvc console.
The function stores the new window size and schedules a function
that finally updates the tty winsize and signals the change to
user space (SIGWINCH).
Because the winsize update must acquire a mutex and might sleep,
the function is scheduled instead of being called from hvc_poll()
or khvcd.

Acked-by: Christian Borntraeger <[EMAIL PROTECTED]>
Signed-off-by: Hendrik Brueckner <[EMAIL PROTECTED]>
---
 drivers/char/hvc_console.c |   61 +
 drivers/char/hvc_console.h |6 
 2 files changed, 67 insertions(+)

--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -494,6 +494,48 @@ static int hvc_write(struct tty_struct *
return written;
 }
 
+/**
+ * hvc_set_winsz() - Resize the hvc tty terminal window.
+ * @work:  work structure.
+ *
+ * The routine shall not be called within an atomic context because it
+ * acquires the tty termios mutex and might sleep.
+ *
+ * Locking:hp->lock, tty->termios_mutex and tty->ctrl_lock
+ */
+static void hvc_set_winsz(struct work_struct *work)
+{
+   struct hvc_struct *hp;
+   struct pid *pgrp;
+   unsigned long hvc_flags;
+   unsigned long ctrl_flags;
+
+   hp = container_of(work, struct hvc_struct, tty_resize);
+   if (!hp || !hp->tty)
+   return;
+
+   mutex_lock(&hp->tty->termios_mutex);
+   spin_lock_irqsave(&hp->lock, hvc_flags);
+
+   if ((hp->ws.ws_row == hp->tty->winsize.ws_row) &&
+   (hp->ws.ws_col == hp->tty->winsize.ws_col))
+   goto out_mutex_unlock;
+
+   spin_lock_irqsave(&hp->tty->ctrl_lock, ctrl_flags);
+   pgrp = get_pid(hp->tty->pgrp);
+   spin_unlock_irqrestore(&hp->tty->ctrl_lock, ctrl_flags);
+
+   if (pgrp)
+   kill_pgrp(pgrp, SIGWINCH, 1);
+   put_pid(pgrp);
+
+   hp->tty->winsize = hp->ws;
+
+out_mutex_unlock:
+   spin_unlock_irqrestore(&hp->lock, hvc_flags);
+   mutex_unlock(&hp->tty->termios_mutex);
+}
+
 /*
  * This is actually a contract between the driver and the tty layer outlining
  * how much write room the driver can guarantee will be sent OR BUFFERED.  This
@@ -638,6 +680,24 @@ int hvc_poll(struct hvc_struct *hp)
 }
 EXPORT_SYMBOL_GPL(hvc_poll);
 
+/**
+ * hvc_resize() - Update terminal window size information.
+ * @hp:HVC console pointer
+ * @ws:Terminal window size structure
+ *
+ * Stores the specified window size information in the hvc structure of @hp.
+ * The function schedule the tty resize update.
+ *
+ * Locking:Locking free; the function MUST be called holding hp->lock
+ */
+void hvc_resize(struct hvc_struct *hp, struct winsize ws)
+{
+   if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) {
+   hp->ws = ws;
+   schedule_work(&hp->tty_resize);
+   }
+}
+
 /*
  * This kthread is either polling or interrupt driven.  This is determined by
  * calling hvc_poll() who determines whether a console adapter support
@@ -720,6 +780,7 @@ struct hvc_struct __devinit *hvc_alloc(u
 
kref_init(&hp->kref);
 
+   INIT_WORK(&hp->tty_resize, hvc_set_winsz);
spin_lock_init(&hp->lock);
spin_lock(&hvc_structs_lock);
 
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -27,6 +27,7 @@
 #ifndef HVC_CONSOLE_H
 #define HVC_CONSOLE_H
 #include 
+#include 
 
 /*
  * This is the max number of console adapters that can/will be found as
@@ -56,6 +57,8 @@ struct hvc_struct {
struct hv_ops *ops;
int irq_requested;
int data;
+   struct winsize ws;
+   struct work_struct tty_resize;
struct list_head next;
struct kref kref; /* ref count & hvc_struct lifetime */
 };
@@ -84,6 +87,9 @@ extern int __devexit hvc_remove(struct h
 int hvc_poll(struct hvc_struct *hp);
 void hvc_kick(void);
 
+/* Resize hvc tty terminal window */
+extern void hvc_resize(struct hvc_struct *hp, struct winsize ws);
+
 /* default notifier for irq based notification */
 extern int notifier_add_irq(struct hvc_struct *hp, int data);
 extern void notifier_del_irq(struct hvc_struct *hp, int data);

-- 
Hendrik Brueckner
D/3303 Linux on System z Deve

Re: [RFC/PATCH] pci: Workaround invalid P2P bridge bus numbers

2008-10-20 Thread Jesse Barnes
On Monday, October 20, 2008 4:06 pm Benjamin Herrenschmidt wrote:
> Some firmware fail to properly configure P2P bridges, leaving them
> with invalid bus numbers. In some cases, this happens on some embedded
> 4xx boards as the result of the kernel allocating different bus space
> than the firmware does to host bridges while not setting
> pcibios_assign_all_busses() for various reasons. In other cases, it can
> just be bogus firmware.
>
> This adds some sanity checking to the PCI probing code. If a bridge is
> found whose primary bus number doesn't match the bus it's sitting on,
> or whose secondary bus number not strictly above it's primary bus
> number, then the bridge bus numbers are deconfigured in the first pass
> of pci_scan_bridge() to be re-assigned in the second pass.
>
> Signed-off-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
> ---
>
> Ayman, can you double check that this variant of the patch still
> fixes your problem ? Thanks !

Sure, seems straightforward enough, I'll wait for Ayman's "Tested-by" before 
pushing.

Thanks,
Jesse
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[Fwd: [PATCH] fix WARN() for PPC]

2008-10-20 Thread Benjamin Herrenschmidt
 Forwarded Message 
From: Arjan van de Ven <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED], Benjamin Herrenschmidt <[EMAIL PROTECTED]>
Subject: [PATCH] fix WARN() for PPC
Date: Mon, 20 Oct 2008 14:50:56 -0700

From: Arjan van de Ven <[EMAIL PROTECTED]>
Date: Mon, 20 Oct 2008 14:41:03 -0700
Subject: [PATCH] fix WARN() for PPC

powerpc doesn't use the generic WARN_ON infrastructure. The newly introduced 
WARN()
as a result didn't print the message, this patch adds the printk for this 
specific case.

Signed-off-by: Arjan van de Ven <[EMAIL PROTECTED]>
---
 include/asm-generic/bug.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 0f6dabd..12c07c1 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -41,7 +41,7 @@ extern void warn_slowpath(const char *file, const int line,
 #define __WARN() warn_on_slowpath(__FILE__, __LINE__)
 #define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg)
 #else
-#define __WARN_printf(arg...) __WARN()
+#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
 #endif
 
 #ifndef WARN_ON
-- 
1.5.5.1




___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC/PATCH] pci: Workaround invalid P2P bridge bus numbers

2008-10-20 Thread Benjamin Herrenschmidt
Some firmware fail to properly configure P2P bridges, leaving them
with invalid bus numbers. In some cases, this happens on some embedded
4xx boards as the result of the kernel allocating different bus space
than the firmware does to host bridges while not setting
pcibios_assign_all_busses() for various reasons. In other cases, it can
just be bogus firmware.

This adds some sanity checking to the PCI probing code. If a bridge is
found whose primary bus number doesn't match the bus it's sitting on,
or whose secondary bus number not strictly above it's primary bus
number, then the bridge bus numbers are deconfigured in the first pass
of pci_scan_bridge() to be re-assigned in the second pass.

Signed-off-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
---

Ayman, can you double check that this variant of the patch still
fixes your problem ? Thanks !

Jesse, if it works for Ayman and you have no objection, can this
still go into 2.6.28 ? The root cause of the problem on PPC 4xx is
a bit more tricky and will be fixed later but I believe that this
added robustness to our code won't harm (and will work around the
problem until I have fixed the root cause).

 drivers/pci/probe.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- linux-work.orig/drivers/pci/probe.c 2008-10-21 09:47:41.0 +1100
+++ linux-work/drivers/pci/probe.c  2008-10-21 09:56:50.0 +1100
@@ -480,19 +480,27 @@ int __devinit pci_scan_bridge(struct pci
int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
u32 buses, i, j = 0;
u16 bctl;
+   int broken = 0;
 
pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
 
dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
buses & 0xff, pass);
 
+   /* Check if setup is sensible at all */
+   if (!pass &&
+   ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= 
bus->number)) {
+   dev_dbg(&dev->dev, "bus configuration invalid, 
reconfiguring\n");
+   broken = 1;
+   }
+
/* Disable MasterAbortMode during probing to avoid reporting
   of bus errors (in some architectures) */ 
pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bctl);
pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
  bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
 
-   if ((buses & 0x00) && !pcibios_assign_all_busses() && !is_cardbus) {
+   if ((buses & 0x00) && !pcibios_assign_all_busses() && !is_cardbus 
&& !broken) {
unsigned int cmax, busnr;
/*
 * Bus already configured by firmware, process it in the first
@@ -530,7 +538,7 @@ int __devinit pci_scan_bridge(struct pci
 * do in the second pass.
 */
if (!pass) {
-   if (pcibios_assign_all_busses())
+   if (pcibios_assign_all_busses() || broken)
/* Temporarily disable forwarding of the
   configuration cycles on all bridges in
   this bus segment to avoid possible
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 0/2] ftrace: fixes for PPC

2008-10-20 Thread Frédéric Weisbecker
2008/10/20 Steven Rostedt <[EMAIL PROTECTED]>:
> I believe MIPS has the same issues as PPC. Doesn't it use a trampoline
> too?

No it doesn't seem to. If I'm not wrong, MIPS uses only the elf
relocation table to relocate
its addresses.

> I want to make the generic code handle trampolines a bit better.

Do you think there could be a generic approach to handles these trampolines?
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 0/2] ftrace: fixes for PPC

2008-10-20 Thread Frédéric Weisbecker
2008/10/20 Josh Boyer <[EMAIL PROTECTED]>:
> That seems like a good plan.  Should we mark dynamic ftrace as X86 only
> in Kconfig for .28 to prevent people from inadvertently setting it?

Hi Josh.

There are other arch that support ftrace as well like sh or sparc64
(I'm currently working on
an implementation for mips).
So the choice would be better between waiting for a fix or disable
dynamic ftrace
on Kconfig only for PowerPC.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: Problems with PCI-E devices not being detected with switch

2008-10-20 Thread Benjamin Herrenschmidt

> The part that didn't look correct is this line (note the operators)
> 
>((buses >> 8) & 0xff) != <= bus->number) {
> 
>Operators ^^ ^^

Ooohhh ... nice typo :-) The right one is <=, thanks for catching this !

> >From reading through the code and your textual description of what was
> supposed to be happening, I went ahead and changed it to ... 
> 
>  ((buses >> 8) & 0xff) !=  bus->number) {
> 
> And this is the code that generated the results from my previous
> message.

Yeah, that's enough to catch most of the problems incuding yours.

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 1/1] powerpc: Update page in counter for CMM

2008-10-20 Thread Brian King

A new field has been added to the VPA as a method for
the client OS to communicate to firmware the number of
page ins it is performing when running collaborative
memory overcommit. The hypervisor will use this information
to better determine if a partition is experiencing memory
pressure and needs more memory allocated to it.

Signed-off-by: Brian King <[EMAIL PROTECTED]>
---

 arch/powerpc/include/asm/lppaca.h |3 ++-
 arch/powerpc/kernel/paca.c|1 +
 arch/powerpc/mm/fault.c   |8 ++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff -puN arch/powerpc/mm/fault.c~powerpc_vrm_mm_pressure 
arch/powerpc/mm/fault.c
--- linux-2.6/arch/powerpc/mm/fault.c~powerpc_vrm_mm_pressure   2008-10-20 
17:13:25.0 -0500
+++ linux-2.6-bjking1/arch/powerpc/mm/fault.c   2008-10-20 17:13:25.0 
-0500
@@ -30,6 +30,8 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -318,9 +320,11 @@ good_area:
goto do_sigbus;
BUG();
}
-   if (ret & VM_FAULT_MAJOR)
+   if (ret & VM_FAULT_MAJOR) {
current->maj_flt++;
-   else
+   if (firmware_has_feature(FW_FEATURE_CMO))
+   atomic_inc((atomic_t *)(&(get_lppaca()->page_ins)));
+   } else
current->min_flt++;
up_read(&mm->mmap_sem);
return 0;
diff -puN arch/powerpc/include/asm/lppaca.h~powerpc_vrm_mm_pressure 
arch/powerpc/include/asm/lppaca.h
--- linux-2.6/arch/powerpc/include/asm/lppaca.h~powerpc_vrm_mm_pressure 
2008-10-20 17:13:25.0 -0500
+++ linux-2.6-bjking1/arch/powerpc/include/asm/lppaca.h 2008-10-20 
17:13:25.0 -0500
@@ -133,7 +133,8 @@ struct lppaca {
 //=
 // CACHE_LINE_4-5 0x0180 - 0x027F Contains PMC interrupt data
 //=
-   u8  pmc_save_area[256]; // PMC interrupt Area   x00-xFF
+   volatile u32 page_ins;  // CMO Hint - # page ins by OS  x00-x04
+   u8  pmc_save_area[252]; // PMC interrupt Area   x04-xFF
 } __attribute__((__aligned__(0x400)));
 
 extern struct lppaca lppaca[];
diff -puN arch/powerpc/kernel/paca.c~powerpc_vrm_mm_pressure 
arch/powerpc/kernel/paca.c
--- linux-2.6/arch/powerpc/kernel/paca.c~powerpc_vrm_mm_pressure
2008-10-20 17:13:25.0 -0500
+++ linux-2.6-bjking1/arch/powerpc/kernel/paca.c2008-10-20 
17:13:25.0 -0500
@@ -37,6 +37,7 @@ struct lppaca lppaca[] = {
.end_of_quantum = 0xul,
.slb_count = 64,
.vmxregs_in_use = 0,
+   .page_ins = 0,
},
 };
 
_
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: Problems with PCI-E devices not being detected with switch

2008-10-20 Thread Ayman El-Khashab
Benjamin Herrenschmidt wrote:

>>> 
>>> +   /* Check if setup is sensible at all */
>>> +   if ((buses & 0xff) != bus->number ||
>>> +   ((buses >> 8) & 0xff) != <= bus->number) {
>> 
>> Note that I removed the <= from the above line -- I did not think it
>> was correct.  Please let me know if that was wrong.
> 
> My logic is that the current setup is incorrect if the primary bus of
> the bridge doesn't match the parent bus number, or if the secondary
> bus number of the bridge is not strictly superior to the parent bus
> number.   
> 
> What sounds incorrect ?
> 

The part that didn't look correct is this line (note the operators)

   ((buses >> 8) & 0xff) != <= bus->number) {

   Operators ^^ ^^

>From reading through the code and your textual description of what was
supposed to be happening, I went ahead and changed it to ... 

 ((buses >> 8) & 0xff) !=  bus->number) {

And this is the code that generated the results from my previous
message.


Hope that made sense ...

Regards,
Ayman
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Kernel Oops when run ifconfig on MPC8360MDS board

2008-10-20 Thread mike zheng
Hi All,

I have following kernel Oops when I run ifconfig to setup the UEC0 of
MPC8360MDS board. There is no hardware problem, the UEC0 runs well
under Uboot.

Any idea on this issue?

Thanks,

Mike


[EMAIL PROTECTED] root]# ifconfig eth0 47.135.148.158
Oops: machine check, sig: 7
NIP: C0126910 XER: 2000 LR: C01268D0 SP: CC10DD80 REGS: cc10dcd0
TRAP: 0200Not tainted
MSR: 00049030 EE: 1 PR: 0 FP: 0 ME: 1 IR/DR: 11
TASK = cc10c000[349] 'ifconfig' Last syscall: 54
last math cc10c000 last altivec 
GPR00:  CC10DD80 CC10C000  1032 CC12D000 C0247264 C04D24C8
GPR08: BA2E8BA3 D110 C01EE55C  4808 100235F8  
GPR16:   1002 1002 9032 CC10DE78  
GPR24: 8914 C000 C01D CC10DDB8 D100 C0586E60 C0269C20 
Call backtrace:
C0126890 C00D59D0 C00D761C C012F400 C0130DD4 C01746B4 C017712C
C0127770 C004D8B0 C0005ABC  10001214 100023C4 0FEC4E00

Bus error
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: Problems with PCI-E devices not being detected with switch

2008-10-20 Thread Benjamin Herrenschmidt
On Mon, 2008-10-20 at 16:03 -0500, Ayman El-Khashab wrote:
> Thank you Ben, I've had success with the patch, details below ...
> 
> Benjamin Herrenschmidt wrote:
> 
> > Can you try this (untested) patch and send me the resulting dmesg log
> > (along with whether it helps). 
> > 
> > Index: linux-work/drivers/pci/probe.c
> > ===
> > --- linux-work.orig/drivers/pci/probe.c 2008-10-18 08:10:25.0
> > +1100 +++ linux-work/drivers/pci/probe.c2008-10-18
> > 08:14:14.0 +1100 @@ -536,19 +536,27 @@
> > int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
> > u32 buses, i, j = 0;
> > u16 bctl;
> > +   int broken = 0;
> > 
> > pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
> > 
> > dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
> > buses & 0xff, pass);
> > 
> > +   /* Check if setup is sensible at all */
> > +   if ((buses & 0xff) != bus->number ||
> > +   ((buses >> 8) & 0xff) != <= bus->number) {
> 
> Note that I removed the <= from the above line -- I did not think it was 
> correct.  Please let me know if that was wrong.

My logic is that the current setup is incorrect if the primary bus of
the bridge doesn't match the parent bus number, or if the secondary bus
number of the bridge is not strictly superior to the parent bus number. 

What sounds incorrect ?

IE, if you have:


PHB ..(A)...RC...(B)..(switch)...(C)

IE, A is bus number of the root PHB, ie, primary bus number of root
complex virtual bridge. B is secondary number of root complex virtual
bridge, as such primary number of the switch. C is secondary number of
the switch (ie, bus where you device will reside). 

I'm checking here that for the switch, PRIMARY == B and SECONDARY > B

(And for the RC additionally that PRIMARY = A and SECONDARY > A)

Which means that this "second" check basically enforces that A <  B < C

> 
> 
> Attached below is the dmesg output, in this case the SIL on the downstream
> switch port was detected correctly.  Advise if there is something else that
> needs to be tried.

There will be yes. The patch works, which confirm my analysis of the
problem. I will probably send this patch upstream as it makes sense to
improve the kernel robustness here, but we also probably need to add
some sort of flag for the default behaviour on 4xx. I see two options
here:

 - We can implement support in pci_4xx to do config space on the whole
range of bus numbers instead of a subset, using the fixmap logic. That
way, we no longer have limitations, we can ignore the bus ranges
specified in the device-tree and just use the existing mechanism to
re-assign all bus numbers.

 - We can add a header quirk in pci_4xx that clears out
PRIMARY/SECONDARY/SUBORDINATE in all P2P bridges other than the Root
Complex to force them to be re-assigned without having to hit the
workaround.

 - We can implement some kind of ppc_pci_flag that trigger
reconfiguration of all busses but _not_ of PHBs (ie would cause
pcibios_assign_all_busses() to be 1 but wouldn't force assign numbers in
pci_32.c for the root busses).
 
I'm not 100% sure what the best approach is at this stage, any opinion ?

Cheers,
Ben.

> Thanks
> Ayman
> 
> Kernel command line: ramdisk_size=65536 root=/dev/ram rw 
> ip=169.254.0.199:169.20
> UIC0 (32 IRQ sources) at DCR 0xc0
> UIC1 (32 IRQ sources) at DCR 0xd0
> UIC2 (32 IRQ sources) at DCR 0xe0
> UIC3 (32 IRQ sources) at DCR 0xf0
> PID hash table entries: 2048 (order: 11, 8192 bytes)
> time_init: decrementer frequency = 800.10 MHz
> time_init: processor frequency   = 800.10 MHz
> clocksource: timebase mult[50] shift[22] registered
> clockevent: decrementer mult[] shift[16] cpu[0]
> Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
> Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
> High memory: 0k
> Memory: 512640k/524288k available (3244k kernel code, 11336k reserved, 124k 
> dat)
> SLUB: Genslabs=10, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
> Calibrating delay loop... 1597.44 BogoMIPS (lpj=3194880)
> Mount-cache hash table entries: 512
> net_namespace: 288 bytes
> NET: Registered protocol family 16
> 256k L2-cache enabled
> PCIE0: Checking link...
> PCIE0: No device detected.
> PCI host bridge /plb/[EMAIL PROTECTED] (primary) ranges:
>  MEM 0x000e..0x000e7fff -> 0x8000
>   IO 0x000f8000..0x000f8000 -> 0x
> 4xx PCI DMA offset set to 0x
> PCIE0: successfully set as endpoint
> PCIE1: Checking link...
> PCIE1: Device detected, waiting for link...
> PCIE1: link is up !
> PCI host bridge /plb/[EMAIL PROTECTED] (primary) ranges:
>  MEM 0x000e8000..0x000e -> 0x8000
>   IO 0x000f8001..0x000f8001 -> 0x
> 4xx PCI DMA offset set to 0x
> PCIE1: successfully set as root-complex
> PCI host bridge /plb/[EMAIL 

RE: Problems with PCI-E devices not being detected with switch

2008-10-20 Thread Ayman El-Khashab
Thank you Ben, I've had success with the patch, details below ...

Benjamin Herrenschmidt wrote:

> Can you try this (untested) patch and send me the resulting dmesg log
> (along with whether it helps). 
> 
> Index: linux-work/drivers/pci/probe.c
> ===
> --- linux-work.orig/drivers/pci/probe.c   2008-10-18 08:10:25.0
> +1100 +++ linux-work/drivers/pci/probe.c  2008-10-18
> 08:14:14.0 +1100 @@ -536,19 +536,27 @@
>   int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
>   u32 buses, i, j = 0;
>   u16 bctl;
> + int broken = 0;
> 
>   pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
> 
>   dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
>   buses & 0xff, pass);
> 
> + /* Check if setup is sensible at all */
> + if ((buses & 0xff) != bus->number ||
> + ((buses >> 8) & 0xff) != <= bus->number) {

Note that I removed the <= from the above line -- I did not think it was 
correct.  Please let me know if that was wrong.



Attached below is the dmesg output, in this case the SIL on the downstream
switch port was detected correctly.  Advise if there is something else that
needs to be tried.

Thanks
Ayman

Kernel command line: ramdisk_size=65536 root=/dev/ram rw ip=169.254.0.199:169.20
UIC0 (32 IRQ sources) at DCR 0xc0
UIC1 (32 IRQ sources) at DCR 0xd0
UIC2 (32 IRQ sources) at DCR 0xe0
UIC3 (32 IRQ sources) at DCR 0xf0
PID hash table entries: 2048 (order: 11, 8192 bytes)
time_init: decrementer frequency = 800.10 MHz
time_init: processor frequency   = 800.10 MHz
clocksource: timebase mult[50] shift[22] registered
clockevent: decrementer mult[] shift[16] cpu[0]
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
High memory: 0k
Memory: 512640k/524288k available (3244k kernel code, 11336k reserved, 124k dat)
SLUB: Genslabs=10, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Calibrating delay loop... 1597.44 BogoMIPS (lpj=3194880)
Mount-cache hash table entries: 512
net_namespace: 288 bytes
NET: Registered protocol family 16
256k L2-cache enabled
PCIE0: Checking link...
PCIE0: No device detected.
PCI host bridge /plb/[EMAIL PROTECTED] (primary) ranges:
 MEM 0x000e..0x000e7fff -> 0x8000
  IO 0x000f8000..0x000f8000 -> 0x
4xx PCI DMA offset set to 0x
PCIE0: successfully set as endpoint
PCIE1: Checking link...
PCIE1: Device detected, waiting for link...
PCIE1: link is up !
PCI host bridge /plb/[EMAIL PROTECTED] (primary) ranges:
 MEM 0x000e8000..0x000e -> 0x8000
  IO 0x000f8001..0x000f8001 -> 0x
4xx PCI DMA offset set to 0x
PCIE1: successfully set as root-complex
PCI host bridge /plb/[EMAIL PROTECTED] (primary) ranges:
 MEM 0x000d8000..0x000d -> 0x8000
  IO 0x000c0800..0x000c0800 -> 0x
4xx PCI DMA offset set to 0x
PCI: Probing PCI hardware
PCI: Scanning bus :40
pci :40:00.0: found [eee0/fed0] class 000b20 header type 00
PCI: :40:00.0 reg 10 64bit mmio: [0, 1ff]
PCI: Hiding 4xx host bridge resources :40:00.0
PCI: Fixups for bus :40
PCI: Bus scan for :40 returning with max=40
PCI: Scanning bus 0001:80
pci 0001:80:00.0: found [aaa1/bed1] class 000604 header type 01
PCI: 0001:80:00.0 reg 10 32bit mmio: [0, 7fff]
PCI: Hiding 4xx host bridge resources 0001:80:00.0
PCI: Fixups for bus 0001:80
pci 0001:80:00.0: scanning behind bridge, config bf8180, pass 0
pci 0001:80:00.0: bus configuration doesn't match, reconfiguring
pci 0001:80:00.0: scanning behind bridge, config 00, pass 1
pci 0001:80:00.0: bus configuration doesn't match, reconfiguring
PCI: Scanning bus 0001:81
pci 0001:81:00.0: found [10b5/8509] class 000604 header type 01
PCI: 0001:81:00.0 reg 10 32bit mmio: [b800, b801]
pci 0001:81:00.0: PME# supported from D0 D3hot D3cold
pci 0001:81:00.0: PME# disabled
PCI: Fixups for bus 0001:81
PCI: bridge 0001:80:00.0 io port: [0, fff]
PCI: bridge 0001:80:00.0 32bit mmio: [b800, b81f]
pci 0001:81:00.0: scanning behind bridge, config 060201, pass 0
pci 0001:81:00.0: bus configuration doesn't match, reconfiguring
pci 0001:81:00.0: scanning behind bridge, config 00, pass 1
pci 0001:81:00.0: bus configuration doesn't match, reconfiguring
PCI: Scanning bus 0001:82
pci 0001:82:01.0: found [10b5/8509] class 000604 header type 01
pci 0001:82:01.0: PME# supported from D0 D3hot D3cold
pci 0001:82:01.0: PME# disabled
pci 0001:82:02.0: found [10b5/8509] class 000604 header type 01
pci 0001:82:02.0: PME# supported from D0 D3hot D3cold
pci 0001:82:02.0: PME# disabled
pci 0001:82:03.0: found [10b5/8509] class 000604 header type 01
pci 0001:82:03.0: PME# supported from D0 D3hot D3cold
pci 0001:82:03.0: PME# disabled

Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Anton Vorontsov
On Mon, Oct 20, 2008 at 02:32:21PM -0500, Kumar Gala wrote:
>
> On Oct 20, 2008, at 2:17 PM, Anton Vorontsov wrote:
>
>> Hi Kumar,
>>
>> On Mon, Oct 20, 2008 at 01:04:36PM -0500, Kumar Gala wrote:
>>> Please pull from 'for-2.6.28' branch of
>>>
>>> master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git  
>>> for-2.6.28
>>
>> Could you tell the status of this patch?
>>
>> [1/4] powerpc/QE: implement QE Pin Multiplexing API
>> http://patchwork.ozlabs.org/patch/4897/
>>
>> I reposted it several times (w/o changes), received no comments.
>> If it's ok, could you merge it for 2.6.28?
>
> Sorry, I was thinking this patch required an OF interface change getting 
> accepted... is that true?

Benjamin merged the OF patch, it's in the Linus' tree already.

Thanks,

-- 
Anton Vorontsov
email: [EMAIL PROTECTED]
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala


On Oct 20, 2008, at 2:17 PM, Anton Vorontsov wrote:


Hi Kumar,

On Mon, Oct 20, 2008 at 01:04:36PM -0500, Kumar Gala wrote:

Please pull from 'for-2.6.28' branch of

	master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git  
for-2.6.28


Could you tell the status of this patch?

[1/4] powerpc/QE: implement QE Pin Multiplexing API
http://patchwork.ozlabs.org/patch/4897/

I reposted it several times (w/o changes), received no comments.
If it's ok, could you merge it for 2.6.28?


Sorry, I was thinking this patch required an OF interface change  
getting accepted... is that true?


- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Please pull from 'for-2.6.28' branch

2008-10-20 Thread Anton Vorontsov
Hi Kumar,

On Mon, Oct 20, 2008 at 01:04:36PM -0500, Kumar Gala wrote:
> Please pull from 'for-2.6.28' branch of
> 
>   master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28

Could you tell the status of this patch?

[1/4] powerpc/QE: implement QE Pin Multiplexing API
http://patchwork.ozlabs.org/patch/4897/

I reposted it several times (w/o changes), received no comments.
If it's ok, could you merge it for 2.6.28?

Thanks,

-- 
Anton Vorontsov
email: [EMAIL PROTECTED]
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Please pull from 'for-2.6.28' branch

2008-10-20 Thread Kumar Gala
Please pull from 'for-2.6.28' branch of

master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.28

to receive the following updates:

 Documentation/powerpc/booting-without-of.txt |2 ++
 Documentation/powerpc/dts-bindings/fsl/board.txt |4 ++--
 arch/powerpc/Kconfig |3 ---
 arch/powerpc/boot/dts/mpc832x_mds.dts|2 +-
 arch/powerpc/boot/dts/mpc834x_mds.dts|2 +-
 arch/powerpc/boot/dts/mpc836x_mds.dts|2 +-
 arch/powerpc/boot/dts/mpc8536ds.dts  |   12 ++--
 arch/powerpc/boot/dts/mpc8568mds.dts |2 +-
 arch/powerpc/include/asm/page.h  |5 -
 arch/powerpc/kernel/prom_init_check.sh   |2 +-
 drivers/i2c/busses/i2c-cpm.c |1 -
 drivers/of/of_spi.c  |2 ++
 12 files changed, 21 insertions(+), 18 deletions(-)

Anton Vorontsov (1):
  powerpc: remove device_type = "board-control"

Ed Swarthout (1):
  powerpc/85xx: Fix mpc8536ds dma interrupt numbers

Jason Jin (1):
  powerpc/85xx: Enable enhanced functions for 8536 TSEC

Kumar Gala (2):
  powerpc: Fix build issue with CONFIG_RELOCATABLE=y
  powerpc: Remove Kconfig support for PPC_MERGE

Wolfgang Ocker (1):
  OF: SPI: specify chip select active high

Wolfram Sang (1):
  i2c-cpm: Suppress autoprobing for devices

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] powerpc: Remove Kconfig support for PPC_MERGE

2008-10-20 Thread Kumar Gala
There are no users of PPC_MERGE in tree so we can get rid of it.
It was a hold over from the arch/ppc days.

Signed-off-by: Kumar Gala <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9391199..369d93e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -19,9 +19,6 @@ config WORD_SIZE
default 64 if PPC64
default 32 if !PPC64
 
-config PPC_MERGE
-   def_bool y
-
 config ARCH_PHYS_ADDR_T_64BIT
def_bool PPC64 || PHYS_64BIT
 
-- 
1.5.5.1

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 0/2] ftrace: fixes for PPC

2008-10-20 Thread Steven Rostedt

On Mon, 20 Oct 2008, Fr?d?ric Weisbecker wrote:

> There are other arch that support ftrace as well like sh or sparc64
> (I'm currently working on
> an implementation for mips).
> So the choice would be better between waiting for a fix or disable
> dynamic ftrace
> on Kconfig only for PowerPC.

Hi Frederic,

I believe MIPS has the same issues as PPC. Doesn't it use a trampoline 
too?  I want to make the generic code handle trampolines a bit better. 
This is one of the problems with developing in x86. It avoids a lot of the 
issues that other archs might have.

-- Steve

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 0/2] ftrace: fixes for PPC

2008-10-20 Thread Steven Rostedt

On Mon, 20 Oct 2008, Josh Boyer wrote:

> On Mon, Oct 20, 2008 at 12:30:33PM -0400, Steven Rostedt wrote:
> >> Anyway, if you want a tester let me know.  It seems 2.6.27.1 should be
> >> fine since FTRACE was disabled, but for .28-rc1 it would be cool if it
> >> worked :).
> >
> >Hi Josh,
> >
> >I've been looking deeper at the code for PPC. I realized that my PPC64 box 
> >that I've been testing on did not use modules. While looking at the module 
> >code it dawned on me the dynamic ftrace needs a bit of work. This is 
> >because the way modules are handled in PPC (and other architectures as 
> >well).  The jmps used by mcount is a 24 bit jump. Since the modules are 
> >loaded farther than 24bits away, a trampoline is needed.
> 
> Ah, indeed.
> 
> >A bit of rework is needed in the ftrace infrastructure to handle the 
> >trampoline. Too much work to go into 28. I'll start working on code that 
> >can hopefully be ready and tested for 29. It's not that major of a change, 
> >but since the merge window for 28 has already been opened, we would like 
> >to get a bit more testing in before we hand it over to Linus.
> 
> That seems like a good plan.  Should we mark dynamic ftrace as X86 only
> in Kconfig for .28 to prevent people from inadvertently setting it?

Well, we probably should disable it for PPC at least. I don't know if 
sparc has the same issue.

David?

-- Steve

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 0/2] ftrace: fixes for PPC

2008-10-20 Thread Josh Boyer
On Mon, Oct 20, 2008 at 12:30:33PM -0400, Steven Rostedt wrote:
>> Anyway, if you want a tester let me know.  It seems 2.6.27.1 should be
>> fine since FTRACE was disabled, but for .28-rc1 it would be cool if it
>> worked :).
>
>Hi Josh,
>
>I've been looking deeper at the code for PPC. I realized that my PPC64 box 
>that I've been testing on did not use modules. While looking at the module 
>code it dawned on me the dynamic ftrace needs a bit of work. This is 
>because the way modules are handled in PPC (and other architectures as 
>well).  The jmps used by mcount is a 24 bit jump. Since the modules are 
>loaded farther than 24bits away, a trampoline is needed.

Ah, indeed.

>A bit of rework is needed in the ftrace infrastructure to handle the 
>trampoline. Too much work to go into 28. I'll start working on code that 
>can hopefully be ready and tested for 29. It's not that major of a change, 
>but since the merge window for 28 has already been opened, we would like 
>to get a bit more testing in before we hand it over to Linus.

That seems like a good plan.  Should we mark dynamic ftrace as X86 only
in Kconfig for .28 to prevent people from inadvertently setting it?

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 17/35] cpumask: make nr_cpu_ids the actual limit on bitmap size

2008-10-20 Thread Mike Travis
nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers;
ie. the variable version of NR_CPUS.

If we use this in *all* the cpu ops it simplifies the API, and will
be possible to allocate cpumasks of the minimal length at runtime.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h  |  110 +--
 include/linux/seq_file.h |2
 include/linux/cpumask.h  |  114 ---
 include/linux/seq_file.h |2 
 lib/cpumask.c|   14 +
 3 files changed, 45 insertions(+), 85 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -3,7 +3,8 @@
 
 /*
  * Cpumasks provide a bitmap suitable for representing the
- * set of CPU's in a system, one bit position per CPU number.
+ * set of CPU's in a system, one bit position per CPU number up to
+ * nr_cpu_ids (<= NR_CPUS).
  *
  * Old-style uses "cpumask_t", but new ops are "struct cpumask *";
  * don't put "struct cpumask"s on the stack.
@@ -20,20 +21,6 @@
  * For details of cpumask_onto(), see bitmap_onto in lib/bitmap.c.
  * For details of cpumask_fold(), see bitmap_fold in lib/bitmap.c.
  *
- * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- * Note: The alternate operations with the suffix "_nr" are used
- *   to limit the range of the loop to nr_cpu_ids instead of
- *   NR_CPUS when NR_CPUS > 64 for performance reasons.
- *   If NR_CPUS is <= 64 then most assembler bitmask
- *   operators execute faster with a constant range, so
- *   the operator will continue to use NR_CPUS.
- *
- *   Another consideration is that nr_cpu_ids is initialized
- *   to NR_CPUS and isn't lowered until the possible cpus are
- *   discovered (including any disabled cpus).  So early uses
- *   will span the entire range of NR_CPUS.
- * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- *
  * The available cpumask operations are:
  *
  * void cpumask_set_cpu(cpu, mask) turn on bit 'cpu' in mask
@@ -55,14 +42,12 @@
  * int cpumask_empty(mask) Is mask empty (no bits sets)?
  * int cpumask_full(mask)  Is mask full (all bits sets)?
  * int cpumask_weight(mask)Hamming weigh - number of set bits
- * int cpumask_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
  *
  * void cpumask_shift_right(dst, src, n) Shift right
  * void cpumask_shift_left(dst, src, n)Shift left
  *
- * int first_cpu(mask) Number lowest set bit, or NR_CPUS
- * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
- * int next_cpu_nr(cpu, mask)  Next cpu past 'cpu', or nr_cpu_ids
+ * int first_cpu(mask) Number lowest set bit, or nr_cpu_ids
+ * int next_cpu(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
  *
  * void cpumask_copy(dmask, smask) dmask = smask
  *
@@ -113,8 +98,7 @@
  * void cpumask_onto(dst, orig, relmap)*dst = orig relative to relmap
  * void cpumask_fold(dst, orig, sz)dst bits = orig bits mod sz
  *
- * for_each_cpu_mask(cpu, mask)for-loop cpu over mask using 
NR_CPUS
- * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
+ * for_each_cpu_mask(cpu, mask)for-loop cpu over mask using 
nr_cpu_ids
  * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
  *
  * int num_online_cpus()   Number of online CPUs
@@ -154,7 +138,7 @@ struct cpumask
 
 static inline ssize_t cpumask_size(void)
 {
-   return BITS_TO_LONGS(NR_CPUS) * sizeof(long);
+   return BITS_TO_LONGS(nr_cpu_ids) * sizeof(long);
 }
 
 /* Deprecated. */
@@ -193,6 +177,9 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpus_fold(dst, orig, sz) \
cpumask_fold(&(dst), &(orig), sz)
 #define cpus_addr(src) ((src).bits)
+#define next_cpu_nr(n, src)next_cpu(n, src)
+#define cpus_weight_nr(cpumask)cpus_weight(cpumask)
+#define for_each_cpu_mask_nr(cpu, mask)for_each_cpu_mask(cpu, mask)
 /* End deprecated region. */
 
 #if NR_CPUS <= BITS_PER_LONG
@@ -223,73 +210,73 @@ static inline int cpumask_test_and_set_c
 
 static inline void cpumask_setall(struct cpumask *dstp)
 {
-   bitmap_fill(dstp->bits, NR_CPUS);
+   bitmap_fill(dstp->bits, nr_cpu_ids);
 }
 
 static inline void cpumask_clear(struct cpumask *dstp)
 {
-   bitmap_zero(dstp->bits, NR_CPUS);
+   bitmap_zero(dstp->bits, nr_cpu_ids);
 }
 
 static inline void cpumask_and(struct cpumask *dstp,
   const struct cpumask *src1p,
   const struct cpumask *src2p)
 {
-   bitmap_and(dstp->bits, src1p->bits, src2p->bits, NR_CPUS);
+   bitmap_and(dstp->bits, src1p->bits, src2p->bits, nr_cpu_ids);
 }
 
 static inline void cpumask_or(st

[PATCH 10/35] cpumask: introduce cpumask_var_t for local cpumask vars

2008-10-20 Thread Mike Travis
We want to move cpumasks off the stack: no local decls, no passing by
copy.  Linus suggested we use the array-or-pointer trick for on-stack
vars; we introduce a new cpumask_var_t for this.

Rather than pick an arbitrary limit, I chose a new config option so
arch maintainers can decide where their threshold is.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   36 
 lib/cpumask.c   |   31 +++
 2 files changed, 67 insertions(+)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -485,6 +485,42 @@ int __next_cpu_nr(int n, const cpumask_t
 #endif /* NR_CPUS > 64 */
 
 /*
+ * cpumask_var_t: struct cpumask for stack usage.
+ *
+ * Oh, the wicked games we play!  In order to make kernel coding a
+ * little more difficult, we typedef cpumask_var_t to an array or a
+ * pointer: doing &mask on an array is a noop, so it still works.
+ *
+ * ie.
+ * cpumask_var_t tmpmask;
+ * if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
+ * return -ENOMEM;
+ *
+ *   ... use 'tmpmask' like a normal struct cpumask * ...
+ *
+ * free_cpumask_var(tmpmask);
+ */
+#ifdef CONFIG_CPUMASK_OFFSTACK
+typedef struct cpumask *cpumask_var_t;
+
+bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
+void free_cpumask_var(cpumask_var_t mask);
+
+#else
+typedef struct cpumask cpumask_var_t[1];
+
+static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
+{
+   return true;
+}
+
+static inline void free_cpumask_var(cpumask_var_t mask)
+{
+}
+
+#endif /* CONFIG_CPUMASK_OFFSTACK */
+
+/*
  * The following particular system cpumasks and operations manage
  * possible, present, active and online cpus.  Each of them is a fixed size
  * bitmap of size NR_CPUS.
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -43,3 +43,34 @@ int __any_online_cpu(const cpumask_t *ma
return cpu;
 }
 EXPORT_SYMBOL(__any_online_cpu);
+
+/* These are not inline because of header tangles. */
+#ifdef CONFIG_CPUMASK_OFFSTACK
+bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
+{
+   if (likely(slab_is_available()))
+   *mask = kmalloc(BITS_TO_LONGS(nr_cpu_ids)*sizeof(long), flags);
+   else {
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
+   printk(KERN_ERR
+   "=> alloc_cpumask_var: kmalloc not available!\n");
+   dump_stack();
+#endif
+   *mask = NULL;
+   }
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
+   if (!*mask) {
+   printk(KERN_ERR "=> alloc_cpumask_var: failed!\n");
+   dump_stack();
+   }
+#endif
+   return *mask != NULL;
+}
+EXPORT_SYMBOL(alloc_cpumask_var);
+
+void free_cpumask_var(cpumask_var_t mask)
+{
+   kfree(mask);
+}
+EXPORT_SYMBOL(free_cpumask_var);
+#endif

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 34/35] cpumask: debug options for cpumasks

2008-10-20 Thread Mike Travis
It's useful to check that no one is accessing > nr_cpumask_bits for
cpumasks.  This also allows you to turn on CONFIG_CPUMASKS_OFFSTACK
even for smaller CONFIG_NR_CPUS.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   23 +--
 lib/Kconfig.debug   |6 ++
 lib/cpumask.c   |3 +++
 3 files changed, 26 insertions(+), 6 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -217,23 +217,34 @@ extern cpumask_t _unused_cpumask_arg_;
 }
 #endif /* CONFIG_NR_CPUS > BITS_PER_LONG */
 
+/* verify cpu argument to cpumask_* operators */
+static inline unsigned int cpumask_check(unsigned int cpu)
+{
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
+   /* This breaks at runtime. */
+   BUG_ON(cpu >= nr_cpumask_bits);
+#endif /* CONFIG_DEBUG_PER_CPU_MAPS */
+   return cpu;
+}
+
 /* cpumask_* operators */
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
 {
-   set_bit(cpu, cpumask_bits(dstp));
+   set_bit(cpumask_check(cpu), cpumask_bits(dstp));
 }
 
 static inline void cpumask_clear_cpu(int cpu, volatile struct cpumask *dstp)
 {
-   clear_bit(cpu, cpumask_bits(dstp));
+   clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
 }
 
 /* No static inline type checking - see Subtlety (1) above. */
-#define cpumask_test_cpu(cpu, cpumask) test_bit((cpu), (cpumask)->bits)
+#define cpumask_test_cpu(cpu, cpumask) \
+   test_bit(cpumask_check(cpu), (cpumask)->bits)
 
 static inline int cpumask_test_and_set_cpu(int cpu, struct cpumask *addr)
 {
-   return test_and_set_bit(cpu, cpumask_bits(addr));
+   return test_and_set_bit(cpumask_check(cpu), cpumask_bits(addr));
 }
 
 static inline void cpumask_setall(struct cpumask *dstp)
@@ -367,8 +378,8 @@ static inline int cpumask_cpuremap(int o
   const struct cpumask *oldp,
   const struct cpumask *newp)
 {
-   return bitmap_bitremap(oldbit, cpumask_bits(oldp), cpumask_bits(newp),
-  nr_cpumask_bits);
+   return bitmap_bitremap(cpumask_check(oldbit), cpumask_bits(oldp),
+   cpumask_bits(newp), nr_cpumask_bits);
 }
 
 static inline void cpumask_remap(struct cpumask *dstp,
--- test-compile.orig/lib/Kconfig.debug
+++ test-compile/lib/Kconfig.debug
@@ -766,6 +766,12 @@ config SYSCTL_SYSCALL_CHECK
  to properly maintain and use. This enables checks that help
  you to keep things correct.
 
+config DEBUG_PER_CPU_MAPS
+   bool "Cpumask debug checks"
+   ---help---
+ Extra debugging for cpumasks.
+ eg. to make sure accesses to cpumasks are < nr_cpu_ids.
+
 source kernel/trace/Kconfig
 
 config PROVIDE_OHCI1394_DMA_INIT
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -11,6 +11,9 @@ EXPORT_SYMBOL(cpumask_first);
 
 int cpumask_next(int n, const cpumask_t *srcp)
 {
+   /* -1 is a legal arg here. */
+   if (n != -1)
+   cpumask_check(n);
return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
 }
 EXPORT_SYMBOL(cpumask_next);

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 33/35] cpumask: reorder header to minimize separate #ifdefs

2008-10-20 Thread Mike Travis
cpumask.h is pretty chaotic.  Now we've replaced most of it, let's
group things together a bit better.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   72 ++--
 1 file changed, 34 insertions(+), 38 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -134,6 +134,8 @@ static inline ssize_t cpumask_size(void)
 }
 
 
+#define cpumask_size() (BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long))
+
 /* Deprecated. */
 typedef struct cpumask cpumask_t;
 extern cpumask_t _unused_cpumask_arg_;
@@ -200,6 +202,22 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpu_mask_all   (*(cpumask_t *)cpu_all_mask)
 /* End deprecated region. */
 
+/* static cpumask initializers */
+#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(CONFIG_NR_CPUS)
+#if CONFIG_NR_CPUS <= BITS_PER_LONG
+#define CPU_BITS_ALL   \
+{  \
+   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
+}
+#else
+#define CPU_BITS_ALL   \
+{  \
+   [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL, \
+   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
+}
+#endif /* CONFIG_NR_CPUS > BITS_PER_LONG */
+
+/* cpumask_* operators */
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
 {
set_bit(cpu, cpumask_bits(dstp));
@@ -414,25 +432,6 @@ static inline const struct cpumask *cpum
return (const struct cpumask *)p;
 }
 
-#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
-
-#if NR_CPUS <= BITS_PER_LONG
-
-#define CPU_BITS_ALL   \
-{  \
-   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
-}
-
-#else
-
-#define CPU_BITS_ALL   \
-{  \
-   [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL, \
-   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
-}
-
-#endif
-
 #define CPU_BITS_NONE  \
 {  \
[0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = 0UL   \
@@ -455,6 +454,13 @@ static inline const struct cpumask *cpum
 #define for_each_cpu_and(cpu, mask, and)   \
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)
 
+#define num_online_cpus()  1
+#define num_possible_cpus()1
+#define num_present_cpus() 1
+#define cpu_online(cpu)((cpu) == 0)
+#define cpu_possible(cpu)  ((cpu) == 0)
+#define cpu_present(cpu)   ((cpu) == 0)
+#define cpu_active(cpu)((cpu) == 0)
 #else /* NR_CPUS > 1 */
 
 int cpumask_first(const cpumask_t *srcp);
@@ -470,7 +476,15 @@ int cpumask_any_but(const struct cpumask
for ((cpu) = -1;\
(cpu) = cpumask_next_and((cpu), (mask), (and)), \
(cpu) < nr_cpumask_bits;)
-#endif
+
+#define num_online_cpus()  cpus_weight(cpu_online_map)
+#define num_possible_cpus()cpus_weight(cpu_possible_map)
+#define num_present_cpus() cpus_weight(cpu_present_map)
+#define cpu_online(cpu)cpu_isset((cpu), cpu_online_map)
+#define cpu_possible(cpu)  cpu_isset((cpu), cpu_possible_map)
+#define cpu_present(cpu)   cpu_isset((cpu), cpu_present_map)
+#define cpu_active(cpu)cpu_isset((cpu), cpu_active_map)
+#endif /* NR_CPUS */
 
 #define cpumask_first_and(mask, and) cpumask_next_and(-1, (mask), (and))
 
@@ -563,24 +577,6 @@ extern const DECLARE_BITMAP(cpu_all_bits
 /* First bits of cpu_bit_bitmap are in fact unset. */
 #define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
 
-#if NR_CPUS > 1
-#define num_online_cpus()  cpus_weight(cpu_online_map)
-#define num_possible_cpus()cpus_weight(cpu_possible_map)
-#define num_present_cpus() cpus_weight(cpu_present_map)
-#define cpu_online(cpu)cpu_isset((cpu), cpu_online_map)
-#define cpu_possible(cpu)  cpu_isset((cpu), cpu_possible_map)
-#define cpu_present(cpu)   cpu_isset((cpu), cpu_present_map)
-#define cpu_active(cpu)cpu_isset((cpu), cpu_active_map)
-#else
-#define num_online_cpus()  1
-#define num_possible_cpus()1
-#define num_present_cpus() 1
-#define cpu_online(cpu)((cpu) == 0)
-#define cpu_possible(cpu)  ((cpu) == 0)
-#define cpu_present(cpu)   ((cpu) == 0)
-#define cpu_active(cpu)((cpu) == 0)
-#endif
-
 /* Wrappers to manipulate otherwise-constant masks. */
 void set_cpu_possible(unsigned int cpu, bool possible);
 void set_c

[PATCH 24/35] cpumask: cpumask_any_but()

2008-10-20 Thread Mike Travis
There's a common case where we want any online cpu except a particular
one.  This creates a helper to do that, otherwise we need a temp var
and cpumask_andnot().

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |3 +++
 lib/cpumask.c   |   10 ++
 2 files changed, 13 insertions(+)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -111,6 +111,7 @@
  *
  * int cpumask_any(mask)   Any cpu in mask
  * int cpumask_any_and(mask1,mask2)Any cpu in both masks
+ * int cpumask_any_but(mask,cpu)   Any cpu in mask except cpu
  *
  * for_each_possible_cpu(cpu)  for-loop cpu over cpu_possible_map
  * for_each_online_cpu(cpu)for-loop cpu over cpu_online_map
@@ -458,6 +459,7 @@ extern cpumask_t cpu_mask_all;
 #define cpumask_first(src) ({ (void)(src); 0; })
 #define cpumask_next(n, src)   ({ (void)(src); 1; })
 #define cpumask_next_and(n, srcp, andp)({ (void)(srcp), (void)(andp); 
1; })
+#define cpumask_any_but(mask, cpu) ({ (void)(mask); (void)(cpu); 0; })
 
 #define for_each_cpu(cpu, mask)\
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
@@ -469,6 +471,7 @@ extern cpumask_t cpu_mask_all;
 int cpumask_first(const cpumask_t *srcp);
 int cpumask_next(int n, const cpumask_t *srcp);
 int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
+int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
 
 #define for_each_cpu(cpu, mask)\
for ((cpu) = -1;\
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -24,6 +24,16 @@ int cpumask_next_and(int n, const cpumas
 }
 EXPORT_SYMBOL(cpumask_next_and);
 
+int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
+{
+   unsigned int i;
+
+   for_each_cpu(i, mask)
+   if (i != cpu)
+   break;
+   return i;
+}
+
 /* These are not inline because of header tangles. */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 31/35] cpumask: switch over to cpu_online/possible/active/present_mask

2008-10-20 Thread Mike Travis
In order to hide the definition of struct cpumask, we need to expose
only pointers.  Plus, it fits the new API far better to have pointers.

This deprecates the old _map versions, and defines them in terms of the
_mask versions.  It also centralizes the definitions (finally!).

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/alpha/kernel/smp.c |5 --
 arch/arm/kernel/smp.c   |   10 
 arch/cris/arch-v32/kernel/smp.c |4 -
 arch/ia64/kernel/smpboot.c  |6 --
 arch/m32r/kernel/smpboot.c  |6 --
 arch/mips/kernel/smp.c  |2 
 arch/parisc/kernel/smp.c|   15 --
 arch/powerpc/kernel/smp.c   |4 -
 arch/s390/kernel/smp.c  |6 --
 arch/sh/kernel/smp.c|6 --
 arch/sparc/kernel/sparc_ksyms.c |2 
 arch/sparc64/kernel/smp.c   |4 -
 arch/um/kernel/smp.c|7 --
 arch/x86/kernel/smpboot.c   |6 --
 arch/x86/mach-voyager/voyager_smp.c |7 --
 include/linux/cpumask.h |   86 +++-
 kernel/cpu.c|   67 
 17 files changed, 67 insertions(+), 176 deletions(-)

--- linux-2.6.28.orig/arch/alpha/kernel/smp.c
+++ linux-2.6.28/arch/alpha/kernel/smp.c
@@ -69,11 +69,6 @@ enum ipi_message_type {
 /* Set to a secondary's cpuid when it comes online.  */
 static int smp_secondary_alive __devinitdata = 0;
 
-/* Which cpus ids came online.  */
-cpumask_t cpu_online_map;
-
-EXPORT_SYMBOL(cpu_online_map);
-
 int smp_num_probed;/* Internal processor count */
 int smp_num_cpus = 1;  /* Number that came online.  */
 EXPORT_SYMBOL(smp_num_cpus);
--- linux-2.6.28.orig/arch/arm/kernel/smp.c
+++ linux-2.6.28/arch/arm/kernel/smp.c
@@ -34,16 +34,6 @@
 #include 
 
 /*
- * bitmask of present and online CPUs.
- * The present bitmask indicates that the CPU is physically present.
- * The online bitmask indicates that the CPU is up and running.
- */
-cpumask_t cpu_possible_map;
-EXPORT_SYMBOL(cpu_possible_map);
-cpumask_t cpu_online_map;
-EXPORT_SYMBOL(cpu_online_map);
-
-/*
  * as from 2.5, kernels no longer have an init_tasks structure
  * so we need some other way of telling a new secondary core
  * where to place its SVC stack
--- linux-2.6.28.orig/arch/cris/arch-v32/kernel/smp.c
+++ linux-2.6.28/arch/cris/arch-v32/kernel/smp.c
@@ -29,11 +29,7 @@
 spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] = 
SPIN_LOCK_UNLOCKED};
 
 /* CPU masks */
-cpumask_t cpu_online_map = CPU_MASK_NONE;
-EXPORT_SYMBOL(cpu_online_map);
 cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
-cpumask_t cpu_possible_map;
-EXPORT_SYMBOL(cpu_possible_map);
 EXPORT_SYMBOL(phys_cpu_present_map);
 
 /* Variables used during SMP boot */
--- linux-2.6.28.orig/arch/ia64/kernel/smpboot.c
+++ linux-2.6.28/arch/ia64/kernel/smpboot.c
@@ -131,12 +131,6 @@ struct task_struct *task_for_booting_cpu
  */
 DEFINE_PER_CPU(int, cpu_state);
 
-/* Bitmasks of currently online, and possible CPUs */
-cpumask_t cpu_online_map;
-EXPORT_SYMBOL(cpu_online_map);
-cpumask_t cpu_possible_map = CPU_MASK_NONE;
-EXPORT_SYMBOL(cpu_possible_map);
-
 cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
 EXPORT_SYMBOL(cpu_core_map);
 DEFINE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
--- linux-2.6.28.orig/arch/m32r/kernel/smpboot.c
+++ linux-2.6.28/arch/m32r/kernel/smpboot.c
@@ -72,17 +72,11 @@ static unsigned int bsp_phys_id = -1;
 /* Bitmask of physically existing CPUs */
 physid_mask_t phys_cpu_present_map;
 
-/* Bitmask of currently online CPUs */
-cpumask_t cpu_online_map;
-EXPORT_SYMBOL(cpu_online_map);
-
 cpumask_t cpu_bootout_map;
 cpumask_t cpu_bootin_map;
 static cpumask_t cpu_callin_map;
 cpumask_t cpu_callout_map;
 EXPORT_SYMBOL(cpu_callout_map);
-cpumask_t cpu_possible_map = CPU_MASK_ALL;
-EXPORT_SYMBOL(cpu_possible_map);
 
 /* Per CPU bogomips and other parameters */
 struct cpuinfo_m32r cpu_data[NR_CPUS] __cacheline_aligned;
--- linux-2.6.28.orig/arch/mips/kernel/smp.c
+++ linux-2.6.28/arch/mips/kernel/smp.c
@@ -46,12 +46,10 @@
 
 cpumask_t phys_cpu_present_map;/* Bitmask of available CPUs */
 volatile cpumask_t cpu_callin_map; /* Bitmask of started secondaries */
-cpumask_t cpu_online_map;  /* Bitmask of currently online CPUs */
 int __cpu_number_map[NR_CPUS]; /* Map physical to logical */
 int __cpu_logical_map[NR_CPUS];/* Map logical to physical */
 
 EXPORT_SYMBOL(phys_cpu_present_map);
-EXPORT_SYMBOL(cpu_online_map);
 
 extern void cpu_idle(void);
 
--- linux-2.6.28.orig/arch/parisc/kernel/smp.c
+++ linux-2.6.28/arch/parisc/kernel/smp.c
@@ -67,21 +67,6 @@ static volatile int cpu_now_booting __re
 
 static int parisc_max_cpus __read_mostly = 1;
 
-/* online cpus are ones that we've managed to bring up completely
- * possible cpus are all vali

[PATCH 22/35] cpumask: cpumask_first/cpumask_next

2008-10-20 Thread Mike Travis
Pointer-taking variants of first_cpu/next_cpu.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   18 +-
 lib/cpumask.c   |   10 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -46,8 +46,8 @@
  * void cpumask_shift_right(dst, src, n) Shift right
  * void cpumask_shift_left(dst, src, n)Shift left
  *
- * int first_cpu(mask) Number lowest set bit or nr_cpumask_bits
- * int next_cpu(cpu, mask) Next cpu past 'cpu', or nr_cpumask_bits
+ * int cpumask_first(mask) Number lowest set bit or nr_cpumask_bits
+ * int cpumask_next(cpu, mask) Next cpu past 'cpu', or nr_cpumask_bits
  *
  * void cpumask_copy(dmask, smask) dmask = smask
  *
@@ -200,6 +200,8 @@ extern cpumask_t _unused_cpumask_arg_;
 #define for_each_cpu_mask(cpu, mask)   for_each_cpu(cpu, &(mask))
 #define for_each_cpu_mask_and(cpu, mask, and)  \
for_each_cpu_and(cpu, &(mask), &(and))
+#define first_cpu(src) cpumask_first(&(src))
+#define next_cpu(n, src)   cpumask_next((n), &(src))
 /* End deprecated region. */
 
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
@@ -448,8 +450,8 @@ extern cpumask_t cpu_mask_all;
 
 #if NR_CPUS == 1
 
-#define first_cpu(src) ({ (void)(src); 0; })
-#define next_cpu(n, src)   ({ (void)(src); 1; })
+#define cpumask_first(src) ({ (void)(src); 0; })
+#define cpumask_next(n, src)   ({ (void)(src); 1; })
 #define cpumask_next_and(n, srcp, andp)({ (void)(srcp), (void)(andp); 
1; })
 #define any_online_cpu(mask)   0
 
@@ -460,18 +462,16 @@ extern cpumask_t cpu_mask_all;
 
 #else /* NR_CPUS > 1 */
 
-int __first_cpu(const cpumask_t *srcp);
-int __next_cpu(int n, const cpumask_t *srcp);
+int cpumask_first(const cpumask_t *srcp);
+int cpumask_next(int n, const cpumask_t *srcp);
 int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
 int __any_online_cpu(const cpumask_t *mask);
 
-#define first_cpu(src) __first_cpu(&(src))
-#define next_cpu(n, src)   __next_cpu((n), &(src))
 #define any_online_cpu(mask) __any_online_cpu(&(mask))
 
 #define for_each_cpu(cpu, mask)\
for ((cpu) = -1;\
-   (cpu) = __next_cpu((cpu), (mask)),  \
+   (cpu) = cpumask_next((cpu), (mask)),\
(cpu) < nr_cpumask_bits;)
 #define for_each_cpu_and(cpu, mask, and)   \
for ((cpu) = -1;\
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -3,21 +3,21 @@
 #include 
 #include 
 
-int __first_cpu(const cpumask_t *srcp)
+int cpumask_first(const cpumask_t *srcp)
 {
return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits);
 }
-EXPORT_SYMBOL(__first_cpu);
+EXPORT_SYMBOL(cpumask_first);
 
-int __next_cpu(int n, const cpumask_t *srcp)
+int cpumask_next(int n, const cpumask_t *srcp)
 {
return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
 }
-EXPORT_SYMBOL(__next_cpu);
+EXPORT_SYMBOL(cpumask_next);
 
 int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp)
 {
-   while ((n = next_cpu(n, *srcp)) < nr_cpumask_bits)
+   while ((n = cpumask_next(n, srcp)) < nr_cpu_ids)
if (cpumask_test_cpu(n, andp))
break;
return n;

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 32/35] cpumask: cpu_all_mask and cpu_none_mask.

2008-10-20 Thread Mike Travis
Instead of CPU_MASK_ALL_PTR and the SMP-only cpu_mask_all, this makes
cpu_all_mask and cpu_none_mask which are const cpumask pointers which
always exist.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   16 ++--
 init/main.c |7 +--
 kernel/cpu.c|2 ++
 kernel/kmod.c   |2 +-
 kernel/kthread.c|4 ++--
 kernel/sched.c  |2 +-
 6 files changed, 17 insertions(+), 16 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -117,6 +117,7 @@ struct cpumask
 typedef struct cpumask cpumask_t;
 extern cpumask_t _unused_cpumask_arg_;
 
+#define CPU_MASK_ALL_PTR   (cpu_all_mask)
 #define CPU_MASK_ALL   ((cpumask_t){ CPU_BITS_ALL })
 #define CPU_MASK_NONE  ((cpumask_t){ CPU_BITS_NONE })
 #define CPU_MASK_CPU0  ((cpumask_t){ CPU_BITS_CPU0 })
@@ -175,6 +176,7 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpu_online_map (*(cpumask_t *)cpu_online_mask)
 #define cpu_present_map(*(cpumask_t *)cpu_present_mask)
 #define cpu_active_map (*(cpumask_t *)cpu_active_mask)
+#define cpu_mask_all   (*(cpumask_t *)cpu_all_mask)
 /* End deprecated region. */
 
 #if NR_CPUS <= BITS_PER_LONG
@@ -411,8 +413,6 @@ static inline const struct cpumask *cpum
[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
 }
 
-#define CPU_MASK_ALL_PTR   (&CPU_MASK_ALL)
-
 #else
 
 #define CPU_BITS_ALL   \
@@ -421,10 +421,6 @@ static inline const struct cpumask *cpum
[BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
 }
 
-/* cpu_mask_all is in init/main.c */
-extern cpumask_t cpu_mask_all;
-#define CPU_MASK_ALL_PTR   (&cpu_mask_all)
-
 #endif
 
 #define CPU_BITS_NONE  \
@@ -578,6 +574,14 @@ extern const struct cpumask *const cpu_o
 extern const struct cpumask *const cpu_present_mask;
 extern const struct cpumask *const cpu_active_mask;
 
+/* It's common to want to use cpu_all_mask in struct member initializers,
+ * so it has to refer to an address rather than a pointer. */
+extern const DECLARE_BITMAP(cpu_all_bits, CONFIG_NR_CPUS);
+#define cpu_all_mask to_cpumask(cpu_all_bits)
+
+/* First bits of cpu_bit_bitmap are in fact unset. */
+#define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
+
 #if NR_CPUS > 1
 #define num_online_cpus()  cpus_weight(cpu_online_map)
 #define num_possible_cpus()cpus_weight(cpu_possible_map)
--- linux-2.6.28.orig/init/main.c
+++ linux-2.6.28/init/main.c
@@ -367,11 +367,6 @@ static inline void smp_prepare_cpus(unsi
 
 #else
 
-#if NR_CPUS > BITS_PER_LONG
-cpumask_t cpu_mask_all __read_mostly = CPU_MASK_ALL;
-EXPORT_SYMBOL(cpu_mask_all);
-#endif
-
 /* Setup number of possible processor ids */
 /* nr_cpumask_bits is a real variable for large NR_CPUS. */
 #ifndef nr_cpumask_bits
@@ -869,7 +864,7 @@ static int __init kernel_init(void * unu
/*
 * init can run on any cpu.
 */
-   set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
+   set_cpus_allowed_ptr(current, cpu_all_mask);
/*
 * Tell the world that we're going to be the grim
 * reaper of innocent orphaned children.
--- linux-2.6.28.orig/kernel/cpu.c
+++ linux-2.6.28/kernel/cpu.c
@@ -489,6 +489,8 @@ EXPORT_SYMBOL(cpu_present_mask);
 static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly;
 const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
 EXPORT_SYMBOL(cpu_active_mask);
+const DECLARE_BITMAP(cpu_all_bits, CONFIG_NR_CPUS) = CPU_BITS_ALL;
+EXPORT_SYMBOL(cpu_all_bits);
 
 void set_cpu_possible(unsigned int cpu, bool possible)
 {
--- linux-2.6.28.orig/kernel/kmod.c
+++ linux-2.6.28/kernel/kmod.c
@@ -166,7 +166,7 @@ static int call_usermodehelper(void 
}
 
/* We can run anywhere, unlike our parent keventd(). */
-   set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
+   set_cpus_allowed_ptr(current, cpu_all_mask);
 
/*
 * Our parent is keventd, which runs with elevated scheduling priority.
--- linux-2.6.28.orig/kernel/kthread.c
+++ linux-2.6.28/kernel/kthread.c
@@ -107,7 +107,7 @@ static void create_kthread(struct kthrea
 */
sched_setscheduler(create->result, SCHED_NORMAL, ¶m);
set_user_nice(create->result, KTHREAD_NICE_LEVEL);
-   set_cpus_allowed_ptr(create->result, CPU_MASK_ALL_PTR);
+   set_cpus_allowed_ptr(create->result, cpu_all_mask);
}
complete(&create->done);
 }
@@ -238,7 +238,7 @@ int kthreadd(void *unused)
set_task_comm(tsk, "kthreadd");
ignore_signals(tsk);
set_user_nice(tsk, KTHREAD_NICE_LEVEL);
-   set_cpus_allowed_ptr(tsk, CPU_MASK_ALL_PTR);
+   set_cpus_allowed_ptr(tsk, cpu_all_mask);
 
  

[PATCH 09/35] cpumask: add cpumask_copy()

2008-10-20 Thread Mike Travis
Since cpumasks are to become pointers to undefined structs, we need to
replace assignments.  Also, dynamically allocated ones will eventually
be nr_cpu_ids bits (<= NR_CPUS), so assignment is a definite no-no.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |8 
 1 file changed, 8 insertions(+)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -64,6 +64,8 @@
  * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
  * int next_cpu_nr(cpu, mask)  Next cpu past 'cpu', or nr_cpu_ids
  *
+ * void cpumask_copy(dmask, smask) dmask = smask
+ *
  * size_t cpumask_size()   Length of cpumask in bytes.
  * cpumask_t cpumask_of_cpu(cpu)   Return cpumask with bit 'cpu' set
  * (can be used as an lvalue)
@@ -351,6 +353,12 @@ static inline void cpumask_fold(struct c
bitmap_fold(dstp->bits, origp->bits, sz, NR_CPUS);
 }
 
+static inline void cpumask_copy(struct cpumask *dstp,
+   const struct cpumask *srcp)
+{
+   bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), NR_CPUS);
+}
+
 /*
  * Special-case data structure for "single bit set only" constant CPU masks.
  *

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 13/35] cpumask: use setup_nr_cpu_ids() instead of direct assignment.

2008-10-20 Thread Mike Travis
nr_cpu_ids is going to become a constant under some configs, so don't
assign it.  Currently only x86 seems to anyway.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/x86/kernel/smpboot.c |4 ++--
 include/linux/cpumask.h   |4 
 init/main.c   |4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)

--- linux-2.6.28.orig/arch/x86/kernel/smpboot.c
+++ linux-2.6.28/arch/x86/kernel/smpboot.c
@@ -1079,7 +1079,7 @@ static int __init smp_sanity_check(unsig
nr++;
}
 
-   nr_cpu_ids = 8;
+   setup_nr_cpu_ids();
}
 #endif
 
@@ -1296,7 +1296,7 @@ __init void prefill_possible_map(void)
for (i = 0; i < possible; i++)
cpu_set(i, cpu_possible_map);
 
-   nr_cpu_ids = possible;
+   setup_nr_cpu_ids();
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -144,6 +144,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct cpumask
 {
@@ -636,4 +637,7 @@ extern cpumask_t cpu_active_map;
 #define for_each_online_cpu(cpu)   for_each_cpu_mask_nr((cpu), cpu_online_map)
 #define for_each_present_cpu(cpu)  for_each_cpu_mask_nr((cpu), cpu_present_map)
 
+/* Arch-specific code may call this to initialize nr_cpu_ids based on
+ * the cpu_possible_map. */
+void __init setup_nr_cpu_ids(void);
 #endif /* __LINUX_CPUMASK_H */
--- linux-2.6.28.orig/init/main.c
+++ linux-2.6.28/init/main.c
@@ -362,7 +362,7 @@ static void __init smp_init(void)
 #endif
 
 static inline void setup_per_cpu_areas(void) { }
-static inline void setup_nr_cpu_ids(void) { }
+void __init setup_nr_cpu_ids(void) { }
 static inline void smp_prepare_cpus(unsigned int maxcpus) { }
 
 #else
@@ -377,7 +377,7 @@ int nr_cpu_ids __read_mostly = NR_CPUS;
 EXPORT_SYMBOL(nr_cpu_ids);
 
 /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
-static void __init setup_nr_cpu_ids(void)
+void __init setup_nr_cpu_ids(void)
 {
int cpu, highest_cpu = 0;
 

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 15/35] cpumask: prepare for iterators to only go to nr_cpu_ids.

2008-10-20 Thread Mike Travis
In fact, all cpumask ops will only be valid (in general) for bit
numbers < nr_cpu_ids.  So use that instead of NR_CPUS in various
places.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/alpha/kernel/irq.c   |3 ++-
 arch/alpha/kernel/smp.c   |8 
 arch/arm/kernel/irq.c |2 +-
 arch/cris/kernel/setup.c  |2 +-
 arch/frv/kernel/setup.c   |2 +-
 arch/h8300/kernel/setup.c |2 +-
 arch/ia64/kernel/acpi.c   |2 +-
 arch/ia64/kernel/iosapic.c|4 ++--
 arch/ia64/kernel/irq.c|2 +-
 arch/ia64/kernel/mca.c|6 +++---
 arch/ia64/kernel/perfmon.c|4 ++--
 arch/ia64/kernel/salinfo.c|6 +++---
 arch/ia64/kernel/setup.c  |4 ++--
 arch/ia64/sn/kernel/setup.c   |2 +-
 arch/ia64/sn/kernel/sn2/sn2_smp.c |6 +++---
 arch/ia64/sn/kernel/sn2/sn_hwperf.c   |2 +-
 arch/m32r/kernel/setup.c  |2 +-
 arch/m68knommu/kernel/setup.c |2 +-
 arch/mips/kernel/irq-gic.c|2 +-
 arch/mips/kernel/proc.c   |2 +-
 arch/mips/kernel/smp-cmp.c|2 +-
 arch/mips/kernel/smtc.c   |6 +++---
 arch/mips/sibyte/bcm1480/irq.c|2 +-
 arch/mips/sibyte/bcm1480/smp.c|2 +-
 arch/mips/sibyte/sb1250/smp.c |2 +-
 arch/mn10300/kernel/irq.c |4 ++--
 arch/mn10300/kernel/setup.c   |2 +-
 arch/parisc/kernel/irq.c  |4 ++--
 arch/parisc/kernel/processor.c|4 ++--
 arch/powerpc/include/asm/cputhreads.h |2 +-
 arch/powerpc/kernel/irq.c |2 +-
 arch/powerpc/kernel/machine_kexec_64.c|2 +-
 arch/powerpc/kernel/process.c |2 +-
 arch/powerpc/kernel/setup-common.c|   10 +-
 arch/powerpc/mm/numa.c|4 ++--
 arch/powerpc/platforms/powermac/setup.c   |2 +-
 arch/powerpc/platforms/powermac/smp.c |4 ++--
 arch/powerpc/platforms/pseries/hotplug-cpu.c  |2 +-
 arch/powerpc/platforms/pseries/rtasd.c|2 +-
 arch/powerpc/platforms/pseries/xics.c |2 +-
 arch/powerpc/xmon/xmon.c  |4 ++--
 arch/s390/kernel/smp.c|   10 +-
 arch/sh/kernel/setup.c|2 +-
 arch/sparc/kernel/smp.c   |   11 +--
 arch/sparc/kernel/sun4d_smp.c |9 -
 arch/sparc/kernel/sun4m_smp.c |8 +++-
 arch/sparc/mm/srmmu.c |2 +-
 arch/sparc64/kernel/ds.c  |2 +-
 arch/sparc64/kernel/irq.c |4 ++--
 arch/sparc64/mm/init.c|2 +-
 arch/um/kernel/um_arch.c  |2 +-
 arch/x86/kernel/apic.c|2 +-
 arch/x86/kernel/irq_32.c  |2 +-
 arch/x86/mach-voyager/voyager_smp.c   |2 +-
 arch/x86/mm/numa_64.c |4 ++--
 arch/x86/mm/srat_64.c |2 +-
 drivers/infiniband/hw/ehca/ehca_irq.c |2 +-
 kernel/kexec.c|2 +-
 kernel/smp.c  |2 +-
 net/core/neighbour.c  |4 ++--
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c |4 ++--
 net/ipv4/route.c  |4 ++--
 net/netfilter/nf_conntrack_standalone.c   |4 ++--
 security/selinux/selinuxfs.c  |2 +-
 64 files changed, 108 insertions(+), 111 deletions(-)

--- test-compile.orig/arch/alpha/kernel/irq.c
+++ test-compile/arch/alpha/kernel/irq.c
@@ -50,8 +50,9 @@ int irq_select_affinity(unsigned int irq
if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
return 1;
 
+   /* FIXME: This has an out-by-one error: inc then test! */
while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity))
-   cpu = (c

[PATCH 30/35] cpumask: CONFIG_BITS_ALL, CONFIG_BITS_NONE and CONFIG_BITS_CPU0

2008-10-20 Thread Mike Travis
Since we're now preferring raw bitmaps for (eventually rare) static
cpumasks, we replace CPU_MASK_X with CPU_BITS_X.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   44 
 1 file changed, 24 insertions(+), 20 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -53,8 +53,9 @@
  *
  * size_t cpumask_size()   Length of cpumask in bytes.
  * const struct cpumask *cpumask_of(cpu) Return cpumask with bit 'cpu' set
- * CPU_MASK_ALLInitializer - all bits set
- * CPU_MASK_NONE   Initializer - no bits set
+ * CPU_BITS_ALLInitializer - all bits set
+ * CPU_BITS_NONE   Initializer - no bits set
+ * CPU_BITS_CPU0   Initializer - first bit set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
  *
  * struct cpumask *to_cpumask(const unsigned long[])
@@ -116,6 +117,9 @@ struct cpumask
 typedef struct cpumask cpumask_t;
 extern cpumask_t _unused_cpumask_arg_;
 
+#define CPU_MASK_ALL   ((cpumask_t){ CPU_BITS_ALL })
+#define CPU_MASK_NONE  ((cpumask_t){ CPU_BITS_NONE })
+#define CPU_MASK_CPU0  ((cpumask_t){ CPU_BITS_CPU0 })
 #define cpu_set(cpu, dst) cpumask_set_cpu((cpu), &(dst))
 #define cpu_clear(cpu, dst) cpumask_clear_cpu((cpu), &(dst))
 #define cpu_test_and_set(cpu, mask) cpumask_test_and_set_cpu((cpu), &(mask))
@@ -397,20 +401,20 @@ static inline const struct cpumask *cpum
 
 #if NR_CPUS <= BITS_PER_LONG
 
-#define CPU_MASK_ALL   \
-(cpumask_t) { {
\
-   [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
-} }
+#define CPU_BITS_ALL   \
+{  \
+   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
+}
 
 #define CPU_MASK_ALL_PTR   (&CPU_MASK_ALL)
 
 #else
 
-#define CPU_MASK_ALL   \
-(cpumask_t) { {
\
-   [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,\
-   [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
-} }
+#define CPU_BITS_ALL   \
+{  \
+   [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-2] = ~0UL, \
+   [BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = CPU_MASK_LAST_WORD  \
+}
 
 /* cpu_mask_all is in init/main.c */
 extern cpumask_t cpu_mask_all;
@@ -418,15 +422,15 @@ extern cpumask_t cpu_mask_all;
 
 #endif
 
-#define CPU_MASK_NONE  \
-(cpumask_t) { {
\
-   [0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL \
-} }
-
-#define CPU_MASK_CPU0  \
-(cpumask_t) { {
\
-   [0] =  1UL  \
-} }
+#define CPU_BITS_NONE  \
+{  \
+   [0 ... BITS_TO_LONGS(CONFIG_NR_CPUS)-1] = 0UL   \
+}
+
+#define CPU_BITS_CPU0  \
+{  \
+   [0] =  1UL  \
+}
 
 #if NR_CPUS == 1
 

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 29/35] cpumask: Use accessors code.

2008-10-20 Thread Mike Travis
Use the accessors rather than frobbing bits directly.  Most of this is
in arch code I haven't even compiled, but is straightforward.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/arm/mach-realview/platsmp.c|2 +-
 arch/cris/arch-v32/kernel/smp.c |4 ++--
 arch/ia64/kernel/acpi.c |2 +-
 arch/ia64/kernel/smpboot.c  |   17 +++--
 arch/m32r/kernel/smpboot.c  |2 +-
 arch/mips/kernel/smp-cmp.c  |6 --
 arch/mips/kernel/smp.c  |2 +-
 arch/powerpc/kernel/setup-common.c  |4 ++--
 arch/powerpc/platforms/powermac/setup.c |2 +-
 arch/s390/kernel/smp.c  |5 ++---
 arch/sh/kernel/cpu/sh4a/smp-shx3.c  |5 ++---
 arch/sh/kernel/smp.c|6 +++---
 arch/sparc64/kernel/mdesc.c |2 +-
 arch/sparc64/kernel/prom.c  |4 ++--
 arch/um/kernel/smp.c|2 +-
 arch/x86/kernel/apic.c  |4 ++--
 16 files changed, 33 insertions(+), 36 deletions(-)

--- linux-2.6.28.orig/arch/arm/mach-realview/platsmp.c
+++ linux-2.6.28/arch/arm/mach-realview/platsmp.c
@@ -193,7 +193,7 @@ void __init smp_init_cpus(void)
unsigned int i, ncores = get_core_count();
 
for (i = 0; i < ncores; i++)
-   cpu_set(i, cpu_possible_map);
+   set_cpu_possible(i, true);
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
--- linux-2.6.28.orig/arch/cris/arch-v32/kernel/smp.c
+++ linux-2.6.28/arch/cris/arch-v32/kernel/smp.c
@@ -102,9 +102,9 @@ void __devinit smp_prepare_boot_cpu(void
SUPP_BANK_SEL(2);
SUPP_REG_WR(RW_MM_TLB_PGD, pgd);
 
-   cpu_set(0, cpu_online_map);
+   set_cpu_online(0, true);
cpu_set(0, phys_cpu_present_map);
-   cpu_set(0, cpu_possible_map);
+   set_cpu_possible(0, true);
 }
 
 void __init smp_cpus_done(unsigned int max_cpus)
--- linux-2.6.28.orig/arch/ia64/kernel/acpi.c
+++ linux-2.6.28/arch/ia64/kernel/acpi.c
@@ -845,7 +845,7 @@ __init void prefill_possible_map(void)
possible, max((possible - available_cpus), 0));
 
for (i = 0; i < possible; i++)
-   cpu_set(i, cpu_possible_map);
+   set_cpu_possible(i, true);
 }
 
 int acpi_map_lsapic(acpi_handle handle, int *pcpu)
--- linux-2.6.28.orig/arch/ia64/kernel/smpboot.c
+++ linux-2.6.28/arch/ia64/kernel/smpboot.c
@@ -587,14 +587,14 @@ smp_build_cpu_map (void)
 
ia64_cpu_to_sapicid[0] = boot_cpu_id;
cpus_clear(cpu_present_map);
-   cpu_set(0, cpu_present_map);
-   cpu_set(0, cpu_possible_map);
+   set_cpu_present(0, true);
+   set_cpu_possible(0, true);
for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) {
sapicid = smp_boot_data.cpu_phys_id[i];
if (sapicid == boot_cpu_id)
continue;
-   cpu_set(cpu, cpu_present_map);
-   cpu_set(cpu, cpu_possible_map);
+   set_cpu_present(cpu, true);
+   set_cpu_possible(cpu, true);
ia64_cpu_to_sapicid[cpu] = sapicid;
cpu++;
}
@@ -632,12 +632,9 @@ smp_prepare_cpus (unsigned int max_cpus)
 */
if (!max_cpus) {
printk(KERN_INFO "SMP mode deactivated.\n");
-   cpus_clear(cpu_online_map);
-   cpus_clear(cpu_present_map);
-   cpus_clear(cpu_possible_map);
-   cpu_set(0, cpu_online_map);
-   cpu_set(0, cpu_present_map);
-   cpu_set(0, cpu_possible_map);
+   init_cpu_online(cpumask_of(0));
+   init_cpu_present(cpumask_of(0));
+   init_cpu_possible(cpumask_of(0));
return;
}
 }
--- linux-2.6.28.orig/arch/m32r/kernel/smpboot.c
+++ linux-2.6.28/arch/m32r/kernel/smpboot.c
@@ -183,7 +183,7 @@ void __init smp_prepare_cpus(unsigned in
for (phys_id = 0 ; phys_id < nr_cpu ; phys_id++)
physid_set(phys_id, phys_cpu_present_map);
 #ifndef CONFIG_HOTPLUG_CPU
-   cpu_present_map = cpu_possible_map;
+   init_cpu_present(&cpu_possible_map);
 #endif
 
show_mp_info(nr_cpu);
--- linux-2.6.28.orig/arch/mips/kernel/smp-cmp.c
+++ linux-2.6.28/arch/mips/kernel/smp-cmp.c
@@ -52,8 +52,10 @@ static int __init allowcpus(char *str)
 
cpus_clear(cpu_allow_map);
if (cpulist_parse(str, &cpu_allow_map) == 0) {
-   cpu_set(0, cpu_allow_map);
-   cpus_and(cpu_possible_map, cpu_possible_map, cpu_allow_map);
+   unsigned int i;
+   for (i = 1; i < nr_cpu_ids; i++)
+   if (!cpumask_test_cpu(i, cpu_allow_map))
+   set_cpu_possible(i, false);
len = cpulist_scnprintf(buf, sizeof(buf)-1, &cpu_possible_map);
buf[len] = '

[PATCH 20/35] cpumask: cpumask_of(): cpumask_of_cpu() which returns a pointer.

2008-10-20 Thread Mike Travis
This deprecates cpumask_of_cpu(), which returns a cpumask_t
(cpumask_of() returns a const pointer, instead).

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -52,8 +52,7 @@
  * void cpumask_copy(dmask, smask) dmask = smask
  *
  * size_t cpumask_size()   Length of cpumask in bytes.
- * cpumask_t cpumask_of_cpu(cpu)   Return cpumask with bit 'cpu' set
- * (can be used as an lvalue)
+ * const struct cpumask *cpumask_of(cpu) Return cpumask with bit 'cpu' set
  * CPU_MASK_ALLInitializer - all bits set
  * CPU_MASK_NONE   Initializer - no bits set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
@@ -176,6 +175,7 @@ extern cpumask_t _unused_cpumask_arg_;
 #define next_cpu_nr(n, src)next_cpu(n, src)
 #define cpus_weight_nr(cpumask)cpus_weight(cpumask)
 #define for_each_cpu_mask_nr(cpu, mask)for_each_cpu_mask(cpu, mask)
+#define cpumask_of_cpu(cpu) (*cpumask_of(cpu))
 /* End deprecated region. */
 
 #if NR_CPUS <= BITS_PER_LONG
@@ -382,21 +382,13 @@ static inline void cpumask_copy(struct c
 extern const unsigned long
cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
 
-static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
+static inline const struct cpumask *cpumask_of(unsigned int cpu)
 {
const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
p -= cpu / BITS_PER_LONG;
-   return (const cpumask_t *)p;
+   return (const struct cpumask *)p;
 }
 
-/*
- * In cases where we take the address of the cpumask immediately,
- * gcc optimizes it out (it's a constant) and there's no huge stack
- * variable created:
- */
-#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
-
-
 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
 
 #if NR_CPUS <= BITS_PER_LONG

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 14/35] cpumask: make nr_cpu_ids valid in all configurations.

2008-10-20 Thread Mike Travis
nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers;
ie. the variable version of NR_CPUS.

This makes is valid in all configs, including UP.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   10 --
 init/main.c |7 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -195,6 +195,14 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpus_addr(src) ((src).bits)
 /* End deprecated region. */
 
+#if NR_CPUS <= BITS_PER_LONG
+/* Constant is usually more efficient than a variable for small NR_CPUS */
+#define nr_cpu_ids NR_CPUS
+#else
+/* Starts at NR_CPUS until we know better. */
+extern int nr_cpu_ids;
+#endif /* NR_CPUS > BITS_PER_LONG */
+
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
 {
set_bit(cpu, dstp->bits);
@@ -434,7 +442,6 @@ extern cpumask_t cpu_mask_all;
 
 #if NR_CPUS == 1
 
-#define nr_cpu_ids 1
 #define first_cpu(src) ({ (void)(src); 0; })
 #define next_cpu(n, src)   ({ (void)(src); 1; })
 #define cpumask_next_and(n, srcp, andp)({ (void)(srcp), (void)(andp); 
1; })
@@ -447,7 +454,6 @@ extern cpumask_t cpu_mask_all;
 
 #else /* NR_CPUS > 1 */
 
-extern int nr_cpu_ids;
 int __first_cpu(const cpumask_t *srcp);
 int __next_cpu(int n, const cpumask_t *srcp);
 int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
--- test-compile.orig/init/main.c
+++ test-compile/init/main.c
@@ -373,6 +373,8 @@ EXPORT_SYMBOL(cpu_mask_all);
 #endif
 
 /* Setup number of possible processor ids */
+/* nr_cpu_ids is a real variable for large NR_CPUS. */
+#ifndef nr_cpu_ids
 int nr_cpu_ids __read_mostly = NR_CPUS;
 EXPORT_SYMBOL(nr_cpu_ids);
 
@@ -386,6 +388,11 @@ void __init setup_nr_cpu_ids(void)
 
nr_cpu_ids = highest_cpu + 1;
 }
+#else
+void __init setup_nr_cpu_ids(void)
+{
+}
+#endif /* ... nr_cpu_ids is a constant. */
 
 #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 35/35] cpumask: smp_call_function_many()

2008-10-20 Thread Mike Travis
Transition from cpumask_t-taking smp_call_function_mask() to a new
smp_call_function_many() which takes a struct cpumask *.

(Naming is inspired by smp_call_function_single).

Note that the new one returns void: the old one couldn't fail either
unless there was a logic bug.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/s390/include/asm/smp.h |3 -
 arch/s390/kernel/smp.c  |   30 +++
 include/linux/smp.h |   13 +++-
 kernel/smp.c|   68 +++-
 4 files changed, 64 insertions(+), 50 deletions(-)

--- test-compile.orig/arch/s390/include/asm/smp.h
+++ test-compile/arch/s390/include/asm/smp.h
@@ -90,9 +90,6 @@ extern int __cpu_up (unsigned int cpu);
 
 extern struct mutex smp_cpu_state_mutex;
 extern int smp_cpu_polarization[];
-
-extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
-   void *info, int wait);
 #endif
 
 #ifndef CONFIG_SMP
--- test-compile.orig/arch/s390/kernel/smp.c
+++ test-compile/arch/s390/kernel/smp.c
@@ -103,7 +103,7 @@ static void do_call_function(void)
 }
 
 static void __smp_call_function_map(void (*func) (void *info), void *info,
-   int wait, cpumask_t map)
+   int wait, struct cpumask *map)
 {
struct call_data_struct data;
int cpu, local = 0;
@@ -163,14 +163,16 @@ out:
  * You must not call this function with disabled interrupts, from a
  * hardware interrupt handler or from a bottom half.
  */
+
+/* protected by call_lock */
+static DEFINE_BITMAP(smp_call_map, CONFIG_NR_CPUS);
+
 int smp_call_function(void (*func) (void *info), void *info, int wait)
 {
-   cpumask_t map;
-
spin_lock(&call_lock);
-   map = cpu_online_map;
-   cpu_clear(smp_processor_id(), map);
-   __smp_call_function_map(func, info, wait, map);
+   cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
+   cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
+   __smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
spin_unlock(&call_lock);
return 0;
 }
@@ -192,14 +194,15 @@ int smp_call_function_single(int cpu, vo
 int wait)
 {
spin_lock(&call_lock);
-   __smp_call_function_map(func, info, wait, cpumask_of_cpu(cpu));
+   cpumask_copy(to_cpumask(smp_call_map), cpumask_of(cpu));
+   __smp_call_function_map(func, info, wait, cpumask_of(cpu));
spin_unlock(&call_lock);
return 0;
 }
 EXPORT_SYMBOL(smp_call_function_single);
 
 /**
- * smp_call_function_mask(): Run a function on a set of other CPUs.
+ * smp_call_function_many(): Run a function on a set of other CPUs.
  * @mask: The set of cpus to run on.  Must not include the current cpu.
  * @func: The function to run. This must be fast and non-blocking.
  * @info: An arbitrary pointer to pass to the function.
@@ -213,16 +216,17 @@ EXPORT_SYMBOL(smp_call_function_single);
  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
-  int wait)
+int smp_call_function_many(const struct cpumask *mask,
+  void (*func)(void *), void *info, bool wait)
 {
spin_lock(&call_lock);
-   cpu_clear(smp_processor_id(), mask);
-   __smp_call_function_map(func, info, wait, mask);
+   cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
+   cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
+   __smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
spin_unlock(&call_lock);
return 0;
 }
-EXPORT_SYMBOL(smp_call_function_mask);
+EXPORT_SYMBOL(smp_call_function_many);
 
 void smp_send_stop(void)
 {
--- test-compile.orig/include/linux/smp.h
+++ test-compile/include/linux/smp.h
@@ -62,12 +62,21 @@ extern void smp_cpus_done(unsigned int m
  * Call a function on all other processors
  */
 int smp_call_function(void(*func)(void *info), void *info, int wait);
-int smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
-   int wait);
+void smp_call_function_many(const struct cpumask *mask,
+   void(*func)(void *info), void *info, bool wait);
 int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
int wait);
 void __smp_call_function_single(int cpuid, struct call_single_data *data);
 
+/* Use smp_call_function_many, which takes a pointer to the mask. */
+static inline int __deprecated
+smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
+  int wait)
+{
+   smp_call_function_many(&mask, func, info, wait);
+   return 0;
+}

[PATCH 28/35] cpumask: accessors to manipulate possible/present/online/active maps

2008-10-20 Thread Mike Travis
Since we are moving to const cpumask pointers for the maps, we need a
way to legitimately access them.  Simple accessors work well.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |9 +
 kernel/cpu.c|   42 +-
 2 files changed, 50 insertions(+), 1 deletion(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -604,6 +604,15 @@ extern cpumask_t cpu_active_map;
 #define cpu_active(cpu)((cpu) == 0)
 #endif
 
+/* Wrappers to manipulate otherwise-constant masks. */
+void set_cpu_possible(unsigned int cpu, bool possible);
+void set_cpu_present(unsigned int cpu, bool present);
+void set_cpu_online(unsigned int cpu, bool online);
+void set_cpu_active(unsigned int cpu, bool active);
+void init_cpu_present(const struct cpumask *src);
+void init_cpu_possible(const struct cpumask *src);
+void init_cpu_online(const struct cpumask *src);
+
 #define cpu_is_offline(cpu)unlikely(!cpu_online(cpu))
 
 #define for_each_possible_cpu(cpu) for_each_cpu((cpu), &cpu_possible_map)
--- linux-2.6.28.orig/kernel/cpu.c
+++ linux-2.6.28/kernel/cpu.c
@@ -490,7 +490,6 @@ void notify_cpu_starting(unsigned int cp
 #define MASK_DECLARE_8(x)  MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
 
 const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
-
MASK_DECLARE_8(0),  MASK_DECLARE_8(8),
MASK_DECLARE_8(16), MASK_DECLARE_8(24),
 #if BITS_PER_LONG > 32
@@ -499,3 +498,44 @@ const unsigned long cpu_bit_bitmap[BITS_
 #endif
 };
 EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
+
+void set_cpu_possible(unsigned int cpu, bool possible)
+{
+   if (possible)
+   cpumask_set_cpu(cpu, &cpu_possible_map);
+   else
+   cpumask_clear_cpu(cpu, &cpu_possible_map);
+}
+void set_cpu_present(unsigned int cpu, bool present)
+{
+   if (present)
+   cpumask_set_cpu(cpu, &cpu_present_map);
+   else
+   cpumask_clear_cpu(cpu, &cpu_present_map);
+}
+void set_cpu_online(unsigned int cpu, bool online)
+{
+   if (online)
+   cpumask_set_cpu(cpu, &cpu_online_map);
+   else
+   cpumask_clear_cpu(cpu, &cpu_online_map);
+}
+void set_cpu_active(unsigned int cpu, bool active)
+{
+   if (active)
+   cpumask_set_cpu(cpu, &cpu_active_map);
+   else
+   cpumask_clear_cpu(cpu, &cpu_active_map);
+}
+void init_cpu_present(const struct cpumask *src)
+{
+   cpumask_copy(&cpu_present_map, src);
+}
+void init_cpu_possible(const struct cpumask *src)
+{
+   cpumask_copy(&cpu_possible_map, src);
+}
+void init_cpu_online(const struct cpumask *src)
+{
+   cpumask_copy(&cpu_online_map, src);
+}

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 12/35] cpumask: make CONFIG_NR_CPUS always valid.

2008-10-20 Thread Mike Travis
Currently we have NR_CPUS, which is 1 on UP, and CONFIG_NR_CPUS on
SMP.  If we make CONFIG_NR_CPUS always valid (and always 1 on !SMP),
we can skip the middleman.

This also allows us to find and check all the remaining NR_CPUS users.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/alpha/Kconfig  |   10 +-
 arch/arm/Kconfig|6 +++---
 arch/ia64/Kconfig   |8 
 arch/m32r/Kconfig   |8 
 arch/mips/Kconfig   |4 ++--
 arch/parisc/Kconfig |8 
 arch/s390/Kconfig   |   10 +-
 arch/sh/Kconfig |   10 +-
 arch/sparc/Kconfig  |8 
 arch/sparc64/Kconfig|8 
 arch/um/Kconfig |8 
 arch/x86/Kconfig|   11 +--
 include/linux/threads.h |   10 ++
 13 files changed, 51 insertions(+), 58 deletions(-)

--- test-compile.orig/arch/alpha/Kconfig
+++ test-compile/arch/alpha/Kconfig
@@ -543,11 +543,11 @@ config HAVE_DEC_LOCK
default y
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-32)"
-   range 2 32
-   depends on SMP
-   default "32" if ALPHA_GENERIC || ALPHA_MARVEL
-   default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
+   int "Maximum number of CPUs (2-32)" if SMP
+   range 2 32 if SMP
+   default "1" if !SMP
+   default "32" if SMP && (ALPHA_GENERIC || ALPHA_MARVEL)
+   default "4" if SMP && (!ALPHA_GENERIC && !ALPHA_MARVEL)
help
  MARVEL support can handle a maximum of 32 CPUs, all the others
   with working support have a maximum of 4 CPUs.
--- test-compile.orig/arch/arm/Kconfig
+++ test-compile/arch/arm/Kconfig
@@ -767,9 +767,9 @@ config PAGE_OFFSET
default 0xC000
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-32)"
-   range 2 32
-   depends on SMP
+   int "Maximum number of CPUs (2-32)" if SMP
+   range 2 32 if SMP
+   default "1" if !SMP
default "4"
 
 config HOTPLUG_CPU
--- test-compile.orig/arch/ia64/Kconfig
+++ test-compile/arch/ia64/Kconfig
@@ -313,10 +313,10 @@ config SMP
  If you don't know what to do here, say N.
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-4096)"
-   range 2 4096
-   depends on SMP
-   default "4096"
+   int "Maximum number of CPUs (2-4096)" if SMP
+   range 2 4096 if SMP
+   default "1" if !SMP
+   default "4096" if SMP
help
  You should set this to the number of CPUs in your system, but
  keep in mind that a kernel compiled for, e.g., 2 CPUs will boot but
--- test-compile.orig/arch/m32r/Kconfig
+++ test-compile/arch/m32r/Kconfig
@@ -316,10 +316,10 @@ config CHIP_M32700_TS1
default n
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-32)"
-   range 2 32
-   depends on SMP
-   default "2"
+   int "Maximum number of CPUs (2-32)" if SMP
+   range 2 32 if SMP
+   default "1" if !SMP
+   default "2" if SMP
help
  This allows you to specify the maximum number of CPUs which this
  kernel will support.  The maximum supported value is 32 and the
--- test-compile.orig/arch/mips/Kconfig
+++ test-compile/arch/mips/Kconfig
@@ -1719,9 +1719,9 @@ config NR_CPUS_DEFAULT_64
bool
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-64)"
+   int "Maximum number of CPUs (2-64)" if SMP
range 1 64 if NR_CPUS_DEFAULT_1
-   depends on SMP
+   default "1" if !SMP
default "1" if NR_CPUS_DEFAULT_1
default "2" if NR_CPUS_DEFAULT_2
default "4" if NR_CPUS_DEFAULT_4
--- test-compile.orig/arch/parisc/Kconfig
+++ test-compile/arch/parisc/Kconfig
@@ -251,10 +251,10 @@ config HPUX
depends on !64BIT
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-32)"
-   range 2 32
-   depends on SMP
-   default "32"
+   int "Maximum number of CPUs (2-32)" if SMP
+   range 2 32 if SMP
+   default "1" if !SMP
+   default "32" if SMP
 
 endmenu
 
--- test-compile.orig/arch/s390/Kconfig
+++ test-compile/arch/s390/Kconfig
@@ -113,11 +113,11 @@ config SMP
  Even if you don't know what to do here, say Y.
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-64)"
-   range 2 64
-   depends on SMP
-   default "32" if !64BIT
-   default "64" if 64BIT
+   int "Maximum number of CPUs (2-64)" if SMP
+   range 2 64 if SMP
+   default "1" if !SMP
+   default "32" if SMP && !64BIT
+   default "64" if SMP && 64BIT
help
  This allows you to specify the maximum number of CPUs which this
  kernel will support.  The maximum supported value is 64 and the
--- test-compile.orig/arch/sh/Kconfig
+++ test-compile/arch/sh/Kconfig
@@ -528,11 +528,11 @@ config SMP
  If you don't know what to do here, say N.
 
 config NR_CPUS
-   int "Maximum number of CPUs (2-32)"
- 

[PATCH 07/35] cpumask: change cpumask_scnprintf, cpumask_parse_user, cpulist_parse, and cpulist_scnprintf to take pointers.

2008-10-20 Thread Mike Travis
We want to move cpumasks off the stack: no local decls, no passing by
copy.

Most cpumask functions started with cpus_: these have been replaced by
cpumask_ ones which take struct cpumask pointers as expected, and macro
stubs used for the transition.

These four functions don't have good replacement names; fortunately
they're rarely used, so we just change them over.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/ia64/kernel/topology.c   |2 +-
 arch/mips/kernel/smp-cmp.c|4 ++--
 arch/powerpc/platforms/pseries/xics.c |2 +-
 arch/x86/kernel/cpu/intel_cacheinfo.c |4 ++--
 arch/x86/kernel/setup_percpu.c|2 +-
 drivers/base/cpu.c|2 +-
 drivers/base/node.c   |4 ++--
 drivers/base/topology.c   |4 ++--
 drivers/pci/pci-sysfs.c   |4 ++--
 drivers/pci/probe.c   |4 ++--
 include/linux/cpumask.h   |   21 +++--
 kernel/cpuset.c   |8 
 kernel/irq/proc.c |4 ++--
 kernel/profile.c  |4 ++--
 kernel/sched.c|4 ++--
 kernel/sched_stats.h  |2 +-
 kernel/taskstats.c|2 +-
 kernel/trace/trace.c  |4 ++--
 mm/slub.c |2 +-
 19 files changed, 38 insertions(+), 45 deletions(-)

--- test-compile.orig/arch/ia64/kernel/topology.c
+++ test-compile/arch/ia64/kernel/topology.c
@@ -217,7 +217,7 @@ static ssize_t show_shared_cpu_map(struc
cpumask_t shared_cpu_map;
 
cpus_and(shared_cpu_map, this_leaf->shared_cpu_map, cpu_online_map);
-   len = cpumask_scnprintf(buf, NR_CPUS+1, shared_cpu_map);
+   len = cpumask_scnprintf(buf, NR_CPUS+1, &shared_cpu_map);
len += sprintf(buf+len, "\n");
return len;
 }
--- test-compile.orig/arch/mips/kernel/smp-cmp.c
+++ test-compile/arch/mips/kernel/smp-cmp.c
@@ -51,10 +51,10 @@ static int __init allowcpus(char *str)
int len;
 
cpus_clear(cpu_allow_map);
-   if (cpulist_parse(str, cpu_allow_map) == 0) {
+   if (cpulist_parse(str, &cpu_allow_map) == 0) {
cpu_set(0, cpu_allow_map);
cpus_and(cpu_possible_map, cpu_possible_map, cpu_allow_map);
-   len = cpulist_scnprintf(buf, sizeof(buf)-1, cpu_possible_map);
+   len = cpulist_scnprintf(buf, sizeof(buf)-1, &cpu_possible_map);
buf[len] = '\0';
pr_debug("Allowable CPUs: %s\n", buf);
return 1;
--- test-compile.orig/arch/powerpc/platforms/pseries/xics.c
+++ test-compile/arch/powerpc/platforms/pseries/xics.c
@@ -358,7 +358,7 @@ static void xics_set_affinity(unsigned i
irq_server = get_irq_server(virq, 1);
if (irq_server == -1) {
char cpulist[128];
-   cpumask_scnprintf(cpulist, sizeof(cpulist), cpumask);
+   cpumask_scnprintf(cpulist, sizeof(cpulist), &cpumask);
printk(KERN_WARNING
"%s: No online cpus in the mask %s for irq %d\n",
__func__, cpulist, virq);
--- test-compile.orig/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ test-compile/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -626,8 +626,8 @@ static ssize_t show_shared_cpu_map_func(
cpumask_t *mask = &this_leaf->shared_cpu_map;
 
n = type?
-   cpulist_scnprintf(buf, len-2, *mask):
-   cpumask_scnprintf(buf, len-2, *mask);
+   cpulist_scnprintf(buf, len-2, mask) :
+   cpumask_scnprintf(buf, len-2, mask);
buf[n++] = '\n';
buf[n] = '\0';
}
--- test-compile.orig/arch/x86/kernel/setup_percpu.c
+++ test-compile/arch/x86/kernel/setup_percpu.c
@@ -282,7 +282,7 @@ static void __cpuinit numa_set_cpumask(i
else
cpu_clear(cpu, *mask);
 
-   cpulist_scnprintf(buf, sizeof(buf), *mask);
+   cpulist_scnprintf(buf, sizeof(buf), mask);
printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",
enable? "numa_add_cpu":"numa_remove_cpu", cpu, node, buf);
  }
--- test-compile.orig/drivers/base/cpu.c
+++ test-compile/drivers/base/cpu.c
@@ -109,7 +109,7 @@ static SYSDEV_ATTR(crash_notes, 0400, sh
  */
 static ssize_t print_cpus_map(char *buf, cpumask_t *map)
 {
-   int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
+   int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map);
 
buf[n++] = '\n';
buf[n] = '\0';
--- test-compile.orig/drivers/base/node.c
+++ test-compile/drivers/base/node.c
@@ -29,8 +29,8 @@ static ssize_t node_read_cpumap(struct s
BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
 
len = type?
-   cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
-   

[PATCH 27/35] cpumask: to_cpumask()

2008-10-20 Thread Mike Travis
There are times when we really want a static cpumask.  Yet we don't
want to expose the struct cpumask definition, to avoid casual on-stack
usage and assignment.

So this macro allows you to do DECLARE_BITMAP(map, CONFIG_NR_CPUS); then use
to_cpumask() to turn it into a cpumask as needed.

Ugly?  Yes, but as we move to fewer static cpumasks these calls vanish.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   14 ++
 1 file changed, 14 insertions(+)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -57,6 +57,9 @@
  * CPU_MASK_NONE   Initializer - no bits set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
  *
+ * struct cpumask *to_cpumask(const unsigned long[])
+ * Convert a bitmap to a cpumask.
+ *
  * 
  *
  * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
@@ -362,6 +365,17 @@ static inline void cpumask_copy(struct c
 #define cpumask_any(srcp) cpumask_first(srcp)
 #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
 
+/* Used for static bitmaps of CONFIG_NR_CPUS bits.  Must be a constant to use
+ * as an initializer. */
+#define to_cpumask(bitmap) \
+   ((struct cpumask *)(1 ? (bitmap)\
+   : (void *)sizeof(__check_is_bitmap(bitmap
+
+static inline int __check_is_bitmap(const unsigned long *bitmap)
+{
+   return 1;
+}
+
 /*
  * Special-case data structure for "single bit set only" constant CPU masks.
  *

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 04/35] x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers

2008-10-20 Thread Mike Travis
  * Change genapic interfaces to accept cpumask_t pointers where possible.

  * Modify external callers to use cpumask_t pointers in function calls.

  * Create new send_IPI_mask_allbutself which is the same as the
send_IPI_mask functions but removes smp_processor_id() from list.
This removes another common need for a temporary cpumask_t variable.

  * Functions that used a temp cpumask_t variable for:

cpumask_t allbutme = cpu_online_map;

cpu_clear(smp_processor_id(), allbutme);
if (!cpus_empty(allbutme))
...

become:

if (!cpus_equal(cpu_online_map, cpumask_of_cpu(cpu)))
...

  * Other minor code optimizations (like using cpus_clear instead of
CPU_MASK_NONE, etc.)


Applies to linux-2.6.tip/master.

Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
Acked-by: Rusty Russell <[EMAIL PROTECTED]>
---
 arch/x86/kernel/apic.c   |2 
 arch/x86/kernel/crash.c  |5 -
 arch/x86/kernel/genapic_flat_64.c|   76 +--
 arch/x86/kernel/genx2apic_cluster.c  |   60 ++-
 arch/x86/kernel/genx2apic_phys.c |   54 +-
 arch/x86/kernel/genx2apic_uv_x.c |   43 ++-
 arch/x86/kernel/io_apic.c|  118 ++-
 arch/x86/kernel/ipi.c|   26 --
 arch/x86/kernel/smp.c|8 +-
 arch/x86/kernel/tlb_32.c |2 
 arch/x86/kernel/tlb_64.c |2 
 arch/x86/mach-generic/bigsmp.c   |5 -
 arch/x86/mach-generic/es7000.c   |5 -
 arch/x86/mach-generic/numaq.c|5 -
 arch/x86/mach-generic/summit.c   |5 -
 arch/x86/xen/smp.c   |   17 ++--
 include/asm-x86/bigsmp/apic.h|   14 +--
 include/asm-x86/bigsmp/ipi.h |9 +-
 include/asm-x86/es7000/apic.h|   18 ++--
 include/asm-x86/es7000/ipi.h |9 +-
 include/asm-x86/genapic_32.h |   11 +-
 include/asm-x86/genapic_64.h |   11 +-
 include/asm-x86/ipi.h|   21 -
 include/asm-x86/mach-default/mach_apic.h |   17 ++--
 include/asm-x86/mach-default/mach_ipi.h  |   18 ++--
 include/asm-x86/numaq/apic.h |4 -
 include/asm-x86/numaq/ipi.h  |9 +-
 include/asm-x86/smp.h|6 -
 include/asm-x86/summit/apic.h|   12 +--
 include/asm-x86/summit/ipi.h |9 +-
 30 files changed, 350 insertions(+), 251 deletions(-)

--- linux-2.6.28.orig/arch/x86/kernel/apic.c
+++ linux-2.6.28/arch/x86/kernel/apic.c
@@ -456,7 +456,7 @@ static void lapic_timer_setup(enum clock
 static void lapic_timer_broadcast(cpumask_t mask)
 {
 #ifdef CONFIG_SMP
-   send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
+   send_IPI_mask(&mask, LOCAL_TIMER_VECTOR);
 #endif
 }
 
--- linux-2.6.28.orig/arch/x86/kernel/crash.c
+++ linux-2.6.28/arch/x86/kernel/crash.c
@@ -77,10 +77,7 @@ static int crash_nmi_callback(struct not
 
 static void smp_send_nmi_allbutself(void)
 {
-   cpumask_t mask = cpu_online_map;
-   cpu_clear(safe_smp_processor_id(), mask);
-   if (!cpus_empty(mask))
-   send_IPI_mask(mask, NMI_VECTOR);
+   send_IPI_allbutself(NMI_VECTOR);
 }
 
 static struct notifier_block crash_nmi_nb = {
--- linux-2.6.28.orig/arch/x86/kernel/genapic_flat_64.c
+++ linux-2.6.28/arch/x86/kernel/genapic_flat_64.c
@@ -30,12 +30,12 @@ static int __init flat_acpi_madt_oem_che
return 1;
 }
 
-static cpumask_t flat_target_cpus(void)
+static const cpumask_t *flat_target_cpus(void)
 {
-   return cpu_online_map;
+   return &cpu_online_map;
 }
 
-static cpumask_t flat_vector_allocation_domain(int cpu)
+static void flat_vector_allocation_domain(int cpu, cpumask_t *retmask)
 {
/* Careful. Some cpus do not strictly honor the set of cpus
 * specified in the interrupt destination when using lowest
@@ -45,8 +45,7 @@ static cpumask_t flat_vector_allocation_
 * deliver interrupts to the wrong hyperthread when only one
 * hyperthread was specified in the interrupt desitination.
 */
-   cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
-   return domain;
+   *retmask = (cpumask_t) { {[0] = APIC_ALL_CPUS, } };
 }
 
 /*
@@ -69,9 +68,8 @@ static void flat_init_apic_ldr(void)
apic_write(APIC_LDR, val);
 }
 
-static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
+static inline void _flat_send_IPI_mask(unsigned long mask, int vector)
 {
-   unsigned long mask = cpus_addr(cpumask)[0];
unsigned long flags;
 
local_irq_save(flags);
@@ -79,20 +77,40 @@ static void flat_send_IPI_mask(cpumask_t
local_irq_restore(flags);
 }
 
+static void flat_send_IPI_mask(const cpumask_t *cpumask, int vector)
+{
+   unsigned long mask = cpus_addr(*cpumask)[0];
+
+   _flat_send_IPI_mask(mask, vector);
+}
+
+static void flat_send_

[PATCH 11/35] x86: enable MAXSMP

2008-10-20 Thread Mike Travis
Set MAXSMP to enable a configuration with the maximum amount of CPUS and
NODES.  Also enables CONFIG_CPUMASK_OFFSTACK which moves cpumask's off
the stack (and in structs) when using cpumask_var_t.

From: Mike Travis <[EMAIL PROTECTED]>
Acked-by: Rusty Russell <[EMAIL PROTECTED]>
---
 arch/x86/Kconfig |   29 ++---
 1 file changed, 26 insertions(+), 3 deletions(-)

--- test-compile.orig/arch/x86/Kconfig
+++ test-compile/arch/x86/Kconfig
@@ -571,12 +571,20 @@ config IOMMU_HELPER
 
 config MAXSMP
bool "Configure Maximum number of SMP Processors and NUMA Nodes"
-   depends on X86_64 && SMP && BROKEN
+   depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL
+   select CPUMASK_OFFSTACK
default n
help
  Configure maximum number of CPUS and NUMA Nodes for this architecture.
  If unsure, say N.
 
+if MAXSMP
+config NR_CPUS
+   int
+   default "4096"
+endif
+
+if !MAXSMP
 config NR_CPUS
int "Maximum number of CPUs (2-512)" if !MAXSMP
range 2 512
@@ -591,6 +599,14 @@ config NR_CPUS
 
  This is purely to save memory - each supported CPU adds
  approximately eight kilobytes to the kernel image.
+endif
+
+config CPUMASK_OFFSTACK
+   bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS
+   help
+ Use dynamic allocation for cpumask_var_t, instead of putting
+ them on the stack.  This is a bit more expensive, but avoids
+ stack overflow.
 
 config SCHED_SMT
bool "SMT (Hyperthreading) scheduler support"
@@ -1027,10 +1043,16 @@ config NUMA_EMU
  into virtual nodes when booted with "numa=fake=N", where N is the
  number of nodes. This is only useful for debugging.
 
+if MAXSMP
+config NODES_SHIFT
+   int
+   default "9"
+endif
+
+if !MAXSMP
 config NODES_SHIFT
-   int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP
+   int "Maximum NUMA Nodes (as a power of 2)"
range 1 9   if X86_64
-   default "9" if MAXSMP
default "6" if X86_64
default "4" if X86_NUMAQ
default "3"
@@ -1038,6 +1060,7 @@ config NODES_SHIFT
help
  Specify the maximum number of NUMA Nodes available on the target
  system.  Increases memory reserved to accomodate various tables.
+endif
 
 config HAVE_ARCH_BOOTMEM_NODE
def_bool y

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 26/35] cpumask: get rid of boutique sched.c allocations, use cpumask_var_t.

2008-10-20 Thread Mike Travis
Using lots of allocs rather than one big alloc is less efficient, but
who cares for this setup function?

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 kernel/sched.c |  133 -
 1 file changed, 56 insertions(+), 77 deletions(-)

--- linux-2.6.28.orig/kernel/sched.c
+++ linux-2.6.28/kernel/sched.c
@@ -7291,40 +7291,6 @@ SD_INIT_FUNC(CPU)
  SD_INIT_FUNC(MC)
 #endif
 
-/*
- * To minimize stack usage kmalloc room for cpumasks and share the
- * space as the usage in build_sched_domains() dictates.  Used only
- * if the amount of space is significant.
- */
-struct allmasks {
-   cpumask_t tmpmask;  /* make this one first */
-   union {
-   cpumask_t nodemask;
-   cpumask_t this_sibling_map;
-   cpumask_t this_core_map;
-   };
-   cpumask_t send_covered;
-
-#ifdef CONFIG_NUMA
-   cpumask_t domainspan;
-   cpumask_t covered;
-   cpumask_t notcovered;
-#endif
-};
-
-#ifNR_CPUS > 128
-#defineSCHED_CPUMASK_ALLOC 1
-#defineSCHED_CPUMASK_FREE(v)   kfree(v)
-#defineSCHED_CPUMASK_DECLARE(v)struct allmasks *v
-#else
-#defineSCHED_CPUMASK_ALLOC 0
-#defineSCHED_CPUMASK_FREE(v)
-#defineSCHED_CPUMASK_DECLARE(v)struct allmasks _v, *v = &_v
-#endif
-
-#defineSCHED_CPUMASK_VAR(v, a) cpumask_t *v = (cpumask_t *) \
-   ((unsigned long)(a) + offsetof(struct allmasks, v))
-
 static int default_relax_domain_level = -1;
 
 static int __init setup_relax_domain_level(char *str)
@@ -7367,14 +7333,35 @@ static void set_domain_attribute(struct 
 static int __build_sched_domains(const cpumask_t *cpu_map,
 struct sched_domain_attr *attr)
 {
-   int i;
+   int i, err = -ENOMEM;
struct root_domain *rd;
-   SCHED_CPUMASK_DECLARE(allmasks);
-   cpumask_t *tmpmask;
+   cpumask_var_t nodemask, this_sibling_map, this_core_map, send_covered,
+   tmpmask;
 #ifdef CONFIG_NUMA
+   cpumask_var_t domainspan, covered, notcovered;
struct sched_group **sched_group_nodes = NULL;
int sd_allnodes = 0;
 
+   if (!alloc_cpumask_var(&domainspan, GFP_KERNEL))
+   goto out;
+   if (!alloc_cpumask_var(&covered, GFP_KERNEL))
+   goto free_domainspan;
+   if (!alloc_cpumask_var(¬covered, GFP_KERNEL))
+   goto free_covered;
+#endif
+
+   if (!alloc_cpumask_var(&nodemask, GFP_KERNEL))
+   goto free_notcovered;
+   if (!alloc_cpumask_var(&this_sibling_map, GFP_KERNEL))
+   goto free_nodemask;
+   if (!alloc_cpumask_var(&this_core_map, GFP_KERNEL))
+   goto free_this_sibling_map;
+   if (!alloc_cpumask_var(&send_covered, GFP_KERNEL))
+   goto free_this_core_map;
+   if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
+   goto free_send_covered;
+
+#ifdef CONFIG_NUMA
/*
 * Allocate the per-node list of sched groups
 */
@@ -7382,34 +7369,16 @@ static int __build_sched_domains(const c
GFP_KERNEL);
if (!sched_group_nodes) {
printk(KERN_WARNING "Can not alloc sched group node list\n");
-   return -ENOMEM;
+   goto free_tmpmask;
}
 #endif
 
rd = alloc_rootdomain();
if (!rd) {
printk(KERN_WARNING "Cannot alloc root domain\n");
-#ifdef CONFIG_NUMA
-   kfree(sched_group_nodes);
-#endif
-   return -ENOMEM;
+   goto free_sched_groups;
}
 
-#if SCHED_CPUMASK_ALLOC
-   /* get space for all scratch cpumask variables */
-   allmasks = kmalloc(sizeof(*allmasks), GFP_KERNEL);
-   if (!allmasks) {
-   printk(KERN_WARNING "Cannot alloc cpumask array\n");
-   kfree(rd);
-#ifdef CONFIG_NUMA
-   kfree(sched_group_nodes);
-#endif
-   return -ENOMEM;
-   }
-#endif
-   tmpmask = (cpumask_t *)allmasks;
-
-
 #ifdef CONFIG_NUMA
sched_group_nodes_bycpu[first_cpu(*cpu_map)] = sched_group_nodes;
 #endif
@@ -7419,7 +7388,6 @@ static int __build_sched_domains(const c
 */
for_each_cpu(i, cpu_map) {
struct sched_domain *sd = NULL, *p;
-   SCHED_CPUMASK_VAR(nodemask, allmasks);
 
*nodemask = node_to_cpumask(cpu_to_node(i));
cpus_and(*nodemask, *nodemask, *cpu_map);
@@ -7485,9 +7453,6 @@ static int __build_sched_domains(const c
 #ifdef CONFIG_SCHED_SMT
/* Set up CPU (sibling) groups */
for_each_cpu(i, cpu_map) {
-   SCHED_CPUMASK_VAR(this_sibling_map, allmasks);
-   SCHED_CPUMASK_VAR(send_covered, allmasks);
-
*this_sibling_map = per_cpu(cpu_s

[PATCH 21/35] cpumask: for_each_cpu(): for_each_cpu_mask which takes a pointer

2008-10-20 Thread Mike Travis
We want to wean people off handing around cpumask_t's, and have them
pass by pointer instead.  This does for_each_cpu_mask().

We immediately convert core files who were doing
"for_each_cpu_mask(... *mask)" since this is clearer.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   27 +++
 kernel/sched.c  |   40 
 kernel/workqueue.c  |6 +++---
 lib/cpumask.c   |2 +-
 mm/allocpercpu.c|4 ++--
 mm/vmstat.c |2 +-
 6 files changed, 42 insertions(+), 39 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -97,9 +97,9 @@
  * void cpumask_onto(dst, orig, relmap)*dst = orig relative to relmap
  * void cpumask_fold(dst, orig, sz)dst bits = orig bits mod sz
  *
- * for_each_cpu_mask(cpu, mask)for-loop cpu over mask
+ * for_each_cpu(cpu, mask) for-loop cpu over mask
  * using nr_cpumask_bits
- * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
+ * for_each_cpu_and(cpu, mask, and)for-loop cpu over (mask & and).
  *
  * int num_online_cpus()   Number of online CPUs
  * int num_possible_cpus() Number of all possible CPUs
@@ -176,6 +176,9 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpus_weight_nr(cpumask)cpus_weight(cpumask)
 #define for_each_cpu_mask_nr(cpu, mask)for_each_cpu_mask(cpu, mask)
 #define cpumask_of_cpu(cpu) (*cpumask_of(cpu))
+#define for_each_cpu_mask(cpu, mask)   for_each_cpu(cpu, &(mask))
+#define for_each_cpu_mask_and(cpu, mask, and)  \
+   for_each_cpu_and(cpu, &(mask), &(and))
 /* End deprecated region. */
 
 #if NR_CPUS <= BITS_PER_LONG
@@ -439,9 +442,9 @@ extern cpumask_t cpu_mask_all;
 #define next_cpu(n, src)   ({ (void)(src); 1; })
 #define any_online_cpu(mask)   0
 
-#define for_each_cpu_mask(cpu, mask)   \
+#define for_each_cpu(cpu, mask)\
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
-#define for_each_cpu_mask_and(cpu, mask, and)  \
+#define for_each_cpu_and(cpu, mask, and)   \
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)
 
 #else /* NR_CPUS > 1 */
@@ -455,13 +458,13 @@ int __any_online_cpu(const cpumask_t *ma
 #define next_cpu(n, src)   __next_cpu((n), &(src))
 #define any_online_cpu(mask) __any_online_cpu(&(mask))
 
-#define for_each_cpu_mask(cpu, mask)   \
+#define for_each_cpu(cpu, mask)\
for ((cpu) = -1;\
-   (cpu) = next_cpu((cpu), (mask)),\
+   (cpu) = __next_cpu((cpu), (mask)),  \
(cpu) < nr_cpumask_bits;)
-#define for_each_cpu_mask_and(cpu, mask, and)  \
-   for ((cpu) = -1;\
-   (cpu) = cpumask_next_and((cpu), &(mask), &(and)),   \
+#define for_each_cpu_and(cpu, mask, and)   \
+   for ((cpu) = -1;\
+   (cpu) = cpumask_next_and((cpu), (mask), (and)), \
(cpu) < nr_cpumask_bits;)
 #endif
 
@@ -615,9 +618,9 @@ extern cpumask_t cpu_active_map;
 
 #define cpu_is_offline(cpu)unlikely(!cpu_online(cpu))
 
-#define for_each_possible_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
-#define for_each_online_cpu(cpu)   for_each_cpu_mask((cpu), cpu_online_map)
-#define for_each_present_cpu(cpu)  for_each_cpu_mask((cpu), cpu_present_map)
+#define for_each_possible_cpu(cpu) for_each_cpu((cpu), &cpu_possible_map)
+#define for_each_online_cpu(cpu)   for_each_cpu((cpu), &cpu_online_map)
+#define for_each_present_cpu(cpu)  for_each_cpu((cpu), &cpu_present_map)
 
 /* Arch-specific code may call this to initialize nr_cpu_ids based on
  * the cpu_possible_map. */
--- linux-2.6.28.orig/kernel/sched.c
+++ linux-2.6.28/kernel/sched.c
@@ -1512,7 +1512,7 @@ static int tg_shares_up(struct task_grou
struct sched_domain *sd = data;
int i;
 
-   for_each_cpu_mask(i, sd->span) {
+   for_each_cpu(i, &sd->span) {
rq_weight += tg->cfs_rq[i]->load.weight;
shares += tg->cfs_rq[i]->shares;
}
@@ -1526,7 +1526,7 @@ static int tg_shares_up(struct task_grou
if (!rq_weight)
rq_weight = cpus_weight(sd->span) * NICE_0_LOAD;
 
-   for_each_cpu_mask(i, sd->span) {
+   for_each_cpu(i, &sd->span) {
struct rq *rq = cpu_rq(i);
unsigned long flags;
 
@@ -2069,7 +2069,7 @@ find_idlest_group(struct sched_domain *s
/* Tally up the load of all CPUs in the group */
avg_load = 0;
 
-   for_each_cpu_mask_nr(i, group->cpu

[PATCH 23/35] cpumask: deprecate any_online_cpu() in favour of cpumask_any/cpumask_any_and

2008-10-20 Thread Mike Travis
any_online_cpu() is a good name, but it takes a cpumask_t, not a
pointer.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   11 ++-
 lib/cpumask.c   |   12 
 2 files changed, 6 insertions(+), 17 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -109,7 +109,8 @@
  * int cpu_possible(cpu)   Is some cpu possible?
  * int cpu_present(cpu)Is some cpu present (can 
schedule)?
  *
- * int any_online_cpu(mask)First online cpu in mask
+ * int cpumask_any(mask)   Any cpu in mask
+ * int cpumask_any_and(mask1,mask2)Any cpu in both masks
  *
  * for_each_possible_cpu(cpu)  for-loop cpu over cpu_possible_map
  * for_each_online_cpu(cpu)for-loop cpu over cpu_online_map
@@ -202,6 +203,7 @@ extern cpumask_t _unused_cpumask_arg_;
for_each_cpu_and(cpu, &(mask), &(and))
 #define first_cpu(src) cpumask_first(&(src))
 #define next_cpu(n, src)   cpumask_next((n), &(src))
+#define any_online_cpu(mask)   cpumask_any_and(&(mask), &cpu_online_map)
 /* End deprecated region. */
 
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
@@ -387,6 +389,9 @@ static inline void cpumask_copy(struct c
bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits);
 }
 
+#define cpumask_any(srcp) cpumask_first(srcp)
+#define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
+
 /*
  * Special-case data structure for "single bit set only" constant CPU masks.
  *
@@ -453,7 +458,6 @@ extern cpumask_t cpu_mask_all;
 #define cpumask_first(src) ({ (void)(src); 0; })
 #define cpumask_next(n, src)   ({ (void)(src); 1; })
 #define cpumask_next_and(n, srcp, andp)({ (void)(srcp), (void)(andp); 
1; })
-#define any_online_cpu(mask)   0
 
 #define for_each_cpu(cpu, mask)\
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
@@ -465,9 +469,6 @@ extern cpumask_t cpu_mask_all;
 int cpumask_first(const cpumask_t *srcp);
 int cpumask_next(int n, const cpumask_t *srcp);
 int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
-int __any_online_cpu(const cpumask_t *mask);
-
-#define any_online_cpu(mask) __any_online_cpu(&(mask))
 
 #define for_each_cpu(cpu, mask)\
for ((cpu) = -1;\
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -24,18 +24,6 @@ int cpumask_next_and(int n, const cpumas
 }
 EXPORT_SYMBOL(cpumask_next_and);
 
-int __any_online_cpu(const cpumask_t *mask)
-{
-   int cpu;
-
-   for_each_cpu(cpu, mask) {
-   if (cpu_online(cpu))
-   break;
-   }
-   return cpu;
-}
-EXPORT_SYMBOL(__any_online_cpu);
-
 /* These are not inline because of header tangles. */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 25/35] cpumask: Deprecate CPUMASK_ALLOC etc in favor of cpumask_var_t.

2008-10-20 Thread Mike Travis
Remove CPUMASK_ALLOC() in favor of alloc_cpumask_var().

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   46 --
 1 file changed, 8 insertions(+), 38 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -57,35 +57,6 @@
  * CPU_MASK_NONE   Initializer - no bits set
  * unsigned long *cpumask_bits(mask)   Array of unsigned long's in mask
  *
- * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
- * variables, and CPUMASK_PTR provides pointers to each field.
- *
- * The structure should be defined something like this:
- * struct my_cpumasks {
- * cpumask_t mask1;
- * cpumask_t mask2;
- * };
- *
- * Usage is then:
- * CPUMASK_ALLOC(my_cpumasks);
- * CPUMASK_PTR(mask1, my_cpumasks);
- * CPUMASK_PTR(mask2, my_cpumasks);
- *
- * --- DO NOT reference cpumask_t pointers until this check ---
- * if (my_cpumasks == NULL)
- * "kmalloc failed"...
- *
- * References are now pointers to the cpumask_t variables (*mask1, ...)
- *
- *if NR_CPUS > BITS_PER_LONG
- *   CPUMASK_ALLOC(m)  Declares and allocates struct m *m =
- * kmalloc(sizeof(*m), GFP_KERNEL)
- *   CPUMASK_FREE(m)   Macro for kfree(m)
- *else
- *   CPUMASK_ALLOC(m)  Declares struct m _m, *m = &_m
- *   CPUMASK_FREE(m)   Nop
- *endif
- *   CPUMASK_PTR(v, m) Declares cpumask_t *v = &(m->v)
  * 
  *
  * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
@@ -184,6 +155,14 @@ extern cpumask_t _unused_cpumask_arg_;
 #define first_cpu(src) cpumask_first(&(src))
 #define next_cpu(n, src)   cpumask_next((n), &(src))
 #define any_online_cpu(mask)   cpumask_any_and(&(mask), &cpu_online_map)
+#if NR_CPUS > BITS_PER_LONG
+#defineCPUMASK_ALLOC(m)struct m *m = kmalloc(sizeof(*m), 
GFP_KERNEL)
+#defineCPUMASK_FREE(m) kfree(m)
+#else
+#defineCPUMASK_ALLOC(m)struct m _m, *m = &_m
+#defineCPUMASK_FREE(m)
+#endif
+#defineCPUMASK_PTR(v, m)   cpumask_t *v = &(m->v)
 /* End deprecated region. */
 
 #if NR_CPUS <= BITS_PER_LONG
@@ -435,15 +414,6 @@ extern cpumask_t cpu_mask_all;
[0] =  1UL  \
 } }
 
-#if NR_CPUS > BITS_PER_LONG
-#defineCPUMASK_ALLOC(m)struct m *m = kmalloc(sizeof(*m), 
GFP_KERNEL)
-#defineCPUMASK_FREE(m) kfree(m)
-#else
-#defineCPUMASK_ALLOC(m)struct m _m, *m = &_m
-#defineCPUMASK_FREE(m)
-#endif
-#defineCPUMASK_PTR(v, m)   cpumask_t *v = &(m->v)
-
 #if NR_CPUS == 1
 
 #define cpumask_first(src) ({ (void)(src); 0; })

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 05/35] sched: Reduce stack size requirements in kernel/sched.c

2008-10-20 Thread Mike Travis
  * use node_to_cpumask_ptr in place of node_to_cpumask to reduce stack
requirements in sched.c

Applies to linux-2.6.tip/master.

Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
Acked-by: Rusty Russell <[EMAIL PROTECTED]>
---
 kernel/sched.c |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

--- linux-2.6.28.orig/kernel/sched.c
+++ linux-2.6.28/kernel/sched.c
@@ -6117,8 +6117,9 @@ static void move_task_off_dead_cpu(int d
 
do {
/* On same node? */
-   mask = node_to_cpumask(cpu_to_node(dead_cpu));
-   cpus_and(mask, mask, p->cpus_allowed);
+   node_to_cpumask_ptr(pnodemask, cpu_to_node(dead_cpu));
+
+   cpus_and(mask, *pnodemask, p->cpus_allowed);
dest_cpu = any_online_cpu(mask);
 
/* On any allowed CPU? */
@@ -7126,9 +7127,9 @@ static int cpu_to_allnodes_group(int cpu
 struct sched_group **sg, cpumask_t *nodemask)
 {
int group;
+   node_to_cpumask_ptr(pnodemask, cpu_to_node(cpu));
 
-   *nodemask = node_to_cpumask(cpu_to_node(cpu));
-   cpus_and(*nodemask, *nodemask, *cpu_map);
+   cpus_and(*nodemask, *pnodemask, *cpu_map);
group = first_cpu(*nodemask);
 
if (sg)
@@ -7178,9 +7179,9 @@ static void free_sched_groups(const cpum
 
for (i = 0; i < nr_node_ids; i++) {
struct sched_group *oldsg, *sg = sched_group_nodes[i];
+   node_to_cpumask_ptr(pnodemask, i);
 
-   *nodemask = node_to_cpumask(i);
-   cpus_and(*nodemask, *nodemask, *cpu_map);
+   cpus_and(*nodemask, *pnodemask, *cpu_map);
if (cpus_empty(*nodemask))
continue;
 

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 19/35] cpumask: use cpumask_bits() everywhere.

2008-10-20 Thread Mike Travis
Instead of accessing ->bits, we use cpumask_bits().  This will be very
useful when 'struct cpumask' has a hidden definition.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h  |   70 ---
 include/linux/seq_file.h |2 -
 kernel/time/timer_list.c |4 +-
 lib/cpumask.c|4 +-
 4 files changed, 47 insertions(+), 33 deletions(-)

--- linux-2.6.28.orig/include/linux/cpumask.h
+++ linux-2.6.28/include/linux/cpumask.h
@@ -191,12 +191,12 @@ extern int nr_cpu_ids;
 
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
 {
-   set_bit(cpu, dstp->bits);
+   set_bit(cpu, cpumask_bits(dstp));
 }
 
 static inline void cpumask_clear_cpu(int cpu, volatile struct cpumask *dstp)
 {
-   clear_bit(cpu, dstp->bits);
+   clear_bit(cpu, cpumask_bits(dstp));
 }
 
 /* No static inline type checking - see Subtlety (1) above. */
@@ -204,130 +204,142 @@ static inline void cpumask_clear_cpu(int
 
 static inline int cpumask_test_and_set_cpu(int cpu, struct cpumask *addr)
 {
-   return test_and_set_bit(cpu, addr->bits);
+   return test_and_set_bit(cpu, cpumask_bits(addr));
 }
 
 static inline void cpumask_setall(struct cpumask *dstp)
 {
-   bitmap_fill(dstp->bits, nr_cpumask_bits);
+   bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 static inline void cpumask_clear(struct cpumask *dstp)
 {
-   bitmap_zero(dstp->bits, nr_cpumask_bits);
+   bitmap_zero(cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 static inline void cpumask_and(struct cpumask *dstp,
   const struct cpumask *src1p,
   const struct cpumask *src2p)
 {
-   bitmap_and(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
+   bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p),
+  cpumask_bits(src2p), nr_cpumask_bits);
 }
 
 static inline void cpumask_or(struct cpumask *dstp, const struct cpumask 
*src1p,
  const struct cpumask *src2p)
 {
-   bitmap_or(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
+   bitmap_or(cpumask_bits(dstp), cpumask_bits(src1p),
+ cpumask_bits(src2p), nr_cpumask_bits);
 }
 
 static inline void cpumask_xor(struct cpumask *dstp,
   const struct cpumask *src1p,
   const struct cpumask *src2p)
 {
-   bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
+   bitmap_xor(cpumask_bits(dstp), cpumask_bits(src1p),
+  cpumask_bits(src2p), nr_cpumask_bits);
 }
 
 static inline void cpumask_andnot(struct cpumask *dstp,
  const struct cpumask *src1p,
  const struct cpumask *src2p)
 {
-   bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nr_cpumask_bits);
+   bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p),
+ cpumask_bits(src2p), nr_cpumask_bits);
 }
 
 static inline void cpumask_complement(struct cpumask *dstp,
  const struct cpumask *srcp)
 {
-   bitmap_complement(dstp->bits, srcp->bits, nr_cpumask_bits);
+   bitmap_complement(cpumask_bits(dstp), cpumask_bits(srcp),
+ nr_cpumask_bits);
 }
 
 static inline int cpumask_equal(const struct cpumask *src1p,
const struct cpumask *src2p)
 {
-   return bitmap_equal(src1p->bits, src2p->bits, nr_cpumask_bits);
+   return bitmap_equal(cpumask_bits(src1p), cpumask_bits(src2p),
+nr_cpumask_bits);
 }
 
 static inline int cpumask_intersects(const struct cpumask *src1p,
 const struct cpumask *src2p)
 {
-   return bitmap_intersects(src1p->bits, src2p->bits, nr_cpumask_bits);
+   return bitmap_intersects(cpumask_bits(src1p), cpumask_bits(src2p),
+ nr_cpumask_bits);
 }
 
 static inline int cpumask_subset(const struct cpumask *src1p,
 const struct cpumask *src2p)
 {
-   return bitmap_subset(src1p->bits, src2p->bits, nr_cpumask_bits);
+   return bitmap_subset(cpumask_bits(src1p), cpumask_bits(src2p),
+ nr_cpumask_bits);
 }
 
 static inline int cpumask_empty(const struct cpumask *srcp)
 {
-   return bitmap_empty(srcp->bits, nr_cpumask_bits);
+   return bitmap_empty(cpumask_bits(srcp), nr_cpumask_bits);
 }
 
 static inline int cpumask_full(const struct cpumask *srcp)
 {
-   return bitmap_full(srcp->bits, nr_cpumask_bits);
+   return bitmap_full(cpumask_bits(srcp), nr_cpumask_bits);
 }
 
 static inline int __cpus_weight(con

[PATCH 18/35] cpumask: add nr_cpumask_bits

2008-10-20 Thread Mike Travis
When nr_cpu_ids is set to CONFIG_NR_CPUS then references to nr_cpu_ids
will return the maximum index of the configured NR_CPUS (+1) instead
of the maximum index of the possible number of cpus (+1).  This results
in extra unused memory being allocated by functions that are setting up
arrays of structs to keep track of per cpu items.

Since we do want to keep the ability to use constants for the cpu bit
operators on smaller systems (which are generally much faster assembler
ops), we introduce a separate "nr_cpumask_bits" to replace "nr_cpu_ids"
only for the inline assembly ops.  This will be a constant when
CONFIG_CPUMASK_OFFSTACK is undefined and a variable when it is defined.

Thus "nr_cpu_ids" reverts back to being a variable representing the
maximum possible cpu (+1), except in the non-SMP case where it is a
constant value of 1.  The relationship between the related variables
and constants is: (1 <= nr_cpu_ids <= nr_cpumask_bits <= NR_CPUS).

Signed-of-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/x86/kernel/setup_percpu.c |7 +--
 include/linux/cpumask.h|   94 +++--
 init/main.c|   17 +++
 lib/cpumask.c  |8 +--
 4 files changed, 72 insertions(+), 54 deletions(-)

--- test-compile.orig/arch/x86/kernel/setup_percpu.c
+++ test-compile/arch/x86/kernel/setup_percpu.c
@@ -155,6 +155,10 @@ void __init setup_per_cpu_areas(void)
printk(KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n",
  size);
 
+   printk(KERN_DEBUG
+   "NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n",
+   NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
+
for_each_possible_cpu(cpu) {
 #ifndef CONFIG_NEED_MULTIPLE_NODES
ptr = __alloc_bootmem(size, align,
@@ -183,9 +187,6 @@ void __init setup_per_cpu_areas(void)
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
}
 
-   printk(KERN_DEBUG "NR_CPUS: %d, nr_cpu_ids: %d, nr_node_ids %d\n",
-   NR_CPUS, nr_cpu_ids, nr_node_ids);
-
/* Setup percpu data maps */
setup_per_cpu_maps();
 
--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -4,7 +4,7 @@
 /*
  * Cpumasks provide a bitmap suitable for representing the
  * set of CPU's in a system, one bit position per CPU number up to
- * nr_cpu_ids (<= NR_CPUS).
+ * nr_cpumask_bits (<= NR_CPUS).
  *
  * Old-style uses "cpumask_t", but new ops are "struct cpumask *";
  * don't put "struct cpumask"s on the stack.
@@ -46,8 +46,8 @@
  * void cpumask_shift_right(dst, src, n) Shift right
  * void cpumask_shift_left(dst, src, n)Shift left
  *
- * int first_cpu(mask) Number lowest set bit, or nr_cpu_ids
- * int next_cpu(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
+ * int first_cpu(mask) Number lowest set bit or nr_cpumask_bits
+ * int next_cpu(cpu, mask) Next cpu past 'cpu', or nr_cpumask_bits
  *
  * void cpumask_copy(dmask, smask) dmask = smask
  *
@@ -98,7 +98,8 @@
  * void cpumask_onto(dst, orig, relmap)*dst = orig relative to relmap
  * void cpumask_fold(dst, orig, sz)dst bits = orig bits mod sz
  *
- * for_each_cpu_mask(cpu, mask)for-loop cpu over mask using 
nr_cpu_ids
+ * for_each_cpu_mask(cpu, mask)for-loop cpu over mask
+ * using nr_cpumask_bits
  * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
  *
  * int num_online_cpus()   Number of online CPUs
@@ -136,11 +137,34 @@ struct cpumask
 };
 #define cpumask_bits(maskp) ((maskp)->bits)
 
+/*
+ * nr_cpu_ids: max cpu index (+1)
+ * nr_cpumask_bits: number of bits in a struct cpumask
+ * 1 <= nr_cpu_ids <= nr_cpumask_bits <= NR_CPUS
+ *
+ * Use CONFIG_CPUMASK_OFFSTACK to force variable length struct cpumask
+ */
+#if NR_CPUS == 1
+#define nr_cpumask_bits NR_CPUS
+#define nr_cpu_ids NR_CPUS
+#else
+
+#ifdef CONFIG_CPUMASK_OFFSTACK
+extern int nr_cpumask_bits;
+extern int nr_cpu_ids;
+#else
+
+#define nr_cpumask_bits NR_CPUS
+extern int nr_cpu_ids;
+#endif
+#endif
+
 static inline ssize_t cpumask_size(void)
 {
-   return BITS_TO_LONGS(nr_cpu_ids) * sizeof(long);
+   return BITS_TO_LONGS(nr_cpumask_bits) * sizeof(long);
 }
 
+
 /* Deprecated. */
 typedef struct cpumask cpumask_t;
 extern cpumask_t _unused_cpumask_arg_;
@@ -182,14 +206,6 @@ extern cpumask_t _unused_cpumask_arg_;
 #define for_each_cpu_mask_nr(cpu, mask)for_each_cpu_mask(cpu, mask)
 /* End deprecated region. */
 
-#if NR_CPUS <= BITS_PER_LONG
-/* Constant is usually more efficient than a variable for small NR_CPUS */
-#define nr_cpu_ids NR_CPUS
-#else
-/* Starts at NR_CPUS until we know better. */
-extern int nr_cpu_ids;
-#endif /* NR_CPUS > BITS_PER_LONG */
-
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
 {
  

[PATCH 16/35] percpu: fix percpu accessors to potentially !cpu_possible() cpus

2008-10-20 Thread Mike Travis
Percpu areas are only allocated for possible cpus.  In general, you
shouldn't access random cpu's percpu areas: you're corrupting memory.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/m32r/kernel/smpboot.c  |2 +-
 arch/x86/mach-voyager/voyager_smp.c |2 +-
 drivers/pnp/pnpbios/bioscalls.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

--- test-compile.orig/arch/m32r/kernel/smpboot.c
+++ test-compile/arch/m32r/kernel/smpboot.c
@@ -598,7 +598,7 @@ int setup_profiling_timer(unsigned int m
 * accounting. At that time they also adjust their APIC timers
 * accordingly.
 */
-   for (i = 0; i < NR_CPUS; ++i)
+   for_each_possible_cpu(i)
per_cpu(prof_multiplier, i) = multiplier;
 
return 0;
--- test-compile.orig/arch/x86/mach-voyager/voyager_smp.c
+++ test-compile/arch/x86/mach-voyager/voyager_smp.c
@@ -1223,7 +1223,7 @@ int setup_profiling_timer(unsigned int m
 * new values until the next timer interrupt in which they do process
 * accounting.
 */
-   for (i = 0; i < NR_CPUS; ++i)
+   for_each_possible_cpu(i)
per_cpu(prof_multiplier, i) = multiplier;
 
return 0;
--- test-compile.orig/drivers/pnp/pnpbios/bioscalls.c
+++ test-compile/drivers/pnp/pnpbios/bioscalls.c
@@ -481,7 +481,7 @@ void pnpbios_calls_init(union pnp_bios_i
 
set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
_set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
-   for (i = 0; i < NR_CPUS; i++) {
+   for_each_possible_cpu(i) {
struct desc_struct *gdt = get_cpu_gdt_table(i);
if (!gdt)
continue;

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 03/35] cpumask: add for_each_cpu_mask_and function

2008-10-20 Thread Mike Travis
Add for_each_cpu_mask_and() function to eliminate need for a common use
of a temporary cpumask_t variable.  When the following procedure is being
used:

funcproto(const cpumask_t *mask, ...)
{
cpumask_t temp;

cpus_and(temp, mask, cpu_online_map);
for_each_cpu_mask(cpu, temp)
...
It then becomes:

funcproto(cpumask_t *mask, ...)
{
for_each_cpu_mask_and(cpu, *mask, cpu_online_map)
...

... eliminating the need for the temp cpumask.


Applies to linux-2.6.tip/master.

Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
Acked-by: Rusty Russell <[EMAIL PROTECTED]>
---
 include/linux/cpumask.h |   33 -
 lib/cpumask.c   |9 +
 2 files changed, 33 insertions(+), 9 deletions(-)

--- test-compile.orig/include/linux/cpumask.h
+++ test-compile/include/linux/cpumask.h
@@ -109,6 +109,7 @@
  *
  * for_each_cpu_mask(cpu, mask)for-loop cpu over mask using 
NR_CPUS
  * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
+ * for_each_cpu_mask_and(cpu, mask, and) for-loop cpu over (mask & and).
  *
  * int num_online_cpus()   Number of online CPUs
  * int num_possible_cpus() Number of all possible CPUs
@@ -400,29 +401,41 @@ static inline void __cpus_fold(cpumask_t
 
 #if NR_CPUS == 1
 
-#define nr_cpu_ids 1
-#define first_cpu(src) ({ (void)(src); 0; })
-#define next_cpu(n, src)   ({ (void)(src); 1; })
-#define any_online_cpu(mask)   0
-#define for_each_cpu_mask(cpu, mask)   \
+#define nr_cpu_ids 1
+#define first_cpu(src) ({ (void)(src); 0; })
+#define next_cpu(n, src)   ({ (void)(src); 1; })
+#define cpumask_next_and(n, srcp, andp)({ (void)(srcp), (void)(andp); 
1; })
+#define any_online_cpu(mask)   0
+
+#define for_each_cpu_mask(cpu, mask)   \
for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
+#define for_each_cpu_mask_and(cpu, mask, and)  \
+   for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)
 
 #else /* NR_CPUS > 1 */
 
 extern int nr_cpu_ids;
 int __first_cpu(const cpumask_t *srcp);
 int __next_cpu(int n, const cpumask_t *srcp);
+int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp);
 int __any_online_cpu(const cpumask_t *mask);
 
 #define first_cpu(src) __first_cpu(&(src))
 #define next_cpu(n, src)   __next_cpu((n), &(src))
 #define any_online_cpu(mask) __any_online_cpu(&(mask))
+
 #define for_each_cpu_mask(cpu, mask)   \
for ((cpu) = -1;\
(cpu) = next_cpu((cpu), (mask)),\
-   (cpu) < NR_CPUS; )
+   (cpu) < NR_CPUS;)
+#define for_each_cpu_mask_and(cpu, mask, and)  \
+   for ((cpu) = -1;\
+   (cpu) = cpumask_next_and((cpu), &(mask), &(and)),   \
+   (cpu) < nr_cpu_ids;)
 #endif
 
+#define cpumask_first_and(mask, and) cpumask_next_and(-1, (mask), (and))
+
 #if NR_CPUS <= 64
 
 #define next_cpu_nr(n, src)next_cpu(n, src)
@@ -432,12 +445,14 @@ int __any_online_cpu(const cpumask_t *ma
 #else /* NR_CPUS > 64 */
 
 int __next_cpu_nr(int n, const cpumask_t *srcp);
-#define next_cpu_nr(n, src)__next_cpu_nr((n), &(src))
-#define cpus_weight_nr(cpumask)__cpus_weight(&(cpumask), nr_cpu_ids)
+
+#define next_cpu_nr(n, src)__next_cpu_nr((n), &(src))
+#define cpus_weight_nr(cpumask)__cpus_weight(&(cpumask), 
nr_cpu_ids)
+
 #define for_each_cpu_mask_nr(cpu, mask)\
for ((cpu) = -1;\
(cpu) = next_cpu_nr((cpu), (mask)), \
-   (cpu) < nr_cpu_ids; )
+   (cpu) < nr_cpu_ids;)
 
 #endif /* NR_CPUS > 64 */
 
--- test-compile.orig/lib/cpumask.c
+++ test-compile/lib/cpumask.c
@@ -15,6 +15,15 @@ int __next_cpu(int n, const cpumask_t *s
 }
 EXPORT_SYMBOL(__next_cpu);
 
+int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp)
+{
+   while ((n = next_cpu_nr(n, *srcp)) < nr_cpu_ids)
+   if (cpu_isset(n, *andp))
+   break;
+   return n;
+}
+EXPORT_SYMBOL(cpumask_next_and);
+
 #if NR_CPUS > 64
 int __next_cpu_nr(int n, const cpumask_t *srcp)
 {

-- 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 01/35] x86: clean up speedctep-centrino and reduce cpumask_t usage

2008-10-20 Thread Mike Travis
1) The #ifdef CONFIG_HOTPLUG_CPU seems unnecessary these days.
2) The loop can simply skip over offline cpus, rather than creating a tmp mask.
3) set_mask is set to either a single cpu or all online cpus in a policy.
   Since it's just used for set_cpus_allowed(), any offline cpus in a policy
   don't matter, so we can just use cpumask_of_cpu() or the policy->cpus.

From: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Signed-off-by: Mike Travis <[EMAIL PROTECTED]>
---
 arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c |   51 ++-
 1 file changed, 24 insertions(+), 27 deletions(-)

--- linux-2.6.28.orig/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ linux-2.6.28/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -552,9 +552,7 @@ static int centrino_verify (struct cpufr
  * Sets a new CPUFreq policy.
  */
 struct allmasks {
-   cpumask_t   online_policy_cpus;
cpumask_t   saved_mask;
-   cpumask_t   set_mask;
cpumask_t   covered_cpus;
 };
 
@@ -568,9 +566,7 @@ static int centrino_target (struct cpufr
int retval = 0;
unsigned intj, k, first_cpu, tmp;
CPUMASK_ALLOC(allmasks);
-   CPUMASK_PTR(online_policy_cpus, allmasks);
CPUMASK_PTR(saved_mask, allmasks);
-   CPUMASK_PTR(set_mask, allmasks);
CPUMASK_PTR(covered_cpus, allmasks);
 
if (unlikely(allmasks == NULL))
@@ -590,30 +586,28 @@ static int centrino_target (struct cpufr
goto out;
}
 
-#ifdef CONFIG_HOTPLUG_CPU
-   /* cpufreq holds the hotplug lock, so we are safe from here on */
-   cpus_and(*online_policy_cpus, cpu_online_map, policy->cpus);
-#else
-   *online_policy_cpus = policy->cpus;
-#endif
-
*saved_mask = current->cpus_allowed;
first_cpu = 1;
cpus_clear(*covered_cpus);
-   for_each_cpu_mask_nr(j, *online_policy_cpus) {
+   for_each_cpu_mask_nr(j, policy->cpus) {
+   const cpumask_t *mask;
+
+   /* cpufreq holds the hotplug lock, so we are safe here */
+   if (!cpu_online(j))
+   continue;
+
/*
 * Support for SMP systems.
 * Make sure we are running on CPU that wants to change freq
 */
-   cpus_clear(*set_mask);
if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
-   cpus_or(*set_mask, *set_mask, *online_policy_cpus);
+   mask = &policy->cpus;
else
-   cpu_set(j, *set_mask);
+   mask = &cpumask_of_cpu(j);
 
-   set_cpus_allowed_ptr(current, set_mask);
+   set_cpus_allowed_ptr(current, mask);
preempt_disable();
-   if (unlikely(!cpu_isset(smp_processor_id(), *set_mask))) {
+   if (unlikely(!cpu_isset(smp_processor_id(), *mask))) {
dprintk("couldn't limit to CPUs in this domain\n");
retval = -EAGAIN;
if (first_cpu) {
@@ -641,7 +635,9 @@ static int centrino_target (struct cpufr
dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
target_freq, freqs.old, freqs.new, msr);
 
-   for_each_cpu_mask_nr(k, *online_policy_cpus) {
+   for_each_cpu_mask_nr(k, policy->cpus) {
+   if (!cpu_online(k))
+   continue;
freqs.cpu = k;
cpufreq_notify_transition(&freqs,
CPUFREQ_PRECHANGE);
@@ -664,7 +660,9 @@ static int centrino_target (struct cpufr
preempt_enable();
}
 
-   for_each_cpu_mask_nr(k, *online_policy_cpus) {
+   for_each_cpu_mask_nr(k, policy->cpus) {
+   if (!cpu_online(k))
+   continue;
freqs.cpu = k;
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
}
@@ -677,18 +675,17 @@ static int centrino_target (struct cpufr
 * Best effort undo..
 */
 
-   if (!cpus_empty(*covered_cpus))
-   for_each_cpu_mask_nr(j, *covered_cpus) {
-   set_cpus_allowed_ptr(current,
-&cpumask_of_cpu(j));
-   wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
-   }
+   for_each_cpu_mask_nr(j, *covered_cpus) {
+   set_cpus_allowed_ptr(current, &cpumask_of_cpu(j));
+   wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
+   }
 
tmp = freqs.new;
freqs.new = freqs.old;
freqs.old = tmp;
-   for

  1   2   >