Re: [patch V3 03/20] usb: gadget: Use completion interface instead of open coding it

2020-03-27 Thread Sebastian Siewior
On 2020-03-25 10:37:57 [+0200], Felipe Balbi wrote:
> Do you want to carry it via your tree? If so:

We would like to do so.

> Acked-by: Felipe Balbi 

Thank you.

> Otherwise, let me know and I'll pick this patch.

Sebastian


Re: Documentation/locking/locktypes: Further clarifications and wordsmithing

2020-03-25 Thread Sebastian Siewior
On 2020-03-25 09:39:19 [-0700], Paul E. McKenney wrote:
> > > --- a/Documentation/locking/locktypes.rst
> > > +++ b/Documentation/locking/locktypes.rst
> > …
> > > +rw_semaphore
> > > +
> > > +
> > > +rw_semaphore is a multiple readers and single writer lock mechanism.
> > > +
> > > +On non-PREEMPT_RT kernels the implementation is fair, thus preventing
> > > +writer starvation.
> > > +
> > > +rw_semaphore complies by default with the strict owner semantics, but 
> > > there
> > > +exist special-purpose interfaces that allow non-owner release for 
> > > readers.
> > > +These work independent of the kernel configuration.
> > 
> > This reads funny, could be my English. "This works independent …" maybe?
> 
> The "These" refers to "interfaces", which is plural, so "These" rather
> than "This".  But yes, it is a bit awkward, because you have to skip
> back past "readers", "release", and "non-owner" to find the implied
> subject of that last sentence.
> 
> So how about this instead, making the implied subject explicit?
> 
> rw_semaphore complies by default with the strict owner semantics, but there
> exist special-purpose interfaces that allow non-owner release for readers.
> These interfaces work independent of the kernel configuration.

Yes, perfect. Thank you.

>   Thanx, Paul

Sebastian


Re: Documentation/locking/locktypes: Further clarifications and wordsmithing

2020-03-25 Thread Sebastian Siewior
On 2020-03-25 13:27:49 [+0100], Thomas Gleixner wrote:
> The documentation of rw_semaphores is wrong as it claims that the non-owner
> reader release is not supported by RT. That's just history biased memory
> distortion.
> 
> Split the 'Owner semantics' section up and add separate sections for
> semaphore and rw_semaphore to reflect reality.
> 
> Aside of that the following updates are done:
> 
>  - Add pseudo code to document the spinlock state preserving mechanism on
>PREEMPT_RT
> 
>  - Wordsmith the bitspinlock and lock nesting sections
> 
> Co-developed-by: Paul McKenney 
> Signed-off-by: Paul McKenney 
> Signed-off-by: Thomas Gleixner 
Acked-by: Sebastian Andrzej Siewior 

> --- a/Documentation/locking/locktypes.rst
> +++ b/Documentation/locking/locktypes.rst
…
> +rw_semaphore
> +
> +
> +rw_semaphore is a multiple readers and single writer lock mechanism.
> +
> +On non-PREEMPT_RT kernels the implementation is fair, thus preventing
> +writer starvation.
> +
> +rw_semaphore complies by default with the strict owner semantics, but there
> +exist special-purpose interfaces that allow non-owner release for readers.
> +These work independent of the kernel configuration.

This reads funny, could be my English. "This works independent …" maybe?

Sebastian


[PATCH] completion: Use lockdep_assert_RT_in_threaded_ctx() in complete_all()

2020-03-23 Thread Sebastian Siewior
The warning was intended to spot complete_all() users from hardirq
context on PREEMPT_RT. The warning as-is will also trigger in interrupt
handlers, which are threaded on PREEMPT_RT, which was not intended.

Use lockdep_assert_RT_in_threaded_ctx() which triggers in non-preemptive
context on PREEMPT_RT.

Suggested-by: Peter Zijlstra 
Reported-by: kernel test robot 
Signed-off-by: Sebastian Andrzej Siewior 
---
 include/linux/lockdep.h   | 15 +++
 kernel/sched/completion.c |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 425b4ceb7cd07..206774ac69460 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -711,6 +711,21 @@ do {   
\
 # define lockdep_assert_in_irq() do { } while (0)
 #endif
 
+#ifdef CONFIG_PROVE_RAW_LOCK_NESTING
+
+# define lockdep_assert_RT_in_threaded_ctx() do {  \
+   WARN_ONCE(debug_locks && !current->lockdep_recursion && \
+ current->hardirq_context &&   \
+ !(current->hardirq_threaded || current->irq_config),  
\
+ "Not in threaded context on PREEMPT_RT as 
expected\n");   \
+} while (0)
+
+#else
+
+# define lockdep_assert_RT_in_threaded_ctx() do { } while (0)
+
+#endif
+
 #ifdef CONFIG_LOCKDEP
 void lockdep_rcu_suspicious(const char *file, const int line, const char *s);
 #else
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index f15e96164ff1e..a778554f9dad7 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -58,7 +58,7 @@ void complete_all(struct completion *x)
 {
unsigned long flags;
 
-   WARN_ON(irqs_disabled());
+   lockdep_assert_RT_in_threaded_ctx();
 
raw_spin_lock_irqsave(>wait.lock, flags);
x->done = UINT_MAX;
-- 
2.26.0.rc2



Re: [PATCH] powerpc: dtb and purgatory support for ppc32

2008-10-02 Thread Sebastian Siewior

Kumar Gala wrote:


are you trying to get this accepted?


If the reviewer don't have any objections yes. You sound
like there is something terrible wrong. Do you want it in smaller pieces?


- k

Sebastian
--
Firmensitz: 88690 Uhldingen, Auf dem Berg 3
Registergericht: Amtsgericht Freiburg i. Br., HRB 700 806;
StNr. 87007/0; Ust-Id Nr.: DE252739476
Geschäftsführer: Heinz Egger, Thomas Gleixner
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC] powerpc/boot: add kernel,end node to the cuboot target

2008-09-30 Thread Sebastian Siewior

Milton Miller wrote:


|load: entry = 0x80053c flags = 0
|nr_segments = 2
|segment[0].buf   = 0x1002b8f0
|segment[0].bufsz = 80
|segment[0].mem   = (nil)
|segment[0].memsz = 1000
|segment[1].buf   = 0x4803f008
|segment[1].bufsz = 3a3138
|segment[1].mem   = 0x80
|segment[1].memsz = 3b


I would expect a third segment (kernel/zImage, dtb, and purgatory), but 
its not clear that you are getting that far yet.


segment 0 looks like a small segment which should create boot loader 
environment. That one does nothing.

Segment 1 is my cuImage. What is purgatory?


Now. The entry address in image-start is valid and is the entrypoint of
the custom cuImage. Custom means that it does not depend any register
values passed from u-boot (the original one needs a pointer to bd_t).
The only requirement is a valid 1:1 memory mapping.


ok sounds good.  does this have the dtb in it too?

Yes it does.


The branch above is taken, so I've found my current mapping


ok, but should you not be using PID0 explictly to say global only?
The kernel mapping should only be global and therefore that might be a 
good idea.


obviously, a jtag or similar hardware debugger would be best.  Second 
I have here CodeWarrior usb tap but after more than one hour playing with 
that thing I started to hack assembly char put. It helper more :) kexec 
seems to work now :) I get nobody cared irq X from time to time so I 
thing I have to fix here something.


As a final note, it looks like you are currently replacing the code in 
relocate_new_kernel with book-e code.  Obviously this will need 
refinement to select or move to heat_xx to merge.
Yep, this is next what is going to happen. I would prefer to have them 
runtime switchable instead of build depend.


Again, I don't have any direct experience, but mauybe this gives you 
some ideas.

Your hints helped. Thx for that.


milton

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


Re: [RFC] powerpc/boot: add kernel,end node to the cuboot target

2008-09-29 Thread Sebastian Siewior
* Milton Miller | 2008-09-23 20:24:02 [-0500]:

If you have any questions about kdump or what needs to happen,
please feel free to contact me either by email or on irc (sometimes
I use mdm other times the email login as my nick, and when connected
I tend to leave it well past the hours I am at the computer).

I copied most of the 64bit code to parse the device tree without the pci
nodes  moved it to 32. The userland *could* work, I'm not sure. My
outout is:

|load: entry = 0x80053c flags = 0
|nr_segments = 2
|segment[0].buf   = 0x1002b8f0
|segment[0].bufsz = 80
|segment[0].mem   = (nil)
|segment[0].memsz = 1000
|segment[1].buf   = 0x4803f008
|segment[1].bufsz = 3a3138
|segment[1].mem   = 0x80
|segment[1].memsz = 3b

Now. The entry address in image-start is valid and is the entrypoint of
the custom cuImage. Custom means that it does not depend any register
values passed from u-boot (the original one needs a pointer to bd_t).
The only requirement is a valid 1:1 memory mapping.

I learned, that I can not disable the MMU on Book-E so I have to create
a new temporary mapping in my relocate_new_kernel routine. _start is
doing the same thing what I am trying to accomplish: create a new
mapping and don't kill the current one and switch over. This is done by
disabling all mappings but the current, creating a new mapping with
EFN/RPN = 0 and swapping the TS bit in MAS1. This is my current patch
which is not really working:

diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 7a6dfbc..49c9c2a 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -878,22 +878,142 @@ relocate_new_kernel:
/* r4 = reboot_code_buffer */
/* r5 = start_address  */
 
-   li  r0, 0
+   mr r27, r4
+   mr r28, r5
+   mr r29, r6
+
+   li  r25,0   /* phys kernel start (low) */
+   li  r24,0   /* CPU number */
+   li  r23,0   /* phys kernel start (high) */
+
+
+/* 1. Find the index of the entry we're executing in */
+   bl  invstr  /* Find our address */
+invstr: mflrr6  /* Make it accessible */
+   mfmsr   r7
+   rlwinm  r4,r7,27,31,31  /* extract MSR[IS] */
+   mfspr   r7, SPRN_PID0
+   slwir7,r7,16
+   or  r7,r7,r4
+   mtspr   SPRN_MAS6,r7
+   tlbsx   0,r6/* search MSR[IS], SPID=PID0 */
+#ifndef CONFIG_E200
+   mfspr   r7,SPRN_MAS1
+   andis.  r7,r7,[EMAIL PROTECTED]
+   bne match_TLB

The branch above is taken, so I've found my current mapping

+   mfspr   r7,SPRN_PID1
+   slwir7,r7,16
+   or  r7,r7,r4
+   mtspr   SPRN_MAS6,r7
+   tlbsx   0,r6/* search MSR[IS], SPID=PID1 */
+   mfspr   r7,SPRN_MAS1
+   andis.  r7,r7,[EMAIL PROTECTED]
+   bne match_TLB
+   mfspr   r7, SPRN_PID2
+   slwir7,r7,16
+   or  r7,r7,r4
+   mtspr   SPRN_MAS6,r7
+   tlbsx   0,r6/* Fall through, we had to 
match */
+#endif
+match_TLB:
+
+   rlwinm  r3,r7,16,20,31  /* Extract MAS0(Entry) */
+
+   mfspr   r7,SPRN_MAS1/* Insure IPROT set */
+   orisr7,r7,[EMAIL PROTECTED]
+   mtspr   SPRN_MAS1,r7
+   tlbwe
+
+/* 2. Invalidate all entries except the entry we're executing in */
+   mfspr   r9,SPRN_TLB1CFG
+   andi.   r9,r9,0xfff
+   li  r6,0/* Set Entry counter to 0 */
+1:  lis r7,0x1000   /* Set MAS0(TLBSEL) = 1 */
+   rlwimi  r7,r6,16,4,15   /* Setup MAS0 = TLBSEL | 
ESEL(r6) */
+   mtspr   SPRN_MAS0,r7
+   tlbre
+   mfspr   r7,SPRN_MAS1
+   rlwinm  r7,r7,0,2,31/* Clear MAS1 Valid and IPROT */
+   cmpwr3,r6
+   beq skpinv/* Dont update the current 
execution TLB */
+   mtspr   SPRN_MAS1,r7
+   tlbwe
+   isync
+skpinv: addir6,r6,1 /* Increment */
+   cmpwr6,r9   /* Are we done? */
+   bne 1b  /* If not, repeat */
 
-   /*
-* Set Machine Status Register to a known status,
-* switch the MMU off and jump to 1: in a single step.
-*/
+   /* Invalidate TLB0 */
+   li  r6,0x04
+   tlbivax 0,r6
+   TLBSYNC
+   /* Invalidate TLB1 */
+   li  r6,0x0c
+   tlbivax 0,r6
+   TLBSYNC
 
-   mr  r8, r0
-   ori r8, r8, MSR_RI|MSR_ME
-   mtspr   SPRN_SRR1, r8
-   addir8, r4, 1f - relocate_new_kernel
-   mtspr   SPRN_SRR0, r8
-   sync
+/* 3. Setup a temp mapping and jump to it */
+   andi.   r5, r3, 0x1 /* Find an entry not used and is non-zero */
+   addir5, r5, 0x1
+   lis r7,0x1000   /* Set 

Re: [RFC] powerpc/boot: add kernel,end node to the cuboot target

2008-09-25 Thread Sebastian Siewior

Milton Miller wrote:

On Wed Sep 24 at about 05:54:04 EST 2008, Sebastian Siewior wrote:

this could be used by the kexec userland code.


NACK.

[...]
Thanks for explanation. I just went through the kexec user land code and
saw that the 64bit code uses the device tree to obtain some address and
32bit returns a hard coded struct on game cube (unless it was another
console I mixed it up) and nothing on every other platform. Therefore I
tried to add the missing nodes.


If you have any questions about kdump or what needs to happen,
please feel free to contact me either by email or on irc (sometimes
I use mdm other times the email login as my nick, and when connected
I tend to leave it well past the hours I am at the computer).

Thanks for the offer.



milton


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


Re: [RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize

2008-09-25 Thread Sebastian Siewior

Milton Miller wrote:

My current (working) solution is to move cuImage from 4 MiB to 8 MiB.
Something similar has been done for pSeries in 9b09c6d powerpc: Change
the default link address for pSeries zImage kernels. Would it be
appropriate to move initial address to 64 MiB as the default loading
address or do we have here some boards which have only 64 MiB of memory?


I think there are some boards that have even less (8xx?).  Is the
link address a wrapper option yet?


Nope. The wrapper script distinguishes between platforms. Default is 4MiB, 
pSeries has 64MiB, coff does 5MiB and the PS3 has other magic.



--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -56,7 +56,7 @@ static struct addr_range prep_kernel(void)
if (platform_ops.vmlinux_alloc) {
addr = platform_ops.vmlinux_alloc(ei.memsize);
} else {
-   if ((unsigned long)_start  ei.memsize)
+   if ((unsigned long)_start  ei.loadsize)



I think this needs to be a two part test (add approprate casts):  
	_start  ei.loadsize || _end  ei.memsize


.. and a comment explaining why.


okay.


We could do better if we kept allocating more memory until we got
above it, but the current code has no such provision.  (prpmc2800, or
one of those, actually decompresses the header to peek at memsize
before starting the simple_alloc code).


I don't thing I can follow. Do you want to move the bootwrapper code above 
the limit and recall it?


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


Re: [RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize

2008-09-25 Thread Sebastian Siewior
* Milton Miller | 2008-09-23 20:46:18 [-0500]:

On Wed Sep 24 at about 06:38:57 EST in 2008, Sebastian Siewior wrote:
 My mylinux binary incl. bss is ~5 MiB without bss less than 4 MiB.
 Therefore I though that I could replace ei.memsize with ei.loadsize. It
 didn't work. I'm not sure why it did not work but I guess that the
 memset() of bss in the initial kernel code overwrote the cuimage code
 which is required for some reason. Maybe some device-tree callbacks.

probably because the bss extended beyond the cuboot _end to include
where your device tree was copied (just a malloc and we start
simple_malloc at the boot _end on most platforms).

Right, the bss section went past _dtb_start, moving the device tree
helps.

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
 arch/powerpc/boot/libfdt-wrapper.c |   16 
 arch/powerpc/boot/main.c   |   12 +++-
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/boot/libfdt-wrapper.c 
b/arch/powerpc/boot/libfdt-wrapper.c
index c541fd8..1daa73f 100644
--- a/arch/powerpc/boot/libfdt-wrapper.c
+++ b/arch/powerpc/boot/libfdt-wrapper.c
@@ -165,6 +165,7 @@ static unsigned long fdt_wrapper_finalize(void)
 void fdt_init(void *blob)
 {
int err;
+   int bufsize;
 
dt_ops.finddevice = fdt_wrapper_finddevice;
dt_ops.getprop = fdt_wrapper_getprop;
@@ -178,16 +179,15 @@ void fdt_init(void *blob)
 
/* Make sure the dt blob is the right version and so forth */
fdt = blob;
-   err = fdt_open_into(fdt, fdt, fdt_totalsize(blob));
-   if (err == -FDT_ERR_NOSPACE) {
-   int bufsize = fdt_totalsize(fdt) + 4;
-   buf = malloc(bufsize);
-   err = fdt_open_into(fdt, buf, bufsize);
-   }
+   bufsize = fdt_totalsize(fdt) + 4;
+   buf = malloc(bufsize);
+   if(!buf)
+   fatal(malloc failed. can't relocate the device tree\n\r);
+
+   err = fdt_open_into(fdt, buf, bufsize);
 
if (err != 0)
fatal(fdt_init(): %s\n\r, fdt_strerror(err));
 
-   if (buf)
-   fdt = buf;
+   fdt = buf;
 }
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 45a81c3..f5fcd14 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -56,9 +56,19 @@ static struct addr_range prep_kernel(void *chosen)
if (platform_ops.vmlinux_alloc) {
addr = platform_ops.vmlinux_alloc(ei.memsize);
} else {
+   /*
+* Check if the kernel image (without bss) would overwrite the
+* bootwrapper. The device tree has been moved in fdt_init()
+* to an area allocated with malloc() (somewhere past _end).
+*/
if ((unsigned long)_start  ei.loadsize)
fatal(Insufficient memory for kernel at address 0!
-   (_start=%p)\n\r, _start);
+   (_start=%p, uncomressed size=%08x)\n\r,
+  _start, ei.loadsize);
+
+   if ((unsigned long)_end  ei.memsize)
+   fatal(The final kernel image would overwrite the 
+   device tree\n\r);
}
 
/* Finally, gunzip the kernel */
-- 
1.5.6.5

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


[RFC] powerpc/boot: add kernel,end node to the cuboot target

2008-09-23 Thread Sebastian Siewior
this could be used by the kexec userland code.

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
This is done by the 64bit kexec code allready. The 32bit doesn't use the
device tree at all. I'm not sure whether the node has to be a 32bit or
64bit value.

 arch/powerpc/boot/main.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 27f6af1..a8714cf 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -27,7 +27,7 @@ struct addr_range {
 
 #undef DEBUG
 
-static struct addr_range prep_kernel(void)
+static struct addr_range prep_kernel(void *chosen)
 {
char elfheader[256];
void *vmlinuz_addr = _vmlinux_start;
@@ -72,7 +72,7 @@ static struct addr_range prep_kernel(void)
fatal(ran out of data!  only got 0x%x of 0x%lx bytes.\n\r,
len, ei.loadsize);
printf(done 0x%x bytes\n\r, len);
-
+   setprop_val(chosen, linux,kernel-end, (u32)(ei.memsize));
flush_cache(addr, ei.loadsize);
 
return (struct addr_range){addr, ei.memsize};
@@ -180,7 +180,7 @@ void start(void)
if (!chosen)
chosen = create_node(NULL, chosen);
 
-   vmlinux = prep_kernel();
+   vmlinux = prep_kernel(chosen);
initrd = prep_initrd(vmlinux, chosen,
 loader_info.initrd_addr, loader_info.initrd_size);
prep_cmdline(chosen);
-- 
1.5.6.5

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


[RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize

2008-09-23 Thread Sebastian Siewior
My mylinux binary incl. bss is ~5 MiB without bss less than 4 MiB.
Therefore I though that I could replace ei.memsize with ei.loadsize. It
didn't work. I'm not sure why it did not work but I guess that the
memset() of bss in the initial kernel code overwrote the cuimage code
which is required for some reason. Maybe some device-tree callbacks.

My current (working) solution is to move cuImage from 4 MiB to 8 MiB.
Something similar has been done for pSeries in 9b09c6d powerpc: Change
the default link address for pSeries zImage kernels. Would it be
appropriate to move initial address to 64 MiB as the default loading
address or do we have here some boards which have only 64 MiB of memory?
Does someone have another idea?

--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -56,7 +56,7 @@ static struct addr_range prep_kernel(void)
if (platform_ops.vmlinux_alloc) {
addr = platform_ops.vmlinux_alloc(ei.memsize);
} else {
-   if ((unsigned long)_start  ei.memsize)
+   if ((unsigned long)_start  ei.loadsize)
fatal(Insufficient memory for kernel at address 0!
(_start=%p)\n\r, _start);
}
-- 

--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -138,7 +138,7 @@ objflags=-S
 tmp=$tmpdir/zImage.$$.o
 ksection=.kernel:vmlinux.strip
 isection=.kernel:initrd
-link_address='0x40'
+link_address='0x80'
 
 case $platform in
 pseries)
-- 
1.5.6.5

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


[PATCH] powerpc: enforce a non-spe kernel build even on broken compilers

2008-09-01 Thread Sebastian Siewior
From: Thiemo Seufer [EMAIL PROTECTED]

those two are requried on my fresh gcc 4.3.1

Signed-off-by: Thiemo Seufer [EMAIL PROTECTED]
Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
Not sure if this is intendent or a gcc bug but with -mno-spe
the spe opcodes were not used floating point anymore but
for 64bit save/restore for instance.

 arch/powerpc/Makefile |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index b7d4c4c..3727e4f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -108,7 +108,10 @@ endif
 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
 
 # No SPE instruction when building kernel
+# (We use all available options to help semi-broken compilers)
 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
+KBUILD_CFLAGS += $(call cc-option,-mspe=no)
+KBUILD_CFLAGS += $(call cc-option,-mabi=no-spe)
 
 # Enable unit-at-a-time mode when possible. It shrinks the
 # kernel considerably.
-- 
1.5.6.5

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


Re: [RFC] mtd: add OF2PDEV convertor for the NDFC driver

2008-08-21 Thread Sebastian Siewior
* Arnd Bergmann | 2008-08-21 00:40:58 [+0200]:

On Wednesday 20 August 2008, Sebastian Siewior wrote:
 I didn't convert the NDFC driver to support OF because there are
 non-OF-aware platforms with the ndfc chip.
 All settings are mandatory except the oob layout.

Are you aware of Sean's patch from
http://patchwork.ozlabs.org/linuxppc/patch?id=20183 ?

Yes, I heard of it. tglx told me that the IP-Core might show up in
non-IBM HW and it would be better not to drop the platform support.

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


[RFC] mtd: add OF2PDEV convertor for the NDFC driver

2008-08-20 Thread Sebastian Siewior
I didn't convert the NDFC driver to support OF because there are
non-OF-aware platforms with the ndfc chip.
All settings are mandatory except the oob layout.

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
 drivers/mtd/nand/Kconfig   |7 ++
 drivers/mtd/nand/Makefile  |1 +
 drivers/mtd/nand/ndfc_of.c |  253 
 3 files changed, 261 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/ndfc_of.c

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index ab0d77e..5bf0a25 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -170,6 +170,13 @@ config MTD_NAND_NDFC
help
 NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
 
+config MTD_NAND_NDFC_OF
+   tristate OF support for NDFC
+   depends on MTD_NAND_NDFC  PPC_OF
+   help
+ This setting allows to read the NanD configuration from OF instead
+ of a Platform device.
+
 config MTD_NAND_S3C2410_CLKSTOP
bool S3C2410 NAND IDLE clock stop
depends on MTD_NAND_S3C2410
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index b786c5d..5a9da0f 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_MTD_NAND_TS7250) += ts7250.o
 obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
 obj-$(CONFIG_MTD_NAND_CS553X)  += cs553x_nand.o
 obj-$(CONFIG_MTD_NAND_NDFC)+= ndfc.o
+obj-$(CONFIG_MTD_NAND_NDFC_OF) += ndfc_of.o
 obj-$(CONFIG_MTD_NAND_ATMEL)   += atmel_nand.o
 obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
 obj-$(CONFIG_MTD_NAND_BASLER_EXCITE)   += excite_nandflash.o
diff --git a/drivers/mtd/nand/ndfc_of.c b/drivers/mtd/nand/ndfc_of.c
new file mode 100644
index 000..852dca3
--- /dev/null
+++ b/drivers/mtd/nand/ndfc_of.c
@@ -0,0 +1,253 @@
+/*
+ * OF - Platform device wrapper for NDFC
+ * (c) Sebastian Siewior, Linutronix
+ */
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/mtd/partitions.h
+#include linux/mtd/nand.h
+#include linux/mtd/ndfc.h
+
+struct resource ndfc_resource;
+
+struct ndfc_controller_settings ndfc_settings;
+
+struct platform_nand_ctrl ndfc_nand_ctrl = {
+   .priv = ndfc_settings,
+};
+
+static struct platform_device ndfc_nand_device = {
+   .name = ndfc-nand,
+   .id = 0,
+   .dev = {
+   .platform_data = ndfc_nand_ctrl,
+   },
+   .num_resources = 1,
+   .resource = ndfc_resource,
+};
+
+static int ndfc_num_devices;
+
+struct of_ndfc_devices {
+   struct platform_device device;
+   struct platform_nand_chip chip;
+   struct ndfc_chip_settings chip_settings;
+   struct nand_ecclayout ecclayout;
+};
+
+static struct of_ndfc_devices *ndfc_chips;
+
+static int __devinit of_nand_probe(struct of_device *dev,
+   const struct of_device_id *match)
+{
+   struct device_node *dp = dev-node;
+   struct device_node *child_node;
+   const u32 *u32_val;
+   int ret;
+   int i;
+   u32 len;
+   u32 ccr_bank;
+   u32 read_cycles;
+   u32 num_chips = 0;
+
+   ret = of_address_to_resource(dp, 0, ndfc_resource);
+   if (ret) {
+   dev_err(dev-dev, Failed to read address from DT.\n);
+   return ret;
+   }
+
+   u32_val = of_get_property(dp, id, len);
+   if (!u32_val || len != 4) {
+   dev_err(dev-dev, Failed to read property: id\n);
+   return -EINVAL;
+   }
+   ndfc_nand_device.id = *u32_val;
+
+   u32_val = of_get_property(dp, ccr_bank, len);
+   if (!u32_val || len != 4) {
+   dev_err(dev-dev, Failed to read property: ccr_bank\n);
+   return -EINVAL;
+   }
+   ccr_bank = *u32_val;
+
+   u32_val = of_get_property(dp, read_cycles, len);
+   if (!u32_val || len != 4) {
+   dev_err(dev-dev, Failed to read property: read_cycles\n);
+   return -EINVAL;
+   }
+   read_cycles = *u32_val;
+
+   ndfc_settings.ccr_settings = NDFC_CCR_BS(ccr_bank) | read_cycles;
+
+   u32_val = of_get_property(dp, erpn, len);
+   if (!u32_val || len != 4) {
+   dev_err(dev-dev, Failed to read property: erpn\n);
+   return -EINVAL;
+   }
+   ndfc_settings.ndfc_erpn = *u32_val;
+
+   for_each_child_of_node(dp, child_node)
+   num_chips++;
+
+   if (!num_chips) {
+   dev_err(dev-dev, Failed to find chip nodes\n);
+   return -EINVAL;
+   }
+
+   ndfc_num_devices = num_chips;
+   ndfc_chips = kzalloc(ndfc_num_devices * sizeof(struct of_ndfc_devices),
+   GFP_KERNEL);
+   if (!ndfc_chips) {
+   dev_err(dev-dev, OOM while allocating memory for %d 
+   ndfc_chips\n, num_chips);
+   return -ENOMEM

boot cuImage on an old u-boot

2008-08-20 Thread Sebastian Siewior
I have here a mpc8540ads board and a u-boot 1.0.0. I've build the
defconfig for the board and I tried to boot the genarated
cuImage.mpc8540ads image. After the bootm command I see just

|8540 bootm 100
|## Booting image at 0100 ...
|   Image Name:   Linux-2.6.26
|   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
|   Data Size:1232711 Bytes =  1.2 MB
|   Load Address: 0040
|   Entry Point:  004005ac
|   Verifying Checksum ... OK
|   Uncompressing Kernel Image ... OK
|

I don't see the device tree fixups printfs, so crash happend quite
early. Anyone an idea what I could have done wrong?

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


Re: [PATCH / RFC] net: fix locking in ibm_newemac

2008-08-14 Thread Sebastian Siewior
* Benjamin Herrenschmidt | 2008-08-14 13:45:54 [+1000]:

 The fix is to defer phy init until netdevice is registered / initialized.

I think it's better instead to take the dev_mc_add() statement
out of emac_configure().
I looked yesterday into that code and I saw that dev_mc_add() was called
by the network core itself. Now I'm sure it was definitly too late for
writing patches :)

What about this patch instead, does it fix it for you ?
yep it does.

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


[PATCH / RFC] net: fix locking in ibm_newemac

2008-08-13 Thread Sebastian Siewior
|PPC 4xx OCP EMAC driver, version 3.54
|MAL v2 /plb/mcmal, 2 TX channels, 2 RX channels
|RGMII /plb/opb/[EMAIL PROTECTED] initialized with MDIO support
|/plb/opb/[EMAIL PROTECTED]: input 0 in RGMII mode
|BUG: spinlock bad magic on CPU#0, swapper/1
| lock: cf81632c, .magic: , .owner: none/-1, .owner_cpu: 0
|Call Trace:
|[cf82bc70] [c00071c4] show_stack+0x34/0x194 (unreliable)
|[cf82bca0] [c0136d5c] spin_bug+0x8c/0xd0
|[cf82bcc0] [c0136f64] _raw_spin_lock+0x94/0x16c
|[cf82bcf0] [c023b528] _spin_lock_bh+0x20/0x34
|[cf82bd10] [c01d04a8] dev_mc_add+0x2c/0x84
|[cf82bd30] [c0166f80] emac_configure+0x2a8/0x55c
|[cf82bd60] [c02418bc] emac_probe+0xc24/0x105c
|[cf82be40] [c01bb504] of_platform_device_probe+0x58/0x80
|[cf82be60] [c016057c] driver_probe_device+0xb8/0x1ec
|[cf82be80] [c0160734] __driver_attach+0x84/0x88
|[cf82bea0] [c015fa4c] bus_for_each_dev+0x5c/0x98
|[cf82bed0] [c0160384] driver_attach+0x24/0x34
|[cf82bee0] [c01600b4] bus_add_driver+0x1d8/0x24c
|[cf82bf00] [c0160944] driver_register+0x5c/0x158
|[cf82bf20] [c01bb3dc] of_register_driver+0x54/0x70
|[cf82bf30] [c030ba8c] emac_init+0x1c8/0x208
|[cf82bf60] [c02f4184] kernel_init+0x84/0x27c
|[cf82bff0] [c000e594] kernel_thread+0x44/0x60

The fix is to defer phy init until netdevice is registered / initialized.

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
Noticed with spinlock debug enabled  40x/kilauea_defconfig on a kilaue
board. With this patch, the board boots via NFS root, no problems were
noticed so far

 drivers/net/ibm_newemac/core.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index babc79a..c4130e1 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -2751,11 +2751,6 @@ static int __devinit emac_probe(struct of_device *ofdev,
dev-stop_timeout = STOP_TIMEOUT_100;
INIT_DELAYED_WORK(dev-link_work, emac_link_timer);
 
-   /* Find PHY if any */
-   err = emac_init_phy(dev);
-   if (err != 0)
-   goto err_detach_tah;
-
/* Fill in the driver function table */
ndev-open = emac_open;
if (dev-tah_dev)
@@ -2785,6 +2780,11 @@ static int __devinit emac_probe(struct of_device *ofdev,
goto err_detach_tah;
}
 
+   /* Find PHY if any */
+   err = emac_init_phy(dev);
+   if (err != 0)
+   goto err_detach_tah;
+
/* Set our drvdata last as we don't want them visible until we are
 * fully initialized
 */
-- 
1.5.5.2

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


Re: bug: mutex_lock() in interrupt conntext via phy_stop() in gianfar

2008-07-24 Thread Sebastian Siewior
* Benjamin Herrenschmidt | 2008-07-24 08:12:48 [+1000]:

On Mon, 2008-07-21 at 17:57 -0500, Nate Case wrote:
 On Fri, 2008-07-18 at 14:10 +0200, Sebastian Siewior wrote:
  Commit 35b5f6b1a aka [PHYLIB: Locking fixes for PHY I/O potentially 
  sleeping]
  changed the phydev-lock from spinlock into a mutex. Now, the following
  code path got triggered while NFS was unavailable:
  
 [snip]
  |[  194.864733] BUG: sleeping function called from invalid context at 
  /home/bigeasy/git/linux-2.6-powerpc/kernel/mutex.c:87
  |[  194.875529] in_atomic():1, irqs_disabled():0
  |[  194.879805] Call Trace:
  |[  194.882250] [c0383d90] [c0006dd8] show_stack+0x48/0x184 (unreliable)
  |[  194.888649] [c0383db0] [c001e938] __might_sleep+0xe0/0xf4
  |[  194.894069] [c0383dc0] [c025a43c] mutex_lock+0x24/0x3c
  |[  194.899234] [c0383de0] [c019005c] phy_stop+0x20/0x70
  |[  194.904234] [c0383df0] [c018d4ec] stop_gfar+0x28/0xf4
  |[  194.909305] [c0383e10] [c018e8c4] gfar_timeout+0x30/0x60
  |[  194.914638] [c0383e20] [c01fe7c0] dev_watchdog+0xa8/0x144
 
 Hmm..  I'm not sure what the best solution is to this.  Make the
 stop_gfar() call happen in a workqueue, and make a similar change to
 ucc_geth, fec_mpc52xx, and fs_enet? Modify phy_stop() to do the work in
 a workqueue conditionally if in interrupt context?  Between these two
 I'd lean toward the latter.
 
 Does anyone have any better ideas?

Move the reset task to a workqueue.
Done in [1] Ben.

[1] http://marc.info/?l=linux-netdevm=121684347609062w=2
Cheers,
Ben.

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


[PATCH / RFC] net: don't grab a mutex within a timer context in gianfar

2008-07-23 Thread Sebastian Siewior
From: Sebastian Siewior [EMAIL PROTECTED]

I got the following backtrace while network was unavailble:

|NETDEV WATCHDOG: eth0: transmit timed out
|BUG: sleeping function called from invalid context at 
/home/bigeasy/git/linux-2.6-powerpc/kernel/mutex.c:87
|in_atomic():1, irqs_disabled():0
|Call Trace:
|[c0383d90] [c0006dd8] show_stack+0x48/0x184 (unreliable)
|[c0383db0] [c001e938] __might_sleep+0xe0/0xf4
|[c0383dc0] [c025a43c] mutex_lock+0x24/0x3c
|[c0383de0] [c019005c] phy_stop+0x20/0x70
|[c0383df0] [c018d4ec] stop_gfar+0x28/0xf4
|[c0383e10] [c018e8c4] gfar_timeout+0x30/0x60
|[c0383e20] [c01fe7c0] dev_watchdog+0xa8/0x144
|[c0383e30] [c002f93c] run_timer_softirq+0x148/0x1c8
|[c0383e60] [c002b084] __do_softirq+0x5c/0xc4
|[c0383e80] [c00046fc] do_softirq+0x3c/0x54
|[c0383e90] [c002ac60] irq_exit+0x3c/0x5c
|[c0383ea0] [c000b378] timer_interrupt+0xe0/0xf8
|[c0383ec0] [c000e5ac] ret_from_except+0x0/0x18
|[c0383f80] [c000804c] cpu_idle+0xcc/0xdc
|[c0383fa0] [c025c07c] etext+0x7c/0x90
|[c0383fc0] [c0338960] start_kernel+0x294/0x2a8
|[c0383ff0] [c3dc] skpinv+0x304/0x340
|[ cut here ]

The phylock was once a spinlock but got changed into a mutex via
commit 35b5f6b1a aka [PHYLIB: Locking fixes for PHY I/O potentially sleeping]

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
---
bug report @ http://marc.info/?l=linux-netdevm=121638307116389w=2
I moved it into a workqueue, this is what tg3 does.
I would convert the other three drivers unless $dude suggests a better
method or somebody else takes care

 drivers/net/gianfar.c |   22 ++
 drivers/net/gianfar.h |2 ++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 25bdd08..caa6cbd 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -112,6 +112,7 @@ const char gfar_driver_version[] = 1.3;
 
 static int gfar_enet_open(struct net_device *dev);
 static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static void gfar_reset_task(struct work_struct *work);
 static void gfar_timeout(struct net_device *dev);
 static int gfar_close(struct net_device *dev);
 struct sk_buff *gfar_new_skb(struct net_device *dev);
@@ -216,6 +217,7 @@ static int gfar_probe(struct platform_device *pdev)
 
spin_lock_init(priv-txlock);
spin_lock_init(priv-rxlock);
+   INIT_WORK(priv-reset_task, gfar_reset_task);
 
platform_set_drvdata(pdev, dev);
 
@@ -1132,6 +1134,7 @@ static int gfar_close(struct net_device *dev)
napi_disable(priv-napi);
 #endif
 
+   cancel_work_sync(priv-reset_task);
stop_gfar(dev);
 
/* Disconnect from the PHY */
@@ -1246,13 +1249,16 @@ static int gfar_change_mtu(struct net_device *dev, int 
new_mtu)
return 0;
 }
 
-/* gfar_timeout gets called when a packet has not been
+/* gfar_reset_task gets scheduled when a packet has not been
  * transmitted after a set amount of time.
  * For now, assume that clearing out all the structures, and
- * starting over will fix the problem. */
-static void gfar_timeout(struct net_device *dev)
+ * starting over will fix the problem.
+ */
+static void gfar_reset_task(struct work_struct *work)
 {
-   dev-stats.tx_errors++;
+   struct gfar_private *priv = container_of(work, struct gfar_private,
+   reset_task);
+   struct net_device *dev = priv-dev;
 
if (dev-flags  IFF_UP) {
stop_gfar(dev);
@@ -1262,6 +1268,14 @@ static void gfar_timeout(struct net_device *dev)
netif_schedule(dev);
 }
 
+static void gfar_timeout(struct net_device *dev)
+{
+   struct gfar_private *priv = netdev_priv(dev);
+
+   dev-stats.tx_errors++;
+   schedule_work(priv-reset_task);
+}
+
 /* Interrupt Handler for Transmit complete */
 static int gfar_clean_tx_ring(struct net_device *dev)
 {
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 27f37c8..d983a6a 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -759,6 +759,8 @@ struct gfar_private {
 
uint32_t msg_enable;
 
+   struct work_struct reset_task;
+
/* Network Statistics */
struct gfar_extra_stats extra_stats;
 };
-- 
1.5.5.2

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


Re: bug: mutex_lock() in interrupt conntext via phy_stop() in gianfar

2008-07-22 Thread Sebastian Siewior
* Nate Case | 2008-07-21 17:57:08 [-0500]:

On Fri, 2008-07-18 at 14:10 +0200, Sebastian Siewior wrote:
 Commit 35b5f6b1a aka [PHYLIB: Locking fixes for PHY I/O potentially sleeping]
 changed the phydev-lock from spinlock into a mutex. Now, the following
 code path got triggered while NFS was unavailable:
 
[snip]
 |[  194.864733] BUG: sleeping function called from invalid context at 
 /home/bigeasy/git/linux-2.6-powerpc/kernel/mutex.c:87
 |[  194.875529] in_atomic():1, irqs_disabled():0
 |[  194.879805] Call Trace:
 |[  194.882250] [c0383d90] [c0006dd8] show_stack+0x48/0x184 (unreliable)
 |[  194.888649] [c0383db0] [c001e938] __might_sleep+0xe0/0xf4
 |[  194.894069] [c0383dc0] [c025a43c] mutex_lock+0x24/0x3c
 |[  194.899234] [c0383de0] [c019005c] phy_stop+0x20/0x70
 |[  194.904234] [c0383df0] [c018d4ec] stop_gfar+0x28/0xf4
 |[  194.909305] [c0383e10] [c018e8c4] gfar_timeout+0x30/0x60
 |[  194.914638] [c0383e20] [c01fe7c0] dev_watchdog+0xa8/0x144

Hmm..  I'm not sure what the best solution is to this.  Make the
stop_gfar() call happen in a workqueue, and make a similar change to
ucc_geth, fec_mpc52xx, and fs_enet? Modify phy_stop() to do the work in
a workqueue conditionally if in interrupt context?  Between these two
I'd lean toward the latter.

Does anyone have any better ideas?
If I look at tg3.c than exactly this is done. Others call it only on
close(). I guess this depends very much on driver's logic :)
If nobody minds, than I would assume that tg3.c is a good example and I
would move the timout path into a workqueu.

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


bug: mutex_lock() in interrupt conntext via phy_stop() in gianfar

2008-07-18 Thread Sebastian Siewior
Commit 35b5f6b1a aka [PHYLIB: Locking fixes for PHY I/O potentially sleeping]
changed the phydev-lock from spinlock into a mutex. Now, the following
code path got triggered while NFS was unavailable:

|[   21.287359] nfs: server 10.11.3.47 not responding, still trying
|[   38.891373] nfs: server 10.11.3.47 not responding, still trying
|[  148.179592] INFO: task udevd:1762 blocked for more than 120 seconds.
|[  148.185967] echo 0  /proc/sys/kernel/hung_task_timeout_secs disables 
this message.
|[  148.193810] udevd D 0fef1dd8 0  1762   1761
|[  148.199055] Call Trace:
|[  148.201504] [cecdda80] [c00071e4] __switch_to+0x6c/0x84
|[  148.206764] [cecddaa0] [c025973c] schedule+0x46c/0x4cc
|[  148.211937] [cecddad0] [c00f3d84] nfs_wait_schedule+0x24/0x38
|[  148.217712] [cecddae0] [c0259b74] __wait_on_bit_lock+0x68/0xcc
|[  148.223576] [cecddb00] [c0259c4c] out_of_line_wait_on_bit_lock+0x74/0x88
|[  148.230300] [cecddb50] [c00f3e6c] __nfs_revalidate_inode+0xd4/0x264
|[  148.236597] [cecddc20] [c00f1298] nfs_lookup_revalidate+0x1bc/0x3d4
|[  148.243071] [cecddd80] [c0081db8] do_lookup+0x148/0x1a0
|[  148.248361] [cecdddb0] [c0083bac] __link_path_walk+0x930/0xe24
|[  148.254219] [cecdde00] [c00840e8] path_walk+0x48/0xa8
|[  148.259293] [cecdde30] [c008442c] do_path_lookup+0x160/0x194
|[  148.264982] [cecdde60] [c0084fe0] __path_lookup_intent_open+0x58/0xa4
|[  148.271444] [cecdde80] [c007ea54] open_exec+0x2c/0xdc
|[  148.276525] [cecddef0] [c007efa4] do_execve+0x58/0x1c4
|[  148.281704] [cecddf20] [c0007568] sys_execve+0x58/0x84
|[  148.286873] [cecddf40] [c000df58] ret_from_syscall+0x0/0x3c
|[  169.651632] INFO: task udevsettle:1053 blocked for more than 120 seconds.

some more of this and now the interresting part:

|[  194.859659] NETDEV WATCHDOG: eth0: transmit timed out
|[  194.864733] BUG: sleeping function called from invalid context at 
/home/bigeasy/git/linux-2.6-powerpc/kernel/mutex.c:87
|[  194.875529] in_atomic():1, irqs_disabled():0
|[  194.879805] Call Trace:
|[  194.882250] [c0383d90] [c0006dd8] show_stack+0x48/0x184 (unreliable)
|[  194.888649] [c0383db0] [c001e938] __might_sleep+0xe0/0xf4
|[  194.894069] [c0383dc0] [c025a43c] mutex_lock+0x24/0x3c
|[  194.899234] [c0383de0] [c019005c] phy_stop+0x20/0x70
|[  194.904234] [c0383df0] [c018d4ec] stop_gfar+0x28/0xf4
|[  194.909305] [c0383e10] [c018e8c4] gfar_timeout+0x30/0x60
|[  194.914638] [c0383e20] [c01fe7c0] dev_watchdog+0xa8/0x144
|[  194.920064] [c0383e30] [c002f93c] run_timer_softirq+0x148/0x1c8
|[  194.926008] [c0383e60] [c002b084] __do_softirq+0x5c/0xc4
|[  194.931350] [c0383e80] [c00046fc] do_softirq+0x3c/0x54
|[  194.936515] [c0383e90] [c002ac60] irq_exit+0x3c/0x5c
|[  194.941499] [c0383ea0] [c000b378] timer_interrupt+0xe0/0xf8
|[  194.947097] [c0383ec0] [c000e5ac] ret_from_except+0x0/0x18
|[  194.952610] [c0383f80] [c000804c] cpu_idle+0xcc/0xdc
|[  194.957592] [c0383fa0] [c025c07c] etext+0x7c/0x90
|[  194.962322] [c0383fc0] [c0338960] start_kernel+0x294/0x2a8
|[  194.967839] [c0383ff0] [c3dc] skpinv+0x304/0x340
|[  194.972833] [ cut here ]
|[  194.977450] Badness at 
/home/bigeasy/git/linux-2.6-powerpc/kernel/mutex.c:134
|[  194.984589] NIP: c025a268 LR: c025a250 CTR: c017e224
|[  194.989557] REGS: c0383cf0 TRAP: 0700   Not tainted  (2.6.26)
|[  194.995302] MSR: 00029000 EE,ME  CR: 28002022  XER: 
|[  195.001167] TASK = c035e500[0] 'swapper' THREAD: c0382000
|[  195.006390] GPR00:  c0383da0 c035e500 0001 c035e500 0010 
 c036 
|[  195.014798] GPR08:  c039 0001 c036 6353 628a87a2 
0ffe8600  
|[  195.023206] GPR16: cab54ee3   0ffe7384   
0ff904a0  
|[  195.031612] GPR24:   c038e5a4 d1058000 c035e500 cf86b570 
cf9c3888 cf9c3888 
|[  195.040199] NIP [c025a268] __mutex_lock_slowpath+0x44/0x1f4
|[  195.045783] LR [c025a250] __mutex_lock_slowpath+0x2c/0x1f4
|[  195.051277] Call Trace:
|[  195.053721] [c0383da0] [cf9c3888] 0xcf9c3888 (unreliable)
|[  195.059146] [c0383de0] [c019005c] phy_stop+0x20/0x70
|[  195.064135] [c0383df0] [c018d4ec] stop_gfar+0x28/0xf4
|[  195.069202] [c0383e10] [c018e8c4] gfar_timeout+0x30/0x60
|[  195.074529] [c0383e20] [c01fe7c0] dev_watchdog+0xa8/0x144
|[  195.079946] [c0383e30] [c002f93c] run_timer_softirq+0x148/0x1c8
|[  195.085885] [c0383e60] [c002b084] __do_softirq+0x5c/0xc4
|[  195.091219] [c0383e80] [c00046fc] do_softirq+0x3c/0x54
|[  195.096374] [c0383e90] [c002ac60] irq_exit+0x3c/0x5c
|[  195.101353] [c0383ea0] [c000b378] timer_interrupt+0xe0/0xf8
|[  195.106944] [c0383ec0] [c000e5ac] ret_from_except+0x0/0x18
|[  195.112447] [c0383f80] [c000804c] cpu_idle+0xcc/0xdc
|[  195.117426] [c0383fa0] [c025c07c] etext+0x7c/0x90
|[  195.122147] [c0383fc0] [c0338960] start_kernel+0x294/0x2a8
|[  195.127655] [c0383ff0] [c3dc] skpinv+0x304/0x340
|[  195.132633] Instruction dump:
|[  195.135422] 90010044 7c5c1378 8009000c 5409012f 41a20024 4bee78dd 2f83 

Re: [PATCH v2] USB: isp1760: Support board-specific hardware configurations

2008-06-25 Thread Sebastian Siewior
* Nate Case | 2008-06-17 11:11:38 [-0500]:

This adds support for hardware configurations that don't match the
chip default register settings (e.g., 16-bit data bus, DACK and
DREQ pulled up instead of down, analog overcurrent mode).

These settings are passed in via the OF device tree.  The PCI
interface still assumes the same default values.

Signed-off-by: Nate Case [EMAIL PROTECTED]
Acked-by: Sebastian Siewior [EMAIL PROTECTED]

diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 440bf94..56e2ad6 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -35,6 +35,8 @@ static int of_isp1760_probe(struct of_device *dev,
   int virq;
   u64 res_len;
   int ret;
+  const unsigned int *prop;
+  unsigned int devflags = 0;
 
   ret = of_address_to_resource(dp, 0, memory);
   if (ret)
@@ -55,8 +57,32 @@ static int of_isp1760_probe(struct of_device *dev,
   virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
   oirq.size);
 
+  if (of_device_is_compatible(dp, nxp,usb-isp1761))
+  devflags |= ISP1760_FLAG_ISP1761;
+
+  if (of_get_property(dp, port1-disable, NULL) != NULL)
+  devflags |= ISP1760_FLAG_PORT1_DIS;
+
+  /* Some systems wire up only 16 of the 32 data lines */
+  prop = of_get_property(dp, bus-width, NULL);
+  if (prop  *prop == 16)
+  devflags |= ISP1760_FLAG_BUS_WIDTH_16;

The only thing I'm not 100% sure is whether it is okey for bus-width to
be detected like that and of_device_is_compatible() vs a special data
entry in of_isp1760_match to distinguish the two chip from each other.
Since nobody of the linuxppc spoke up so far, then I guess it is okey.

Kumar / Josh: Should we describe those DT entries in
Documentation/powerpc/booting-without-of.txt? In the yes case: which
section do you recommend?

+
+  if (of_get_property(dp, port1-otg, NULL) != NULL)
+  devflags |= ISP1760_FLAG_OTG_EN;
+
+  if (of_get_property(dp, analog-oc, NULL) != NULL)
+  devflags |= ISP1760_FLAG_ANALOG_OC;
+
+  if (of_get_property(dp, dack-polarity, NULL) != NULL)
+  devflags |= ISP1760_FLAG_DACK_POL_HIGH;
+
+  if (of_get_property(dp, dreq-polarity, NULL) != NULL)
+  devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
+
   hcd = isp1760_register(memory.start, res_len, virq,
-  IRQF_SHARED | IRQF_DISABLED, dev-dev, dev-dev.bus_id);
+  IRQF_SHARED | IRQF_DISABLED, dev-dev, dev-dev.bus_id,
+  devflags);
   if (IS_ERR(hcd)) {
   ret = PTR_ERR(hcd);
   goto release_reg;
@@ -87,6 +113,9 @@ static struct of_device_id of_isp1760_match[] = {
   {
   .compatible = nxp,usb-isp1760,
   },
+  {
+  .compatible = nxp,usb-isp1761,
+  },
   { },
 };

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


Re: [PATCH v2] USB: isp1760: Support board-specific hardware configurations

2008-06-25 Thread Sebastian Siewior
* Olof Johansson | 2008-06-25 16:22:50 [-0500]:

 Kumar / Josh: Should we describe those DT entries in
 Documentation/powerpc/booting-without-of.txt? In the yes case: which
 section do you recommend?

I don't see a need to. We don't document the IBM busses there either.

Okey.



-Olof

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


Re: [PATCH 1/2] USB: isp1760: Assign resource fields before adding hcd

2008-05-22 Thread Sebastian Siewior
* Nate Case | 2008-05-21 16:28:20 [-0500]:

This fixes the bogus io mem 0x message printed
during driver init due to hcd-rsrc_start being assigned after
the call to usb_add_hcd().

Signed-off-by: Nate Case [EMAIL PROTECTED]
I saw this and was wondering why it was correct in other places like
/proc/iomem :)

Acked-by: Sebastian Siewior [EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2/2] USB: isp1760: Support board-specific hardware configurations

2008-05-22 Thread Sebastian Siewior
* Nate Case | 2008-05-21 16:28:51 [-0500]:

This adds support for hardware configurations that don't match the
chip default register settings (e.g., 16-bit data bus, DACK and
DREQ pulled down instead of up, analog overcurrent mode).
Nice patch. A few comments inline.

These settings are passed in via the OF device tree.  The PCI
interface still assumes the same default values.
The default values should be okay for PCI . It should only be required
for the eval kit from NXP. There was an ISP1761 behind a PLB bridge. I
had all three ports functional there (no OTG) in my first shot after
enabling or disabling some resistors (don't remember the details
anymore). Than I moved to my powerpc and returned the eval kit.

Signed-off-by: Nate Case [EMAIL PROTECTED]
---
 drivers/usb/host/isp1760-hcd.c |   68 +++
 drivers/usb/host/isp1760-hcd.h |   19 ++-
 drivers/usb/host/isp1760-if.c  |   34 +++-
 3 files changed, 103 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 65aa5ec..679b8df 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -38,6 +38,7 @@ struct isp1760_hcd {
   unsignedi_thresh;
   unsigned long   reset_done;
   unsigned long   next_statechange;
+  unsigned intdevflags;
 };
 
 static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd)
@@ -378,9 +379,31 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
 {
   struct isp1760_hcd *priv = hcd_to_priv(hcd);
   int result;
-  u32 scratch;
+  u32 scratch, hwmode;
+
+  /* Setup HW Mode Control: This assumes a level active-low interrupt */
+  hwmode = HW_DATA_BUS_32BIT;
+
+  if (priv-devflags  ISP1760_FLAG_BUS_WIDTH_16)
+  hwmode = ~HW_DATA_BUS_32BIT;

If you don't mind, I would prefer having ISP1760_FLAG_BUS_WIDTH_32 and
or conditionally HW_DATA_BUS_32BIT.

+  if (priv-devflags  ISP1760_FLAG_ANALOG_OC)
+  hwmode |= HW_ANA_DIGI_OC;
+  if (priv-devflags  ISP1760_FLAG_DACK_POL_HIGH)
+  hwmode |= HW_DACK_POL_HIGH;
+  if (priv-devflags  ISP1760_FLAG_DREQ_POL_HIGH)
+  hwmode |= HW_DREQ_POL_HIGH;
+
+  /*
+   * We have to set this first in case we're in 16-bit mode.
+   * Write it twice to ensure correct upper bits if switching
+   * to 16-bit mode.
+   */
+  isp1760_writel(hwmode, hcd-regs + HC_HW_MODE_CTRL);
+  isp1760_writel(hwmode, hcd-regs + HC_HW_MODE_CTRL);
 
   isp1760_writel(0xdeadbabe, hcd-regs + HC_SCRATCH_REG);
+  /* Change bus pattern */
+  scratch = isp1760_readl(hcd-regs + HC_CHIP_ID_REG);
   scratch = isp1760_readl(hcd-regs + HC_SCRATCH_REG);
Why do you have to read the chip id here? Is this a dummy read to ensure
something?

   if (scratch != 0xdeadbabe) {
   printk(KERN_ERR ISP1760: Scratch test failed.\n);
@@ -403,17 +426,30 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
 
   /* Step 11 passed */
 
-  isp1760_writel(INTERRUPT_ENABLE_MASK, hcd-regs + HC_INTERRUPT_REG);
-  isp1760_writel(INTERRUPT_ENABLE_MASK, hcd-regs + HC_INTERRUPT_ENABLE);
+  isp1760_info(priv, bus width: %d, oc: %s\n,
+ (priv-devflags  ISP1760_FLAG_BUS_WIDTH_16) ?
+ 16 : 32, (priv-devflags  ISP1760_FLAG_ANALOG_OC) ?
+ analog : digital);
 
   /* ATL reset */
-  scratch = isp1760_readl(hcd-regs + HC_HW_MODE_CTRL);
-  isp1760_writel(scratch | ALL_ATX_RESET, hcd-regs + HC_HW_MODE_CTRL);
+  isp1760_writel(hwmode | ALL_ATX_RESET, hcd-regs + HC_HW_MODE_CTRL);
   mdelay(10);
-  isp1760_writel(scratch, hcd-regs + HC_HW_MODE_CTRL);
+  isp1760_writel(hwmode, hcd-regs + HC_HW_MODE_CTRL);
 
-  isp1760_writel(PORT1_POWER | PORT1_INIT2, hcd-regs + HC_PORT1_CTRL);
-  mdelay(10);
+  isp1760_writel(INTERRUPT_ENABLE_MASK, hcd-regs + HC_INTERRUPT_REG);
+  isp1760_writel(INTERRUPT_ENABLE_MASK, hcd-regs + HC_INTERRUPT_ENABLE);
+
+  /*
+   * PORT 1 Control register of the ISP1760 is the OTG control
+   * register on ISP1761.
+   */
+  scratch = isp1760_readl(hcd-regs + HC_CHIP_ID_REG);
+  if (((scratch  0x) == 0x1760) 
+  !(priv-devflags  ISP1760_FLAG_PORT1_DIS)) {
+  isp1760_writel(PORT1_POWER | PORT1_INIT2,
+ hcd-regs + HC_PORT1_CTRL);
+  mdelay(10);
+  }
I'm sorry, you can't solve this way. My ISP1760 claims to be an ISP1761
this way :) So I end up with one functional port... The only way to
distinguish between 1760  1761 would be at the probing level.

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


[PATCH / RFC 2/2] ISP1760: bus glue code

2008-04-01 Thread Sebastian Siewior
This patch contains the entry for the build system and glue code for the
platform bus. Currently OpenFirmware and PCI is supported.

Signed-off-by: Sebastian Siewior [EMAIL PROTECTED]
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -95,6 +95,32 @@ config USB_ISP116X_HCD
  To compile this driver as a module, choose M here: the
  module will be called isp116x-hcd.
 
+config USB_ISP1760_HCD
+   tristate ISP 1760 HCD support
+   depends on USB  EXPERIMENTAL
+   ---help---
+ The ISP1760 chip is a USB 2.0 host controller.
+
+ This driver does not support isochronous transfers or OTG.
+
+ To compile this driver as a module, choose M here: the
+ module will be called isp1760-hcd.
+
+config USB_ISP1760_PCI
+   bool Support for the PCI bus
+   depends on USB_ISP1760_HCD  PCI
+   ---help---
+ Enables support for the device present on the PCI bus.
+ This should only be required if you happen to have the eval kit from
+ NXP and you are going to test it.
+
+config USB_ISP1760_OF
+   bool Support for the OF platform bus
+   depends on USB_ISP1760_HCD  OF
+   ---help---
+ Enables support for the device present on the PowerPC
+ OpenFirmware platform bus.
+
 config USB_OHCI_HCD
tristate OHCI HCD support
depends on USB  USB_ARCH_HAS_OHCI
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -6,6 +6,8 @@ ifeq ($(CONFIG_USB_DEBUG),y)
EXTRA_CFLAGS+= -DDEBUG
 endif
 
+isp1760-objs := isp1760-hcd.o isp1760-if.o
+
 obj-$(CONFIG_PCI)  += pci-quirks.o
 
 obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
@@ -16,4 +18,4 @@ obj-$(CONFIG_USB_SL811_HCD)   += sl811-hcd
 obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
 obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
 obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
-
+obj-$(CONFIG_USB_ISP1760_HCD)  += isp1760.o
--- /dev/null
+++ b/drivers/usb/host/isp1760-if.c
@@ -0,0 +1,294 @@
+/*
+ * Glue code for the ISP1760 driver and bus
+ * Currently there is support for
+ * - OpenFirmware
+ * - PCI
+ *
+ * (c) 2007 Sebastian Siewior [EMAIL PROTECTED]
+ *
+ */
+
+#include linux/usb.h
+#include linux/io.h
+
+#include ../core/hcd.h
+#include isp1760-hcd.h
+
+#ifdef CONFIG_USB_ISP1760_OF
+#include linux/of.h
+#include linux/of_platform.h
+#endif
+
+#ifdef CONFIG_USB_ISP1760_PCI
+#include linux/pci.h
+#endif
+
+#ifdef CONFIG_USB_ISP1760_OF
+static int of_isp1760_probe(struct of_device *dev,
+   const struct of_device_id *match)
+{
+   struct usb_hcd *hcd;
+   struct device_node *dp = dev-node;
+   struct resource *res;
+   struct resource memory;
+   struct of_irq oirq;
+   int virq;
+   u64 res_len;
+   int ret;
+
+   ret = of_address_to_resource(dp, 0, memory);
+   if (ret)
+   return -ENXIO;
+
+   res = request_mem_region(memory.start, memory.end - memory.start + 1,
+   dev-dev.bus_id);
+   if (!res)
+   return -EBUSY;
+
+   res_len = memory.end - memory.start + 1;
+
+   if (of_irq_map_one(dp, 0, oirq)) {
+   ret = -ENODEV;
+   goto release_reg;
+   }
+
+   virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
+   oirq.size);
+
+   hcd = isp1760_register(memory.start, res_len, virq,
+   IRQF_SHARED | IRQF_DISABLED, dev-dev, dev-dev.bus_id);
+   if (IS_ERR(hcd)) {
+   ret = PTR_ERR(hcd);
+   goto release_reg;
+   }
+
+   dev_set_drvdata(dev-dev, hcd);
+   return ret;
+
+release_reg:
+   release_mem_region(memory.start, memory.end - memory.start + 1);
+   return ret;
+}
+
+static int of_isp1760_remove(struct of_device *dev)
+{
+   struct usb_hcd *hcd = dev_get_drvdata(dev-dev);
+
+   dev_set_drvdata(dev-dev, NULL);
+
+   usb_remove_hcd(hcd);
+   iounmap(hcd-regs);
+   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
+   usb_put_hcd(hcd);
+   return 0;
+}
+
+static struct of_device_id of_isp1760_match[] = {
+   {
+   .compatible = nxp,usb-isp1760,
+   },
+   { },
+};
+MODULE_DEVICE_TABLE(of, of_isp1760_match);
+
+static struct of_platform_driver isp1760_of_driver = {
+   .name   = nxp-isp1760,
+   .match_table= of_isp1760_match,
+   .probe  = of_isp1760_probe,
+   .remove = of_isp1760_remove,
+};
+#endif
+
+#ifdef CONFIG_USB_ISP1760_PCI
+static u32 nxp_pci_io_base;
+static u32 iolength;
+static u32 pci_mem_phy0;
+static u32 length;
+static u8 *chip_addr;
+static u8 *iobase;
+
+static int __devinit isp1761_pci_probe(struct pci_dev *dev,
+   const struct pci_device_id *id)
+{
+   u8 latency, limit;
+   __u32 reg_data;
+   int retry_count;
+   int length;
+   int status = 1;
+   struct usb_hcd *hcd;
+
+   if (usb_disabled())
+   return