CRYPTO_DEV_NX merge problem (Re: linux-next: Tree for July 31)

2012-07-30 Thread Michael Neuling
> Please do not add anything to linux-next included branches/series that is
> destined for v3.7 until after v3.6-rc1 is released.

Looks like there is a merge conflict between:
  commit 1b074ac867a2bd08a6f12f0feed7d91e06941723
  Author: Seth Jennings 
  Subject: powerpc/crypto: rework Kconfig

and 
  commit fd297b3a7302ab866306f53c1fd1e97b083fe83e
  Author: Anton Blanchard 
  powerpc: Enable pseries hardware RNG and crypto modules

Seth made CRYPTO_DEV_NX a bool and Anton set it as a module.

Hence I get this with a pseries_defconfig
  arch/powerpc/configs/pseries_defconfig:372:warning: symbol value 'm' invalid 
for CRYPTO_DEV_NX

Seth: any reason this can stay as a tristate?

Mikey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [3.5 regression / mcs7830 / bisected] bridge constantly toggeling between disabled and forwarding

2012-07-30 Thread Michael Leun
On Tue, 24 Jul 2012 01:36:34 +0200
Michael Leun  wrote:

My report might sound like I'm complaining that link state detection
works because link state detection was implemented - sorry, but thats
not true.

I do NOT see this link state changes if there is no traffic on the
interface, but I start seeing them once I start pinging. I think this
is not the idea of link state detection?

I would very much appreciate if you could have a look into that,
because it is rather annoying.

> On Mon, 23 Jul 2012 09:15:04 +0200
> Michael Leun  wrote:
> 
> [see issue description below]
> 
> Bisecting yielded
> 
> b1ff4f96fd1c63890d78d8939c6e0f2b44ce3113 is the first bad commit
> commit b1ff4f96fd1c63890d78d8939c6e0f2b44ce3113
> Author: Ondrej Zary 
> Date:   Fri Jun 1 10:29:08 2012 +
> 
> mcs7830: Implement link state detection
> 
> Add .status callback that detects link state changes.
> Tested with MCS7832CV-AA chip (9710:7830, identified as rev.C by the 
> driver).
> Fixes https://bugzilla.kernel.org/show_bug.cgi?id=28532
> 
> Signed-off-by: Ondrej Zary 
> Signed-off-by: David S. Miller 
> 
> :04 04 5480780cb5e75c57122a621fc3bab0108c16be27 
> d97efd9cc0a465dff76bcd3a3c547f718f2a5345 Mdrivers
> 
> 
> Reverting that from 3.5 makes the issue go away.
> 
> > Hi,
> > 
> > when I use my usb ethernet adapter
> > 
> > # > lsusb
> > [...]
> > Bus 002 Device 009: ID 9710:7830 MosChip Semiconductor MCS7830 10/100 Mbps 
> > Ethernet adapter
> > [...]
> > 
> > as port of an bridge
> > 
> > > # brctl addbr br0
> > > # brctl addif br0 eth0
> > > # brctl addif br0 ue5
> > > # ifconfig ue5 up
> > > # ifconfig br0 up
> > 
> > (Also does happen when eth0 is not part of the bridge, but the logs I
> > had available were from that situation...)
> > 
> > I constantly get messages showing the interface toggeling between
> > disabled and forwarding state:
> > 
> > Jul 23 07:40:50 elektra kernel: [ 1539.497337] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:40:50 elektra kernel: [ 1539.554992] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:50 elektra kernel: [ 1539.555005] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:51 elektra kernel: [ 1540.496242] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:40:51 elektra kernel: [ 1540.552534] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:51 elektra kernel: [ 1540.552548] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:52 elektra kernel: [ 1541.550413] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:53 elektra kernel: [ 1542.529672] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:40:53 elektra kernel: [ 1542.587162] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:53 elektra kernel: [ 1542.587175] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:40:54 elektra kernel: [ 1543.585309] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:00 elektra kernel: [ 1549.360600] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:41:00 elektra kernel: [ 1549.442998] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:00 elektra kernel: [ 1549.443011] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:01 elektra kernel: [ 1550.357686] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:41:01 elektra kernel: [ 1550.408208] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:01 elektra kernel: [ 1550.408222] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:02 elektra kernel: [ 1551.407656] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:03 elektra kernel: [ 1552.401578] br0: port 2(ue5) entered 
> > disabled state
> > Jul 23 07:41:03 elektra kernel: [ 1552.474773] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:03 elektra kernel: [ 1552.474786] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:04 elektra kernel: [ 1553.472487] br0: port 2(ue5) entered 
> > forwarding state
> > Jul 23 07:41:05 elektra kernel: [ 1554.356138] br0: port 2(ue5) entered 
> > disabled state
> > [...]
> > 
> > This does (in the same situation, nothing else than the kernel changed)
> > not happen with 3.4.5.
> > 
> > Does anybody have an idea what the issue might be or do I need to bisect?
> 
> 
> -- 
> MfG,
> 
> Michael Leun
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


-- 
MfG,

Michael Leun

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: boot panic regression introduced in 3.5-rc7

2012-07-30 Thread John Stultz

On 07/29/2012 08:51 PM, CAI Qian wrote:

The bisecting pointed out this patch caused one of dell servers boot panic.

   5baefd6d84163443215f4a99f6a20f054ef11236
   hrtimer: Update hrtimer base offsets each hrtimer_interrupt

[2.971092] WARNING: at kernel/time/clockevents.c:209 
clockevents_program_event+0x10a/0x120()
[2.971092] Hardware name: PowerEdge M605


Ok. So I think I've chased this all the way down.

The main issue as noted earlier, is that on this system, the RTC/CMOS is 
returning a year of 8200 as seen in the dmesg:


[0.00] Extended CMOS year: 8200

This causes problems because,  the (signed) 64bit ktime_t structure can 
only store ~292 years of nanoseconds.  Thus, when initialize the time 
from the persistent clock, and set the time to the year 8200, this 
results in the timekeeper.offs_real being capped at KTIME_MAX ((1LL<<63)-1).


So congrats! While most folks haven't started looking at the 2038 issue 
on 32bit systems, you've already started pushing the internal limits on 
64bit systems :)


Now, while this is obviously problematic, this point confused me for a 
bit:  Prior to the commit bisected in the original mail above, we stored 
the same bad KTIME_MAX data in the 
cpu_base->clock_base[HRTIMER_BASE_REALTIME].offset value.  We just 
didn't read the value from the timekeeping core at each interrupt, and 
the value isn't actually changing when the warning and panic is being 
triggered.


So it was unclear as to why if we're providing the same bad KTIME_MAX 
value to hrtimer_interrupt, why are we seeing problems now and not before?


After hacking the kernel and forcing the persistent clock to return a 
similar bad CMOS value of the year 8200, I could reproduce this and 
finally track it down.


Ends up there's a slight difference in  ktime_get_update_offsets() vs 
ktime_get():


ktime_get() does basically the following:
return timespec_to_ktime(timespec_add(xtime, wall_to_monotonic))

Where as ktime_get_update_offsets does approximately:
return ktime_sub(timespec_to_ktime(xtime), realtime_offset);

The problem is, at boot we set xtime = year 8200 and wall_to_monotonic = 
year -8200,  ktime_get adds both values, mostly nulling the difference 
out (leaving only how long the system has been up), then converts that 
relatively small value to a ktime_t properly without losing any information.


ktime_get_update_offsets however, since it converts xtime (again set to 
some value greater then year 8200), to a ktime, it gets clamped at 
KTIME_MAX, then we subtract realtime_offset, which is _also_ clamped at 
KTIME_MAX, resulting in us always returning almost[1] zero.  This causes 
us to stop expiring timers.


Now, one of the reasons Thomas and I changed the logic was that using 
the precalculated realtime_offset was slightly more efficient then 
re-adding xtime and wall_to_monotonic's components separately. But how 
valuable this unmeasured slight efficiency is vs extra robustness for 
crazy time values is questionable.


Additionally I suspect that your system probably corrects itself in 
early boot via ntpdate, as I'm pretty sure you'd have other strange 
timer behavior trying to run the system with a date larger then KTIME_MAX.


So I suspect we need two fixes here:
1) Fall back to using the full-precision ktime_get() method of 
calculating the current monotonic time in ktime_get_update_offsets to 
avoid what is in effect precision loss with very large timespecs.
2) Validate that time values we accept are smaller the ktime_t before 
using them.


Thomas, does this sound reasonable? Patches to follow shortly.

thanks
-john


[1] So the reality is slightly more complicated, since 
ktime_get_update_offsets actually returns:
return ktime_sub(ktime_add(ktime_set(xtime.tv_sec,0),nsecs), 
realtime_offset);
Which basically means we return some value that increases to ~4seconds 
and then nsec overflows and we loop back to zero.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: build failure after merge of the akpm tree

2012-07-30 Thread Michel Lespinasse
On Mon, Jul 30, 2012 at 9:40 PM, Stephen Rothwell  wrote:
> Hi Andrew,
>
> After merging the akpm tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> net/ceph/osd_client.c: In function 'ceph_osdc_alloc_request':
> net/ceph/osd_client.c:216:2: error: implicit declaration of function 
> 'rb_init_node' [-Werror=implicit-function-declaration]
>
> Caused by commit 753b960e52b7 ("rbtree: empty nodes have no color") from
> the akpm tree interacting with commit cd43045c2de6 ("libceph: initialize
> rb, list nodes in ceph_osd_request") from the ceph tree.
>
> I added the following merge fix patch for today:
>
> From: Stephen Rothwell 
> Date: Tue, 31 Jul 2012 14:37:35 +1000
> Subject: [PATCH] libceph: remove rb_node initialisation
>
> Signed-off-by: Stephen Rothwell 
> ---
>  net/ceph/osd_client.c |1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index ad427e6..06fb7a9 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -213,7 +213,6 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct 
> ceph_osd_client *osdc,
> kref_init(>r_kref);
> init_completion(>r_completion);
> init_completion(>r_safe_completion);
> -   rb_init_node(>r_node);
> INIT_LIST_HEAD(>r_unsafe_item);
> INIT_LIST_HEAD(>r_linger_item);
> INIT_LIST_HEAD(>r_linger_osd);
> --
> 1.7.10.280.gaa39

There is a good chance that this is the right fix, if ceph doesn't use
the RB_CLEAR_NODE / RB_EMPTY_NODE macros or try to directly access the
rb_node fields. I wanted to grab the ceph tree to make sure, however
the first repo I found under that name did not have a commit
cd43045c2de6; where would be the correct place for me to fetch that ?

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2][resend] genirq: export dummy_irq_chip

2012-07-30 Thread Kuninori Morimoto
Export dummy_irq_chip to modules to allow them to do things such as

irq_set_chip_and_handler(virq,
 _irq_chip,
 handle_level_irq);
This fixes

ERROR: "dummy_irq_chip" [drivers/gpio/gpio-pcf857x.ko] undefined!

when gpio-pcf857x.c is being built as a module.

Signed-off-by: Kuninori Morimoto 
---
 kernel/irq/dummychip.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/dummychip.c b/kernel/irq/dummychip.c
index b5fcd96..988dc58 100644
--- a/kernel/irq/dummychip.c
+++ b/kernel/irq/dummychip.c
@@ -6,6 +6,7 @@
  */
 #include 
 #include 
+#include 
 
 #include "internals.h"
 
@@ -57,3 +58,4 @@ struct irq_chip dummy_irq_chip = {
.irq_mask   = noop,
.irq_unmask = noop,
 };
+EXPORT_SYMBOL_GPL(dummy_irq_chip);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2][resend] genirq: export patches

2012-07-30 Thread Kuninori Morimoto

Hi all

These are "resend" of genirq export patches.

Kuninori Morimoto (2):
  genirq: export irq_set_chip_and_handler_name()
  genirq: export dummy_irq_chip


> 
> Hi Thomas
> 
> Could you please teach me current status of these patches ?
> 
> Kuninori Morimoto (2):
>   genirq: export irq_set_chip_and_handler_name()
>   genirq: export dummy_irq_chip
> 
> At Mon, 9 Jul 2012 22:34:23 +0200,
> Linus Walleij wrote:
> > 
> > On Mon, Jul 9, 2012 at 4:04 AM, Kuninori Morimoto
> >  wrote:
> > 
> > > Hi Linus Walleij, Stephen, and Thomas
> > >
> > >> >> > After merging the gpio-lw tree, today's linux-next build (x86_64
> > >> >> > allmodconfig) failed like this:
> > >> >> >
> > >> >> > ERROR: "irq_set_chip_and_handler_name" 
> > >> >> > [drivers/gpio/gpio-pcf857x.ko] undefined!
> > >> >> > ERROR: "dummy_irq_chip" [drivers/gpio/gpio-pcf857x.ko] undefined!
> > >> >>
> > >> >> Thanks, I've dropped the offending patch, Kuninori can you look into 
> > >> >> this and
> > >> >> provide a new patch? It's the second patch from your patch set.
> > >> >
> > >> > OK. I will, but it will be next week.
> > >> > And could you please show me where is your repository/branch ?
> > >>
> > >> http://git.kernel.org/?p=linux/kernel/git/linusw/linux-gpio.git;a=summary
> > >> branch devel/for-next
> > >
> > > In my check, these are export symbol issue.
> > > I think above 2 function/struct were not exported for module.
> > >
> > > Is it poosible to solve this issue by these patches ?
> > 
> > Hm Thomas has to answer to that (and merge the patches, if he
> > likes them).
> > 
> > Yours,
> > Linus Walleij
> 
> 
> Best regards
> ---
> Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2][resend] genirq: export irq_set_chip_and_handler_name()

2012-07-30 Thread Kuninori Morimoto
Export irq_set_chip_and_handler_name() to modules to allow them to
do things such as

irq_set_chip_and_handler();

This fixes

ERROR: "irq_set_chip_and_handler_name" \
  [drivers/gpio/gpio-pcf857x.ko] undefined!

when gpio-pcf857x.c is being built as a module.

Signed-off-by: Kuninori Morimoto 
---
 kernel/irq/chip.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index eebd6d5..57d86d0 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -671,6 +671,7 @@ irq_set_chip_and_handler_name(unsigned int irq, struct 
irq_chip *chip,
irq_set_chip(irq, chip);
__irq_set_handler(irq, handle, 0, name);
 }
+EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name);
 
 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] SUNRPC: protect service sockets lists during per-net shutdown

2012-07-30 Thread NeilBrown
On Tue, 24 Jul 2012 15:40:37 -0400 "J. Bruce Fields" 
wrote:

> On Tue, Jul 03, 2012 at 04:58:57PM +0400, Stanislav Kinsbursky wrote:
> > v3:
> > 1) rebased on 3.5-rc3 kernel.
> > 
> > v2: destruction of currently processing transport added:
> > 1) Added marking of currently processing transports with XPT_CLOSE on 
> > per-net
> > shutdown. These transports will be destroyed in svc_xprt_enqueue() (instead 
> > of
> > enqueueing).
> 
> That worries me:
> 
>   - Why did we originally defer close until svc_recv?

I don't think there was any obscure reason - it was just the natural place do
to it.  In svc_recv we are absolutely sure that the socket is idle.  There
are a number of things we might want to do, so we find the highest-priority
one and do it.  "state machine" pattern?


>   - Are we sure there's no risk to performing it immediately in
> svc_enqueue?  Is it safe to call from the socket callbacks and
> wherever else we call svc_enqueue?

The latter point is the one I'd want to see verified.  If svc_xprt_enqueue
gets called in 'bh' content, and calls svc_delete_xprt which then calls
svc_deferred_dequeue and that takes ->xpt_lock - does that mean that all
lock/unlock of ->xpt_lock needs to be changed to use the _bh variants?

NeilBrown


> 
> And in the past I haven't been good at testing for problems
> here--instead they tend to show up when a use somewhere tries shutting
> down a server that's under load.
> 
> I'll look more closely.  Meanwhile you could split out that change as a
> separate patch and convince me why it's right
> 
> --b.
> 
> > 2) newly created temporary transport in svc_recv() will be destroyed, if 
> > it's
> > "parent" was marked with XPT_CLOSE.
> > 3) spin_lock(>sv_lock) was replaced by spin_lock_bh() in
> > svc_close_net(>sv_lock).
> > 
> > Service sv_tempsocks and sv_permsocks lists are accessible by tasks with
> > different network namespaces, and thus per-net service destruction must be
> > protected.
> > These lists are protected by service sv_lock. So lets wrap list 
> > munipulations
> > with this lock and move tranports destruction outside wrapped area to 
> > prevent
> > deadlocks.
> > 
> > Signed-off-by: Stanislav Kinsbursky 
> > ---
> >  net/sunrpc/svc_xprt.c |   56 
> > ++---
> >  1 files changed, 52 insertions(+), 4 deletions(-)
> > 
> > diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> > index 88f2bf6..4af2114 100644
> > --- a/net/sunrpc/svc_xprt.c
> > +++ b/net/sunrpc/svc_xprt.c
> > @@ -320,6 +320,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
> > struct svc_pool *pool;
> > struct svc_rqst *rqstp;
> > int cpu;
> > +   int destroy = 0;
> >  
> > if (!svc_xprt_has_something_to_do(xprt))
> > return;
> > @@ -338,6 +339,17 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
> >  
> > pool->sp_stats.packets++;
> >  
> > +   /*
> > +* Check transport close flag. It could be marked as closed on per-net
> > +* service shutdown.
> > +*/
> > +   if (test_bit(XPT_CLOSE, >xpt_flags)) {
> > +   /* Don't enqueue transport if it has to be destroyed. */
> > +   dprintk("svc: transport %p have to be closed\n", xprt);
> > +   destroy++;
> > +   goto out_unlock;
> > +   }
> > +
> > /* Mark transport as busy. It will remain in this state until
> >  * the provider calls svc_xprt_received. We update XPT_BUSY
> >  * atomically because it also guards against trying to enqueue
> > @@ -374,6 +386,8 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
> >  
> >  out_unlock:
> > spin_unlock_bh(>sp_lock);
> > +   if (destroy)
> > +   svc_delete_xprt(xprt);
> >  }
> >  EXPORT_SYMBOL_GPL(svc_xprt_enqueue);
> >  
> > @@ -714,6 +728,13 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
> > __module_get(newxpt->xpt_class->xcl_owner);
> > svc_check_conn_limits(xprt->xpt_server);
> > spin_lock_bh(>sv_lock);
> > +   if (test_bit(XPT_CLOSE, >xpt_flags)) {
> > +   dprintk("svc_recv: found XPT_CLOSE on 
> > listener\n");
> > +   set_bit(XPT_DETACHED, >xpt_flags);
> > +   spin_unlock_bh(>sp_lock);
> > +   svc_delete_xprt(newxpt);
> > +   goto out_closed;
> > +   }
> > set_bit(XPT_TEMP, >xpt_flags);
> > list_add(>xpt_list, >sv_tempsocks);
> > serv->sv_tmpcnt++;
> > @@ -739,6 +760,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
> > len = xprt->xpt_ops->xpo_recvfrom(rqstp);
> > dprintk("svc: got len=%d\n", len);
> > }
> > +out_closed:
> > svc_xprt_received(xprt);
> >  
> > /* No data, incomplete (TCP) read, or accept() */
> > @@ -936,6 +958,7 @@ static void svc_clear_pools(struct svc_serv *serv, 
> > struct net 

linux-next: Tree for July 31

2012-07-30 Thread Stephen Rothwell
Hi all,

Please do not add anything to linux-next included branches/series that is
destined for v3.7 until after v3.6-rc1 is released.

Reminder: do not rebase your branches before asking Linus to pull them ...

Changes since 20120730:

Dropped tree: bjdooks-i2c (complex conflict against old code)

Linus' tree gained a build failure for which I cherry-picked a fix from
later in his tree.

The ceph tree gained a conflict against Linus' treee.

The xfs tree lost its conflicts.

The bjdooks-i2c tree gained a conflict against Linus' tree for which I
dropped the bjdooks-i2c tree.

The i2c-embedded tree lost its conflicts.

The v4l-dvb tree lost its build fix patch.

The rr tree lost its conflict.

The mfd tree lost its conflicts.

The kvmn-ppc tree lost its conflict.

The tty tree still has its build failures for which I have disabled 2
staging drivers and applied a patch.

The pwm tree lost its conflicts.

I have still reverted 3 commits from the signal tree at the request of the
arm maintainer.

The akpm tree gained a conflict against the nfs tree and a build failure
involving the ceph tree for which I applied a merge fix patch.



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" as mentioned in the FAQ on the wiki
(see below).

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log files
in the Next directory.  Between each merge, the tree was built with
a ppc64_defconfig for powerpc and an allmodconfig for x86_64. After the
final fixups (if any), it is also built with powerpc allnoconfig (32 and
64 bit), ppc44x_defconfig and allyesconfig (minus
CONFIG_PROFILE_ALL_BRANCHES - this fails its final link) and i386, sparc,
sparc64 and arm defconfig. These builds also have
CONFIG_ENABLE_WARN_DEPRECATED, CONFIG_ENABLE_MUST_CHECK and
CONFIG_DEBUG_INFO disabled when necessary.

Below is a summary of the state of the merge.

We are up to 197 trees (counting Linus' and 26 trees of patches pending
for Linus' tree), more are welcome (even if they are currently empty).
Thanks to those who have contributed, and to those who haven't, please do.

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

There is a wiki covering stuff to do with linux-next at
http://linux.f-seidel.de/linux-next/pmwiki/ .  Thanks to Frank Seidel.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

$ git checkout master
$ git reset --hard stable
Merging origin/master (37cd960 Merge tag 'for-linus-v3.6-rc1' of 
git://oss.sgi.com/xfs/xfs)
Merging fixes/master (9023a40 Merge tag 'mmc-fixes-for-3.5-rc4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc)
Merging kbuild-current/rc-fixes (f8f5701 Linux 3.5-rc1)
Merging arm-current/fixes (6662372 ARM: Fix undefined instruction exception 
handling)
Merging m68k-current/for-linus (1525e06 m68k/apollo: Rename "timer" to 
"apollo_timer")
Merging powerpc-merge/merge (bac821a powerpc/ftrace: Trace function graph entry 
before updating index)
Merging sparc/master (b387e41 Merge branch 'merge' of 
git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc)
Merging net/master (5a0d513 bridge: make port attributes const)
Merging sound-current/for-linus (e5b3542 ALSA: es1688 - freeup resources on 
init failure)
Merging pci-current/for-linus (314489b Merge tag 'fixes-for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc)
Merging wireless/master (9dbf5f5 bcma: add missing iounmap on error path)
Merging driver-core.current/driver-core-linus (84a1caf Linux 3.5-rc7)
Merging tty.current/tty-linus (38bd2a1 pch_uart: Fix parity setting issue)
Merging usb.current/usb-linus (84a1caf Linux 3.5-rc7)
Merging staging.current/staging-linus (6887a41 Linux 3.5-rc5)
Merging char-misc.current/char-misc-linus (84a1caf Linux 3.5-rc7)
Merging input-current/for-linus (cf45b5a Merge branch 'next' into for-linus)
Merging md-current/for-linus (58e94ae md/raid1: close some possible races on 
write errors during resync)
Merging audit-current/for-linus (c158a35 audit: no leading space in 
audit_log_d_path prefix)
Merging crypto-current/master (76f16f8 crypto: hifn_795x - fix 64bit division 
and undefined __divdi3 on 32bit archs)
Merging ide/master (39a50b4 Merge branch 'hfsplus')
Merging dwmw2/master (244dc4e Merge 
git://git.infradead.org/users

Re: [PATCH] uprobes: don't enable/disable signle step if the user did it

2012-07-30 Thread Srikar Dronamraju
* Oleg Nesterov  [2012-07-30 16:16:38]:

> On 07/30, Ananth N Mavinakayanahalli wrote:
> >
> > On Thu, Jul 26, 2012 at 05:20:43PM +0200, Sebastian Andrzej Siewior wrote:
> > > If someone is using single stepping over uprobe brackpoint then after
> > > we pass the uprobe single step, single stepping is disabled and the user
> > > who enebaled them in the first place does not know anything about this.
> > >
> > > This patch avoids enabling / disabling the single step mode if it is
> > > already enabled.
> >
> > This could happen any time 2 different entities call the
> > user_(en/dis)able_single_step() helpers on the same thread.
> 
> Yes. But nobody except ptrace should do use these helpers, I think.
> 
> > Wouldn't the right way to fix it be to teach these helpers
> > to honor what the TIF_SINGLESTEP
> 
> Well, I think uprobes should not use TIF_SINGLESTEP at all. This
> bit is (mostly) needed to handle the stepping over syscall. But
> I guess you didn't actually mean TIF_SINGLESTEP...
> 
> > flag setting was in the first place?
> 
> Perhaps, but I don't think so. If nothing else, we do not want
> to add the new counter/whatever in task_struct, while uprobes
> already has uprobe_task which can "remember" the state of _TF
> bit and more.
> 
> And this can't solve other problems. Suppose that gdb does
> PTRACE_SINGLESTEP but the original "popf" insn was already replaced
> by "int3", this will obviously confuse is_setting_trap_flag().
> 
> And we need the additional SIGTRAP from handle_singlestep().
> And we have more problems with DEBUGCTLMSR_BTF. And we do
> not want access_process_vm() from uprobes code.
> 
> So I think we need arch_uprobe_*able_step(struct uprobe_task *utask).
> Ignoring all problems except the one this patch tries to fix, x86
> can simply do:
> 
>   arch_uprobe_enble_step(utask, struct arch_uprobe *auprobe)
>   {
>   utask->clear_tf =
>   !(regs->flags & X86_EFLAGS_TF) &&
>   (auprobe->insn != "popf");
>   regs->flags |= X86_EFLAGS_TF;
>   }
> 
>   arch_uprobe_disable_step(utask)
>   {
>   if (utask->clear_tf)
>   regs->flags &= ~X86_EFLAGS_TF;
>   }
> 

We were using something similar to this approach. [though we were still
using TIF_SINGLESTEP flag]. However this was all changed based on
feedback from Roland and Peter.

Here is the pointer to the discussion.

https://lkml.org/lkml/2011/1/27/283

> Fortunately, we can never race with gdb/enable_step(), and we do
> not care why X86_EFLAGS_TF was set, and we do not care about
> TIF_SINGLESTEP/TIF_FORCED_TF.
> 
> However. This all needs more discussion (and help from Roland I guess).
> 
> Sebastian, I think your patch is simple and certainly makes the things
> better, just it is not correct (you already realized you can't use
> uprobe->flags) and it is not arch-friendly.
> 
> I'd suggest you to make 2 patches:
> 
>   - 1/2 creates arch_uprobe_*_step(...) __weak helpers in
> kernel/events/uprobes.c which simply call
> user_*_single_step() and updates the callers
> 
> Not strictly necessary, but imho makes sense...
> 
>   - 2/2 adds the x86 implementation in arch/x86/kernel/uprobes.c
> which still uses user_*_single_step() but checks
> TIF_SINGLESTEP. As your patch does, but you should use
> utask, not uprobe.
> 
> IOW, I simply suggest to make your patch x86-specific. Then we
> will try to do more fixes/improvements.
> 
> Sebastian, Ananth, what do you think?
> 
> Oleg.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: build failure after merge of the final tree

2012-07-30 Thread Stephen Rothwell
Hi all,

After merging the final tree, today's linux-next build (powerpc
allyesconfig) failed like this:

drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe':
drivers/regulator/s5m8767.c:575:2: error: implicit declaration of function 
's5m_reg_write' [-Werror=implicit-function-declaration]

Caused by a mismerge in Linus' tree between commits c848bc8538cd
("regulator: s5m8767a: Support AP watchdog reset operation") and
63063bfbffe9 ("mfd: Modify samsung mfd driver for common api").

Fixed by commit 938e05bf1313 ("regulator: Fix an s5m8767 build failure")
from Linus' tree which I have cherry picked for today.

This was reported a couple of weeks ago when it caused a merge conflict
in linux-next.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpDLatn5vhff.pgp
Description: PGP signature


Re: [GIT PULL (PATCH 0/4)] VFIO driver for v3.6

2012-07-30 Thread Linus Torvalds
On Mon, Jul 30, 2012 at 4:17 PM, Alex Williamson
 wrote:
>
> I'm pretty anxious to find out as well.  Linus, ping, any thoughts on
> including this in 3.6?  Thanks,

I just pulled it, but then I unpulled again when I realized it's not a
signed tag and it's on github.

Please, people. Do tagged releases with proper signatures if you're
not using kernel.org or other controlled servers. In fact, I prefer
signed tags even if you *do* use kernel.org etc.

 Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 00/73] 3.2.25-stable review

2012-07-30 Thread Ben Hutchings
This is the start of the stable review cycle for the 3.2.25 release.
There are 73 patches in this series, which will be posted as responses
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Thu Aug  2 10:00:00 UTC 2012.
Anything received after that time might be too late.

A combined patch relative to 3.2.24 will be posted as an additional
response to this, and the diffstat can be found below.

Ben.

-
 Makefile |4 +-
 arch/arm/mach-omap2/opp.c|3 +-
 arch/powerpc/include/asm/reg.h   |3 +-
 arch/powerpc/kernel/ftrace.c |   12 +-
 arch/s390/kernel/processor.c |2 +
 arch/s390/kernel/smp.c   |3 -
 arch/x86/kernel/microcode_core.c |   31 +++--
 arch/x86/pci/fixup.c |   17 +++
 block/blk-core.c |6 +-
 block/blk-exec.c |2 +-
 block/blk-sysfs.c|4 +-
 block/blk-throttle.c |4 +-
 block/blk.h  |2 +-
 drivers/acpi/ac.c|4 +-
 drivers/gpu/drm/nouveau/nva3_copy.fuc|4 +-
 drivers/gpu/drm/nouveau/nva3_copy.fuc.h  |   94 +-
 drivers/gpu/drm/nouveau/nvc0_copy.fuc.h  |   87 -
 drivers/gpu/drm/radeon/atombios_dp.c |   10 +-
 drivers/gpu/drm/radeon/radeon_connectors.c   |   35 --
 drivers/gpu/drm/radeon/radeon_cursor.c   |8 +-
 drivers/gpu/drm/radeon/radeon_object.c   |3 +-
 drivers/iommu/amd_iommu.c|   10 +-
 drivers/media/video/cx25821/cx25821-core.c   |3 -
 drivers/media/video/cx25821/cx25821.h|2 +-
 drivers/mmc/host/sdhci-pci.c |1 +
 drivers/net/ethernet/realtek/r8169.c |1 +
 drivers/net/wireless/mwifiex/cfg80211.c  |4 +-
 drivers/net/wireless/rt2x00/rt2800usb.c  |   23 +++-
 drivers/net/wireless/rtlwifi/rtl8192de/phy.c |6 +-
 drivers/scsi/hosts.c |7 +-
 drivers/scsi/libsas/sas_expander.c   |   47 +++
 drivers/scsi/scsi.c  |8 +-
 drivers/scsi/scsi_error.c|   14 +++
 drivers/scsi/scsi_lib.c  |   43 +++
 drivers/scsi/scsi_priv.h |1 -
 drivers/scsi/scsi_scan.c |3 +
 drivers/scsi/scsi_sysfs.c|   46 ---
 drivers/target/iscsi/iscsi_target.c  |   22 +---
 drivers/target/iscsi/iscsi_target_core.h |2 -
 drivers/target/iscsi/iscsi_target_login.c|   60 +
 drivers/target/target_core_cdb.c |   43 +--
 drivers/target/target_core_transport.c   |   10 ++
 drivers/usb/core/devio.c |   10 +-
 drivers/usb/gadget/u_ether.c |   12 +-
 drivers/usb/serial/option.c  |8 +-
 fs/btrfs/async-thread.c  |9 +-
 fs/btrfs/disk-io.c   |5 +-
 fs/cifs/cifssmb.c|   30 +
 fs/ext4/balloc.c |3 +-
 fs/ext4/bitmap.c |   12 +-
 fs/ext4/ext4.h   |6 +-
 fs/ext4/ialloc.c |3 +-
 fs/ext4/inode.c  |   41 --
 fs/ext4/resize.c |5 +
 fs/ext4/super.c  |  174 ++
 fs/hugetlbfs/inode.c |3 +-
 fs/locks.c   |6 +-
 fs/nfs/internal.h|2 +-
 fs/nfs/write.c   |4 +-
 fs/udf/super.c   |2 +-
 include/linux/blkdev.h   |1 +
 include/linux/cpu.h  |5 +-
 include/linux/cpuset.h   |   47 +++
 include/linux/fs.h   |   11 +-
 include/linux/init_task.h|8 ++
 include/linux/migrate.h  |   23 +++-
 include/linux/mmzone.h   |2 +
 include/linux/sched.h|3 +-
 include/target/target_core_base.h|1 +
 kernel/cpuset.c  |   43 ++-
 kernel/fork.c|3 +
 kernel/power/hibernate.c |6 +
 kernel/power/suspend.c   |3 +
 kernel/sched.c   |   86 +++--
 kernel/sched_fair.c  |2 +-
 kernel/time/tick-sched.c |1 +
 kernel/workqueue.c   |   38 +-
 mm/compaction.c  |4 +-
 mm/filemap.c   

[ 08/73] mm: vmscan: do not OOM if aborting reclaim to start compaction

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit 7335084d446b83cbcb15da80497d03f0c1dc9e21 upstream.

Stable note: Not tracked in Bugzilla. This patch makes later patches
easier to apply but otherwise has little to justify it. The
problem it fixes was never observed but the source of the
theoretical problem did not exist for very long.

During direct reclaim it is possible that reclaim will be aborted so that
compaction can be attempted to satisfy a high-order allocation.  If this
decision is made before any pages are reclaimed, it is possible that 0 is
returned to the page allocator potentially triggering an OOM.  This has
not been observed but it is a possibility so this patch addresses it.

Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel 
Cc: Andrea Arcangeli 
Cc: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2284,6 +2284,7 @@ static unsigned long do_try_to_free_page
struct zoneref *z;
struct zone *zone;
unsigned long writeback_threshold;
+   bool should_abort_reclaim;
 
get_mems_allowed();
delayacct_freepages_start();
@@ -2295,7 +2296,8 @@ static unsigned long do_try_to_free_page
sc->nr_scanned = 0;
if (!priority)
disable_swap_token(sc->mem_cgroup);
-   if (shrink_zones(priority, zonelist, sc))
+   should_abort_reclaim = shrink_zones(priority, zonelist, sc);
+   if (should_abort_reclaim)
break;
 
/*
@@ -2363,6 +2365,10 @@ out:
if (oom_killer_disabled)
return 0;
 
+   /* Aborting reclaim to try compaction? don't OOM, then */
+   if (should_abort_reclaim)
+   return 1;
+
/* top priority shrink_zones still had more to do? don't OOM, then */
if (scanning_global_lru(sc) && !all_unreclaimable(zonelist, sc))
return 1;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 06/73] mm: compaction: introduce sync-light migration for use by compaction

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit a6bc32b899223a877f595ef9ddc1e89ead5072b8 upstream.

Stable note: Not tracked in Buzilla. This was part of a series that
reduced interactivity stalls experienced when THP was enabled.
These stalls were particularly noticable when copying data
to a USB stick but the experiences for users varied a lot.

This patch adds a lightweight sync migrate operation MIGRATE_SYNC_LIGHT
mode that avoids writing back pages to backing storage.  Async compaction
maps to MIGRATE_ASYNC while sync compaction maps to MIGRATE_SYNC_LIGHT.
For other migrate_pages users such as memory hotplug, MIGRATE_SYNC is
used.

This avoids sync compaction stalling for an excessive length of time,
particularly when copying files to a USB stick where there might be a
large number of dirty pages backed by a filesystem that does not support
->writepages.

[aarca...@redhat.com: This patch is heavily based on Andrea's work]
[a...@linux-foundation.org: fix fs/nfs/write.c build]
[a...@linux-foundation.org: fix fs/btrfs/disk-io.c build]
Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel 
Cc: Andrea Arcangeli 
Cc: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 fs/btrfs/disk-io.c  |5 +--
 fs/hugetlbfs/inode.c|2 +-
 fs/nfs/internal.h   |2 +-
 fs/nfs/write.c  |4 +--
 include/linux/fs.h  |6 ++--
 include/linux/migrate.h |   23 +++---
 mm/compaction.c |2 +-
 mm/memory-failure.c |2 +-
 mm/memory_hotplug.c |2 +-
 mm/mempolicy.c  |2 +-
 mm/migrate.c|   78 ++-
 11 files changed, 76 insertions(+), 52 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1375494..d852566 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -872,7 +872,8 @@ static int btree_submit_bio_hook(struct inode *inode, int 
rw, struct bio *bio,
 
 #ifdef CONFIG_MIGRATION
 static int btree_migratepage(struct address_space *mapping,
-   struct page *newpage, struct page *page, bool sync)
+   struct page *newpage, struct page *page,
+   enum migrate_mode mode)
 {
/*
 * we can't safely write a btree page from here,
@@ -887,7 +888,7 @@ static int btree_migratepage(struct address_space *mapping,
if (page_has_private(page) &&
!try_to_release_page(page, GFP_KERNEL))
return -EAGAIN;
-   return migrate_page(mapping, newpage, page, sync);
+   return migrate_page(mapping, newpage, page, mode);
 }
 #endif
 
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 06fd460..1e85a7a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -584,7 +584,7 @@ static int hugetlbfs_set_page_dirty(struct page *page)
 
 static int hugetlbfs_migrate_page(struct address_space *mapping,
struct page *newpage, struct page *page,
-   bool sync)
+   enum migrate_mode mode)
 {
int rc;
 
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 114398a..8102db9 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -332,7 +332,7 @@ void nfs_commit_release_pages(struct nfs_write_data *data);
 
 #ifdef CONFIG_MIGRATION
 extern int nfs_migrate_page(struct address_space *,
-   struct page *, struct page *, bool);
+   struct page *, struct page *, enum migrate_mode);
 #else
 #define nfs_migrate_page NULL
 #endif
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 889e98b..834f0fe 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1688,7 +1688,7 @@ out_error:
 
 #ifdef CONFIG_MIGRATION
 int nfs_migrate_page(struct address_space *mapping, struct page *newpage,
-   struct page *page, bool sync)
+   struct page *page, enum migrate_mode mode)
 {
/*
 * If PagePrivate is set, then the page is currently associated with
@@ -1703,7 +1703,7 @@ int nfs_migrate_page(struct address_space *mapping, 
struct page *newpage,
 
nfs_fscache_release_page(page, GFP_KERNEL);
 
-   return migrate_page(mapping, newpage, page, sync);
+   return migrate_page(mapping, newpage, page, mode);
 }
 #endif
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b92b73d..e694bd4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -525,6 +525,7 @@ enum positive_aop_returns {
 struct page;
 struct address_space;
 struct writeback_control;
+enum migrate_mode;
 
 struct iov_iter {
const struct iovec *iov;
@@ -614,7 +615,7 @@ struct address_space_operations {
 * is false, it must not block.
 */
int (*migratepage) (struct address_space *,
- 

[ 07/73] mm: vmscan: when reclaiming for compaction, ensure there are sufficient free pages available

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit fe4b1b244bdb96136855f2c694071cb09d140766 upstream.

Stable note: Not tracked on Bugzilla. THP and compaction was found to
aggressively reclaim pages and stall systems under different
situations that was addressed piecemeal over time. This patch
addresses a problem where the fix regressed THP allocation
success rates.

In commit e0887c19 ("vmscan: limit direct reclaim for higher order
allocations"), Rik noted that reclaim was too aggressive when THP was
enabled.  In his initial patch he used the number of free pages to decide
if reclaim should abort for compaction.  My feedback was that reclaim and
compaction should be using the same logic when deciding if reclaim should
be aborted.

Unfortunately, this had the effect of reducing THP success rates when the
workload included something like streaming reads that continually
allocated pages.  The window during which compaction could run and return
a THP was too small.

This patch combines Rik's two patches together.  compaction_suitable() is
still used to decide if reclaim should be aborted to allow compaction is
used.  However, it will also ensure that there is a reasonable buffer of
free pages available.  This improves upon the THP allocation success rates
but bounds the number of pages that are freed for compaction.

Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel
Cc: Andrea Arcangeli 
Cc: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |   44 +++-
 1 file changed, 39 insertions(+), 5 deletions(-)

--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2119,6 +2119,42 @@ restart:
throttle_vm_writeout(sc->gfp_mask);
 }
 
+/* Returns true if compaction should go ahead for a high-order request */
+static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
+{
+   unsigned long balance_gap, watermark;
+   bool watermark_ok;
+
+   /* Do not consider compaction for orders reclaim is meant to satisfy */
+   if (sc->order <= PAGE_ALLOC_COSTLY_ORDER)
+   return false;
+
+   /*
+* Compaction takes time to run and there are potentially other
+* callers using the pages just freed. Continue reclaiming until
+* there is a buffer of free pages available to give compaction
+* a reasonable chance of completing and allocating the page
+*/
+   balance_gap = min(low_wmark_pages(zone),
+   (zone->present_pages + KSWAPD_ZONE_BALANCE_GAP_RATIO-1) /
+   KSWAPD_ZONE_BALANCE_GAP_RATIO);
+   watermark = high_wmark_pages(zone) + balance_gap + (2UL << sc->order);
+   watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0);
+
+   /*
+* If compaction is deferred, reclaim up to a point where
+* compaction will have a chance of success when re-enabled
+*/
+   if (compaction_deferred(zone))
+   return watermark_ok;
+
+   /* If compaction is not ready to start, keep reclaiming */
+   if (!compaction_suitable(zone, sc->order))
+   return false;
+
+   return watermark_ok;
+}
+
 /*
  * This is the direct reclaim path, for page-allocating processes.  We only
  * try to reclaim pages from zones which will satisfy the caller's allocation
@@ -2136,8 +2172,8 @@ restart:
  * scan then give up on it.
  *
  * This function returns true if a zone is being reclaimed for a costly
- * high-order allocation and compaction is either ready to begin or deferred.
- * This indicates to the caller that it should retry the allocation or fail.
+ * high-order allocation and compaction is ready to begin. This indicates to
+ * the caller that it should retry the allocation or fail.
  */
 static bool shrink_zones(int priority, struct zonelist *zonelist,
struct scan_control *sc)
@@ -2171,9 +2207,7 @@ static bool shrink_zones(int priority, s
 * noticable problem, like transparent huge page
 * allocations.
 */
-   if (sc->order > PAGE_ALLOC_COSTLY_ORDER &&
-   (compaction_suitable(zone, sc->order) ||
-compaction_deferred(zone))) {
+   if (compaction_ready(zone, sc)) {
should_abort_reclaim = true;
continue;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[ 04/73] mm: page allocator: do not call direct reclaim for THP allocations while compaction is deferred

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit 66199712e9eef5aede09dbcd9dfff87798a66917 upstream.

Stable note: Not tracked in Buzilla. This was part of a series that
reduced interactivity stalls experienced when THP was enabled.

If compaction is deferred, direct reclaim is used to try to free enough
pages for the allocation to succeed.  For small high-orders, this has a
reasonable chance of success.  However, if the caller has specified
__GFP_NO_KSWAPD to limit the disruption to the system, it makes more sense
to fail the allocation rather than stall the caller in direct reclaim.
This patch skips direct reclaim if compaction is deferred and the caller
specifies __GFP_NO_KSWAPD.

Async compaction only considers a subset of pages so it is possible for
compaction to be deferred prematurely and not enter direct reclaim even in
cases where it should.  To compensate for this, this patch also defers
compaction only if sync compaction failed.

Signed-off-by: Mel Gorman 
Acked-by: Minchan Kim 
Reviewed-by: Rik van Riel
Cc: Andrea Arcangeli 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/page_alloc.c |   45 +++--
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9404b38..cb5723c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1981,14 +1981,20 @@ static struct page *
 __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
struct zonelist *zonelist, enum zone_type high_zoneidx,
nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
-   int migratetype, unsigned long *did_some_progress,
-   bool sync_migration)
+   int migratetype, bool sync_migration,
+   bool *deferred_compaction,
+   unsigned long *did_some_progress)
 {
struct page *page;
 
-   if (!order || compaction_deferred(preferred_zone))
+   if (!order)
return NULL;
 
+   if (compaction_deferred(preferred_zone)) {
+   *deferred_compaction = true;
+   return NULL;
+   }
+
current->flags |= PF_MEMALLOC;
*did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask,
nodemask, sync_migration);
@@ -2016,7 +2022,13 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned 
int order,
 * but not enough to satisfy watermarks.
 */
count_vm_event(COMPACTFAIL);
-   defer_compaction(preferred_zone);
+
+   /*
+* As async compaction considers a subset of pageblocks, only
+* defer if the failure was a sync compaction failure.
+*/
+   if (sync_migration)
+   defer_compaction(preferred_zone);
 
cond_resched();
}
@@ -2028,8 +2040,9 @@ static inline struct page *
 __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
struct zonelist *zonelist, enum zone_type high_zoneidx,
nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone,
-   int migratetype, unsigned long *did_some_progress,
-   bool sync_migration)
+   int migratetype, bool sync_migration,
+   bool *deferred_compaction,
+   unsigned long *did_some_progress)
 {
return NULL;
 }
@@ -2179,6 +2192,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
unsigned long pages_reclaimed = 0;
unsigned long did_some_progress;
bool sync_migration = false;
+   bool deferred_compaction = false;
 
/*
 * In the slowpath, we sanity check order to avoid ever trying to
@@ -2259,12 +2273,22 @@ rebalance:
zonelist, high_zoneidx,
nodemask,
alloc_flags, preferred_zone,
-   migratetype, _some_progress,
-   sync_migration);
+   migratetype, sync_migration,
+   _compaction,
+   _some_progress);
if (page)
goto got_pg;
sync_migration = true;
 
+   /*
+* If compaction is deferred for high-order allocations, it is because
+* sync compaction recently failed. In this is the case and the caller
+* has requested the system not be heavily disrupted, fail the
+* allocation now instead of entering direct reclaim
+*/
+   if (deferred_compaction && (gfp_mask & __GFP_NO_KSWAPD))
+   goto nopage;
+
/* Try direct reclaim and then allocating */
page = 

[ 09/73] mm: vmscan: check if reclaim should really abort even if compaction_ready() is true for one zone

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit 0cee34fd72c582b4f8ad8ce00645b75fb4168199 upstream.

Stable note: Not tracked on Bugzilla. THP and compaction was found to
aggressively reclaim pages and stall systems under different
situations that was addressed piecemeal over time.

If compaction can proceed for a given zone, shrink_zones() does not
reclaim any more pages from it.  After commit [e0c2327: vmscan: abort
reclaim/compaction if compaction can proceed], do_try_to_free_pages()
tries to finish as soon as possible once one zone can compact.

This was intended to prevent slabs being shrunk unnecessarily but there
are side-effects.  One is that a small zone that is ready for compaction
will abort reclaim even if the chances of successfully allocating a THP
from that zone is small.  It also means that reclaim can return too early
even though sc->nr_to_reclaim pages were not reclaimed.

This partially reverts the commit until it is proven that slabs are really
being shrunk unnecessarily but preserves the check to return 1 to avoid
OOM if reclaim was aborted prematurely.

[aarca...@redhat.com: This patch replaces a revert from Andrea]
Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel 
Cc: Andrea Arcangeli 
Cc: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |   19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2173,7 +2173,8 @@ static inline bool compaction_ready(stru
  *
  * This function returns true if a zone is being reclaimed for a costly
  * high-order allocation and compaction is ready to begin. This indicates to
- * the caller that it should retry the allocation or fail.
+ * the caller that it should consider retrying the allocation instead of
+ * further reclaim.
  */
 static bool shrink_zones(int priority, struct zonelist *zonelist,
struct scan_control *sc)
@@ -2182,7 +2183,7 @@ static bool shrink_zones(int priority, s
struct zone *zone;
unsigned long nr_soft_reclaimed;
unsigned long nr_soft_scanned;
-   bool should_abort_reclaim = false;
+   bool aborted_reclaim = false;
 
for_each_zone_zonelist_nodemask(zone, z, zonelist,
gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -2208,7 +2209,7 @@ static bool shrink_zones(int priority, s
 * allocations.
 */
if (compaction_ready(zone, sc)) {
-   should_abort_reclaim = true;
+   aborted_reclaim = true;
continue;
}
}
@@ -2230,7 +2231,7 @@ static bool shrink_zones(int priority, s
shrink_zone(priority, zone, sc);
}
 
-   return should_abort_reclaim;
+   return aborted_reclaim;
 }
 
 static bool zone_reclaimable(struct zone *zone)
@@ -2284,7 +2285,7 @@ static unsigned long do_try_to_free_page
struct zoneref *z;
struct zone *zone;
unsigned long writeback_threshold;
-   bool should_abort_reclaim;
+   bool aborted_reclaim;
 
get_mems_allowed();
delayacct_freepages_start();
@@ -2296,9 +2297,7 @@ static unsigned long do_try_to_free_page
sc->nr_scanned = 0;
if (!priority)
disable_swap_token(sc->mem_cgroup);
-   should_abort_reclaim = shrink_zones(priority, zonelist, sc);
-   if (should_abort_reclaim)
-   break;
+   aborted_reclaim = shrink_zones(priority, zonelist, sc);
 
/*
 * Don't shrink slabs when reclaiming memory from
@@ -2365,8 +2364,8 @@ out:
if (oom_killer_disabled)
return 0;
 
-   /* Aborting reclaim to try compaction? don't OOM, then */
-   if (should_abort_reclaim)
+   /* Aborted reclaim to try compaction? don't OOM, then */
+   if (aborted_reclaim)
return 1;
 
/* top priority shrink_zones still had more to do? don't OOM, then */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 17/73] [SCSI] Fix NULL dereferences in scsi_cmd_to_driver

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mark Rustad 

commit 222a806af830fda34ad1f6bc991cd226916de060 upstream.

Avoid crashing if the private_data pointer happens to be NULL. This has
been seen sometimes when a host reset happens, notably when there are
many LUNs:

host3: Assigned Port ID 0c1601
scsi host3: libfc: Host reset succeeded on port (0c1601)
BUG: unable to handle kernel NULL pointer dereference at 0350
IP: [] scsi_send_eh_cmnd+0x58/0x3a0

Process scsi_eh_3 (pid: 4144, threadinfo 88030920c000, task 
880326b160c0)
Stack:
 00010372e6ba 0282 27100920dca0 a0038ee0
  00030003 88030920dc80 88030920dc80
 0002000e 000a4000 8803242f7760 88031326ed80
Call Trace:
 [] ? lock_timer_base+0x70/0x70
 [] scsi_eh_tur+0x3e/0xc0
 [] scsi_eh_test_devices+0x76/0x170
 [] scsi_eh_host_reset+0x85/0x160
 [] scsi_eh_ready_devs+0x91/0x110
 [] scsi_unjam_host+0xed/0x1f0
 [] scsi_error_handler+0x1a8/0x200
 [] ? scsi_unjam_host+0x1f0/0x1f0
 [] kthread+0x9e/0xb0
 [] kernel_thread_helper+0x4/0x10
 [] ? kthread_freezable_should_stop+0x70/0x70
 [] ? gs_change+0x13/0x13
Code: 25 28 00 00 00 48 89 45 c8 31 c0 48 8b 87 80 00 00 00 48 8d b5 60 ff ff 
ff 89 d1 48 89 fb 41 89 d6 4c 89 fa 48 8b 80 b8 00 00 00
 <48> 8b 80 50 03 00 00 48 8b 00 48 89 85 38 ff ff ff 48 8b 07 4c
RIP  [] scsi_send_eh_cmnd+0x58/0x3a0
 RSP 
CR2: 0350


Signed-off-by: Mark Rustad 
Tested-by: Marcus Dennis 
Signed-off-by: James Bottomley 
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings 
---
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -785,7 +785,13 @@ static void scsi_done(struct scsi_cmnd *
 /* Move this to a header if it becomes more generally useful */
 static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 {
-   return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
+   struct scsi_driver **sdp;
+
+   sdp = (struct scsi_driver **)cmd->request->rq_disk->private_data;
+   if (!sdp)
+   return NULL;
+
+   return *sdp;
 }
 
 /**


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 16/73] mm/hugetlb: fix warning in alloc_huge_page/dequeue_huge_page_vma

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Konstantin Khlebnikov 

commit b1c12cbcd0a02527c180a862e8971e249d3b347d upstream.

Stable note: Not tracked in Bugzilla. [get|put]_mems_allowed() is extremely
expensive and severely impacted page allocator performance. This
is part of a series of patches that reduce page allocator overhead.

Fix a gcc warning (and bug?) introduced in cc9a6c877 ("cpuset: mm: reduce
large amounts of memory barrier related damage v3")

Local variable "page" can be uninitialized if the nodemask from vma policy
does not intersects with nodemask from cpuset.  Even if it doesn't happens
it is better to initialize this variable explicitly than to introduce
a kernel oops in a weird corner case.

mm/hugetlb.c: In function `alloc_huge_page':
mm/hugetlb.c:1135:5: warning: `page' may be used uninitialized in this function

Signed-off-by: Konstantin Khlebnikov 
Acked-by: Mel Gorman 
Acked-by: David Rientjes 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Mel Gorman 
Signed-off-by: Ben Hutchings 
---
 mm/hugetlb.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index cd65cb1..5a16423 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -532,7 +532,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
struct vm_area_struct *vma,
unsigned long address, int avoid_reserve)
 {
-   struct page *page;
+   struct page *page = NULL;
struct mempolicy *mpol;
nodemask_t *nodemask;
struct zonelist *zonelist;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 03/73] mm: compaction: determine if dirty pages can be migrated without blocking within ->migratepage

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit b969c4ab9f182a6e1b2a0848be349f99714947b0 upstream.

Stable note: Not tracked in Bugzilla. A fix aimed at preserving page
aging information by reducing LRU list churning had the side-effect
of reducing THP allocation success rates. This was part of a series
to restore the success rates while preserving the reclaim fix.

Asynchronous compaction is used when allocating transparent hugepages to
avoid blocking for long periods of time.  Due to reports of stalling,
there was a debate on disabling synchronous compaction but this severely
impacted allocation success rates.  Part of the reason was that many dirty
pages are skipped in asynchronous compaction by the following check;

if (PageDirty(page) && !sync &&
mapping->a_ops->migratepage != migrate_page)
rc = -EBUSY;

This skips over all mapping aops using buffer_migrate_page() even though
it is possible to migrate some of these pages without blocking.  This
patch updates the ->migratepage callback with a "sync" parameter.  It is
the responsibility of the callback to fail gracefully if migration would
block.

Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel 
Cc: Andrea Arcangeli 
Cc: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 fs/btrfs/disk-io.c  |4 +-
 fs/hugetlbfs/inode.c|3 +-
 fs/nfs/internal.h   |2 +-
 fs/nfs/write.c  |4 +-
 include/linux/fs.h  |9 ++--
 include/linux/migrate.h |2 +-
 mm/migrate.c|  129 +--
 7 files changed, 106 insertions(+), 47 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f99a099..1375494 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -872,7 +872,7 @@ static int btree_submit_bio_hook(struct inode *inode, int 
rw, struct bio *bio,
 
 #ifdef CONFIG_MIGRATION
 static int btree_migratepage(struct address_space *mapping,
-   struct page *newpage, struct page *page)
+   struct page *newpage, struct page *page, bool sync)
 {
/*
 * we can't safely write a btree page from here,
@@ -887,7 +887,7 @@ static int btree_migratepage(struct address_space *mapping,
if (page_has_private(page) &&
!try_to_release_page(page, GFP_KERNEL))
return -EAGAIN;
-   return migrate_page(mapping, newpage, page);
+   return migrate_page(mapping, newpage, page, sync);
 }
 #endif
 
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e425ad9..06fd460 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -583,7 +583,8 @@ static int hugetlbfs_set_page_dirty(struct page *page)
 }
 
 static int hugetlbfs_migrate_page(struct address_space *mapping,
-   struct page *newpage, struct page *page)
+   struct page *newpage, struct page *page,
+   bool sync)
 {
int rc;
 
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 5ee9253..114398a 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -332,7 +332,7 @@ void nfs_commit_release_pages(struct nfs_write_data *data);
 
 #ifdef CONFIG_MIGRATION
 extern int nfs_migrate_page(struct address_space *,
-   struct page *, struct page *);
+   struct page *, struct page *, bool);
 #else
 #define nfs_migrate_page NULL
 #endif
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 0c38852..889e98b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1688,7 +1688,7 @@ out_error:
 
 #ifdef CONFIG_MIGRATION
 int nfs_migrate_page(struct address_space *mapping, struct page *newpage,
-   struct page *page)
+   struct page *page, bool sync)
 {
/*
 * If PagePrivate is set, then the page is currently associated with
@@ -1703,7 +1703,7 @@ int nfs_migrate_page(struct address_space *mapping, 
struct page *newpage,
 
nfs_fscache_release_page(page, GFP_KERNEL);
 
-   return migrate_page(mapping, newpage, page);
+   return migrate_page(mapping, newpage, page, sync);
 }
 #endif
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a7409bc..b92b73d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -609,9 +609,12 @@ struct address_space_operations {
loff_t offset, unsigned long nr_segs);
int (*get_xip_mem)(struct address_space *, pgoff_t, int,
void **, unsigned long *);
-   /* migrate the contents of a page to the specified target */
+   /*
+* migrate the contents of a page to the specified target. If sync
+* is false, it must not block.
+*/
int 

[ 13/73] mm: test PageSwapBacked in lumpy reclaim

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Hugh Dickins 

commit 043bcbe5ec51e0478ef2b44acef17193e01d7f70 upstream.

Stable note: Not tracked in Bugzilla. There were reports of shared
mapped pages being unfairly reclaimed in comparison to older kernels.
This is being addressed over time. Even though the subject
refers to lumpy reclaim, it impacts compaction as well.

Lumpy reclaim does well to stop at a PageAnon when there's no swap, but
better is to stop at any PageSwapBacked, which includes shmem/tmpfs too.

Signed-off-by: Hugh Dickins 
Reviewed-by: KOSAKI Motohiro 
Reviewed-by: Minchan Kim 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Mel Gorman 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index b935e6f..8a4e767 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1166,7 +1166,7 @@ static unsigned long isolate_lru_pages(unsigned long 
nr_to_scan,
 * anon page which don't already have a swap slot is
 * pointless.
 */
-   if (nr_swap_pages <= 0 && PageAnon(cursor_page) &&
+   if (nr_swap_pages <= 0 && PageSwapBacked(cursor_page) &&
!PageSwapCache(cursor_page))
break;
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 14/73] mm: vmscan: convert global reclaim to per-memcg LRU lists

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Johannes Weiner 

commit b95a2f2d486d0d768a92879c023a03757b9c7e58 upstream - WARNING: this is a 
substitute patch.

Stable note: Not tracked in Bugzilla. This is a partial backport of an
upstream commit addressing a completely different issue
that accidentally contained an important fix. The workload
this patch helps was memcached when IO is started in the
background. memcached should stay resident but without this patch
it gets swapped. Sometimes this manifests as a drop in throughput
but mostly it was observed through /proc/vmstat.

Commit [246e87a9: memcg: fix get_scan_count() for small targets] was meant
to fix a problem whereby small scan targets on memcg were ignored causing
priority to raise too sharply. It forced scanning to take place if the
target was small, memcg or kswapd.

>From the time it was introduced it caused excessive reclaim by kswapd
with workloads being pushed to swap that previously would have stayed
resident. This was accidentally fixed in commit [b95a2f2d: mm: vmscan:
convert global reclaim to per-memcg LRU lists] by making it harder for
kswapd to force scan small targets but that patchset is not suitable for
backporting. This was later changed again by commit [90126375: mm/vmscan:
push lruvec pointer into get_scan_count()] into a format that looks
like it would be a straight-forward backport but there is a subtle
difference due to the use of lruvecs.

The impact of the accidental fix is to make it harder for kswapd to force
scan small targets by taking zone->all_unreclaimable into account. This
patch is the closest equivalent available based on what is backported.

Signed-off-by: Mel Gorman 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1911,7 +1911,8 @@ static void get_scan_count(struct zone *
 * latencies, so it's better to scan a minimum amount there as
 * well.
 */
-   if (scanning_global_lru(sc) && current_is_kswapd())
+   if (scanning_global_lru(sc) && current_is_kswapd() &&
+   zone->all_unreclaimable)
force_scan = true;
if (!scanning_global_lru(sc))
force_scan = true;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 68/73] drm/radeon: fix bo creation retry path

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jerome Glisse 

commit d1c7871ddb1f588b8eb35affd9ee1a3d5e11cd0c upstream.

Retry label was at wrong place in function leading to memory
leak.

Signed-off-by: Jerome Glisse 
Reviewed-by: Michel Dänzer 
Reviewed-by: Christian König 
Signed-off-by: Dave Airlie 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/radeon/radeon_object.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -117,7 +117,6 @@ int radeon_bo_create(struct radeon_devic
return -ENOMEM;
}
 
-retry:
bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
if (bo == NULL)
return -ENOMEM;
@@ -130,6 +129,8 @@ retry:
bo->gem_base.driver_private = NULL;
bo->surface_reg = -1;
INIT_LIST_HEAD(>list);
+
+retry:
radeon_ttm_placement_from_domain(bo, domain);
/* Kernel allocation are uninterruptible */
mutex_lock(>vram_mutex);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 10/73] vmscan: promote shared file mapped pages

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Konstantin Khlebnikov 

commit 34dbc67a644f11ab3475d822d72e25409911e760 upstream.

Stable note: Not tracked in Bugzilla. There were reports of shared
mapped pages being unfairly reclaimed in comparison to older kernels.
This is being addressed over time. The specific workload being
addressed here in described in paragraph four and while paragraph
five says it did not help performance as such, it made a difference
to major page faults. I'm aware of at least one bug for a large
vendor that was due to increased major faults.

Commit 645747462435 ("vmscan: detect mapped file pages used only once")
greatly decreases lifetime of single-used mapped file pages.
Unfortunately it also decreases life time of all shared mapped file
pages.  Because after commit bf3f3bc5e7347 ("mm: don't mark_page_accessed
in fault path") page-fault handler does not mark page active or even
referenced.

Thus page_check_references() activates file page only if it was used twice
while it stays in inactive list, meanwhile it activates anon pages after
first access.  Inactive list can be small enough, this way reclaimer can
accidentally throw away any widely used page if it wasn't used twice in
short period.

After this patch page_check_references() also activate file mapped page at
first inactive list scan if this page is already used multiple times via
several ptes.

I found this while trying to fix degragation in rhel6 (~2.6.32) from rhel5
(~2.6.18).  There a complete mess with >100 web/mail/spam/ftp containers,
they share all their files but there a lot of anonymous pages: ~500mb
shared file mapped memory and 15-20Gb non-shared anonymous memory.  In
this situation major-pagefaults are very costly, because all containers
share the same page.  In my load kernel created a disproportionate
pressure on the file memory, compared with the anonymous, they equaled
only if I raise swappiness up to 150 =)

These patches actually wasn't helped a lot in my problem, but I saw
noticable (10-20 times) reduce in count and average time of
major-pagefault in file-mapped areas.

Actually both patches are fixes for commit v2.6.33-5448-g6457474, because
it was aimed at one scenario (singly used pages), but it breaks the logic
in other scenarios (shared and/or executable pages)

Signed-off-by: Konstantin Khlebnikov 
Acked-by: Pekka Enberg 
Acked-by: Minchan Kim 
Reviewed-by: KAMEZAWA Hiroyuki 
Cc: Wu Fengguang 
Cc: Johannes Weiner 
Cc: Nick Piggin 
Cc: Mel Gorman 
Cc: Shaohua Li 
Cc: Rik van Riel 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 11adc89..753c1e6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -715,7 +715,7 @@ static enum page_references page_check_references(struct 
page *page,
 */
SetPageReferenced(page);
 
-   if (referenced_page)
+   if (referenced_page || referenced_ptes > 1)
return PAGEREF_ACTIVATE;
 
return PAGEREF_KEEP;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 71/73] drm/radeon: on hotplug force link training to happen (v2)

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jerome Glisse 

commit ca2ccde5e2f24a792caa4cca919fc5c6f65d1887 upstream.

To have DP behave like VGA/DVI we need to retrain the link
on hotplug. For this to happen we need to force link
training to happen by setting connector dpms to off
before asking it turning it on again.

v2: agd5f
- drop the dp_get_link_status() change in atombios_dp.c
  for now.  We still need the dpms OFF change.

Signed-off-by: Jerome Glisse 
Signed-off-by: Alex Deucher 
Signed-off-by: Dave Airlie 
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/radeon/radeon_connectors.c |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index 3524f17..895e628 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -79,10 +79,16 @@ void radeon_connector_hotplug(struct drm_connector 
*connector)
if (dig_connector->dp_sink_type == 
CONNECTOR_OBJECT_ID_DISPLAYPORT) {
int saved_dpms = connector->dpms;
/* Only turn off the display if it's physically 
disconnected */
-   if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+   if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) 
{
drm_helper_connector_dpms(connector, 
DRM_MODE_DPMS_OFF);
-   else if (radeon_dp_needs_link_train(radeon_connector))
+   } else if 
(radeon_dp_needs_link_train(radeon_connector)) {
+   /* set it to OFF so that 
drm_helper_connector_dpms()
+* won't return immediately since the current 
state
+* is ON at this point.
+*/
+   connector->dpms = DRM_MODE_DPMS_OFF;
drm_helper_connector_dpms(connector, 
DRM_MODE_DPMS_ON);
+   }
connector->dpms = saved_dpms;
}
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 15/73] cpuset: mm: reduce large amounts of memory barrier related damage v3

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit cc9a6c8776615f9c194ccf0b63a0aa5628235545 upstream.

Stable note:  Not tracked in Bugzilla. [get|put]_mems_allowed() is extremely
expensive and severely impacted page allocator performance. This
is part of a series of patches that reduce page allocator overhead.

Commit c0ff7453bb5c ("cpuset,mm: fix no node to alloc memory when
changing cpuset's mems") wins a super prize for the largest number of
memory barriers entered into fast paths for one commit.

[get|put]_mems_allowed is incredibly heavy with pairs of full memory
barriers inserted into a number of hot paths.  This was detected while
investigating at large page allocator slowdown introduced some time
after 2.6.32.  The largest portion of this overhead was shown by
oprofile to be at an mfence introduced by this commit into the page
allocator hot path.

For extra style points, the commit introduced the use of yield() in an
implementation of what looks like a spinning mutex.

This patch replaces the full memory barriers on both read and write
sides with a sequence counter with just read barriers on the fast path
side.  This is much cheaper on some architectures, including x86.  The
main bulk of the patch is the retry logic if the nodemask changes in a
manner that can cause a false failure.

While updating the nodemask, a check is made to see if a false failure
is a risk.  If it is, the sequence number gets bumped and parallel
allocators will briefly stall while the nodemask update takes place.

In a page fault test microbenchmark, oprofile samples from
__alloc_pages_nodemask went from 4.53% of all samples to 1.15%.  The
actual results were

 3.3.0-rc3  3.3.0-rc3
 rc3-vanillanobarrier-v2r1
Clients   1 UserTime   0.07 (  0.00%)   0.08 (-14.19%)
Clients   2 UserTime   0.07 (  0.00%)   0.07 (  2.72%)
Clients   4 UserTime   0.08 (  0.00%)   0.07 (  3.29%)
Clients   1 SysTime0.70 (  0.00%)   0.65 (  6.65%)
Clients   2 SysTime0.85 (  0.00%)   0.82 (  3.65%)
Clients   4 SysTime1.41 (  0.00%)   1.41 (  0.32%)
Clients   1 WallTime   0.77 (  0.00%)   0.74 (  4.19%)
Clients   2 WallTime   0.47 (  0.00%)   0.45 (  3.73%)
Clients   4 WallTime   0.38 (  0.00%)   0.37 (  1.58%)
Clients   1 Flt/sec/cpu  497620.28 (  0.00%) 520294.53 (  4.56%)
Clients   2 Flt/sec/cpu  414639.05 (  0.00%) 429882.01 (  3.68%)
Clients   4 Flt/sec/cpu  257959.16 (  0.00%) 258761.48 (  0.31%)
Clients   1 Flt/sec  495161.39 (  0.00%) 517292.87 (  4.47%)
Clients   2 Flt/sec  820325.95 (  0.00%) 850289.77 (  3.65%)
Clients   4 Flt/sec  1020068.93 (  0.00%) 1022674.06 (  0.26%)
MMTests Statistics: duration
Sys Time Running Test (seconds) 135.68132.17
User+Sys Time Running Test (seconds) 164.2160.13
Total Elapsed Time (seconds)123.46120.87

The overall improvement is small but the System CPU time is much
improved and roughly in correlation to what oprofile reported (these
performance figures are without profiling so skew is expected).  The
actual number of page faults is noticeably improved.

For benchmarks like kernel builds, the overall benefit is marginal but
the system CPU time is slightly reduced.

To test the actual bug the commit fixed I opened two terminals.  The
first ran within a cpuset and continually ran a small program that
faulted 100M of anonymous data.  In a second window, the nodemask of the
cpuset was continually randomised in a loop.

Without the commit, the program would fail every so often (usually
within 10 seconds) and obviously with the commit everything worked fine.
With this patch applied, it also worked fine so the fix should be
functionally equivalent.

Signed-off-by: Mel Gorman 
Cc: Miao Xie 
Cc: David Rientjes 
Cc: Peter Zijlstra 
Cc: Christoph Lameter 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Mel Gorman 
[bwh: Forward-ported from 3.0 to 3.2: apply the upstream changes
 to get_any_partial()]
Signed-off-by: Ben Hutchings 
---
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -89,42 +89,33 @@ extern void rebuild_sched_domains(void);
 extern void cpuset_print_task_mems_allowed(struct task_struct *p);
 
 /*
- * reading current mems_allowed and mempolicy in the fastpath must protected
- * by get_mems_allowed()
+ * get_mems_allowed is required when making decisions involving mems_allowed
+ * such as during page allocation. mems_allowed can be updated in parallel
+ * and depending on the new value an operation can fail potentially causing
+ * process failure. A retry loop with get_mems_allowed and put_mems_allowed
+ * prevents these artificial failures.
  */
-static inline void get_mems_allowed(void)
+static inline unsigned int 

[ 70/73] drm/radeon: fix hotplug of DP to DVI|HDMI passive adapters (v2)

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jerome Glisse 

commit 266dcba541a1ef7e5d82d9e67c67fde2910636e8 upstream.

No need to retrain the link for passive adapters.

v2: agd5f
- no passive DP to VGA adapters, update comments
- assign radeon_connector_atom_dig after we are sure
  we have a digital connector as analog connectors
  have different private data.
- get new sink type before checking for retrain.  No
  need to check if it's no longer a DP connection.

Signed-off-by: Jerome Glisse 
Signed-off-by: Alex Deucher 
Signed-off-by: Dave Airlie 
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/radeon/radeon_connectors.c |   29 
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index 2914c57..3524f17 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -64,14 +64,27 @@ void radeon_connector_hotplug(struct drm_connector 
*connector)
 
/* just deal with DP (not eDP) here. */
if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
-   int saved_dpms = connector->dpms;
-
-   /* Only turn off the display it it's physically disconnected */
-   if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
-   drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
-   else if (radeon_dp_needs_link_train(radeon_connector))
-   drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
-   connector->dpms = saved_dpms;
+   struct radeon_connector_atom_dig *dig_connector =
+   radeon_connector->con_priv;
+
+   /* if existing sink type was not DP no need to retrain */
+   if (dig_connector->dp_sink_type != 
CONNECTOR_OBJECT_ID_DISPLAYPORT)
+   return;
+
+   /* first get sink type as it may be reset after (un)plug */
+   dig_connector->dp_sink_type = 
radeon_dp_getsinktype(radeon_connector);
+   /* don't do anything if sink is not display port, i.e.,
+* passive dp->(dvi|hdmi) adaptor
+*/
+   if (dig_connector->dp_sink_type == 
CONNECTOR_OBJECT_ID_DISPLAYPORT) {
+   int saved_dpms = connector->dpms;
+   /* Only turn off the display if it's physically 
disconnected */
+   if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd))
+   drm_helper_connector_dpms(connector, 
DRM_MODE_DPMS_OFF);
+   else if (radeon_dp_needs_link_train(radeon_connector))
+   drm_helper_connector_dpms(connector, 
DRM_MODE_DPMS_ON);
+   connector->dpms = saved_dpms;
+   }
}
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 66/73] locks: fix checking of fcntl_setlease argument

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: "J. Bruce Fields" 

commit 0ec4f431eb56d633da3a55da67d5c4b6ccc7 upstream.

The only checks of the long argument passed to fcntl(fd,F_SETLEASE,.)
are done after converting the long to an int.  Thus some illegal values
may be let through and cause problems in later code.

[ They actually *don't* cause problems in mainline, as of Dave Jones's
  commit 8d657eb3b438 "Remove easily user-triggerable BUG from
  generic_setlease", but we should fix this anyway.  And this patch will
  be necessary to fix real bugs on earlier kernels. ]

Signed-off-by: J. Bruce Fields 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 fs/locks.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index fce6238..82c3533 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -308,7 +308,7 @@ static int flock_make_lock(struct file *filp, struct 
file_lock **lock,
return 0;
 }
 
-static int assign_type(struct file_lock *fl, int type)
+static int assign_type(struct file_lock *fl, long type)
 {
switch (type) {
case F_RDLCK:
@@ -445,7 +445,7 @@ static const struct lock_manager_operations 
lease_manager_ops = {
 /*
  * Initialize a lease, use the default lock manager operations
  */
-static int lease_init(struct file *filp, int type, struct file_lock *fl)
+static int lease_init(struct file *filp, long type, struct file_lock *fl)
  {
if (assign_type(fl, type) != 0)
return -EINVAL;
@@ -463,7 +463,7 @@ static int lease_init(struct file *filp, int type, struct 
file_lock *fl)
 }
 
 /* Allocate a file_lock initialised to this type of lease */
-static struct file_lock *lease_alloc(struct file *filp, int type)
+static struct file_lock *lease_alloc(struct file *filp, long type)
 {
struct file_lock *fl = locks_alloc_lock();
int error = -ENOMEM;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 67/73] ACPI/AC: prevent OOPS on some boxes due to missing check power_supply_register() return value check

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Lan Tianyu 

commit f197ac13f6eeb351b31250b9ab7d0da17434ea36 upstream.

In the ac.c, power_supply_register()'s return value is not checked.

As a result, the driver's add() ops may return success
even though the device failed to initialize.

For example, some BIOS may describe two ACADs in the same DSDT.
The second ACAD device will fail to register,
but ACPI driver's add() ops returns sucessfully.
The ACPI device will receive ACPI notification and cause OOPS.

https://bugzilla.redhat.com/show_bug.cgi?id=772730

Signed-off-by: Lan Tianyu 
Signed-off-by: Len Brown 
Signed-off-by: Ben Hutchings 
---
 drivers/acpi/ac.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 6512b20..d1fcbc0 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -292,7 +292,9 @@ static int acpi_ac_add(struct acpi_device *device)
ac->charger.properties = ac_props;
ac->charger.num_properties = ARRAY_SIZE(ac_props);
ac->charger.get_property = get_ac_property;
-   power_supply_register(>device->dev, >charger);
+   result = power_supply_register(>device->dev, >charger);
+   if (result)
+   goto end;
 
printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
   acpi_device_name(device), acpi_device_bid(device),


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 59/73] [SCSI] libsas: continue revalidation

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 26f2f199ff150d8876b2641c41e60d1c92d2fb81 upstream.

Continue running revalidation until no more broadcast devices are
discovered.  Fixes cases where re-discovery completes too early in a
domain with multiple expanders with pending re-discovery events.
Servicing BCNs can get backed up behind error recovery.

Signed-off-by: Dan Williams 
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/libsas/sas_expander.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index af659cc..63c5742 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -2114,9 +2114,7 @@ int sas_ex_revalidate_domain(struct domain_device 
*port_dev)
struct domain_device *dev = NULL;
 
res = sas_find_bcast_dev(port_dev, );
-   if (res)
-   goto out;
-   if (dev) {
+   while (res == 0 && dev) {
struct expander_device *ex = >ex_dev;
int i = 0, phy_id;
 
@@ -2128,8 +2126,10 @@ int sas_ex_revalidate_domain(struct domain_device 
*port_dev)
res = sas_rediscover(dev, phy_id);
i = phy_id + 1;
} while (i < ex->num_phys);
+
+   dev = NULL;
+   res = sas_find_bcast_dev(port_dev, );
}
-out:
return res;
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 54/73] block: add blk_queue_dead()

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Tejun Heo 

commit 34f6055c80285e4efb3f602a9119db75239744dc upstream.

There are a number of QUEUE_FLAG_DEAD tests.  Add blk_queue_dead()
macro and use it.

This patch doesn't introduce any functional difference.

Signed-off-by: Tejun Heo 
Signed-off-by: Jens Axboe 
Signed-off-by: Ben Hutchings 
---
 block/blk-core.c   |6 +++---
 block/blk-exec.c   |2 +-
 block/blk-sysfs.c  |4 ++--
 block/blk-throttle.c   |4 ++--
 block/blk.h|2 +-
 include/linux/blkdev.h |1 +
 6 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 435af23..b5ed4f4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -608,7 +608,7 @@ EXPORT_SYMBOL(blk_init_allocated_queue_node);
 
 int blk_get_queue(struct request_queue *q)
 {
-   if (likely(!test_bit(QUEUE_FLAG_DEAD, >queue_flags))) {
+   if (likely(!blk_queue_dead(q))) {
kobject_get(>kobj);
return 0;
}
@@ -755,7 +755,7 @@ static struct request *get_request(struct request_queue *q, 
int rw_flags,
const bool is_sync = rw_is_sync(rw_flags) != 0;
int may_queue;
 
-   if (unlikely(test_bit(QUEUE_FLAG_DEAD, >queue_flags)))
+   if (unlikely(blk_queue_dead(q)))
return NULL;
 
may_queue = elv_may_queue(q, rw_flags);
@@ -875,7 +875,7 @@ static struct request *get_request_wait(struct 
request_queue *q, int rw_flags,
struct io_context *ioc;
struct request_list *rl = >rq;
 
-   if (unlikely(test_bit(QUEUE_FLAG_DEAD, >queue_flags)))
+   if (unlikely(blk_queue_dead(q)))
return NULL;
 
prepare_to_wait_exclusive(>wait[is_sync], ,
diff --git a/block/blk-exec.c b/block/blk-exec.c
index a1ebceb..6053285 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -50,7 +50,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct 
gendisk *bd_disk,
 {
int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
 
-   if (unlikely(test_bit(QUEUE_FLAG_DEAD, >queue_flags))) {
+   if (unlikely(blk_queue_dead(q))) {
rq->errors = -ENXIO;
if (rq->end_io)
rq->end_io(rq, rq->errors);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e7f9f65..f0b2ca8 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -425,7 +425,7 @@ queue_attr_show(struct kobject *kobj, struct attribute 
*attr, char *page)
if (!entry->show)
return -EIO;
mutex_lock(>sysfs_lock);
-   if (test_bit(QUEUE_FLAG_DEAD, >queue_flags)) {
+   if (blk_queue_dead(q)) {
mutex_unlock(>sysfs_lock);
return -ENOENT;
}
@@ -447,7 +447,7 @@ queue_attr_store(struct kobject *kobj, struct attribute 
*attr,
 
q = container_of(kobj, struct request_queue, kobj);
mutex_lock(>sysfs_lock);
-   if (test_bit(QUEUE_FLAG_DEAD, >queue_flags)) {
+   if (blk_queue_dead(q)) {
mutex_unlock(>sysfs_lock);
return -ENOENT;
}
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 4553245..5eed6a7 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -310,7 +310,7 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data 
*td)
struct request_queue *q = td->queue;
 
/* no throttling for dead queue */
-   if (unlikely(test_bit(QUEUE_FLAG_DEAD, >queue_flags)))
+   if (unlikely(blk_queue_dead(q)))
return NULL;
 
rcu_read_lock();
@@ -335,7 +335,7 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data 
*td)
spin_lock_irq(q->queue_lock);
 
/* Make sure @q is still alive */
-   if (unlikely(test_bit(QUEUE_FLAG_DEAD, >queue_flags))) {
+   if (unlikely(blk_queue_dead(q))) {
kfree(tg);
return NULL;
}
diff --git a/block/blk.h b/block/blk.h
index 3f6551b..e38691d 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -85,7 +85,7 @@ static inline struct request *__elv_next_request(struct 
request_queue *q)
q->flush_queue_delayed = 1;
return NULL;
}
-   if (test_bit(QUEUE_FLAG_DEAD, >queue_flags) ||
+   if (unlikely(blk_queue_dead(q)) ||
!q->elevator->ops->elevator_dispatch_fn(q, 0))
return NULL;
}
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 8a6b51b..783f97c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -481,6 +481,7 @@ static inline void queue_flag_clear(unsigned int flag, 
struct request_queue *q)
 
 #define blk_queue_tagged(q)test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
 #define blk_queue_stopped(q)   test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
+#define 

[ 73/73] nouveau: Fix alignment requirements on src and dst addresses

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Maarten Lankhorst 

commit ce806a30470bcd846d148bf39d46de3ad7748228 upstream.

Linear copy works by adding the offset to the buffer address,
which may end up not being 16-byte aligned.

Some tests I've written for prime_pcopy show that the engine
allows this correctly, so the restriction on lowest 4 bits of
address can be lifted safely.

The comments added were by envyas, I think because I used
a newer version.

Signed-off-by: Maarten Lankhorst 
[bwh: Backported to 3.2: no # prefixes in nva3_copy.fuc]
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/nouveau/nva3_copy.fuc   |4 +-
 drivers/gpu/drm/nouveau/nva3_copy.fuc.h |   94 +--
 drivers/gpu/drm/nouveau/nvc0_copy.fuc.h |   87 ++--
 3 files changed, 175 insertions(+), 10 deletions(-)

--- a/drivers/gpu/drm/nouveau/nva3_copy.fuc
+++ b/drivers/gpu/drm/nouveau/nva3_copy.fuc
@@ -118,9 +118,9 @@ dispatch_dma:
 // mthd 0x030c-0x0340, various stuff
 .b16 0xc3 14
 .b32 ctx_src_address_high   ~0x00ff
-.b32 ctx_src_address_low~0xfff0
+.b32 ctx_src_address_low~0x
 .b32 ctx_dst_address_high   ~0x00ff
-.b32 ctx_dst_address_low~0xfff0
+.b32 ctx_dst_address_low~0x
 .b32 ctx_src_pitch  ~0x0007
 .b32 ctx_dst_pitch  ~0x0007
 .b32 ctx_xcnt   ~0x
--- a/drivers/gpu/drm/nouveau/nva3_copy.fuc.h
+++ b/drivers/gpu/drm/nouveau/nva3_copy.fuc.h
@@ -1,37 +1,72 @@
-uint32_t nva3_pcopy_data[] = {
+u32 nva3_pcopy_data[] = {
+/* 0x: ctx_object */
0x,
+/* 0x0004: ctx_dma */
+/* 0x0004: ctx_dma_query */
0x,
+/* 0x0008: ctx_dma_src */
0x,
+/* 0x000c: ctx_dma_dst */
0x,
+/* 0x0010: ctx_query_address_high */
0x,
+/* 0x0014: ctx_query_address_low */
0x,
+/* 0x0018: ctx_query_counter */
0x,
+/* 0x001c: ctx_src_address_high */
0x,
+/* 0x0020: ctx_src_address_low */
0x,
+/* 0x0024: ctx_src_pitch */
0x,
+/* 0x0028: ctx_src_tile_mode */
0x,
+/* 0x002c: ctx_src_xsize */
0x,
+/* 0x0030: ctx_src_ysize */
0x,
+/* 0x0034: ctx_src_zsize */
0x,
+/* 0x0038: ctx_src_zoff */
0x,
+/* 0x003c: ctx_src_xoff */
0x,
+/* 0x0040: ctx_src_yoff */
0x,
+/* 0x0044: ctx_src_cpp */
0x,
+/* 0x0048: ctx_dst_address_high */
0x,
+/* 0x004c: ctx_dst_address_low */
0x,
+/* 0x0050: ctx_dst_pitch */
0x,
+/* 0x0054: ctx_dst_tile_mode */
0x,
+/* 0x0058: ctx_dst_xsize */
0x,
+/* 0x005c: ctx_dst_ysize */
0x,
+/* 0x0060: ctx_dst_zsize */
0x,
+/* 0x0064: ctx_dst_zoff */
0x,
+/* 0x0068: ctx_dst_xoff */
0x,
+/* 0x006c: ctx_dst_yoff */
0x,
+/* 0x0070: ctx_dst_cpp */
0x,
+/* 0x0074: ctx_format */
0x,
+/* 0x0078: ctx_swz_const0 */
0x,
+/* 0x007c: ctx_swz_const1 */
0x,
+/* 0x0080: ctx_xcnt */
0x,
+/* 0x0084: ctx_ycnt */
0x,
0x,
0x,
@@ -63,6 +98,7 @@ uint32_t nva3_pcopy_data[] = {
0x,
0x,
0x,
+/* 0x0100: dispatch_table */
0x0001,
0x,
0x,
@@ -73,6 +109,7 @@ uint32_t nva3_pcopy_data[] = {
0x00010162,
0x,
0x00030060,
+/* 0x0128: dispatch_dma */
0x00010170,
0x,
0x00010170,
@@ -118,11 +155,11 @@ uint32_t nva3_pcopy_data[] = {
0x001c,
0xff00,
0x0020,
-   0x000f,
+   0x,
0x0048,
0xff00,
0x004c,
-   0x000f,
+   0x,
0x0024,
0xfff8,
0x0050,
@@ -146,7 +183,8 @@ uint32_t nva3_pcopy_data[] = {
0x0800,
 };
 
-uint32_t nva3_pcopy_code[] = {
+u32 nva3_pcopy_code[] = {
+/* 0x: main */
0x04fe04bd,
0x3517f000,
0xf10010fe,
@@ -158,23 +196,31 @@ uint32_t nva3_pcopy_code[] = {
0x17f11031,
0x27f01200,
0x0012d003,
+/* 0x002f: spin */
0xf40031f4,
0x0ef40028,
+/* 0x0035: ih */
0x8001cffd,
0xf40812c4,
0x21f4060b,
+/* 0x0041: ih_no_chsw */
0x0412c472,
0xf4060bf4,
+/* 0x004a: ih_no_cmd */
0x11c4c321,
0x4001d00c,
+/* 0x0052: swctx */
0x47f101f8,
0x4bfe7700,
0x0007fe00,
0xf00204b9,
0x01f40643,
0x0604fa09,
+/* 0x006b: swctx_load */
0xfa060ef4,
+/* 0x006e: swctx_done */
0x03f80504,
+/* 0x0072: 

[ 62/73] mmc: sdhci-pci: CaFe has broken card detection

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Daniel Drake 

commit 55fc05b7414274f17795cd0e8a3b1546f3649d5e upstream.

At http://dev.laptop.org/ticket/11980 we have determined that the
Marvell CaFe SDHCI controller reports bad card presence during
resume. It reports that no card is present even when it is.
This is a regression -- resume worked back around 2.6.37.

Around 400ms after resuming, a "card inserted" interrupt is
generated, at which point it starts reporting presence.

Work around this hardware oddity by setting the
SDHCI_QUIRK_BROKEN_CARD_DETECTION flag.
Thanks to Chris Ball for helping with diagnosis.

Signed-off-by: Daniel Drake 
[stable@: please apply to 3.0+]
Signed-off-by: Chris Ball 
Signed-off-by: Ben Hutchings 
---
 drivers/mmc/host/sdhci-pci.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 69ef0be..504da71 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -157,6 +157,7 @@ static const struct sdhci_pci_fixes sdhci_ene_714 = {
 static const struct sdhci_pci_fixes sdhci_cafe = {
.quirks = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER |
  SDHCI_QUIRK_NO_BUSY_IRQ |
+ SDHCI_QUIRK_BROKEN_CARD_DETECTION |
  SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
 };
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 69/73] drm/radeon: fix non revealent error message

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jerome Glisse 

commit 8d1c702aa0b2c4b22b0742b72a1149d91690674b upstream.

We want to print link status query failed only if it's
an unexepected fail. If we query to see if we need
link training it might be because there is nothing
connected and thus link status query have the right
to fail in that case.

To avoid printing failure when it's expected, move the
failure message to proper place.

Signed-off-by: Jerome Glisse 
Signed-off-by: Dave Airlie 
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/radeon/atombios_dp.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_dp.c 
b/drivers/gpu/drm/radeon/atombios_dp.c
index 0355536..7712cf5 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -22,6 +22,7 @@
  *
  * Authors: Dave Airlie
  *  Alex Deucher
+ *  Jerome Glisse
  */
 #include "drmP.h"
 #include "radeon_drm.h"
@@ -654,7 +655,6 @@ static bool radeon_dp_get_link_status(struct 
radeon_connector *radeon_connector,
ret = radeon_dp_aux_native_read(radeon_connector, DP_LANE0_1_STATUS,
link_status, DP_LINK_STATUS_SIZE, 100);
if (ret <= 0) {
-   DRM_ERROR("displayport link status failed\n");
return false;
}
 
@@ -833,8 +833,10 @@ static int radeon_dp_link_train_cr(struct 
radeon_dp_link_train_info *dp_info)
else
mdelay(dp_info->rd_interval * 4);
 
-   if (!radeon_dp_get_link_status(dp_info->radeon_connector, 
dp_info->link_status))
+   if (!radeon_dp_get_link_status(dp_info->radeon_connector, 
dp_info->link_status)) {
+   DRM_ERROR("displayport link status failed\n");
break;
+   }
 
if (dp_clock_recovery_ok(dp_info->link_status, 
dp_info->dp_lane_count)) {
clock_recovery = true;
@@ -896,8 +898,10 @@ static int radeon_dp_link_train_ce(struct 
radeon_dp_link_train_info *dp_info)
else
mdelay(dp_info->rd_interval * 4);
 
-   if (!radeon_dp_get_link_status(dp_info->radeon_connector, 
dp_info->link_status))
+   if (!radeon_dp_get_link_status(dp_info->radeon_connector, 
dp_info->link_status)) {
+   DRM_ERROR("displayport link status failed\n");
break;
+   }
 
if (dp_channel_eq_ok(dp_info->link_status, 
dp_info->dp_lane_count)) {
channel_eq = true;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 72/73] Btrfs: call the ordered free operation without any locks held

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Chris Mason 

commit e9fbcb42201c862fd6ab45c48ead4f47bb2dea9d upstream.

Each ordered operation has a free callback, and this was called with the
worker spinlock held.  Josef made the free callback also call iput,
which we can't do with the spinlock.

This drops the spinlock for the free operation and grabs it again before
moving through the rest of the list.  We'll circle back around to this
and find a cleaner way that doesn't bounce the lock around so much.

Signed-off-by: Chris Mason 
Signed-off-by: Ben Hutchings 
---
 fs/btrfs/async-thread.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 4270414..58b7d14 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -206,10 +206,17 @@ static noinline void run_ordered_completions(struct 
btrfs_workers *workers,
 
work->ordered_func(work);
 
-   /* now take the lock again and call the freeing code */
+   /* now take the lock again and drop our item from the list */
spin_lock(>order_lock);
list_del(>order_list);
+   spin_unlock(>order_lock);
+
+   /*
+* we don't want to call the ordered free functions
+* with the lock held though
+*/
work->ordered_free(work);
+   spin_lock(>order_lock);
}
 
spin_unlock(>order_lock);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 60/73] [SCSI] libsas: fix sas_discover_devices return code handling

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit b17caa174a7e1fd2e17b26e210d4ee91c4c28b37 upstream.

commit 198439e4 [SCSI] libsas: do not set res = 0 in sas_ex_discover_dev()
commit 19252de6 [SCSI] libsas: fix wide port hotplug issues

The above commits seem to have confused the return value of
sas_ex_discover_dev which is non-zero on failure and
sas_ex_join_wide_port which just indicates short circuiting discovery on
already established ports.  The result is random discovery failures
depending on configuration.

Calls to sas_ex_join_wide_port are the source of the trouble as its
return value is errantly assigned to 'res'.  Convert it to bool and stop
returning its result up the stack.

Tested-by: Dan Melnic 
Reported-by: Dan Melnic 
Signed-off-by: Dan Williams 
Reviewed-by: Jack Wang 
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/libsas/sas_expander.c |   39 +++-
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 63c5742..879dbbe 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -868,7 +868,7 @@ static struct domain_device *sas_ex_discover_end_dev(
 }
 
 /* See if this phy is part of a wide port */
-static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
+static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
 {
struct ex_phy *phy = >ex_dev.ex_phy[phy_id];
int i;
@@ -884,11 +884,11 @@ static int sas_ex_join_wide_port(struct domain_device 
*parent, int phy_id)
sas_port_add_phy(ephy->port, phy->phy);
phy->port = ephy->port;
phy->phy_state = PHY_DEVICE_DISCOVERED;
-   return 0;
+   return true;
}
}
 
-   return -ENODEV;
+   return false;
 }
 
 static struct domain_device *sas_ex_discover_expander(
@@ -1030,8 +1030,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, 
int phy_id)
return res;
}
 
-   res = sas_ex_join_wide_port(dev, phy_id);
-   if (!res) {
+   if (sas_ex_join_wide_port(dev, phy_id)) {
SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
phy_id, SAS_ADDR(ex_phy->attached_sas_addr));
return res;
@@ -1077,8 +1076,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, 
int phy_id)
if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) ==
SAS_ADDR(child->sas_addr)) {
ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED;
-   res = sas_ex_join_wide_port(dev, i);
-   if (!res)
+   if (sas_ex_join_wide_port(dev, i))
SAS_DPRINTK("Attaching ex phy%d to wide 
port %016llx\n",
i, 
SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
 
@@ -1943,32 +1941,20 @@ static int sas_discover_new(struct domain_device *dev, 
int phy_id)
 {
struct ex_phy *ex_phy = >ex_dev.ex_phy[phy_id];
struct domain_device *child;
-   bool found = false;
-   int res, i;
+   int res;
 
SAS_DPRINTK("ex %016llx phy%d new device attached\n",
SAS_ADDR(dev->sas_addr), phy_id);
res = sas_ex_phy_discover(dev, phy_id);
if (res)
-   goto out;
-   /* to support the wide port inserted */
-   for (i = 0; i < dev->ex_dev.num_phys; i++) {
-   struct ex_phy *ex_phy_temp = >ex_dev.ex_phy[i];
-   if (i == phy_id)
-   continue;
-   if (SAS_ADDR(ex_phy_temp->attached_sas_addr) ==
-   SAS_ADDR(ex_phy->attached_sas_addr)) {
-   found = true;
-   break;
-   }
-   }
-   if (found) {
-   sas_ex_join_wide_port(dev, phy_id);
+   return res;
+
+   if (sas_ex_join_wide_port(dev, phy_id))
return 0;
-   }
+
res = sas_ex_discover_devices(dev, phy_id);
-   if (!res)
-   goto out;
+   if (res)
+   return res;
list_for_each_entry(child, >ex_dev.children, siblings) {
if (SAS_ADDR(child->sas_addr) ==
SAS_ADDR(ex_phy->attached_sas_addr)) {
@@ -1978,7 +1964,6 @@ static int sas_discover_new(struct domain_device *dev, 
int phy_id)
break;
}
}
-out:
return res;
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[ 57/73] [SCSI] fix hot unplug vs async scan race

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 3b661a92e869ebe2358de8f4b3230ad84f7fce51 upstream.

The following crash results from cases where the end_device has been
removed before scsi_sysfs_add_sdev has had a chance to run.

 BUG: unable to handle kernel NULL pointer dereference at 0098
 IP: [] sysfs_create_dir+0x32/0xb6
 ...
 Call Trace:
  [] kobject_add_internal+0x120/0x1e3
  [] ? trace_hardirqs_on+0xd/0xf
  [] kobject_add_varg+0x41/0x50
  [] kobject_add+0x64/0x66
  [] device_add+0x12d/0x63a
  [] ? _raw_spin_unlock_irqrestore+0x47/0x56
  [] ? module_refcount+0x89/0xa0
  [] scsi_sysfs_add_sdev+0x4e/0x28a
  [] do_scan_async+0x9c/0x145

...teach scsi_sysfs_add_devices() to check for deleted devices() before
trying to add them, and teach scsi_remove_target() how to remove targets
that have not been added via device_add().

Reported-by: Dariusz Majchrzak 
Signed-off-by: Dan Williams 
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/scsi_scan.c  |3 +++
 drivers/scsi/scsi_sysfs.c |   41 ++---
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 2e5fe58..f55e5f1 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1717,6 +1717,9 @@ static void scsi_sysfs_add_devices(struct Scsi_Host 
*shost)
 {
struct scsi_device *sdev;
shost_for_each_device(sdev, shost) {
+   /* target removed before the device could be added */
+   if (sdev->sdev_state == SDEV_DEL)
+   continue;
if (!scsi_host_scan_allowed(shost) ||
scsi_sysfs_add_sdev(sdev) != 0)
__scsi_remove_device(sdev);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index d19d7e9..093d4f6 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1005,7 +1005,6 @@ static void __scsi_remove_target(struct scsi_target 
*starget)
struct scsi_device *sdev;
 
spin_lock_irqsave(shost->host_lock, flags);
-   starget->reap_ref++;
  restart:
list_for_each_entry(sdev, >__devices, siblings) {
if (sdev->channel != starget->channel ||
@@ -1019,14 +1018,6 @@ static void __scsi_remove_target(struct scsi_target 
*starget)
goto restart;
}
spin_unlock_irqrestore(shost->host_lock, flags);
-   scsi_target_reap(starget);
-}
-
-static int __remove_child (struct device * dev, void * data)
-{
-   if (scsi_is_target_device(dev))
-   __scsi_remove_target(to_scsi_target(dev));
-   return 0;
 }
 
 /**
@@ -1039,14 +1030,34 @@ static int __remove_child (struct device * dev, void * 
data)
  */
 void scsi_remove_target(struct device *dev)
 {
-   if (scsi_is_target_device(dev)) {
-   __scsi_remove_target(to_scsi_target(dev));
-   return;
+   struct Scsi_Host *shost = dev_to_shost(dev->parent);
+   struct scsi_target *starget, *found;
+   unsigned long flags;
+
+ restart:
+   found = NULL;
+   spin_lock_irqsave(shost->host_lock, flags);
+   list_for_each_entry(starget, >__targets, siblings) {
+   if (starget->state == STARGET_DEL)
+   continue;
+   if (starget->dev.parent == dev || >dev == dev) {
+   found = starget;
+   found->reap_ref++;
+   break;
+   }
}
+   spin_unlock_irqrestore(shost->host_lock, flags);
 
-   get_device(dev);
-   device_for_each_child(dev, NULL, __remove_child);
-   put_device(dev);
+   if (found) {
+   __scsi_remove_target(found);
+   scsi_target_reap(found);
+   /* in the case where @dev has multiple starget children,
+* continue removing.
+*
+* FIXME: does such a case exist?
+*/
+   goto restart;
+   }
 }
 EXPORT_SYMBOL(scsi_remove_target);
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 63/73] ext4: dont let i_reserved_meta_blocks go negative

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Brian Foster 

commit 97795d2a5b8d3c8dc4365d4bd3404191840453ba upstream.

If we hit a condition where we have allocated metadata blocks that
were not appropriately reserved, we risk underflow of
ei->i_reserved_meta_blocks.  In turn, this can throw
sbi->s_dirtyclusters_counter significantly out of whack and undermine
the nondelalloc fallback logic in ext4_nonda_switch().  Warn if this
occurs and set i_allocated_meta_blocks to avoid this problem.

This condition is reproduced by xfstests 270 against ext2 with
delalloc enabled:

Mar 28 08:58:02 localhost kernel: [  171.526344] EXT4-fs (loop1): delayed block 
allocation failed for inode 14 at logical offset 64486 with max blocks 64 with 
error -28
Mar 28 08:58:02 localhost kernel: [  171.526346] EXT4-fs (loop1): This should 
not happen!! Data will be lost

270 ultimately fails with an inconsistent filesystem and requires an
fsck to repair.  The cause of the error is an underflow in
ext4_da_update_reserve_space() due to an unreserved meta block
allocation.

Signed-off-by: Brian Foster 
Signed-off-by: "Theodore Ts'o" 
Signed-off-by: Ben Hutchings 
---
 fs/ext4/inode.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index a533a18..25f809d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -346,6 +346,15 @@ void ext4_da_update_reserve_space(struct inode *inode,
used = ei->i_reserved_data_blocks;
}
 
+   if (unlikely(ei->i_allocated_meta_blocks > ei->i_reserved_meta_blocks)) 
{
+   ext4_msg(inode->i_sb, KERN_NOTICE, "%s: ino %lu, allocated %d "
+"with only %d reserved metadata blocks\n", __func__,
+inode->i_ino, ei->i_allocated_meta_blocks,
+ei->i_reserved_meta_blocks);
+   WARN_ON(1);
+   ei->i_allocated_meta_blocks = ei->i_reserved_meta_blocks;
+   }
+
/* Update per-inode reservations */
ei->i_reserved_data_blocks -= used;
ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 61/73] iscsi-target: Drop bogus struct file usage for iSCSI/SCTP

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Al Viro 

commit bf6932f44a7b3fa7e2246a8b18a44670e5eab6c2 upstream.

>From Al Viro:

BTW, speaking of struct file treatment related to sockets -
there's this piece of code in iscsi:
/*
 * The SCTP stack needs struct socket->file.
 */
if ((np->np_network_transport == ISCSI_SCTP_TCP) ||
(np->np_network_transport == ISCSI_SCTP_UDP)) {
if (!new_sock->file) {
new_sock->file = kzalloc(
sizeof(struct file), GFP_KERNEL);

For one thing, as far as I can see it'not true - sctp does *not* depend on
socket->file being non-NULL; it does, in one place, check socket->file->f_flags
for O_NONBLOCK, but there it treats NULL socket->file as "flag not set".
Which is the case here anyway - the fake struct file created in
__iscsi_target_login_thread() (and in iscsi_target_setup_login_socket(), with
the same excuse) do *not* get that flag set.

Moreover, it's a bloody serious violation of a bunch of asserts in VFS;
all struct file instances should come from filp_cachep, via get_empty_filp()
(or alloc_file(), which is a wrapper for it).  FWIW, I'm very tempted to
do this and be done with the entire mess:

Signed-off-by: Al Viro 
Cc: Andy Grover 
Cc: Hannes Reinecke 
Cc: Christoph Hellwig 
Signed-off-by: Nicholas Bellinger 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
 drivers/target/iscsi/iscsi_target.c   |   22 ++-
 drivers/target/iscsi/iscsi_target_core.h  |2 -
 drivers/target/iscsi/iscsi_target_login.c |   60 ++---
 3 files changed, 6 insertions(+), 78 deletions(-)

--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -427,19 +427,8 @@ int iscsit_reset_np_thread(
 
 int iscsit_del_np_comm(struct iscsi_np *np)
 {
-   if (!np->np_socket)
-   return 0;
-
-   /*
-* Some network transports allocate their own struct sock->file,
-* see  if we need to free any additional allocated resources.
-*/
-   if (np->np_flags & NPF_SCTP_STRUCT_FILE) {
-   kfree(np->np_socket->file);
-   np->np_socket->file = NULL;
-   }
-
-   sock_release(np->np_socket);
+   if (np->np_socket)
+   sock_release(np->np_socket);
return 0;
 }
 
@@ -4105,13 +4094,8 @@ int iscsit_close_connection(
kfree(conn->conn_ops);
conn->conn_ops = NULL;
 
-   if (conn->sock) {
-   if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) {
-   kfree(conn->sock->file);
-   conn->sock->file = NULL;
-   }
+   if (conn->sock)
sock_release(conn->sock);
-   }
conn->thread_set = NULL;
 
pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -224,7 +224,6 @@ enum iscsi_timer_flags_table {
 /* Used for struct iscsi_np->np_flags */
 enum np_flags_table {
NPF_IP_NETWORK  = 0x00,
-   NPF_SCTP_STRUCT_FILE= 0x01 /* Bugfix */
 };
 
 /* Used for struct iscsi_np->np_thread_state */
@@ -511,7 +510,6 @@ struct iscsi_conn {
u16 local_port;
int net_size;
u32 auth_id;
-#define CONNFLAG_SCTP_STRUCT_FILE  0x01
u32 conn_flags;
/* Used for iscsi_tx_login_rsp() */
u32 login_itt;
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -793,22 +793,6 @@ int iscsi_target_setup_login_socket(
}
np->np_socket = sock;
/*
-* The SCTP stack needs struct socket->file.
-*/
-   if ((np->np_network_transport == ISCSI_SCTP_TCP) ||
-   (np->np_network_transport == ISCSI_SCTP_UDP)) {
-   if (!sock->file) {
-   sock->file = kzalloc(sizeof(struct file), GFP_KERNEL);
-   if (!sock->file) {
-   pr_err("Unable to allocate struct"
-   " file for SCTP\n");
-   ret = -ENOMEM;
-   goto fail;
-   }
-   np->np_flags |= NPF_SCTP_STRUCT_FILE;
-   }
-   }
-   /*
 * Setup the np->np_sockaddr from the passed sockaddr setup
 * in iscsi_target_configfs.c code..
 */
@@ -857,21 +841,15 @@ int iscsi_target_setup_login_socket(
 
 fail:
np->np_socket = NULL;
-   if (sock) {
-   if (np->np_flags & NPF_SCTP_STRUCT_FILE) {
-   kfree(sock->file);
-   sock->file = NULL;
-   }
-
+   if 

[ 19/73] sched/nohz: Fix rq->cpu_load calculations some more

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit 5aaa0b7a2ed5b12692c9ffb5222182bd558d3146 upstream.

Follow up on commit 556061b00 ("sched/nohz: Fix rq->cpu_load[]
calculations") since while that fixed the busy case it regressed the
mostly idle case.

Add a callback from the nohz exit to also age the rq->cpu_load[]
array. This closes the hole where either there was no nohz load
balance pass during the nohz, or there was a 'significant' amount of
idle time between the last nohz balance and the nohz exit.

So we'll update unconditionally from the tick to not insert any
accidental 0 load periods while busy, and we try and catch up from
nohz idle balance and nohz exit. Both these are still prone to missing
a jiffy, but that has always been the case.

Signed-off-by: Peter Zijlstra 
Cc: p...@google.com
Cc: Venkatesh Pallipadi 
Link: http://lkml.kernel.org/n/tip-kt0trz0apodbf84ucjfdb...@git.kernel.org
Signed-off-by: Ingo Molnar 
[bwh: Backported to 3.2: adjust filenames and context]
Signed-off-by: Ben Hutchings 
---
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -145,6 +145,7 @@ extern unsigned long this_cpu_load(void)
 
 
 extern void calc_global_load(unsigned long ticks);
+extern void update_cpu_load_nohz(void);
 
 extern unsigned long get_parent_ip(unsigned long addr);
 
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3886,25 +3886,32 @@ static void __update_cpu_load(struct rq
sched_avg_update(this_rq);
 }
 
+#ifdef CONFIG_NO_HZ
+/*
+ * There is no sane way to deal with nohz on smp when using jiffies because the
+ * cpu doing the jiffies update might drift wrt the cpu doing the jiffy reading
+ * causing off-by-one errors in observed deltas; {0,2} instead of {1,1}.
+ *
+ * Therefore we cannot use the delta approach from the regular tick since that
+ * would seriously skew the load calculation. However we'll make do for those
+ * updates happening while idle (nohz_idle_balance) or coming out of idle
+ * (tick_nohz_idle_exit).
+ *
+ * This means we might still be one tick off for nohz periods.
+ */
+
 /*
  * Called from nohz_idle_balance() to update the load ratings before doing the
  * idle balance.
  */
 static void update_idle_cpu_load(struct rq *this_rq)
 {
-   unsigned long curr_jiffies = jiffies;
+   unsigned long curr_jiffies = ACCESS_ONCE(jiffies);
unsigned long load = this_rq->load.weight;
unsigned long pending_updates;
 
/*
-* Bloody broken means of dealing with nohz, but better than nothing..
-* jiffies is updated by one cpu, another cpu can drift wrt the jiffy
-* update and see 0 difference the one time and 2 the next, even though
-* we ticked at roughtly the same rate.
-*
-* Hence we only use this from nohz_idle_balance() and skip this
-* nonsense when called from the scheduler_tick() since that's
-* guaranteed a stable rate.
+* bail if there's load or we're actually up-to-date.
 */
if (load || curr_jiffies == this_rq->last_load_update_tick)
return;
@@ -3916,12 +3923,38 @@ static void update_idle_cpu_load(struct
 }
 
 /*
+ * Called from tick_nohz_idle_exit() -- try and fix up the ticks we missed.
+ */
+void update_cpu_load_nohz(void)
+{
+   struct rq *this_rq = this_rq();
+   unsigned long curr_jiffies = ACCESS_ONCE(jiffies);
+   unsigned long pending_updates;
+
+   if (curr_jiffies == this_rq->last_load_update_tick)
+   return;
+
+   raw_spin_lock(_rq->lock);
+   pending_updates = curr_jiffies - this_rq->last_load_update_tick;
+   if (pending_updates) {
+   this_rq->last_load_update_tick = curr_jiffies;
+   /*
+* We were idle, this means load 0, the current load might be
+* !0 due to remote wakeups and the sort.
+*/
+   __update_cpu_load(this_rq, 0, pending_updates);
+   }
+   raw_spin_unlock(_rq->lock);
+}
+#endif /* CONFIG_NO_HZ */
+
+/*
  * Called from scheduler_tick()
  */
 static void update_cpu_load_active(struct rq *this_rq)
 {
/*
-* See the mess in update_idle_cpu_load().
+* See the mess around update_idle_cpu_load() / update_cpu_load_nohz().
 */
this_rq->last_load_update_tick = jiffies;
__update_cpu_load(this_rq, this_rq->load.weight, 1);
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -549,6 +549,7 @@ void tick_nohz_restart_sched_tick(void)
/* Update jiffies first */
select_nohz_load_balancer(0);
tick_do_update_jiffies64(now);
+   update_cpu_load_nohz();
 
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
/*


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  

[ 02/73] mm: compaction: allow compaction to isolate dirty pages

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit a77ebd333cd810d7b680d544be88c875131c2bd3 upstream.

Stable note: Not tracked in Bugzilla. A fix aimed at preserving page aging
information by reducing LRU list churning had the side-effect of
reducing THP allocation success rates. This was part of a series
to restore the success rates while preserving the reclaim fix.

Short summary: There are severe stalls when a USB stick using VFAT is
used with THP enabled that are reduced by this series.  If you are
experiencing this problem, please test and report back and considering I
have seen complaints from openSUSE and Fedora users on this as well as a
few private mails, I'm guessing it's a widespread issue.  This is a new
type of USB-related stall because it is due to synchronous compaction
writing where as in the past the big problem was dirty pages reaching
the end of the LRU and being written by reclaim.

Am cc'ing Andrew this time and this series would replace
mm-do-not-stall-in-synchronous-compaction-for-thp-allocations.patch.
I'm also cc'ing Dave Jones as he might have merged that patch to Fedora
for wider testing and ideally it would be reverted and replaced by this
series.

That said, the later patches could really do with some review.  If this
series is not the answer then a new direction needs to be discussed
because as it is, the stalls are unacceptable as the results in this
leader show.

For testers that try backporting this to 3.1, it won't work because
there is a non-obvious dependency on not writing back pages in direct
reclaim so you need those patches too.

Changelog since V5
o Rebase to 3.2-rc5
o Tidy up the changelogs a bit

Changelog since V4
o Added reviewed-bys, credited Andrea properly for sync-light
o Allow dirty pages without mappings to be considered for migration
o Bound the number of pages freed for compaction
o Isolate PageReclaim pages on their own LRU list

This is against 3.2-rc5 and follows on from discussions on "mm: Do
not stall in synchronous compaction for THP allocations" and "[RFC
PATCH 0/5] Reduce compaction-related stalls". Initially, the proposed
patch eliminated stalls due to compaction which sometimes resulted in
user-visible interactivity problems on browsers by simply never using
sync compaction. The downside was that THP success allocation rates
were lower because dirty pages were not being migrated as reported by
Andrea. His approach at fixing this was nacked on the grounds that
it reverted fixes from Rik merged that reduced the amount of pages
reclaimed as it severely impacted his workloads performance.

This series attempts to reconcile the requirements of maximising THP
usage, without stalling in a user-visible fashion due to compaction
or cheating by reclaiming an excessive number of pages.

Patch 1 partially reverts commit 39deaf85 to allow migration to isolate
dirty pages. This is because migration can move some dirty
pages without blocking.

Patch 2 notes that the /proc/sys/vm/compact_memory handler is not using
synchronous compaction when it should be. This is unrelated
to the reported stalls but is worth fixing.

Patch 3 checks if we isolated a compound page during lumpy scan and
account for it properly. For the most part, this affects
tracing so it's unrelated to the stalls but worth fixing.

Patch 4 notes that it is possible to abort reclaim early for compaction
and return 0 to the page allocator potentially entering the
"may oom" path. This has not been observed in practice but
the rest of the series potentially makes it easier to happen.

Patch 5 adds a sync parameter to the migratepage callback and gives
the callback responsibility for migrating the page without
blocking if sync==false. For example, fallback_migrate_page
will not call writepage if sync==false. This increases the
number of pages that can be handled by asynchronous compaction
thereby reducing stalls.

Patch 6 restores filter-awareness to isolate_lru_page for migration.
In practice, it means that pages under writeback and pages
without a ->migratepage callback will not be isolated
for migration.

Patch 7 avoids calling direct reclaim if compaction is deferred but
makes sure that compaction is only deferred if sync
compaction was used.

Patch 8 introduces a sync-light migration mechanism that sync compaction
uses. The objective is to allow some stalls but to not call
->writepage which can lead to significant user-visible stalls.

Patch 9 notes that while we want to abort reclaim ASAP to allow
compation to go ahead that we leave a very small window of
opportunity for compaction to run. This patch allows more pages
to be freed by reclaim but bounds the number to a reasonable
level based on the 

[ 11/73] vmscan: activate executable pages after first usage

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Konstantin Khlebnikov 

commit c909e99364c8b6ca07864d752950b6b4ecf6bef4 upstream.

Stable note: Not tracked in Bugzilla. There were reports of shared
mapped pages being unfairly reclaimed in comparison to older kernels.
This is being addressed over time.

Logic added in commit 8cab4754d24a0 ("vmscan: make mapped executable pages
the first class citizen") was noticeably weakened in commit
645747462435d84 ("vmscan: detect mapped file pages used only once").

Currently these pages can become "first class citizens" only after second
usage.  After this patch page_check_references() will activate they after
first usage, and executable code gets yet better chance to stay in memory.

Signed-off-by: Konstantin Khlebnikov 
Cc: Pekka Enberg 
Cc: Minchan Kim 
Cc: KAMEZAWA Hiroyuki 
Cc: Wu Fengguang 
Cc: Johannes Weiner 
Cc: Nick Piggin 
Cc: Mel Gorman 
Cc: Shaohua Li 
Cc: Rik van Riel 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 753c1e6..753a2dc 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -718,6 +718,12 @@ static enum page_references page_check_references(struct 
page *page,
if (referenced_page || referenced_ptes > 1)
return PAGEREF_ACTIVATE;
 
+   /*
+* Activate file-backed executable pages after first usage.
+*/
+   if (vm_flags & VM_EXEC)
+   return PAGEREF_ACTIVATE;
+
return PAGEREF_KEEP;
}
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 05/73] mm: compaction: make isolate_lru_page() filter-aware again

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit c82449352854ff09e43062246af86bdeb628f0c3 upstream.

Stable note: Not tracked in Bugzilla. A fix aimed at preserving page aging
information by reducing LRU list churning had the side-effect of
reducing THP allocation success rates. This was part of a series
to restore the success rates while preserving the reclaim fix.

Commit 39deaf85 ("mm: compaction: make isolate_lru_page() filter-aware")
noted that compaction does not migrate dirty or writeback pages and that
is was meaningless to pick the page and re-add it to the LRU list.  This
had to be partially reverted because some dirty pages can be migrated by
compaction without blocking.

This patch updates "mm: compaction: make isolate_lru_page" by skipping
over pages that migration has no possibility of migrating to minimise LRU
disruption.

Signed-off-by: Mel Gorman 
Reviewed-by: Rik van Riel
Cc: Andrea Arcangeli 
Reviewed-by: Minchan Kim 
Cc: Dave Jones 
Cc: Jan Kara 
Cc: Andy Isaacson 
Cc: Nai Xia 
Cc: Johannes Weiner 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 include/linux/mmzone.h |2 ++
 mm/compaction.c|3 +++
 mm/vmscan.c|   35 +--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 42e544c..2038b90 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -177,6 +177,8 @@ struct lruvec {
 #define ISOLATE_CLEAN  ((__force isolate_mode_t)0x4)
 /* Isolate unmapped file */
 #define ISOLATE_UNMAPPED   ((__force isolate_mode_t)0x8)
+/* Isolate for asynchronous migration */
+#define ISOLATE_ASYNC_MIGRATE  ((__force isolate_mode_t)0x10)
 
 /* LRU Isolation modes. */
 typedef unsigned __bitwise__ isolate_mode_t;
diff --git a/mm/compaction.c b/mm/compaction.c
index d31e64b..fb29158 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -349,6 +349,9 @@ static isolate_migrate_t isolate_migratepages(struct zone 
*zone,
continue;
}
 
+   if (!cc->sync)
+   mode |= ISOLATE_ASYNC_MIGRATE;
+
/* Try isolate the page */
if (__isolate_lru_page(page, mode, 0) != 0)
continue;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index cb68c53..efbcab1 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1075,8 +1075,39 @@ int __isolate_lru_page(struct page *page, isolate_mode_t 
mode, int file)
 
ret = -EBUSY;
 
-   if ((mode & ISOLATE_CLEAN) && (PageDirty(page) || PageWriteback(page)))
-   return ret;
+   /*
+* To minimise LRU disruption, the caller can indicate that it only
+* wants to isolate pages it will be able to operate on without
+* blocking - clean pages for the most part.
+*
+* ISOLATE_CLEAN means that only clean pages should be isolated. This
+* is used by reclaim when it is cannot write to backing storage
+*
+* ISOLATE_ASYNC_MIGRATE is used to indicate that it only wants to pages
+* that it is possible to migrate without blocking
+*/
+   if (mode & (ISOLATE_CLEAN|ISOLATE_ASYNC_MIGRATE)) {
+   /* All the caller can do on PageWriteback is block */
+   if (PageWriteback(page))
+   return ret;
+
+   if (PageDirty(page)) {
+   struct address_space *mapping;
+
+   /* ISOLATE_CLEAN means only clean pages */
+   if (mode & ISOLATE_CLEAN)
+   return ret;
+
+   /*
+* Only pages without mappings or that have a
+* ->migratepage callback are possible to migrate
+* without blocking
+*/
+   mapping = page_mapping(page);
+   if (mapping && !mapping->a_ops->migratepage)
+   return ret;
+   }
+   }
 
if ((mode & ISOLATE_UNMAPPED) && page_mapped(page))
return ret;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 18/73] sched/nohz: Fix rq->cpu_load[] calculations

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

commit 556061b00c9f2fd6a5524b6bde823ef12f299ecf upstream.

While investigating why the load-balancer did funny I found that the
rq->cpu_load[] tables were completely screwy.. a bit more digging
revealed that the updates that got through were missing ticks followed
by a catchup of 2 ticks.

The catchup assumes the cpu was idle during that time (since only nohz
can cause missed ticks and the machine is idle etc..) this means that
esp. the higher indices were significantly lower than they ought to
be.

The reason for this is that its not correct to compare against jiffies
on every jiffy on any other cpu than the cpu that updates jiffies.

This patch cludges around it by only doing the catch-up stuff from
nohz_idle_balance() and doing the regular stuff unconditionally from
the tick.

Signed-off-by: Peter Zijlstra 
Cc: p...@google.com
Cc: Venkatesh Pallipadi 
Link: http://lkml.kernel.org/n/tip-tp4kj18xdd5aj4vvj0qg5...@git.kernel.org
Signed-off-by: Ingo Molnar 
[bwh: Backported to 3.2: adjust filenames and context; keep functions static]
Signed-off-by: Ben Hutchings 
---
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1887,7 +1887,7 @@ static void double_rq_unlock(struct rq *
 
 static void update_sysctl(void);
 static int get_update_sysctl_factor(void);
-static void update_cpu_load(struct rq *this_rq);
+static void update_idle_cpu_load(struct rq *this_rq);
 
 static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
 {
@@ -3855,22 +3855,13 @@ decay_load_missed(unsigned long load, un
  * scheduler tick (TICK_NSEC). With tickless idle this will not be called
  * every tick. We fix it up based on jiffies.
  */
-static void update_cpu_load(struct rq *this_rq)
+static void __update_cpu_load(struct rq *this_rq, unsigned long this_load,
+ unsigned long pending_updates)
 {
-   unsigned long this_load = this_rq->load.weight;
-   unsigned long curr_jiffies = jiffies;
-   unsigned long pending_updates;
int i, scale;
 
this_rq->nr_load_updates++;
 
-   /* Avoid repeated calls on same jiffy, when moving in and out of idle */
-   if (curr_jiffies == this_rq->last_load_update_tick)
-   return;
-
-   pending_updates = curr_jiffies - this_rq->last_load_update_tick;
-   this_rq->last_load_update_tick = curr_jiffies;
-
/* Update our load: */
this_rq->cpu_load[0] = this_load; /* Fasttrack for idx 0 */
for (i = 1, scale = 2; i < CPU_LOAD_IDX_MAX; i++, scale += scale) {
@@ -3895,9 +3886,45 @@ static void update_cpu_load(struct rq *t
sched_avg_update(this_rq);
 }
 
+/*
+ * Called from nohz_idle_balance() to update the load ratings before doing the
+ * idle balance.
+ */
+static void update_idle_cpu_load(struct rq *this_rq)
+{
+   unsigned long curr_jiffies = jiffies;
+   unsigned long load = this_rq->load.weight;
+   unsigned long pending_updates;
+
+   /*
+* Bloody broken means of dealing with nohz, but better than nothing..
+* jiffies is updated by one cpu, another cpu can drift wrt the jiffy
+* update and see 0 difference the one time and 2 the next, even though
+* we ticked at roughtly the same rate.
+*
+* Hence we only use this from nohz_idle_balance() and skip this
+* nonsense when called from the scheduler_tick() since that's
+* guaranteed a stable rate.
+*/
+   if (load || curr_jiffies == this_rq->last_load_update_tick)
+   return;
+
+   pending_updates = curr_jiffies - this_rq->last_load_update_tick;
+   this_rq->last_load_update_tick = curr_jiffies;
+
+   __update_cpu_load(this_rq, load, pending_updates);
+}
+
+/*
+ * Called from scheduler_tick()
+ */
 static void update_cpu_load_active(struct rq *this_rq)
 {
-   update_cpu_load(this_rq);
+   /*
+* See the mess in update_idle_cpu_load().
+*/
+   this_rq->last_load_update_tick = jiffies;
+   __update_cpu_load(this_rq, this_rq->load.weight, 1);
 
calc_load_account_active(this_rq);
 }
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -4735,7 +4735,7 @@ static void nohz_idle_balance(int this_c
 
raw_spin_lock_irq(_rq->lock);
update_rq_clock(this_rq);
-   update_cpu_load(this_rq);
+   update_idle_cpu_load(this_rq);
raw_spin_unlock_irq(_rq->lock);
 
rebalance_domains(balance_cpu, CPU_IDLE);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 56/73] [SCSI] Avoid dangling pointer in scsi_requeue_command()

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Bart Van Assche 

commit 940f5d47e2f2e1fa00443921a0abf4822335b54d upstream.

When we call scsi_unprep_request() the command associated with the request
gets destroyed and therefore drops its reference on the device.  If this was
the only reference, the device may get released and we end up with a NULL
pointer deref when we call blk_requeue_request.

Reported-by: Mike Christie 
Signed-off-by: Bart Van Assche 
Reviewed-by: Mike Christie 
Reviewed-by: Tejun Heo 
[jejb: enhance commend and add commit log for stable]
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/scsi_lib.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4acf5c2..0e52ff0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -479,15 +479,26 @@ void scsi_requeue_run_queue(struct work_struct *work)
  */
 static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd 
*cmd)
 {
+   struct scsi_device *sdev = cmd->device;
struct request *req = cmd->request;
unsigned long flags;
 
+   /*
+* We need to hold a reference on the device to avoid the queue being
+* killed after the unlock and before scsi_run_queue is invoked which
+* may happen because scsi_unprep_request() puts the command which
+* releases its reference on the device.
+*/
+   get_device(>sdev_gendev);
+
spin_lock_irqsave(q->queue_lock, flags);
scsi_unprep_request(req);
blk_requeue_request(q, req);
spin_unlock_irqrestore(q->queue_lock, flags);
 
scsi_run_queue(q);
+
+   put_device(>sdev_gendev);
 }
 
 void scsi_next_command(struct scsi_cmnd *cmd)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 65/73] ASoC: dapm: Fix _PRE and _POST events for DAPM performance improvements

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mark Brown 

commit 0ff97ebf0804d2e519d578fcb4db03f104d2ca8c upstream.

Ever since the DAPM performance improvements we've been marking all widgets
as not dirty after each DAPM run. Since _PRE and _POST events aren't part
of the DAPM graph this has rendered them non-functional, they will never be
marked dirty again and thus will never be run again.

Fix this by skipping them when marking widgets as not dirty.

Signed-off-by: Mark Brown 
Acked-by: Liam Girdwood 
Signed-off-by: Ben Hutchings 
---
 sound/soc/soc-dapm.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f7a13f7..025060b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1598,7 +1598,15 @@ static int dapm_power_widgets(struct 
snd_soc_dapm_context *dapm, int event)
}
 
list_for_each_entry(w, >widgets, list) {
-   list_del_init(>dirty);
+   switch (w->id) {
+   case snd_soc_dapm_pre:
+   case snd_soc_dapm_post:
+   /* These widgets always need to be powered */
+   break;
+   default:
+   list_del_init(>dirty);
+   break;
+   }
 
if (w->power) {
d = w->dapm;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 55/73] [SCSI] Fix device removal NULL pointer dereference

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Bart Van Assche 

commit 67bd94130015c507011af37858989b199c52e1de upstream.

Use blk_queue_dead() to test whether the queue is dead instead
of !sdev. Since scsi_prep_fn() may be invoked concurrently with
__scsi_remove_device(), keep the queuedata (sdev) pointer in
__scsi_remove_device(). This patch fixes a kernel oops that
can be triggered by USB device removal. See also
http://www.spinics.net/lists/linux-scsi/msg56254.html.

Other changes included in this patch:
- Swap the blk_cleanup_queue() and kfree() calls in
  scsi_host_dev_release() to make that code easier to grasp.
- Remove the queue dead check from scsi_run_queue() since the
  queue state can change anyway at any point in that function
  where the queue lock is not held.
- Remove the queue dead check from the start of scsi_request_fn()
  since it is redundant with the scsi_device_online() check.

Reported-by: Jun'ichi Nomura 
Signed-off-by: Bart Van Assche 
Reviewed-by: Mike Christie 
Reviewed-by: Tejun Heo 
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/hosts.c  |7 ---
 drivers/scsi/scsi_lib.c   |   32 
 drivers/scsi/scsi_priv.h  |1 -
 drivers/scsi/scsi_sysfs.c |5 +
 4 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 2b6a03d..593085a 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -290,6 +290,7 @@ static void scsi_host_dev_release(struct device *dev)
struct Scsi_Host *shost = dev_to_shost(dev);
struct device *parent = dev->parent;
struct request_queue *q;
+   void *queuedata;
 
scsi_proc_hostdir_rm(shost->hostt);
 
@@ -299,9 +300,9 @@ static void scsi_host_dev_release(struct device *dev)
destroy_workqueue(shost->work_q);
q = shost->uspace_req_q;
if (q) {
-   kfree(q->queuedata);
-   q->queuedata = NULL;
-   scsi_free_queue(q);
+   queuedata = q->queuedata;
+   blk_cleanup_queue(q);
+   kfree(queuedata);
}
 
scsi_destroy_command_freelist(shost);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9f00c12..4acf5c2 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -406,10 +406,6 @@ static void scsi_run_queue(struct request_queue *q)
LIST_HEAD(starved_list);
unsigned long flags;
 
-   /* if the device is dead, sdev will be NULL, so no queue to run */
-   if (!sdev)
-   return;
-
shost = sdev->host;
if (scsi_target(sdev)->single_lun)
scsi_single_lun_run(sdev);
@@ -1371,16 +1367,16 @@ static inline int scsi_host_queue_ready(struct 
request_queue *q,
  * may be changed after request stacking drivers call the function,
  * regardless of taking lock or not.
  *
- * When scsi can't dispatch I/Os anymore and needs to kill I/Os
- * (e.g. !sdev), scsi needs to return 'not busy'.
- * Otherwise, request stacking drivers may hold requests forever.
+ * When scsi can't dispatch I/Os anymore and needs to kill I/Os scsi
+ * needs to return 'not busy'. Otherwise, request stacking drivers
+ * may hold requests forever.
  */
 static int scsi_lld_busy(struct request_queue *q)
 {
struct scsi_device *sdev = q->queuedata;
struct Scsi_Host *shost;
 
-   if (!sdev)
+   if (blk_queue_dead(q))
return 0;
 
shost = sdev->host;
@@ -1491,12 +1487,6 @@ static void scsi_request_fn(struct request_queue *q)
struct scsi_cmnd *cmd;
struct request *req;
 
-   if (!sdev) {
-   while ((req = blk_peek_request(q)) != NULL)
-   scsi_kill_request(req, q);
-   return;
-   }
-
if(!get_device(>sdev_gendev))
/* We must be tearing the block queue down already */
return;
@@ -1698,20 +1688,6 @@ struct request_queue *scsi_alloc_queue(struct 
scsi_device *sdev)
return q;
 }
 
-void scsi_free_queue(struct request_queue *q)
-{
-   unsigned long flags;
-
-   WARN_ON(q->queuedata);
-
-   /* cause scsi_request_fn() to kill all non-finished requests */
-   spin_lock_irqsave(q->queue_lock, flags);
-   q->request_fn(q);
-   spin_unlock_irqrestore(q->queue_lock, flags);
-
-   blk_cleanup_queue(q);
-}
-
 /*
  * Function:scsi_block_requests()
  *
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index cbfe5df..291db6e 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -85,7 +85,6 @@ extern void scsi_next_command(struct scsi_cmnd *cmd);
 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_run_host_queues(struct Scsi_Host *shost);
 extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
-extern void 

[ 46/73] target: Check number of unmap descriptors against our limit

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Roland Dreier 

commit 7409a6657aebf8be74c21d0eded80709b27275cb upstream.

Fail UNMAP commands that have more than our reported limit on unmap
descriptors.

Signed-off-by: Roland Dreier 
Signed-off-by: Nicholas Bellinger 
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings 
---
 drivers/target/target_core_cdb.c |5 +
 1 file changed, 5 insertions(+)

--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1133,6 +1133,11 @@ int target_emulate_unmap(struct se_task
bd_dl = get_unaligned_be16([2]);
 
size = min(size - 8, bd_dl);
+   if (size / 16 > 
dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) {
+   cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
+   ret = -EINVAL;
+   goto err;
+   }
 
/* First UNMAP block descriptor starts at 8 byte offset */
ptr = [8];


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 43/73] target: Add range checking to UNMAP emulation

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Roland Dreier 

commit 2594e29865c291db162313187612cd9f14538f33 upstream.

When processing an UNMAP command, we need to make sure that the number
of blocks we're asked to UNMAP does not exceed our reported maximum
number of blocks per UNMAP, and that the range of blocks we're
unmapping doesn't go past the end of the device.

Signed-off-by: Roland Dreier 
Signed-off-by: Nicholas Bellinger 
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings 
---
 drivers/target/target_core_cdb.c |   12 
 1 file changed, 12 insertions(+)

--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1145,6 +1145,18 @@ int target_emulate_unmap(struct se_task
pr_debug("UNMAP: Using lba: %llu and range: %u\n",
 (unsigned long long)lba, range);
 
+   if (range > dev->se_sub_dev->se_dev_attrib.max_unmap_lba_count) 
{
+   cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
+   ret = -EINVAL;
+   goto err;
+   }
+
+   if (lba + range > dev->transport->get_blocks(dev) + 1) {
+   cmd->scsi_sense_reason = TCM_ADDRESS_OUT_OF_RANGE;
+   ret = -EINVAL;
+   goto err;
+   }
+
ret = dev->transport->do_discard(dev, lba, range);
if (ret < 0) {
pr_err("blkdev_issue_discard() failed: %d\n",


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 37/73] udf: Improve table length check to avoid possible overflow

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jan Kara 

commit 57b9655d01ef057a523e810d29c37ac09b80eead upstream.

When a partition table length is corrupted to be close to 1 << 32, the
check for its length may overflow on 32-bit systems and we will think
the length is valid. Later on the kernel can crash trying to read beyond
end of buffer. Fix the check to avoid possible overflow.

Reported-by: Ben Hutchings 
Signed-off-by: Jan Kara 
Signed-off-by: Ben Hutchings 
---
 fs/udf/super.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 8a75838..dcbf987 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1340,7 +1340,7 @@ static int udf_load_logicalvol(struct super_block *sb, 
sector_t block,
BUG_ON(ident != TAG_IDENT_LVD);
lvd = (struct logicalVolDesc *)bh->b_data;
table_len = le32_to_cpu(lvd->mapTableLength);
-   if (sizeof(*lvd) + table_len > sb->s_blocksize) {
+   if (table_len > sb->s_blocksize - sizeof(*lvd)) {
udf_err(sb, "error loading logical volume descriptor: "
"Partition table too long (%u > %lu)\n", table_len,
sb->s_blocksize - sizeof(*lvd));


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 42/73] target: Add generation of LOGICAL BLOCK ADDRESS OUT OF RANGE

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Roland Dreier 

commit e2397c704429025bc6b331a970f699e52f34283e upstream.

Many SCSI commands are defined to return a CHECK CONDITION / ILLEGAL
REQUEST with ASC set to LOGICAL BLOCK ADDRESS OUT OF RANGE if the
initiator sends a command that accesses a too-big LBA.  Add an enum
value and case entries so that target code can return this status.

Signed-off-by: Roland Dreier 
Signed-off-by: Nicholas Bellinger 
Signed-off-by: Ben Hutchings 
---
 drivers/target/target_core_transport.c |   10 ++
 include/target/target_core_base.h  |1 +
 2 files changed, 11 insertions(+)

--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1820,6 +1820,7 @@ static void transport_generic_request_fa
case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE:
case TCM_UNKNOWN_MODE_PAGE:
case TCM_WRITE_PROTECTED:
+   case TCM_ADDRESS_OUT_OF_RANGE:
case TCM_CHECK_CONDITION_ABORT_CMD:
case TCM_CHECK_CONDITION_UNIT_ATTENTION:
case TCM_CHECK_CONDITION_NOT_READY:
@@ -4496,6 +4497,15 @@ int transport_send_check_condition_and_s
/* WRITE PROTECTED */
buffer[offset+SPC_ASC_KEY_OFFSET] = 0x27;
break;
+   case TCM_ADDRESS_OUT_OF_RANGE:
+   /* CURRENT ERROR */
+   buffer[offset] = 0x70;
+   buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
+   /* ILLEGAL REQUEST */
+   buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
+   /* LOGICAL BLOCK ADDRESS OUT OF RANGE */
+   buffer[offset+SPC_ASC_KEY_OFFSET] = 0x21;
+   break;
case TCM_CHECK_CONDITION_UNIT_ATTENTION:
/* CURRENT ERROR */
buffer[offset] = 0x70;
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -157,6 +157,7 @@ enum tcm_sense_reason_table {
TCM_CHECK_CONDITION_UNIT_ATTENTION  = 0x0e,
TCM_CHECK_CONDITION_NOT_READY   = 0x0f,
TCM_RESERVATION_CONFLICT= 0x10,
+   TCM_ADDRESS_OUT_OF_RANGE= 0x11,
 };
 
 struct se_obj {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 47/73] s390/idle: fix sequence handling vs cpu hotplug

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Heiko Carstens 

commit 0008204ffe85d23382d6fd0f971f3f0fbe70bae2 upstream.

The s390 idle accounting code uses a sequence counter which gets used
when the per cpu idle statistics get updated and read.

One assumption on read access is that only when the sequence counter is
even and did not change while reading all values the result is valid.
On cpu hotplug however the per cpu data structure gets initialized via
a cpu hotplug notifier on CPU_ONLINE.
CPU_ONLINE however is too late, since the onlined cpu is already running
and might access the per cpu data. Worst case is that the data structure
gets initialized while an idle thread is updating its idle statistics.
This will result in an uneven sequence counter after an update.

As a result user space tools like top, which access /proc/stat in order
to get idle stats, will busy loop waiting for the sequence counter to
become even again, which will never happen until the queried cpu will
update its idle statistics again. And even then the sequence counter
will only have an even value for a couple of cpu cycles.

Fix this by moving the initialization of the per cpu idle statistics
to cpu_init(). I prefer that solution in favor of changing the
notifier to CPU_UP_PREPARE, which would be a different solution to
the problem.

Signed-off-by: Heiko Carstens 
Signed-off-by: Martin Schwidefsky 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
 arch/s390/kernel/processor.c |2 ++
 arch/s390/kernel/smp.c   |3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -26,12 +26,14 @@ static DEFINE_PER_CPU(struct cpuid, cpu_
 void __cpuinit cpu_init(void)
 {
struct cpuid *id = _cpu(cpu_id, smp_processor_id());
+   struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
 
get_cpu_id(id);
atomic_inc(_mm.mm_count);
current->active_mm = _mm;
BUG_ON(current->mm);
enter_lazy_tlb(_mm, current);
+   memset(idle, 0, sizeof(*idle));
 }
 
 /*
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1020,14 +1020,11 @@ static int __cpuinit smp_cpu_notify(stru
unsigned int cpu = (unsigned int)(long)hcpu;
struct cpu *c = _cpu(cpu_devices, cpu);
struct sys_device *s = >sysdev;
-   struct s390_idle_data *idle;
int err = 0;
 
switch (action) {
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
-   idle = _cpu(s390_idle, cpu);
-   memset(idle, 0, sizeof(struct s390_idle_data));
err = sysfs_create_group(>kobj, _online_attr_group);
break;
case CPU_DEAD:


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 48/73] rtlwifi: rtl8192de: Fix phy-based version calculation

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Forest Bond 

commit f1b00f4dab29b57bdf1bc03ef12020b280fd2a72 upstream.

Commit d83579e2a50ac68389e6b4c58b845c702cf37516 incorporated some
changes from the vendor driver that made it newly important that the
calculated hardware version correctly include the CHIP_92D bit, as all
of the IS_92D_* macros were changed to depend on it.  However, this bit
was being unset for dual-mac, dual-phy devices.  The vendor driver
behavior was modified to not do this, but unfortunately this change was
not picked up along with the others.  This caused scanning in the 2.4GHz
band to be broken, and possibly other bugs as well.

This patch brings the version calculation logic in parity with the
vendor driver in this regard, and in doing so fixes the regression.
However, the version calculation code in general continues to be largely
incoherent and messy, and needs to be cleaned up.

Signed-off-by: Forest Bond 
Signed-off-by: Larry Finger 
Signed-off-by: John W. Linville 
Signed-off-by: Ben Hutchings 
---
 drivers/net/wireless/rtlwifi/rtl8192de/phy.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c 
b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
index 18380a7..4420312 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
@@ -3345,21 +3345,21 @@ void rtl92d_phy_config_macphymode_info(struct 
ieee80211_hw *hw)
switch (rtlhal->macphymode) {
case DUALMAC_SINGLEPHY:
rtlphy->rf_type = RF_2T2R;
-   rtlhal->version |= CHIP_92D_SINGLEPHY;
+   rtlhal->version |= RF_TYPE_2T2R;
rtlhal->bandset = BAND_ON_BOTH;
rtlhal->current_bandtype = BAND_ON_2_4G;
break;
 
case SINGLEMAC_SINGLEPHY:
rtlphy->rf_type = RF_2T2R;
-   rtlhal->version |= CHIP_92D_SINGLEPHY;
+   rtlhal->version |= RF_TYPE_2T2R;
rtlhal->bandset = BAND_ON_BOTH;
rtlhal->current_bandtype = BAND_ON_2_4G;
break;
 
case DUALMAC_DUALPHY:
rtlphy->rf_type = RF_1T1R;
-   rtlhal->version &= (~CHIP_92D_SINGLEPHY);
+   rtlhal->version &= RF_TYPE_1T1R;
/* Now we let MAC0 run on 5G band. */
if (rtlhal->interfaceindex == 0) {
rtlhal->bandset = BAND_ON_5G;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 39/73] mwifiex: correction in mcs index check

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Amitkumar Karwar 

commit fe020120cb863ba918c6d603345342a880272c4d upstream.

mwifiex driver supports 2x2 chips as well. Hence valid mcs values
are 0 to 15. The check for mcs index is corrected in this patch.

For example: if 40MHz is enabled and mcs index is 11, "iw link"
command would show "tx bitrate: 108.0 MBit/s" without this patch.
Now it shows "tx bitrate: 108.0 MBit/s MCS 11 40Mhz" with the patch.

Signed-off-by: Amitkumar Karwar 
Signed-off-by: Bing Zhao 
Signed-off-by: John W. Linville 
Signed-off-by: Ben Hutchings 
---
 drivers/net/wireless/mwifiex/cfg80211.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c 
b/drivers/net/wireless/mwifiex/cfg80211.c
index 5c7fd18..76b5c0f 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -634,9 +634,9 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
 
/*
 * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid
-* MCS index values for us are 0 to 7.
+* MCS index values for us are 0 to 15.
 */
-   if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 8)) {
+   if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) {
sinfo->txrate.mcs = priv->tx_rate;
sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
/* 40MHz rate */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 41/73] USB: option: add ZTE MF821D

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Bjørn Mork 

commit 09110529780890804b22e997ae6b4fe3f0b3b158 upstream.

Sold by O2 (telefonica germany) under the name "LTE4G"

Tested-by: Thomas Schäfer 
Signed-off-by: Bjørn Mork 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Ben Hutchings 
---
 drivers/usb/serial/option.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 2b0c88d..08ff9b8 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -936,6 +936,8 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 
0xff),
  .driver_info = (kernel_ulong_t)_intf4_blacklist },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 
0xff),
+ .driver_info = (kernel_ulong_t)_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 
0xff),
  .driver_info = (kernel_ulong_t)_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 
0xff),


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 38/73] powerpc: Add "memory" attribute for mfmsr()

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Tiejun Chen 

commit b416c9a10baae6a177b4f9ee858b8d309542fbef upstream.

Add "memory" attribute in inline assembly language as a compiler
barrier to make sure 4.6.x GCC don't reorder mfmsr().

Signed-off-by: Tiejun Chen 
Signed-off-by: Benjamin Herrenschmidt 
Signed-off-by: Ben Hutchings 
---
 arch/powerpc/include/asm/reg.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 2baeb7c..6386086 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1025,7 +1025,8 @@
 /* Macros for setting and retrieving special purpose registers */
 #ifndef __ASSEMBLY__
 #define mfmsr()({unsigned long rval; \
-   asm volatile("mfmsr %0" : "=r" (rval)); rval;})
+   asm volatile("mfmsr %0" : "=r" (rval) : \
+   : "memory"); rval;})
 #ifdef CONFIG_PPC_BOOK3S_64
 #define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
 : : "r" (v) : "memory")


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 45/73] target: Fix possible integer underflow in UNMAP emulation

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Roland Dreier 

commit b7fc7f3777582dea85156a821d78a522a0c083aa upstream.

It's possible for an initiator to send us an UNMAP command with a
descriptor that is less than 8 bytes; in that case it's really bad for
us to set an unsigned int to that value, subtract 8 from it, and then
use that as a limit for our loop (since the value will wrap around to
a huge positive value).

Fix this by making size be signed and only looping if size >= 16 (ie
if we have at least a full descriptor available).

Also remove offset as an obfuscated name for the constant 8.

Signed-off-by: Roland Dreier 
Signed-off-by: Nicholas Bellinger 
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings 
---
 drivers/target/target_core_cdb.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1115,9 +1115,10 @@ int target_emulate_unmap(struct se_task
struct se_device *dev = cmd->se_dev;
unsigned char *buf, *ptr = NULL;
sector_t lba;
-   unsigned int size = cmd->data_length, range;
-   int ret = 0, offset;
-   unsigned short dl, bd_dl;
+   int size = cmd->data_length;
+   u32 range;
+   int ret = 0;
+   int dl, bd_dl;
 
if (!dev->transport->do_discard) {
pr_err("UNMAP emulation not supported for: %s\n",
@@ -1126,20 +1127,19 @@ int target_emulate_unmap(struct se_task
return -ENOSYS;
}
 
-   /* First UNMAP block descriptor starts at 8 byte offset */
-   offset = 8;
-   size -= 8;
-
buf = transport_kmap_data_sg(cmd);
 
dl = get_unaligned_be16([0]);
bd_dl = get_unaligned_be16([2]);
 
-   ptr = [offset];
-   pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
+   size = min(size - 8, bd_dl);
+
+   /* First UNMAP block descriptor starts at 8 byte offset */
+   ptr = [8];
+   pr_debug("UNMAP: Sub: %s Using dl: %u bd_dl: %u size: %u"
" ptr: %p\n", dev->transport->name, dl, bd_dl, size, ptr);
 
-   while (size) {
+   while (size >= 16) {
lba = get_unaligned_be64([0]);
range = get_unaligned_be32([8]);
pr_debug("UNMAP: Using lba: %llu and range: %u\n",


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 51/73] iommu/amd: Fix hotplug with iommu=pt

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Joerg Roedel 

commit 2c9195e990297068d0f1f1bd8e2f1d09538009da upstream.

This did not work because devices are not put into the
pt_domain. Fix this.

Signed-off-by: Joerg Roedel 
[bwh: Backported to 3.2: do not use iommu_dev_data::passthrough]
Signed-off-by: Ben Hutchings 
---
 drivers/iommu/amd_iommu.c |   17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1865,6 +1865,11 @@ static int device_change_notifier(struct
 
iommu_init_device(dev);
 
+   if (iommu_pass_through) {
+   attach_device(dev, pt_domain);
+   break;
+   }
+
domain = domain_for_device(dev);
 
/* allocate a protection domain if a device is added */
@@ -1880,10 +1885,7 @@ static int device_change_notifier(struct
list_add_tail(_domain->list, _pd_list);
spin_unlock_irqrestore(_pd_list_lock, flags);
 
-   if (!iommu_pass_through)
-   dev->archdata.dma_ops = _iommu_dma_ops;
-   else
-   dev->archdata.dma_ops = _dma_ops;
+   dev->archdata.dma_ops = _iommu_dma_ops;
 
break;
case BUS_NOTIFY_DEL_DEVICE:


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 52/73] drm/radeon: Try harder to avoid HW cursor ending on a multiple of 128 columns.

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Michel Dänzer 

commit f60ec4c7df043df81e62891ac45383d012afe0da upstream.

This could previously fail if either of the enabled displays was using a
horizontal resolution that is a multiple of 128, and only the leftmost column
of the cursor was (supposed to be) visible at the right edge of that display.

The solution is to move the cursor one pixel to the left in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33183

Signed-off-by: Michel Dänzer 
Reviewed-by: Alex Deucher 
Signed-off-by: Dave Airlie 
Signed-off-by: Ben Hutchings 
---
 drivers/gpu/drm/radeon/radeon_cursor.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c 
b/drivers/gpu/drm/radeon/radeon_cursor.c
index 42acc64..711e95a 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -262,8 +262,14 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
if (!(cursor_end & 0x7f))
w--;
}
-   if (w <= 0)
+   if (w <= 0) {
w = 1;
+   cursor_end = x - xorigin + w;
+   if (!(cursor_end & 0x7f)) {
+   x--;
+   WARN_ON_ONCE(x < 0);
+   }
+   }
}
}
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 50/73] ALSA: hda - Add support for Realtek ALC282

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: David Henningsson 

commit 4e01ec636e64707d202a1ca21a47bbc6d53085b7 upstream.

This codec has a separate dmic path (separate dmic only ADC),
and thus it looks mostly like ALC275.

BugLink: https://bugs.launchpad.net/bugs/1025377
Tested-by: Ray Chen 
Signed-off-by: David Henningsson 
Signed-off-by: Takashi Iwai 
Signed-off-by: Ben Hutchings 
---
 sound/pci/hda/patch_realtek.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a5b0b50..aef3139 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6988,6 +6988,7 @@ static const struct hda_codec_preset 
snd_hda_preset_realtek[] = {
{ .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
{ .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
{ .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
+   { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
{ .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  .patch = patch_alc861 },
{ .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 64/73] ext4: undo ext4_calc_metadata_amount if we fail to claim space

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

commit 03179fe92318e7934c180d96f12eff2cb36ef7b6 upstream.

The function ext4_calc_metadata_amount() has side effects, although
it's not obvious from its function name.  So if we fail to claim
space, regardless of whether we retry to claim the space again, or
return an error, we need to undo these side effects.

Otherwise we can end up incorrectly calculating the number of metadata
blocks needed for the operation, which was responsible for an xfstests
failure for test #271 when using an ext2 file system with delalloc
enabled.

Reported-by: Brian Foster 
Signed-off-by: "Theodore Ts'o" 
Signed-off-by: Ben Hutchings 
---
 fs/ext4/inode.c |   32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 25f809d..89b59cb 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1182,6 +1182,17 @@ static int ext4_da_reserve_space(struct inode *inode, 
ext4_lblk_t lblock)
struct ext4_inode_info *ei = EXT4_I(inode);
unsigned int md_needed;
int ret;
+   ext4_lblk_t save_last_lblock;
+   int save_len;
+
+   /*
+* We will charge metadata quota at writeout time; this saves
+* us from metadata over-estimation, though we may go over by
+* a small amount in the end.  Here we just reserve for data.
+*/
+   ret = dquot_reserve_block(inode, EXT4_C2B(sbi, 1));
+   if (ret)
+   return ret;
 
/*
 * recalculate the amount of metadata blocks to reserve
@@ -1190,32 +1201,31 @@ static int ext4_da_reserve_space(struct inode *inode, 
ext4_lblk_t lblock)
 */
 repeat:
spin_lock(>i_block_reservation_lock);
+   /*
+* ext4_calc_metadata_amount() has side effects, which we have
+* to be prepared undo if we fail to claim space.
+*/
+   save_len = ei->i_da_metadata_calc_len;
+   save_last_lblock = ei->i_da_metadata_calc_last_lblock;
md_needed = EXT4_NUM_B2C(sbi,
 ext4_calc_metadata_amount(inode, lblock));
trace_ext4_da_reserve_space(inode, md_needed);
-   spin_unlock(>i_block_reservation_lock);
 
/*
-* We will charge metadata quota at writeout time; this saves
-* us from metadata over-estimation, though we may go over by
-* a small amount in the end.  Here we just reserve for data.
-*/
-   ret = dquot_reserve_block(inode, EXT4_C2B(sbi, 1));
-   if (ret)
-   return ret;
-   /*
 * We do still charge estimated metadata to the sb though;
 * we cannot afford to run out of free blocks.
 */
if (ext4_claim_free_clusters(sbi, md_needed + 1, 0)) {
-   dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
+   ei->i_da_metadata_calc_len = save_len;
+   ei->i_da_metadata_calc_last_lblock = save_last_lblock;
+   spin_unlock(>i_block_reservation_lock);
if (ext4_should_retry_alloc(inode->i_sb, )) {
yield();
goto repeat;
}
+   dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
return -ENOSPC;
}
-   spin_lock(>i_block_reservation_lock);
ei->i_reserved_data_blocks++;
ei->i_reserved_meta_blocks += md_needed;
spin_unlock(>i_block_reservation_lock);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 35/73] ASoC: dapm: Fix locking during codec shutdown

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Liam Girdwood 

commit 01005a729a17ab419f61a366e22f3419e7a2c3fe upstream.

Codec shutdown performs a DAPM power sequence that might cause conflicts
and/or race conditions if another stream power event is running simultaneously.
Use card's dapm mutex to protect any potential race condition between them.

Signed-off-by: Misael Lopez Cruz 
Signed-off-by: Liam Girdwood 
Signed-off-by: Mark Brown 
Signed-off-by: Ben Hutchings 
---
 sound/soc/soc-dapm.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 5be4f9a..114f2af 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3537,10 +3537,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
 
 static void soc_dapm_shutdown_codec(struct snd_soc_dapm_context *dapm)
 {
+   struct snd_soc_card *card = dapm->card;
struct snd_soc_dapm_widget *w;
LIST_HEAD(down_list);
int powerdown = 0;
 
+   mutex_lock(>dapm_mutex);
+
list_for_each_entry(w, >card->widgets, list) {
if (w->dapm != dapm)
continue;
@@ -3563,6 +3566,8 @@ static void soc_dapm_shutdown_codec(struct 
snd_soc_dapm_context *dapm)
snd_soc_dapm_set_bias_level(dapm,
SND_SOC_BIAS_STANDBY);
}
+
+   mutex_unlock(>dapm_mutex);
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 44/73] target: Fix reading of data length fields for UNMAP commands

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Roland Dreier 

commit 1a5fa4576ec8a462313c7516b31d7453481ddbe8 upstream.

The UNMAP DATA LENGTH and UNMAP BLOCK DESCRIPTOR DATA LENGTH fields
are in the unmap descriptor (the payload transferred to our data out
buffer), not in the CDB itself.  Read them from the correct place in
target_emulated_unmap.

Signed-off-by: Roland Dreier 
Signed-off-by: Nicholas Bellinger 
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings 
---
 drivers/target/target_core_cdb.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/target/target_core_cdb.c
+++ b/drivers/target/target_core_cdb.c
@@ -1114,7 +1114,6 @@ int target_emulate_unmap(struct se_task
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev;
unsigned char *buf, *ptr = NULL;
-   unsigned char *cdb = >t_task_cdb[0];
sector_t lba;
unsigned int size = cmd->data_length, range;
int ret = 0, offset;
@@ -1130,11 +1129,12 @@ int target_emulate_unmap(struct se_task
/* First UNMAP block descriptor starts at 8 byte offset */
offset = 8;
size -= 8;
-   dl = get_unaligned_be16([0]);
-   bd_dl = get_unaligned_be16([2]);
 
buf = transport_kmap_data_sg(cmd);
 
+   dl = get_unaligned_be16([0]);
+   bd_dl = get_unaligned_be16([2]);
+
ptr = [offset];
pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
" ptr: %p\n", dev->transport->name, dl, bd_dl, size, ptr);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 34/73] usbdevfs: Correct amount of data copied to user in processcompl_compat

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Hans de Goede 

commit 2102e06a5f2e414694921f23591f072a5ba7db9f upstream.

iso data buffers may have holes in them if some packets were short, so for
iso urbs we should always copy the entire buffer, just like the regular
processcompl does.

Signed-off-by: Hans de Goede 
Acked-by: Alan Stern 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Ben Hutchings 
---
 drivers/usb/core/devio.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index e0f1079..62679bc 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1604,10 +1604,14 @@ static int processcompl_compat(struct async *as, void 
__user * __user *arg)
void __user *addr = as->userurb;
unsigned int i;
 
-   if (as->userbuffer && urb->actual_length)
-   if (copy_to_user(as->userbuffer, urb->transfer_buffer,
-urb->actual_length))
+   if (as->userbuffer && urb->actual_length) {
+   if (urb->number_of_packets > 0) /* Isochronous */
+   i = urb->transfer_buffer_length;
+   else/* Non-Isoc */
+   i = urb->actual_length;
+   if (copy_to_user(as->userbuffer, urb->transfer_buffer, i))
return -EFAULT;
+   }
if (put_user(as->status, >status))
return -EFAULT;
if (put_user(urb->actual_length, >actual_length))


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 30/73] ext4: pass a char * to ext4_count_free() instead of a buffer_head ptr

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

commit f6fb99cadcd44660c68e13f6eab28333653621e6 upstream.

Make it possible for ext4_count_free to operate on buffers and not
just data in buffer_heads.

Signed-off-by: "Theodore Ts'o" 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
 fs/ext4/balloc.c |3 ++-
 fs/ext4/bitmap.c |8 +++-
 fs/ext4/ext4.h   |2 +-
 fs/ext4/ialloc.c |3 ++-
 4 files changed, 8 insertions(+), 8 deletions(-)

--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -557,7 +557,8 @@ ext4_fsblk_t ext4_count_free_clusters(st
if (bitmap_bh == NULL)
continue;
 
-   x = ext4_count_free(bitmap_bh, sb->s_blocksize);
+   x = ext4_count_free(bitmap_bh->b_data,
+   EXT4_BLOCKS_PER_GROUP(sb) / 8);
printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n",
i, ext4_free_group_clusters(sb, gdp), x);
bitmap_count += x;
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -15,15 +15,13 @@
 
 static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 
0};
 
-unsigned int ext4_count_free(struct buffer_head *map, unsigned int numchars)
+unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
 {
unsigned int i, sum = 0;
 
-   if (!map)
-   return 0;
for (i = 0; i < numchars; i++)
-   sum += nibblemap[map->b_data[i] & 0xf] +
-   nibblemap[(map->b_data[i] >> 4) & 0xf];
+   sum += nibblemap[bitmap[i] & 0xf] +
+   nibblemap[(bitmap[i] >> 4) & 0xf];
return sum;
 }
 
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1757,7 +1757,7 @@ struct mmpd_data {
 # define NORET_AND noreturn,
 
 /* bitmap.c */
-extern unsigned int ext4_count_free(struct buffer_head *, unsigned);
+extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
 
 /* balloc.c */
 extern unsigned int ext4_block_group(struct super_block *sb,
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1057,7 +1057,8 @@ unsigned long ext4_count_free_inodes(str
if (!bitmap_bh)
continue;
 
-   x = ext4_count_free(bitmap_bh, EXT4_INODES_PER_GROUP(sb) / 8);
+   x = ext4_count_free(bitmap_bh->b_data,
+   EXT4_INODES_PER_GROUP(sb) / 8);
printk(KERN_DEBUG "group %lu: stored = %d, counted = %lu\n",
(unsigned long) i, ext4_free_inodes_count(sb, gdp), x);
bitmap_count += x;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 33/73] x86, microcode: Sanitize per-cpu microcode reloading interface

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Borislav Petkov 

commit c9fc3f778a6a215ace14ee556067c73982b6d40f upstream.

Microcode reloading in a per-core manner is a very bad idea for both
major x86 vendors. And the thing is, we have such interface with which
we can end up with different microcode versions applied on different
cores of an otherwise homogeneous wrt (family,model,stepping) system.

So turn off the possibility of doing that per core and allow it only
system-wide.

This is a minimal fix which we'd like to see in stable too thus the
more-or-less arbitrary decision to allow system-wide reloading only on
the BSP:

$ echo 1 > /sys/devices/system/cpu/cpu0/microcode/reload
...

and disable the interface on the other cores:

$ echo 1 > /sys/devices/system/cpu/cpu23/microcode/reload
-bash: echo: write error: Invalid argument

Also, allowing the reload only from one CPU (the BSP in
that case) doesn't allow the reload procedure to degenerate
into an O(n^2) deal when triggering reloads from all
/sys/devices/system/cpu/cpuX/microcode/reload sysfs nodes
simultaneously.

A more generic fix will follow.

Cc: Henrique de Moraes Holschuh 
Cc: Peter Zijlstra 
Signed-off-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1340280437-7718-2-git-send-email...@amd64.org
Signed-off-by: H. Peter Anvin 
Signed-off-by: Ben Hutchings 
---
 arch/x86/kernel/microcode_core.c |   26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index fbdfc69..24b852b 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -298,19 +298,31 @@ static ssize_t reload_store(struct device *dev,
const char *buf, size_t size)
 {
unsigned long val;
-   int cpu = dev->id;
-   ssize_t ret = 0;
+   int cpu;
+   ssize_t ret = 0, tmp_ret;
+
+   /* allow reload only from the BSP */
+   if (boot_cpu_data.cpu_index != dev->id)
+   return -EINVAL;
 
ret = kstrtoul(buf, 0, );
if (ret)
return ret;
 
-   if (val == 1) {
-   get_online_cpus();
-   if (cpu_online(cpu))
-   ret = reload_for_cpu(cpu);
-   put_online_cpus();
+   if (val != 1)
+   return size;
+
+   get_online_cpus();
+   for_each_online_cpu(cpu) {
+   tmp_ret = reload_for_cpu(cpu);
+   if (tmp_ret != 0)
+   pr_warn("Error reloading microcode on CPU %d\n", cpu);
+
+   /* save retval of the first encountered reload error */
+   if (!ret)
+   ret = tmp_ret;
}
+   put_online_cpus();
 
if (!ret)
ret = size;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 32/73] x86, microcode: microcode_core.c simple_strtoul cleanup

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Shuah Khan 

commit e826abd523913f63eb03b59746ffb16153c53dc4 upstream.

Change reload_for_cpu() in kernel/microcode_core.c to call kstrtoul()
instead of calling obsoleted simple_strtoul().

Signed-off-by: Shuah Khan 
Reviewed-by: Borislav Petkov 
Link: http://lkml.kernel.org/r/1336324264.2897.9.camel@lorien2
Signed-off-by: H. Peter Anvin 
Signed-off-by: Ben Hutchings 
---
 arch/x86/kernel/microcode_core.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index c9bda6d..fbdfc69 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -299,12 +299,11 @@ static ssize_t reload_store(struct device *dev,
 {
unsigned long val;
int cpu = dev->id;
-   int ret = 0;
-   char *end;
+   ssize_t ret = 0;
 
-   val = simple_strtoul(buf, , 0);
-   if (end == buf)
-   return -EINVAL;
+   ret = kstrtoul(buf, 0, );
+   if (ret)
+   return ret;
 
if (val == 1) {
get_online_cpus();


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 26/73] wireless: rt2x00: rt2800usb more devices were identified

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 

commit e828b9fb4f6c3513950759d5fb902db5bd054048 upstream.

found in 2012_03_22_RT5572_Linux_STA_v2.6.0.0_DPO

RT3070:
(0x2019,0x5201)  Planex Communications, Inc. RT8070
(0x7392,0x4085)  2L Central Europe BV 8070
7392 is Edimax

RT35xx:
(0x1690,0x0761) Askey
was Fujitsu Stylistic 550, but 1690 is Askey

Signed-off-by: Xose Vazquez Perez 
Acked-by: Gertjan van Wingerde 
Signed-off-by: John W. Linville 
Signed-off-by: Ben Hutchings 
---
 drivers/net/wireless/rt2x00/rt2800usb.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c 
b/drivers/net/wireless/rt2x00/rt2800usb.c
index 5851be7..5601302 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -992,6 +992,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
/* DVICO */
{ USB_DEVICE(0x0fe9, 0xb307) },
/* Edimax */
+   { USB_DEVICE(0x7392, 0x4085) },
{ USB_DEVICE(0x7392, 0x7711) },
{ USB_DEVICE(0x7392, 0x7717) },
{ USB_DEVICE(0x7392, 0x7718) },
@@ -1067,6 +1068,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
/* Philips */
{ USB_DEVICE(0x0471, 0x200f) },
/* Planex */
+   { USB_DEVICE(0x2019, 0x5201) },
{ USB_DEVICE(0x2019, 0xab25) },
{ USB_DEVICE(0x2019, 0xed06) },
/* Quanta */
@@ -1150,6 +1152,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
{ USB_DEVICE(0x8516, 0x3572) },
/* Askey */
{ USB_DEVICE(0x1690, 0x0744) },
+   { USB_DEVICE(0x1690, 0x0761) },
{ USB_DEVICE(0x1690, 0x0764) },
/* Cisco */
{ USB_DEVICE(0x167b, 0x4001) },
@@ -1235,12 +1238,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
{ USB_DEVICE(0x07d1, 0x3c0b) },
{ USB_DEVICE(0x07d1, 0x3c17) },
{ USB_DEVICE(0x2001, 0x3c17) },
-   /* Edimax */
-   { USB_DEVICE(0x7392, 0x4085) },
/* Encore */
{ USB_DEVICE(0x203d, 0x14a1) },
-   /* Fujitsu Stylistic 550 */
-   { USB_DEVICE(0x1690, 0x0761) },
/* Gemtek */
{ USB_DEVICE(0x15a9, 0x0010) },
/* Gigabyte */
@@ -1261,7 +1260,6 @@ static struct usb_device_id rt2800usb_device_table[] = {
{ USB_DEVICE(0x05a6, 0x0101) },
{ USB_DEVICE(0x1d4d, 0x0010) },
/* Planex */
-   { USB_DEVICE(0x2019, 0x5201) },
{ USB_DEVICE(0x2019, 0xab24) },
/* Qcom */
{ USB_DEVICE(0x18e8, 0x6259) },


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GPIO] Crashed when not using

2012-07-30 Thread Poddar, Sourav
Hi Kevin,

On Tue, Jul 31, 2012 at 2:06 AM, Kevin Hilman  wrote:
> "Poddar, Sourav"  writes:
>
>> On Mon, Jul 30, 2012 at 3:04 PM, DebBarma, Tarun Kanti
>>  wrote:
>>> Sourav,
>>>
>>> On Mon, Jul 30, 2012 at 2:13 PM, Poddar, Sourav  
>>> wrote:
 Hi All,

 I tried using gpio as an interrupt line for my driver
 (drivers/staging/iio/light/tsl2x7x_core.c) for omap5.
 The interrupt line number was directly passed to the driver using
 device tree. But what I observed
 is the following crash..


 [1.599273] mousedev: PS/2 mouse device common for all mice
 [1.607513] i2c /dev entries driver
 [1.613739] Driver for 1-wire Dallas network protocol.
 [1.622650] usbcore: registered new interface driver usbhid
 [1.628540] usbhid: USB HID core driver
 [1.633728] Unhandled fault: imprecise external abort (0x1406) at 
 0x
 [1.641113] Internal error: : 1406 [#1] SMP ARM
 [1.645874] Modules linked in:
 [1.649078] CPU: 0Not tainted  (3.5.0-02045-g0b474d6-dirty #415)
 [1.655761] PC is at _set_gpio_triggering+0x44/0x264
 [1.660980] LR is at gpio_irq_type+0xb8/0x160
 [1.665527] pc : []lr : []psr: 6093
 [1.665527] sp : dc851df0  ip : c07a8f00  fp : 
 [1.677581] r10: 0081  r9 :   r8 : dc8ffc10
 [1.683074] r7 : 2093  r6 :   r5 : 0001  r4 : fa05b000
 [1.689910] r3 : dc8ffc10  r2 : 0002  r1 : 0002  r0 : 0140
 [1.696746] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM
 Segment kernel
 [1.704528] Control: 10c53c7d  Table: 8000406a  DAC: 0017
 [1.710540] Process swapper/0 (pid: 1, stack limit = 0xdc8502f8)
 [1.716857] Stack: (0xdc851df0 to 0xdc852000)
 [1.721405] 1de0: 0002
 c0731280 dc8ffc6c 2093
 [1.730010] 1e00: c02dc224 c0731280 dc8d4980  c07a8e50
 0141 0002 c00a37b8
 [1.738586] 1e20: 2002 c0731280 dc8d4980 0141 c07312d4
 c07312b4 4013 c00a3d7c
 [1.747161] 1e40: 0141 c06728c0  c0090578 c247f000
 c00a2d5c c0412258 0141
 [1.755737] 1e60: c0731280 c0537818 dc8d4980 c00a3fe4 c07bf6a0
 2002 c071bed8 c247f000
 [1.764312] 1e80: dc9df000 0004 c07bf6a0 dc9df020 c247f3c0
 c04ea344 c06728c0 c247f000
 [1.772888] 1ea0:  09090578 c07bf6a0 dc9df004 dc9df000
 c04ea194 0091 c071bed8
 [1.781494] 1ec0: c06f89f4 c03e13c0 c03e1314 dc9df020 c0d1afd8
 dc9df054 c07bf60c c03272ac
 [1.790069] 1ee0: dc9df020 c07bf60c dc9df054  0091
 c03274c0 c07bf60c dc851f08
 [1.798645] 1f00: c032742c c0325b10 dc8f26a8 dc9ef790 
 c07bf60c c07bcea8 c243d6c0
 [1.807220] 1f20:  c0326240 c0672958 c02bce08 c07bf5e4
 c07bf60c c03e12a0 
 [1.815795] 1f40: 0091 c071bed8 c06f89f4 c0327ab0 c07bf5e4
 0007 c07c8c40 
 [1.824401] 1f60: 0091 c03e1738  dc85 0007
 c0008648  c112c9f0
 [1.832977] 1f80: c06a6d58 c06f89f4 0001 6013 c06694c8
  0006 0006
 [1.841552] 1fa0: 6013 c0700a20 0007 c07c8c40 c06d020c
 0091 c071bed8 c0700a28
 [1.850128] 1fc0:  c06d0380 0006 0006 c06d020c
   c06d028c
 [1.858703] 1fe0: c001548c 0013   
 c001548c 3f3f3f3f 3f3f3f3f
 [1.867309] [] (_set_gpio_triggering+0x44/0x264) from
 [] (gpio_irq_type+0x0/0x160)
 [1.877075] [] (gpio_irq_type+0x0/0x160) from [<2002>] 
 (0x2002)
 [1.884552] Code: e3120008 11816006 01c66001 e7846000 (e593c0fc)
 [1.890960] [ cut here ]
 [1.895812] WARNING: at arch/arm/mach-omap2/omap_l3_noc.c:113
 l3_interrupt_handler+0x184/0x1bc()
 [1.905029] L3 custom error: MASTER:MPU TARGET:L4 PER2
 [1.910430] Modules linked in:
 [1.913635] [] (unwind_backtrace+0x0/0xf4) from
 [] (warn_slowpath_common+0x4c/0x64)
 [1.923492] [] (warn_slowpath_common+0x4c/0x64) from
 [] (warn_slowpath_fmt+0x30/0x40)
 [1.933563] [] (warn_slowpath_fmt+0x30/0x40) from
 [] (l3_interrupt_handler+0x184/0x1bc)
 [1.943786] [] (l3_interrupt_handler+0x184/0x1bc) from
 [] (handle_irq_event_percpu+0x64/0x24c)
 [1.954650] [] (handle_irq_event_percpu+0x64/0x24c) from
 [] (handle_irq_event+0x3c/0x5c)
 [1.964965] [] (handle_irq_event+0x3c/0x5c) from
 [] (handle_fasteoi_irq+0x98/0x13c)
 [1.974822] [] (handle_fasteoi_irq+0x98/0x13c) from
 [] (generic_handle_irq+0x34/0x44)
 [1.984863] [] (generic_handle_irq+0x34/0x44) from
 [] (handle_IRQ+0x4c/0xac)
 [1.994110] [] (handle_IRQ+0x4c/0xac) from []
 (gic_handle_irq+0x2c/0x60)
 [

[ 25/73] wireless: rt2x00: rt2800usb add more devices ids

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 

commit 63b376411173c343bbcb450f95539da91f079e0c upstream.

They were taken from ralink drivers:
2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO
2012_03_22_RT5572_Linux_STA_v2.6.0.0_DPO

0x1eda,0x2210 RT3070 Airties

0x083a,0xb511 RT3370 Panasonic
0x0471,0x20dd RT3370 Philips

0x1690,0x0764 RT35xx Askey
0x0df6,0x0065 RT35xx Sitecom
0x0df6,0x0066 RT35xx Sitecom
0x0df6,0x0068 RT35xx Sitecom

0x2001,0x3c1c RT5370 DLink
0x2001,0x3c1d RT5370 DLink

2001 is D-Link not Alpha

Signed-off-by: Xose Vazquez Perez 
Acked-by: Gertjan van Wingerde 
Signed-off-by: John W. Linville 
[bwh: Backported to 3.2: drop the 5372 devices]
Signed-off-by: Ben Hutchings 
---
 drivers/net/wireless/rt2x00/rt2800usb.c |   17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -876,6 +876,7 @@ static struct usb_device_id rt2800usb_de
{ USB_DEVICE(0x1482, 0x3c09) },
/* AirTies */
{ USB_DEVICE(0x1eda, 0x2012) },
+   { USB_DEVICE(0x1eda, 0x2210) },
{ USB_DEVICE(0x1eda, 0x2310) },
/* Allwin */
{ USB_DEVICE(0x8516, 0x2070) },
@@ -1088,6 +1089,10 @@ static struct usb_device_id rt2800usb_de
 #ifdef CONFIG_RT2800USB_RT33XX
/* Belkin */
{ USB_DEVICE(0x050d, 0x945b) },
+   /* Panasonic */
+   { USB_DEVICE(0x083a, 0xb511) },
+   /* Philips */
+   { USB_DEVICE(0x0471, 0x20dd) },
/* Ralink */
{ USB_DEVICE(0x148f, 0x3370) },
{ USB_DEVICE(0x148f, 0x8070) },
@@ -1099,6 +1104,7 @@ static struct usb_device_id rt2800usb_de
{ USB_DEVICE(0x8516, 0x3572) },
/* Askey */
{ USB_DEVICE(0x1690, 0x0744) },
+   { USB_DEVICE(0x1690, 0x0764) },
/* Cisco */
{ USB_DEVICE(0x167b, 0x4001) },
/* EnGenius */
@@ -1113,6 +1119,9 @@ static struct usb_device_id rt2800usb_de
/* Sitecom */
{ USB_DEVICE(0x0df6, 0x0041) },
{ USB_DEVICE(0x0df6, 0x0062) },
+   { USB_DEVICE(0x0df6, 0x0065) },
+   { USB_DEVICE(0x0df6, 0x0066) },
+   { USB_DEVICE(0x0df6, 0x0068) },
/* Toshiba */
{ USB_DEVICE(0x0930, 0x0a07) },
/* Zinwell */
@@ -1122,6 +1131,9 @@ static struct usb_device_id rt2800usb_de
/* Azurewave */
{ USB_DEVICE(0x13d3, 0x3329) },
{ USB_DEVICE(0x13d3, 0x3365) },
+   /* D-Link */
+   { USB_DEVICE(0x2001, 0x3c1c) },
+   { USB_DEVICE(0x2001, 0x3c1d) },
/* Ralink */
{ USB_DEVICE(0x148f, 0x5370) },
{ USB_DEVICE(0x148f, 0x5372) },


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 29/73] usb: gadget: Fix g_ether interface link status

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Kevin Cernekee 

commit 31bde1ceaa873bcaecd49e829bfabceacc4c512d upstream.

A "usb0" interface that has never been connected to a host has an unknown
operstate, and therefore the IFF_RUNNING flag is (incorrectly) asserted
when queried by ifconfig, ifplugd, etc.  This is a result of calling
netif_carrier_off() too early in the probe function; it should be called
after register_netdev().

Similar problems have been fixed in many other drivers, e.g.:

e826eafa6 (bonding: Call netif_carrier_off after register_netdevice)
0d672e9f8 (drivers/net: Call netif_carrier_off at the end of the probe)
6a3c869a6 (cxgb4: fix reported state of interfaces without link)

Fix is to move netif_carrier_off() to the end of the function.

Signed-off-by: Kevin Cernekee 
Signed-off-by: Felipe Balbi 
Signed-off-by: Ben Hutchings 
---
 drivers/usb/gadget/u_ether.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 47cf48b..5b46f02 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -798,12 +798,6 @@ int gether_setup_name(struct usb_gadget *g, u8 
ethaddr[ETH_ALEN],
 
SET_ETHTOOL_OPS(net, );
 
-   /* two kinds of host-initiated state changes:
-*  - iff DATA transfer is active, carrier is "on"
-*  - tx queueing enabled if open *and* carrier is "on"
-*/
-   netif_carrier_off(net);
-
dev->gadget = g;
SET_NETDEV_DEV(net, >dev);
SET_NETDEV_DEVTYPE(net, _type);
@@ -817,6 +811,12 @@ int gether_setup_name(struct usb_gadget *g, u8 
ethaddr[ETH_ALEN],
INFO(dev, "HOST MAC %pM\n", dev->host_mac);
 
the_dev = dev;
+
+   /* two kinds of host-initiated state changes:
+*  - iff DATA transfer is active, carrier is "on"
+*  - tx queueing enabled if open *and* carrier is "on"
+*/
+   netif_carrier_off(net);
}
 
return status;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 22/73] x86: Fix boot on Twinhead H12Y

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Alan Cox 

commit 80b3e557371205566a71e569fbfcce5b11f92dbe upstream.

Despite lots of investigation into why this is needed we don't
know or have an elegant cure. The only answer found on this
laptop is to mark a problem region as used so that Linux doesn't
put anything there.

Currently all the users add reserve= command lines and anyone
not knowing this needs to find the magic page that documents it.
Automate it instead.

Signed-off-by: Alan Cox 
Tested-and-bugfixed-by: Arne Fitzenreiter 
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?id=10231
Link: http://lkml.kernel.org/r/20120515174347.5109.94551.stgit@bluebook
Signed-off-by: Ingo Molnar 
Signed-off-by: Ben Hutchings 
---
 arch/x86/pci/fixup.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index d0e6e40..5dd467b 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -519,3 +519,20 @@ static void sb600_disable_hpet_bar(struct pci_dev *dev)
}
 }
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, 0x4385, sb600_disable_hpet_bar);
+
+/*
+ * Twinhead H12Y needs us to block out a region otherwise we map devices
+ * there and any access kills the box.
+ *
+ *   See: https://bugzilla.kernel.org/show_bug.cgi?id=10231
+ *
+ * Match off the LPC and svid/sdid (older kernels lose the bridge subvendor)
+ */
+static void __devinit twinhead_reserve_killing_zone(struct pci_dev *dev)
+{
+if (dev->subsystem_vendor == 0x14FF && dev->subsystem_device == 
0xA003) {
+pr_info("Reserving memory on Twinhead H12Y\n");
+request_mem_region(0xFFB0, 0x10, "twinhead");
+}
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, 
twinhead_reserve_killing_zone);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 40/73] USB: option: Ignore ZTE (Vodafone) K3570/71 net interfaces

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: "Andrew Bird (Sphere Systems)" 

commit f264ddea0109bf7ce8aab920d64a637e830ace5b upstream.

These interfaces need to be handled by QMI/WWAN driver

Signed-off-by: Andrew Bird 
Signed-off-by: David S. Miller 
Signed-off-by: Ben Hutchings 
---
 drivers/usb/serial/option.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6815701..836cfa9 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -903,8 +903,10 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 
0xff),
  .driver_info = (kernel_ulong_t)_intf4_blacklist },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 
0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 
0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 
0xff),
+ .driver_info = (kernel_ulong_t)_intf4_blacklist },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 
0xff),
+ .driver_info = (kernel_ulong_t)_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 
0xff) },


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 31/73] ftrace: Disable function tracing during suspend/resume and hibernation, again

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: "Srivatsa S. Bhat" 

commit 443772d408a25af62498793f6f805ce3c559309a upstream.

If function tracing is enabled for some of the low-level suspend/resume
functions, it leads to triple fault during resume from suspend, ultimately
ending up in a reboot instead of a resume (or a total refusal to come out
of suspended state, on some machines).

This issue was explained in more detail in commit f42ac38c59e0a03d (ftrace:
disable tracing for suspend to ram). However, the changes made by that commit
got reverted by commit cbe2f5a6e84eebb (tracing: allow tracing of
suspend/resume & hibernation code again). So, unfortunately since things are
not yet robust enough to allow tracing of low-level suspend/resume functions,
suspend/resume is still broken when ftrace is enabled.

So fix this by disabling function tracing during suspend/resume & hibernation.

Signed-off-by: Srivatsa S. Bhat 
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Ben Hutchings 
---
 kernel/power/hibernate.c |6 ++
 kernel/power/suspend.c   |3 +++
 2 files changed, 9 insertions(+)

--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -367,6 +367,7 @@ int hibernation_snapshot(int platform_mo
}
 
suspend_console();
+   ftrace_stop();
pm_restrict_gfp_mask();
error = dpm_suspend(PMSG_FREEZE);
if (error)
@@ -392,6 +393,7 @@ int hibernation_snapshot(int platform_mo
if (error || !in_suspend)
pm_restore_gfp_mask();
 
+   ftrace_start();
resume_console();
dpm_complete(msg);
 
@@ -496,6 +498,7 @@ int hibernation_restore(int platform_mod
 
pm_prepare_console();
suspend_console();
+   ftrace_stop();
pm_restrict_gfp_mask();
error = dpm_suspend_start(PMSG_QUIESCE);
if (!error) {
@@ -503,6 +506,7 @@ int hibernation_restore(int platform_mod
dpm_resume_end(PMSG_RECOVER);
}
pm_restore_gfp_mask();
+   ftrace_start();
resume_console();
pm_restore_console();
return error;
@@ -529,6 +533,7 @@ int hibernation_platform_enter(void)
 
entering_platform_hibernation = true;
suspend_console();
+   ftrace_stop();
error = dpm_suspend_start(PMSG_HIBERNATE);
if (error) {
if (hibernation_ops->recover)
@@ -572,6 +577,7 @@ int hibernation_platform_enter(void)
  Resume_devices:
entering_platform_hibernation = false;
dpm_resume_end(PMSG_RESTORE);
+   ftrace_start();
resume_console();
 
  Close:
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "power.h"
@@ -220,6 +221,7 @@ int suspend_devices_and_enter(suspend_st
goto Close;
}
suspend_console();
+   ftrace_stop();
suspend_test_start();
error = dpm_suspend_start(PMSG_SUSPEND);
if (error) {
@@ -239,6 +241,7 @@ int suspend_devices_and_enter(suspend_st
suspend_test_start();
dpm_resume_end(PMSG_RESUME);
suspend_test_finish("resume devices");
+   ftrace_start();
resume_console();
  Close:
if (suspend_ops->end)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 24/73] cifs: when CONFIG_HIGHMEM is set, serialize the read/write kmaps

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Jeff Layton 

commit 3cf003c08be785af4bee9ac05891a15bcbff856a upstream.

Jian found that when he ran fsx on a 32 bit arch with a large wsize the
process and one of the bdi writeback kthreads would sometimes deadlock
with a stack trace like this:

crash> bt
PID: 2789   TASK: f02edaa0  CPU: 3   COMMAND: "fsx"
 #0 [eed63cbc] schedule at c083c5b3
 #1 [eed63d80] kmap_high at c0500ec8
 #2 [eed63db0] cifs_async_writev at f7fabcd7 [cifs]
 #3 [eed63df0] cifs_writepages at f7fb7f5c [cifs]
 #4 [eed63e50] do_writepages at c04f3e32
 #5 [eed63e54] __filemap_fdatawrite_range at c04e152a
 #6 [eed63ea4] filemap_fdatawrite at c04e1b3e
 #7 [eed63eb4] cifs_file_aio_write at f7fa111a [cifs]
 #8 [eed63ecc] do_sync_write at c052d202
 #9 [eed63f74] vfs_write at c052d4ee
#10 [eed63f94] sys_write at c052df4c
#11 [eed63fb0] ia32_sysenter_target at c0409a98
EAX: 0004  EBX: 0003  ECX: abd73b73  EDX: 012a65c6
DS:  007b  ESI: 012a65c6  ES:  007b  EDI: 
SS:  007b  ESP: bf8db178  EBP: bf8db1f8  GS:  0033
CS:  0073  EIP: 4424  ERR: 0004  EFLAGS: 0246

Each task would kmap part of its address array before getting stuck, but
not enough to actually issue the write.

This patch fixes this by serializing the marshal_iov operations for
async reads and writes. The idea here is to ensure that cifs
aggressively tries to populate a request before attempting to fulfill
another one. As soon as all of the pages are kmapped for a request, then
we can unlock and allow another one to proceed.

There's no need to do this serialization on non-CONFIG_HIGHMEM arches
however, so optimize all of this out when CONFIG_HIGHMEM isn't set.

Reported-by: Jian Li 
Signed-off-by: Jeff Layton 
Signed-off-by: Steve French 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
 fs/cifs/cifssmb.c |   30 ++
 1 file changed, 30 insertions(+)

--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -89,6 +89,32 @@ static struct {
 /* Forward declarations */
 static void cifs_readv_complete(struct work_struct *work);
 
+#ifdef CONFIG_HIGHMEM
+/*
+ * On arches that have high memory, kmap address space is limited. By
+ * serializing the kmap operations on those arches, we ensure that we don't
+ * end up with a bunch of threads in writeback with partially mapped page
+ * arrays, stuck waiting for kmap to come back. That situation prevents
+ * progress and can deadlock.
+ */
+static DEFINE_MUTEX(cifs_kmap_mutex);
+
+static inline void
+cifs_kmap_lock(void)
+{
+   mutex_lock(_kmap_mutex);
+}
+
+static inline void
+cifs_kmap_unlock(void)
+{
+   mutex_unlock(_kmap_mutex);
+}
+#else /* !CONFIG_HIGHMEM */
+#define cifs_kmap_lock() do { ; } while(0)
+#define cifs_kmap_unlock() do { ; } while(0)
+#endif /* CONFIG_HIGHMEM */
+
 /* Mark as invalid, all open files on tree connections since they
were closed when session to server was lost */
 static void mark_open_files_invalid(struct cifs_tcon *pTcon)
@@ -1540,6 +1566,7 @@ cifs_readv_receive(struct TCP_Server_Inf
eof_index = eof ? (eof - 1) >> PAGE_CACHE_SHIFT : 0;
cFYI(1, "eof=%llu eof_index=%lu", eof, eof_index);
 
+   cifs_kmap_lock();
list_for_each_entry_safe(page, tpage, >pages, lru) {
if (remaining >= PAGE_CACHE_SIZE) {
/* enough data to fill the page */
@@ -1589,6 +1616,7 @@ cifs_readv_receive(struct TCP_Server_Inf
page_cache_release(page);
}
}
+   cifs_kmap_unlock();
 
/* issue the read if we have any iovecs left to fill */
if (rdata->nr_iov > 1) {
@@ -2171,6 +2199,7 @@ cifs_async_writev(struct cifs_writedata
iov[0].iov_base = smb;
 
/* marshal up the pages into iov array */
+   cifs_kmap_lock();
wdata->bytes = 0;
for (i = 0; i < wdata->nr_pages; i++) {
iov[i + 1].iov_len = min(inode->i_size -
@@ -2179,6 +2208,7 @@ cifs_async_writev(struct cifs_writedata
iov[i + 1].iov_base = kmap(wdata->pages[i]);
wdata->bytes += iov[i + 1].iov_len;
}
+   cifs_kmap_unlock();
 
cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes);
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 21/73] cx25821: Remove bad strcpy to read-only char*

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Ezequiel Garcia 

commit 380e99fc44d79bc35af9ff1d3316ef4027ce775e upstream.

The strcpy was being used to set the name of the board.  Since the
destination char* was read-only and the name is set statically at
compile time; this was both wrong and redundant.

The type of char* is changed to const char* to prevent future errors.

Reported-by: Radek Masin 
Signed-off-by: Ezequiel Garcia 
[ Taking directly due to vacations   - Linus ]
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 drivers/media/video/cx25821/cx25821-core.c |3 ---
 drivers/media/video/cx25821/cx25821.h  |2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/video/cx25821/cx25821-core.c 
b/drivers/media/video/cx25821/cx25821-core.c
index 83c1aa6..f11f6f0 100644
--- a/drivers/media/video/cx25821/cx25821-core.c
+++ b/drivers/media/video/cx25821/cx25821-core.c
@@ -904,9 +904,6 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
list_add_tail(>devlist, _devlist);
mutex_unlock(_devlist_mutex);
 
-   strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
-   strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
-
if (dev->pci->device != 0x8210) {
pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
__func__, dev->pci->device);
diff --git a/drivers/media/video/cx25821/cx25821.h 
b/drivers/media/video/cx25821/cx25821.h
index b9aa801..029f293 100644
--- a/drivers/media/video/cx25821/cx25821.h
+++ b/drivers/media/video/cx25821/cx25821.h
@@ -187,7 +187,7 @@ enum port {
 };
 
 struct cx25821_board {
-   char *name;
+   const char *name;
enum port porta;
enum port portb;
enum port portc;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 23/73] r8169: RxConfig hack for the 8168evl.

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: françois romieu 

commit eb2dc35d99028b698cdedba4f5522bc43e576bd2 upstream.

The 8168evl (RTL_GIGA_MAC_VER_34) based Gigabyte GA-990FXA motherboards
are very prone to NETDEV watchdog problems without this change. See
https://bugzilla.kernel.org/show_bug.cgi?id=42899 for instance.

I don't know why it *works*. It's depressingly effective though.

For the record:
- the problem may go along IOMMU (AMD-Vi) errors but it really looks
  like a red herring.
- the patch sets the RX_MULTI_EN bit. If the 8168c doc is any guide,
  the chipset now fetches several Rx descriptors at a time.
- long ago the driver ignored the RX_MULTI_EN bit.
  e542a2269f232d61270ceddd42b73a4348dee2bb changed the RxConfig
  settings. Whatever the problem it's now labeled a regression.
- Realtek's own driver can identify two different 8168evl devices
  (CFG_METHOD_16 and CFG_METHOD_17) where the r8169 driver only
  sees one. It sucks.

Signed-off-by: Francois Romieu 
Signed-off-by: David S. Miller 
Signed-off-by: Ben Hutchings 
---
 drivers/net/ethernet/realtek/r8169.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/realtek/r8169.c 
b/drivers/net/ethernet/realtek/r8169.c
index 7260aa7..d7a04e0 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -3894,6 +3894,7 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
case RTL_GIGA_MAC_VER_22:
case RTL_GIGA_MAC_VER_23:
case RTL_GIGA_MAC_VER_24:
+   case RTL_GIGA_MAC_VER_34:
RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
break;
default:


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 20/73] powerpc/ftrace: Fix assembly trampoline register usage

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: roger blofeld 

commit fd5a42980e1cf327b7240adf5e7b51ea41c23437 upstream.

Just like the module loader, ftrace needs to be updated to use r12
instead of r11 with newer gcc's.

Signed-off-by: Roger Blofeld 
Signed-off-by: Benjamin Herrenschmidt 
Signed-off-by: Ben Hutchings 
---
 arch/powerpc/kernel/ftrace.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 6f33296..91b46b7 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -240,9 +240,9 @@ __ftrace_make_nop(struct module *mod,
 
/*
 * On PPC32 the trampoline looks like:
-*  0x3d, 0x60, 0x00, 0x00  lis r11,sym@ha
-*  0x39, 0x6b, 0x00, 0x00  addi r11,r11,sym@l
-*  0x7d, 0x69, 0x03, 0xa6  mtctr r11
+*  0x3d, 0x80, 0x00, 0x00  lis r12,sym@ha
+*  0x39, 0x8c, 0x00, 0x00  addi r12,r12,sym@l
+*  0x7d, 0x89, 0x03, 0xa6  mtctr r12
 *  0x4e, 0x80, 0x04, 0x20  bctr
 */
 
@@ -257,9 +257,9 @@ __ftrace_make_nop(struct module *mod,
pr_devel(" %08x %08x ", jmp[0], jmp[1]);
 
/* verify that this is what we expect it to be */
-   if (((jmp[0] & 0x) != 0x3d60) ||
-   ((jmp[1] & 0x) != 0x396b) ||
-   (jmp[2] != 0x7d6903a6) ||
+   if (((jmp[0] & 0x) != 0x3d80) ||
+   ((jmp[1] & 0x) != 0x398c) ||
+   (jmp[2] != 0x7d8903a6) ||
(jmp[3] != 0x4e800420)) {
printk(KERN_ERR "Not a trampoline\n");
return -EINVAL;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 27/73] rt2800usb: 2001:3c17 is an RT3370 device

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Albert Pool 

commit 8fd9d059af12786341dec5a688e607bcdb372238 upstream.

D-Link DWA-123 rev A1

Signed-off-by: Albert Pool
Acked-by: Gertjan van Wingerde 
Signed-off-by: John W. Linville 
Signed-off-by: Ben Hutchings 
---
 drivers/net/wireless/rt2x00/rt2800usb.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c 
b/drivers/net/wireless/rt2x00/rt2800usb.c
index bf78317..20a5040 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1137,6 +1137,8 @@ static struct usb_device_id rt2800usb_device_table[] = {
 #ifdef CONFIG_RT2800USB_RT33XX
/* Belkin */
{ USB_DEVICE(0x050d, 0x945b) },
+   /* D-Link */
+   { USB_DEVICE(0x2001, 0x3c17) },
/* Panasonic */
{ USB_DEVICE(0x083a, 0xb511) },
/* Philips */
@@ -1237,7 +1239,6 @@ static struct usb_device_id rt2800usb_device_table[] = {
/* D-Link */
{ USB_DEVICE(0x07d1, 0x3c0b) },
{ USB_DEVICE(0x07d1, 0x3c17) },
-   { USB_DEVICE(0x2001, 0x3c17) },
/* Encore */
{ USB_DEVICE(0x203d, 0x14a1) },
/* Gemtek */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 28/73] ARM: OMAP2+: OPP: Fix to ensure check of right oppdef after bad one

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Nishanth Menon 

commit b110547e586eb5825bc1d04aa9147bff83b57672 upstream.

Commit 9fa2df6b90786301b175e264f5fa9846aba81a65
(ARM: OMAP2+: OPP: allow OPP enumeration to continue if device is not present)
makes the logic:
for (i = 0; i < opp_def_size; i++) {

if (!oh || !oh->od) {

continue;
}

opp_def++;
}

In short, the moment we hit a "Bad OPP", we end up looping the list
comparing against the bad opp definition pointer for the rest of the
iteration count. Instead, increment opp_def in the for loop itself
and allow continue to be used in code without much thought so that
we check the next set of OPP definition pointers :)

Cc: Steve Sakoman 
Cc: Tony Lindgren 
Signed-off-by: Nishanth Menon 
Signed-off-by: Kevin Hilman 
Signed-off-by: Ben Hutchings 
---
 arch/arm/mach-omap2/opp.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c
index de6d464..d8f6dbf 100644
--- a/arch/arm/mach-omap2/opp.c
+++ b/arch/arm/mach-omap2/opp.c
@@ -53,7 +53,7 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
omap_table_init = 1;
 
/* Lets now register with OPP library */
-   for (i = 0; i < opp_def_size; i++) {
+   for (i = 0; i < opp_def_size; i++, opp_def++) {
struct omap_hwmod *oh;
struct device *dev;
 
@@ -86,7 +86,6 @@ int __init omap_init_opp_table(struct omap_opp_def *opp_def,
__func__, opp_def->freq,
opp_def->hwmod_name, i, r);
}
-   opp_def++;
}
 
return 0;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 36/73] ext4: fix overhead calculation used by ext4_statfs()

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

commit 952fc18ef9ec707ebdc16c0786ec360295e5ff15 upstream.

Commit f975d6bcc7a introduced bug which caused ext4_statfs() to
miscalculate the number of file system overhead blocks.  This causes
the f_blocks field in the statfs structure to be larger than it should
be.  This would in turn cause the "df" output to show the number of
data blocks in the file system and the number of data blocks used to
be larger than they should be.

Signed-off-by: "Theodore Ts'o" 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
I put the call to ext4_calculate_overhead() in ext4_group_add(); is
it the right place?

Ben.
---
 fs/ext4/bitmap.c |4 --
 fs/ext4/ext4.h   |4 +-
 fs/ext4/resize.c |7 ++-
 fs/ext4/super.c  |  174 ++
 4 files changed, 132 insertions(+), 57 deletions(-)

--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -11,8 +11,6 @@
 #include 
 #include "ext4.h"
 
-#ifdef EXT4FS_DEBUG
-
 static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 
0};
 
 unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
@@ -25,5 +23,3 @@ unsigned int ext4_count_free(char *bitma
return sum;
 }
 
-#endif  /*  EXT4FS_DEBUG  */
-
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1123,8 +1123,7 @@ struct ext4_sb_info {
unsigned long s_desc_per_block; /* Number of group descriptors per 
block */
ext4_group_t s_groups_count;/* Number of groups in the fs */
ext4_group_t s_blockfile_groups;/* Groups acceptable for non-extent 
files */
-   unsigned long s_overhead_last;  /* Last calculated overhead */
-   unsigned long s_blocks_last;/* Last seen block count */
+   unsigned long s_overhead;  /* # of fs overhead clusters */
unsigned int s_cluster_ratio;   /* Number of blocks per cluster */
unsigned int s_cluster_bits;/* log2 of s_cluster_ratio */
loff_t s_bitmap_maxbytes;   /* max bytes for bitmap files */
@@ -1925,6 +1924,7 @@ extern int ext4_group_extend(struct supe
ext4_fsblk_t n_blocks_count);
 
 /* super.c */
+extern int ext4_calculate_overhead(struct super_block *sb);
 extern void *ext4_kvmalloc(size_t size, gfp_t flags);
 extern void *ext4_kvzalloc(size_t size, gfp_t flags);
 extern void ext4_kvfree(void *ptr);
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -952,6 +952,11 @@ int ext4_group_add(struct super_block *s
   >s_flex_groups[flex_group].free_inodes);
}
 
+   /*
+* Update the fs overhead information
+*/
+   ext4_calculate_overhead(sb);
+
ext4_handle_dirty_super(handle, sb);
 
 exit_journal:
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3083,6 +3083,114 @@ static void ext4_destroy_lazyinit_thread
kthread_stop(ext4_lazyinit_task);
 }
 
+/*
+ * Note: calculating the overhead so we can be compatible with
+ * historical BSD practice is quite difficult in the face of
+ * clusters/bigalloc.  This is because multiple metadata blocks from
+ * different block group can end up in the same allocation cluster.
+ * Calculating the exact overhead in the face of clustered allocation
+ * requires either O(all block bitmaps) in memory or O(number of block
+ * groups**2) in time.  We will still calculate the superblock for
+ * older file systems --- and if we come across with a bigalloc file
+ * system with zero in s_overhead_clusters the estimate will be close to
+ * correct especially for very large cluster sizes --- but for newer
+ * file systems, it's better to calculate this figure once at mkfs
+ * time, and store it in the superblock.  If the superblock value is
+ * present (even for non-bigalloc file systems), we will use it.
+ */
+static int count_overhead(struct super_block *sb, ext4_group_t grp,
+ char *buf)
+{
+   struct ext4_sb_info *sbi = EXT4_SB(sb);
+   struct ext4_group_desc  *gdp;
+   ext4_fsblk_tfirst_block, last_block, b;
+   ext4_group_ti, ngroups = ext4_get_groups_count(sb);
+   int s, j, count = 0;
+
+   first_block = le32_to_cpu(sbi->s_es->s_first_data_block) +
+   (grp * EXT4_BLOCKS_PER_GROUP(sb));
+   last_block = first_block + EXT4_BLOCKS_PER_GROUP(sb) - 1;
+   for (i = 0; i < ngroups; i++) {
+   gdp = ext4_get_group_desc(sb, i, NULL);
+   b = ext4_block_bitmap(sb, gdp);
+   if (b >= first_block && b <= last_block) {
+   ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
+   count++;
+   }
+   b = ext4_inode_bitmap(sb, gdp);
+   if (b >= first_block && b <= last_block) {
+   ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
+   count++;
+ 

[ 49/73] workqueue: perform cpu down operations from low priority cpu_notifier()

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Tejun Heo 

commit 6575820221f7a4dd6eadecf7bf83cdd154335eda upstream.

Currently, all workqueue cpu hotplug operations run off
CPU_PRI_WORKQUEUE which is higher than normal notifiers.  This is to
ensure that workqueue is up and running while bringing up a CPU before
other notifiers try to use workqueue on the CPU.

Per-cpu workqueues are supposed to remain working and bound to the CPU
for normal CPU_DOWN_PREPARE notifiers.  This holds mostly true even
with workqueue offlining running with higher priority because
workqueue CPU_DOWN_PREPARE only creates a bound trustee thread which
runs the per-cpu workqueue without concurrency management without
explicitly detaching the existing workers.

However, if the trustee needs to create new workers, it creates
unbound workers which may wander off to other CPUs while
CPU_DOWN_PREPARE notifiers are in progress.  Furthermore, if the CPU
down is cancelled, the per-CPU workqueue may end up with workers which
aren't bound to the CPU.

While reliably reproducible with a convoluted artificial test-case
involving scheduling and flushing CPU burning work items from CPU down
notifiers, this isn't very likely to happen in the wild, and, even
when it happens, the effects are likely to be hidden by the following
successful CPU down.

Fix it by using different priorities for up and down notifiers - high
priority for up operations and low priority for down operations.

Workqueue cpu hotplug operations will soon go through further cleanup.

Signed-off-by: Tejun Heo 
Acked-by: "Rafael J. Wysocki" 
Signed-off-by: Ben Hutchings 
---
 include/linux/cpu.h |5 +++--
 kernel/workqueue.c  |   38 +-
 2 files changed, 40 insertions(+), 3 deletions(-)

--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -66,8 +66,9 @@ enum {
/* migration should happen before other stuff but after perf */
CPU_PRI_PERF= 20,
CPU_PRI_MIGRATION   = 10,
-   /* prepare workqueues for other notifiers */
-   CPU_PRI_WORKQUEUE   = 5,
+   /* bring up workqueues before normal notifiers and down after */
+   CPU_PRI_WORKQUEUE_UP= 5,
+   CPU_PRI_WORKQUEUE_DOWN  = -5,
 };
 
 #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3586,6 +3586,41 @@ static int __devinit workqueue_cpu_callb
return notifier_from_errno(0);
 }
 
+/*
+ * Workqueues should be brought up before normal priority CPU notifiers.
+ * This will be registered high priority CPU notifier.
+ */
+static int __devinit workqueue_cpu_up_callback(struct notifier_block *nfb,
+  unsigned long action,
+  void *hcpu)
+{
+   switch (action & ~CPU_TASKS_FROZEN) {
+   case CPU_UP_PREPARE:
+   case CPU_UP_CANCELED:
+   case CPU_DOWN_FAILED:
+   case CPU_ONLINE:
+   return workqueue_cpu_callback(nfb, action, hcpu);
+   }
+   return NOTIFY_OK;
+}
+
+/*
+ * Workqueues should be brought down after normal priority CPU notifiers.
+ * This will be registered as low priority CPU notifier.
+ */
+static int __devinit workqueue_cpu_down_callback(struct notifier_block *nfb,
+unsigned long action,
+void *hcpu)
+{
+   switch (action & ~CPU_TASKS_FROZEN) {
+   case CPU_DOWN_PREPARE:
+   case CPU_DYING:
+   case CPU_POST_DEAD:
+   return workqueue_cpu_callback(nfb, action, hcpu);
+   }
+   return NOTIFY_OK;
+}
+
 #ifdef CONFIG_SMP
 
 struct work_for_cpu {
@@ -3779,7 +3814,8 @@ static int __init init_workqueues(void)
unsigned int cpu;
int i;
 
-   cpu_notifier(workqueue_cpu_callback, CPU_PRI_WORKQUEUE);
+   cpu_notifier(workqueue_cpu_up_callback, CPU_PRI_WORKQUEUE_UP);
+   cpu_notifier(workqueue_cpu_down_callback, CPU_PRI_WORKQUEUE_DOWN);
 
/* initialize gcwqs */
for_each_gcwq_cpu(cpu) {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] xhci: EHCI/XHCI ports switching on Intense-PC.

2012-07-30 Thread Oliver Neukum
On Monday 30 July 2012 15:34:06 Sarah Sharp wrote:
> Hi Denis,
> 
> Can you send me the output of `sudo dmidecode`?  I'd like to see if I
> can make a more general patch apply to the Intense-PC.

As this is for shutdown, why not all systems?

Regards
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 53/73] ALSA: hda - Turn on PIN_OUT from hdmi playback prepare.

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Dylan Reid 

commit 9e76e6d031482194a5b24d8e9ab88063fbd6b4b5 upstream.

Turn on the pin widget's PIN_OUT bit from playback prepare. The pin is
enabled in open, but is disabled in hdmi_init_pin which is called during
system resume.  This causes a system suspend/resume during playback to
mute HDMI/DP. Enabling the pin in prepare instead of open allows calling
snd_pcm_prepare after a system resume to restore audio.

Signed-off-by: Dylan Reid 
Signed-off-by: Takashi Iwai 
Signed-off-by: Ben Hutchings 
---
 sound/pci/hda/patch_hdmi.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 0b4a1ea..641408d 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -876,7 +876,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
struct hdmi_spec_per_pin *per_pin;
struct hdmi_eld *eld;
struct hdmi_spec_per_cvt *per_cvt = NULL;
-   int pinctl;
 
/* Validate hinfo */
pin_idx = hinfo_to_pin_index(spec, hinfo);
@@ -912,11 +911,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
snd_hda_codec_write(codec, per_pin->pin_nid, 0,
AC_VERB_SET_CONNECT_SEL,
mux_idx);
-   pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
-   AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
-   snd_hda_codec_write(codec, per_pin->pin_nid, 0,
-   AC_VERB_SET_PIN_WIDGET_CONTROL,
-   pinctl | PIN_OUT);
snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid);
 
/* Initially set the converter's capabilities */
@@ -1153,11 +1147,17 @@ static int generic_hdmi_playback_pcm_prepare(struct 
hda_pcm_stream *hinfo,
struct hdmi_spec *spec = codec->spec;
int pin_idx = hinfo_to_pin_index(spec, hinfo);
hda_nid_t pin_nid = spec->pins[pin_idx].pin_nid;
+   int pinctl;
 
hdmi_set_channel_count(codec, cvt_nid, substream->runtime->channels);
 
hdmi_setup_audio_infoframe(codec, pin_idx, substream);
 
+   pinctl = snd_hda_codec_read(codec, pin_nid, 0,
+   AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+   snd_hda_codec_write(codec, pin_nid, 0,
+   AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl | PIN_OUT);
+
return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
 }
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 58/73] [SCSI] fix eh wakeup (scsi_schedule_eh vs scsi_restart_operations)

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 57fc2e335fd3c2f898ee73570dc81426c28dc7b4 upstream.

Rapid ata hotplug on a libsas controller results in cases where libsas
is waiting indefinitely on eh to perform an ata probe.

A race exists between scsi_schedule_eh() and scsi_restart_operations()
in the case when scsi_restart_operations() issues i/o to other devices
in the sas domain.  When this happens the host state transitions from
SHOST_RECOVERY (set by scsi_schedule_eh) back to SHOST_RUNNING and
->host_busy is non-zero so we put the eh thread to sleep even though
->host_eh_scheduled is active.

Before putting the error handler to sleep we need to check if the
host_state needs to return to SHOST_RECOVERY for another trip through
eh.  Since i/o that is released by scsi_restart_operations has been
blocked for at least one eh cycle, this implementation allows those
i/o's to run before another eh cycle starts to discourage hung task
timeouts.

Reported-by: Tom Jackson 
Tested-by: Tom Jackson 
Signed-off-by: Dan Williams 
Signed-off-by: James Bottomley 
Signed-off-by: Ben Hutchings 
---
 drivers/scsi/scsi_error.c |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index d0f71e5..804f632 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1687,6 +1687,20 @@ static void scsi_restart_operations(struct Scsi_Host 
*shost)
 * requests are started.
 */
scsi_run_host_queues(shost);
+
+   /*
+* if eh is active and host_eh_scheduled is pending we need to re-run
+* recovery.  we do this check after scsi_run_host_queues() to allow
+* everything pent up since the last eh run a chance to make forward
+* progress before we sync again.  Either we'll immediately re-run
+* recovery or scsi_device_unbusy() will wake us again when these
+* pending commands complete.
+*/
+   spin_lock_irqsave(shost->host_lock, flags);
+   if (shost->host_eh_scheduled)
+   if (scsi_host_set_state(shost, SHOST_RECOVERY))
+   WARN_ON(scsi_host_set_state(shost, 
SHOST_CANCEL_RECOVERY));
+   spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
 /**


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 12/73] mm/vmscan.c: consider swap space when deciding whether to continue reclaim

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Minchan Kim 

commit 86cfd3a45042ab242d47f3935a02811a402beab6 upstream.

Stable note: Not tracked in Bugzilla. This patch reduces kswapd CPU
usage on swapless systems with high anonymous memory usage.

It's pointless to continue reclaiming when we have no swap space and lots
of anon pages in the inactive list.

Without this patch, it is possible when swap is disabled to continue
trying to reclaim when there are only anonymous pages in the system even
though that will not make any progress.

Signed-off-by: Minchan Kim 
Cc: KOSAKI Motohiro 
Acked-by: Mel Gorman 
Reviewed-by: Rik van Riel 
Cc: Johannes Weiner 
Cc: Andrea Arcangeli 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/vmscan.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 974162c..b935e6f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2000,8 +2000,9 @@ static inline bool should_continue_reclaim(struct zone 
*zone,
 * inactive lists are large enough, continue reclaiming
 */
pages_for_compaction = (2UL << sc->order);
-   inactive_lru_pages = zone_nr_lru_pages(zone, sc, LRU_INACTIVE_ANON) +
-   zone_nr_lru_pages(zone, sc, LRU_INACTIVE_FILE);
+   inactive_lru_pages = zone_nr_lru_pages(zone, sc, LRU_INACTIVE_FILE);
+   if (nr_swap_pages > 0)
+   inactive_lru_pages += zone_nr_lru_pages(zone, sc, 
LRU_INACTIVE_ANON);
if (sc->nr_reclaimed < pages_for_compaction &&
inactive_lru_pages > pages_for_compaction)
return true;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 01/73] mm: reduce the amount of work done when updating min_free_kbytes

2012-07-30 Thread Ben Hutchings
3.2-stable review patch.  If anyone has any objections, please let me know.

--

From: Mel Gorman 

commit 938929f14cb595f43cd1a4e63e22d36cab1e4a1f upstream.

Stable note: Fixes https://bugzilla.novell.com/show_bug.cgi?id=726210 .
Large machines with 1TB or more of RAM take a long time to boot
without this patch and may spew out soft lockup warnings.

When min_free_kbytes is updated, some pageblocks are marked
MIGRATE_RESERVE.  Ordinarily, this work is unnoticable as it happens early
in boot but on large machines with 1TB of memory, this has been reported
to delay boot times, probably due to the NUMA distances involved.

The bulk of the work is due to calling calling pageblock_is_reserved() an
unnecessary amount of times and accessing far more struct page metadata
than is necessary.  This patch significantly reduces the amount of work
done by setup_zone_migrate_reserve() improving boot times on 1TB machines.

[a...@linux-foundation.org: coding-style fixes]
Signed-off-by: Mel Gorman 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Ben Hutchings 
---
 mm/page_alloc.c |   40 
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 516ab62..671e6c9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3388,25 +3388,33 @@ static void setup_zone_migrate_reserve(struct zone 
*zone)
if (page_to_nid(page) != zone_to_nid(zone))
continue;
 
-   /* Blocks with reserved pages will never free, skip them. */
-   block_end_pfn = min(pfn + pageblock_nr_pages, end_pfn);
-   if (pageblock_is_reserved(pfn, block_end_pfn))
-   continue;
-
block_migratetype = get_pageblock_migratetype(page);
 
-   /* If this block is reserved, account for it */
-   if (reserve > 0 && block_migratetype == MIGRATE_RESERVE) {
-   reserve--;
-   continue;
-   }
+   /* Only test what is necessary when the reserves are not met */
+   if (reserve > 0) {
+   /*
+* Blocks with reserved pages will never free, skip
+* them.
+*/
+   block_end_pfn = min(pfn + pageblock_nr_pages, end_pfn);
+   if (pageblock_is_reserved(pfn, block_end_pfn))
+   continue;
 
-   /* Suitable for reserving if this block is movable */
-   if (reserve > 0 && block_migratetype == MIGRATE_MOVABLE) {
-   set_pageblock_migratetype(page, MIGRATE_RESERVE);
-   move_freepages_block(zone, page, MIGRATE_RESERVE);
-   reserve--;
-   continue;
+   /* If this block is reserved, account for it */
+   if (block_migratetype == MIGRATE_RESERVE) {
+   reserve--;
+   continue;
+   }
+
+   /* Suitable for reserving if this block is movable */
+   if (block_migratetype == MIGRATE_MOVABLE) {
+   set_pageblock_migratetype(page,
+   MIGRATE_RESERVE);
+   move_freepages_block(zone, page,
+   MIGRATE_RESERVE);
+   reserve--;
+   continue;
+   }
}
 
/*


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] ACPI processor: Fix a typo error in commit 99b725084

2012-07-30 Thread Feng Tang
In commit 99b725084 "ACPI processor hotplug: Delay acpi_processor_start()
call for hotplugged cores", acpi_processor_hotplug(pr) was wrongly replaced
by acpi_processor_cst_has_changed() inside the acpi_cpu_soft_notify(). This
patch will restore it back, which also fixes a tick_broadcast_mask regression:
https://lkml.org/lkml/2012/7/30/169

[Resend to ACPI mail list and Cc stable kernel]

Signed-off-by: Feng Tang 
Cc: Thomas Renninger 
Cc: Deepthi Dharwar 
Cc:  # 3.3+
---
 drivers/acpi/processor_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index ff8e04f..bfc31cb 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -437,7 +437,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
/* Normal CPU soft online event */
} else {
acpi_processor_ppc_has_changed(pr, 0);
-   acpi_processor_cst_has_changed(pr);
+   acpi_processor_hotplug(pr);
acpi_processor_reevaluate_tstate(pr, action);
acpi_processor_tstate_has_changed(pr);
}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] GPIO changes for v3.6

2012-07-30 Thread NeilBrown
On Mon, 30 Jul 2012 14:36:15 +0100 Mark Brown
 wrote:

> On Mon, Jul 30, 2012 at 04:57:33PM +1000, NeilBrown wrote:
> 
> > it means that if !gpio_is_valid(gpio), the error returned is EPROBE_DEFER 
> > which isn't right (an invalid gpio number will never become valid).
> > If a driver happened to use gpio_request to check the validity of the gpio
> > rather than doing it itself, it would defer the probe, rather than assume
> > that the GPIO doesn't exist.
> 
> Is anything actually doing this?  For positive numbers that just seems
> like it's asking for things to explode, for negative numbers I guess you
> can get away with it at the minute though it's obviously not awesome
> error handling.

I suspect not, but stranger things have happened.

... though it occurs to me that it is possible that the GPIO number might not
be allocated until something else has been probed, so a -ve gpio number could
mean "there is no such gpio" or it could mean "gpio has not been allocated
yet".  I wonder if that should be allowed and where it should be handled.

> 
> > I would suggest the following.  Reasonable?
> 
> TBH I'd actually expect that gpio_is_valid() were checking that there's
> a gpio_chip behind the GPIO number, now I look at the implementation
> it's very surprising to me that it's just checking the GPIO array bounds
> (and also that we remove the need for the fixed size GPIO array which is
> just an endless source of annoyance).

Yes, gpio_is_valid is really just a check that the gpio_desc array dereference
won't over-flow.

I'd really like to see gpios be requested by name ... anyone know if there
are any plans along that line?

NeilBrown


signature.asc
Description: PGP signature


linux-next: build failure after merge of the akpm tree

2012-07-30 Thread Stephen Rothwell
Hi Andrew,

After merging the akpm tree, today's linux-next build (x86_64
allmodconfig) failed like this:

net/ceph/osd_client.c: In function 'ceph_osdc_alloc_request':
net/ceph/osd_client.c:216:2: error: implicit declaration of function 
'rb_init_node' [-Werror=implicit-function-declaration]

Caused by commit 753b960e52b7 ("rbtree: empty nodes have no color") from
the akpm tree interacting with commit cd43045c2de6 ("libceph: initialize
rb, list nodes in ceph_osd_request") from the ceph tree.

I added the following merge fix patch for today:

From: Stephen Rothwell 
Date: Tue, 31 Jul 2012 14:37:35 +1000
Subject: [PATCH] libceph: remove rb_node initialisation

Signed-off-by: Stephen Rothwell 
---
 net/ceph/osd_client.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index ad427e6..06fb7a9 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -213,7 +213,6 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct 
ceph_osd_client *osdc,
kref_init(>r_kref);
init_completion(>r_completion);
init_completion(>r_safe_completion);
-   rb_init_node(>r_node);
INIT_LIST_HEAD(>r_unsafe_item);
INIT_LIST_HEAD(>r_linger_item);
INIT_LIST_HEAD(>r_linger_osd);
-- 
1.7.10.280.gaa39

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpZ7NH1sTVYR.pgp
Description: PGP signature


Re: [patch] x86, avx: don't use avx instructions with "noxsave" boot param

2012-07-30 Thread H. Peter Anvin
I'm wondering if we shouldn't just kill the affected CPUID bits if osxsave is 
off...

NeilBrown  wrote:

>On Mon, 30 Jul 2012 15:46:15 -0700 Suresh Siddha
>
>wrote:
>
>> Check the kernel has indeed enabled xsave before using AVX
>instructions.
>> 
>> Fixes the kernel boot panic with "noxsave" boot parameter.
>> 
>> Signed-off-by: Suresh Siddha 
>
>Looks consistent with other usage - thanks.
>Applied.
>
>Should it go in '-stable' kernels too?
>
>NeilBrown
>
>> ---
>>  arch/x86/include/asm/xor_avx.h |4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/x86/include/asm/xor_avx.h
>b/arch/x86/include/asm/xor_avx.h
>> index 2510d35..77987cd 100644
>> --- a/arch/x86/include/asm/xor_avx.h
>> +++ b/arch/x86/include/asm/xor_avx.h
>> @@ -197,12 +197,12 @@ static struct xor_block_template xor_block_avx
>= {
>>  
>>  #define AVX_XOR_SPEED \
>>  do { \
>> -if (cpu_has_avx) \
>> +if (cpu_has_avx && cpu_has_osxsave) \
>>  xor_speed(_block_avx); \
>>  } while (0)
>>  
>>  #define AVX_SELECT(FASTEST) \
>> -(cpu_has_avx ? _block_avx : FASTEST)
>> +((cpu_has_avx && cpu_has_osxsave) ? _block_avx : FASTEST)
>>  
>>  #else
>>  
>> 

-- 
Sent from my mobile phone. Please excuse brevity and lack of formatting.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] perf tool: change strlist to use the new rblist

2012-07-30 Thread David Ahern
Replaces the direct use of rbtree code with the rblist API. In the end
the patch is a no-op on strlist functionality; the API for strlist is
not changed, only its implementaton.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 
---
 tools/perf/util/strlist.c |  130 ++---
 tools/perf/util/strlist.h |   11 ++--
 2 files changed, 57 insertions(+), 84 deletions(-)

diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index 6783a20..95856ff 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -10,23 +10,28 @@
 #include 
 #include 
 
-static struct str_node *str_node__new(const char *s, bool dupstr)
+static
+struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry)
 {
-   struct str_node *self = malloc(sizeof(*self));
+   const char *s = entry;
+   struct rb_node *rc = NULL;
+   struct strlist *strlist = container_of(rblist, struct strlist, rblist);
+   struct str_node *snode = malloc(sizeof(*snode));
 
-   if (self != NULL) {
-   if (dupstr) {
+   if (snode != NULL) {
+   if (strlist->dupstr) {
s = strdup(s);
if (s == NULL)
goto out_delete;
}
-   self->s = s;
+   snode->s = s;
+   rc = >rb_node;
}
 
-   return self;
+   return rc;
 
 out_delete:
-   free(self);
+   free(snode);
return NULL;
 }
 
@@ -37,36 +42,26 @@ static void str_node__delete(struct str_node *self, bool 
dupstr)
free(self);
 }
 
-int strlist__add(struct strlist *self, const char *new_entry)
+static
+void strlist__node_delete(struct rblist *rblist, struct rb_node *rb_node)
 {
-   struct rb_node **p = >entries.rb_node;
-   struct rb_node *parent = NULL;
-   struct str_node *sn;
-
-   while (*p != NULL) {
-   int rc;
-
-   parent = *p;
-   sn = rb_entry(parent, struct str_node, rb_node);
-   rc = strcmp(sn->s, new_entry);
-
-   if (rc > 0)
-   p = &(*p)->rb_left;
-   else if (rc < 0)
-   p = &(*p)->rb_right;
-   else
-   return -EEXIST;
-   }
+   struct strlist *slist = container_of(rblist, struct strlist, rblist);
+   struct str_node *snode = container_of(rb_node, struct str_node, 
rb_node);
 
-   sn = str_node__new(new_entry, self->dupstr);
-   if (sn == NULL)
-   return -ENOMEM;
+   str_node__delete(snode, slist->dupstr);
+}
 
-   rb_link_node(>rb_node, parent, p);
-   rb_insert_color(>rb_node, >entries);
-   ++self->nr_entries;
+static int strlist__node_cmp(struct rb_node *rb_node, const void *entry)
+{
+   const char *str = entry;
+   struct str_node *snode = container_of(rb_node, struct str_node, 
rb_node);
+
+   return strcmp(snode->s, str);
+}
 
-   return 0;
+int strlist__add(struct strlist *self, const char *new_entry)
+{
+   return rblist__add_node(>rblist, new_entry);
 }
 
 int strlist__load(struct strlist *self, const char *filename)
@@ -96,34 +91,20 @@ out:
return err;
 }
 
-void strlist__remove(struct strlist *self, struct str_node *sn)
+void strlist__remove(struct strlist *slist, struct str_node *snode)
 {
-   rb_erase(>rb_node, >entries);
-   str_node__delete(sn, self->dupstr);
+   str_node__delete(snode, slist->dupstr);
 }
 
-struct str_node *strlist__find(struct strlist *self, const char *entry)
+struct str_node *strlist__find(struct strlist *slist, const char *entry)
 {
-   struct rb_node **p = >entries.rb_node;
-   struct rb_node *parent = NULL;
-
-   while (*p != NULL) {
-   struct str_node *sn;
-   int rc;
-
-   parent = *p;
-   sn = rb_entry(parent, struct str_node, rb_node);
-   rc = strcmp(sn->s, entry);
-
-   if (rc > 0)
-   p = &(*p)->rb_left;
-   else if (rc < 0)
-   p = &(*p)->rb_right;
-   else
-   return sn;
-   }
+   struct str_node *snode = NULL;
+   struct rb_node *rb_node = rblist__find(>rblist, entry);
 
-   return NULL;
+   if (rb_node)
+   snode = container_of(rb_node, struct str_node, rb_node);
+
+   return snode;
 }
 
 static int strlist__parse_list_entry(struct strlist *self, const char *s)
@@ -156,9 +137,12 @@ struct strlist *strlist__new(bool dupstr, const char 
*slist)
struct strlist *self = malloc(sizeof(*self));
 
if (self != NULL) {
-   self->entries= RB_ROOT;
+   rblist__init(>rblist);
+   self->rblist.node_cmp= strlist__node_cmp;
+   self->rblist.node_new= 

[PATCH 1/4] perf tool: introducing rblist

2012-07-30 Thread David Ahern
rblist is the rbtree based code from strlist. It will be the common
code for strlist and the to-be-introduced intlist.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 
---
 tools/perf/Makefile  |2 +
 tools/perf/util/rblist.c |  107 ++
 tools/perf/util/rblist.h |   47 
 3 files changed, 156 insertions(+)
 create mode 100644 tools/perf/util/rblist.c
 create mode 100644 tools/perf/util/rblist.h

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 77f124f..285f700 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -319,6 +319,7 @@ LIB_H += $(ARCH_INCLUDE)
 LIB_H += util/cgroup.h
 LIB_H += $(TRACE_EVENT_DIR)event-parse.h
 LIB_H += util/target.h
+LIB_H += util/rblist.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -383,6 +384,7 @@ LIB_OBJS += $(OUTPUT)util/xyarray.o
 LIB_OBJS += $(OUTPUT)util/cpumap.o
 LIB_OBJS += $(OUTPUT)util/cgroup.o
 LIB_OBJS += $(OUTPUT)util/target.o
+LIB_OBJS += $(OUTPUT)util/rblist.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
 
diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c
new file mode 100644
index 000..0171fb6
--- /dev/null
+++ b/tools/perf/util/rblist.c
@@ -0,0 +1,107 @@
+/*
+ * Based on strlist.c by:
+ * (c) 2009 Arnaldo Carvalho de Melo 
+ *
+ * Licensed under the GPLv2.
+ */
+
+#include 
+#include 
+#include 
+
+#include "rblist.h"
+
+int rblist__add_node(struct rblist *rblist, const void *new_entry)
+{
+   struct rb_node **p = >entries.rb_node;
+   struct rb_node *parent = NULL, *new_node;
+
+   while (*p != NULL) {
+   int rc;
+
+   parent = *p;
+
+   rc = rblist->node_cmp(parent, new_entry);
+   if (rc > 0)
+   p = &(*p)->rb_left;
+   else if (rc < 0)
+   p = &(*p)->rb_right;
+   else
+   return -EEXIST;
+   }
+
+   new_node = rblist->node_new(rblist, new_entry);
+   if (new_node == NULL)
+   return -ENOMEM;
+
+   rb_link_node(new_node, parent, p);
+   rb_insert_color(new_node, >entries);
+   ++rblist->nr_entries;
+
+   return 0;
+}
+
+void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node)
+{
+   rb_erase(rb_node, >entries);
+   rblist->node_delete(rblist, rb_node);
+}
+
+struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
+{
+   struct rb_node **p = >entries.rb_node;
+   struct rb_node *parent = NULL;
+
+   while (*p != NULL) {
+   int rc;
+
+   parent = *p;
+
+   rc = rblist->node_cmp(parent, entry);
+   if (rc > 0)
+   p = &(*p)->rb_left;
+   else if (rc < 0)
+   p = &(*p)->rb_right;
+   else
+   return parent;
+   }
+
+   return NULL;
+}
+
+void rblist__init(struct rblist *rblist)
+{
+   if (rblist != NULL) {
+   rblist->entries  = RB_ROOT;
+   rblist->nr_entries = 0;
+   }
+
+   return;
+}
+
+void rblist__delete(struct rblist *rblist)
+{
+   if (rblist != NULL) {
+   struct rb_node *pos, *next = rb_first(>entries);
+
+   while (next) {
+   pos = next;
+   next = rb_next(pos);
+   rb_erase(pos, >entries);
+   rblist->node_delete(rblist, pos);
+   }
+   free(rblist);
+   }
+}
+
+struct rb_node *rblist__entry(const struct rblist *rblist, unsigned int idx)
+{
+   struct rb_node *node;
+
+   for (node = rb_first(>entries); node; node = rb_next(node)) {
+   if (!idx--)
+   return node;
+   }
+
+   return NULL;
+}
diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h
new file mode 100644
index 000..13f4f45
--- /dev/null
+++ b/tools/perf/util/rblist.h
@@ -0,0 +1,47 @@
+#ifndef __PERF_RBLIST_H
+#define __PERF_RBLIST_H
+
+#include 
+#include 
+
+/*
+ * create node structs of the form:
+ * struct my_node {
+ * struct rb_node rb_node;
+ * ... my data ...
+ * };
+ *
+ * create list structs of the form:
+ * struct mylist {
+ * struct rblist rblist;
+ * ... my data ...
+ * };
+ */
+
+struct rblist {
+   struct rb_root entries;
+   unsigned int   nr_entries;
+
+   int (*node_cmp) (struct rb_node *rbn, const void *entry);
+   struct rb_node *(*node_new) (struct rblist *rlist, const void 
*new_entry);
+   void (*node_delete) (struct rblist *rblist, struct rb_node *rb_node);
+};
+
+void rblist__init(struct rblist *rblist);
+void rblist__delete(struct rblist *rblist);
+int rblist__add_node(struct rblist *rblist, const void *new_entry);
+void rblist__remove_node(struct rblist *rblist, struct rb_node 

[PATCH 4/4] perf kvm top: limit guest kernel info message to once

2012-07-30 Thread David Ahern
'perf kvm top' shows a continual flurry of:
Can't find guest [5201]'s kernel information

if it can't find the guest info and with a lot of VMs running a user
has no chance of reading them all. Limit message to once per guest.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 
---
 tools/perf/builtin-top.c |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 35e86c6..0687c82 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -38,6 +38,7 @@
 #include "util/cpumap.h"
 #include "util/xyarray.h"
 #include "util/sort.h"
+#include "util/intlist.h"
 
 #include "util/debug.h"
 
@@ -706,8 +707,16 @@ static void perf_event__process_sample(struct perf_tool 
*tool,
int err;
 
if (!machine && perf_guest) {
-   pr_err("Can't find guest [%d]'s kernel information\n",
-   event->ip.pid);
+   static struct intlist *seen;
+
+   if (!seen)
+   seen = intlist__new();
+
+   if (!intlist__has_entry(seen, event->ip.pid)) {
+   pr_err("Can't find guest [%d]'s kernel information\n",
+   event->ip.pid);
+   intlist__add(seen, event->ip.pid);
+   }
return;
}
 
-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] perf tool: introduce intlist

2012-07-30 Thread David Ahern
Built on rblist - like strlist. Used in the next patch.

Signed-off-by: David Ahern 
Cc: Arnaldo Carvalho de Melo 
Cc: Ingo Molnar 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Frederic Weisbecker 
Cc: Peter Zijlstra 

---
 tools/perf/Makefile   |2 +
 tools/perf/util/intlist.c |  101 +
 tools/perf/util/intlist.h |   75 +
 3 files changed, 178 insertions(+)
 create mode 100644 tools/perf/util/intlist.c
 create mode 100644 tools/perf/util/intlist.h

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 285f700..32912af 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -320,6 +320,7 @@ LIB_H += util/cgroup.h
 LIB_H += $(TRACE_EVENT_DIR)event-parse.h
 LIB_H += util/target.h
 LIB_H += util/rblist.h
+LIB_H += util/intlist.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -385,6 +386,7 @@ LIB_OBJS += $(OUTPUT)util/cpumap.o
 LIB_OBJS += $(OUTPUT)util/cgroup.o
 LIB_OBJS += $(OUTPUT)util/target.o
 LIB_OBJS += $(OUTPUT)util/rblist.o
+LIB_OBJS += $(OUTPUT)util/intlist.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
 
diff --git a/tools/perf/util/intlist.c b/tools/perf/util/intlist.c
new file mode 100644
index 000..55b3441
--- /dev/null
+++ b/tools/perf/util/intlist.c
@@ -0,0 +1,101 @@
+/*
+ * Based on intlist.c by:
+ * (c) 2009 Arnaldo Carvalho de Melo 
+ *
+ * Licensed under the GPLv2.
+ */
+
+#include 
+#include 
+#include 
+
+#include "intlist.h"
+
+static struct rb_node *intlist__node_new(struct rblist *rblist __used,
+const void *entry)
+{
+   int i = (int) ((long) entry);
+   struct rb_node *rc = NULL;
+   struct int_node *node = malloc(sizeof(*node));
+
+   if (node != NULL) {
+   node->i = i;
+   rc = >rb_node;
+   }
+
+   return rc;
+}
+
+static void int_node__delete(struct int_node *ilist)
+{
+   free(ilist);
+}
+
+static void intlist__node_delete(struct rblist *rblist __used,
+struct rb_node *rb_node)
+{
+   struct int_node *node = container_of(rb_node, struct int_node, rb_node);
+
+   int_node__delete(node);
+}
+
+static int intlist__node_cmp(struct rb_node *rb_node, const void *entry)
+{
+   int i = (int) ((long) entry);
+   struct int_node *node = container_of(rb_node, struct int_node, rb_node);
+
+   return node->i - i;
+}
+
+int intlist__add(struct intlist *ilist, int i)
+{
+   return rblist__add_node(>rblist, (void *)((long) i));
+}
+
+void intlist__remove(struct intlist *ilist __used, struct int_node *node)
+{
+   int_node__delete(node);
+}
+
+struct int_node *intlist__find(struct intlist *ilist, int i)
+{
+   struct int_node *node = NULL;
+   struct rb_node *rb_node = rblist__find(>rblist, (void *)((long) 
i));
+
+   if (rb_node)
+   node = container_of(rb_node, struct int_node, rb_node);
+
+   return node;
+}
+
+struct intlist *intlist__new(void)
+{
+   struct intlist *ilist = malloc(sizeof(*ilist));
+
+   if (ilist != NULL) {
+   rblist__init(>rblist);
+   ilist->rblist.node_cmp= intlist__node_cmp;
+   ilist->rblist.node_new= intlist__node_new;
+   ilist->rblist.node_delete = intlist__node_delete;
+   }
+
+   return ilist;
+}
+
+void intlist__delete(struct intlist *ilist)
+{
+   if (ilist != NULL)
+   rblist__delete(>rblist);
+}
+
+struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx)
+{
+   struct int_node *node = NULL;
+   struct rb_node *rb_node;
+
+   rb_node = rblist__entry(>rblist, idx);
+   if (rb_node)
+   node = container_of(rb_node, struct int_node, rb_node);
+
+   return node;
+}
diff --git a/tools/perf/util/intlist.h b/tools/perf/util/intlist.h
new file mode 100644
index 000..8fd70ad
--- /dev/null
+++ b/tools/perf/util/intlist.h
@@ -0,0 +1,75 @@
+#ifndef __PERF_INTLIST_H
+#define __PERF_INTLIST_H
+
+#include 
+#include 
+
+#include "rblist.h"
+
+struct int_node {
+   struct rb_node rb_node;
+   int i;
+};
+
+struct intlist {
+   struct rblist rblist;
+};
+
+struct intlist *intlist__new(void);
+void intlist__delete(struct intlist *ilist);
+
+void intlist__remove(struct intlist *ilist, struct int_node *in);
+int intlist__add(struct intlist *ilist, int i);
+
+struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx);
+struct int_node *intlist__find(struct intlist *ilist, int i);
+
+static inline bool intlist__has_entry(struct intlist *ilist, int i)
+{
+   return intlist__find(ilist, i) != NULL;
+}
+
+static inline bool intlist__empty(const struct intlist *ilist)
+{
+   return rblist__empty(>rblist);
+}
+
+static inline unsigned int intlist__nr_entries(const struct intlist *ilist)
+{
+   return rblist__nr_entries(>rblist);
+}
+
+/* For intlist iteration */
+static inline struct int_node 

[PATCH 0/4] limit guest messages to once in perf kvm top

2012-07-30 Thread David Ahern
Some refactoring so that strlist and intlist have a common base - rblist.
>From there use intlist to only show guest messages once.

David Ahern (4):
  perf tool: introducing rblist
  perf tool: change strlist to use the new rblist
  perf tool: introduce intlist
  perf kvm top: limit guest kernel info message to once

 tools/perf/Makefile   |4 ++
 tools/perf/builtin-top.c  |   13 -
 tools/perf/util/intlist.c |  101 +++
 tools/perf/util/intlist.h |   75 ++
 tools/perf/util/rblist.c  |  107 +
 tools/perf/util/rblist.h  |   47 
 tools/perf/util/strlist.c |  130 ++---
 tools/perf/util/strlist.h |   11 ++--
 8 files changed, 402 insertions(+), 86 deletions(-)
 create mode 100644 tools/perf/util/intlist.c
 create mode 100644 tools/perf/util/intlist.h
 create mode 100644 tools/perf/util/rblist.c
 create mode 100644 tools/perf/util/rblist.h

-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the akpm tree with the nfs tree

2012-07-30 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm tree got a conflict in
net/sunrpc/xprtsock.c between commit 5cf02d09b50b ("nfs: skip commit in
releasepage if we're freeing memory for fs-related reasons") from the nfs
tree and commit "nfs: enable swap on NFS" from the akpm tree.

Just context changes?  I fixed it up (I think - see below) and can carry
the fix as necessary.
-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc net/sunrpc/xprtsock.c
index 9266794,83bb0eb..000
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@@ -1927,9 -1925,47 +1927,48 @@@ static void xs_local_setup_socket(struc
  out:
xprt_clear_connecting(xprt);
xprt_wake_pending_tasks(xprt, status);
 +  current->flags &= ~PF_FSTRANS;
  }
  
+ #ifdef CONFIG_SUNRPC_SWAP
+ static void xs_set_memalloc(struct rpc_xprt *xprt)
+ {
+   struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
+   xprt);
+ 
+   if (xprt->swapper)
+   sk_set_memalloc(transport->inet);
+ }
+ 
+ /**
+  * xs_swapper - Tag this transport as being used for swap.
+  * @xprt: transport to tag
+  * @enable: enable/disable
+  *
+  */
+ int xs_swapper(struct rpc_xprt *xprt, int enable)
+ {
+   struct sock_xprt *transport = container_of(xprt, struct sock_xprt,
+   xprt);
+   int err = 0;
+ 
+   if (enable) {
+   xprt->swapper++;
+   xs_set_memalloc(xprt);
+   } else if (xprt->swapper) {
+   xprt->swapper--;
+   sk_clear_memalloc(transport->inet);
+   }
+ 
+   return err;
+ }
+ EXPORT_SYMBOL_GPL(xs_swapper);
+ #else
+ static void xs_set_memalloc(struct rpc_xprt *xprt)
+ {
+ }
+ #endif
+ 
  static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket 
*sock)
  {
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, 
xprt);
@@@ -1970,7 -2009,8 +2012,9 @@@ static void xs_udp_setup_socket(struct 
if (xprt->shutdown)
goto out;
  
 +  current->flags |= PF_FSTRANS;
+   if (xprt->swapper)
+   current->flags |= PF_MEMALLOC;
  
/* Start by resetting any existing state */
xs_reset_transport(transport);
@@@ -1990,7 -2030,7 +2034,8 @@@
  out:
xprt_clear_connecting(xprt);
xprt_wake_pending_tasks(xprt, status);
+   tsk_restore_flags(current, pflags, PF_MEMALLOC);
 +  current->flags &= ~PF_FSTRANS;
  }
  
  /*
@@@ -2116,7 -2159,8 +2164,9 @@@ static void xs_tcp_setup_socket(struct 
if (xprt->shutdown)
goto out;
  
 +  current->flags |= PF_FSTRANS;
+   if (xprt->swapper)
+   current->flags |= PF_MEMALLOC;
  
if (!sock) {
clear_bit(XPRT_CONNECTION_ABORT, >state);
@@@ -2167,7 -2211,7 +2217,8 @@@
case -EINPROGRESS:
case -EALREADY:
xprt_clear_connecting(xprt);
+   tsk_restore_flags(current, pflags, PF_MEMALLOC);
 +  current->flags &= ~PF_FSTRANS;
return;
case -EINVAL:
/* Happens, for instance, if the user specified a link
@@@ -2180,7 -2224,7 +2231,8 @@@ out_eagain
  out:
xprt_clear_connecting(xprt);
xprt_wake_pending_tasks(xprt, status);
+   tsk_restore_flags(current, pflags, PF_MEMALLOC);
 +  current->flags &= ~PF_FSTRANS;
  }
  
  /**


pgpwX6bTPhUA0.pgp
Description: PGP signature


Re: [patch] x86, avx: don't use avx instructions with "noxsave" boot param

2012-07-30 Thread NeilBrown
On Mon, 30 Jul 2012 15:46:15 -0700 Suresh Siddha 
wrote:

> Check the kernel has indeed enabled xsave before using AVX instructions.
> 
> Fixes the kernel boot panic with "noxsave" boot parameter.
> 
> Signed-off-by: Suresh Siddha 

Looks consistent with other usage - thanks.
Applied.

Should it go in '-stable' kernels too?

NeilBrown

> ---
>  arch/x86/include/asm/xor_avx.h |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/xor_avx.h b/arch/x86/include/asm/xor_avx.h
> index 2510d35..77987cd 100644
> --- a/arch/x86/include/asm/xor_avx.h
> +++ b/arch/x86/include/asm/xor_avx.h
> @@ -197,12 +197,12 @@ static struct xor_block_template xor_block_avx = {
>  
>  #define AVX_XOR_SPEED \
>  do { \
> - if (cpu_has_avx) \
> + if (cpu_has_avx && cpu_has_osxsave) \
>   xor_speed(_block_avx); \
>  } while (0)
>  
>  #define AVX_SELECT(FASTEST) \
> - (cpu_has_avx ? _block_avx : FASTEST)
> + ((cpu_has_avx && cpu_has_osxsave) ? _block_avx : FASTEST)
>  
>  #else
>  
> 



signature.asc
Description: PGP signature


Re: [Regression 3.4] tick_broadcast_mask is not restored after a CPU has been offline/onlined

2012-07-30 Thread Paul E. McKenney
On Tue, Jul 31, 2012 at 11:18:32AM +0800, Feng Tang wrote:
> Hi Paul,
> 
> On Mon, 30 Jul 2012 10:42:18 -0700
> "Paul E. McKenney"  wrote:
> 
> > On Mon, Jul 30, 2012 at 10:08:47AM -0700, Paul E. McKenney wrote:
> > > On Mon, Jul 30, 2012 at 11:07:47PM +0800, Feng Tang wrote:
> > > > Hi Paul,
> > > > 
> > > > On Mon, 30 Jul 2012 06:39:13 -0700
> > > > "Paul E. McKenney"  wrote:
> > > > 
> > > > > On Mon, Jul 30, 2012 at 03:15:59PM +0800, Feng Tang wrote:
> > > > > > Hi All,
> > > > > > 
> > > > > > When I debugged a suspend/resume bug, I found that
> > > > > > tick_broadcast_mask is not restored for a CPU after it is
> > > > > > offline/onlined since kernel 3.4, while it's fine for 3.3.
> > > > > 
> > > > > Could you please try 3.5?
> > > > 
> > > > Yes, it's the same for 3.5
> > > 
> > > Thank you for checking, Feng.
> > > 
> > > Len, the comment above the change says:
> > > 
> > >   /*
> > >* FIXME:  Design the ACPI notification to make it once per
> > >* system instead of once per-cpu.  This condition is a hack
> > >* to make the code that updates C-States be called once.
> > >*/
> > > 
> > > Is it time for this design-level change?  Or is there something obvious
> > > that I missed when fixing the smp_processor_id() splat?
> > > 
> > > I could revert back, but use raw_smp_processor_id() rather than
> > > smp_processor_id(), but that feels like papering over a problem rather
> > > than fixing it.
> > 
> > But should papering be appropriate, here is the patch.
> > 
> > Thanx, Paul
> 
> Just found and have a patch to fix a typo in acpi processor_driver.c, which
> could also fix  this tick_broadcast_mask issue.
>   
> Patch is in https://lkml.org/lkml/2012/7/30/483 
> 
> So I think we don't need this "papering over" patch :)

Very good, I have dropped it.

Thanx, Paul

> Thanks,
> Feng
> 
> > 
> > 
> > 
> > ACPI: Repair fix to unprotected smp_processor_id()
> > 
> > Commit 9505626d (ACPI: Fix unprotected smp_processor_id() in
> > acpi_processor_cst_has_changed()) introduced a suspend/resume bug.
> > This commit therefore introduces a bug-for-bug compatible fix for the
> > original problem.
> > 
> > Reported-by: Feng Tang 
> > Signed-off-by: Paul E. McKenney 
> > 
> > diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> > index 47a8caa..19c151a 100644
> > --- a/drivers/acpi/processor_idle.c
> > +++ b/drivers/acpi/processor_idle.c
> > @@ -1218,7 +1218,8 @@ int acpi_processor_cst_has_changed(struct
> > acpi_processor *pr)
> >  * to make the code that updates C-States be called once.
> >  */
> >  
> > -   if (pr->id == 0 && cpuidle_get_driver() == _idle_driver) {
> > +   if (raw_smp_processor_id() == 0 &&
> > +   cpuidle_get_driver() == _idle_driver) {
> >  
> > cpuidle_pause_and_lock();
> > /* Protect against cpu-hotplug */
> > 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >