Re: [PATCH] powerpc: Fix call to flush_ptrace_hw_breakpoint()

2011-02-06 Thread Benjamin Herrenschmidt
On Mon, 2011-02-07 at 10:22 +0530, K.Prasad wrote:
> Okay! Another wrapper of "#ifndef CONFIG_HAVE_HW_BREAKPOINT" around
> the
> definition of 'set_debug_reg_defaults'.

Can you send a patch ?

> There's indeed too much sprinkling of #ifdefs in the code, but most of
> it would go away when the BookE code also uses the generic
> hw-breakpoint interfaces. 

What's your status for those patches ?

> Given the advanced debug features that BookE supports, it's
> unfortunately not that straight-forward (needs additions to generic
> hw-breakpoint infrastructure).

Might want to move a lot of that code to a separate set of files maybe
and just call a single hook from the various process.c locations ?

Cheers,
Ben.

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


Re: [PATCH v2 3/3] powerpc: Add IO event interrupt support

2011-02-06 Thread Benjamin Herrenschmidt
On Wed, 2011-01-05 at 16:44 -0600, Tseng-Hui (Frank) Lin wrote:
> This patch adds support for handling IO Event interrupts which come
> through at the /event-sources/ibm,io-events device tree node.

 .../...

The previous patches regarding the error log sometimes call it error log
and sometimes event log. Can you consolidate that ?

> +int pseries_ioei_register_handler(pseries_ioei_handler_t handler)
> +{

Shouldn't we have a void * to attach with each client so it can put
its private data there and get them back in the handler ?

We are -really- re-inventing interrupts and/or notifiers here, which
I find a tad annoying..

Cheers,
Ben.


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


Re: [PATCH 2/6] nvram: Capture oops/panic reports in ibm, oops-log partition

2011-02-06 Thread Benjamin Herrenschmidt
On Sat, 2010-11-13 at 20:15 -0800, Jim Keniston wrote:
> Create the ibm,oops-log NVRAM partition, and capture the end of the printk
> buffer in it when there's an oops or panic.  If we can't create the
> ibm,oops-log partition, capture the oops/panic report in ibm,rtas-log.

Won't the parsing tools choke on the oops log in the RTAS log
partition ?

Also, maybe remove the "ibm," prefix on the nvram partition, make it
"lnx," instead.

Then, if you move the rest of the code out of pseries, you can move that
out too, just make pseries platform code call the init code for it, that
way other platforms can re-use that as-is.

But that later part can wait a separate patch series, just make sure you
change the partition name now.

Cheers,
Ben.

> Signed-off-by: Jim Keniston 
> ---
> 
>  arch/powerpc/platforms/pseries/nvram.c |   89 
> 
>  1 files changed, 88 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/nvram.c 
> b/arch/powerpc/platforms/pseries/nvram.c
> index 43d5c52..6c88cda 100644
> --- a/arch/powerpc/platforms/pseries/nvram.c
> +++ b/arch/powerpc/platforms/pseries/nvram.c
> @@ -16,6 +16,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -50,11 +52,32 @@ static struct os_partition rtas_log_partition = {
>   .index = -1
>  };
>  
> +static struct os_partition oops_log_partition = {
> + .name = "ibm,oops-log",
> + .req_size = 4000,
> + .min_size = 2000,
> + .index = -1
> +};
> +
>  static const char *valid_os_partitions[] = {
>   "ibm,rtas-log",
> + "ibm,oops-log",
>   NULL
>  };
>  
> +static void oops_to_nvram(struct kmsg_dumper *dumper,
> + enum kmsg_dump_reason reason,
> + const char *old_msgs, unsigned long old_len,
> + const char *new_msgs, unsigned long new_len);
> +
> +static struct kmsg_dumper nvram_kmsg_dumper = {
> + .dump = oops_to_nvram
> +};
> +
> +/* We preallocate oops_buf during init to avoid kmalloc during oops/panic. */
> +static size_t oops_buf_sz;
> +static char *oops_buf;
> +
>  static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
>  {
>   unsigned int i;
> @@ -337,9 +360,36 @@ static int __init pseries_nvram_init_os_partition(struct 
> os_partition *part)
>   return 0;
>  }
>  
> +static void __init nvram_init_oops_partition(int rtas_partition_exists)
> +{
> + int rc;
> +
> + rc = pseries_nvram_init_os_partition(&oops_log_partition);
> + if (rc != 0) {
> + if (!rtas_partition_exists)
> + return;
> + pr_notice("nvram: Using %s partition to log both"
> + " RTAS errors and oops/panic reports\n",
> + rtas_log_partition.name);
> + memcpy(&oops_log_partition, &rtas_log_partition,
> + sizeof(rtas_log_partition));
> + }
> + oops_buf_sz = oops_log_partition.size - sizeof(struct err_log_info);
> + oops_buf = kmalloc(oops_buf_sz, GFP_KERNEL);
> + rc = kmsg_dump_register(&nvram_kmsg_dumper);
> + if (rc != 0) {
> + pr_err("nvram: kmsg_dump_register() failed; returned %d\n", rc);
> + kfree(oops_buf);
> + return;
> + }
> +}
> +
>  static int __init pseries_nvram_init_log_partitions(void)
>  {
> - (void) pseries_nvram_init_os_partition(&rtas_log_partition);
> + int rc;
> +
> + rc = pseries_nvram_init_os_partition(&rtas_log_partition);
> + nvram_init_oops_partition(rc == 0);
>   return 0;
>  }
>  machine_late_initcall(pseries, pseries_nvram_init_log_partitions);
> @@ -373,3 +423,40 @@ int __init pSeries_nvram_init(void)
>  
>   return 0;
>  }
> +
> +/*
> + * Try to capture the last capture_len bytes of the printk buffer.  Return
> + * the amount actually captured.
> + */
> +static size_t capture_last_msgs(const char *old_msgs, size_t old_len,
> + const char *new_msgs, size_t new_len,
> + char *captured, size_t capture_len)
> +{
> + if (new_len >= capture_len) {
> + memcpy(captured, new_msgs + (new_len - capture_len),
> + capture_len);
> + return capture_len;
> + } else {
> + /* Grab the end of old_msgs. */
> + size_t old_tail_len = min(old_len, capture_len - new_len);
> + memcpy(captured, old_msgs + (old_len - old_tail_len),
> + old_tail_len);
> + memcpy(captured + old_tail_len, new_msgs, new_len);
> + return old_tail_len + new_len;
> + }
> +}
> +
> +/* our kmsg_dump callback */
> +static void oops_to_nvram(struct kmsg_dumper *dumper,
> + enum kmsg_dump_reason reason,
> + const char *old_msgs, unsigned long old_len,
> + const char *new_msgs, unsign

Re: [PATCH 1/6] nvram: Generalize code for OS partitions in NVRAM

2011-02-06 Thread Benjamin Herrenschmidt
On Sat, 2010-11-13 at 20:15 -0800, Jim Keniston wrote:
> Adapt the functions used to create and write to the RTAS-log partition
> to work with any OS-type partition.
> 
> Signed-off-by: Jim Keniston 
> ---

Overall pretty good (sorry for taking that long to review, I've been
swamped down). Just a handful of minor nits:

> +/*
> + * Per the criteria passed via nvram_remove_partition(), should this
> + * partition be removed?  1=remove, 0=keep
> + */
> +static int nvram_condemn_partition(struct nvram_partition *part,
> + const char *name, int sig, const char *exceptions[])

As "fun" as this name is, it didn't help me understand what the function
was about until I read the code for the next one :-)

What about instead something like nvram_can_remove_partition() or
something a bit more explicit like that ?

"comdemn" made me thought it was a function used to "mark" partitions
to be killed later, which is not what the function does.

 .../...

> +static const char *valid_os_partitions[] = {
> + "ibm,rtas-log",
> + NULL
> +};

Can you pick a name that will be less confusing in the global
symbol table ? Something like "pseries_nvram_os_partitions"
or whatever shorter you can come up with which doesn't suck ?

Also, should we move that "os partition" core out of pseries ?

Looks like it will be useful for a few other platforms, I'd like
to move that to a more generically useful location in arch/powerpc
but that's not a blocker for this series but something to do next
maybe ?

In that case "struct os_partition" should also find itself a better
name, maybe struct nvram_os_partition ?

>  static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
>  {
> @@ -134,7 +147,7 @@ static ssize_t pSeries_nvram_get_size(void)
>  }
>  
> 
> -/* nvram_write_error_log
> +/* nvram_write_os_partition, nvram_write_error_log
>   *
>   * We need to buffer the error logs into nvram to ensure that we have
>   * the failure information to decode.  If we have a severe error there
> @@ -156,48 +169,55 @@ static ssize_t pSeries_nvram_get_size(void)
>   * The 'data' section would look like (in bytes):
>   * +--++---+
>   * | event_logged | sequence # | error log |
> - * |03|4  7|8nvram_error_log_size-1|
> + * |03|4  7|8  error_log_size-1|
>   * +--++---+
>   *
>   * event_logged: 0 if event has not been logged to syslog, 1 if it has
>   * sequence #: The unique sequence # for each event. (until it wraps)
>   * error log: The error log from event_scan
>   */
> -int nvram_write_error_log(char * buff, int length,
> +int nvram_write_os_partition(struct os_partition *part, char * buff, int 
> length,
>unsigned int err_type, unsigned int error_log_cnt)
>  {
>   int rc;
>   loff_t tmp_index;
>   struct err_log_info info;
>   
> - if (nvram_error_log_index == -1) {
> + if (part->index == -1) {
>   return -ESPIPE;
>   }
>  
> - if (length > nvram_error_log_size) {
> - length = nvram_error_log_size;
> + if (length > part->size) {
> + length = part->size;
>   }
>  
>   info.error_type = err_type;
>   info.seq_num = error_log_cnt;
>  
> - tmp_index = nvram_error_log_index;
> + tmp_index = part->index;
>  
>   rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), 
> &tmp_index);
>   if (rc <= 0) {
> - printk(KERN_ERR "nvram_write_error_log: Failed nvram_write 
> (%d)\n", rc);
> + printk(KERN_ERR "nvram_write_os_partition: Failed nvram_write 
> (%d)\n", rc);
>   return rc;
>   }
>  
>   rc = ppc_md.nvram_write(buff, length, &tmp_index);
>   if (rc <= 0) {
> - printk(KERN_ERR "nvram_write_error_log: Failed nvram_write 
> (%d)\n", rc);
> + printk(KERN_ERR "nvram_write_os_partition: Failed nvram_write 
> (%d)\n", rc);
>   return rc;
>   }
>   
>   return 0;
>  }

While at it, turn these into pr_err and use __FUNCTION__ or __func__

> +int nvram_write_error_log(char * buff, int length,
> +  unsigned int err_type, unsigned int error_log_cnt)
> +{
> + return nvram_write_os_partition(&rtas_log_partition, buff, length,
> + err_type, error_log_cnt);
> +}

That's a candidate for a static inline in a .h

>  /* nvram_read_error_log
>   *
>   * Reads nvram for error log for at most 'length'
> @@ -209,13 +229,13 @@ int nvram_read_error_log(char * buff, int length,
>   loff_t tmp_index;
>   struct err_log_info info;
>   
> - if (nvram_error_log_index == -1)
> + if (rtas_log_partition.index == -1)
>   return -1;
>  
> - if (length > nvram_error_log_size)
> - length = nvram_error_log_si

Re: [PATCH] powerpc: Fix call to flush_ptrace_hw_breakpoint()

2011-02-06 Thread K.Prasad
On Mon, Feb 07, 2011 at 02:10:39PM +1100, Benjamin Herrenschmidt wrote:
> On Mon, 2011-02-07 at 08:26 +0530, K.Prasad wrote:
> > On Mon, Feb 07, 2011 at 09:54:13AM +1100, Benjamin Herrenschmidt wrote:
> > > A typo in the #ifdef statement makes us never call it
> > > in flush_thread()
> > >
> > 
> > I wish it never compiled for such typos :-)
> > 
> >  
> > > Signed-off-by: Benjamin Herrenschmidt 
> > Acked-by: K.Prasad 
> 
> Interestingly, that 'fix' now breaks the build:
> 
> cc1: warnings being treated as errors
> /home/benh/linux-powerpc-test/arch/powerpc/kernel/process.c:356: error:
> 'set_debug_reg_defaults' defined but not used 
> 
> This file is is becoming an absolute mess of ifdef's in large part due
> to the new BookE debug stuff and your HW breakpoint stuff... Any chance
> you and Shaggy see if you can improve that situation a bit ?
> 
> Cheers,
> Ben.
> 
> 

Okay! Another wrapper of "#ifndef CONFIG_HAVE_HW_BREAKPOINT" around the
definition of 'set_debug_reg_defaults'.

There's indeed too much sprinkling of #ifdefs in the code, but most of
it would go away when the BookE code also uses the generic hw-breakpoint
interfaces. Given the advanced debug features that BookE supports, it's
unfortunately not that straight-forward (needs additions to generic
hw-breakpoint infrastructure).

Thanks,
K.Prasad

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


Re: [PATCH 5/6] nvram: Slim down zlib_deflate workspace when possible

2011-02-06 Thread Benjamin Herrenschmidt
On Sat, 2010-11-13 at 20:15 -0800, Jim Keniston wrote:
> Instead of always creating a huge (268K) deflate_workspace with the
> maximum compression parameters (windowBits=15, memLevel=8), allow the
> caller to obtain a smaller workspace (24K in our case) by specifying
> smaller parameter values -- via zlib_deflate_workspacesize2(). In our
> case, a small workspace is a win because our choices are to allocate
> the workspace when we need it (i.e., during an oops or panic) or
> allocate it at boot time.  (We do the latter.)
> 
> Signed-off-by: Jim Keniston 
> ---

Can you submit that to lkml please ? CC Linus and Andrew (or send to
Andrew/Linus and CC lkml). This change shouldn't go via the powerpc tree
since it changes the generic zlib code.

I'm dropping 5/6 and 6/6 for now... still reviewing the rest.

Cheers,
Ben.

>  include/linux/zlib.h|   14 --
>  lib/zlib_deflate/deflate.c  |   33 -
>  lib/zlib_deflate/deflate_syms.c |1 +
>  lib/zlib_deflate/defutil.h  |   17 +
>  4 files changed, 58 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/zlib.h b/include/linux/zlib.h
> index 40c49cb..3f15036 100644
> --- a/include/linux/zlib.h
> +++ b/include/linux/zlib.h
> @@ -179,11 +179,21 @@ typedef z_stream *z_streamp;
>  
>  /* basic functions */
>  
> +extern int zlib_deflate_workspacesize2 (int windowBits, int memLevel);
> +/*
> +   Returns the number of bytes that needs to be allocated for a per-
> +   stream workspace with the specified parameters.  A pointer to this
> +   number of bytes should be returned in stream->workspace before
> +   calling zlib_deflateInit2(); and the windowBits and memLevel
> +   parameters passed to zlib_deflateInit2() must not exceed those
> +   passed here.
> +*/
> +
>  extern int zlib_deflate_workspacesize (void);
>  /*
> Returns the number of bytes that needs to be allocated for a per-
> -   stream workspace.  A pointer to this number of bytes should be
> -   returned in stream->workspace before calling zlib_deflateInit().
> +   stream workspace with the default (large) windowBits and memLevel
> +   parameters.
>  */
>  
>  /* 
> diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c
> index 46a31e5..cdb207a 100644
> --- a/lib/zlib_deflate/deflate.c
> +++ b/lib/zlib_deflate/deflate.c
> @@ -176,6 +176,7 @@ int zlib_deflateInit2(
>  deflate_state *s;
>  int noheader = 0;
>  deflate_workspace *mem;
> +char *next;
>  
>  ush *overlay;
>  /* We overlay pending_buf and d_buf+l_buf. This works since the average
> @@ -199,6 +200,21 @@ int zlib_deflateInit2(
>   strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
>  return Z_STREAM_ERROR;
>  }
> +
> +/*
> + * Direct the workspace's pointers to the chunks that were allocated
> + * along with the deflate_workspace struct.
> + */
> +next = (char *) mem;
> +next += sizeof(*mem);
> +mem->window_memory = (Byte *) next;
> +next += zlib_deflate_window_memsize(windowBits);
> +mem->prev_memory = (Pos *) next;
> +next += zlib_deflate_prev_memsize(windowBits);
> +mem->head_memory = (Pos *) next;
> +next += zlib_deflate_head_memsize(memLevel);
> +mem->overlay_memory = next;
> +
>  s = (deflate_state *) &(mem->deflate_memory);
>  strm->state = (struct internal_state *)s;
>  s->strm = strm;
> @@ -1249,5 +1265,20 @@ static block_state deflate_slow(
>  
>  int zlib_deflate_workspacesize(void)
>  {
> -return sizeof(deflate_workspace);
> +return zlib_deflate_workspacesize2(MAX_WBITS, MAX_MEM_LEVEL);
> +}
> +
> +int zlib_deflate_workspacesize2(int windowBits, int memLevel)
> +{
> +if (windowBits < 0) /* undocumented feature: suppress zlib header */
> +windowBits = -windowBits;
> +if (memLevel < 1 || memLevel > MAX_MEM_LEVEL ||
> +windowBits < 9 || windowBits > 15)
> +return -1;
> +
> +return sizeof(deflate_workspace)
> ++ zlib_deflate_window_memsize(windowBits)
> ++ zlib_deflate_prev_memsize(windowBits)
> ++ zlib_deflate_head_memsize(memLevel)
> ++ zlib_deflate_overlay_memsize(memLevel);
>  }
> diff --git a/lib/zlib_deflate/deflate_syms.c b/lib/zlib_deflate/deflate_syms.c
> index ccfe25f..cdf1cdd 100644
> --- a/lib/zlib_deflate/deflate_syms.c
> +++ b/lib/zlib_deflate/deflate_syms.c
> @@ -11,6 +11,7 @@
>  #include 
>  
>  EXPORT_SYMBOL(zlib_deflate_workspacesize);
> +EXPORT_SYMBOL(zlib_deflate_workspacesize2);
>  EXPORT_SYMBOL(zlib_deflate);
>  EXPORT_SYMBOL(zlib_deflateInit2);
>  EXPORT_SYMBOL(zlib_deflateEnd);
> diff --git a/lib/zlib_deflate/defutil.h b/lib/zlib_deflate/defutil.h
> index 6b15a90..b640b64 100644
> --- a/lib/zlib_deflate/defutil.h
> +++ b/lib/zlib_deflate/defutil.h
> @@ -241,12 +241,21 @@ typedef struct deflate_state {
>  typedef struct deflate_workspace {
>  /* State memory for the deflator */
>  deflate_state deflate_memory;
> - 

Re: [PATCH] sched: provide scheduler_ipi() callback in response to smp_send_reschedule()

2011-02-06 Thread Benjamin Herrenschmidt
On Mon, 2011-01-17 at 12:07 +0100, Peter Zijlstra wrote:
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 68034bb..7ee0fc3 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -128,6 +128,7 @@ static irqreturn_t call_function_action(int irq, void 
> *data)
>  static irqreturn_t reschedule_action(int irq, void *data)
>  {
> /* we just need the return path side effect of checking need_resched 
> */
> +   scheduler_ipi();
> return IRQ_HANDLED;
>  }
>   

You missed:

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 9813605..467d122 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -98,6 +98,7 @@ void smp_message_recv(int msg)
break;
case PPC_MSG_RESCHEDULE:
/* we notice need_resched on exit */
+   scheduler_ipi();
break;
case PPC_MSG_CALL_FUNC_SINGLE:
generic_smp_call_function_single_interrupt();

Fold that in and add:

Acked-by: Benjamin Herrenschmidt 

(We have two variants of the IPIs)

Cheers,
Ben.


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


[PATCH] powerpc/pseries: Reduce HVCS driver insanity

2011-02-06 Thread Benjamin Herrenschmidt
The HVCS driver, for those who don't know, is a driver for the "server" side
of the IBM virtual terminal mechanism allowing Linux partitions to act as
terminal servers under IBM PowerVM hypervisor. It's almost never used on
the field at the moment.

However, it's part of our configs, and in its current incarnation, will
allocate the tty driver & major (with 64 minors) and create a kernel thread
whether it's used or not, ie, whether the hypervisor did put a virtual
terminal server device node in the partition or not (or whether running on
a pseries machine or not even).

This in turns causes modern distro's udev's to start trying to open all
those 64 minors at boot, which, since they aren't linked to anything,
causes the driver to spew errors in the kernel log for each of them.

Not nice.

This moves all that initialization to a function which is now only called
the first time a terminal server virtual IO device is actually probed
(that is almost never).

There's still a _LOT_ of cleanup that can be done in this driver, some
simple (almost all printk's statements in there shall either just be
removed or in some case turned into better written & more informative
messages, including using the dev_* variants etc...). This is left as
an exercise for whoever actually cares about that driver.

One could also try to be smart and dispose of all the tty related
resources when the last instance of the VIO server device
is removed (Hotplug anybody ?).

Signed-off-by: Benjamin Herrenschmidt 
---

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index bedc6c1..7e315b7 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -309,6 +309,7 @@ struct hvcs_struct {
 
 static LIST_HEAD(hvcs_structs);
 static DEFINE_SPINLOCK(hvcs_structs_lock);
+static DEFINE_MUTEX(hvcs_init_mutex);
 
 static void hvcs_unthrottle(struct tty_struct *tty);
 static void hvcs_throttle(struct tty_struct *tty);
@@ -340,6 +341,7 @@ static int __devinit hvcs_probe(struct vio_dev *dev,
 static int __devexit hvcs_remove(struct vio_dev *dev);
 static int __init hvcs_module_init(void);
 static void __exit hvcs_module_exit(void);
+static int __devinit hvcs_initialize(void);
 
 #define HVCS_SCHED_READ0x0001
 #define HVCS_QUICK_READ0x0002
@@ -762,7 +764,7 @@ static int __devinit hvcs_probe(
const struct vio_device_id *id)
 {
struct hvcs_struct *hvcsd;
-   int index;
+   int index, rc;
int retval;
 
if (!dev || !id) {
@@ -770,6 +772,13 @@ static int __devinit hvcs_probe(
return -EPERM;
}
 
+   /* Make sure we are properly initialized */
+   rc = hvcs_initialize();
+   if (rc) {
+   pr_err("HVCS: Failed to initialize core driver.\n");
+   return rc;
+   }
+
/* early to avoid cleanup on failure */
index = hvcs_get_index();
if (index < 0) {
@@ -1464,12 +1473,15 @@ static void hvcs_free_index_list(void)
hvcs_index_count = 0;
 }
 
-static int __init hvcs_module_init(void)
+static int __devinit hvcs_initialize(void)
 {
-   int rc;
-   int num_ttys_to_alloc;
+   int rc, num_ttys_to_alloc;
 
-   printk(KERN_INFO "Initializing %s\n", hvcs_driver_string);
+   mutex_lock(&hvcs_init_mutex);
+   if (hvcs_task) {
+   mutex_unlock(&hvcs_init_mutex);
+   return 0;
+   }
 
/* Has the user specified an overload with an insmod param? */
if (hvcs_parm_num_devs <= 0 ||
@@ -1528,35 +1540,13 @@ static int __init hvcs_module_init(void)
 
hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
if (IS_ERR(hvcs_task)) {
-   printk(KERN_ERR "HVCS: khvcsd creation failed.  Driver not 
loaded.\n");
+   printk(KERN_ERR "HVCS: khvcsd creation failed.\n");
rc = -EIO;
goto kthread_fail;
}
-
-   rc = vio_register_driver(&hvcs_vio_driver);
-   if (rc) {
-   printk(KERN_ERR "HVCS: can't register vio driver\n");
-   goto vio_fail;
-   }
-
-   /*
-* This needs to be done AFTER the vio_register_driver() call or else
-* the kobjects won't be initialized properly.
-*/
-   rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan);
-   if (rc) {
-   printk(KERN_ERR "HVCS: sysfs attr create failed\n");
-   goto attr_fail;
-   }
-
-   printk(KERN_INFO "HVCS: driver module inserted.\n");
-
+   mutex_unlock(&hvcs_init_mutex);
return 0;
 
-attr_fail:
-   vio_unregister_driver(&hvcs_vio_driver);
-vio_fail:
-   kthread_stop(hvcs_task);
 kthread_fail:
kfree(hvcs_pi_buff);
 buff_alloc_fail:
@@ -1566,15 +1556,39 @@ register_fail:
 index_fail:
put_tty_driver(hvcs_tty_driver);
hvcs_tty_driver = NULL;
+   mutex_unlock(&hvcs_init_mutex);
return rc;
 }
 
+static int __init hvcs_module_init(void)
+{
+   int rc = vio_register

[git pull] Please pull powerpc.git merge branch

2011-02-06 Thread Benjamin Herrenschmidt
Hi Linus !

Here are a few powerpc bug fixes for you. Mostly Anton and Jesse fixing
up the new VPNH feature (which was added this cycle) and a handful of
other fixes worth having.

Cheers,
Ben.

The following changes since commit 8dbdea8444d303a772bceb1ba963f0e3273bfc5e:

  Merge branch 'ixp4xx' of 
git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6 (2011-02-06 
12:05:58 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git merge

Anton Blanchard (6):
  powerpc/numa: Only use active VPHN count fields
  powerpc/numa: Check for all VPHN changes
  powerpc/numa: Add length when creating OF properties via VPHN
  powerpc/numa: Disable VPHN on dedicated processor partitions
  powerpc/numa: Fix bug in unmap_cpu_from_node
  powerpc: Fix hcall tracepoint recursion

Benjamin Herrenschmidt (2):
  powerpc: Pass the right cpu_spec to ->setup_cpu() on 64-bit
  powerpc: Fix some 6xx/7xxx CPU setup functions

Jesse Larrew (3):
  powerpc/pseries: Fix typo in VPHN comments
  powerpc/pseries: Fix brace placement in numa.c
  powerpc/pseries: Remove unnecessary variable initializations in numa.c

Scott Wood (2):
  powerpc: Fix pfn_valid() when memory starts at a non-zero address
  powerpc/book3e: Protect complex macro args in mmu-book3e.h

 arch/powerpc/include/asm/mmu-book3e.h |8 ++--
 arch/powerpc/include/asm/page.h   |2 +-
 arch/powerpc/kernel/cpu_setup_6xx.S   |   40 
 arch/powerpc/kernel/cputable.c|4 +-
 arch/powerpc/mm/numa.c|   55 ++---
 arch/powerpc/platforms/pseries/lpar.c |   37 ++
 6 files changed, 94 insertions(+), 52 deletions(-)


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


Re: [PATCH] powerpc: Fix call to flush_ptrace_hw_breakpoint()

2011-02-06 Thread Benjamin Herrenschmidt
On Mon, 2011-02-07 at 08:26 +0530, K.Prasad wrote:
> On Mon, Feb 07, 2011 at 09:54:13AM +1100, Benjamin Herrenschmidt wrote:
> > A typo in the #ifdef statement makes us never call it
> > in flush_thread()
> >
> 
> I wish it never compiled for such typos :-)
> 
>  
> > Signed-off-by: Benjamin Herrenschmidt 
> Acked-by: K.Prasad 

Interestingly, that 'fix' now breaks the build:

cc1: warnings being treated as errors
/home/benh/linux-powerpc-test/arch/powerpc/kernel/process.c:356: error:
'set_debug_reg_defaults' defined but not used 

This file is is becoming an absolute mess of ifdef's in large part due
to the new BookE debug stuff and your HW breakpoint stuff... Any chance
you and Shaggy see if you can improve that situation a bit ?

Cheers,
Ben.


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


Re: [PATCH -mm 2/6] powerpc: convert little-endian bitops macros to static inline functions

2011-02-06 Thread Akinobu Mita
2011/2/7 Benjamin Herrenschmidt :
> On Thu, 2011-01-27 at 22:56 +0900, Akinobu Mita wrote:
>> (This patch is intended to be folded into the patch in -mm:
>> powerpc-introduce-little-endian-bitops.patch)
>>
>> The little-endian bitops on powerpc are written as preprocessor
>> macros with the cast to "unsigned long *".
>> This means that even non-pointers will be accepted without an error, and
>> that is a Very Bad Thing.
>>
>> This converts the little-endian bitops macros to static inline functions
>> with proper prototypes.
>
> No objection to the powerpc variant of the patches. What is the status
> with the wholes series tho ? Does it looks like its going to be
> accepted ? Do you expect my Ack and will merge the whole thing at once ?

The whole series now seems acceptable since I fixed two issues
that Linus found annoying. (the naming and the change of prototype)

Please give your ack if it is OK.

I should have fixed them quickly so that the series went upstream
in the last merge windows. But I couldn't because I spent some time
fixing and compile testing for a bisection hole.

> Does it break bisection unless it's merged as one single giant patch ?

I think there is no known problem that breaks bisectability by
this patch series.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: Fix call to flush_ptrace_hw_breakpoint()

2011-02-06 Thread K.Prasad
On Mon, Feb 07, 2011 at 09:54:13AM +1100, Benjamin Herrenschmidt wrote:
> A typo in the #ifdef statement makes us never call it
> in flush_thread()
>

I wish it never compiled for such typos :-)

 
> Signed-off-by: Benjamin Herrenschmidt 
Acked-by: K.Prasad 

> ---
> 
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index 7a1d5cb..c4e4eab 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -670,11 +670,11 @@ void flush_thread(void)
>  {
>   discard_lazy_cpu_state();
> 
> -#ifdef CONFIG_HAVE_HW_BREAKPOINTS
> +#ifdef CONFIG_HAVE_HW_BREAKPOINT
>   flush_ptrace_hw_breakpoint(current);
> -#else /* CONFIG_HAVE_HW_BREAKPOINTS */
> +#else /* CONFIG_HAVE_HW_BREAKPOINT */
>   set_debug_reg_defaults(¤t->thread);
> -#endif /* CONFIG_HAVE_HW_BREAKPOINTS */
> +#endif /* CONFIG_HAVE_HW_BREAKPOINT */
>  }
> 
>  void
> 
> 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 3/4]Define memory_block_size_bytes for powerpc/pseries

2011-02-06 Thread Greg KH
On Mon, Feb 07, 2011 at 10:39:23AM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2011-01-20 at 10:45 -0600, Nathan Fontenot wrote:
> > Define a version of memory_block_size_bytes() for powerpc/pseries such that
> > a memory block spans an entire lmb.
> > 
> > Signed-off-by: Nathan Fontenot 
> > Reviewed-by: Robin Holt 
> 
> Hi Nathan !
> 
> Is somebody from -mm picking the rest of the series ? This patch as well
> or shall I wait for the first two to go in and then pick that one in
> -powerpc ?

I took all of these in my tree already, is that ok?

thanks,

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


Re: [PATCH v3 1/4] powerpc: Removing support for 'protected-sources'

2011-02-06 Thread Benjamin Herrenschmidt
On Sun, 2011-02-06 at 19:32 -0600, Meador Inge wrote:
> So barring the removal of protected sources, does the inclusion of the
> "pic-no-reset" property seem reasonable? 

Sure.

Ben.


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


Re: [PATCH v3 1/4] powerpc: Removing support for 'protected-sources'

2011-02-06 Thread Meador Inge

On 02/06/2011 05:35 PM, Benjamin Herrenschmidt wrote:

On Fri, 2011-02-04 at 17:25 -0600, Meador Inge wrote:

In a recent thread [1,2,3] concerning device trees for AMP systems, the
question of whether we really need 'protected-sources' arose.  The general
consensus was that a new boolean property 'pic-no-reset' (described in more
detail in a following patch) could be expanded to cover the use cases that
'protected-sources' was covering.

One concern that was raised was for legacy systems which already use the
'protected-sources' property [4].  For legacy use cases, 'protected-sources'
will be treated as an alias of 'pic-no-reset'.  The sources
encoded in the 'protected-sources' cells, however, will not be processed.  This
legacy check is added in a later patch in the series.


I'm a bit annoyed here. Why do we need to do that ? Those Cell machines


Apologies, that certainly was not the intent.


are going to be real bastards to find and test with, and I don't really
see the point...


The idea came up when submitting a patch for documenting an Open PIC 
binding.  The following two properties were documented in that binding: 
(1) "protected-sources" and (2) "pic-no-reset".  "pic-no-reset" is a 
newly proposed property with the intent of specifying from a device tree 
that the PIC should not be reset.  The question of whether the one 
property, "pic-no-reset", would suffice for both purposes came up.


It seems reasonable that "pic-no-reset" could satisfy the use case that 
"protected-sources" is covering (since all of the sources that a 
particular machine is actually using are already explicitly mentioned in 
the device tree) and the use case of marking from a device tree that the 
PIC should not be reset.  So it is not so much as a need as it is a 
potential simplification.  It sounds like as a practical concern 
(several systems using "protected-sources" are already in the wild and 
testing considerations) that this may not be possible, which is fine.



The reason for not resetting the MPIC wasn't -only- about the protected
sources, but also because, from memory, some MPIC implementations had
issues when toggling the reset lines (pseries I think is one).

That's actually why the MPIC_WANTS_RESET flag is working the other way
around, only platforms that actually want the reset set it.

This is orthogonal to the need to touch or not touch the interrupt
sources as set by firmware. Yes, having protected sources probably
implies no-reset but the reverse isn't necessarily true.


So barring the removal of protected sources, does the inclusion of the 
"pic-no-reset" property seem reasonable?



Ben.


--
Meador Inge | meador_inge AT mentor.com
Mentor Embedded | http://www.mentor.com/embedded-software
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] watchdog: booke_wdt: clean up status messages

2011-02-06 Thread Benjamin Herrenschmidt
On Mon, 2011-01-17 at 15:29 -0600, Timur Tabi wrote:
> Improve the status messages that are displayed during some operations of the
> PowerPC watchdog timer driver.  When the watchdog is enabled, the timeout is
> displayed as a number of seconds, instead of an obscure "period".  The 
> "period"
> is the position of a bit in a 64-bit timer register.  The higher the value,
> the quicker the watchdog timeout occurs.  Some people chose a high "period"
> value for the timer and get confused as to why the board resets within a
> few seconds.
> 
> Messages displayed during open and close are now debug messages, so that they
> don't clutter the console by default.  Finally, printk() is replaced with the
> pr_xxx() equivalent.

Minor nit bu
>  
> - printk(KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
> + pr_info("PowerPC Book-E Watchdog Timer Loaded\n");
>   ident.firmware_version = cur_cpu_spec->pvr_value;
>  
>   ret = misc_register(&booke_wdt_miscdev);
>   if (ret) {
> - printk(KERN_CRIT "Cannot register miscdev on minor=%d: %d\n",
> - WATCHDOG_MINOR, ret);
> + pr_err("booke_wdt: cannot register device (minor=%u, ret=%i)\n",
> +WATCHDOG_MINOR, ret);
>   return ret;
>   }
>  
>   spin_lock(&booke_wdt_lock);
>   if (booke_wdt_enabled == 1) {
> - printk(KERN_INFO
> -   "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n",
> - booke_wdt_period);
> + pr_info("booke_wdt: watchdog enabled (timeout = %llu sec)\n",
> + period_to_sec(booke_wdt_period));
>   on_each_cpu(__booke_wdt_enable, NULL, 0);
>   }

If you're going to cleanup the messages, then I think displaying:

PowerPC Book-E Watchdog Timer Loaded
booke_wdt: watchdog enabled (timeout = xxx sec)

Isn't very nice.

Lacks consistency ... you can prefix both lines the same way, or
maybe better print only one line with all the necessary info.

Ben.


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


Re: [PATCH 1/2] video, sm501: add OF binding to support SM501

2011-02-06 Thread Benjamin Herrenschmidt
On Sat, 2010-12-04 at 09:23 +0100, Heiko Schocher wrote:
> - add binding to OF, compatible name "smi,sm501"
> 
> - add read/write functions for using this driver
>   also on powerpc plattforms

 .../...

Who plans to merge that patch series ? I'm happy for whoever is doing
that to take the powerpc patch at the end (that adds the entry to
the .dts file) with my

Acked-by: Benjamin Herrenschmidt 

Cheers,
Ben.


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


RE: [PATCH] e500: Erratum cpu a005 workaround

2011-02-06 Thread Benjamin Herrenschmidt

> > 
> > This isn't the way to do this.  We normally add entries in 
> > cputable.c an add a new cpu_feature_bit for the errata.
> > 
> > Than above we'd do:
> > 
> > if (cur_cpu_spec->cpu_features & CPU_FTR_E500_A005_ERRATUM)
> > 
> > 
> 
> IMHO, a cpu erratum is not a cpu feature.
> See there're only 32 bits can be used for all PowerPC platform to represent 
> cpu feature, 
> then is it worth consuming one of them to represent one e500 erratum?

This is an interesting debate :-)

We have used cpu_features for errata in the past. However, we are
getting a bit short and I'd rather keep CPU features for things
that are spread out in multiple places and/or hitting hot code path.

If the workaround is very limited to a single non-critical code path,
testing the PVR might actually be a nicer way to do it.

Now, this specific patch is ... hrm ... hard to decide. I don't like
that much the global variable. On the other hand, it's static and allows
the whole business of this errata to be completely local to the
math_efp.c file which is a good thing.

So I'm tempted to say go with the patch as it-is, but I'll let Kumar
ultimately decide.

Cheers,
Ben.


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


[PATCH 21/23] hvc_console: Fix race between hvc_close and hvc_remove

2011-02-06 Thread Willy Tarreau
2.6.27.58-stable review patch.  If anyone has any objections, please let us 
know.

--

From: Amit Shah 

commit e74d098c66543d0731de62eb747ccd5b636a6f4c upstream.

Alan pointed out a race in the code where hvc_remove is invoked. The
recent virtio_console work is the first user of hvc_remove().

Alan describes it thus:

The hvc_console assumes that a close and remove call can't occur at the
same time.

In addition tty_hangup(tty) is problematic as tty_hangup is asynchronous
itself

So this can happen

hvc_close   hvc_remove
hung up ? - no
lock
tty = hp->tty
unlock
lock
hp->tty = NULL
unlock
notify del
kref_put the hvc struct
close completes
tty is destroyed
tty_hangup dead tty
tty->ops will be NULL
NULL->...

This patch adds some tty krefs and also converts to using tty_vhangup().

Reported-by: Alan Cox 
Signed-off-by: Amit Shah 
CC: Alan Cox 
CC: linuxppc-...@ozlabs.org
CC: Rusty Russell 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Willy Tarreau 

---
 drivers/char/hvc_console.c |   31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

Index: longterm-2.6.27/drivers/char/hvc_console.c
===
--- longterm-2.6.27.orig/drivers/char/hvc_console.c 2011-01-23 
10:52:15.0 +0100
+++ longterm-2.6.27/drivers/char/hvc_console.c  2011-01-29 15:33:05.169065818 
+0100
@@ -312,6 +312,7 @@
spin_lock_irqsave(&hp->lock, flags);
/* Check and then increment for fast path open. */
if (hp->count++ > 0) {
+   tty_kref_get(tty);
spin_unlock_irqrestore(&hp->lock, flags);
hvc_kick();
return 0;
@@ -320,7 +321,7 @@
tty->driver_data = hp;
tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
 
-   hp->tty = tty;
+   hp->tty = tty_kref_get(tty);
 
spin_unlock_irqrestore(&hp->lock, flags);
 
@@ -337,6 +338,7 @@
spin_lock_irqsave(&hp->lock, flags);
hp->tty = NULL;
spin_unlock_irqrestore(&hp->lock, flags);
+   tty_kref_put(tty);
tty->driver_data = NULL;
kref_put(&hp->kref, destroy_hvc_struct);
printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", 
rc);
@@ -364,13 +366,18 @@
return;
 
hp = tty->driver_data;
+
spin_lock_irqsave(&hp->lock, flags);
+   tty_kref_get(tty);
 
if (--hp->count == 0) {
/* We are done with the tty pointer now. */
hp->tty = NULL;
spin_unlock_irqrestore(&hp->lock, flags);
 
+   /* Put the ref obtained in hvc_open() */
+   tty_kref_put(tty);
+
if (hp->ops->notifier_del)
hp->ops->notifier_del(hp, hp->data);
 
@@ -387,6 +394,7 @@
spin_unlock_irqrestore(&hp->lock, flags);
}
 
+   tty_kref_put(tty);
kref_put(&hp->kref, destroy_hvc_struct);
 }
 
@@ -423,6 +431,7 @@
 
while(temp_open_count) {
--temp_open_count;
+   tty_kref_put(tty);
kref_put(&hp->kref, destroy_hvc_struct);
}
 }
@@ -550,7 +559,7 @@
poll_mask |= HVC_POLL_WRITE;
 
/* No tty attached, just skip */
-   tty = hp->tty;
+   tty = tty_kref_get(hp->tty);
if (tty == NULL)
goto bail;
 
@@ -627,6 +636,8 @@
 
tty_flip_buffer_push(tty);
}
+   if (tty)
+   tty_kref_put(tty);
 
return poll_mask;
 }
@@ -749,7 +760,7 @@
struct tty_struct *tty;
 
spin_lock_irqsave(&hp->lock, flags);
-   tty = hp->tty;
+   tty = tty_kref_get(hp->tty);
 
if (hp->index < MAX_NR_HVC_CONSOLES)
vtermnos[hp->index] = -1;
@@ -761,18 +772,18 @@
/*
 * We 'put' the instance that was grabbed when the kref instance
 * was initialized using kref_init().  Let the last holder of this
-* kref cause it to be removed, which will probably be the tty_hangup
+* kref cause it to be removed, which will probably be the tty_vhangup
 * below.
 */
kref_put(&hp->kref, destroy_hvc_struct);
 
/*
-* This function call will auto chain call hvc_hangup.  The tty should
-* always be valid at this time unless a simultaneous tty close already
-* cleaned up the hvc_struct.
+* This function call will auto chain call hvc_hangup.
 */
-   if (tty)
-   tty_hangup(tty

Re: [PATCH 3/4]Define memory_block_size_bytes for powerpc/pseries

2011-02-06 Thread Benjamin Herrenschmidt
On Thu, 2011-01-20 at 10:45 -0600, Nathan Fontenot wrote:
> Define a version of memory_block_size_bytes() for powerpc/pseries such that
> a memory block spans an entire lmb.
> 
> Signed-off-by: Nathan Fontenot 
> Reviewed-by: Robin Holt 

Hi Nathan !

Is somebody from -mm picking the rest of the series ? This patch as well
or shall I wait for the first two to go in and then pick that one in
-powerpc ?

Cheers,
Ben.

> ---
>  arch/powerpc/platforms/pseries/hotplug-memory.c |   66 
> +++-
>  1 file changed, 53 insertions(+), 13 deletions(-)
> 
> Index: linux-2.6/arch/powerpc/platforms/pseries/hotplug-memory.c
> ===
> --- linux-2.6.orig/arch/powerpc/platforms/pseries/hotplug-memory.c
> 2011-01-20 08:18:21.0 -0600
> +++ linux-2.6/arch/powerpc/platforms/pseries/hotplug-memory.c 2011-01-20 
> 08:21:07.0 -0600
> @@ -17,6 +17,54 @@
>  #include 
>  #include 
>  
> +static unsigned long get_memblock_size(void)
> +{
> + struct device_node *np;
> + unsigned int memblock_size = 0;
> +
> + np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
> + if (np) {
> + const unsigned long *size;
> +
> + size = of_get_property(np, "ibm,lmb-size", NULL);
> + memblock_size = size ? *size : 0;
> +
> + of_node_put(np);
> + } else {
> + unsigned int memzero_size = 0;
> + const unsigned int *regs;
> +
> + np = of_find_node_by_path("/memory@0");
> + if (np) {
> + regs = of_get_property(np, "reg", NULL);
> + memzero_size = regs ? regs[3] : 0;
> + of_node_put(np);
> + }
> +
> + if (memzero_size) {
> + /* We now know the size of memory@0, use this to find
> +  * the first memoryblock and get its size.
> +  */
> + char buf[64];
> +
> + sprintf(buf, "/memory@%x", memzero_size);
> + np = of_find_node_by_path(buf);
> + if (np) {
> + regs = of_get_property(np, "reg", NULL);
> + memblock_size = regs ? regs[3] : 0;
> + of_node_put(np);
> + }
> + }
> + }
> +
> + return memblock_size;
> +}
> +
> +unsigned long memory_block_size_bytes(void)
> +{
> + return get_memblock_size();
> +}
> +
>  static int pseries_remove_memblock(unsigned long base, unsigned int 
> memblock_size)
>  {
>   unsigned long start, start_pfn;
> @@ -127,30 +175,22 @@ static int pseries_add_memory(struct dev
>  
>  static int pseries_drconf_memory(unsigned long *base, unsigned int action)
>  {
> - struct device_node *np;
> - const unsigned long *lmb_size;
> + unsigned long memblock_size;
>   int rc;
>  
> - np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
> - if (!np)
> + memblock_size = get_memblock_size();
> + if (!memblock_size)
>   return -EINVAL;
>  
> - lmb_size = of_get_property(np, "ibm,lmb-size", NULL);
> - if (!lmb_size) {
> - of_node_put(np);
> - return -EINVAL;
> - }
> -
>   if (action == PSERIES_DRCONF_MEM_ADD) {
> - rc = memblock_add(*base, *lmb_size);
> + rc = memblock_add(*base, memblock_size);
>   rc = (rc < 0) ? -EINVAL : 0;
>   } else if (action == PSERIES_DRCONF_MEM_REMOVE) {
> - rc = pseries_remove_memblock(*base, *lmb_size);
> + rc = pseries_remove_memblock(*base, memblock_size);
>   } else {
>   rc = -EINVAL;
>   }
>  
> - of_node_put(np);
>   return rc;
>  }
>  
> 
> ___
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


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


Re: [PATCH v3 1/4] powerpc: Removing support for 'protected-sources'

2011-02-06 Thread Benjamin Herrenschmidt
On Fri, 2011-02-04 at 17:25 -0600, Meador Inge wrote:
> In a recent thread [1,2,3] concerning device trees for AMP systems, the
> question of whether we really need 'protected-sources' arose.  The general
> consensus was that a new boolean property 'pic-no-reset' (described in more
> detail in a following patch) could be expanded to cover the use cases that
> 'protected-sources' was covering.
> 
> One concern that was raised was for legacy systems which already use the
> 'protected-sources' property [4].  For legacy use cases, 'protected-sources'
> will be treated as an alias of 'pic-no-reset'.  The sources
> encoded in the 'protected-sources' cells, however, will not be processed.  
> This
> legacy check is added in a later patch in the series.

I'm a bit annoyed here. Why do we need to do that ? Those Cell machines
are going to be real bastards to find and test with, and I don't really
see the point...

The reason for not resetting the MPIC wasn't -only- about the protected
sources, but also because, from memory, some MPIC implementations had
issues when toggling the reset lines (pseries I think is one).

That's actually why the MPIC_WANTS_RESET flag is working the other way
around, only platforms that actually want the reset set it.

This is orthogonal to the need to touch or not touch the interrupt
sources as set by firmware. Yes, having protected sources probably
implies no-reset but the reverse isn't necessarily true.

Ben.
 
> [1] 
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-January/004038.html
> [2] 
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-January/003991.html
> [3] 
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-January/004043.html
> [4] 
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-February/004254.html
> 
> Signed-off-by: Meador Inge 
> Cc: Hollis Blanchard 
> Cc: Benjamin Herrenschmidt 
> ---
>  arch/powerpc/include/asm/mpic.h |3 ---
>  arch/powerpc/sysdev/mpic.c  |   38 --
>  2 files changed, 0 insertions(+), 41 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
> index e000cce..9b94f18 100644
> --- a/arch/powerpc/include/asm/mpic.h
> +++ b/arch/powerpc/include/asm/mpic.h
> @@ -301,9 +301,6 @@ struct mpic
>   struct mpic_reg_bankcpuregs[MPIC_MAX_CPUS];
>   struct mpic_reg_bankisus[MPIC_MAX_ISU];
>  
> - /* Protected sources */
> - unsigned long   *protected;
> -
>  #ifdef CONFIG_MPIC_WEIRD
>   /* Pointer to HW info array */
>   u32 *hw_set;
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 7c13426..a98f41d 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -947,8 +947,6 @@ static int mpic_host_map(struct irq_host *h, unsigned int 
> virq,
>  
>   if (hw == mpic->spurious_vec)
>   return -EINVAL;
> - if (mpic->protected && test_bit(hw, mpic->protected))
> - return -EINVAL;
>  
>  #ifdef CONFIG_SMP
>   else if (hw >= mpic->ipi_vecs[0]) {
> @@ -1095,26 +1093,6 @@ struct mpic * __init mpic_alloc(struct device_node 
> *node,
>   if (node && of_get_property(node, "big-endian", NULL) != NULL)
>   mpic->flags |= MPIC_BIG_ENDIAN;
>  
> - /* Look for protected sources */
> - if (node) {
> - int psize;
> - unsigned int bits, mapsize;
> - const u32 *psrc =
> - of_get_property(node, "protected-sources", &psize);
> - if (psrc) {
> - psize /= 4;
> - bits = intvec_top + 1;
> - mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long);
> - mpic->protected = kzalloc(mapsize, GFP_KERNEL);
> - BUG_ON(mpic->protected == NULL);
> - for (i = 0; i < psize; i++) {
> - if (psrc[i] > intvec_top)
> - continue;
> - __set_bit(psrc[i], mpic->protected);
> - }
> - }
> - }
> -
>  #ifdef CONFIG_MPIC_WEIRD
>   mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)];
>  #endif
> @@ -1321,9 +1299,6 @@ void __init mpic_init(struct mpic *mpic)
>   u32 vecpri = MPIC_VECPRI_MASK | i |
>   (8 << MPIC_VECPRI_PRIORITY_SHIFT);
>   
> - /* check if protected */
> - if (mpic->protected && test_bit(i, mpic->protected))
> - continue;
>   /* init hw */
>   mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
>   mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu);
> @@ -1492,13 +1467,6 @@ static unsigned int _mpic_get_one_irq(struct mpic 
> *mpic, int reg)
>   mpic_eoi(mpic);
>   return NO_IRQ;
>   }
> - if (unlikely(mpic->protected && test_bit(sr

Re: [PATCH -mm 2/6] powerpc: convert little-endian bitops macros to static inline functions

2011-02-06 Thread Benjamin Herrenschmidt
On Thu, 2011-01-27 at 22:56 +0900, Akinobu Mita wrote:
> (This patch is intended to be folded into the patch in -mm:
> powerpc-introduce-little-endian-bitops.patch)
> 
> The little-endian bitops on powerpc are written as preprocessor
> macros with the cast to "unsigned long *".
> This means that even non-pointers will be accepted without an error, and
> that is a Very Bad Thing.
> 
> This converts the little-endian bitops macros to static inline functions
> with proper prototypes.

No objection to the powerpc variant of the patches. What is the status
with the wholes series tho ? Does it looks like its going to be
accepted ? Do you expect my Ack and will merge the whole thing at once ?
Does it break bisection unless it's merged as one single giant patch ?

Cheers,
Ben.

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


[PATCH] powerpc: Fix call to flush_ptrace_hw_breakpoint()

2011-02-06 Thread Benjamin Herrenschmidt
A typo in the #ifdef statement makes us never call it
in flush_thread()

Signed-off-by: Benjamin Herrenschmidt 
---

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 7a1d5cb..c4e4eab 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -670,11 +670,11 @@ void flush_thread(void)
 {
discard_lazy_cpu_state();
 
-#ifdef CONFIG_HAVE_HW_BREAKPOINTS
+#ifdef CONFIG_HAVE_HW_BREAKPOINT
flush_ptrace_hw_breakpoint(current);
-#else /* CONFIG_HAVE_HW_BREAKPOINTS */
+#else /* CONFIG_HAVE_HW_BREAKPOINT */
set_debug_reg_defaults(¤t->thread);
-#endif /* CONFIG_HAVE_HW_BREAKPOINTS */
+#endif /* CONFIG_HAVE_HW_BREAKPOINT */
 }
 
 void


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