LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [POWERPC] add U-Boot bootcount driver.
From: Vitaly Bordug @ 2009-12-18  5:50 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <20091217093434.GA19931@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

В Thu, 17 Dec 2009 10:34:34 +0100
Wolfram Sang <w.sang@pengutronix.de> пишет:

> On Wed, Dec 16, 2009 at 02:47:30AM +0300, Vitaly Bordug wrote:
> > 
> > From: Heiko Schocher <hs@denx.de>
> > 
> > This driver provides (read/write) access to the
> > U-Boot bootcounter via PROC FS or sysFS.
> > 
> > in u-boot, it uses a 8 byte mem area (it must hold the value over a
> > soft reset of course), for storing a bootcounter (it counts many
> > soft resets are done, on hard reset it starts with 0). If the
> > bootcountvalue exceeds the value in the env variable "bootlimit",
> > and alternative bootcmd stored in the env variable "altbootcmd" is
> > run.
> 
> Hmm, both in my inbox and in patchwork, the patch seems line-wrapped.
> Also, there are a few printk without loglevel. As probe has access to
> a device structure, dev_* should be a nice option here.
> 
OK, makes sense.

-Vitaly
> Regards,
> 
>    Wolfram
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: [POWERPC] add U-Boot bootcount driver.
From: Vitaly Bordug @ 2009-12-18  6:01 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <20091216000250.GK9463@yookeroo>

[...]
> > bootcount@0x3eb0 {
> >                   device_type = "bootcount";
Clear.

> 
> No device_type.
> 
> >                   compatible = "uboot,bootcount";
> >                   reg = <0x3eb0 0x08>;
> >                  };
> 
> This area should also be in the flattened tree's reserved map.
> 
Can you elaborate this a little bit? I know about the reserved map by
putting -R4 into device tree cmdline which is apparently not enough :)

Thanks,
-Vitaly

^ permalink raw reply

* [PATCH] ps3_gelic_wireless: Fix build failure due to missing WEXT_PRIV
From: Benjamin Herrenschmidt @ 2009-12-18  5:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: Geert Uytterhoeven, linuxppc-dev

The option to support the old style PSK interface in the PS3
GELIC wireless drivers requires CONFIG_WEXT_PRIV to be set

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

Please send to Linus asap (or I can put it in powerpc.git) as it's
breaking one of my test build configs :-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e58a653..c0ecc77 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2358,6 +2358,7 @@ config GELIC_WIRELESS
 config GELIC_WIRELESS_OLD_PSK_INTERFACE
        bool "PS3 Wireless private PSK interface (OBSOLETE)"
        depends on GELIC_WIRELESS
+       select WEXT_PRIV
        help
           This option retains the obsolete private interface to pass
           the PSK from user space programs to the driver.  The PSK

^ permalink raw reply related

* 2.6.32 Kernel panic - not syncing: Attempted to kill init! Rebooting in 180 seconds..
From: Zhiyong Wu @ 2009-12-18  4:08 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Zhiyong Wu, llim, Herbert Xu, agraf

HI,

linux-2.6.32 is compiled on a p6 machine with RH5.4 OS and KVM option is enable.

When rebooting this machine, a crash takes place such as:

Loading ramdisk...
ramdisk loaded at 01700000, size: 2700 Kbytes
OF stdout device is: /vdevice/vty@30000000
Preparing to boot Linux version 2.6.32 (root@p6ml4n07.clusters.com)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Dec 18
06:53:27 EST 2009
Calling ibm,client-architecture-support.../
Elapsed time since release of system processors: 1212 mins 30 secs

Config file read, 1024 bytes

Welcome
Welcome to yaboot version 1.3.13 (Red Hat 1.3.13-8.el5)
Enter "help" to get some basic usage information
boot: linux-32
Please wait, loading kernel...
   Elf64 kernel loaded...
Loading ramdisk...
ramdisk loaded at 01700000, size: 2700 Kbytes
OF stdout device is: /vdevice/vty@30000000
Preparing to boot Linux version 2.6.32 (root@p6ml4n07.clusters.com)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Dec 18
06:53:27 EST 2009
Calling ibm,client-architecture-support... done
command line: ro console=hvc0 rhgb quiet root=LABEL=/
memory layout at init:
  memory_limit : 0000000000000000 (16 MB aligned)
  alloc_bottom : 00000000019b0000
  alloc_top    : 0000000008000000
  alloc_top_hi : 0000000008000000
  rmo_top      : 0000000008000000
  ram_top      : 0000000008000000
instantiating rtas at 0x0000000006e10000... done
boot cpu hw idx 0000000000000000
copying OF device tree...
Building dt strings...
Building dt structure...
Device tree strings 0x0000000001bc0000 -> 0x0000000001bc15bb
Device tree struct  0x0000000001bd0000 -> 0x0000000001bf0000
Calling quiesce...
returning from prom_init
Red Hat nash version 5.1.19.6 starting
ibmvscsi 30000002: fast_fail not supported in server
sd 0:0:1:0: [sda] Assuming drive cache: write through
sd 0:0:1:0: [sda] Assuming drive cache: write through
sd 0:0:1:0: [sda] Assuming drive cache: write through
insmod: error inserting '/lib/dm-region-hash.ko': -1 File exists
mount: could not find filesystem '/dev/root'
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
Rebooting in 180 seconds..[disconnect]

Can anyone give me a warm hand?


Cheers,

Zhiyong Wu

^ permalink raw reply

* Kernel panic - not syncing: Attempted to kill init! Rebooting in 180 seconds..
From: Zhi Yong Wu @ 2009-12-18  4:05 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 2396 bytes --]


HI,

linux-2.6.32 is compiled on a p6 machine with RH5.4 OS and KVM option is
enable.

When rebooting this machine, a crash takes place such as:

