Deputy maintainer for powerpc

2008-07-04 Thread Paul Mackerras
I'm going to be on vacation for the next two weeks, and it looks
highly likely that Linus will open the 2.6.27 merge window during that
time, so I'm appointing Ben Herrenschmidt as my deputy maintainer.
During the next two weeks, he'll be the person collecting together any
further powerpc-related commits that need to go upstream, and sending
pull requests to Linus as necessary.

This is the start of a longer-term transition which will ultimately
result in me handing over the powerpc architecture maintainership to
Ben.  Because of various work commitments, this will be a gradual
transition taking probably around 6 months.

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


Re: [RFC/PATCH] powerpc/bootwrapper: Allow user to specify additional default targets

2008-07-04 Thread Grant Likely
Anyone had a chance to look at this?  I think this could be used to
eliminate a lot of the platform specific default targets in
arch/powerpc/boot/Makefile by moving them into the defconfigs.  Josh,
Kumar, what are your thoughts?

g.

On Tue, Jul 1, 2008 at 11:59 AM, Grant Likely [EMAIL PROTECTED] wrote:
 From: Grant Likely [EMAIL PROTECTED]

 It is inconvenient to add additional default targets to the bootwrapper
 Makefile for each new board supported which just needs a different dts
 file.  This change allows the defconfig to specify additional build
 targets.

 Signed-off-by: Grant Likely [EMAIL PROTECTED]
 ---

  arch/powerpc/Kconfig   |   13 +
  arch/powerpc/boot/Makefile |3 +++
  2 files changed, 16 insertions(+), 0 deletions(-)

 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
 index 3934e26..f09f617 100644
 --- a/arch/powerpc/Kconfig
 +++ b/arch/powerpc/Kconfig
 @@ -458,6 +458,19 @@ config CMDLINE
  some command-line options at build time by entering them here.  In
  most cases you will need to specify the root device here.

 +config EXTRA_TARGETS
 +   string Additional default image types
 +   help
 + List additional targets to be built by the bootwrapper here 
 (separated
 + by spaces).  This is useful for targets that depend of device tree
 + files in the .dts directory.
 +
 + Targets in this list will be build as part of the default build
 + target, or when the user does a 'make zImage' or a
 + 'make zImage.initrd'.
 +
 + If unsure, leave blank
 +
  if !44x || BROKEN
  config ARCH_WANTS_FREEZER_CONTROL
def_bool y
 diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
 index 1cee2f9..1e38237 100644
 --- a/arch/powerpc/boot/Makefile
 +++ b/arch/powerpc/boot/Makefile
 @@ -270,6 +270,9 @@ ifeq ($(CONFIG_PPC32),y)
  image-$(CONFIG_PPC_PMAC)   += zImage.coff zImage.miboot
  endif

 +# Allow extra targets to be added to the defconfig
 +image-y+= $(subst ,,$(CONFIG_EXTRA_TARGETS))
 +
  initrd-  := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-))
  initrd-y := $(patsubst zImage%, zImage.initrd%, \
$(patsubst dtbImage%, dtbImage.initrd%, \





-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: linux-next: manual merge of the powerpc tree

2008-07-04 Thread Jean Delvare
On Thu, 3 Jul 2008 23:54:26 -0600, Grant Likely wrote:
 On Thu, Jul 3, 2008 at 9:24 AM, Grant Likely [EMAIL PROTECTED] wrote:
  On Thu, Jul 03, 2008 at 08:22:18AM -0400, Jon Smirl wrote:
  Testing was good when the patch was initially posted in January. In
  the last six months the initial patch set has been sliced and diced
  into a bunch of different pieces but the contents of this patch are
  essentially unchanged.
 
  I don't care which tree it uses to get to mainline, I'd just like to
  see it get merged.
 
  Me too, but it is used by some of the mpc8xxx platforms too, so I'd like
  to see an ack from one of those users also.
 
 Okay, I've tested it on my board.  All looks good to me.  I'd prefer
 to hear back from one of the Freescale folks, but on a second reading
 I think it is pretty safe.  I'll make sure any merge conflicts are
 resolved.
 
 Jean, is it okay with you to drop it from your tree and merge it through mine?

Sure, no problem. It's done now, the patch is yours.

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


Re: [PATCH] powerpc: add FHCI USB, FSL MCU, FSL UPM and GPIO LEDs bindings

2008-07-04 Thread Wolfgang Grandegger

Hi Anton,

Anton Vorontsov wrote:

This patch adds few bindings for the new drivers to be submitted through
the appropriate maintainers.

Signed-off-by: Anton Vorontsov [EMAIL PROTECTED]
---

Segher, thanks for the comments on the previous version. Do you see any
issues with this one or anything I could improve further?

And if there are no issues... Kumar, could you apply this for powerpc-next?


As you know, I have some additions to your bindings and I posted a patch 
recently:


  http://ozlabs.org/pipermail/linuxppc-dev/2008-June/058617.html

Segher did not comment yet, maybe you would like to have a look. And do 
you have some news about the corresponding NAND support from the MTD people?


I really appreciate breaking booting-without-of.txt up. Will this happen 
already for powerpc-next (for 2.6.27)?


Thanks,

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


powerpc: fix swapcontext backwards compatibility due to VSX ucontext changes

2008-07-04 Thread Michael Neuling
When the ucontext changed to add the VSX context, this broke backwards
compatibly on swapcontext.  swapcontext only compares the ucontext
size passed in from the user to the new kernel ucontext size.

This adds a check against the old ucontext size (with VMX but without
VSX).  It also adds some sanity check for ucontexts without VSX, but
where VSX is used according the MSR.  Fixes for both 32 and 64bit
processes on 64bit kernels

Kudos to Paulus for noticing.

Signed-off-by: Michael Neuling [EMAIL PROTECTED]
---
Benh: please apply to your 2.6.27 tree.

PS I for one welcome our new powerpc linux maintainer overload :-)

 arch/powerpc/kernel/signal_32.c |   36 +++-
 arch/powerpc/kernel/signal_64.c |   35 +++
 2 files changed, 66 insertions(+), 5 deletions(-)

Index: linux-2.6-ozlabs/arch/powerpc/kernel/signal_32.c
===
--- linux-2.6-ozlabs.orig/arch/powerpc/kernel/signal_32.c
+++ linux-2.6-ozlabs/arch/powerpc/kernel/signal_32.c
@@ -68,6 +68,13 @@
 #define ucontext   ucontext32
 
 /*
+ * Userspace code may pass a ucontext which doesn't include VSX added
+ * at the end.  We need to check for this case.
+ */
+#define UCONTEXTSIZEWITHOUTVSX \
+   (sizeof(struct ucontext) - sizeof(elf_vsrreghalf_t32))
+
+/*
  * Returning 0 means we return to userspace via
  * ret_from_except and thus restore all user
  * registers from *regs.  This is what we need
@@ -930,12 +937,39 @@ long sys_swapcontext(struct ucontext __u
 {
unsigned char tmp;
 
+#ifdef CONFIG_PPC64
+   unsigned long new_msr = 0;
+
+   if (new_ctx 
+   __get_user(new_msr, new_ctx-uc_mcontext.mc_gregs[PT_MSR]))
+   return -EFAULT;
+   if (/*
+* Check that the context is not smaller than the original
+* size (with VMX but without VSX)
+*/
+   (ctx_size  UCONTEXTSIZEWITHOUTVSX) ||
+   /*
+* If userspace doesn't provide enough room for VSX data,
+* but current thread has used VSX, we don't have anywhere
+* to store the full context back into.
+*/
+   ((ctx_size  sizeof(struct ucontext)) 
+(regs-msr  MSR_VSX)  old_ctx) ||
+   /*
+* If the new context state sets the MSR VSX bits but
+* it doesn't provide VSX state.
+*/
+   ((ctx_size  sizeof(struct ucontext)) 
+(new_msr  MSR_VSX)))
+   /* ... computer says n */
+   return -EINVAL;
+#else
/* Context size is for future use. Right now, we only make sure
 * we are passed something we understand
 */
if (ctx_size  sizeof(struct ucontext))
return -EINVAL;
-
+#endif
if (old_ctx != NULL) {
struct mcontext __user *mctx;
 
Index: linux-2.6-ozlabs/arch/powerpc/kernel/signal_64.c
===
--- linux-2.6-ozlabs.orig/arch/powerpc/kernel/signal_64.c
+++ linux-2.6-ozlabs/arch/powerpc/kernel/signal_64.c
@@ -268,6 +268,13 @@ static long setup_trampoline(unsigned in
 }
 
 /*
+ * Userspace code may pass a ucontext which doesn't include VSX added
+ * at the end.  We need to check for this case.
+ */
+#define UCONTEXTSIZEWITHOUTVSX \
+   (sizeof(struct ucontext) - 32*sizeof(long))
+
+/*
  * Handle {get,set,swap}_context operations
  */
 int sys_swapcontext(struct ucontext __user *old_ctx,
@@ -277,10 +284,30 @@ int sys_swapcontext(struct ucontext __us
unsigned char tmp;
sigset_t set;
 
-   /* Context size is for future use. Right now, we only make sure
-* we are passed something we understand
-*/
-   if (ctx_size  sizeof(struct ucontext))
+   unsigned long new_msr = 0;
+
+   if (new_ctx 
+   __get_user(new_msr, new_ctx-uc_mcontext.gp_regs[PT_MSR]))
+   return -EFAULT;
+   if (/*
+* Check that the context is not smaller than the original
+* size (with VMX but without VSX)
+*/
+   (ctx_size  UCONTEXTSIZEWITHOUTVSX) ||
+   /*
+* If userspace doesn't provide enough room for VSX data,
+* but current thread has used VSX, we don't have anywhere
+* to store the full context back into.
+*/
+   ((ctx_size  sizeof(struct ucontext)) 
+(regs-msr  MSR_VSX)  old_ctx) ||
+   /*
+* If the new context state sets the MSR VSX bits but
+* it doesn't provide VSX state.
+*/
+   ((ctx_size  sizeof(struct ucontext)) 
+(new_msr  MSR_VSX)))
+   /* ... computer says No */
return -EINVAL;
 
if (old_ctx != NULL) {
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org

GPIO @ MPC5200

2008-07-04 Thread Andre Schwarz
Sascha, Grant,

I'm running on 2.6.26-rc6 with an MPC5200B based system.

Looks like some (for me) crucial GPIO are touched during boot.
Is this possible ?

Of course I have compiled in GPIO-Lib and specified the GPIOs in the dts.
But no access yet - I'd like to preserve the setup from u-boot...

regards,
Andre

MATRIX VISION GmbH, Talstraße 16, DE-71570 Oppenweiler  - Registergericht: 
Amtsgericht Stuttgart, HRB 271090
Geschäftsführer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] fsl-diu-fb: Update Freescale DIU driver to use page_alloc_exact()

2008-07-04 Thread Timur Tabi


On Jun 30, 2008, at 4:24 PM, Andrew Morton wrote:


This is also incorrect.  We cannot pass u64 or uint64_t into printk at
all.  We do not know what type the architectures uses to implement
them.  It should be cast to a known type.  In this case `unsigned long
long'.


Ok, I'll fix these, but I'm on vacation now and won't get to it for  
another 10 days.


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



Re: [alsa-devel] [PATCH 2/3] ALSA SoC: Add mpc5200-psc I2S driver

2008-07-04 Thread Timur Tabi

[EMAIL PROTECTED] { // PSC2
compatible = fsl,mpc5200b-psc-i2s,fsl,mpc5200-psc-i2s;
cell-index = 1;


cell-index should be zero-based, not one-based.

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


Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-04 Thread Timur Tabi


On Jul 3, 2008, at 12:33 PM, Grant Likely wrote:


Yes, but you hadn't written these functions when I wrote this helper.
:-P.  I believe ASoC v2 makes all this stuff unnecessary, but I'm
waiting for v2 to hit mainline before I port forward.


FYI, it took me about a month to port my drivers to ASoC V2.  I had  
more work than most people because I addressed issues that others  
drivers didn't.  For instance, my CS4270 driver is the only codec  
driver in V2 that supports multiple instances of itself.


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


Update maintainers for powerpc

2008-07-04 Thread Paul Mackerras
This updates the MAINTAINERS entries for powerpc.  It adds Ben H to
the overall Linux for PowerPC entry and makes it clear this covers
both 32-bit and 64-bit machines.  It removes the separate entry we had
for Linux on 64-bit PowerPC where Anton and I were listed as
maintainers - Anton hasn't been involved in the day-to-day maintenance
of the code for several years.  Finally, it removes the entry for the
Linux for PowerPC boot code where Tom Rini was listed as the
maintainer.  That code got completely rewritten when we merged
32-bit and 64-bit, and I and the various platform maintainers have
been maintaining that code since.

Signed-off-by: Paul Mackerras [EMAIL PROTECTED]
---
Linus, could this go in for 2.6.26 please?

diff --git a/MAINTAINERS b/MAINTAINERS
index 8f0ec46..e1b62c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2474,9 +2474,11 @@ M:   [EMAIL PROTECTED]
 W: http://www.hansenpartnership.com/voyager
 S: Maintained
 
-LINUX FOR POWERPC
+LINUX FOR POWERPC (32-BIT AND 64-BIT)
 P: Paul Mackerras
 M: [EMAIL PROTECTED]
+P: Benjamin Herrenschmidt
+M: [EMAIL PROTECTED]
 W: http://www.penguinppc.org/
 L: linuxppc-dev@ozlabs.org
 T: git kernel.org:/pub/scm/linux/kernel/git/paulus/powerpc.git
@@ -2516,13 +2518,6 @@ W:   
http://wiki.secretlab.ca/index.php/Linux_on_Xilinx_Virtex
 L: linuxppc-dev@ozlabs.org
 S: Maintained
 
-LINUX FOR POWERPC BOOT CODE
-P: Tom Rini
-M: [EMAIL PROTECTED]
-W: http://www.penguinppc.org/
-L: linuxppc-dev@ozlabs.org
-S: Maintained
-
 LINUX FOR POWERPC EMBEDDED PPC8XX
 P: Vitaly Bordug
 M: [EMAIL PROTECTED]
@@ -2551,17 +2546,6 @@ P:   Arnaldo Carvalho de Melo
 M: [EMAIL PROTECTED]
 S: Maintained
 
-LINUX FOR 64BIT POWERPC
-P: Paul Mackerras
-M: [EMAIL PROTECTED]
-M: [EMAIL PROTECTED]
-P: Anton Blanchard
-M: [EMAIL PROTECTED]
-M: [EMAIL PROTECTED]
-W: http://www.penguinppc.org/ppc64/
-L: linuxppc-dev@ozlabs.org
-S: Supported
-
 LINUX SECURITY MODULE (LSM) FRAMEWORK
 P: Chris Wright
 M: [EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: powerpc: fix swapcontext backwards compatibility due to VSX ucontext changes

2008-07-04 Thread Paul Mackerras
Michael Neuling writes:

 + /*
 +  * If userspace doesn't provide enough room for VSX data,
 +  * but current thread has used VSX, we don't have anywhere
 +  * to store the full context back into.
 +  */
 + ((ctx_size  sizeof(struct ucontext)) 
 +  (regs-msr  MSR_VSX)  old_ctx) ||

I think we need to check current-thread.used_vsr rather than
regs-msr here (in both instances of this code).

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


Re: [PATCH 1/3] ehea: fix might sleep problem

2008-07-04 Thread Jeff Garzik

Jan-Bernd Themann wrote:

A mutex has to be replaced by spinlocks as it can be called from
a context which does not allow sleeping.
The kzalloc flag GFP_KERNEL has to be replaced by GFP_ATOMIC
for the same reason.

Signed-off-by: Jan-Bernd Themann [EMAIL PROTECTED]


applied 1-3 to 2.6.26


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


Re: [PATCH v3] ibm_newemac: Fixes kernel crashes when speed of cable connected changes

2008-07-04 Thread Jeff Garzik

Stefan Roese wrote:

From: Sathya Narayanan [EMAIL PROTECTED]

The descriptor pointers were not initialized to NIL values, so it was
poiniting to some random addresses which was completely invalid. This
fix takes care of initializing the descriptor to NIL values and clearing
the valid descriptors on clean ring operation.

Signed-off-by: Sathya Narayanan [EMAIL PROTECTED]
Signed-off-by: Stefan Roese [EMAIL PROTECTED]
---
 drivers/net/ibm_newemac/core.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 5d2108c..ca63fa0 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -2719,6 +2719,8 @@ static int __devinit emac_probe(struct of_device *ofdev,
/* Clean rings */
memset(dev-tx_desc, 0, NUM_TX_BUFF * sizeof(struct mal_descriptor));
memset(dev-rx_desc, 0, NUM_RX_BUFF * sizeof(struct mal_descriptor));
+   memset(dev-tx_skb, 0, NUM_TX_BUFF * sizeof(struct sk_buff *));
+   memset(dev-rx_skb, 0, NUM_RX_BUFF * sizeof(struct sk_buff *));
 


applied to 2.6.26


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


Re: [PATCH v2] ibm_newemac: Fixes entry of short packets

2008-07-04 Thread Jeff Garzik

Stefan Roese wrote:

From: Sathya Narayanan [EMAIL PROTECTED]

Short packets has to be discarded by the driver. So this patch addresses the
issue of discarding the short packets of size lesser then ethernet header
size.

Signed-off-by: Sathya Narayanan [EMAIL PROTECTED]
Signed-off-by: Stefan Roese [EMAIL PROTECTED]
---
 drivers/net/ibm_newemac/core.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index ca63fa0..babc79a 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -1636,6 +1636,12 @@ static int emac_poll_rx(void *param, int budget)
goto next;
}
 
+		if (len  ETH_HLEN) {

+   ++dev-estats.rx_dropped_stack;
+   emac_recycle_rx_skb(dev, slot, len);
+   goto next;
+   }
+
if (len  len  EMAC_RX_COPY_THRESH) {


applied 2.6.26


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


Re: [PATCHv2] fs_enet: restore promiscuous and multicast settings in restart()

2008-07-04 Thread Jeff Garzik

Laurent Pinchart wrote:

The restart() function is called when the link state changes and resets
multicast and promiscuous settings. This patch restores those settings at the
end of restart().

Signed-off-by: Laurent Pinchart [EMAIL PROTECTED]
---
 drivers/net/fs_enet/mac-fcc.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index e363211..849afbe 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -463,6 +463,9 @@ static void restart(struct net_device *dev)
else
C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB);
 
+	/* Restore multicast and promiscuous settings */

+   set_multicast_list(dev);
+
S32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT);


applied 2.6.26


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


[PATCH 00/16 v3] powerpc: pSeries Cooperative Memory Overcommitment support

2008-07-04 Thread Robert Jennings
This is version 3 of the full patchset.  Please consider this for 2.6.27.
Only the vio bus patch is changed but with two other patches dropped I
felt it would be clearer to post the full set.

A change was made so that devices not performing DMA operations will not
require modification, therefore the hvc and hvcs driver patches have
been dropped.  The vio bus patch has a more descriptive patch header
now as it is a large addition of code.

Cooperative Memory Overcommitment (CMO) is a pSeries platform feature
that enables the allocation of more memory to a set logical partitions
than is physically present.  For example, a system with 16Gb of memory
can be configured to simultaneously run 3 logical partitions each with
8Gb of memory allocated to them.

The system firmware can page out memory as needed to meet the needs
of each partition.  To minimize the effects of firmware paging memory,
the Collaborative Memory Manager (CMM) driver acts as a balloon driver
to work with firmware to provide memory ahead of any paging needs.

The OS is provided with an entitlement of IO memory for device drivers
to map.  This amount varies with the number of virtual IO adapters
present and can change as devices are hot-plugged.  The VIO bus code
distributes this memory to devices.  Logical partitions supporting CMO
may only have virtual IO devices, physical devices are not supported.
Above the entitled level, IO mappings can fail and the IOMMU needed be
updated to handle this change.

Virtual IO adapters have been updated to handle DMA mapping failures and
to size their entitlement needs.

Platform support for for CMM and hot-plug entitlement events are also
included in the following patches.

The changes should have minimal impact to non-CMO enabled environments.
This patch set has been written against 2.6.26-rc8 and has been tested
at that level.

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


[PATCH 01/16 v3] powerpc: Remove extraneous error reporting for hcall failures in lparcfg

2008-07-04 Thread Robert Jennings
From: Nathan Fontenot [EMAIL PROTECTED]

Remove the extraneous error reporting used when a hcall made from lparcfg fails.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/lparcfg.c |   32 
 1 file changed, 32 deletions(-)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -129,33 +129,6 @@ static int iseries_lparcfg_data(struct s
 /*
  * Methods used to fetch LPAR data when running on a pSeries platform.
  */
-static void log_plpar_hcall_return(unsigned long rc, char *tag)
-{
-   switch(rc) {
-   case 0:
-   return;
-   case H_HARDWARE:
-   printk(KERN_INFO plpar-hcall (%s) 
-   Hardware fault\n, tag);
-   return;
-   case H_FUNCTION:
-   printk(KERN_INFO plpar-hcall (%s) 
-   Function not allowed\n, tag);
-   return;
-   case H_AUTHORITY:
-   printk(KERN_INFO plpar-hcall (%s) 
-   Not authorized to this function\n, tag);
-   return;
-   case H_PARAMETER:
-   printk(KERN_INFO plpar-hcall (%s) 
-   Bad parameter(s)\n,tag);
-   return;
-   default:
-   printk(KERN_INFO plpar-hcall (%s) 
-   Unexpected rc(0x%lx)\n, tag, rc);
-   }
-}
-
 /*
  * H_GET_PPP hcall returns info in 4 parms.
  *  entitled_capacity,unallocated_capacity,
@@ -191,8 +164,6 @@ static unsigned int h_get_ppp(unsigned l
*aggregation = retbuf[2];
*resource = retbuf[3];
 
-   log_plpar_hcall_return(rc, H_GET_PPP);
-
return rc;
 }
 
@@ -205,9 +176,6 @@ static void h_pic(unsigned long *pool_id
 
*pool_idle_time = retbuf[0];
*num_procs = retbuf[1];
-
-   if (rc != H_AUTHORITY)
-   log_plpar_hcall_return(rc, H_PIC);
 }
 
 #define SPLPAR_CHARACTERISTICS_TOKEN 20
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 02/16 v3] powerpc: Split processor entitlement retrieval and gathering to helper routines

2008-07-04 Thread Robert Jennings
From: Nathan Fotenot [EMAIL PROTECTED]

Split the retrieval and setting of processor entitlement and weight into
helper routines.  This also removes the printing of the raw values
returned from h_get_ppp, the values are already parsed and printed.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/lparcfg.c |  168 ++---
 1 file changed, 90 insertions(+), 78 deletions(-)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -167,7 +167,8 @@ static unsigned int h_get_ppp(unsigned l
return rc;
 }
 
-static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
+static unsigned h_pic(unsigned long *pool_idle_time,
+ unsigned long *num_procs)
 {
unsigned long rc;
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
@@ -176,6 +177,53 @@ static void h_pic(unsigned long *pool_id
 
*pool_idle_time = retbuf[0];
*num_procs = retbuf[1];
+
+   return rc;
+}
+
+/*
+ * parse_ppp_data
+ * Parse out the data returned from h_get_ppp and h_pic
+ */
+static void parse_ppp_data(struct seq_file *m)
+{
+   unsigned long h_entitled, h_unallocated;
+   unsigned long h_aggregation, h_resource;
+   int rc;
+
+   rc = h_get_ppp(h_entitled, h_unallocated, h_aggregation,
+  h_resource);
+   if (rc)
+   return;
+
+   seq_printf(m, partition_entitled_capacity=%ld\n, h_entitled);
+   seq_printf(m, group=%ld\n, (h_aggregation  2 * 8)  0x);
+   seq_printf(m, system_active_processors=%ld\n,
+  (h_resource  0 * 8)  0x);
+
+   /* pool related entries are apropriate for shared configs */
+   if (lppaca[0].shared_proc) {
+   unsigned long pool_idle_time, pool_procs;
+
+   seq_printf(m, pool=%ld\n, (h_aggregation  0 * 8)  0x);
+
+   /* report pool_capacity in percentage */
+   seq_printf(m, pool_capacity=%ld\n,
+  ((h_resource  2 * 8)  0x) * 100);
+
+   rc = h_pic(pool_idle_time, pool_procs);
+   if (! rc) {
+   seq_printf(m, pool_idle_time=%ld\n, pool_idle_time);
+   seq_printf(m, pool_num_procs=%ld\n, pool_procs);
+   }
+   }
+
+   seq_printf(m, unallocated_capacity_weight=%ld\n,
+  (h_resource  4 * 8)  0xFF);
+
+   seq_printf(m, capacity_weight=%ld\n, (h_resource  5 * 8)  0xFF);
+   seq_printf(m, capped=%ld\n, (h_resource  6 * 8)  0x01);
+   seq_printf(m, unallocated_capacity=%ld\n, h_unallocated);
 }
 
 #define SPLPAR_CHARACTERISTICS_TOKEN 20
@@ -302,60 +350,11 @@ static int pseries_lparcfg_data(struct s
partition_active_processors = lparcfg_count_active_processors();
 
if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
-   unsigned long h_entitled, h_unallocated;
-   unsigned long h_aggregation, h_resource;
-   unsigned long pool_idle_time, pool_procs;
-   unsigned long purr;
-
-   h_get_ppp(h_entitled, h_unallocated, h_aggregation,
- h_resource);
-
-   seq_printf(m, R4=0x%lx\n, h_entitled);
-   seq_printf(m, R5=0x%lx\n, h_unallocated);
-   seq_printf(m, R6=0x%lx\n, h_aggregation);
-   seq_printf(m, R7=0x%lx\n, h_resource);
-
-   purr = get_purr();
-
/* this call handles the ibm,get-system-parameter contents */
parse_system_parameter_string(m);
+   parse_ppp_data(m);
 
-   seq_printf(m, partition_entitled_capacity=%ld\n, h_entitled);
-
-   seq_printf(m, group=%ld\n, (h_aggregation  2 * 8)  0x);
-
-   seq_printf(m, system_active_processors=%ld\n,
-  (h_resource  0 * 8)  0x);
-
-   /* pool related entries are apropriate for shared configs */
-   if (lppaca[0].shared_proc) {
-
-   h_pic(pool_idle_time, pool_procs);
-
-   seq_printf(m, pool=%ld\n,
-  (h_aggregation  0 * 8)  0x);
-
-   /* report pool_capacity in percentage */
-   seq_printf(m, pool_capacity=%ld\n,
-  ((h_resource  2 * 8)  0x) * 100);
-
-   seq_printf(m, pool_idle_time=%ld\n, pool_idle_time);
-
-   seq_printf(m, pool_num_procs=%ld\n, pool_procs);
-   }
-
-   seq_printf(m, unallocated_capacity_weight=%ld\n,
-  (h_resource  4 * 8)  0xFF);
-
-   seq_printf(m, capacity_weight=%ld\n,
-  (h_resource  5 * 8)  0xFF);
-
-   seq_printf(m, 

[PATCH 03/16 v3] powerpc: Add memory entitlement capabilities to /proc/ppc64/lparcfg

2008-07-04 Thread Robert Jennings
From: Nathan Fontenot [EMAIL PROTECTED]

Update /proc/ppc64/lparcfg to enable displaying of Cooperative Memory
Overcommitment statistics as reported by the H_GET_MPP hcall.  This also
updates the lparcfg interface to allow setting memory entitlement and
weight.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/lparcfg.c |  119 ++
 include/asm-powerpc/hvcall.h  |   18 ++
 2 files changed, 136 insertions(+), 1 deletion(-)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -129,6 +129,35 @@ static int iseries_lparcfg_data(struct s
 /*
  * Methods used to fetch LPAR data when running on a pSeries platform.
  */
+/**
+ * h_get_mpp
+ * H_GET_MPP hcall returns info in 7 parms
+ */
+int h_get_mpp(struct hvcall_mpp_data *mpp_data)
+{
+   int rc;
+   unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+
+   rc = plpar_hcall9(H_GET_MPP, retbuf);
+
+   mpp_data-entitled_mem = retbuf[0];
+   mpp_data-mapped_mem = retbuf[1];
+
+   mpp_data-group_num = (retbuf[2]  2 * 8)  0x;
+   mpp_data-pool_num = retbuf[2]  0x;
+
+   mpp_data-mem_weight = (retbuf[3]  7 * 8)  0xff;
+   mpp_data-unallocated_mem_weight = (retbuf[3]  6 * 8)  0xff;
+   mpp_data-unallocated_entitlement = retbuf[3]  0x;
+
+   mpp_data-pool_size = retbuf[4];
+   mpp_data-loan_request = retbuf[5];
+   mpp_data-backing_mem = retbuf[6];
+
+   return rc;
+}
+EXPORT_SYMBOL(h_get_mpp);
+
 /*
  * H_GET_PPP hcall returns info in 4 parms.
  *  entitled_capacity,unallocated_capacity,
@@ -226,6 +255,44 @@ static void parse_ppp_data(struct seq_fi
seq_printf(m, unallocated_capacity=%ld\n, h_unallocated);
 }
 
+/**
+ * parse_mpp_data
+ * Parse out data returned from h_get_mpp
+ */
+static void parse_mpp_data(struct seq_file *m)
+{
+   struct hvcall_mpp_data mpp_data;
+   int rc;
+
+   rc = h_get_mpp(mpp_data);
+   if (rc)
+   return;
+
+   seq_printf(m, entitled_memory=%ld\n, mpp_data.entitled_mem);
+
+   if (mpp_data.mapped_mem != -1)
+   seq_printf(m, mapped_entitled_memory=%ld\n,
+  mpp_data.mapped_mem);
+
+   seq_printf(m, entitled_memory_group_number=%d\n, mpp_data.group_num);
+   seq_printf(m, entitled_memory_pool_number=%d\n, mpp_data.pool_num);
+
+   seq_printf(m, entitled_memory_weight=%d\n, mpp_data.mem_weight);
+   seq_printf(m, unallocated_entitled_memory_weight=%d\n,
+  mpp_data.unallocated_mem_weight);
+   seq_printf(m, unallocated_io_mapping_entitlement=%ld\n,
+  mpp_data.unallocated_entitlement);
+
+   if (mpp_data.pool_size != -1)
+   seq_printf(m, entitled_memory_pool_size=%ld bytes\n,
+  mpp_data.pool_size);
+
+   seq_printf(m, entitled_memory_loan_request=%ld\n,
+  mpp_data.loan_request);
+
+   seq_printf(m, backing_memory=%ld bytes\n, mpp_data.backing_mem);
+}
+
 #define SPLPAR_CHARACTERISTICS_TOKEN 20
 #define SPLPAR_MAXLENGTH 1026*(sizeof(char))
 
@@ -353,6 +420,7 @@ static int pseries_lparcfg_data(struct s
/* this call handles the ibm,get-system-parameter contents */
parse_system_parameter_string(m);
parse_ppp_data(m);
+   parse_mpp_data(m);
 
seq_printf(m, purr=%ld\n, get_purr());
} else {/* non SPLPAR case */
@@ -416,6 +484,43 @@ static ssize_t update_ppp(u64 *entitleme
return retval;
 }
 
+/**
+ * update_mpp
+ *
+ * Update the memory entitlement and weight for the partition.  Caller must
+ * specify either a new entitlement or weight, not both, to be updated
+ * since the h_set_mpp call takes both entitlement and weight as parameters.
+ */
+static ssize_t update_mpp(u64 *entitlement, u8 *weight)
+{
+   struct hvcall_mpp_data mpp_data;
+   u64 new_entitled;
+   u8 new_weight;
+   ssize_t rc;
+
+   rc = h_get_mpp(mpp_data);
+   if (rc)
+   return rc;
+
+   if (entitlement) {
+   new_weight = mpp_data.mem_weight;
+   new_entitled = *entitlement;
+   } else if (weight) {
+   new_weight = *weight;
+   new_entitled = mpp_data.entitled_mem;
+   } else
+   return -EINVAL;
+
+   pr_debug(%s: current_entitled = %lu, current_weight = %u\n,
+__FUNCTION__, mpp_data.entitled_mem, mpp_data.mem_weight);
+
+   pr_debug(%s: new_entitled = %lu, new_weight = %u\n,
+__FUNCTION__, new_entitled, new_weight);
+
+   rc = plpar_hcall_norets(H_SET_MPP, new_entitled, new_weight);
+   return rc;
+}
+
 /*
  * Interface for changing system parameters (variable capacity weight
  * and entitled capacity).  Format 

[PATCH 04/16 v3] powerpc: Split retrieval of processor entitlement data into a helper routine

2008-07-04 Thread Robert Jennings
From: Nathan Fontenot [EMAIL PROTECTED]

Split the retrieval of processor entitlement data returned in the H_GET_PPP
hcall into its own helper routine.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/lparcfg.c |   80 --
 1 file changed, 45 insertions(+), 35 deletions(-)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -158,6 +158,18 @@ int h_get_mpp(struct hvcall_mpp_data *mp
 }
 EXPORT_SYMBOL(h_get_mpp);
 
+struct hvcall_ppp_data {
+   u64 entitlement;
+   u64 unallocated_entitlement;
+   u16 group_num;
+   u16 pool_num;
+   u8  capped;
+   u8  weight;
+   u8  unallocated_weight;
+   u16 active_procs_in_pool;
+   u16 active_system_procs;
+};
+
 /*
  * H_GET_PPP hcall returns info in 4 parms.
  *  entitled_capacity,unallocated_capacity,
@@ -178,20 +190,24 @@ EXPORT_SYMBOL(h_get_mpp);
  *   - Active processors in Physical Processor Pool.
  *    - Processors active on platform.
  */
-static unsigned int h_get_ppp(unsigned long *entitled,
- unsigned long *unallocated,
- unsigned long *aggregation,
- unsigned long *resource)
+static unsigned int h_get_ppp(struct hvcall_ppp_data *ppp_data)
 {
unsigned long rc;
unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
 
rc = plpar_hcall(H_GET_PPP, retbuf);
 
-   *entitled = retbuf[0];
-   *unallocated = retbuf[1];
-   *aggregation = retbuf[2];
-   *resource = retbuf[3];
+   ppp_data-entitlement = retbuf[0];
+   ppp_data-unallocated_entitlement = retbuf[1];
+
+   ppp_data-group_num = (retbuf[2]  2 * 8)  0x;
+   ppp_data-pool_num = retbuf[2]  0x;
+
+   ppp_data-capped = (retbuf[3]  6 * 8)  0x01;
+   ppp_data-weight = (retbuf[3]  5 * 8)  0xff;
+   ppp_data-unallocated_weight = (retbuf[3]  4 * 8)  0xff;
+   ppp_data-active_procs_in_pool = (retbuf[3]  2 * 8)  0x;
+   ppp_data-active_system_procs = retbuf[3]  0x;
 
return rc;
 }
@@ -216,29 +232,27 @@ static unsigned h_pic(unsigned long *poo
  */
 static void parse_ppp_data(struct seq_file *m)
 {
-   unsigned long h_entitled, h_unallocated;
-   unsigned long h_aggregation, h_resource;
+   struct hvcall_ppp_data ppp_data;
int rc;
 
-   rc = h_get_ppp(h_entitled, h_unallocated, h_aggregation,
-  h_resource);
+   rc = h_get_ppp(ppp_data);
if (rc)
return;
 
-   seq_printf(m, partition_entitled_capacity=%ld\n, h_entitled);
-   seq_printf(m, group=%ld\n, (h_aggregation  2 * 8)  0x);
-   seq_printf(m, system_active_processors=%ld\n,
-  (h_resource  0 * 8)  0x);
+   seq_printf(m, partition_entitled_capacity=%ld\n,
+  ppp_data.entitlement);
+   seq_printf(m, group=%d\n, ppp_data.group_num);
+   seq_printf(m, system_active_processors=%d\n,
+  ppp_data.active_system_procs);
 
/* pool related entries are apropriate for shared configs */
if (lppaca[0].shared_proc) {
unsigned long pool_idle_time, pool_procs;
 
-   seq_printf(m, pool=%ld\n, (h_aggregation  0 * 8)  0x);
+   seq_printf(m, pool=%d\n, ppp_data.pool_num);
 
/* report pool_capacity in percentage */
-   seq_printf(m, pool_capacity=%ld\n,
-  ((h_resource  2 * 8)  0x) * 100);
+   seq_printf(m, pool_capacity=%d\n, ppp_data.group_num * 100);
 
rc = h_pic(pool_idle_time, pool_procs);
if (! rc) {
@@ -247,12 +261,12 @@ static void parse_ppp_data(struct seq_fi
}
}
 
-   seq_printf(m, unallocated_capacity_weight=%ld\n,
-  (h_resource  4 * 8)  0xFF);
-
-   seq_printf(m, capacity_weight=%ld\n, (h_resource  5 * 8)  0xFF);
-   seq_printf(m, capped=%ld\n, (h_resource  6 * 8)  0x01);
-   seq_printf(m, unallocated_capacity=%ld\n, h_unallocated);
+   seq_printf(m, unallocated_capacity_weight=%d\n,
+  ppp_data.unallocated_weight);
+   seq_printf(m, capacity_weight=%d\n, ppp_data.weight);
+   seq_printf(m, capped=%d\n, ppp_data.capped);
+   seq_printf(m, unallocated_capacity=%ld\n,
+  ppp_data.unallocated_entitlement);
 }
 
 /**
@@ -451,31 +465,27 @@ static int pseries_lparcfg_data(struct s
 
 static ssize_t update_ppp(u64 *entitlement, u8 *weight)
 {
-   unsigned long current_entitled;
-   unsigned long dummy;
-   unsigned long resource;
-   u8 current_weight, new_weight;
+   struct hvcall_ppp_data ppp_data;
+   u8 new_weight;
u64 

[PATCH 05/16 v3] powerpc: Enable CMO feature during platform setup

2008-07-04 Thread Robert Jennings
From: Robert Jennings [EMAIL PROTECTED]

For Cooperative Memory Overcommitment (CMO), set the FW_FEATURE_CMO
flag in powerpc_firmware_features from the rtas ibm,get-system-parameters
table prior to calling iommu_init_early_pSeries.

With this, any CMO specific functionality can be controlled by checking:
 firmware_has_feature(FW_FEATURE_CMO)

Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/platforms/pseries/setup.c |   71 +
 include/asm-powerpc/firmware.h |3 +
 2 files changed, 73 insertions(+), 1 deletion(-)

Index: b/arch/powerpc/platforms/pseries/setup.c
===
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -314,6 +314,76 @@ static int pseries_set_xdabr(unsigned lo
H_DABRX_KERNEL | H_DABRX_USER);
 }
 
+#define CMO_CHARACTERISTICS_TOKEN 44
+#define CMO_MAXLENGTH 1026
+
+/**
+ * fw_cmo_feature_init - FW_FEATURE_CMO is not stored in 
ibm,hypertas-functions,
+ * handle that here. (Stolen from parse_system_parameter_string)
+ */
+void pSeries_cmo_feature_init(void)
+{
+   char *ptr, *key, *value, *end;
+   int call_status;
+   int PrPSP = -1;
+   int SecPSP = -1;
+
+   pr_debug( - fw_cmo_feature_init()\n);
+   spin_lock(rtas_data_buf_lock);
+   memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
+   call_status = rtas_call(rtas_token(ibm,get-system-parameter), 3, 1,
+   NULL,
+   CMO_CHARACTERISTICS_TOKEN,
+   __pa(rtas_data_buf),
+   RTAS_DATA_BUF_SIZE);
+
+   if (call_status != 0) {
+   spin_unlock(rtas_data_buf_lock);
+   pr_debug(CMO not available\n);
+   pr_debug( - fw_cmo_feature_init()\n);
+   return;
+   }
+
+   end = rtas_data_buf + CMO_MAXLENGTH - 2;
+   ptr = rtas_data_buf + 2;/* step over strlen value */
+   key = value = ptr;
+
+   while (*ptr  (ptr = end)) {
+   /* Separate the key and value by replacing '=' with '\0' and
+* point the value at the string after the '='
+*/
+   if (ptr[0] == '=') {
+   ptr[0] = '\0';
+   value = ptr + 1;
+   } else if (ptr[0] == '\0' || ptr[0] == ',') {
+   /* Terminate the string containing the key/value pair */
+   ptr[0] = '\0';
+
+   if (key == value) {
+   pr_debug(Malformed key/value pair\n);
+   /* Never found a '=', end processing */
+   break;
+   }
+
+   if (0 == strcmp(key, PrPSP))
+   PrPSP = simple_strtoul(value, NULL, 10);
+   else if (0 == strcmp(key, SecPSP))
+   SecPSP = simple_strtoul(value, NULL, 10);
+   value = key = ptr + 1;
+   }
+   ptr++;
+   }
+
+   if (PrPSP != -1 || SecPSP != -1) {
+   pr_info(CMO enabled\n);
+   pr_debug(CMO enabled, PrPSP=%d, SecPSP=%d\n, PrPSP, SecPSP);
+   powerpc_firmware_features |= FW_FEATURE_CMO;
+   } else
+   pr_debug(CMO not enabled, PrPSP=%d, SecPSP=%d\n, PrPSP, 
SecPSP);
+   spin_unlock(rtas_data_buf_lock);
+   pr_debug( - fw_cmo_feature_init()\n);
+}
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
@@ -329,6 +399,7 @@ static void __init pSeries_init_early(vo
else if (firmware_has_feature(FW_FEATURE_XDABR))
ppc_md.set_dabr = pseries_set_xdabr;
 
+   pSeries_cmo_feature_init();
iommu_init_early_pSeries();
 
pr_debug( - pSeries_init_early()\n);
Index: b/include/asm-powerpc/firmware.h
===
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -45,6 +45,7 @@
 #define FW_FEATURE_PS3_LV1 ASM_CONST(0x0080)
 #define FW_FEATURE_BEATASM_CONST(0x0100)
 #define FW_FEATURE_BULK_REMOVE ASM_CONST(0x0200)
+#define FW_FEATURE_CMO ASM_CONST(0x0400)
 
 #ifndef __ASSEMBLY__
 
@@ -57,7 +58,7 @@ enum {
FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE |
-   FW_FEATURE_SPLPAR | FW_FEATURE_LPAR,
+   FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | FW_FEATURE_CMO,
FW_FEATURE_PSERIES_ALWAYS = 0,
FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | 

[PATCH 05/16 v3] powerpc: Enable CMO feature during platform setup

2008-07-04 Thread Robert Jennings
From: Robert Jennings [EMAIL PROTECTED]

For Cooperative Memory Overcommitment (CMO), set the FW_FEATURE_CMO
flag in powerpc_firmware_features from the rtas ibm,get-system-parameters
table prior to calling iommu_init_early_pSeries.

With this, any CMO specific functionality can be controlled by checking:
 firmware_has_feature(FW_FEATURE_CMO)

Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/platforms/pseries/setup.c |   71 +
 include/asm-powerpc/firmware.h |3 +
 2 files changed, 73 insertions(+), 1 deletion(-)

Index: b/arch/powerpc/platforms/pseries/setup.c
===
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -314,6 +314,76 @@ static int pseries_set_xdabr(unsigned lo
H_DABRX_KERNEL | H_DABRX_USER);
 }
 
+#define CMO_CHARACTERISTICS_TOKEN 44
+#define CMO_MAXLENGTH 1026
+
+/**
+ * fw_cmo_feature_init - FW_FEATURE_CMO is not stored in 
ibm,hypertas-functions,
+ * handle that here. (Stolen from parse_system_parameter_string)
+ */
+void pSeries_cmo_feature_init(void)
+{
+   char *ptr, *key, *value, *end;
+   int call_status;
+   int PrPSP = -1;
+   int SecPSP = -1;
+
+   pr_debug( - fw_cmo_feature_init()\n);
+   spin_lock(rtas_data_buf_lock);
+   memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
+   call_status = rtas_call(rtas_token(ibm,get-system-parameter), 3, 1,
+   NULL,
+   CMO_CHARACTERISTICS_TOKEN,
+   __pa(rtas_data_buf),
+   RTAS_DATA_BUF_SIZE);
+
+   if (call_status != 0) {
+   spin_unlock(rtas_data_buf_lock);
+   pr_debug(CMO not available\n);
+   pr_debug( - fw_cmo_feature_init()\n);
+   return;
+   }
+
+   end = rtas_data_buf + CMO_MAXLENGTH - 2;
+   ptr = rtas_data_buf + 2;/* step over strlen value */
+   key = value = ptr;
+
+   while (*ptr  (ptr = end)) {
+   /* Separate the key and value by replacing '=' with '\0' and
+* point the value at the string after the '='
+*/
+   if (ptr[0] == '=') {
+   ptr[0] = '\0';
+   value = ptr + 1;
+   } else if (ptr[0] == '\0' || ptr[0] == ',') {
+   /* Terminate the string containing the key/value pair */
+   ptr[0] = '\0';
+
+   if (key == value) {
+   pr_debug(Malformed key/value pair\n);
+   /* Never found a '=', end processing */
+   break;
+   }
+
+   if (0 == strcmp(key, PrPSP))
+   PrPSP = simple_strtoul(value, NULL, 10);
+   else if (0 == strcmp(key, SecPSP))
+   SecPSP = simple_strtoul(value, NULL, 10);
+   value = key = ptr + 1;
+   }
+   ptr++;
+   }
+
+   if (PrPSP != -1 || SecPSP != -1) {
+   pr_info(CMO enabled\n);
+   pr_debug(CMO enabled, PrPSP=%d, SecPSP=%d\n, PrPSP, SecPSP);
+   powerpc_firmware_features |= FW_FEATURE_CMO;
+   } else
+   pr_debug(CMO not enabled, PrPSP=%d, SecPSP=%d\n, PrPSP, 
SecPSP);
+   spin_unlock(rtas_data_buf_lock);
+   pr_debug( - fw_cmo_feature_init()\n);
+}
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
@@ -329,6 +399,7 @@ static void __init pSeries_init_early(vo
else if (firmware_has_feature(FW_FEATURE_XDABR))
ppc_md.set_dabr = pseries_set_xdabr;
 
+   pSeries_cmo_feature_init();
iommu_init_early_pSeries();
 
pr_debug( - pSeries_init_early()\n);
Index: b/include/asm-powerpc/firmware.h
===
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -45,6 +45,7 @@
 #define FW_FEATURE_PS3_LV1 ASM_CONST(0x0080)
 #define FW_FEATURE_BEATASM_CONST(0x0100)
 #define FW_FEATURE_BULK_REMOVE ASM_CONST(0x0200)
+#define FW_FEATURE_CMO ASM_CONST(0x0400)
 
 #ifndef __ASSEMBLY__
 
@@ -57,7 +58,7 @@ enum {
FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE |
-   FW_FEATURE_SPLPAR | FW_FEATURE_LPAR,
+   FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | FW_FEATURE_CMO,
FW_FEATURE_PSERIES_ALWAYS = 0,
FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | 

[PATCH 06/16 v3] powerpc: Utilities to set firmware page state

2008-07-04 Thread Robert Jennings
From: Brian King [EMAIL PROTECTED]

Newer versions of firmware support page states, which are used by the
collaborative memory manager (future patch) to loan pages to the
hypervisor for use by other partitions.

Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 arch/powerpc/platforms/pseries/plpar_wrappers.h |   10 ++
 include/asm-powerpc/hvcall.h|5 +
 2 files changed, 15 insertions(+)

Index: b/arch/powerpc/platforms/pseries/plpar_wrappers.h
===
--- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ b/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -42,6 +42,16 @@ static inline long register_slb_shadow(u
return vpa_call(0x3, cpu, vpa);
 }
 
+static inline long plpar_page_set_loaned(unsigned long vpa)
+{
+   return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa, 0);
+}
+
+static inline long plpar_page_set_active(unsigned long vpa)
+{
+   return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa, 0);
+}
+
 extern void vpa_init(int cpu);
 
 static inline long plpar_pte_enter(unsigned long flags,
Index: b/include/asm-powerpc/hvcall.h
===
--- a/include/asm-powerpc/hvcall.h
+++ b/include/asm-powerpc/hvcall.h
@@ -92,6 +92,11 @@
 #define H_EXACT(1UL(63-24))  /* Use exact PTE or 
return H_PTEG_FULL */
 #define H_R_XLATE  (1UL(63-25))  /* include a valid logical page 
num in the pte if the valid bit is set */
 #define H_READ_4   (1UL(63-26))  /* Return 4 PTEs */
+#define H_PAGE_STATE_CHANGE(1UL(63-28))
+#define H_PAGE_UNUSED  ((1UL(63-29)) | (1UL(63-30)))
+#define H_PAGE_SET_UNUSED  (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)
+#define H_PAGE_SET_LOANED  (H_PAGE_SET_UNUSED | (1UL(63-31)))
+#define H_PAGE_SET_ACTIVE  H_PAGE_STATE_CHANGE
 #define H_AVPN (1UL(63-32))  /* An avpn is provided as a 
sanity test */
 #define H_ANDCOND  (1UL(63-33))
 #define H_ICACHE_INVALIDATE(1UL(63-40))  /* icbi, etc.  (ignored for IO 
pages) */
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 06/16 v3] powerpc: Utilities to set firmware page state

2008-07-04 Thread Robert Jennings
From: Brian King [EMAIL PROTECTED]

Newer versions of firmware support page states, which are used by the
collaborative memory manager (future patch) to loan pages to the
hypervisor for use by other partitions.

Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 arch/powerpc/platforms/pseries/plpar_wrappers.h |   10 ++
 include/asm-powerpc/hvcall.h|5 +
 2 files changed, 15 insertions(+)

Index: b/arch/powerpc/platforms/pseries/plpar_wrappers.h
===
--- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ b/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -42,6 +42,16 @@ static inline long register_slb_shadow(u
return vpa_call(0x3, cpu, vpa);
 }
 
+static inline long plpar_page_set_loaned(unsigned long vpa)
+{
+   return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa, 0);
+}
+
+static inline long plpar_page_set_active(unsigned long vpa)
+{
+   return plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa, 0);
+}
+
 extern void vpa_init(int cpu);
 
 static inline long plpar_pte_enter(unsigned long flags,
Index: b/include/asm-powerpc/hvcall.h
===
--- a/include/asm-powerpc/hvcall.h
+++ b/include/asm-powerpc/hvcall.h
@@ -92,6 +92,11 @@
 #define H_EXACT(1UL(63-24))  /* Use exact PTE or 
return H_PTEG_FULL */
 #define H_R_XLATE  (1UL(63-25))  /* include a valid logical page 
num in the pte if the valid bit is set */
 #define H_READ_4   (1UL(63-26))  /* Return 4 PTEs */
+#define H_PAGE_STATE_CHANGE(1UL(63-28))
+#define H_PAGE_UNUSED  ((1UL(63-29)) | (1UL(63-30)))
+#define H_PAGE_SET_UNUSED  (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)
+#define H_PAGE_SET_LOANED  (H_PAGE_SET_UNUSED | (1UL(63-31)))
+#define H_PAGE_SET_ACTIVE  H_PAGE_STATE_CHANGE
 #define H_AVPN (1UL(63-32))  /* An avpn is provided as a 
sanity test */
 #define H_ANDCOND  (1UL(63-33))
 #define H_ICACHE_INVALIDATE(1UL(63-40))  /* icbi, etc.  (ignored for IO 
pages) */
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 07/16 v3] powerpc: Add collaborative memory manager

2008-07-04 Thread Robert Jennings
From: Brian King [EMAIL PROTECTED]

Adds a collaborative memory manager, which acts as a simple balloon driver
for System p machines that support cooperative memory overcommitment
(CMO).

Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 arch/powerpc/platforms/pseries/Kconfig  |   11 +
 arch/powerpc/platforms/pseries/Makefile |1 +
 arch/powerpc/platforms/pseries/cmm.c|  468 
 3 files changed, 480 insertions(+)

Index: b/arch/powerpc/platforms/pseries/Kconfig
===
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -39,3 +39,14 @@ config PPC_PSERIES_DEBUG
depends on PPC_PSERIES  PPC_EARLY_DEBUG
bool Enable extra debug logging in platforms/pseries
default y
+
+config CMM
+   tristate Collaborative memory management
+   depends on PPC_PSERIES
+   help
+ Select this option, if you want to enable the kernel interface
+ to reduce the memory size of the system. This is accomplished
+ by allocating pages of memory and put them on hold. This only
+ makes sense for a system running in an LPAR where the unused pages
+ will be reused for other LPARs. The interface allows firmware to
+ balance memory across many LPARs.
Index: b/arch/powerpc/platforms/pseries/Makefile
===
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
 obj-$(CONFIG_HVCS) += hvcserver.o
 obj-$(CONFIG_HCALL_STATS)  += hvCall_inst.o
 obj-$(CONFIG_PHYP_DUMP)+= phyp_dump.o
+obj-$(CONFIG_CMM)  += cmm.o
Index: b/arch/powerpc/platforms/pseries/cmm.c
===
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -0,0 +1,468 @@
+/*
+ * Collaborative memory management interface.
+ *
+ * Copyright (C) 2008 IBM Corporation
+ * Author(s): Brian King ([EMAIL PROTECTED]),
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include linux/ctype.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/fs.h
+#include linux/init.h
+#include linux/kthread.h
+#include linux/module.h
+#include linux/oom.h
+#include linux/sched.h
+#include linux/stringify.h
+#include linux/swap.h
+#include linux/sysdev.h
+#include asm/firmware.h
+#include asm/hvcall.h
+#include asm/mmu.h
+#include asm/pgalloc.h
+#include asm/uaccess.h
+
+#include plpar_wrappers.h
+
+#define CMM_DRIVER_VERSION 1.0.0
+#define CMM_DEFAULT_DELAY  1
+#define CMM_DEBUG  0
+#define CMM_DISABLE0
+#define CMM_OOM_KB 1024
+#define CMM_MIN_MEM_MB 256
+#define KB2PAGES(_p)   ((_p)(PAGE_SHIFT-10))
+#define PAGES2KB(_p)   ((_p)(PAGE_SHIFT-10))
+
+static unsigned int delay = CMM_DEFAULT_DELAY;
+static unsigned int oom_kb = CMM_OOM_KB;
+static unsigned int cmm_debug = CMM_DEBUG;
+static unsigned int cmm_disabled = CMM_DISABLE;
+static unsigned long min_mem_mb = CMM_MIN_MEM_MB;
+static struct sys_device cmm_sysdev;
+
+MODULE_AUTHOR(Brian King [EMAIL PROTECTED]);
+MODULE_DESCRIPTION(IBM System p Collaborative Memory Manager);
+MODULE_LICENSE(GPL);
+MODULE_VERSION(CMM_DRIVER_VERSION);
+
+module_param_named(delay, delay, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(delay, Delay (in seconds) between polls to query hypervisor 
paging requests. 
+[Default= __stringify(CMM_DEFAULT_DELAY) ]);
+module_param_named(oom_kb, oom_kb, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(oom_kb, Amount of memory in kb to free on OOM. 
+[Default= __stringify(CMM_OOM_KB) ]);
+module_param_named(min_mem_mb, min_mem_mb, ulong, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(min_mem_mb, Minimum amount of memory (in MB) to not balloon. 

+[Default= __stringify(CMM_MIN_MEM_MB) ]);
+module_param_named(debug, cmm_debug, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, Enable module debugging logging. Set to 1 to enable. 
+[Default= __stringify(CMM_DEBUG) ]);
+
+#define CMM_NR_PAGES ((PAGE_SIZE - 

[PATCH 08/16 v3] powerpc: Do not probe PCI buses or eBus devices if CMO is enabled

2008-07-04 Thread Robert Jennings
From: Brian King [EMAIL PROTECTED]

The Cooperative Memory Overcommit (CMO) on System p does not currently
support native PCI devices or eBus devices when enabled. Prevent
PCI bus probe and eBus device probe if the feature is enabled.

Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 arch/powerpc/kernel/ibmebus.c  |6 ++
 arch/powerpc/platforms/pseries/setup.c |4 
 2 files changed, 10 insertions(+)

Index: b/arch/powerpc/kernel/ibmebus.c
===
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -45,6 +45,7 @@
 #include linux/of_platform.h
 #include asm/ibmebus.h
 #include asm/abs_addr.h
+#include asm/firmware.h
 
 static struct device ibmebus_bus_device = { /* fake parent device */
.bus_id = ibmebus,
@@ -332,6 +333,11 @@ static int __init ibmebus_bus_init(void)
 {
int err;
 
+   if (firmware_has_feature(FW_FEATURE_CMO)) {
+   printk(KERN_WARNING Not probing eBus since CMO is enabled\n);
+   return 0;
+   }
+
printk(KERN_INFO IBM eBus Device Driver\n);
 
err = of_bus_type_init(ibmebus_bus_type, ibmebus);
Index: b/arch/powerpc/platforms/pseries/setup.c
===
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -539,6 +539,10 @@ static void pseries_shared_idle_sleep(vo
 
 static int pSeries_pci_probe_mode(struct pci_bus *bus)
 {
+   if (firmware_has_feature(FW_FEATURE_CMO)) {
+   dev_warn(bus-dev, Not probing PCI bus since CMO is 
enabled\n);
+   return PCI_PROBE_NONE;
+   }
if (firmware_has_feature(FW_FEATURE_LPAR))
return PCI_PROBE_DEVTREE;
return PCI_PROBE_NORMAL;
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 09/16 v3] powerpc: Add CMO paging statistics

2008-07-04 Thread Robert Jennings
From: Brian King [EMAIL PROTECTED]

With the addition of Cooperative Memory Overcommitment (CMO) support
for IBM Power Systems, two fields have been added to the VPA to report
paging statistics. Add support in lparcfg to report them to userspace.

Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 arch/powerpc/kernel/lparcfg.c |   20 
 include/asm-powerpc/lppaca.h  |5 -
 2 files changed, 24 insertions(+), 1 deletion(-)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -410,6 +410,25 @@ static int lparcfg_count_active_processo
return count;
 }
 
+static void pseries_cmo_data(struct seq_file *m)
+{
+   int cpu;
+   unsigned long cmo_faults = 0;
+   unsigned long cmo_fault_time = 0;
+
+   if (!firmware_has_feature(FW_FEATURE_CMO))
+   return;
+
+   for_each_possible_cpu(cpu) {
+   cmo_faults += lppaca[cpu].cmo_faults;
+   cmo_fault_time += lppaca[cpu].cmo_fault_time;
+   }
+
+   seq_printf(m, cmo_faults=%lu\n, cmo_faults);
+   seq_printf(m, cmo_fault_time_usec=%lu\n,
+  cmo_fault_time / tb_ticks_per_usec);
+}
+
 static int pseries_lparcfg_data(struct seq_file *m, void *v)
 {
int partition_potential_processors;
@@ -435,6 +454,7 @@ static int pseries_lparcfg_data(struct s
parse_system_parameter_string(m);
parse_ppp_data(m);
parse_mpp_data(m);
+   pseries_cmo_data(m);
 
seq_printf(m, purr=%ld\n, get_purr());
} else {/* non SPLPAR case */
Index: b/include/asm-powerpc/lppaca.h
===
--- a/include/asm-powerpc/lppaca.h
+++ b/include/asm-powerpc/lppaca.h
@@ -125,7 +125,10 @@ struct lppaca {
// NOTE: This value will ALWAYS be zero for dedicated processors and
// will NEVER be zero for shared processors (ie, initialized to a 1).
volatile u32 yield_count;   // PLIC increments each dispatchx00-x03
-   u8  reserved6[124]; // Reserved x04-x7F
+   u32 reserved6;
+   volatile u64 cmo_faults;// CMO page fault count x08-x0F
+   volatile u64 cmo_fault_time;// CMO page fault time  x10-x17
+   u8  reserved7[104]; // Reserved x18-x7F
 
 //=
 // CACHE_LINE_4-5 0x0180 - 0x027F Contains PMC interrupt data
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 10/16 v3] powerpc: iommu enablement for CMO

2008-07-04 Thread Robert Jennings
To support Cooperative Memory Overcommitment (CMO), we need to check
for failure from some of the tce hcalls.

These changes for the pseries platform affect the powerpc architecture;
patches for the other affected platforms are included in this patch.

pSeries platform IOMMU code changes:
 * platform TCE functions must handle H_NOT_ENOUGH_RESOURCES errors and
   return an error.

Architecture IOMMU code changes:
 * Calls to ppc_md.tce_build need to check return values and return
   DMA_MAPPING_ERROR for transient errors.

Architecture changes:
 * struct machdep_calls for tce_build*_pSeriesLP functions need to change
   to indicate failure.
 * all other platforms will need updates to iommu functions to match the new
   calling semantics; they will return 0 on success.  The other platforms
   default configs have been built, but no further testing was performed.

Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/iommu.c|   26 +
 arch/powerpc/platforms/cell/iommu.c|3 ++-
 arch/powerpc/platforms/iseries/iommu.c |3 ++-
 arch/powerpc/platforms/pasemi/iommu.c  |3 ++-
 arch/powerpc/platforms/pseries/iommu.c |   34 -
 arch/powerpc/sysdev/dart_iommu.c   |3 ++-
 include/asm-powerpc/machdep.h  |2 +-
 7 files changed, 60 insertions(+), 14 deletions(-)

Index: b/arch/powerpc/kernel/iommu.c
===
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -49,6 +49,8 @@ static int novmerge = 1;
 
 static int protect4gb = 1;
 
+static void __iommu_free(struct iommu_table *, dma_addr_t, unsigned int);
+
 static inline unsigned long iommu_num_pages(unsigned long vaddr,
unsigned long slen)
 {
@@ -190,6 +192,7 @@ static dma_addr_t iommu_alloc(struct dev
 {
unsigned long entry, flags;
dma_addr_t ret = DMA_ERROR_CODE;
+   int build_fail;
 
spin_lock_irqsave((tbl-it_lock), flags);
 
@@ -204,9 +207,21 @@ static dma_addr_t iommu_alloc(struct dev
ret = entry  IOMMU_PAGE_SHIFT;/* Set the return dma address */
 
/* Put the TCEs in the HW table */
-   ppc_md.tce_build(tbl, entry, npages, (unsigned long)page  
IOMMU_PAGE_MASK,
-direction);
+   build_fail = ppc_md.tce_build(tbl, entry, npages,
+ (unsigned long)page  IOMMU_PAGE_MASK,
+ direction);
+
+   /* ppc_md.tce_build() only returns non-zero for transient errors.
+* Clean up the table bitmap in this case and return
+* DMA_ERROR_CODE. For all other errors the functionality is
+* not altered.
+*/
+   if (unlikely(build_fail)) {
+   __iommu_free(tbl, ret, npages);
 
+   spin_unlock_irqrestore((tbl-it_lock), flags);
+   return DMA_ERROR_CODE;
+   }
 
/* Flush/invalidate TLB caches if necessary */
if (ppc_md.tce_flush)
@@ -275,7 +290,7 @@ int iommu_map_sg(struct device *dev, str
dma_addr_t dma_next = 0, dma_addr;
unsigned long flags;
struct scatterlist *s, *outs, *segstart;
-   int outcount, incount, i;
+   int outcount, incount, i, build_fail = 0;
unsigned int align;
unsigned long handle;
unsigned int max_seg_size;
@@ -336,7 +351,10 @@ int iommu_map_sg(struct device *dev, str
npages, entry, dma_addr);
 
/* Insert into HW table */
-   ppc_md.tce_build(tbl, entry, npages, vaddr  IOMMU_PAGE_MASK, 
direction);
+   build_fail = ppc_md.tce_build(tbl, entry, npages,
+ vaddr  IOMMU_PAGE_MASK, 
direction);
+   if(unlikely(build_fail))
+   goto failure;
 
/* If we are in an open segment, try merging */
if (segstart != s) {
Index: b/arch/powerpc/platforms/cell/iommu.c
===
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -172,7 +172,7 @@ static void invalidate_tce_cache(struct 
}
 }
 
-static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
+static int tce_build_cell(struct iommu_table *tbl, long index, long npages,
unsigned long uaddr, enum dma_data_direction direction)
 {
int i;
@@ -210,6 +210,7 @@ static void tce_build_cell(struct iommu_
 
pr_debug(tce_build_cell(index=%lx,n=%lx,dir=%d,base_pte=%lx)\n,
 index, npages, direction, base_pte);
+   return 0;
 }
 
 static void tce_free_cell(struct iommu_table *tbl, long index, long npages)
Index: b/arch/powerpc/platforms/iseries/iommu.c
===
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ 

[PATCH 11/16 v3] powerpc: vio bus support for CMO

2008-07-04 Thread Robert Jennings
From: Robert Jennings [EMAIL PROTECTED]

This is a large patch but the normal code path is not affected.  For
non-pSeries platforms the code is ifdef'ed out and for non-CMO enabled
pSeries systems this does not affect the normal code path.  Devices that
do not perform DMA operations do not need modification with this patch.
The function get_desired_dma was renamed from get_io_entitlement for
clarity.

Overview

Cooperative Memory Overcommitment (CMO) allows for a set of OS partitions
to be run with less RAM than the aggregate needs of the group of
partitions.  The firmware will balance memory between the partitions
and page in/out memory as needed.  Based on the number and type of IO
adpaters preset each partition is allocated an amount of memory for
DMA operations and this allocation will be guaranteed to the partition;
this is referred to as the partition's 'entitlement'.

Partitions running in a CMO environment can only have virtual IO devices
present.  The VIO bus layer will manage the IO entitlement for the system.
Accounting, at a system and per-device level, is tracked in the VIO bus
code and exposed via sysfs.  A set of dma_ops functions are added to
the bus to allow for this accounting.

Bus initialization

At initialization, the bus will calculate the minimum needs of the system
based on providing each device present with a standard minimum entitlement
along with a spare allocation for the bus to handle hotplug events.
If the minimum needs can not be met the system boot will be halted.

Device changes

The significant changes for devices while running under CMO are that the
devices must specify how much dedicated IO entitlement they desire and
must also handle DMA mapping errors that can occur due to constrained
IO memory.  The virtual IO drivers are modified to silence errors when
DMA mappings fail for CMO and handle these failures gracefully.

Each devices will be guaranteed a minimum entitlement that can always
be mapped.  Devices will specify how much entitlement they desire and
the VIO bus will attempt to provide for this.  Devices can change their
desired entitlement level at any point in time to address particular needs
(via vio_cmo_set_dev_desired()), not just at device probe time.

VIO bus changes

The system will have a particular entitlement level available from which
it can provide memory to the devices.  The bus defines two pools of memory
within this entitlement, the reserved and excess pools.  Each device is
provided with it's own entitlement no less than a system defined minimum
entitlement and no greater than what the device has specified as it's
desired entitlement.  The entitlement provided to devices comes from the
reserve pool.  The reserve pool can also contain a spare allocation as
large as the system defined minimum entitlement which is used for device
hotplug events.  Any entitlement not needed to fulfill the needs of a
reserve pool is placed in the excess pool.  Each device is guaranteed
that it can map up to it's entitled level; additional mapping are possible
as long as there is unmapped memory in the excess pool.

Bus probe

As the system starts, each device is given an entitlement equal only
to the system defined minimum entitlement.  The reserve pool is equal
to the sum of these entitlements, plus a spare allocation.  The VIO bus
also tracks the aggregate desired entitlement of all the devices.  If the
system desired entitlement is greater than the size of the reserve pool,
when devices unmap IO memory it will be reserved and a balance operation
will be scheduled for some time in the future.

Entitlement balancing

The balance function tries to fairly distribute entitlement between the
devices in the system with the goal of providing each device with it's
desired amount of entitlement.  Devices using more than what would be
ideal will have their entitled set-point adjusted; this will effectively
set a goal for lower IO memory usage as future mappings can fail and
deallocations will trigger a balance operation to distribute the newly
unmapped memory.  A fair distribution of entitlement can take several
balance operations to achieve.  Entitlement changes and device DLPAR
events will alter the state of CMO and will trigger balance operations.

Hotplug events

The VIO bus allows for changes in system entitlement at run-time via
'vio_cmo_entitlement_update()'.  When devices are added the hotplug
device event will be preceded by a system entitlement increase and this
is reversed when devices are removed.

The following changes are made that the VIO bus layer for CMO:
 * add IO memory accounting per device structure.
 * add IO memory entitlement query function to driver structure.
 * during vio bus probe, if CMO is enabled, check that driver has
   memory entitlement query function defined.  Fail if function not defined.
 * fail to register driver if io entitlement function not defined.
 * create set of dma_ops at vio level for CMO that will track allocations
   and 

[PATCH 12/16 v3] powerpc: Verify CMO memory entitlement updates with virtual I/O

2008-07-04 Thread Robert Jennings
From: Nathan Fontenot [EMAIL PROTECTED]

Verify memory entitlement updates can be handled by vio.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/lparcfg.c |   10 ++
 1 file changed, 10 insertions(+)

Index: b/arch/powerpc/kernel/lparcfg.c
===
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -34,6 +34,7 @@
 #include asm/time.h
 #include asm/prom.h
 #include asm/vdso_datapage.h
+#include asm/vio.h
 
 #define MODULE_VERS 1.7
 #define MODULE_NAME lparcfg
@@ -528,6 +529,15 @@ static ssize_t update_mpp(u64 *entitleme
u8 new_weight;
ssize_t rc;
 
+   if (entitlement) {
+   /* Check with vio to ensure the new memory entitlement
+* can be handled.
+*/
+   rc = vio_cmo_entitlement_update(*entitlement);
+   if (rc)
+   return rc;
+   }
+
rc = h_get_mpp(mpp_data);
if (rc)
return rc;
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 13/16 v3] ibmveth: Automatically enable larger rx buffer pools for larger mtu

2008-07-04 Thread Robert Jennings
From: Santiago Leon [EMAIL PROTECTED]

Activates larger rx buffer pools when the MTU is changed to a larger
value.  This patch de-activates the large rx buffer pools when the MTU
changes to a smaller value.

Signed-off-by: Santiago Leon [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---

 drivers/net/ibmveth.c |   20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

Index: b/drivers/net/ibmveth.c
===
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1054,7 +1054,6 @@ static int ibmveth_change_mtu(struct net
 {
struct ibmveth_adapter *adapter = dev-priv;
int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH;
-   int reinit = 0;
int i, rc;
 
if (new_mtu  IBMVETH_MAX_MTU)
@@ -1067,15 +1066,21 @@ static int ibmveth_change_mtu(struct net
if (i == IbmVethNumBufferPools)
return -EINVAL;
 
+   /* Deactivate all the buffer pools so that the next loop can activate
+  only the buffer pools necessary to hold the new MTU */
+   for (i = 0; i  IbmVethNumBufferPools; i++)
+   if (adapter-rx_buff_pool[i].active) {
+   ibmveth_free_buffer_pool(adapter,
+adapter-rx_buff_pool[i]);
+   adapter-rx_buff_pool[i].active = 0;
+   }
+
/* Look for an active buffer pool that can hold the new MTU */
for(i = 0; iIbmVethNumBufferPools; i++) {
-   if (!adapter-rx_buff_pool[i].active) {
-   adapter-rx_buff_pool[i].active = 1;
-   reinit = 1;
-   }
+   adapter-rx_buff_pool[i].active = 1;
 
if (new_mtu_oh  adapter-rx_buff_pool[i].buff_size) {
-   if (reinit  netif_running(adapter-netdev)) {
+   if (netif_running(adapter-netdev)) {
adapter-pool_config = 1;
ibmveth_close(adapter-netdev);
adapter-pool_config = 0;
@@ -1402,14 +1407,15 @@ const char * buf, size_t count)
return -EPERM;
}
 
-   pool-active = 0;
if (netif_running(netdev)) {
adapter-pool_config = 1;
ibmveth_close(netdev);
+   pool-active = 0;
adapter-pool_config = 0;
if ((rc = ibmveth_open(netdev)))
return rc;
}
+   pool-active = 0;
}
} else if (attr == veth_num_attr) {
if (value = 0 || value  IBMVETH_MAX_POOL_COUNT)
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 14/16 v3] ibmveth: enable driver for CMO

2008-07-04 Thread Robert Jennings
Enable ibmveth for Cooperative Memory Overcommitment (CMO).  For this driver
it means calculating a desired amount of IO memory based on the current MTU
and updating this value with the bus when MTU changes occur.  Because DMA
mappings can fail, we have added a bounce buffer for temporary cases where
the driver can not map IO memory for the buffer pool.

The following changes are made to enable the driver for CMO:
 * DMA mapping errors will not result in error messages if entitlement has
   been exceeded and resources were not available.
 * DMA mapping errors are handled gracefully, ibmveth_replenish_buffer_pool()
   is corrected to check the return from dma_map_single and fail gracefully.
 * The driver will have a get_desired_dma function defined to function
   in a CMO environment.
 * When the MTU is changed, the driver will update the device IO entitlement

Signed-off-by: Robert Jennings [EMAIL PROTECTED]
Signed-off-by: Brian King [EMAIL PROTECTED]
Signed-off-by: Santiago Leon [EMAIL PROTECTED]

---

 drivers/net/ibmveth.c |  169 --
 drivers/net/ibmveth.h |5 +
 2 files changed, 140 insertions(+), 34 deletions(-)

Index: b/drivers/net/ibmveth.c
===
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -33,6 +33,7 @@
 */
 
 #include linux/module.h
+#include linux/moduleparam.h
 #include linux/types.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -52,7 +53,9 @@
 #include asm/hvcall.h
 #include asm/atomic.h
 #include asm/vio.h
+#include asm/iommu.h
 #include asm/uaccess.h
+#include asm/firmware.h
 #include linux/seq_file.h
 
 #include ibmveth.h
@@ -94,8 +97,10 @@ static void ibmveth_proc_register_adapte
 static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter);
 static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance);
 static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter);
+static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev);
 static struct kobj_type ktype_veth_pool;
 
+
 #ifdef CONFIG_PROC_FS
 #define IBMVETH_PROC_DIR ibmveth
 static struct proc_dir_entry *ibmveth_proc_dir;
@@ -226,16 +231,16 @@ static void ibmveth_replenish_buffer_poo
u32 i;
u32 count = pool-size - atomic_read(pool-available);
u32 buffers_added = 0;
+   struct sk_buff *skb;
+   unsigned int free_index, index;
+   u64 correlator;
+   unsigned long lpar_rc;
+   dma_addr_t dma_addr;
 
mb();
 
for(i = 0; i  count; ++i) {
-   struct sk_buff *skb;
-   unsigned int free_index, index;
-   u64 correlator;
union ibmveth_buf_desc desc;
-   unsigned long lpar_rc;
-   dma_addr_t dma_addr;
 
skb = alloc_skb(pool-buff_size, GFP_ATOMIC);
 
@@ -255,6 +260,9 @@ static void ibmveth_replenish_buffer_poo
dma_addr = dma_map_single(adapter-vdev-dev, skb-data,
pool-buff_size, DMA_FROM_DEVICE);
 
+   if (dma_mapping_error(dma_addr))
+   goto failure;
+
pool-free_map[free_index] = IBM_VETH_INVALID_MAP;
pool-dma_addr[index] = dma_addr;
pool-skbuff[index] = skb;
@@ -267,20 +275,9 @@ static void ibmveth_replenish_buffer_poo
 
lpar_rc = h_add_logical_lan_buffer(adapter-vdev-unit_address, 
desc.desc);
 
-   if(lpar_rc != H_SUCCESS) {
-   pool-free_map[free_index] = index;
-   pool-skbuff[index] = NULL;
-   if (pool-consumer_index == 0)
-   pool-consumer_index = pool-size - 1;
-   else
-   pool-consumer_index--;
-   dma_unmap_single(adapter-vdev-dev,
-   pool-dma_addr[index], pool-buff_size,
-   DMA_FROM_DEVICE);
-   dev_kfree_skb_any(skb);
-   adapter-replenish_add_buff_failure++;
-   break;
-   } else {
+   if (lpar_rc != H_SUCCESS)
+   goto failure;
+   else {
buffers_added++;
adapter-replenish_add_buff_success++;
}
@@ -288,6 +285,24 @@ static void ibmveth_replenish_buffer_poo
 
mb();
atomic_add(buffers_added, (pool-available));
+   return;
+
+failure:
+   pool-free_map[free_index] = index;
+   pool-skbuff[index] = NULL;
+   if (pool-consumer_index == 0)
+   pool-consumer_index = pool-size - 1;
+   else
+   pool-consumer_index--;
+   if (!dma_mapping_error(dma_addr))
+   dma_unmap_single(adapter-vdev-dev,
+pool-dma_addr[index], pool-buff_size,
+

[PATCH 15/16 v3] ibmvscsi: driver enablement for CMO

2008-07-04 Thread Robert Jennings
From: Robert Jennings [EMAIL PROTECTED]

Enable the driver to function in a Cooperative Memory Overcommitment (CMO)
environment.

The following changes are made to enable the driver for CMO:
 * DMA mapping errors will not result in error messages if entitlement has
   been exceeded and resources were not available.
 * The driver has a get_desired_dma function defined to function
   in a CMO environment. It will indicate how much IO memory it would like
   to function.

Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 drivers/scsi/ibmvscsi/ibmvscsi.c |   46 +--
 drivers/scsi/ibmvscsi/ibmvscsi.h |2 ++
 2 files changed, 41 insertions(+), 7 deletions(-)

Index: b/drivers/scsi/ibmvscsi/ibmvscsi.c
===
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -72,6 +72,8 @@
 #include linux/delay.h
 #include asm/firmware.h
 #include asm/vio.h
+#include asm/firmware.h
+#include asm/iommu.h
 #include scsi/scsi.h
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_host.h
@@ -426,8 +428,10 @@ static int map_sg_data(struct scsi_cmnd 
   SG_ALL * sizeof(struct 
srp_direct_buf),
   evt_struct-ext_list_token, 0);
if (!evt_struct-ext_list) {
-   sdev_printk(KERN_ERR, cmd-device,
-   Can't allocate memory for indirect 
table\n);
+   if (!firmware_has_feature(FW_FEATURE_CMO))
+   sdev_printk(KERN_ERR, cmd-device,
+   Can't allocate memory 
+   for indirect table\n);
return 0;
}
}
@@ -743,7 +747,9 @@ static int ibmvscsi_queuecommand(struct 
srp_cmd-lun = ((u64) lun)  48;
 
if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata-dev)) {
-   sdev_printk(KERN_ERR, cmnd-device, couldn't convert cmd to 
srp_cmd\n);
+   if (!firmware_has_feature(FW_FEATURE_CMO))
+   sdev_printk(KERN_ERR, cmnd-device,
+   couldn't convert cmd to srp_cmd\n);
free_event_struct(hostdata-pool, evt_struct);
return SCSI_MLQUEUE_HOST_BUSY;
}
@@ -855,7 +861,10 @@ static void send_mad_adapter_info(struct
DMA_BIDIRECTIONAL);
 
if (dma_mapping_error(req-buffer)) {
-   dev_err(hostdata-dev, Unable to map request_buffer for 
adapter_info!\n);
+   if (!firmware_has_feature(FW_FEATURE_CMO))
+   dev_err(hostdata-dev,
+   Unable to map request_buffer for 
+   adapter_info!\n);
free_event_struct(hostdata-pool, evt_struct);
return;
}
@@ -1400,7 +1409,9 @@ static int ibmvscsi_do_host_config(struc
DMA_BIDIRECTIONAL);
 
if (dma_mapping_error(host_config-buffer)) {
-   dev_err(hostdata-dev, dma_mapping error getting host 
config\n);
+   if (!firmware_has_feature(FW_FEATURE_CMO))
+   dev_err(hostdata-dev,
+   dma_mapping error getting host config\n);
free_event_struct(hostdata-pool, evt_struct);
return -1;
}
@@ -1604,7 +1615,7 @@ static struct scsi_host_template driver_
.eh_host_reset_handler = ibmvscsi_eh_host_reset_handler,
.slave_configure = ibmvscsi_slave_configure,
.change_queue_depth = ibmvscsi_change_queue_depth,
-   .cmd_per_lun = 16,
+   .cmd_per_lun = IBMVSCSI_CMDS_PER_LUN_DEFAULT,
.can_queue = IBMVSCSI_MAX_REQUESTS_DEFAULT,
.this_id = -1,
.sg_tablesize = SG_ALL,
@@ -1613,6 +1624,26 @@ static struct scsi_host_template driver_
 };
 
 /**
+ * ibmvscsi_get_desired_dma - Calculate IO entitlement needed by the driver
+ *
+ * @vdev: struct vio_dev for the device whose entitlement is to be returned
+ *
+ * Return value:
+ * Number of bytes of IO data the driver will need to perform well.
+ */
+static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev)
+{
+   /* iu_storage data allocated in initialize_event_pool */
+   unsigned long io_entitlement = max_requests * sizeof(union viosrp_iu);
+
+   /* add io space for sg data */
+   io_entitlement += (IBMVSCSI_MAX_SECTORS_DEFAULT *
+IBMVSCSI_CMDS_PER_LUN_DEFAULT);
+
+   return IOMMU_PAGE_ALIGN(io_entitlement);
+}
+
+/**
  * Called by bus code for each adapter
  */
 static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
@@ -1641,7 +1672,7 @@ static int ibmvscsi_probe(struct vio_dev
hostdata-host = host;
hostdata-dev = dev;

[PATCH 16/16 v3] powerpc: Update arch vector to indicate support for CMO

2008-07-04 Thread Robert Jennings
From: Nathan Fontenot [EMAIL PROTECTED]

Update the architecture vector to indicate that Cooperative Memory
Overcommitment is supported.

This is the last patch in the series.  Committing it will signal to 
the platform firmware is CMO enabled.

Signed-off-by: Nathan Fontenot [EMAIL PROTECTED]
Signed-off-by: Robert Jennings [EMAIL PROTECTED]

---
 arch/powerpc/kernel/prom_init.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: b/arch/powerpc/kernel/prom_init.c
===
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -642,6 +642,7 @@ static void __init early_cmdline_parse(v
 #else
 #define OV5_MSI0x00
 #endif /* CONFIG_PCI_MSI */
+#define OV5_CMO0x80/* Cooperative Memory 
Overcommitment */
 
 /*
  * The architecture vector has an array of PVR mask/value pairs,
@@ -684,10 +685,12 @@ static unsigned char ibm_architecture_ve
0,  /* don't halt */
 
/* option vector 5: PAPR/OF options */
-   3 - 2,  /* length */
+   5 - 2,  /* length */
0,  /* don't ignore, don't halt */
OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY |
OV5_DONATE_DEDICATE_CPU | OV5_MSI,
+   0,
+   OV5_CMO,
 };
 
 /* Old method - ELF header with PT_NOTE sections */
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: New fsl device bindings file

2008-07-04 Thread Matt Sealey

Anton Vorontsov wrote:

On Thu, Jul 03, 2008 at 01:20:18PM -0500, Kumar Gala wrote:

Guys,


/* deprecated; */
device_type = i2c;


How about deprecated but kept for compatibility with true Open Firmware
implementations?

Seriously, you can't have a binding for OF and then cut out that part of the
standard at a whim. It should be there (at least for those parts which are
governed by a client interface API, like display, serial etc. but cutting it
off takes away all it's meaning, plus Linux implementations STILL keep searching
that property along with compatible, and probably will for all time that
real IEEE1275 bindings are in use), and if it's not, then what used to go into
there needs to be in compatible.

As a nit, I don't think making it into an example makes the documentation any 
better
to read at all, in fact I found it harder to read. You may as well throw away 
all
the docs altogether and produce a well-commented example set if that is the 
route
this is going down. I think having everything as a plaintext file, while nice 
and
accessible for everyone, might have something to do with that though.

--
Matt Sealey [EMAIL PROTECTED]
Genesi, Manager, Developer Relations
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Add PPC_FEATURE_PMU_COMPAT

2008-07-04 Thread Kumar Gala


On Jul 3, 2008, at 6:20 PM, Nathan Lynch wrote:


Beginning with Power6, there is a set of 32 PMU events which is
compatible across POWER processor lines.  PPC_FEATURE_PMU_COMPAT
indicates support for this subset.

Signed-off-by: Nathan Lynch [EMAIL PROTECTED]
---
arch/powerpc/kernel/cputable.c |4 ++--
include/asm-powerpc/cputable.h |1 +
2 files changed, 3 insertions(+), 2 deletions(-)


Can you explain what these PMU events are a bit further?

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


Re: GPIO @ MPC5200

2008-07-04 Thread Grant Likely
On Fri, Jul 04, 2008 at 11:57:14AM +0200, Andre Schwarz wrote:
 Sascha, Grant,
 
 I'm running on 2.6.26-rc6 with an MPC5200B based system.
 
 Looks like some (for me) crucial GPIO are touched during boot.
 Is this possible ?
 
 Of course I have compiled in GPIO-Lib and specified the GPIOs in the dts.
 But no access yet - I'd like to preserve the setup from u-boot...

The GPIO driver only writes to the GPIO registers when a driver actually
requests to use them.  At probe time, the gpio drivers read the current
values from the GPIO registers, so current config should be preserved.

However, the gpiochip_dir hook explicitly sets the output value when it
is called.  It may be that when you are claiming the GPIO line it is
getting set with a default (and wrong) value.

Another possibility; have you verified that it is the GPIO regs getting
clobbered?  Or is port_config getting changed on you?  Which GPIO pins?

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


Re: [alsa-devel] [PATCH 2/3] ALSA SoC: Add mpc5200-psc I2S driver

2008-07-04 Thread Grant Likely
On Fri, Jul 04, 2008 at 07:03:25AM -0400, Timur Tabi wrote:
  [EMAIL PROTECTED] { // PSC2
  compatible = fsl,mpc5200b-psc-i2s,fsl,mpc5200-psc-i2s;
  cell-index = 1;

 cell-index should be zero-based, not one-based.


Umm... this is for PSC #2... cell index is set to '1'.  It is zero
based.

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


Re: GPIO @ MPC5200

2008-07-04 Thread Andre Schwarz
Grant Likely schrieb:
 On Fri, Jul 04, 2008 at 11:57:14AM +0200, Andre Schwarz wrote:
   
 Sascha, Grant,

 I'm running on 2.6.26-rc6 with an MPC5200B based system.

 Looks like some (for me) crucial GPIO are touched during boot.
 Is this possible ?

 Of course I have compiled in GPIO-Lib and specified the GPIOs in the dts.
 But no access yet - I'd like to preserve the setup from u-boot...
 

 The GPIO driver only writes to the GPIO registers when a driver actually
 requests to use them.  At probe time, the gpio drivers read the current
 values from the GPIO registers, so current config should be preserved.

 However, the gpiochip_dir hook explicitly sets the output value when it
 is called.  It may be that when you are claiming the GPIO line it is
 getting set with a default (and wrong) value.

 Another possibility; have you verified that it is the GPIO regs getting
 clobbered?  Or is port_config getting changed on you?  Which GPIO pins?

 g.
   

The pin in question is PSC2_4, i.e. a wake-up GPIO.
It is configured as push-pull output and driven high.

Since it has an external pull-down resistor I can't say if it is driven
low or re-configured as an input ...

I removed GPIO Lib and the problem is gone.
I'm not yet using it anyway under linux - they're mainly for system
configuration (setting up muxes etc.).

I'll dig into it when I have some time.

thanks,
Andre






MATRIX VISION GmbH, Talstraße 16, DE-71570 Oppenweiler  - Registergericht: 
Amtsgericht Stuttgart, HRB 271090
Geschäftsführer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Update maintainers for powerpc

2008-07-04 Thread Tom Rini
On Fri, Jul 04, 2008 at 09:04:42PM +1000, Paul Mackerras wrote:

 This updates the MAINTAINERS entries for powerpc.  It adds Ben H to
 the overall Linux for PowerPC entry and makes it clear this covers
 both 32-bit and 64-bit machines.  It removes the separate entry we had
 for Linux on 64-bit PowerPC where Anton and I were listed as
 maintainers - Anton hasn't been involved in the day-to-day maintenance
 of the code for several years.  Finally, it removes the entry for the
 Linux for PowerPC boot code where Tom Rini was listed as the
 maintainer.  That code got completely rewritten when we merged
 32-bit and 64-bit, and I and the various platform maintainers have
 been maintaining that code since.
 
 Signed-off-by: Paul Mackerras [EMAIL PROTECTED]

Acked-by: Tom Rini [EMAIL PROTECTED]

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


Re: GPIO @ MPC5200

2008-07-04 Thread Grant Likely
On Fri, Jul 04, 2008 at 05:10:46PM +0200, Andre Schwarz wrote:
 I removed GPIO Lib and the problem is gone.
 I'm not yet using it anyway under linux - they're mainly for system
 configuration (setting up muxes etc.).
 
 I'll dig into it when I have some time.

When you do, try adding #define DEBUG to the top of mpc52xx_gpio.c and
see what comes out of dmesg.

g.

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


[PATCH] Add MPC5200B base board mvBC-P

2008-07-04 Thread Andre Schwarz
The mvBlueCOUGAR-P is a MPC5200B based camera system with Intel Gigabit ethernet
controller (using e1000). It's just another MPC5200_simple board.

Signed-off-by: Andre Schwarz [EMAIL PROTECTED]
---


Grant,

I don't know if there are any merge windows ...
If the patch should be modified or re-submitted on a later time please let me 
know.


thanks,
Andre



MATRIX VISION GmbH, Talstraße 16, DE-71570 Oppenweiler  - Registergericht: 
Amtsgericht Stuttgart, HRB 271090
Geschäftsführer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
 arch/powerpc/boot/dts/mvbc-p.dts |  206 +
 arch/powerpc/configs/mvbc-p_defconfig| 1158 ++
 arch/powerpc/platforms/52xx/Kconfig  |3 +-
 arch/powerpc/platforms/52xx/mpc5200_simple.c |1 +
 4 files changed, 1367 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/boot/dts/mvbc-p.dts b/arch/powerpc/boot/dts/mvbc-p.dts
new file mode 100644
index 000..90a2808
--- /dev/null
+++ b/arch/powerpc/boot/dts/mvbc-p.dts
@@ -0,0 +1,206 @@
+/*
+ * mvBlueCOUGAR-P device tree source
+ *
+ * Copyright (C) 2008 Matrix Vision GmbH
+ * Andre Schwarz [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+/dts-v1/;
+
+/ {
+   model = matrix-vision,mvbc-p;
+   compatible = matrix-vision,mvbc-p;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   cpus {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   PowerPC,[EMAIL PROTECTED] {
+   device_type = cpu;
+   reg = 0;
+   d-cache-line-size = 32;
+   i-cache-line-size = 32;
+   d-cache-size = 0x4000;
+   i-cache-size = 0x4000;
+   timebase-frequency = 0;
+   bus-frequency = 0;
+   clock-frequency = 0;
+   };
+   };
+
+   memory {
+   device_type = memory;
+   reg = 0x 0x;
+   };
+
+   [EMAIL PROTECTED] {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = fsl,mpc5200-immr;
+   ranges = 0 0xf000 0xc000;
+   reg = 0xf000 0x0100;
+   bus-frequency = 0;
+   system-frequency = 0;
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,mpc5200-cdm;
+   reg = 0x200 0x38;
+   };
+
+   mpc5200_pic: [EMAIL PROTECTED] {
+   // 5200 interrupts are encoded into two levels;
+   interrupt-controller;
+   #interrupt-cells = 3;
+   compatible = fsl,mpc5200-pic;
+   reg = 0x500 0x80;
+   };
+
+   [EMAIL PROTECTED] { // General Purpose Timer
+   compatible = fsl,mpc5200-gpt;
+   reg = 0x600 0x10;
+   interrupts = 1 9 0;
+   interrupt-parent = mpc5200_pic;
+   fsl,has-wdt;
+   };
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,mpc5200-gpio;
+   reg = 0xb00 0x40;
+   interrupts = 1 7 0;
+   interrupt-parent = mpc5200_pic;
+   };
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,mpc5200-gpio-wkup;
+   reg = 0xc00 0x40;
+   interrupts = 1 8 0 0 3 0;
+   interrupt-parent = mpc5200_pic;
+   };
+
+   [EMAIL PROTECTED] {
+   device_type = dma-controller;
+   compatible = fsl,mpc5200-bestcomm;
+   reg = 0x1200 0x80;
+   interrupts = 3 0 0  3 1 0  3 2 0  3 3 0
+   3 4 0  3 5 0  3 6 0  3 7 0
+   3 8 0  3 9 0  3 10 0  3 11 0
+   3 12 0  3 13 0  3 14 0  3 15 0;
+   interrupt-parent = mpc5200_pic;
+   };
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,mpc5200-xlb;
+   reg = 0x1f00 0x100;
+   };
+
+   serial0: [EMAIL PROTECTED] {// PSC1
+   device_type = serial;
+   compatible = fsl,mpc5200-psc-uart;
+   port-number = 0;
+   reg = 0x2000 0x100;
+   interrupts = 2 1 0;
+   interrupt-parent = mpc5200_pic;
+   };
+
+   [EMAIL PROTECTED] {
+  

[PATCH v2] powerpc: add FHCI USB, FSL MCU, FSL UPM and GPIO LEDs bindings

2008-07-04 Thread Anton Vorontsov
This patch adds few bindings for the new drivers to be submitted through
the appropriate maintainers.

Signed-off-by: Anton Vorontsov [EMAIL PROTECTED]
---

Updated to decrypt MCU, and to split the bindings into appropriate files.

 .../powerpc/device-tree/fsl/mcu-mpc8349emitx.txt   |   17 +
 Documentation/powerpc/device-tree/fsl/qe/usb.txt   |   37 
 Documentation/powerpc/device-tree/fsl/upm-nand.txt |   28 +++
 Documentation/powerpc/device-tree/gpio/led.txt |   15 
 4 files changed, 97 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/powerpc/device-tree/fsl/mcu-mpc8349emitx.txt
 create mode 100644 Documentation/powerpc/device-tree/fsl/qe/usb.txt
 create mode 100644 Documentation/powerpc/device-tree/fsl/upm-nand.txt
 create mode 100644 Documentation/powerpc/device-tree/gpio/led.txt

diff --git a/Documentation/powerpc/device-tree/fsl/mcu-mpc8349emitx.txt 
b/Documentation/powerpc/device-tree/fsl/mcu-mpc8349emitx.txt
new file mode 100644
index 000..0f76633
--- /dev/null
+++ b/Documentation/powerpc/device-tree/fsl/mcu-mpc8349emitx.txt
@@ -0,0 +1,17 @@
+Freescale MPC8349E-mITX-compatible Power Management Micro Controller Unit (MCU)
+
+Required properties:
+- compatible : fsl,mcu-chip-board, fsl,mcu-mpc8349emitx.
+- reg : should specify I2C address (0x0a).
+- #gpio-cells : should be 2.
+- gpio-controller : should be present.
+
+Example:
+
[EMAIL PROTECTED] {
+   #gpio-cells = 2;
+   compatible = fsl,mc9s08qg8-mpc8349emitx,
+fsl,mcu-mpc8349emitx;
+   reg = 0x0a;
+   gpio-controller;
+};
diff --git a/Documentation/powerpc/device-tree/fsl/qe/usb.txt 
b/Documentation/powerpc/device-tree/fsl/qe/usb.txt
new file mode 100644
index 000..9ccd5f3
--- /dev/null
+++ b/Documentation/powerpc/device-tree/fsl/qe/usb.txt
@@ -0,0 +1,37 @@
+Freescale QUICC Engine USB Controller
+
+Required properties:
+- compatible : should be fsl,chip-qe-usb, fsl,mpc8323-qe-usb.
+- reg : the first two cells should contain usb registers location and
+  length, the next two two cells should contain PRAM location and
+  length.
+- interrupts : should contain USB interrupt.
+- interrupt-parent : interrupt source phandle.
+- fsl,fullspeed-clock : specifies the full speed USB clock source:
+  none: clock source is disabled
+  brg1 through brg16: clock source is BRG1-BRG16, respectively
+  clk1 through clk24: clock source is CLK1-CLK24, respectively
+- fsl,lowspeed-clock : specifies the low speed USB clock source:
+  none: clock source is disabled
+  brg1 through brg16: clock source is BRG1-BRG16, respectively
+  clk1 through clk24: clock source is CLK1-CLK24, respectively
+- hub-power-budget : USB power budget for the root hub, in mA.
+- gpios : should specify GPIOs in this order: USBOE, USBTP, USBTN, USBRP,
+  USBRN, SPEED (optional), and POWER (optional).
+
+Example:
+
[EMAIL PROTECTED] {
+   compatible = fsl,mpc8360-qe-usb, fsl,mpc8323-qe-usb;
+   reg = 0x6c0 0x40 0x8b00 0x100;
+   interrupts = 11;
+   interrupt-parent = qeic;
+   fsl,fullspeed-clock = clk21;
+   gpios = qe_pio_b  2 0 /* USBOE */
+qe_pio_b  3 0 /* USBTP */
+qe_pio_b  8 0 /* USBTN */
+qe_pio_b  9 0 /* USBRP */
+qe_pio_b 11 0 /* USBRN */
+qe_pio_e 20 0 /* SPEED */
+qe_pio_e 21 0 /* POWER */;
+};
diff --git a/Documentation/powerpc/device-tree/fsl/upm-nand.txt 
b/Documentation/powerpc/device-tree/fsl/upm-nand.txt
new file mode 100644
index 000..84a04d5
--- /dev/null
+++ b/Documentation/powerpc/device-tree/fsl/upm-nand.txt
@@ -0,0 +1,28 @@
+Freescale Localbus UPM programmed to work with NAND flash
+
+Required properties:
+- compatible : fsl,upm-nand.
+- reg : should specify localbus chip select and size used for the chip.
+- fsl,upm-addr-offset : UPM pattern offset for the address latch.
+- fsl,upm-cmd-offset : UPM pattern offset for the command latch.
+- gpios : may specify optional GPIO connected to the Ready-Not-Busy pin.
+
+Example:
+
[EMAIL PROTECTED],0 {
+   compatible = fsl,upm-nand;
+   reg = 1 0 1;
+   fsl,upm-addr-offset = 16;
+   fsl,upm-cmd-offset = 8;
+   gpios = qe_pio_e 18 0;
+
+   flash {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = ...;
+
+   [EMAIL PROTECTED] {
+   ...
+   };
+   };
+};
diff --git a/Documentation/powerpc/device-tree/gpio/led.txt 
b/Documentation/powerpc/device-tree/gpio/led.txt
new file mode 100644
index 000..ff51f4c
--- /dev/null
+++ b/Documentation/powerpc/device-tree/gpio/led.txt
@@ -0,0 +1,15 @@
+LED connected to GPIO
+
+Required properties:
+- compatible : should be gpio-led.
+- label : (optional) the label for this LED. If omitted, the label is
+  taken from the node name (excluding the unit address).
+- gpios : should specify LED GPIO.
+
+Example:
+
[EMAIL PROTECTED] {
+   compatible 

Re: [PATCH] Add MPC5200B base board mvBC-P

2008-07-04 Thread Grant Likely
On Fri, Jul 04, 2008 at 06:35:39PM +0200, Andre Schwarz wrote:
 The mvBlueCOUGAR-P is a MPC5200B based camera system with Intel Gigabit 
 ethernet
 controller (using e1000). It's just another MPC5200_simple board.
 
 Signed-off-by: Andre Schwarz [EMAIL PROTECTED]
 ---
 
 
 Grant,
 
 I don't know if there are any merge windows ...
 If the patch should be modified or re-submitted on a later time please let me 
 know.

The merge window will be opening any day now.  If you address comments
quickly then I should be able to merge it into 2.6.27

  arch/powerpc/boot/dts/mvbc-p.dts |  206 +
  arch/powerpc/configs/mvbc-p_defconfig| 1158 
 ++
Rename this to arch/powerpc/config/52xx/mvbc_p_defconfig (use platform
specific defconfig dir and don't mix '-' and '_' in filenames).

 diff --git a/arch/powerpc/boot/dts/mvbc-p.dts 
 b/arch/powerpc/boot/dts/mvbc-p.dts
 new file mode 100644
 index 000..90a2808
 --- /dev/null
 +++ b/arch/powerpc/boot/dts/mvbc-p.dts
 @@ -0,0 +1,206 @@
 +/*
 + * mvBlueCOUGAR-P device tree source
 + *
 + * Copyright (C) 2008 Matrix Vision GmbH
 + * Andre Schwarz [EMAIL PROTECTED]
 + *
 + * This program is free software; you can redistribute it and/or modify it
 + * under the terms of the GNU General Public License as published by the
 + * Free Software Foundation; either version 2 of the License, or (at your
 + * option) any later version.
 + */
 +
 +/dts-v1/;
 +
 +/ {
 + model = matrix-vision,mvbc-p;
 + compatible = matrix-vision,mvbc-p;
 + #address-cells = 1;
 + #size-cells = 1;
 +
 + cpus {
 + #address-cells = 1;
 + #size-cells = 0;
 +
 + PowerPC,[EMAIL PROTECTED] {
 + device_type = cpu;
 + reg = 0;
 + d-cache-line-size = 32;
 + i-cache-line-size = 32;
 + d-cache-size = 0x4000;
 + i-cache-size = 0x4000;
 + timebase-frequency = 0;
 + bus-frequency = 0;
 + clock-frequency = 0;
 + };
 + };
 +
 + memory {
 + device_type = memory;
 + reg = 0x 0x;
 + };
 +
 + [EMAIL PROTECTED] {
 + #address-cells = 1;
 + #size-cells = 1;
 + compatible = fsl,mpc5200-immr;

Does this board use the original 5200, or the 5200B?  If it uses the
5200B, then you should specify both fsl,mpc5200b-immr and
fsl,mpc5200-immr.  Same goes for all other compatible properties in the
tree; see lite5200b.dts for an example.

I am toying with the option of eliminating the need for fsl,mpc5200b-*,
but until then the conservative and safest thing to do is to claim
compatibility with both.

 + lpb {
 + compatible = fsl,lpb;

You should also claim compatibility with simple-bus here.

ie:  compatible = fsl,lpb, simple-bus;

 + #address-cells = 2;
 + #size-cells = 1;
 + ranges = 0x0 0x0 0xff80 0x0080;
 + [EMAIL PROTECTED],0 {
 + compatible = cfi-flash;

For completeness, it is good practice for the first entry in the compatible
list to be the actual flash chip, followed by cfi-flash

 + reg = 0 0 0x80;
 + #address-cells = 1;
 + #size-cells = 1;
 + bank-width = 1;
 + device-width = 1;
 + [EMAIL PROTECTED] {
 + reg = 0x0 0x80;
 + };

I don't know if this is legal; to have overlapping flash sections (but
I'm not a cfi-flash binding expert).

 + [EMAIL PROTECTED] {
 + reg = 0x0 0x4;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x4 0x1;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x5 0x1;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x6 0x4;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0xa0 0x6;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x10 0x30;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x40 0x3c;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x7c 0x1;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x7d 0x1;
 + };
 + [EMAIL PROTECTED] {
 + reg = 0x7e 0x1;
 + };
 + [EMAIL PROTECTED] {
 + 

Please pull linux-2.6-virtex.git

2008-07-04 Thread Grant Likely
Hi Josh,

Here are the bulk of the Xilinx 440 support patches.  Please pull
into your next branch.

Thanks,
g.

The following changes since commit f3e909c2750eb20536bacacc867dc9047b70546a:
  Michael Neuling (1):
powerpc: Update for VSX core file and ptrace

are available in the git repository at:

  git://git.secretlab.ca/git/linux-2.6-virtex virtex-for-2.6.27

Grant Likely (2):
  powerpc/bootwrapper: Add documentation of boot wrapper targets
  powerpc/bootwrapper: add missing bit of simpleImage target

John Linn (5):
  powerpc/virtex: add dts file for ML507 reference design
  powerpc/virtex: Fix booting of Xilinx FPGAs with 16550 for 405 and 440
  powerpc/virtex: add Xilinx Virtex 5 ppc440 platform support
  powerpc/virtex: add Xilinx 440 cpu to the cputable
  powerpc/virtex: add defconfig for virtex 5 platforms

 Documentation/powerpc/bootwrapper.txt  |  141 
 arch/powerpc/Makefile  |   15 +-
 arch/powerpc/boot/Makefile |2 +-
 arch/powerpc/boot/dts/virtex440-ml507.dts  |  238 ++
 arch/powerpc/boot/simpleboot.c |6 +
 arch/powerpc/boot/virtex.c |  100 +++
 arch/powerpc/boot/wrapper  |   10 +-
 arch/powerpc/configs/44x/virtex5_defconfig | 1107 
 arch/powerpc/kernel/cputable.c |   10 +
 arch/powerpc/platforms/44x/Kconfig |   26 +
 arch/powerpc/platforms/44x/Makefile|1 +
 arch/powerpc/platforms/44x/virtex.c|   60 ++
 12 files changed, 1713 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/powerpc/bootwrapper.txt
 create mode 100644 arch/powerpc/boot/dts/virtex440-ml507.dts
 create mode 100644 arch/powerpc/boot/virtex.c
 create mode 100644 arch/powerpc/configs/44x/virtex5_defconfig
 create mode 100644 arch/powerpc/platforms/44x/virtex.c

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


Re: [PATCH] Add MPC5200B base board mvBC-P

2008-07-04 Thread Jon Smirl
On 7/4/08, Grant Likely [EMAIL PROTECTED] wrote:
 On Fri, Jul 04, 2008 at 06:35:39PM +0200, Andre Schwarz wrote:
   + #address-cells = 2;
   + #size-cells = 1;
   + ranges = 0x0 0x0 0xff80 0x0080;
   + [EMAIL PROTECTED],0 {
   + compatible = cfi-flash;

  For completeness, it is good practice for the first entry in the compatible
  list to be the actual flash chip, followed by cfi-flash

   + reg = 0 0 0x80;
   + #address-cells = 1;
   + #size-cells = 1;
   + bank-width = 1;
   + device-width = 1;
   + [EMAIL PROTECTED] {
   + reg = 0x0 0x80;
   + };

  I don't know if this is legal; to have overlapping flash sections (but
  I'm not a cfi-flash binding expert).

   + [EMAIL PROTECTED] {
   + reg = 0x0 0x4;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x4 0x1;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x5 0x1;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x6 0x4;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0xa0 0x6;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x10 0x30;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x40 0x3c;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x7c 0x1;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x7d 0x1;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x7e 0x1;
   + };
   + [EMAIL PROTECTED] {
   + reg = 0x7f 0x1;
   + };

  I think it would be better to just leave out the partition information
  and modify U-Boot to fill them in (just like memory and clock speed are
  left out).  Things like flash partitions are less like hardware
  description and more like configuration data.

Has anyone tried writing a RedBoot type partition table onto their
flash device? If it is there the kernel will read the partition info
from it. It's a config option in the kernel flash support section. Is
there a utility for creating these tables?

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


[patch 01/11] powerpc/cell: add support for power button of future IBM cell blades

2008-07-04 Thread arnd
This patch adds support for the power button on future IBM cell blades.
It actually doesn't shut down the machine. Instead it exposes an
input device /dev/input/event0 to userspace which sends KEY_POWER
if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid
replacement should handle it correctly.

Signed-off-by: Christian Krafft [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/platforms/cell/pervasive.c |   70 ++-
 1 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/cell/pervasive.c 
b/arch/powerpc/platforms/cell/pervasive.c
index 8a3631c..e5bd08c 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -24,8 +24,10 @@
 #undef DEBUG
 
 #include linux/interrupt.h
+#include linux/input.h
 #include linux/irq.h
 #include linux/percpu.h
+#include linux/platform_device.h
 #include linux/types.h
 #include linux/kallsyms.h
 
@@ -40,6 +42,9 @@
 
 static int sysreset_hack;
 
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
+
 static void cbe_power_save(void)
 {
unsigned long ctrl, thread_switch_control;
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs 
*regs)
 */
if (sysreset_hack  (cpu = smp_processor_id()) == 0) {
pmd = cbe_get_cpu_pmd_regs(cpu);
-   if (in_be64(pmd-ras_esc_0)  0x) {
+   if (in_be64(pmd-ras_esc_0)  0x) {
out_be64(pmd-ras_esc_0, 0);
return 0;
}
+   if (in_be64(pmd-ras_esc_0)  0x0001) {
+   out_be64(pmd-ras_esc_0, 0);
+   if (!button_dev)
+   return 0;
+
+   input_report_key(button_dev, KEY_POWER, 1);
+   input_sync(button_dev);
+   input_report_key(button_dev, KEY_POWER, 0);
+   input_sync(button_dev);
+   return 1;
+   }
}
break;
 #ifdef CONFIG_CBE_RAS
@@ -155,3 +171,55 @@ void __init cbe_pervasive_init(void)
ppc_md.power_save = cbe_power_save;
ppc_md.system_reset_exception = cbe_system_reset_exception;
 }
+
+static int __init cbe_power_button_init(void)
+{
+   int ret;
+   struct input_dev *dev;
+
+   if (!sysreset_hack)
+   return 0;
+
+   dev = input_allocate_device();
+if (!dev) {
+   ret = -ENOMEM;
+printk(KERN_ERR %s: Not enough memory\n, __func__);
+goto out;
+}
+
+   set_bit(EV_KEY, dev-evbit);
+   set_bit(KEY_POWER, dev-keybit);
+
+   dev-name = Power Button;
+   dev-id.bustype = BUS_HOST;
+
+   /* this makes the button look like an acpi power button
+* no clue whether anyone relies on that though */
+   dev-id.product = 0x02;
+   dev-phys = LNXPWRBN/button/input0;
+
+   button_pdev = platform_device_register_simple(power_button, 0, NULL, 
0);
+   if (IS_ERR(button_pdev)) {
+   ret = PTR_ERR(button_pdev);
+   goto out_free_input;
+   }
+
+   dev-dev.parent = button_pdev-dev;
+
+   ret = input_register_device(dev);
+   if (ret) {
+printk(KERN_ERR %s: Failed to register device\n, __func__);
+   goto out_free_pdev;
+}
+
+   button_dev = dev;
+   return ret;
+
+out_free_pdev:
+   platform_device_unregister(button_pdev);
+out_free_input:
+   input_free_device(dev);
+out:
+   return ret;
+}
+device_initcall(cbe_power_button_init);
-- 
1.5.4.3

-- 

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


[patch 09/11] powerpc/cell: cell_dma_dev_setup_iommu() return the iommu table

2008-07-04 Thread arnd
Make cell_dma_dev_setup_iommu() return a pointer to the struct iommu_table
(or NULL if no table can be found) rather than putting this pointer into
dev-archdata.dma_data (let the caller do that), and rename this function
to cell_get_iommu_table() to reflect this change.

This will allow us to get the iommu table for a device that doesn't have
the table in the archdata.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/platforms/cell/iommu.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/cell/iommu.c 
b/arch/powerpc/platforms/cell/iommu.c
index b4fe598..3b70784 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -541,7 +541,7 @@ static unsigned long cell_dma_direct_offset;
 static unsigned long dma_iommu_fixed_base;
 struct dma_mapping_ops dma_iommu_fixed_ops;
 
-static void cell_dma_dev_setup_iommu(struct device *dev)
+static struct iommu_table *cell_get_iommu_table(struct device *dev)
 {
struct iommu_window *window;
struct cbe_iommu *iommu;
@@ -556,11 +556,11 @@ static void cell_dma_dev_setup_iommu(struct device *dev)
printk(KERN_ERR iommu: missing iommu for %s (node %d)\n,
   archdata-of_node ? archdata-of_node-full_name : ?,
   archdata-numa_node);
-   return;
+   return NULL;
}
window = list_entry(iommu-windows.next, struct iommu_window, list);
 
-   archdata-dma_data = window-table;
+   return window-table;
 }
 
 static void cell_dma_dev_setup_fixed(struct device *dev);
@@ -573,7 +573,7 @@ static void cell_dma_dev_setup(struct device *dev)
if (get_dma_ops(dev) == dma_iommu_fixed_ops)
cell_dma_dev_setup_fixed(dev);
else if (get_pci_dma_ops() == dma_iommu_ops)
-   cell_dma_dev_setup_iommu(dev);
+   archdata-dma_data = cell_get_iommu_table(dev);
else if (get_pci_dma_ops() == dma_direct_ops)
archdata-dma_data = (void *)cell_dma_direct_offset;
else
-- 
1.5.4.3

-- 

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


[patch 03/11] powerpc/axonram: enable partitioning of the Axons DDR2 DIMMs

2008-07-04 Thread arnd
DDR2 memory DIMMs on the Axon could be accessed only as one partition
when using file system drivers which are using the direct_access() method.
This patch enables for such file system drivers to access Axon's DDR2 memory
even if it is splitted in several partitions.

Signed-off-by: Maxim Shchetynin [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/axonram.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
index 9b639ed..9e105cb 100644
--- a/arch/powerpc/sysdev/axonram.c
+++ b/arch/powerpc/sysdev/axonram.c
@@ -150,7 +150,10 @@ axon_ram_direct_access(struct block_device *device, 
sector_t sector,
struct axon_ram_bank *bank = device-bd_disk-private_data;
loff_t offset;
 
-   offset = sector  AXON_RAM_SECTOR_SHIFT;
+   offset = sector;
+   if (device-bd_part != NULL)
+   offset += device-bd_part-start_sect;
+   offset = AXON_RAM_SECTOR_SHIFT;
if (offset = bank-size) {
dev_err(bank-device-dev, Access outside of address 
space\n);
return -ERANGE;
-- 
1.5.4.3

-- 

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


[patch 07/11] powerpc/dma: implement new dma_*map*_attrs() interfaces

2008-07-04 Thread arnd
Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so
update struct dma_mapping_ops to accept a struct dma_attrs and propagate
these changes through to all users of the code (generic IOMMU and the
64bit DMA code, and the iseries and ps3 platform code).

The old dma_*map_*() interfaces are reimplemented as calls to the
corresponding new interfaces.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig|1 +
 arch/powerpc/kernel/dma_64.c|   34 ++---
 arch/powerpc/kernel/ibmebus.c   |   12 ++-
 arch/powerpc/kernel/iommu.c |   11 ++-
 arch/powerpc/platforms/iseries/iommu.c  |4 +-
 arch/powerpc/platforms/ps3/system-bus.c |   17 +++--
 include/asm-powerpc/dma-mapping.h   |  116 +++
 include/asm-powerpc/iommu.h |   12 ++-
 8 files changed, 144 insertions(+), 63 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index f2a0f50..462c86a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -110,6 +110,7 @@ config PPC
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_LMB
+   select HAVE_DMA_ATTRS
 
 config EARLY_PRINTK
bool
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 7397445..3ae0c35 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -50,32 +50,38 @@ static void dma_iommu_free_coherent(struct device *dev, 
size_t size,
  */
 static dma_addr_t dma_iommu_map_single(struct device *dev, void *vaddr,
   size_t size,
-  enum dma_data_direction direction)
+  enum dma_data_direction direction,
+  struct dma_attrs *attrs)
 {
return iommu_map_single(dev, dev-archdata.dma_data, vaddr, size,
-   device_to_mask(dev), direction);
+   device_to_mask(dev), direction, attrs);
 }
 
 
 static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
   size_t size,
-  enum dma_data_direction direction)
+  enum dma_data_direction direction,
+  struct dma_attrs *attrs)
 {
-   iommu_unmap_single(dev-archdata.dma_data, dma_handle, size, direction);
+   iommu_unmap_single(dev-archdata.dma_data, dma_handle, size, direction,
+  attrs);
 }
 
 
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-   int nelems, enum dma_data_direction direction)
+   int nelems, enum dma_data_direction direction,
+   struct dma_attrs *attrs)
 {
return iommu_map_sg(dev, dev-archdata.dma_data, sglist, nelems,
-   device_to_mask(dev), direction);
+   device_to_mask(dev), direction, attrs);
 }
 
 static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
-   int nelems, enum dma_data_direction direction)
+   int nelems, enum dma_data_direction direction,
+   struct dma_attrs *attrs)
 {
-   iommu_unmap_sg(dev-archdata.dma_data, sglist, nelems, direction);
+   iommu_unmap_sg(dev-archdata.dma_data, sglist, nelems, direction,
+  attrs);
 }
 
 /* We support DMA to/from any memory page via the iommu */
@@ -148,19 +154,22 @@ static void dma_direct_free_coherent(struct device *dev, 
size_t size,
 
 static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
size_t size,
-   enum dma_data_direction direction)
+   enum dma_data_direction direction,
+   struct dma_attrs *attrs)
 {
return virt_to_abs(ptr) + get_dma_direct_offset(dev);
 }
 
 static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
size_t size,
-   enum dma_data_direction direction)
+   enum dma_data_direction direction,
+   struct dma_attrs *attrs)
 {
 }
 
 static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
-int nents, enum dma_data_direction direction)
+int nents, enum dma_data_direction direction,
+struct dma_attrs *attrs)
 {
struct scatterlist *sg;
int i;
@@ -174,7 +183,8 @@ static int dma_direct_map_sg(struct device *dev, struct 
scatterlist *sgl,
 }
 
 static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
-  

[patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

2008-07-04 Thread arnd
As nr_active counter includes also spus waiting for syscalls to return
we need a seperate counter that only counts spus that are currently running
on spu side. This counter shall be used by a cpufreq governor that targets
a frequency dependent from the number of running spus.

From: Maxim Shchetynin [EMAIL PROTECTED]
Signed-off-by: Christian Krafft [EMAIL PROTECTED]
---
 arch/powerpc/platforms/cell/spufs/sched.c |6 ++
 include/asm-powerpc/spu.h |1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/sched.c 
b/arch/powerpc/platforms/cell/spufs/sched.c
index e929e70..be77910 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -993,6 +993,7 @@ void spuctx_switch_state(struct spu_context *ctx,
struct timespec ts;
struct spu *spu;
enum spu_utilization_state old_state;
+   int node;
 
ktime_get_ts(ts);
curtime = timespec_to_ns(ts);
@@ -1014,6 +1015,11 @@ void spuctx_switch_state(struct spu_context *ctx,
spu-stats.times[old_state] += delta;
spu-stats.util_state = new_state;
spu-stats.tstamp = curtime;
+   node = spu-node;
+   if (old_state == SPU_UTIL_USER)
+   atomic_dec(cbe_spu_info[node].busy_spus);
+   if (new_state == SPU_UTIL_USER);
+   atomic_inc(cbe_spu_info[node].busy_spus);
}
 }
 
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index 99348c1..8b2eb04 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -191,6 +191,7 @@ struct cbe_spu_info {
struct list_head spus;
int n_spus;
int nr_active;
+   atomic_t busy_spus;
atomic_t reserved_spus;
 };
 
-- 
1.5.4.3

-- 

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


[patch 10/11] powerpc: move device_to_mask() to dma-mapping.h

2008-07-04 Thread arnd
Move device_to_mask() to dma-mapping.h because we need to use it from
outside dma_64.c in a later patch.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/kernel/dma_64.c  |9 -
 include/asm-powerpc/dma-mapping.h |9 +
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 3ae0c35..ae5708e 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -15,15 +15,6 @@
  * Generic iommu implementation
  */
 
-static inline unsigned long device_to_mask(struct device *dev)
-{
-   if (dev-dma_mask  *dev-dma_mask)
-   return *dev-dma_mask;
-   /* Assume devices without mask can take 32 bit addresses */
-   return 0xul;
-}
-
-
 /* Allocates a contiguous real buffer and creates mappings over it.
  * Returns the virtual address of the buffer and sets dma_handle
  * to the dma address (mapping) of the first page.
diff --git a/include/asm-powerpc/dma-mapping.h 
b/include/asm-powerpc/dma-mapping.h
index de13950..74c5497 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -45,6 +45,15 @@ extern void __dma_sync_page(struct page *page, unsigned long 
offset,
 #endif /* ! CONFIG_NOT_COHERENT_CACHE */
 
 #ifdef CONFIG_PPC64
+
+static inline unsigned long device_to_mask(struct device *dev)
+{
+   if (dev-dma_mask  *dev-dma_mask)
+   return *dev-dma_mask;
+   /* Assume devices without mask can take 32 bit addresses */
+   return 0xul;
+}
+
 /*
  * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
  */
-- 
1.5.4.3

-- 

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


[patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

2008-07-04 Thread arnd
Introduce a new dma attriblue DMA_ATTR_STRONG_ORDERING to use strong ordering
on DMA mappings in the Cell processor. Add the code to the Cell's IOMMU
implementation to use this.

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs
(for both the dynamic and fixed mappings) which enforces strong ordering of
both reads and writes. This patch makes the default behaviour weak ordering
(the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the
new DMA_ATTR_STRONG_ORDERING needs to be used.

Dynamic mappings can be weakly or strongly ordered on an individual basis
but the fixed mapping is always weakly ordered.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 Documentation/DMA-attributes.txt|   12 +
 arch/powerpc/platforms/cell/iommu.c |   93 ---
 include/linux/dma-attrs.h   |1 +
 3 files changed, 99 insertions(+), 7 deletions(-)

diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt
index 6d772f8..f2d2800 100644
--- a/Documentation/DMA-attributes.txt
+++ b/Documentation/DMA-attributes.txt
@@ -22,3 +22,15 @@ ready and available in memory.  The DMA of the completion 
indication
 could race with data DMA.  Mapping the memory used for completion
 indications with DMA_ATTR_WRITE_BARRIER would prevent the race.
 
+
+DMA_ATTR_STRONG_ORDERING
+--
+
+DMA_ATTR_STRONG_ORDERING specifies that previous reads and writes are
+performed in the order in which they're received by the IOMMU; thus
+reads and writes may not pass each other.
+
+Platforms that are strongly ordered by default will ignore this new
+attribute but platforms that are weakly ordered by default should not
+ignore this new attribute. Instead, they should return an error if a
+strongly ordered mapping cannot be used when one is requested.
diff --git a/arch/powerpc/platforms/cell/iommu.c 
b/arch/powerpc/platforms/cell/iommu.c
index 3b70784..7f6ed20 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -194,11 +194,13 @@ static void tce_build_cell(struct iommu_table *tbl, long 
index, long npages,
const unsigned long prot = 0xc48;
base_pte =
((prot  (52 + 4 * direction))  (IOPTE_PP_W | IOPTE_PP_R))
-   | IOPTE_M | IOPTE_SO_RW | (window-ioid  IOPTE_IOID_Mask);
+   | IOPTE_M | (window-ioid  IOPTE_IOID_Mask);
 #else
-   base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW |
+   base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M |
(window-ioid  IOPTE_IOID_Mask);
 #endif
+   if (unlikely(dma_get_attr(DMA_ATTR_STRONG_ORDERING, attrs)))
+   base_pte |= IOPTE_SO_RW;
 
io_pte = (unsigned long *)tbl-it_base + (index - tbl-it_offset);
 
@@ -539,7 +541,6 @@ static struct cbe_iommu *cell_iommu_for_node(int nid)
 static unsigned long cell_dma_direct_offset;
 
 static unsigned long dma_iommu_fixed_base;
-struct dma_mapping_ops dma_iommu_fixed_ops;
 
 static struct iommu_table *cell_get_iommu_table(struct device *dev)
 {
@@ -563,6 +564,85 @@ static struct iommu_table *cell_get_iommu_table(struct 
device *dev)
return window-table;
 }
 
+static void *dma_fixed_alloc_coherent(struct device *dev, size_t size,
+ dma_addr_t *dma_handle, gfp_t flag)
+{
+   return dma_direct_ops.alloc_coherent(dev, size, dma_handle, flag);
+}
+
+static void dma_fixed_free_coherent(struct device *dev, size_t size,
+   void *vaddr, dma_addr_t dma_handle)
+{
+   dma_direct_ops.free_coherent(dev, size, vaddr, dma_handle);
+}
+
+static dma_addr_t dma_fixed_map_single(struct device *dev, void *ptr,
+  size_t size,
+  enum dma_data_direction direction,
+  struct dma_attrs *attrs)
+{
+   if (dma_get_attr(DMA_ATTR_STRONG_ORDERING, attrs))
+   return iommu_map_single(dev, cell_get_iommu_table(dev), ptr,
+   size, device_to_mask(dev), direction,
+   attrs);
+   else
+   return dma_direct_ops.map_single(dev, ptr, size, direction,
+attrs);
+}
+
+static void dma_fixed_unmap_single(struct device *dev, dma_addr_t dma_addr,
+  size_t size,
+  enum dma_data_direction direction,
+  struct dma_attrs *attrs)
+{
+   if (dma_get_attr(DMA_ATTR_STRONG_ORDERING, attrs))
+   iommu_unmap_single(cell_get_iommu_table(dev), dma_addr, size,
+  direction, attrs);
+   else
+   dma_direct_ops.unmap_single(dev, dma_addr, size, direction,
+   attrs);
+}
+
+static int 

[patch 00/11] Cell patches for 2.6.27

2008-07-04 Thread arnd
Hi Paul and Ben,

These are the cell related patches I would like to see in
2.6.27. If there are no further comments, please pull into
powerpc-next from

master.kernel.org/pub/scm/linux/kernel/git/arnd/cell-2.6.git cell-next

-- 

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


[patch 08/11] powerpc/dma: use the struct dma_attrs in iommu code

2008-07-04 Thread arnd
Update iommu_alloc() to take the struct dma_attrs and pass them on to
tce_build(). This change propagates down to the tce_build functions of
all the platforms.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/kernel/iommu.c|   13 -
 arch/powerpc/platforms/cell/iommu.c|5 +++--
 arch/powerpc/platforms/iseries/iommu.c |3 ++-
 arch/powerpc/platforms/pasemi/iommu.c  |3 ++-
 arch/powerpc/platforms/pseries/iommu.c |   14 +-
 arch/powerpc/sysdev/dart_iommu.c   |3 ++-
 include/asm-powerpc/machdep.h  |3 ++-
 7 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 8c68ee9..2385f68 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -186,7 +186,8 @@ static unsigned long iommu_range_alloc(struct device *dev,
 static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
  void *page, unsigned int npages,
  enum dma_data_direction direction,
- unsigned long mask, unsigned int align_order)
+ unsigned long mask, unsigned int align_order,
+ struct dma_attrs *attrs)
 {
unsigned long entry, flags;
dma_addr_t ret = DMA_ERROR_CODE;
@@ -205,7 +206,7 @@ static dma_addr_t iommu_alloc(struct device *dev, struct 
iommu_table *tbl,
 
/* Put the TCEs in the HW table */
ppc_md.tce_build(tbl, entry, npages, (unsigned long)page  
IOMMU_PAGE_MASK,
-direction);
+direction, attrs);
 
 
/* Flush/invalidate TLB caches if necessary */
@@ -336,7 +337,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table 
*tbl,
npages, entry, dma_addr);
 
/* Insert into HW table */
-   ppc_md.tce_build(tbl, entry, npages, vaddr  IOMMU_PAGE_MASK, 
direction);
+   ppc_md.tce_build(tbl, entry, npages, vaddr  IOMMU_PAGE_MASK,
+direction, attrs);
 
/* If we are in an open segment, try merging */
if (segstart != s) {
@@ -573,7 +575,8 @@ dma_addr_t iommu_map_single(struct device *dev, struct 
iommu_table *tbl,
align = PAGE_SHIFT - IOMMU_PAGE_SHIFT;
 
dma_handle = iommu_alloc(dev, tbl, vaddr, npages, direction,
-mask  IOMMU_PAGE_SHIFT, align);
+mask  IOMMU_PAGE_SHIFT, align,
+attrs);
if (dma_handle == DMA_ERROR_CODE) {
if (printk_ratelimit())  {
printk(KERN_INFO iommu_alloc failed, 
@@ -642,7 +645,7 @@ void *iommu_alloc_coherent(struct device *dev, struct 
iommu_table *tbl,
nio_pages = size  IOMMU_PAGE_SHIFT;
io_order = get_iommu_order(size);
mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
- mask  IOMMU_PAGE_SHIFT, io_order);
+ mask  IOMMU_PAGE_SHIFT, io_order, NULL);
if (mapping == DMA_ERROR_CODE) {
free_pages((unsigned long)ret, order);
return NULL;
diff --git a/arch/powerpc/platforms/cell/iommu.c 
b/arch/powerpc/platforms/cell/iommu.c
index 45646b2..b4fe598 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -173,7 +173,8 @@ static void invalidate_tce_cache(struct cbe_iommu *iommu, 
unsigned long *pte,
 }
 
 static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
-   unsigned long uaddr, enum dma_data_direction direction)
+   unsigned long uaddr, enum dma_data_direction direction,
+   struct dma_attrs *attrs)
 {
int i;
unsigned long *io_pte, base_pte;
@@ -519,7 +520,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct 
device_node *np,
 
__set_bit(0, window-table.it_map);
tce_build_cell(window-table, window-table.it_offset, 1,
-  (unsigned long)iommu-pad_page, DMA_TO_DEVICE);
+  (unsigned long)iommu-pad_page, DMA_TO_DEVICE, NULL);
window-table.it_hint = window-table.it_blocksize;
 
return window;
diff --git a/arch/powerpc/platforms/iseries/iommu.c 
b/arch/powerpc/platforms/iseries/iommu.c
index ab5d868..bc818e4 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -42,7 +42,8 @@
 #include asm/iseries/iommu.h
 
 static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
-   unsigned long uaddr, enum dma_data_direction direction)
+   unsigned long uaddr, enum dma_data_direction direction,
+   struct dma_attrs 

[patch 06/11] powerpc: Add struct iommu_table argument to iommu_map_sg()

2008-07-04 Thread arnd
Make iommu_map_sg take a struct iommu_table. It did so before commit
740c3ce66700640a6e6136ff679b067e92125794 (iommu sg merging: ppc: make
iommu respect the segment size limits).

This stops the function looking in the archdata.dma_data for the iommu
table because in the future it will be called with a device that has
no table there.

This also has the nice side effect of making iommu_map_sg() match the
other map functions.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/kernel/dma_64.c |2 +-
 arch/powerpc/kernel/iommu.c  |7 +++
 include/asm-powerpc/iommu.h  |6 +++---
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 3a317cb..7397445 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -68,7 +68,7 @@ static void dma_iommu_unmap_single(struct device *dev, 
dma_addr_t dma_handle,
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction)
 {
-   return iommu_map_sg(dev, sglist, nelems,
+   return iommu_map_sg(dev, dev-archdata.dma_data, sglist, nelems,
device_to_mask(dev), direction);
 }
 
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 0c66366..ccf00fe 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -267,11 +267,10 @@ static void iommu_free(struct iommu_table *tbl, 
dma_addr_t dma_addr,
spin_unlock_irqrestore((tbl-it_lock), flags);
 }
 
-int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-int nelems, unsigned long mask,
-enum dma_data_direction direction)
+int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
+struct scatterlist *sglist, int nelems,
+unsigned long mask, enum dma_data_direction direction)
 {
-   struct iommu_table *tbl = dev-archdata.dma_data;
dma_addr_t dma_next = 0, dma_addr;
unsigned long flags;
struct scatterlist *s, *outs, *segstart;
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index 852e15f..65f6682 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -79,9 +79,9 @@ extern void iommu_free_table(struct iommu_table *tbl, const 
char *node_name);
 extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
int nid);
 
-extern int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-   int nelems, unsigned long mask,
-   enum dma_data_direction direction);
+extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
+   struct scatterlist *sglist, int nelems,
+   unsigned long mask, enum dma_data_direction direction);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
   int nelems, enum dma_data_direction direction);
 
-- 
1.5.4.3

-- 

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


[patch 02/11] powerpc/axonram: use only one block device major number

2008-07-04 Thread arnd
Axonram module registers one block device for each DDR2 DIMM found
on a system. This means that each DDR2 DIMM becomes its own block device
major number. This patch lets axonram module to register the only one
block device for all DDR2 DIMMs which also spares kernel resources.

Signed-off-by: Maxim Shchetynin [EMAIL PROTECTED]
Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/axonram.c |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
index 7f59188..9b639ed 100644
--- a/arch/powerpc/sysdev/axonram.c
+++ b/arch/powerpc/sysdev/axonram.c
@@ -57,6 +57,8 @@
 #define AXON_RAM_SECTOR_SIZE   1  AXON_RAM_SECTOR_SHIFT
 #define AXON_RAM_IRQ_FLAGS IRQF_SHARED | IRQF_TRIGGER_RISING
 
+static int azfs_major, azfs_minor;
+
 struct axon_ram_bank {
struct of_device*device;
struct gendisk  *disk;
@@ -227,19 +229,14 @@ axon_ram_probe(struct of_device *device, const struct 
of_device_id *device_id)
goto failed;
}
 
-   bank-disk-first_minor = 0;
+   bank-disk-major = azfs_major;
+   bank-disk-first_minor = azfs_minor;
bank-disk-fops = axon_ram_devops;
bank-disk-private_data = bank;
bank-disk-driverfs_dev = device-dev;
 
sprintf(bank-disk-disk_name, %s%d,
AXON_RAM_DEVICE_NAME, axon_ram_bank_id);
-   bank-disk-major = register_blkdev(0, bank-disk-disk_name);
-   if (bank-disk-major  0) {
-   dev_err(device-dev, Cannot register block device\n);
-   rc = -EFAULT;
-   goto failed;
-   }
 
bank-disk-queue = blk_alloc_queue(GFP_KERNEL);
if (bank-disk-queue == NULL) {
@@ -276,6 +273,8 @@ axon_ram_probe(struct of_device *device, const struct 
of_device_id *device_id)
goto failed;
}
 
+   azfs_minor += bank-disk-minors;
+
return 0;
 
 failed:
@@ -310,7 +309,6 @@ axon_ram_remove(struct of_device *device)
 
device_remove_file(device-dev, dev_attr_ecc);
free_irq(bank-irq_id, device);
-   unregister_blkdev(bank-disk-major, bank-disk-disk_name);
del_gendisk(bank-disk);
iounmap((void __iomem *) bank-io_addr);
kfree(bank);
@@ -341,6 +339,14 @@ static struct of_platform_driver axon_ram_driver = {
 static int __init
 axon_ram_init(void)
 {
+   azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
+   if (azfs_major  0) {
+   printk(KERN_ERR %s cannot become block device major number\n,
+   AXON_RAM_MODULE_NAME);
+   return -EFAULT;
+   }
+   azfs_minor = 0;
+
return of_register_platform_driver(axon_ram_driver);
 }
 
@@ -351,6 +357,7 @@ static void __exit
 axon_ram_exit(void)
 {
of_unregister_platform_driver(axon_ram_driver);
+   unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
 }
 
 module_init(axon_ram_init);
-- 
1.5.4.3

-- 

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


[patch 05/11] powerpc/cell: add spu aware cpufreq governor

2008-07-04 Thread arnd
This patch adds a cpufreq governor that takes the number of running spus
into account. It's very similar to the ondemand governor, but not as complex.
Instead of hacking spu load into the ondemand governor it might be easier to
have cpufreq accepting multiple governors per cpu in future.
Don't know if this is the right way, but it would keep the governors simple.

Signed-off-by: Christian Krafft [EMAIL PROTECTED]
---
 arch/powerpc/platforms/cell/Kconfig|   10 ++
 arch/powerpc/platforms/cell/Makefile   |1 +
 arch/powerpc/platforms/cell/cbe_spu_governor.c |  183 
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/cell/cbe_spu_governor.c

diff --git a/arch/powerpc/platforms/cell/Kconfig 
b/arch/powerpc/platforms/cell/Kconfig
index 3959fcf..2dfff9f 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -107,6 +107,16 @@ config CBE_CPUFREQ_PMI
  processor will not only be able to run at lower speed,
  but also at lower core voltage.
 
+config CBE_CPUFREQ_SPU_GOVERNOR
+   tristate CBE frequency scaling based on SPU usage
+   depends on SPU_FS
+   select CBE_CPUFREQ
+   default m
+   help
+ This governor checks for spu usage to adjust the cpu frequency.
+ If no spu is running on a given cpu, that cpu will be throttled to
+ the minimal possible frequency.
+
 endmenu
 
 config OPROFILE_CELL
diff --git a/arch/powerpc/platforms/cell/Makefile 
b/arch/powerpc/platforms/cell/Makefile
index c2a7e4e..8be5158 100644
--- a/arch/powerpc/platforms/cell/Makefile
+++ b/arch/powerpc/platforms/cell/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_CBE_THERM) += cbe_thermal.o
 obj-$(CONFIG_CBE_CPUFREQ_PMI)  += cbe_cpufreq_pmi.o
 obj-$(CONFIG_CBE_CPUFREQ)  += cbe-cpufreq.o
 cbe-cpufreq-y  += cbe_cpufreq_pervasive.o cbe_cpufreq.o
+obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR) += cbe_spu_governor.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_CELL_NATIVE)  += smp.o
diff --git a/arch/powerpc/platforms/cell/cbe_spu_governor.c 
b/arch/powerpc/platforms/cell/cbe_spu_governor.c
new file mode 100644
index 000..7e63009
--- /dev/null
+++ b/arch/powerpc/platforms/cell/cbe_spu_governor.c
@@ -0,0 +1,183 @@
+/*
+ * spu aware cpufreq governor for the cell processor
+ *
+ * (C) Copyright IBM Corporation 2006-2008
+ *
+ * Author: Christian Krafft [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/cpufreq.h
+#include linux/sched.h
+#include linux/timer.h
+#include linux/workqueue.h
+#include asm/atomic.h
+#include asm/machdep.h
+#include asm/spu.h
+
+#define POLL_TIME  10  /* in us */
+#define EXP753 /* exp(-1) in fixed-point */
+
+struct spu_gov_info_struct {
+   unsigned long busy_spus;/* fixed-point */
+   struct cpufreq_policy *policy;
+   struct delayed_work work;
+   unsigned int poll_int;  /* us */
+};
+static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
+
+static struct workqueue_struct *kspugov_wq;
+
+static int calc_freq(struct spu_gov_info_struct *info)
+{
+   int cpu;
+   int busy_spus;
+
+   cpu = info-policy-cpu;
+   busy_spus = atomic_read(cbe_spu_info[cpu_to_node(cpu)].busy_spus);
+
+   CALC_LOAD(info-busy_spus, EXP, busy_spus * FIXED_1);
+   pr_debug(KERN_ERR cpu %d: busy_spus=%d, info-busy_spus=%d\n, cpu, 
busy_spus, info-busy_spus);
+
+   return info-policy-max * info-busy_spus / FIXED_1;
+}
+
+static void spu_gov_work(struct work_struct *work)
+{
+   struct spu_gov_info_struct *info;
+   int delay;
+   unsigned long target_freq;
+
+   info = container_of(work, struct spu_gov_info_struct, work.work);
+
+   /* after cancel_delayed_work_sync we unset info-policy */
+   BUG_ON(info-policy == NULL);
+
+   target_freq = calc_freq(info);
+   __cpufreq_driver_target(info-policy, target_freq, CPUFREQ_RELATION_H);
+
+   delay = usecs_to_jiffies(info-poll_int);
+   queue_delayed_work_on(info-policy-cpu, kspugov_wq, info-work, 
delay);
+}
+
+static void spu_gov_init_work(struct spu_gov_info_struct *info)
+{
+   int delay = usecs_to_jiffies(info-poll_int);
+   

Re: the printk problem

2008-07-04 Thread Linus Torvalds


On Fri, 4 Jul 2008, Linus Torvalds wrote:
 
 so I think we could easily just say that we extend %p in various ways:
 
  - %pS - print pointer as a symbol
 
 and leave tons of room for future extensions for different kinds of 
 pointers. 

So here's a totally untested example patch of this, which could probably 
easily be extended to to other things.

I actually made it '%pF' and '%pS' for a Function descriptor pointer and 
normal Symbolic pointer respectively, because of the stupid things ia64 
and PPC64 do with the pointer indirection through function descriptors. 

That function descriptor indirection is totally untested, and I did it 
with a

pagefault_disable();
__get_user(..)
pagefault_enable();

thing because I thought it would be nice if printk() was always safe, and 
passing bogus function pointers to '%pF' should try to work, but quite 
frankly, I didn't even check that that part compiles, much less works.

ia64/ppc lists cc'd, just in case somebody wants to test this.

NOTE! There are no current actual users of this, but the _idea_ is that we 
should be able to just do

printk(%pF\n, desc-handle_irq);

instead of using

print_symbol(%s\n, (unsigned long)desc-handle_irq);

The latter is from kernel/irq/internals.h, and actually looks incorrect - 
shouldn't it use print_fn_descriptor_symbol(), since it's a C level 
function pointer? We should use print_symbol() for return pointers we 
find on the stack and data pointers, but not for stuff that actually has a 
C type that is a function pointer?

Somebody who cares about the insane function descriptors should take a 
deeper look.

NOTE AGAIN! UNTESTED! I could easily have screwed up printk() _entirely_, 
since I had to factor out the string handling into a function of its own.

Linus
---
 lib/vsprintf.c |  102 ---
 1 files changed, 74 insertions(+), 28 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6021757..148b656 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -22,6 +22,7 @@
 #include linux/string.h
 #include linux/ctype.h
 #include linux/kernel.h
+#include linux/kallsyms.h
 
 #include asm/page.h  /* for PAGE_SIZE */
 #include asm/div64.h
@@ -482,6 +483,72 @@ static char *number(char *buf, char *end, unsigned long 
long num, int base, int
return buf;
 }
 
+static char *string(char *buf, char *end, char *s, int field_width, int 
precision, int flags)
+{
+   int len, i;
+
+   if ((unsigned long)s  PAGE_SIZE)
+   s = NULL;
+
+   len = strnlen(s, precision);
+
+   if (!(flags  LEFT)) {
+   while (len  field_width--) {
+   if (buf  end)
+   *buf = ' ';
+   ++buf;
+   }
+   }
+   for (i = 0; i  len; ++i) {
+   if (buf  end)
+   *buf = *s;
+   ++buf; ++s;
+   }
+   while (len  field_width--) {
+   if (buf  end)
+   *buf = ' ';
+   ++buf;
+   }
+   return buf;
+}
+
+/*
+ * Show a '%p' thing.  A kernel extension is that the '%p' is followed
+ * by an extra set of alphanumeric characters that are extended format
+ * specifiers.  Right now we just handle 'F' (for symbolic Function
+ * pointers) and 'S' (for Symbolic data pointers), but this can easily
+ * be extended in the future (network address types etc).
+ *
+ * The difference between 'S' and 'F' is that on ia64 and ppc64 function
+ * pointers are really function descriptors, which contain a pointer the
+ * real address. 
+ */
+static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int 
base, int size, int precision, int type)
+{
+   char sym[KSYM_SYMBOL_LEN];
+   switch (*fmt) {
+   case 'F':   /* Function pointer */
+#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
+   { void *p;
+   pagefault_disable();
+   if (!__get_user((void **)ptr, p))
+   ptr = p;
+   pagefault_enable();
+   }
+#endif
+   /* Fallthrough */
+   case 'S':   /* Other pointer */
+#if CONFIG_KALLSYMS
+   sprint_symbol(sym, (unsigned long) ptr);
+   return string(buf, end, sym, size, precision, type);
+#else
+   type |= SPECIAL;
+   break;
+#endif
+   }
+   return number(buf, end, (unsigned long long) ptr, base, size, 
precision, type);
+}
+
 /**
  * vsnprintf - Format a string and place it in a buffer
  * @buf: The buffer to place the result into
@@ -502,11 +569,9 @@ static char *number(char *buf, char *end, unsigned long 
long num, int base, int
  */
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
-   int len;
unsigned long long num;
-   int i, base;
+   int base;
char *str, *end, c;
-   const char *s;
 
int flags;

Re: the printk problem

2008-07-04 Thread Andrew Morton
On Fri, 4 Jul 2008 13:02:05 -0700 (PDT) Linus Torvalds [EMAIL PROTECTED] 
wrote:

 
 
 On Fri, 4 Jul 2008, Linus Torvalds wrote:
  
  so I think we could easily just say that we extend %p in various ways:
  
   - %pS - print pointer as a symbol
  
  and leave tons of room for future extensions for different kinds of 
  pointers. 
 
 So here's a totally untested example patch of this, which could probably 
 easily be extended to to other things.
 
 I actually made it '%pF' and '%pS' for a Function descriptor pointer and 
 normal Symbolic pointer respectively, because of the stupid things ia64 
 and PPC64 do with the pointer indirection through function descriptors. 
 
 That function descriptor indirection is totally untested, and I did it 
 with a
 
   pagefault_disable();
   __get_user(..)
   pagefault_enable();
 
 thing because I thought it would be nice if printk() was always safe, and 
 passing bogus function pointers to '%pF' should try to work, but quite 
 frankly, I didn't even check that that part compiles, much less works.

probe_kernel_address() should be usable here.

 ia64/ppc lists cc'd, just in case somebody wants to test this.
 
 NOTE! There are no current actual users of this, but the _idea_ is that we 
 should be able to just do
 
   printk(%pF\n, desc-handle_irq);
 
 instead of using
 
   print_symbol(%s\n, (unsigned long)desc-handle_irq);
 
 The latter is from kernel/irq/internals.h, and actually looks incorrect - 
 shouldn't it use print_fn_descriptor_symbol(), since it's a C level 
 function pointer? We should use print_symbol() for return pointers we 
 find on the stack and data pointers, but not for stuff that actually has a 
 C type that is a function pointer?
 
 Somebody who cares about the insane function descriptors should take a 
 deeper look.
 
 NOTE AGAIN! UNTESTED! I could easily have screwed up printk() _entirely_, 
 since I had to factor out the string handling into a function of its own.
 
   Linus
 ---
  lib/vsprintf.c |  102 ---
  1 files changed, 74 insertions(+), 28 deletions(-)
 
 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
 index 6021757..148b656 100644
 --- a/lib/vsprintf.c
 +++ b/lib/vsprintf.c
 @@ -22,6 +22,7 @@
  #include linux/string.h
  #include linux/ctype.h
  #include linux/kernel.h
 +#include linux/kallsyms.h
  
  #include asm/page.h/* for PAGE_SIZE */
  #include asm/div64.h
 @@ -482,6 +483,72 @@ static char *number(char *buf, char *end, unsigned long 
 long num, int base, int
   return buf;
  }
  
 +static char *string(char *buf, char *end, char *s, int field_width, int 
 precision, int flags)
 +{
 + int len, i;
 +
 + if ((unsigned long)s  PAGE_SIZE)
 + s = NULL;

hm, is that needed for other reasons than it will fault?

otherwise we could walk the whole string with probe_kernel_address()
before we do anything with it.

That's slightly racy against vunmap and CONFIG_DEBUG_PAGEALLOC and
stuff.  Fixable by *never* dereferencing that pointer except via
probe_kernel_address().

 + len = strnlen(s, precision);
 +
 + if (!(flags  LEFT)) {
 + while (len  field_width--) {
 + if (buf  end)
 + *buf = ' ';
 + ++buf;
 + }
 + }
 + for (i = 0; i  len; ++i) {
 + if (buf  end)
 + *buf = *s;
 + ++buf; ++s;
 + }
 + while (len  field_width--) {
 + if (buf  end)
 + *buf = ' ';
 + ++buf;
 + }
 + return buf;
 +}
 +
 +/*
 + * Show a '%p' thing.  A kernel extension is that the '%p' is followed
 + * by an extra set of alphanumeric characters that are extended format
 + * specifiers.  Right now we just handle 'F' (for symbolic Function
 + * pointers) and 'S' (for Symbolic data pointers), but this can easily
 + * be extended in the future (network address types etc).
 + *
 + * The difference between 'S' and 'F' is that on ia64 and ppc64 function
 + * pointers are really function descriptors, which contain a pointer the
 + * real address. 
 + */
 +static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int 
 base, int size, int precision, int type)
 +{
 + char sym[KSYM_SYMBOL_LEN];
 + switch (*fmt) {
 + case 'F':   /* Function pointer */
 +#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
 + { void *p;
 + pagefault_disable();
 + if (!__get_user((void **)ptr, p))
 + ptr = p;
 + pagefault_enable();
 + }
 +#endif
 + /* Fallthrough */
 + case 'S':   /* Other pointer */
 +#if CONFIG_KALLSYMS
 + sprint_symbol(sym, (unsigned long) ptr);
 + return string(buf, end, sym, size, precision, type);
 +#else
 + type |= SPECIAL;
 + break;
 +#endif
 + }
 + return number(buf, end, (unsigned long 

Re: the printk problem

2008-07-04 Thread Matthew Wilcox
On Fri, Jul 04, 2008 at 01:02:05PM -0700, Linus Torvalds wrote:
 On Fri, 4 Jul 2008, Linus Torvalds wrote:
  
  so I think we could easily just say that we extend %p in various ways:
  
   - %pS - print pointer as a symbol
  
  and leave tons of room for future extensions for different kinds of 
  pointers. 
 
 So here's a totally untested example patch of this, which could probably 
 easily be extended to to other things.
 
 I actually made it '%pF' and '%pS' for a Function descriptor pointer and 
 normal Symbolic pointer respectively, because of the stupid things ia64 
 and PPC64 do with the pointer indirection through function descriptors. 

It's also true for parisc, fwiw.  Added a cc to them.

 That function descriptor indirection is totally untested, and I did it 
 with a
 
   pagefault_disable();
   __get_user(..)
   pagefault_enable();
 
 thing because I thought it would be nice if printk() was always safe, and 
 passing bogus function pointers to '%pF' should try to work, but quite 
 frankly, I didn't even check that that part compiles, much less works.
 
 ia64/ppc lists cc'd, just in case somebody wants to test this.
 
 NOTE! There are no current actual users of this, but the _idea_ is that we 
 should be able to just do
 
   printk(%pF\n, desc-handle_irq);
 
 instead of using
 
   print_symbol(%s\n, (unsigned long)desc-handle_irq);
 
 The latter is from kernel/irq/internals.h, and actually looks incorrect - 
 shouldn't it use print_fn_descriptor_symbol(), since it's a C level 
 function pointer? We should use print_symbol() for return pointers we 
 find on the stack and data pointers, but not for stuff that actually has a 
 C type that is a function pointer?
 
 Somebody who cares about the insane function descriptors should take a 
 deeper look.
 
 NOTE AGAIN! UNTESTED! I could easily have screwed up printk() _entirely_, 
 since I had to factor out the string handling into a function of its own.
 
   Linus
 ---
  lib/vsprintf.c |  102 ---
  1 files changed, 74 insertions(+), 28 deletions(-)
 
 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
 index 6021757..148b656 100644
 --- a/lib/vsprintf.c
 +++ b/lib/vsprintf.c
 @@ -22,6 +22,7 @@
  #include linux/string.h
  #include linux/ctype.h
  #include linux/kernel.h
 +#include linux/kallsyms.h
  
  #include asm/page.h/* for PAGE_SIZE */
  #include asm/div64.h
 @@ -482,6 +483,72 @@ static char *number(char *buf, char *end, unsigned long 
 long num, int base, int
   return buf;
  }
  
 +static char *string(char *buf, char *end, char *s, int field_width, int 
 precision, int flags)
 +{
 + int len, i;
 +
 + if ((unsigned long)s  PAGE_SIZE)
 + s = NULL;
 +
 + len = strnlen(s, precision);
 +
 + if (!(flags  LEFT)) {
 + while (len  field_width--) {
 + if (buf  end)
 + *buf = ' ';
 + ++buf;
 + }
 + }
 + for (i = 0; i  len; ++i) {
 + if (buf  end)
 + *buf = *s;
 + ++buf; ++s;
 + }
 + while (len  field_width--) {
 + if (buf  end)
 + *buf = ' ';
 + ++buf;
 + }
 + return buf;
 +}
 +
 +/*
 + * Show a '%p' thing.  A kernel extension is that the '%p' is followed
 + * by an extra set of alphanumeric characters that are extended format
 + * specifiers.  Right now we just handle 'F' (for symbolic Function
 + * pointers) and 'S' (for Symbolic data pointers), but this can easily
 + * be extended in the future (network address types etc).
 + *
 + * The difference between 'S' and 'F' is that on ia64 and ppc64 function
 + * pointers are really function descriptors, which contain a pointer the
 + * real address. 
 + */
 +static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int 
 base, int size, int precision, int type)
 +{
 + char sym[KSYM_SYMBOL_LEN];
 + switch (*fmt) {
 + case 'F':   /* Function pointer */
 +#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
 + { void *p;
 + pagefault_disable();
 + if (!__get_user((void **)ptr, p))
 + ptr = p;
 + pagefault_enable();
 + }
 +#endif
 + /* Fallthrough */
 + case 'S':   /* Other pointer */
 +#if CONFIG_KALLSYMS
 + sprint_symbol(sym, (unsigned long) ptr);
 + return string(buf, end, sym, size, precision, type);
 +#else
 + type |= SPECIAL;
 + break;
 +#endif
 + }
 + return number(buf, end, (unsigned long long) ptr, base, size, 
 precision, type);
 +}
 +
  /**
   * vsnprintf - Format a string and place it in a buffer
   * @buf: The buffer to place the result into
 @@ -502,11 +569,9 @@ static char *number(char *buf, char *end, unsigned long 
 long num, int base, int
   */
  int vsnprintf(char *buf, size_t size, const char *fmt, 

Re: the printk problem

2008-07-04 Thread Linus Torvalds


On Fri, 4 Jul 2008, Andrew Morton wrote:
 
 probe_kernel_address() should be usable here.

Right you are.

  +static char *string(char *buf, char *end, char *s, int field_width, int 
  precision, int flags)
  +{
  +   int len, i;
  +
  +   if ((unsigned long)s  PAGE_SIZE)
  +   s = NULL;
 
 hm, is that needed for other reasons than it will fault?

It's similar to what glibc does - showing a NULL ptr gracefully. They are 
pretty common, and it's very rude to SIGSEGV or oops just because you 
wanted to print a string out for debugging.

The code is also just copied from the old code - just moved it to a 
function of its own.

 otherwise we could walk the whole string with probe_kernel_address()
 before we do anything with it.

That would be pretty slow, wed' be better off then unrolling it (ie doing 
all the ugly setup around the whole string).

 If this takes off we might want a register-your-printk-handler
 interface.  Maybe.

Yeah. 

 We also jump through hoops to print things like sector_t and
 resource_size_t.  They always need to be cast to `unsiged long long',
 which generates additional stack space and text in some setups.

Indeed. Though doing it with a pointer is often not a _whole_ lot cleaner, 
but yes, it's often nicer to add a '' than adding a cast.

 And then there's the perennial need to cast u64 to unsigned long long
 to print it.  If we were to do
 
   printk(%SL, (void *)some_u64);
 
 then that's still bloody ugly, but it'll save a little text-n-stack.

No can do. (void *) isn't big enough to hold a u64. So it would have to be 
something like this:

printk(%p64i, some_u64);

instead. Avoiding the cast, and often being more efficient calling 
convention on 32-bit.

But it can often generate worse code too - now we're taking an address of 
a variable, and that will disable many optimizations because now i's not a 
purely local variable that the compiler knows all uses for any more.

So I'm not entirely conviced it's a good idea to do this for just long 
long cases. Dunno.

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


Re: the printk problem

2008-07-04 Thread Matthew Wilcox
On Fri, Jul 04, 2008 at 01:27:16PM -0700, Andrew Morton wrote:
 On Fri, 4 Jul 2008 13:02:05 -0700 (PDT) Linus Torvalds [EMAIL PROTECTED] 
 wrote:
   so I think we could easily just say that we extend %p in various ways:
   
- %pS - print pointer as a symbol
   
   and leave tons of room for future extensions for different kinds of 
   pointers. 
 
 If this takes off we might want a register-your-printk-handler
 interface.  Maybe.
 
 We also jump through hoops to print things like sector_t and
 resource_size_t.  They always need to be cast to `unsiged long long',
 which generates additional stack space and text in some setups.

The thing is that GCC checks types.  So it's fine to add print this
pointer specially, but you can't in general add new printf arguments
without also hacking GCC.  Unless you use -Wno-format, and require
sparse to check special kernel types.

 And then there's the perennial need to cast u64 to unsigned long long
 to print it.  If we were to do
 
   printk(%SL, (void *)some_u64);
 
 then that's still bloody ugly, but it'll save a little text-n-stack.

u64 is easy to fix, and I don't know why we haven't.  Just make it
unsigned long long on all architectures.

-- 
Intel are signing my paycheques ... these opinions are still mine
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 3/3] ALSA SoC: Add Texas Instruments TLV320AIC26 codec driver

2008-07-04 Thread Mark Brown
On Tue, Jul 01, 2008 at 05:53:40PM -0600, Grant Likely wrote:

 +static ssize_t aic26_keyclick_show(struct device *dev,
 +struct device_attribute *attr, char *buf)
 +{
 + struct aic26 *aic26 = dev_get_drvdata(dev);
 + int val, amp, freq, len;
 +
 + val = aic26_reg_read_cache(aic26-codec, AIC26_REG_AUDIO_CTRL2);
 + amp = (val  12)  0x7;
 + freq = (125  ((val  8)  0x7))  1;
 + len = 2 * (1 +((val  8)  0xf));
 +
 + return sprintf(buf, amp=%x freq=%iHz len=%iclks\n, amp, freq, len);
 +}

It might be nice if these parameters were exposed as controls if they
can be configured, though obviously that's not essential.

 + /* Tell the of_soc helper about this codec */
 + of_snd_soc_register_codec(aic26_soc_codec_dev, aic26, aic26_dai,
 +   spi-dev.archdata.of_node);

Does this need to be ifdefed out if of_snd_soc_register_codec() is not
in use or is the function stubbed out if it's not in use?  Stubbing it
out would be cleaner.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: the printk problem

2008-07-04 Thread Andrew Morton

(heck, let's cc lkml - avoid having to go through all this again)

On Fri, 4 Jul 2008 14:42:53 -0600 Matthew Wilcox [EMAIL PROTECTED] wrote:

 On Fri, Jul 04, 2008 at 01:27:16PM -0700, Andrew Morton wrote:
  On Fri, 4 Jul 2008 13:02:05 -0700 (PDT) Linus Torvalds [EMAIL PROTECTED] 
  wrote:
so I think we could easily just say that we extend %p in various ways:

 - %pS - print pointer as a symbol

and leave tons of room for future extensions for different kinds of 
pointers. 
  
  If this takes off we might want a register-your-printk-handler
  interface.  Maybe.
  
  We also jump through hoops to print things like sector_t and
  resource_size_t.  They always need to be cast to `unsiged long long',
  which generates additional stack space and text in some setups.
 
 The thing is that GCC checks types.  So it's fine to add print this
 pointer specially, but you can't in general add new printf arguments
 without also hacking GCC.  Unless you use -Wno-format, and require
 sparse to check special kernel types.

It would be excellent if gcc had an extension system so that you could
add new printf control chars and maybe even tell gcc how to check them.
But of course, if that were to happen, we couldn't use it for 4-5 years.

What I had initially proposed was to abuse %S, which takes a wchar_t*. 
gcc accepts `unsigned long *' for %S.

Then, we put the kernel-specific control char after the S, so we can
print an inode (rofl) with

struct inode *inode;

printk(here is an inode: %Si\n, (unsigned long *)inode);

Downsides are:

- there's a cast, so you could accidentally do

printk(here is an inode: %Si\n, (unsigned long *)dentry);

- there's a cast, and they're ugly

- gcc cannot of course check that the arg matches the control string

Unfortunately (and this seems weird), gcc printf checking will not
accept a void* for %S: it _has_ to be wchar_t*, and the checker won't
permit void* substitution for that.

Anyway, Linus took all that and said let's abuse %p instead.  It
_will_ accept any pointer so we can instead do:

printk(here is an inode: %pi\n, inode);

which is nicer.


I think the main customers of this are print_symbol():

printk(I am about to call %ps\n, fn);
(*fn)();

and NIPQUAD and its ipv6 version.

We don't know how much interest there would be in churning NIPQUAD from
the net guys.  Interestingly, there's also %C (wint_t) which is a
32-bit quantity.  So we could just go and say %C prints an ipv4
address and be done with it.  But there's no way of doing that for
ipv6 addresses so things would become asymmetrical there.

Another customer is net mac addresses.  There are surely others.  One
which should have been in printf 30 years ago was %b: binary.


  And then there's the perennial need to cast u64 to unsigned long long
  to print it.  If we were to do
  
  printk(%SL, (void *)some_u64);
  
  then that's still bloody ugly, but it'll save a little text-n-stack.
 
 u64 is easy to fix, and I don't know why we haven't.  Just make it
 unsigned long long on all architectures.

Yeah.  Why don't we do that?
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: patches for 2.6.27...

2008-07-04 Thread Segher Boessenkool

Please point out any patches that have been posted but havent made it
into a git tree related to Freescale chips.


I haven't heard back from Segher, so:

http://patchwork.ozlabs.org/linuxppc/patch?id=19313


You haven't heard back because I feel like I'm talking to a wall.

The compatible definition for this node needs to be fixed.


Segher

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


Re: [PATCH v3] powerpc: update crypto node definition and device tree instances

2008-07-04 Thread Segher Boessenkool

+- compatible : Should contain entries for this and backward compatible
+  SEC versions, high to low, e.g., fsl,sec2.1, fsl,sec2.0


First entry should state the _exact_ version of the device.  sec-N.M
isn't good enough; there can be implementation bugs.

There can be more entries; you make it sound like each device tree
should list _all_ compatible devices, which isn't the case.

A device binding should not (and can not) say how compatible
should be used; instead, it should list what values of compatible
this binding applies to.  You can give recommendations of course.


+- interrupts : a b where a is the interrupt number and b is a
+  field that represents an encoding of the sense and level
+  information for the interrupt.  This should be encoded based on
+  the information in section 2) depending on the type of interrupt
+  controller you have.


#interrupt-cells isn't always 2.  Your device binding shouldn't describe
how interrupt encoding works (that's described in the imap recommended
practice, already); instead, it should describe which device interrupts
are listed here, and in what order.  Sounds like you only have one
interrupt, so that should be easy ;-)


+- interrupt-parent : the phandle for the interrupt controller that
+  services interrupts for this device.


interrupt-parent isn't a required property.  It isn't part of this
device binding, either.


Segher

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


Re: the printk problem

2008-07-04 Thread Benjamin Herrenschmidt

 u64 is easy to fix, and I don't know why we haven't.  Just make it
 unsigned long long on all architectures.

Yup. Also, one of the major user of that is to print a struct resource,
which everybody does differently, so we may even look at doing a %pR
that does the nice start..end [attr]..

Ben.


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


Re: New fsl device bindings file

2008-07-04 Thread Segher Boessenkool

Just curious... why we're maintaining documentation in the .txt file?


Because it is human-readable text?


Or is this too wild? :-)


Yes :-)


Segher

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


Re: the printk problem

2008-07-04 Thread Benjamin Herrenschmidt
On Fri, 2008-07-04 at 13:02 -0700, Linus Torvalds wrote:
 
 That function descriptor indirection is totally untested, and I did it 
 with a
 
 pagefault_disable();
 __get_user(..)
 pagefault_enable();
 
 thing because I thought it would be nice if printk() was always safe, and 
 passing bogus function pointers to '%pF' should try to work, but quite 
 frankly, I didn't even check that that part compiles, much less works.
 
 ia64/ppc lists cc'd, just in case somebody wants to test this.

I'll give it a try using probe_kernel_address() instead on monday.

Cheers,
Ben.


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

Re: New fsl device bindings file

2008-07-04 Thread Segher Boessenkool

/* deprecated; */
device_type = i2c;


How about deprecated but kept for compatibility with true Open 
Firmware

implementations?


Well, except a flat tree isn't compatible with OF at all here.
A device_type promises a certain interface; a flat tree doesn't
even have the open method.  From the OF base spec:

“device_type” S

Standard property name to specify the implemented interface.

prop-encoded-array: Text string encoded with encode-string.

Specifies the “device type” of this package, thus implying a
specific set of package class methods implemented by this
package.

Seriously, you can't have a binding for OF and then cut out that 
part of the

standard at a whim.


Nothing is cut out.  There never was a device binding for device_type
i2c; creating one would be a considerable effort, and since flat tree
users wouldn't use it anyway, you can't be seriously suggesting they
should do this.


It should be there (at least for those parts which are
governed by a client interface API, like display, serial etc.


Huh?  Nothing in the client interface mentions display or serial
as far as I know.


but cutting it off takes away all it's meaning,


So what?  There _is_ no real device interface, when a flat tree is
used.


plus Linux implementations STILL keep searching
that property along with compatible,


That's a bug.


Segher

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


Re: New fsl device bindings file

2008-07-04 Thread Segher Boessenkool

I'm sure you'll hate for doing this,


No, it's an excellent move :-)

but I've asked Kim to create a new 
Documentation/powerpc/fsl-device-tree-bindings.txt as part of his SEC 
patch.


As a separate patch, that (at first) _only_ moves the content into 
separate

files, please.


Segher

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


Re: the printk problem

2008-07-04 Thread Linus Torvalds


On Sat, 5 Jul 2008, Benjamin Herrenschmidt wrote:
 
 I'll give it a try using probe_kernel_address() instead on monday.

Here's the updated patch which uses probe_kernel_address() instead (and 
moves the whole #ifdef mess out of the code that wants it and into a 
helper function - and maybe we should then put that helper into 
kallsyms.h, but that's a different issue).

Still all happily untested, of course. And still with no actual users 
converted.

Linus

---
 lib/vsprintf.c |  108 +--
 1 files changed, 80 insertions(+), 28 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6021757..1fbb1c0 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -22,6 +22,8 @@
 #include linux/string.h
 #include linux/ctype.h
 #include linux/kernel.h
+#include linux/kallsyms.h
+#include linux/uaccess.h
 
 #include asm/page.h  /* for PAGE_SIZE */
 #include asm/div64.h
@@ -482,6 +484,77 @@ static char *number(char *buf, char *end, unsigned long 
long num, int base, int
return buf;
 }
 
+static char *string(char *buf, char *end, char *s, int field_width, int 
precision, int flags)
+{
+   int len, i;
+
+   if ((unsigned long)s  PAGE_SIZE)
+   s = NULL;
+
+   len = strnlen(s, precision);
+
+   if (!(flags  LEFT)) {
+   while (len  field_width--) {
+   if (buf  end)
+   *buf = ' ';
+   ++buf;
+   }
+   }
+   for (i = 0; i  len; ++i) {
+   if (buf  end)
+   *buf = *s;
+   ++buf; ++s;
+   }
+   while (len  field_width--) {
+   if (buf  end)
+   *buf = ' ';
+   ++buf;
+   }
+   return buf;
+}
+
+static inline void *dereference_function_descriptor(void *ptr)
+{
+#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
+   void *p;
+   if (!probe_kernel_address(ptr, p))
+   ptr = p;
+#endif
+   return ptr;
+}
+
+
+/*
+ * Show a '%p' thing.  A kernel extension is that the '%p' is followed
+ * by an extra set of alphanumeric characters that are extended format
+ * specifiers.  Right now we just handle 'F' (for symbolic Function
+ * pointers) and 'S' (for Symbolic data pointers), but this can easily
+ * be extended in the future (network address types etc).
+ *
+ * The difference between 'S' and 'F' is that on ia64 and ppc64 function
+ * pointers are really function descriptors, which contain a pointer the
+ * real address. 
+ */
+static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int 
base, int size, int precision, int type)
+{
+   switch (*fmt) {
+   case 'F':
+   ptr = dereference_function_descriptor(ptr);
+   /* Fallthrough */
+   case 'S': { /* Other (direct) pointer */
+#if CONFIG_KALLSYMS
+   char sym[KSYM_SYMBOL_LEN];
+   sprint_symbol(sym, (unsigned long) ptr);
+   return string(buf, end, sym, size, precision, type);
+#else
+   type |= SPECIAL;
+   break;
+#endif
+   }
+   }
+   return number(buf, end, (unsigned long long) ptr, base, size, 
precision, type);
+}
+
 /**
  * vsnprintf - Format a string and place it in a buffer
  * @buf: The buffer to place the result into
@@ -502,11 +575,9 @@ static char *number(char *buf, char *end, unsigned long 
long num, int base, int
  */
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
-   int len;
unsigned long long num;
-   int i, base;
+   int base;
char *str, *end, c;
-   const char *s;
 
int flags;  /* flags to number() */
 
@@ -622,29 +693,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, 
va_list args)
continue;
 
case 's':
-   s = va_arg(args, char *);
-   if ((unsigned long)s  PAGE_SIZE)
-   s = NULL;
-
-   len = strnlen(s, precision);
-
-   if (!(flags  LEFT)) {
-   while (len  field_width--) {
-   if (str  end)
-   *str = ' ';
-   ++str;
-   }
-   }
-   for (i = 0; i  len; ++i) {
-   if (str  end)
-   *str = *s;
-   ++str; ++s;
-   }
-   while (len  field_width--) {
-   if (str  end)
-   *str = ' ';
-   

Re: [PATCH v2 3/5] of-bindings: Add binding documentation for SPI busses and devices

2008-07-04 Thread Segher Boessenkool

+The SPI master node requires the following properties:
+- #address-cells  - number of cells required to define a chip 
select

+   address on the SPI bus.


Hrm.  Should this (and reg in the child node) be required for SPI
masters that have only one chip select?

+- max-speed   - (required) Maximum SPI clocking speed of 
device in Hz


The property name should include something SPI, it's way too generic
otherwise.

+- spi,cpol- (optional) Device requires inverse clock 
polarity

+- spi,cpha- (optional) Device requires shifted clock phase


Don't abbr the property names, there's nothing wrong with longer names.
The names shouldn't start with spi, either, spi isn't a vendor;
how about spi-inverse-clock-polarity or similar?

+- linux,modalias  - (optional, Linux specific) Force binding of 
SPI device

+   to a particular spi_device driver.  Useful for changing
+   driver binding between spidev and a kernel SPI driver.


This is a temporary workaround I hope?


Segher

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


Re: [PATCH v2 3/5] of-bindings: Add binding documentation for SPI busses and devices

2008-07-04 Thread Grant Likely
On Fri, Jul 4, 2008 at 5:36 PM, Segher Boessenkool
[EMAIL PROTECTED] wrote:
 +The SPI master node requires the following properties:
 +- #address-cells  - number of cells required to define a chip select
 +   address on the SPI bus.

 Hrm.  Should this (and reg in the child node) be required for SPI
 masters that have only one chip select?

I suppose it could be skipped, but I'd rather have it there for consistency


 +- max-speed   - (required) Maximum SPI clocking speed of device
 in Hz

 The property name should include something SPI, it's way too generic
 otherwise.

Good point; I'll change this to 'spi-max-speed'

 +- spi,cpol- (optional) Device requires inverse clock polarity
 +- spi,cpha- (optional) Device requires shifted clock phase

 Don't abbr the property names, there's nothing wrong with longer names.
 The names shouldn't start with spi, either, spi isn't a vendor;
 how about spi-inverse-clock-polarity or similar?

Okay, but cpol and cpha are common abbreviations w.r.t. SPI devices.

 +- linux,modalias  - (optional, Linux specific) Force binding of SPI
 device
 +   to a particular spi_device driver.  Useful for
 changing
 +   driver binding between spidev and a kernel SPI
 driver.

 This is a temporary workaround I hope?

Yeah, I'm kind of ashamed of this one.  I'll drop it.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 3/3] ALSA SoC: Add Texas Instruments TLV320AIC26 codec driver

2008-07-04 Thread Grant Likely
On Fri, Jul 4, 2008 at 2:49 PM, Mark Brown
[EMAIL PROTECTED] wrote:
 On Tue, Jul 01, 2008 at 05:53:40PM -0600, Grant Likely wrote:
 + /* Tell the of_soc helper about this codec */
 + of_snd_soc_register_codec(aic26_soc_codec_dev, aic26, aic26_dai,
 +   spi-dev.archdata.of_node);

 Does this need to be ifdefed out if of_snd_soc_register_codec() is not
 in use or is the function stubbed out if it's not in use?  Stubbing it
 out would be cleaner.

yeah, probably.  This is a stop-gap measure anyway until ASoC v2 is merged.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: the printk problem

2008-07-04 Thread Matthew Wilcox
On Fri, Jul 04, 2008 at 03:01:00PM -0700, Andrew Morton wrote:
 (heck, let's cc lkml - avoid having to go through all this again)
 
 It would be excellent if gcc had an extension system so that you could
 add new printf control chars and maybe even tell gcc how to check them.
 But of course, if that were to happen, we couldn't use it for 4-5 years.

I believe NetBSD added that as an extension many years ago.  Dunno if
they still have it.

 What I had initially proposed was to abuse %S, which takes a wchar_t*. 
 gcc accepts `unsigned long *' for %S.
 
[...]
 - there's a cast, so you could accidentally do
 
   printk(here is an inode: %Si\n, (unsigned long *)dentry);
 
 - there's a cast, and they're ugly
 
 - gcc cannot of course check that the arg matches the control string
 
 Unfortunately (and this seems weird), gcc printf checking will not
 accept a void* for %S: it _has_ to be wchar_t*, and the checker won't
 permit void* substitution for that.

Presumably that's the compiler getting rid of the first and third
downside ;-)

 Anyway, Linus took all that and said let's abuse %p instead.  It
 _will_ accept any pointer so we can instead do:
 
   printk(here is an inode: %pi\n, inode);
 
 which is nicer.

Yes.  It's possible to confuse it, of course.

printk(Function %pSucks\n, sys_open);

but I really doubt we have such a usage in the kernel today.

  u64 is easy to fix, and I don't know why we haven't.  Just make it
  unsigned long long on all architectures.
 
 Yeah.  Why don't we do that?

Patch ...

[PATCH] Make u64 long long on all architectures

It is currently awkward to print a u64 type.  Some architectures use
unsigned long while others use unsigned long long.  Since unsigned long
long is 64-bit for all existing Linux architectures, change those that
use long to use long long.  Note that this applies only within the
kernel.  If u64 is being used in a C++ method definition, the symbol
mangling would change.

Signed-off-by: Matthew Wilcox [EMAIL PROTECTED]

diff --git a/include/asm-generic/int-l64.h b/include/asm-generic/int-l64.h
index 2af9b75..32f07bd 100644
--- a/include/asm-generic/int-l64.h
+++ b/include/asm-generic/int-l64.h
@@ -23,8 +23,13 @@ typedef unsigned short __u16;
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
+#ifdef __KERNEL__
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+#else
 typedef __signed__ long __s64;
 typedef unsigned long __u64;
+#endif
 
 #endif /* __ASSEMBLY__ */
 

-- 
Intel are signing my paycheques ... these opinions are still mine
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: New fsl device bindings file

2008-07-04 Thread David Gibson
On Sat, Jul 05, 2008 at 01:12:31AM +0200, Segher Boessenkool wrote:
 /* deprecated; */
 device_type = i2c;

 How about deprecated but kept for compatibility with true Open  
 Firmware
 implementations?

 Well, except a flat tree isn't compatible with OF at all here.
 A device_type promises a certain interface; a flat tree doesn't
 even have the open method.  From the OF base spec:

   “device_type” S

   Standard property name to specify the implemented interface.

   prop-encoded-array: Text string encoded with encode-string.

   Specifies the “device type” of this package, thus implying a
   specific set of package class methods implemented by this
   package.

 Seriously, you can't have a binding for OF and then cut out that  
 part of the
 standard at a whim.

 Nothing is cut out.  There never was a device binding for device_type
 i2c; creating one would be a considerable effort, and since flat tree
 users wouldn't use it anyway, you can't be seriously suggesting they
 should do this.

 It should be there (at least for those parts which are
 governed by a client interface API, like display, serial etc.

 Huh?  Nothing in the client interface mentions display or serial
 as far as I know.

 but cutting it off takes away all it's meaning,

 So what?  There _is_ no real device interface, when a flat tree is
 used.

 plus Linux implementations STILL keep searching
 that property along with compatible,

 That's a bug.

Thank you Segher, you saved me the trouble of saying exactly all that.

-- 
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: [alsa-devel] [PATCH 2/3] ALSA SoC: Add mpc5200-psc I2S driver

2008-07-04 Thread David Gibson
On Fri, Jul 04, 2008 at 07:03:25AM -0400, Timur Tabi wrote:
  [EMAIL PROTECTED] { // PSC2
  compatible = fsl,mpc5200b-psc-i2s,fsl,mpc5200-psc-i2s;
  cell-index = 1;

 cell-index should be zero-based, not one-based.

Well...since cell-index is for indexing shared resources, the
cell-index values should be whatever the convention is for that shared
resource, which can be defined as whatever is convenient for that
resource.  I think that's been zero-based in every user of cell-index
so far, but there's no reason it *has* to be if a different
enumeration is convenient for the shared resource in question.

-- 
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: [PATCH] Add PPC_FEATURE_PMU_COMPAT

2008-07-04 Thread Olof Johansson

On Jul 3, 2008, at 6:20 PM, Nathan Lynch wrote:


Beginning with Power6, there is a set of 32 PMU events which is
compatible across POWER processor lines.  PPC_FEATURE_PMU_COMPAT
indicates support for this subset.


The PMU isn't, as far as I know, part of the architecture, it's up to  
each implementation to do as it pleases. Right? So this should  
probably be named less generic.



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


Re: New fsl device bindings file

2008-07-04 Thread Olof Johansson


On Jul 3, 2008, at 1:34 PM, Grant Likely wrote:


How about splitting up like this:

Documentation/powerpc/device-tree/fsl/cpm.txt
Documentation/powerpc/device-tree/fsl/cpm/uart.txt
Documentation/powerpc/device-tree/fsl/tsec.txt
Documentation/powerpc/device-tree/interrupts.txt
Documentation/powerpc/device-tree/dtb.txt


May I suggest moving it to Documentation/of-bindings/ instead?  Some
of these bindings (granted, not the fsl ones) will be used by
non-powerpc platforms (sparc, microblaze).


Good idea, but:

Don't call the bindings OF. They're not.

They are a linux-specific binding that happens to use the same data  
structures and representation that OF does.


Call them dts-bindings or something else, just to avoid confusion.


-Olof

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


Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

2008-07-04 Thread Michael Ellerman
On Fri, 2008-07-04 at 21:05 +0200, [EMAIL PROTECTED] wrote:

 Introduce a new dma attriblue DMA_ATTR_STRONG_ORDERING to use strong ordering
 on DMA mappings in the Cell processor. Add the code to the Cell's IOMMU
 implementation to use this.
 
 The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs
 (for both the dynamic and fixed mappings) which enforces strong ordering of
 both reads and writes. This patch makes the default behaviour weak ordering
 (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the
 new DMA_ATTR_STRONG_ORDERING needs to be used.

We're sure that's safe?

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