Loading ramdisk...
ramdisk loaded at 01700000, size: 2700 Kbytes
OF stdout device is: /vdevice/vty@30000000
Preparing to boot Linux version 2.6.32 (root@p6ml4n07.clusters.com) (gcc
version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Dec 18 06:53:27 EST
2009
Calling ibm,client-architecture-support.../
Elapsed time since release of system processors: 1212 mins 30 secs

Config file read, 1024 bytes

Welcome
Welcome to yaboot version 1.3.13 (Red Hat 1.3.13-8.el5)
Enter "help" to get some basic usage information
boot: linux-32
Please wait, loading kernel...
   Elf64 kernel loaded...
Loading ramdisk...
ramdisk loaded at 01700000, size: 2700 Kbytes
OF stdout device is: /vdevice/vty@30000000
Preparing to boot Linux version 2.6.32 (root@p6ml4n07.clusters.com) (gcc
version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Dec 18 06:53:27 EST
2009
Calling ibm,client-architecture-support... done
command line: ro console=hvc0 rhgb quiet root=LABEL=/
memory layout at init:
  memory_limit : 0000000000000000 (16 MB aligned)
  alloc_bottom : 00000000019b0000
  alloc_top    : 0000000008000000
  alloc_top_hi : 0000000008000000
  rmo_top      : 0000000008000000
  ram_top      : 0000000008000000
instantiating rtas at 0x0000000006e10000... done
boot cpu hw idx 0000000000000000
copying OF device tree...
Building dt strings...
Building dt structure...
Device tree strings 0x0000000001bc0000 -> 0x0000000001bc15bb
Device tree struct  0x0000000001bd0000 -> 0x0000000001bf0000
Calling quiesce...
returning from prom_init
Red Hat nash version 5.1.19.6 starting
ibmvscsi 30000002: fast_fail not supported in server
sd 0:0:1:0: [sda] Assuming drive cache: write through
sd 0:0:1:0: [sda] Assuming drive cache: write through
sd 0:0:1:0: [sda] Assuming drive cache: write through
insmod: error inserting '/lib/dm-region-hash.ko': -1 File exists
mount: could not find filesystem '/dev/root'
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
Rebooting in 180 seconds..[disconnect]

Can anyone give me a warm hand?


Cheers,

Zhiyong Wu

[-- Attachment #2: Type: text/html, Size: 2697 bytes --]

^ permalink raw reply

* Re: [patch 1/5] powerpc: Sky CPU: redundant or incorrect tests on unsigned
From: Benjamin Herrenschmidt @ 2009-12-18  3:45 UTC (permalink / raw)
  To: akpm; +Cc: gorcunov, linuxppc-dev, roel.kluin, waite, galak
In-Reply-To: <1261107631.2173.10.camel@pasglop>

On Fri, 2009-12-18 at 14:40 +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2009-12-17 at 16:44 -0800, akpm@linux-foundation.org wrote:
> > From: Roel Kluin <roel.kluin@gmail.com>
> > 
> > count is unsigned and cannot be less than 0.
> 
> Is this really a powerpc thing ?
> 
> This driver is only build with CONFIG_HDPU_FEATURES and a git grep
> HDPU_FEATURES returns no Kconfig that defines it :-)
> 
> I'm happy to apply such a trivial thing but it's weird isn't it ?

Ok so it looks like some old stuff that got removed a long time ago and
never made it to arch/powerpc.

I'll send a patch to just remove the whole driver, it's stale.

Cheers,
Ben.

> Cheers,
> Ben.
> 
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> > Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: Kumar Gala <galak@gate.crashing.org>
> > Cc: Brian Waite <waite@skycomputers.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > ---
> > 
> >  drivers/misc/hdpuftrs/hdpu_cpustate.c |    5 -----
> >  1 file changed, 5 deletions(-)
> > 
> > diff -puN drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned drivers/misc/hdpuftrs/hdpu_cpustate.c
> > --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned
> > +++ a/drivers/misc/hdpuftrs/hdpu_cpustate.c
> > @@ -121,8 +121,6 @@ static ssize_t cpustate_read(struct file
> >  {
> >  	unsigned char data;
> >  
> > -	if (count < 0)
> > -		return -EFAULT;
> >  	if (count == 0)
> >  		return 0;
> >  
> > @@ -137,9 +135,6 @@ static ssize_t cpustate_write(struct fil
> >  {
> >  	unsigned char data;
> >  
> > -	if (count < 0)
> > -		return -EFAULT;
> > -
> >  	if (count == 0)
> >  		return 0;
> >  
> > _
> 

^ permalink raw reply

* Re: [patch 1/5] powerpc: Sky CPU: redundant or incorrect tests on unsigned
From: Benjamin Herrenschmidt @ 2009-12-18  3:40 UTC (permalink / raw)
  To: akpm; +Cc: gorcunov, linuxppc-dev, roel.kluin, waite, galak
In-Reply-To: <200912180044.nBI0iTbj028399@imap1.linux-foundation.org>

On Thu, 2009-12-17 at 16:44 -0800, akpm@linux-foundation.org wrote:
> From: Roel Kluin <roel.kluin@gmail.com>
> 
> count is unsigned and cannot be less than 0.

Is this really a powerpc thing ?

This driver is only build with CONFIG_HDPU_FEATURES and a git grep
HDPU_FEATURES returns no Kconfig that defines it :-)

I'm happy to apply such a trivial thing but it's weird isn't it ?

Cheers,
Ben.

> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Kumar Gala <galak@gate.crashing.org>
> Cc: Brian Waite <waite@skycomputers.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/misc/hdpuftrs/hdpu_cpustate.c |    5 -----
>  1 file changed, 5 deletions(-)
> 
> diff -puN drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned drivers/misc/hdpuftrs/hdpu_cpustate.c
> --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned
> +++ a/drivers/misc/hdpuftrs/hdpu_cpustate.c
> @@ -121,8 +121,6 @@ static ssize_t cpustate_read(struct file
>  {
>  	unsigned char data;
>  
> -	if (count < 0)
> -		return -EFAULT;
>  	if (count == 0)
>  		return 0;
>  
> @@ -137,9 +135,6 @@ static ssize_t cpustate_write(struct fil
>  {
>  	unsigned char data;
>  
> -	if (count < 0)
> -		return -EFAULT;
> -
>  	if (count == 0)
>  		return 0;
>  
> _

^ permalink raw reply

* Re: [PATCH v2 2/2] Crypto: Talitos: Support for Async_tx XOR offload
From: Dan Williams @ 2009-12-18  0:58 UTC (permalink / raw)
  To: Kumar Gala
  Cc: herbert@gondor.apana.org.au, Ira W. Snyder, B04825@freescale.com,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	linuxppc-dev@ozlabs.org, Vishnu Suresh,
	linux-crypto@vger.kernel.org, Dipen Dudhat, Maneesh Gupta,
	R58472@freescale.com
In-Reply-To: <AFE3AE33-41FB-42EE-A861-9C6CC1D1F435@kernel.crashing.org>

On Thu, Dec 17, 2009 at 11:45 AM, Kumar Gala <galak@kernel.crashing.org> wr=
ote:
>> The specific case it is needed for Talitos/raid is a channel switch inte=
rrupt. =A0The interrupt causes the cleanup operation to be run which will k=
ick off any pending dependent operations on the xor channel. =A0In the raid=
 case we only have callbacks at the end of a chain, so we need the interrup=
t to kick the engine in an operation chain like xor->copy->xor->callback.
>
> Ok, I'm still confused as to how the DMA interrupt interacts with the Tal=
itos/raid side of things. =A0The should be completely independent (separate=
 interrupts, separate IP blocks).
>

To keep hardware implementation details out of md/raid the async_tx
api provides support for managing cross-channel dependency chains.
When the raid5 code submits a xor->copy->xor chain the api prepares
all the descriptors across all the involved channels but then delays
submission as needed to maintain ordering.  So at a minimum we need
two interrupts in this scenario one from Talitos to kick the
submission of the copy-descriptor to fsldma when the first xor
completes, and another one to kick the submission of the second
xor-descriptor on Talitos when fsldma completes the copy.  Needless to
say it is more efficient when a channel has all the capabilities, but
this channel switch mechanism has proven effective on iop3xx and
ppc4xx.

--
Dan

^ permalink raw reply

* [patch 2/5] mm: add notifier in pageblock isolation for balloon drivers
From: akpm @ 2009-12-18  0:44 UTC (permalink / raw)
  To: benh
  Cc: mel, geralds, linuxppc-dev, paulus, brking, schwidefsky, akpm,
	mingo, kamezawa.hiroyu

From: Robert Jennings <rcj@linux.vnet.ibm.com>

Memory balloon drivers can allocate a large amount of memory which is not
movable but could be freed to accomodate memory hotplug remove.

Prior to calling the memory hotplug notifier chain the memory in the
pageblock is isolated.  Currently, if the migrate type is not
MIGRATE_MOVABLE the isolation will not proceed, causing the memory removal
for that page range to fail.

Rather than failing pageblock isolation if the migrateteype is not
MIGRATE_MOVABLE, this patch checks if all of the pages in the pageblock,
and not on the LRU, are owned by a registered balloon driver (or other
entity) using a notifier chain.  If all of the non-movable pages are owned
by a balloon, they can be freed later through the memory notifier chain
and the range can still be isolated in set_migratetype_isolate().

Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Brian King <brking@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Gerald Schaefer <geralds@linux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/base/memory.c  |   19 +++++++++++++
 include/linux/memory.h |   27 ++++++++++++++++++
 mm/page_alloc.c        |   57 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 96 insertions(+), 7 deletions(-)

diff -puN drivers/base/memory.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers drivers/base/memory.c
--- a/drivers/base/memory.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers
+++ a/drivers/base/memory.c
@@ -63,6 +63,20 @@ void unregister_memory_notifier(struct n
 }
 EXPORT_SYMBOL(unregister_memory_notifier);
 
+static ATOMIC_NOTIFIER_HEAD(memory_isolate_chain);
+
+int register_memory_isolate_notifier(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_register(&memory_isolate_chain, nb);
+}
+EXPORT_SYMBOL(register_memory_isolate_notifier);
+
+void unregister_memory_isolate_notifier(struct notifier_block *nb)
+{
+	atomic_notifier_chain_unregister(&memory_isolate_chain, nb);
+}
+EXPORT_SYMBOL(unregister_memory_isolate_notifier);
+
 /*
  * register_memory - Setup a sysfs device for a memory block
  */
@@ -157,6 +171,11 @@ int memory_notify(unsigned long val, voi
 	return blocking_notifier_call_chain(&memory_chain, val, v);
 }
 
+int memory_isolate_notify(unsigned long val, void *v)
+{
+	return atomic_notifier_call_chain(&memory_isolate_chain, val, v);
+}
+
 /*
  * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is
  * OK to have direct references to sparsemem variables in here.
diff -puN include/linux/memory.h~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers include/linux/memory.h
--- a/include/linux/memory.h~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers
+++ a/include/linux/memory.h
@@ -50,6 +50,19 @@ struct memory_notify {
 	int status_change_nid;
 };
 
+/*
+ * During pageblock isolation, count the number of pages within the
+ * range [start_pfn, start_pfn + nr_pages) which are owned by code
+ * in the notifier chain.
+ */
+#define MEM_ISOLATE_COUNT	(1<<0)
+
+struct memory_isolate_notify {
+	unsigned long start_pfn;	/* Start of range to check */
+	unsigned int nr_pages;		/* # pages in range to check */
+	unsigned int pages_found;	/* # pages owned found by callbacks */
+};
+
 struct notifier_block;
 struct mem_section;
 
@@ -76,14 +89,28 @@ static inline int memory_notify(unsigned
 {
 	return 0;
 }
+static inline int register_memory_isolate_notifier(struct notifier_block *nb)
+{
+	return 0;
+}
+static inline void unregister_memory_isolate_notifier(struct notifier_block *nb)
+{
+}
+static inline int memory_isolate_notify(unsigned long val, void *v)
+{
+	return 0;
+}
 #else
 extern int register_memory_notifier(struct notifier_block *nb);
 extern void unregister_memory_notifier(struct notifier_block *nb);
+extern int register_memory_isolate_notifier(struct notifier_block *nb);
+extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
 extern int register_new_memory(int, struct mem_section *);
 extern int unregister_memory_section(struct mem_section *);
 extern int memory_dev_init(void);
 extern int remove_memory_block(unsigned long, struct mem_section *, int);
 extern int memory_notify(unsigned long val, void *v);
+extern int memory_isolate_notify(unsigned long val, void *v);
 extern struct memory_block *find_memory_block(struct mem_section *);
 #define CONFIG_MEM_BLOCK_SIZE	(PAGES_PER_SECTION<<PAGE_SHIFT)
 enum mem_add_context { BOOT, HOTPLUG };
diff -puN mm/page_alloc.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers mm/page_alloc.c
--- a/mm/page_alloc.c~mm-add-notifier-in-pageblock-isolation-for-balloon-drivers
+++ a/mm/page_alloc.c
@@ -48,6 +48,7 @@
 #include <linux/page_cgroup.h>
 #include <linux/debugobjects.h>
 #include <linux/kmemleak.h>
+#include <linux/memory.h>
 #include <trace/events/kmem.h>
 
 #include <asm/tlbflush.h>
@@ -5008,23 +5009,65 @@ void set_pageblock_flags_group(struct pa
 int set_migratetype_isolate(struct page *page)
 {
 	struct zone *zone;
-	unsigned long flags;
+	struct page *curr_page;
+	unsigned long flags, pfn, iter;
+	unsigned long immobile = 0;
+	struct memory_isolate_notify arg;
+	int notifier_ret;
 	int ret = -EBUSY;
 	int zone_idx;
 
 	zone = page_zone(page);
 	zone_idx = zone_idx(zone);
+
 	spin_lock_irqsave(&zone->lock, flags);
+	if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE ||
+	    zone_idx == ZONE_MOVABLE) {
+		ret = 0;
+		goto out;
+	}
+
+	pfn = page_to_pfn(page);
+	arg.start_pfn = pfn;
+	arg.nr_pages = pageblock_nr_pages;
+	arg.pages_found = 0;
+
 	/*
-	 * In future, more migrate types will be able to be isolation target.
+	 * It may be possible to isolate a pageblock even if the
+	 * migratetype is not MIGRATE_MOVABLE. The memory isolation
+	 * notifier chain is used by balloon drivers to return the
+	 * number of pages in a range that are held by the balloon
+	 * driver to shrink memory. If all the pages are accounted for
+	 * by balloons, are free, or on the LRU, isolation can continue.
+	 * Later, for example, when memory hotplug notifier runs, these
+	 * pages reported as "can be isolated" should be isolated(freed)
+	 * by the balloon driver through the memory notifier chain.
 	 */
-	if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE &&
-	    zone_idx != ZONE_MOVABLE)
+	notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg);
+	notifier_ret = notifier_to_errno(notifier_ret);
+	if (notifier_ret || !arg.pages_found)
 		goto out;
-	set_pageblock_migratetype(page, MIGRATE_ISOLATE);
-	move_freepages_block(zone, page, MIGRATE_ISOLATE);
-	ret = 0;
+
+	for (iter = pfn; iter < (pfn + pageblock_nr_pages); iter++) {
+		if (!pfn_valid_within(pfn))
+			continue;
+
+		curr_page = pfn_to_page(iter);
+		if (!page_count(curr_page) || PageLRU(curr_page))
+			continue;
+
+		immobile++;
+	}
+
+	if (arg.pages_found == immobile)
+		ret = 0;
+
 out:
+	if (!ret) {
+		set_pageblock_migratetype(page, MIGRATE_ISOLATE);
+		move_freepages_block(zone, page, MIGRATE_ISOLATE);
+	}
+
 	spin_unlock_irqrestore(&zone->lock, flags);
 	if (!ret)
 		drain_all_pages();
_

^ permalink raw reply

* [patch 3/5] powerpc: make the CMM memory hotplug aware
From: akpm @ 2009-12-18  0:44 UTC (permalink / raw)
  To: benh
  Cc: mel, geralds, linuxppc-dev, paulus, brking, schwidefsky, akpm,
	mingo, kamezawa.hiroyu

From: Robert Jennings <rcj@linux.vnet.ibm.com>

The Collaborative Memory Manager (CMM) module allocates individual pages
over time that are not migratable.  On a long running system this can
severely impact the ability to find enough pages to support a hotplug
memory remove operation.

This patch adds a memory isolation notifier and a memory hotplug notifier.
The memory isolation notifier will return the number of pages found in
the range specified.  This is used to determine if all of the used pages
in a pageblock are owned by the balloon (or other entities in the notifier
chain).  The hotplug notifier will free pages in the range which is to be
removed.  The priority of this hotplug notifier is low so that it will be
called near last, this helps avoids removing loaned pages in operations
that fail due to other handlers.

CMM activity will be halted when hotplug remove operations are active and
resume activity after a delay period to allow the hypervisor time to
adjust.

Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Brian King <brking@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Gerald Schaefer <geralds@linux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/powerpc/platforms/pseries/cmm.c |  254 ++++++++++++++++++++++++-
 1 file changed, 248 insertions(+), 6 deletions(-)

diff -puN arch/powerpc/platforms/pseries/cmm.c~powerpc-make-the-cmm-memory-hotplug-aware arch/powerpc/platforms/pseries/cmm.c
--- a/arch/powerpc/platforms/pseries/cmm.c~powerpc-make-the-cmm-memory-hotplug-aware
+++ a/arch/powerpc/platforms/pseries/cmm.c
@@ -38,19 +38,28 @@
 #include <asm/mmu.h>
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
+#include <linux/memory.h>
 
 #include "plpar_wrappers.h"
 
 #define CMM_DRIVER_VERSION	"1.0.0"
 #define CMM_DEFAULT_DELAY	1
+#define CMM_HOTPLUG_DELAY	5
 #define CMM_DEBUG			0
 #define CMM_DISABLE		0
 #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))
+/*
+ * The priority level tries to ensure that this notifier is called as
+ * late as possible to reduce thrashing in the shared memory pool.
+ */
+#define CMM_MEM_HOTPLUG_PRI	1
+#define CMM_MEM_ISOLATE_PRI	15
 
 static unsigned int delay = CMM_DEFAULT_DELAY;
+static unsigned int hotplug_delay = CMM_HOTPLUG_DELAY;
 static unsigned int oom_kb = CMM_OOM_KB;
 static unsigned int cmm_debug = CMM_DEBUG;
 static unsigned int cmm_disabled = CMM_DISABLE;
@@ -65,6 +74,10 @@ 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(hotplug_delay, hotplug_delay, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(delay, "Delay (in seconds) after memory hotplug remove "
+		 "before loaning resumes. "
+		 "[Default=" __stringify(CMM_HOTPLUG_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) "]");
@@ -92,6 +105,9 @@ static unsigned long oom_freed_pages;
 static struct cmm_page_array *cmm_page_list;
 static DEFINE_SPINLOCK(cmm_lock);
 
+static DEFINE_MUTEX(hotplug_mutex);
+static int hotplug_occurred; /* protected by the hotplug mutex */
+
 static struct task_struct *cmm_thread_ptr;
 
 /**
@@ -110,6 +126,17 @@ static long cmm_alloc_pages(long nr)
 	cmm_dbg("Begin request for %ld pages\n", nr);
 
 	while (nr) {
+		/* Exit if a hotplug operation is in progress or occurred */
+		if (mutex_trylock(&hotplug_mutex)) {
+			if (hotplug_occurred) {
+				mutex_unlock(&hotplug_mutex);
+				break;
+			}
+			mutex_unlock(&hotplug_mutex);
+		} else {
+			break;
+		}
+
 		addr = __get_free_page(GFP_NOIO | __GFP_NOWARN |
 				       __GFP_NORETRY | __GFP_NOMEMALLOC);
 		if (!addr)
@@ -119,8 +146,9 @@ static long cmm_alloc_pages(long nr)
 		if (!pa || pa->index >= CMM_NR_PAGES) {
 			/* Need a new page for the page list. */
 			spin_unlock(&cmm_lock);
-			npa = (struct cmm_page_array *)__get_free_page(GFP_NOIO | __GFP_NOWARN |
-								       __GFP_NORETRY | __GFP_NOMEMALLOC);
+			npa = (struct cmm_page_array *)__get_free_page(
+					GFP_NOIO | __GFP_NOWARN |
+					__GFP_NORETRY | __GFP_NOMEMALLOC);
 			if (!npa) {
 				pr_info("%s: Can not allocate new page list\n", __func__);
 				free_page(addr);
@@ -282,9 +310,28 @@ static int cmm_thread(void *dummy)
 	while (1) {
 		timeleft = msleep_interruptible(delay * 1000);
 
-		if (kthread_should_stop() || timeleft) {
-			loaned_pages_target = loaned_pages;
+		if (kthread_should_stop() || timeleft)
 			break;
+
+		if (mutex_trylock(&hotplug_mutex)) {
+			if (hotplug_occurred) {
+				hotplug_occurred = 0;
+				mutex_unlock(&hotplug_mutex);
+				cmm_dbg("Hotplug operation has occurred, "
+						"loaning activity suspended "
+						"for %d seconds.\n",
+						hotplug_delay);
+				timeleft = msleep_interruptible(hotplug_delay *
+						1000);
+				if (kthread_should_stop() || timeleft)
+					break;
+				continue;
+			}
+			mutex_unlock(&hotplug_mutex);
+		} else {
+			cmm_dbg("Hotplug operation in progress, activity "
+					"suspended\n");
+			continue;
 		}
 
 		cmm_get_mpp();
@@ -414,6 +461,193 @@ static struct notifier_block cmm_reboot_
 };
 
 /**
+ * cmm_count_pages - Count the number of pages loaned in a particular range.
+ *
+ * @arg: memory_isolate_notify structure with address range and count
+ *
+ * Return value:
+ *      0 on success
+ **/
+static unsigned long cmm_count_pages(void *arg)
+{
+	struct memory_isolate_notify *marg = arg;
+	struct cmm_page_array *pa;
+	unsigned long start = (unsigned long)pfn_to_kaddr(marg->start_pfn);
+	unsigned long end = start + (marg->nr_pages << PAGE_SHIFT);
+	unsigned long idx;
+
+	spin_lock(&cmm_lock);
+	pa = cmm_page_list;
+	while (pa) {
+		if ((unsigned long)pa >= start && (unsigned long)pa < end)
+			marg->pages_found++;
+		for (idx = 0; idx < pa->index; idx++)
+			if (pa->page[idx] >= start && pa->page[idx] < end)
+				marg->pages_found++;
+		pa = pa->next;
+	}
+	spin_unlock(&cmm_lock);
+	return 0;
+}
+
+/**
+ * cmm_memory_isolate_cb - Handle memory isolation notifier calls
+ * @self:	notifier block struct
+ * @action:	action to take
+ * @arg:	struct memory_isolate_notify data for handler
+ *
+ * Return value:
+ *	NOTIFY_OK or notifier error based on subfunction return value
+ **/
+static int cmm_memory_isolate_cb(struct notifier_block *self,
+				 unsigned long action, void *arg)
+{
+	int ret = 0;
+
+	if (action == MEM_ISOLATE_COUNT)
+		ret = cmm_count_pages(arg);
+
+	if (ret)
+		ret = notifier_from_errno(ret);
+	else
+		ret = NOTIFY_OK;
+
+	return ret;
+}
+
+static struct notifier_block cmm_mem_isolate_nb = {
+	.notifier_call = cmm_memory_isolate_cb,
+	.priority = CMM_MEM_ISOLATE_PRI
+};
+
+/**
+ * cmm_mem_going_offline - Unloan pages where memory is to be removed
+ * @arg: memory_notify structure with page range to be offlined
+ *
+ * Return value:
+ *	0 on success
+ **/
+static int cmm_mem_going_offline(void *arg)
+{
+	struct memory_notify *marg = arg;
+	unsigned long start_page = (unsigned long)pfn_to_kaddr(marg->start_pfn);
+	unsigned long end_page = start_page + (marg->nr_pages << PAGE_SHIFT);
+	struct cmm_page_array *pa_curr, *pa_last, *npa;
+	unsigned long idx;
+	unsigned long freed = 0;
+
+	cmm_dbg("Memory going offline, searching 0x%lx (%ld pages).\n",
+			start_page, marg->nr_pages);
+	spin_lock(&cmm_lock);
+
+	/* Search the page list for pages in the range to be offlined */
+	pa_last = pa_curr = cmm_page_list;
+	while (pa_curr) {
+		for (idx = (pa_curr->index - 1); (idx + 1) > 0; idx--) {
+			if ((pa_curr->page[idx] < start_page) ||
+			    (pa_curr->page[idx] >= end_page))
+				continue;
+
+			plpar_page_set_active(__pa(pa_curr->page[idx]));
+			free_page(pa_curr->page[idx]);
+			freed++;
+			loaned_pages--;
+			totalram_pages++;
+			pa_curr->page[idx] = pa_last->page[--pa_last->index];
+			if (pa_last->index == 0) {
+				if (pa_curr == pa_last)
+					pa_curr = pa_last->next;
+				pa_last = pa_last->next;
+				free_page((unsigned long)cmm_page_list);
+				cmm_page_list = pa_last;
+				continue;
+			}
+		}
+		pa_curr = pa_curr->next;
+	}
+
+	/* Search for page list structures in the range to be offlined */
+	pa_last = NULL;
+	pa_curr = cmm_page_list;
+	while (pa_curr) {
+		if (((unsigned long)pa_curr >= start_page) &&
+				((unsigned long)pa_curr < end_page)) {
+			npa = (struct cmm_page_array *)__get_free_page(
+					GFP_NOIO | __GFP_NOWARN |
+					__GFP_NORETRY | __GFP_NOMEMALLOC);
+			if (!npa) {
+				spin_unlock(&cmm_lock);
+				cmm_dbg("Failed to allocate memory for list "
+						"management. Memory hotplug "
+						"failed.\n");
+				return ENOMEM;
+			}
+			memcpy(npa, pa_curr, PAGE_SIZE);
+			if (pa_curr == cmm_page_list)
+				cmm_page_list = npa;
+			if (pa_last)
+				pa_last->next = npa;
+			free_page((unsigned long) pa_curr);
+			freed++;
+			pa_curr = npa;
+		}
+
+		pa_last = pa_curr;
+		pa_curr = pa_curr->next;
+	}
+
+	spin_unlock(&cmm_lock);
+	cmm_dbg("Released %ld pages in the search range.\n", freed);
+
+	return 0;
+}
+
+/**
+ * cmm_memory_cb - Handle memory hotplug notifier calls
+ * @self:	notifier block struct
+ * @action:	action to take
+ * @arg:	struct memory_notify data for handler
+ *
+ * Return value:
+ *	NOTIFY_OK or notifier error based on subfunction return value
+ *
+ **/
+static int cmm_memory_cb(struct notifier_block *self,
+			unsigned long action, void *arg)
+{
+	int ret = 0;
+
+	switch (action) {
+	case MEM_GOING_OFFLINE:
+		mutex_lock(&hotplug_mutex);
+		hotplug_occurred = 1;
+		ret = cmm_mem_going_offline(arg);
+		break;
+	case MEM_OFFLINE:
+	case MEM_CANCEL_OFFLINE:
+		mutex_unlock(&hotplug_mutex);
+		cmm_dbg("Memory offline operation complete.\n");
+		break;
+	case MEM_GOING_ONLINE:
+	case MEM_ONLINE:
+	case MEM_CANCEL_ONLINE:
+		break;
+	}
+
+	if (ret)
+		ret = notifier_from_errno(ret);
+	else
+		ret = NOTIFY_OK;
+
+	return ret;
+}
+
+static struct notifier_block cmm_mem_nb = {
+	.notifier_call = cmm_memory_cb,
+	.priority = CMM_MEM_HOTPLUG_PRI
+};
+
+/**
  * cmm_init - Module initialization
  *
  * Return value:
@@ -435,18 +669,24 @@ static int cmm_init(void)
 	if ((rc = cmm_sysfs_register(&cmm_sysdev)))
 		goto out_reboot_notifier;
 
+	if (register_memory_notifier(&cmm_mem_nb) ||
+	    register_memory_isolate_notifier(&cmm_mem_isolate_nb))
+		goto out_unregister_notifier;
+
 	if (cmm_disabled)
 		return rc;
 
 	cmm_thread_ptr = kthread_run(cmm_thread, NULL, "cmmthread");
 	if (IS_ERR(cmm_thread_ptr)) {
 		rc = PTR_ERR(cmm_thread_ptr);
-		goto out_unregister_sysfs;
+		goto out_unregister_notifier;
 	}
 
 	return rc;
 
-out_unregister_sysfs:
+out_unregister_notifier:
+	unregister_memory_notifier(&cmm_mem_nb);
+	unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
 	cmm_unregister_sysfs(&cmm_sysdev);
 out_reboot_notifier:
 	unregister_reboot_notifier(&cmm_reboot_nb);
@@ -467,6 +707,8 @@ static void cmm_exit(void)
 		kthread_stop(cmm_thread_ptr);
 	unregister_oom_notifier(&cmm_oom_nb);
 	unregister_reboot_notifier(&cmm_reboot_nb);
+	unregister_memory_notifier(&cmm_mem_nb);
+	unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
 	cmm_free_pages(loaned_pages);
 	cmm_unregister_sysfs(&cmm_sysdev);
 }
_

^ permalink raw reply

* [patch 5/5] powerpc/85xx: wrong variable returned on error
From: akpm @ 2009-12-18  0:45 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, akpm, roel.kluin

From: Roel Kluin <roel.kluin@gmail.com>

The wrong variable was returned in the case of an error.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/powerpc/platforms/85xx/mpc85xx_mds.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN arch/powerpc/platforms/85xx/mpc85xx_mds.c~powerpc-85xx-wrong-variable-returned-on-error arch/powerpc/platforms/85xx/mpc85xx_mds.c
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c~powerpc-85xx-wrong-variable-returned-on-error
+++ a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -86,7 +86,7 @@ static int mpc8568_fixup_125_clock(struc
 	scr = phy_read(phydev, MV88E1111_SCR);
 
 	if (scr < 0)
-		return err;
+		return scr;
 
 	err = phy_write(phydev, MV88E1111_SCR, scr | 0x0008);
 
_

^ permalink raw reply

* [patch 4/5] iseries: convert to proc_fops
From: akpm @ 2009-12-18  0:45 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, akpm, adobriyan

From: Alexey Dobriyan <adobriyan@gmail.com>

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/powerpc/platforms/iseries/mf.c |  147 ++++++++++++++------------
 1 file changed, 83 insertions(+), 64 deletions(-)

diff -puN arch/powerpc/platforms/iseries/mf.c~iseries-convert-to-proc_fops arch/powerpc/platforms/iseries/mf.c
--- a/arch/powerpc/platforms/iseries/mf.c~iseries-convert-to-proc_fops
+++ a/arch/powerpc/platforms/iseries/mf.c
@@ -855,59 +855,58 @@ static int mf_get_boot_rtc(struct rtc_ti
 }
 
 #ifdef CONFIG_PROC_FS
-
-static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
+static int mf_cmdline_proc_show(struct seq_file *m, void *v)
 {
-	int len;
-	char *p;
+	char *page, *p;
 	struct vsp_cmd_data vsp_cmd;
 	int rc;
 	dma_addr_t dma_addr;
 
 	/* The HV appears to return no more than 256 bytes of command line */
-	if (off >= 256)
-		return 0;
-	if ((off + count) > 256)
-		count = 256 - off;
+	page = kmalloc(256, GFP_KERNEL);
+	if (!page)
+		return -ENOMEM;
 
-	dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE);
-	if (dma_addr == DMA_ERROR_CODE)
+	dma_addr = iseries_hv_map(page, 256, DMA_FROM_DEVICE);
+	if (dma_addr == DMA_ERROR_CODE) {
+		kfree(page);
 		return -ENOMEM;
-	memset(page, 0, off + count);
+	}
+	memset(page, 0, 256);
 	memset(&vsp_cmd, 0, sizeof(vsp_cmd));
 	vsp_cmd.cmd = 33;
 	vsp_cmd.sub_data.kern.token = dma_addr;
 	vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-	vsp_cmd.sub_data.kern.side = (u64)data;
-	vsp_cmd.sub_data.kern.length = off + count;
+	vsp_cmd.sub_data.kern.side = (u64)m->private;
+	vsp_cmd.sub_data.kern.length = 256;
 	mb();
 	rc = signal_vsp_instruction(&vsp_cmd);
-	iseries_hv_unmap(dma_addr, off + count, DMA_FROM_DEVICE);
-	if (rc)
+	iseries_hv_unmap(dma_addr, 256, DMA_FROM_DEVICE);
+	if (rc) {
+		kfree(page);
 		return rc;
-	if (vsp_cmd.result_code != 0)
+	}
+	if (vsp_cmd.result_code != 0) {
+		kfree(page);
 		return -ENOMEM;
+	}
 	p = page;
-	len = 0;
-	while (len < (off + count)) {
-		if ((*p == '\0') || (*p == '\n')) {
-			if (*p == '\0')
-				*p = '\n';
-			p++;
-			len++;
-			*eof = 1;
+	while (p - page < 256) {
+		if (*p == '\0' || *p == '\n') {
+			*p = '\n';
 			break;
 		}
 		p++;
-		len++;
-	}
 
-	if (len < off) {
-		*eof = 1;
-		len = 0;
 	}
-	return len;
+	seq_write(m, page, p - page);
+	kfree(page);
+	return 0;
+}
+
+static int mf_cmdline_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, mf_cmdline_proc_show, PDE(inode)->data);
 }
 
 #if 0
@@ -962,10 +961,8 @@ static int proc_mf_dump_vmlinux(char *pa
 }
 #endif
 
-static int proc_mf_dump_side(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
+static int mf_side_proc_show(struct seq_file *m, void *v)
 {
-	int len;
 	char mf_current_side = ' ';
 	struct vsp_cmd_data vsp_cmd;
 
@@ -989,21 +986,17 @@ static int proc_mf_dump_side(char *page,
 		}
 	}
 
-	len = sprintf(page, "%c\n", mf_current_side);
+	seq_printf(m, "%c\n", mf_current_side);
+	return 0;
+}
 
-	if (len <= (off + count))
-		*eof = 1;
-	*start = page + off;
-	len -= off;
-	if (len > count)
-		len = count;
-	if (len < 0)
-		len = 0;
-	return len;
+static int mf_side_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, mf_side_proc_show, NULL);
 }
 
-static int proc_mf_change_side(struct file *file, const char __user *buffer,
-		unsigned long count, void *data)
+static ssize_t mf_side_proc_write(struct file *file, const char __user *buffer,
+				  size_t count, loff_t *pos)
 {
 	char side;
 	u64 newSide;
@@ -1041,6 +1034,15 @@ static int proc_mf_change_side(struct fi
 	return count;
 }
 
+static const struct file_operations mf_side_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= mf_side_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.write		= mf_side_proc_write,
+};
+
 #if 0
 static void mf_getSrcHistory(char *buffer, int size)
 {
@@ -1087,8 +1089,7 @@ static void mf_getSrcHistory(char *buffe
 }
 #endif
 
-static int proc_mf_dump_src(char *page, char **start, off_t off,
-		int count, int *eof, void *data)
+static int mf_src_proc_show(struct seq_file *m, void *v)
 {
 #if 0
 	int len;
@@ -1109,8 +1110,13 @@ static int proc_mf_dump_src(char *page, 
 #endif
 }
 
-static int proc_mf_change_src(struct file *file, const char __user *buffer,
-		unsigned long count, void *data)
+static int mf_src_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, mf_src_proc_show, NULL);
+}
+
+static ssize_t mf_src_proc_write(struct file *file, const char __user *buffer,
+				 size_t count, loff_t *pos)
 {
 	char stkbuf[10];
 
@@ -1135,9 +1141,19 @@ static int proc_mf_change_src(struct fil
 	return count;
 }
 
-static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
-		unsigned long count, void *data)
+static const struct file_operations mf_src_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= mf_src_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.write		= mf_src_proc_write,
+};
+
+static ssize_t mf_cmdline_proc_write(struct file *file, const char __user *buffer,
+				     size_t count, loff_t *pos)
 {
+	void *data = PDE(file->f_path.dentry->d_inode)->data;
 	struct vsp_cmd_data vsp_cmd;
 	dma_addr_t dma_addr;
 	char *page;
@@ -1172,6 +1188,15 @@ out:
 	return ret;
 }
 
+static const struct file_operations mf_cmdline_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= mf_cmdline_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.write		= mf_cmdline_proc_write,
+};
+
 static ssize_t proc_mf_change_vmlinux(struct file *file,
 				      const char __user *buf,
 				      size_t count, loff_t *ppos)
@@ -1246,12 +1271,10 @@ static int __init mf_proc_init(void)
 		if (!mf)
 			return 1;
 
-		ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
+		ent = proc_create_data("cmdline", S_IRUSR|S_IWUSR, mf,
+				       &mf_cmdline_proc_fops, (void *)(long)i);
 		if (!ent)
 			return 1;
-		ent->data = (void *)(long)i;
-		ent->read_proc = proc_mf_dump_cmdline;
-		ent->write_proc = proc_mf_change_cmdline;
 
 		if (i == 3)	/* no vmlinux entry for 'D' */
 			continue;
@@ -1263,19 +1286,15 @@ static int __init mf_proc_init(void)
 			return 1;
 	}
 
-	ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	ent = proc_create("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root,
+			  &mf_side_proc_fops);
 	if (!ent)
 		return 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_side;
-	ent->write_proc = proc_mf_change_side;
 
-	ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	ent = proc_create("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root,
+			  &mf_src_proc_fops);
 	if (!ent)
 		return 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_src;
-	ent->write_proc = proc_mf_change_src;
 
 	return 0;
 }
_

^ permalink raw reply

* [patch 1/5] powerpc: Sky CPU: redundant or incorrect tests on unsigned
From: akpm @ 2009-12-18  0:44 UTC (permalink / raw)
  To: benh; +Cc: waite, roel.kluin, gorcunov, linuxppc-dev, galak, akpm

From: Roel Kluin <roel.kluin@gmail.com>

count is unsigned and cannot be less than 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@gate.crashing.org>
Cc: Brian Waite <waite@skycomputers.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/misc/hdpuftrs/hdpu_cpustate.c |    5 -----
 1 file changed, 5 deletions(-)

diff -puN drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned drivers/misc/hdpuftrs/hdpu_cpustate.c
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c~powerpc-sky-cpu-redundant-or-incorrect-tests-on-unsigned
+++ a/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -121,8 +121,6 @@ static ssize_t cpustate_read(struct file
 {
 	unsigned char data;
 
-	if (count < 0)
-		return -EFAULT;
 	if (count == 0)
 		return 0;
 
@@ -137,9 +135,6 @@ static ssize_t cpustate_write(struct fil
 {
 	unsigned char data;
 
-	if (count < 0)
-		return -EFAULT;
-
 	if (count == 0)
 		return 0;
 
_

^ permalink raw reply

* Re: [PATCH 3/3] mpc8xxx_gpio: add interrupt support
From: Peter Korsgaard @ 2009-12-17 20:31 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Anton Vorontsov, linuxppc-dev
In-Reply-To: <87r5r1ttmd.fsf@macbook.be.48ers.dk>

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

>>>>> "Kumar" == Kumar Gala <galak@kernel.crashing.org> writes:
 Peter> Hi,

 Kumar> We need a binding document to go with this.

 Peter> Ok, but where should it go? In the existing
 Peter> powerpc/dts-bindings/fsl/8xxx_gpio.txt or somewhere seperate? I don't
 Peter> see any other interrupt controller documentation besides the stuff in
 Peter> booting-without-of.txt

Any comments?

-- 
Bye, Peter Korsgaard

^ permalink raw reply

* Re: Problem with mini-PCI-E slot on P2020RDB
From: Felix Radensky @ 2009-12-17 20:28 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Mahajan Vivek-B08308, linuxppc-dev, Aggrwal Poonam-B10812
In-Reply-To: <EBE3ECA5-AC1B-4E1C-A0DA-89260D0F03F6@kernel.crashing.org>

Hi, Kumar
Kumar Gala wrote:
> On Dec 17, 2009, at 2:59 AM, Mahajan Vivek-B08308 wrote:
>
>   
>>> Thanks a lot. If I understand you correctly, the only way I 
>>> can get ath9k driver to work on this board using legacy 
>>> interrupts is to wait for a hardware fix. Right ?
>>>       
>> Correct
>>     
>
> I'm confused.  What's the issue with IRQ0 on the P2020RDB?  Is it used for another purpose?
>   

There's a problem with IRQ0 with respect to mini-PCI-E slot. I have 
Atheros wireless card plugged
into it. ath9k wireless driver for this card uses legacy PCI-E 
interrupts, and I get "irq 16: nobody cared"
message when driver executes request_irq(). Vivek has come to a 
conclusion that the problem is
related to incorrect IRQ0 routing for mini-PCI-E slot on P2020RDB.

Felix.

^ permalink raw reply

* Re: [Patch 1/1] PPC64-HWBKPT: Implement hw-breakpoints for PPC64
From: K.Prasad @ 2009-12-17 19:03 UTC (permalink / raw)
  To: Roland McGrath
  Cc: Michael Neuling, Benjamin Herrenschmidt, Frederic Weisbecker,
	David Gibson, linuxppc-dev, Alan Stern, paulus
In-Reply-To: <20091214192626.3F9171DE@magilla.sf.frob.com>

On Mon, Dec 14, 2009 at 11:26:26AM -0800, Roland McGrath wrote:
<snipped>
> I understand the reason for using stepping.  (I have advised in the past
> that I thought this magical implicit step logic was too hairy to roll in
> under the covers and that a low-level facility expressing the different
> hardware semantics to a kernel API would be OK.  I do agree with the
> motivation of cross-arch uniformity of the semantics.  I don't object to
> making it magically right--I just expressed general skepticism/fear about
> getting that right so that I didn't want to try writing that magic.  Now
> I'm just responding about the particular details I've noticed about that
> can of worms.  It's certainly great if you can resolve all that.  But I'll
> note that I am still by no means confident that the details I have raised
> cover all the worms in that can.)
> 
> What remains less than clear is how preemption relates.  For any per-thread
> hw_breakpoint, there is no high-level reason to care one way or the other.
> The thread, its HW breakpoints, its register state including state of
> stepping, are all part of per-thread state and no reason to do any less (or
> more) preemption than normally happens.
> 

I get that reasoning now...I'd been unduly worried about pre-emption
and hence the introduction of pre-emption disabled state.

But of course, in the existing design, the per-cpu variables would be
affected because if pre-emption was to occur. I'll see how that can be
factored in, while retaining the abstraction provided by the interfaces.

> > Disabling pre-emption is necessary to ensure that hw-breakpoints are
> > enabled immediately after the causative instruction has finished
> > execution (the control flow may go astray if pre-emption occurs between
> > i1 and i2).
> 
> I don't understand what "go astray" means here.  The only thing I can think
> of is the effect on any per-cpu variables you are using in hw_breakpoint
> implementation.
> 

As stated above, I was worried about a pre-emption happening between a
return from breakpoint exception handler and the execution of the
causative instruction....but as I learn, it seems fine now. It is just that
the kernel code needs to be tweaked keeping this in mind.

Thanks,
K.Prasad

^ permalink raw reply

* Re: [PATCH v2 2/2] Crypto: Talitos: Support for Async_tx XOR offload
From: Kumar Gala @ 2009-12-17 18:45 UTC (permalink / raw)
  To: Dan Williams
  Cc: herbert@gondor.apana.org.au, Ira W. Snyder, B04825@freescale.com,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	linuxppc-dev@ozlabs.org, Vishnu Suresh,
	linux-crypto@vger.kernel.org, Dipen Dudhat, Maneesh Gupta,
	R58472@freescale.com
In-Reply-To: <4B2A6DFA.6000504@intel.com>


On Dec 17, 2009, at 11:44 AM, Dan Williams wrote:

> Ira W. Snyder wrote:
>> Yes, I have used the device_prep_dma_interrupt() functionality quite =
a
>> while back. However, I found it to be pretty much useless.
>=20
> The specific case it is needed for Talitos/raid is a channel switch =
interrupt.  The interrupt causes the cleanup operation to be run which =
will kick off any pending dependent operations on the xor channel.  In =
the raid case we only have callbacks at the end of a chain, so we need =
the interrupt to kick the engine in an operation chain like =
xor->copy->xor->callback.

Ok, I'm still confused as to how the DMA interrupt interacts with the =
Talitos/raid side of things.  The should be completely independent =
(separate interrupts, separate IP blocks).

- k=

^ permalink raw reply

* [PATCH] powerpc: gamecube/wii: fix off-by-one error in ugecon/usbgecko_udbg
From: Albert Herranz @ 2009-12-17 18:33 UTC (permalink / raw)
  To: linuxppc-dev, grant.likely; +Cc: juha_motorsportcom, Albert Herranz

The retry logic in ug_putc() is broken.

If the TX fifo is not ready and the counter runs out it will have a
value of -1 and no transfer should be attempted. Also, a counter
with a value of 0 means that the TX fifo got ready in the last try
and the transfer should be attempted.

Reported-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
---
 arch/powerpc/boot/ugecon.c                         |    2 +-
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/ugecon.c b/arch/powerpc/boot/ugecon.c
index 50609ea..8f2a6b3 100644
--- a/arch/powerpc/boot/ugecon.c
+++ b/arch/powerpc/boot/ugecon.c
@@ -86,7 +86,7 @@ static void ug_putc(char ch)
 
 	while (!ug_is_txfifo_ready() && count--)
 		barrier();
-	if (count)
+	if (count >= 0)
 		ug_raw_putc(ch);
 }
 
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
index edc956c..20a8ed9 100644
--- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
+++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
@@ -120,7 +120,7 @@ static void ug_putc(char ch)
 
 	while (!ug_is_txfifo_ready() && count--)
 		barrier();
-	if (count)
+	if (count >= 0)
 		ug_raw_putc(ch);
 }
 
-- 
1.6.3.3

^ permalink raw reply related

* Re: [PATCH v2 2/2] Crypto: Talitos: Support for Async_tx XOR offload
From: Dan Williams @ 2009-12-17 17:44 UTC (permalink / raw)
  To: Ira W. Snyder
  Cc: herbert@gondor.apana.org.au, B04825@freescale.com,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	linuxppc-dev@ozlabs.org, Vishnu Suresh,
	linux-crypto@vger.kernel.org, Dipen Dudhat, Maneesh Gupta,
	R58472@freescale.com
In-Reply-To: <20091217170958.GE18271@ovro.caltech.edu>

Ira W. Snyder wrote:
> Yes, I have used the device_prep_dma_interrupt() functionality quite a
> while back. However, I found it to be pretty much useless.

The specific case it is needed for Talitos/raid is a channel switch 
interrupt.  The interrupt causes the cleanup operation to be run which 
will kick off any pending dependent operations on the xor channel.  In 
the raid case we only have callbacks at the end of a chain, so we need 
the interrupt to kick the engine in an operation chain like 
xor->copy->xor->callback.

--
Dan

^ permalink raw reply

* Re: [PATCH v2 2/2] Crypto: Talitos: Support for Async_tx XOR offload
From: Kumar Gala @ 2009-12-17 17:29 UTC (permalink / raw)
  To: Ira W. Snyder
  Cc: herbert@gondor.apana.org.au, B04825@freescale.com,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	linuxppc-dev@ozlabs.org, Vishnu Suresh,
	linux-crypto@vger.kernel.org, Dipen Dudhat, Dan Williams,
	Maneesh Gupta, R58472@freescale.com
In-Reply-To: <20091217170958.GE18271@ovro.caltech.edu>


On Dec 17, 2009, at 11:09 AM, Ira W. Snyder wrote:

> On Wed, Dec 16, 2009 at 03:47:48PM -0700, Dan Williams wrote:
>> Kumar Gala wrote:
>>>>> Changes with respect to v1 as per comments received
>>>>> o. Rebased to linux-next as of 20091216
>>>>> o. The selection is based exclusive of fsldma
>>>>> o. Intoduced a new Kernel Configuration variable
>>>>>  *. This enables selecting the Cryptographic functionality
>>>>>     of Talitos along with fsldma.
>>>>>  *. Disables the XOR parity calculation offload, if fsldma enabled
>>>>>     either as kernel in-built or as a module
>>>>>  *. Once the inter-operability with fsldma is resolved, this =
option
>>>>>     can be removed
>>>> wait, why can't the interoperability bug be fixed in the first =
place?
>>>=20
>>> I agree w/Kim.  We need to better understand what the bug is and how =
to reproduce it so we can get to the root cause.
>>>=20
>>> Paper taping over it by disabling fsldma is not the right solution.
>>=20
>> Hopefully this prompts fsldma authors to get involved because the=20
>> interoperability issue has been out there without comment*, just=20
>> band-aids, since October.
>>=20
>> --
>> Dan
>>=20
>> * well one comment from Ira saying the interrupt functionality worked=20=

>> for him.
>=20
> Yes, I have used the device_prep_dma_interrupt() functionality quite a
> while back. However, I found it to be pretty much useless. Any
> functionality I need is covered by adding a callback to the last DMA
> memcpy() operation. Since the operations happen in-order, I can be =
sure
> that the entire set of memcpy()s cas completed. I never needed the
> capability to generate an interrupt without a memcpy().
>=20
> I agree that the fsldma driver could use some love. There are places
> where I am still not confident in the locking. Perhaps I can find some
> time over Christmas to work on it, but I need someone with 85xx/86xx
> hardware to test the changes. I only have 83xx hardware.

I can test on 85xx/86xx if you work up some patches.

- k=

^ permalink raw reply

* Re: [PATCH v2 2/2] Crypto: Talitos: Support for Async_tx XOR offload
From: Ira W. Snyder @ 2009-12-17 17:09 UTC (permalink / raw)
  To: Dan Williams
  Cc: herbert@gondor.apana.org.au, B04825@freescale.com,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	linuxppc-dev@ozlabs.org, Vishnu Suresh,
	linux-crypto@vger.kernel.org, Dipen Dudhat, Maneesh Gupta,
	R58472@freescale.com
In-Reply-To: <4B296394.9010709@intel.com>

On Wed, Dec 16, 2009 at 03:47:48PM -0700, Dan Williams wrote:
> Kumar Gala wrote:
> >>> Changes with respect to v1 as per comments received
> >>> o. Rebased to linux-next as of 20091216
> >>> o. The selection is based exclusive of fsldma
> >>> o. Intoduced a new Kernel Configuration variable
> >>>   *. This enables selecting the Cryptographic functionality
> >>>      of Talitos along with fsldma.
> >>>   *. Disables the XOR parity calculation offload, if fsldma enabled
> >>>      either as kernel in-built or as a module
> >>>   *. Once the inter-operability with fsldma is resolved, this option
> >>>      can be removed
> >> wait, why can't the interoperability bug be fixed in the first place?
> > 
> > I agree w/Kim.  We need to better understand what the bug is and how to reproduce it so we can get to the root cause.
> > 
> > Paper taping over it by disabling fsldma is not the right solution.
> 
> Hopefully this prompts fsldma authors to get involved because the 
> interoperability issue has been out there without comment*, just 
> band-aids, since October.
> 
> --
> Dan
> 
> * well one comment from Ira saying the interrupt functionality worked 
> for him.

Yes, I have used the device_prep_dma_interrupt() functionality quite a
while back. However, I found it to be pretty much useless. Any
functionality I need is covered by adding a callback to the last DMA
memcpy() operation. Since the operations happen in-order, I can be sure
that the entire set of memcpy()s cas completed. I never needed the
capability to generate an interrupt without a memcpy().

I agree that the fsldma driver could use some love. There are places
where I am still not confident in the locking. Perhaps I can find some
time over Christmas to work on it, but I need someone with 85xx/86xx
hardware to test the changes. I only have 83xx hardware.

Ira

^ permalink raw reply

* Re: Problem with mini-PCI-E slot on P2020RDB
From: Kumar Gala @ 2009-12-17 17:01 UTC (permalink / raw)
  To: Mahajan Vivek-B08308; +Cc: linuxppc-dev, Felix Radensky, Aggrwal Poonam-B10812
In-Reply-To: <0949C49693EF1A47A54B0F0113CDB4A60767F0@zin33exm23.fsl.freescale.net>


On Dec 17, 2009, at 2:59 AM, Mahajan Vivek-B08308 wrote:

>>=20
>> Thanks a lot. If I understand you correctly, the only way I=20
>> can get ath9k driver to work on this board using legacy=20
>> interrupts is to wait for a hardware fix. Right ?
>=20
> Correct

I'm confused.  What's the issue with IRQ0 on the P2020RDB?  Is it used =
for another purpose?

- k=

^ permalink raw reply

* Need advice on changing MPC5200B UART prescaler
From: Sylvain Lamontagne @ 2009-12-17 15:57 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

Hi all,

I would like to be able to set a baud rate of 460800 for modem that we are
testing. With the actual prescaler of 32 and a IPB frequency of 84MHz
I got a 5.1% error (437500) vs a 0.9% error (456522) if I could use the
prescaler of 4. See MPC5200B user manual page 15-46 for the calculation
formula and page 15-12 for the CSR description.

Currently the code for the kernel we are using here, (2.6.29.2) seams not to
take a prescaler of 4 into account.
Line 249 of mpc52xx_uart.c
http://lxr.linux.no/linux+v2.6.29.2/drivers/serial/mpc52xx_uart.c#L249

/* Search for bus-frequency property in this node or a parent */
static unsigned long mpc52xx_getuartclk(void *p)
{
        /*
         * 5200 UARTs have a / 32 prescaler
         * but the generic serial code assumes 16
         * so return ipb freq / 2
         */
        return mpc52xx_find_ipb_freq(p) / 2;
}

How could I make it use the prescaler of 4 without breaking anything that we
currently have working ?
I doubt that simply doing  return mpc52xx_find_ipb_freq(p) / 4 would do the
trick ...

[-- Attachment #2: Type: text/html, Size: 1418 bytes --]

^ permalink raw reply

* Re: [PATCH] PowerPC: const intspec pointers
From: Roman Fietze @ 2009-12-17 12:55 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <fa686aa40912151150o64f97533h1b736b4445301192@mail.gmail.com>

Hello Grant,

On Tuesday 15 December 2009 20:50:05 Grant Likely wrote:

> Yes, I'm using the driver in a couple of projects.  It works for me
> for both RX and TX (although TX+DMA has been troublesome).

That's what I found out.

> The test driver on the other hand is pretty poor code.  Don't expect
> much from it other than some hints.  There's a reason I didn't merge
> that chunk.

I brought it up to speed before using it.

> Yes, please post the patches and cc: me. I'll review, test, and make
> comments.

I hope it's ok that I've copied them to my web space instead of
providing patches in a mail. The URL is:

  http://www.fietze-home.de/telemotive/linux-2.6-telemotive-mpc.git

Branches:

  benh-next-lpbfifo
    the modified version of the LocalPlus platform driver

  benh-next-localplus-test
    your old test driver, now using the platform driver


Both branches are on top of the benh next branch.


I could only test the driver using fifo and bcom mode in read mode,
using your old test driver, because I currently do not yet have a
target with a writeable device on the LocalPlus. The test ran fine
using different transer sizes starting at 4 up to 128KiB.

I will now port our FPGA driver to use the platform driver, which can
deliver a very high load, and supports writing.

The biggest problem using DMA is the unpredictable order of arrival of
the two interrupts. They both depend on the appropriate load of the
system generating them. In the case of the BestComm a parallel load on
e.g. FEC or ATA can delay the bcom gen bd interrupt until it's task
gets scheduled again, which can take "some time" due its low BestComm
prio of 2. The second problem was, that the original driver does not
use the flush bit to avoid stale RX data.


Roman

=2D-=20
Roman Fietze                Telemotive AG B=FCro M=FChlhausen
Breitwiesen                              73347 M=FChlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply

* Re: [PATCH -tip tracing/kprobes] PPC: Powerpc port of the kprobe-based event tracer
From: Michael Neuling @ 2009-12-17  9:57 UTC (permalink / raw)
  To: Mahesh Jagannath Salgaonkar; +Cc: linuxppc-dev, Masami Hiramatsu
In-Reply-To: <4B29EE5F.9020801@linux.vnet.ibm.com>

In message <4B29EE5F.9020801@linux.vnet.ibm.com> you wrote:
> Hi Michael,
> 
> Michael Neuling wrote:
> >> Index: linux-2.6-tip/arch/powerpc/include/asm/ptrace.h
> >> ===================================================================
> >> --- linux-2.6-tip.orig/arch/powerpc/include/asm/ptrace.h
> >> +++ linux-2.6-tip/arch/powerpc/include/asm/ptrace.h
> >> @@ -83,6 +83,7 @@ struct pt_regs {
> >>  
> >>  #define instruction_pointer(regs) ((regs)->nip)
> >>  #define user_stack_pointer(regs) ((regs)->gpr[1])
> >> +#define kernel_stack_pointer(regs) ((regs)->gpr[1])
> >>  #define regs_return_value(regs) ((regs)->gpr[3])
> >>  
> >>  #ifdef CONFIG_SMP
> >> @@ -131,6 +132,69 @@ do {						
> > 			      \
> >>  } while (0)
> >>  #endif /* __powerpc64__ */
> >>  
> >> +/* Query offset/name of register from its name/offset */
> >> +#include <linux/stddef.h>
> >> +#include <linux/thread_info.h>
> > 
> > Includes should be at the start of the file
> > 
> The compilation throws many errors when moved to start of the file. This 
> file has lots of #ifdef and found this place to be perfect for compilation.

Ok, no problem.

> 
> >> +/**
> >> + * regs_query_register_name() - query register name from its offset
> >> + * @offset:	the offset of a register in struct pt_regs.
> >> + *
> >> + * regs_query_register_name() returns the name of a register from its
> >> + * offset in struct pt_regs. If the @offset is invalid, this returns NULL
;
> >> + */
> >> +const char *regs_query_register_name(unsigned int offset)
> >> +{
> >> +	const struct pt_regs_offset *roff;
> >> +	for (roff = regoffset_table; roff->name != NULL; roff++)
> >> +		if (roff->offset == offset)
> >> +			return roff->name;
> >> +	return NULL;
> >> +}
> >> +
> >> +static const int arg_offs_table[] = {
> >> +	[0] = offsetof(struct pt_regs, gpr[3]),
> >> +	[1] = offsetof(struct pt_regs, gpr[4]),
> >> +	[2] = offsetof(struct pt_regs, gpr[5]),
> >> +	[3] = offsetof(struct pt_regs, gpr[6]),
> >> +	[4] = offsetof(struct pt_regs, gpr[7]),
> >> +	[5] = offsetof(struct pt_regs, gpr[8]),
> >> +	[6] = offsetof(struct pt_regs, gpr[9]),
> >> +	[7] = offsetof(struct pt_regs, gpr[10])
> >> +};
> >> +
> >> +/**
> >> + * regs_get_argument_nth() - get Nth argument at function call
> >> + * @regs:	pt_regs which contains registers at function entry.
> >> + * @n:		argument number.
> >> + *
> >> + * regs_get_argument_nth() returns @n th argument of a function call.
> >> + * Since usually the kernel stack will be changed right after function en
try
> > ,
> >> + * you must use this at function entry. If the @n th entry is NOT in the
> >> + * kernel stack or pt_regs, this returns 0.
> >> + */
> >> +unsigned long regs_get_argument_nth(struct pt_regs *regs, unsigned int n)
> >> +{
> >> +	if (n < ARRAY_SIZE(arg_offs_table))
> >> +		return *(unsigned long *)((char *)regs + arg_offs_table[n]);
> >> +	else {
> >> +		/*
> >> +		 * If more arguments are passed that can be stored in
> >> +		 * registers, the remaining arguments are stored in the
> >> +		 * parameter save area located at fixed offset from stack
> >> +		 * pointer.
> >> +		 * Following the PowerPC ABI, the first few arguments are
> >> +		 * actually passed in registers (r3-r10), with equivalent space
> >> +		 * left unused in the parameter save area.
> >> +		 */
> >> +		n += (PARAMETER_SAVE_AREA_OFFSET / sizeof(unsigned long));
> >> +		return regs_get_kernel_stack_nth(regs, n);
> > 
> > How do we handle FP args?
> 
> Currently this patch does not support FP args.

This might be OK.  I don't think we use floating point parameters in any
function definitions in the kernel.  

We do use altivec in the raid6 driver (drivers/md/raid6altivec.uc) but
they are static inline, so they probably don't even end up as
functions.  

I guess we need to make sure that we're not limiting the interface in
such a way that we can't support it later if the above changes.  

regs_get_argument_nth returns an unsigned long which makes returning a
128 bit VMX register impossible.  This might be a show stopper for me.
How are the x86 guys dealing with this?

> > 
> >> +	}
> >> +}
> >> +/*
> >>   * does not yet catch signals sent when the child dies.
> >>   * in exit.c or in signal.c.
> >>   */
> >> Index: linux-2.6-tip/kernel/trace/Kconfig
> >> ===================================================================
> >> --- linux-2.6-tip.orig/kernel/trace/Kconfig
> >> +++ linux-2.6-tip/kernel/trace/Kconfig
> >> @@ -464,7 +464,7 @@ config BLK_DEV_IO_TRACE
> >>  
> >>  config KPROBE_EVENT
> >>  	depends on KPROBES
> >> -	depends on X86
> >> +	depends on X86 || PPC
> >>  	bool "Enable kprobes-based dynamic events"
> >>  	select TRACING
> >>  	default y
> >>
> >> _______________________________________________
> >> Linuxppc-dev mailing list
> >> Linuxppc-dev@lists.ozlabs.org
> >> https://lists.ozlabs.org/listinfo/linuxppc-dev
> >>
> 
> Thanks for reviewing.

We are creating a new user space API here, so I'm keen for others to take
a good look at the interface before we commit to something we are going
to have to keep forever.  

Who is the main consumer of this (/me is pretty ignorant of kprobes)?
What do they think of the interface?

Mikey

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox