Re: [PATCH] xen/events: xen/events: fix RCU warning

2012-11-07 Thread 邱模炯
Thanks Konrad.  You are right, commit 98ad1cc14 missed the xen case.
And before merging, please modify the title a bit. one redundant
"xen/events" there.
"xen/events: xen/events: fix RCU warning"  -> "xen/events: fix RCU warning"

>> Cc: sta...@kernel.org (at least to 3.0.y)
>  ^^^- vger.kernel.org
>
> You mean 3.3.x

This is my mistake. 3.0.y is OK. please ignore it.


On Wed, Nov 7, 2012 at 12:17 AM, Konrad Rzeszutek Wilk
 wrote:
> On Tue, Nov 06, 2012 at 04:08:15PM +0800, Mojiong Qiu wrote:
>> exit_idle() should be called after irq_enter(), otherwise it throws:
>
> That seems odd - wouldn't "smp_x86_platform_ipi"
> also need the same treatment [edit: I was looking at 3.0 kernel code] ?
>
> Ah, this is caused by
>
> commit 98ad1cc14a5c4fd658f9d72c6ba5c86dfd3ce0d5
> Author: Frederic Weisbecker 
> Date:   Fri Oct 7 18:22:09 2011 +0200
>
> x86: Call idle notifier after irq_enter()
>
>
> and it missed the xen-case
>
> which means that any kernel v3.3 and newer need this, but earlier do
> not.
>
> Thx. Will put in 3.7 tree.
>
>>
>> [2.513020] [ INFO: suspicious RCU usage. ]
>> [2.513076] 3.6.5 #1 Not tainted
>> [2.513128] ---
>> [2.513183] include/linux/rcupdate.h:725 rcu_read_lock() used illegally 
>> while idle!
>> [2.513271]
>> [2.513271] other info that might help us debug this:
>> [2.513271]
>> [2.513388]
>> [2.513388] RCU used illegally from idle CPU!
>> [2.513388] rcu_scheduler_active = 1, debug_locks = 1
>> [2.513511] RCU used illegally from extended quiescent state!
>> [2.513572] 1 lock held by swapper/0/0:
>> [2.513626]  #0:  (rcu_read_lock){..}, at: [] 
>> __atomic_notifier_call_chain+0x0/0x140
>> [2.513815]
>> [2.513815] stack backtrace:
>> [2.513897] Pid: 0, comm: swapper/0 Not tainted 3.6.5 #1
>> [2.513954] Call Trace:
>> [2.514005][] lockdep_rcu_suspicious+0xe2/0x130
>> [2.514107]  [] __atomic_notifier_call_chain+0x12c/0x140
>> [2.514169]  [] ? 
>> atomic_notifier_chain_unregister+0x90/0x90
>> [2.514258]  [] ? trace_hardirqs_off+0xd/0x10
>> [2.514318]  [] atomic_notifier_call_chain+0x16/0x20
>> [2.514381]  [] exit_idle+0x43/0x50
>> [2.514441]  [] xen_evtchn_do_upcall+0x25/0x50
>> [2.514503]  [] xen_do_hypervisor_callback+0x1e/0x30
>> [2.514562][] ? hypercall_page+0x3aa/0x1000
>> [2.514662]  [] ? hypercall_page+0x3aa/0x1000
>> [2.514722]  [] ? xen_safe_halt+0x10/0x20
>> [2.514782]  [] ? default_idle+0xba/0x570
>> [2.514841]  [] ? cpu_idle+0xdf/0x140
>> [2.514900]  [] ? rest_init+0x135/0x144
>> [2.514960]  [] ? csum_partial_copy_generic+0x16c/0x16c
>> [2.515022]  [] ? start_kernel+0x3db/0x3e8
>> [2.515081]  [] ? repair_env_string+0x5a/0x5a
>> [2.515141]  [] ? x86_64_start_reservations+0x131/0x135
>> [2.515202]  [] ? xen_start_kernel+0x465/0x46
>>
>> Signed-off-by: Mojiong Qiu 
>> Cc: Konrad Rzeszutek Wilk 
>> Cc: Jeremy Fitzhardinge 
>> Cc: xen-de...@lists.xensource.com
>> Cc: virtualizat...@lists.linux-foundation.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: sta...@kernel.org (at least to 3.0.y)
>  ^^^- vger.kernel.org
>
> You mean 3.3.x
>
>> ---
>>  drivers/xen/events.c |2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/xen/events.c b/drivers/xen/events.c
>> index 912ac81..0be4df3 100644
>> --- a/drivers/xen/events.c
>> +++ b/drivers/xen/events.c
>> @@ -1395,10 +1395,10 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
>>  {
>>   struct pt_regs *old_regs = set_irq_regs(regs);
>>
>> + irq_enter();
>>  #ifdef CONFIG_X86
>>   exit_idle();
>>  #endif
>> - irq_enter();
>>
>>   __xen_evtchn_do_upcall();
>>
>> --
>> 1.6.3.2
--
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: [RFC v4+ hot_track 16/19] btrfs: add hot tracking support

2012-11-07 Thread Zhi Yong Wu
On Wed, Nov 7, 2012 at 8:00 AM, David Sterba  wrote:
> On Mon, Oct 29, 2012 at 12:30:58PM +0800, zwu.ker...@gmail.com wrote:
>> From: Zhi Yong Wu 
>>
>>   Introduce one new mount option '-o hot_track',
>> and add its parsing support.
>>   Its usage looks like:
>>mount -o hot_track
>>mount -o nouser,hot_track
>>mount -o nouser,hot_track,loop
>>mount -o hot_track,nouser
>>
>> Signed-off-by: Zhi Yong Wu 
> Reviewed-by: David Sterba 
thanks for your review.



-- 
Regards,

Zhi Yong Wu
--
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] utilize _Static_assert() for BUILD_BUG_ON() when the compiler supports it

2012-11-07 Thread Jan Beulich
>>> On 07.11.12 at 02:03, Rusty Russell  wrote:
> Jan Beulich  writes:
> On 06.11.12 at 02:51, Rusty Russell  wrote:
>>> Yeah, there are a lot of goodies here:
>>> 
>>> _Static_assert:
>>> We could define __ASSERT_STRUCT_FIELD(e) for this:
>>> #define BUILD_BUG_ON_ZERO(e) \
>>> sizeof(struct { __ASSERT_STRUCT_FIELD(e); })
>>
>> I considered something like this too, but it wouldn't work well: The
>> diagnostic issued from a failed _Static_assert() would preferably
>> refer to the original source expression, not an already macro
>> expanded variant of it. That, however, precludes passing it
>> through multiple levels of macro expansion. Which would leave
>> passing e and #e to __ASSERT_STRUCT_FIELD(), but that's again
>> ugly as it opens the door for someone adding a use where the two
>> arguments don't match up.
> 
> Good point, but this is going to be pretty damn obscure.  In fact, I
> don't think it'll see more than the use here.

Okay, so I'll go with something like that then.

>>> __COUNTER__:
>>> Used to make a unique id.  Let's define __UNIQUE_ID(prefix) for
>>> this (using __COUNTER__ or __LINE__). 4.3 and above.
>>
>> The fallback to __LINE__ is not necessarily correct in all cases,
>> namely when deep macro expansions result in two instances used
>> on the same source line, or a use in a header matches line number
>> wise a second use in another header or the source file.
>>
>> I considered to option of a fallback (and hence an abstraction in
>> compiler*.h) when doing this, but I didn't want to do something
>> that would break in perhaps vary obscure ways.
> 
> I was thinking of my own code in moduleparam.h, but elfnote.h does the
> same trick.  In both cases, it'll simply fail compile if we fallback and
> __LINE__ isn't unique.
> 
> So again, I don't think we're going to see many uses, and no existing
> use will bite us.

That's exactly the point - we can't know (because there's no
guarantee there aren't - or won't be by the time it might get
merged - any two conflicting uses of BUILD_BUG_ON...().

>>> __compiletime_error():
>>> I blame Arjan for this.  It disappears if not implemented, which
>>> is just lazy.  BUILD_BUG_ON() does this right, and he didn't fix
>>> that at the time :(
>>
>> Again, the name of the macro made me not use it, as the obvious
>> fallback is a link time error. The only thing I would be agreeable to
>> is something like __buildtime_error().
> 
> Yes, it's awkward to use.  Your own usage here is the only correct way
> to do it, AFAICT:
> 
>> #define __build_bug_on_failed(n) __build_bug_on_##n##_failed
>> #define _BUILD_BUG_ON(n, condition)  \
>>  do {\
>>  extern void __compiletime_error(#condition) \
>>  __build_bug_on_failed(n)(void); \
>>  if (condition) __build_bug_on_failed(n)();  \
>>  } while(0)

Actually, I just noticed that __linktime_error() really is a compile
time error when gcc supports __attribute__(__error__()), so
probably using that one instead of __compiletime_error() here
would be the cleaner approach.

The one thing puzzling me here is that __linktime_error() gets
defined even if __CHECKER__ isn't defined, while
__compiletime_error() doesn't - an apparent inconsistency
between 746a2a838deec3ef86ef6b7c3edd4207b9a351aa
(Kosaki?) and 1399ff86f2a2bbacbbe68fa00c5f8c752b344723
(David?), with apparently the latter being too lax, as it only
introduced a use inside a !__CHECKER__ section.

>> #define BUILD_BUG_ON(condition...) _BUILD_BUG_ON(__COUNTER__, ##condition)
> 
> The ... is overkill here: sure it's general, but we don't allow that
> currently, nor in the other BUILD_BUG_ON() definitions.

This may be a leftover from previous failed attempts; I don't
see a reason why it should stay.

> So I think this becomes:
> 
> #define _BUILD_BUG_ON(undefname, condition)   
>  \
> do {  
>  \
> extern void __compiletime_error(#condition) undefname(void);  
>  \
> if (condition) undefname();   
>  \
> } while(0)
> #define BUILD_BUG_ON(condition) \
> _BUILD_BUG_ON(__UNIQUE_ID(__build_bug_fail), (condition))

Yes, subject to the fallback issue.

> Subject: __UNIQUE_ID()
> 
> Jan Beulich points out __COUNTER__ (gcc 4.3 and above), so let's use
> that to create unique ids.  This is better than __LINE__ which we use
> today, so provide a wrapper.
> 
> Signed-off-by: Rusty Russell 

Acked-by: Jan Beulich 

> diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
> index 412bc6c..8908821 100644
> --- a/include/linux/compiler-gcc4.h
> +++ b/include/linux/compiler-gcc4.h
> @@ -31,6 +31,8 @@
>  
>  #define __linktime_error(message) __attribute__((__error__(messag

Re: [RFC] Device Tree Overlays Proposal (Was Re: capebus moving omap_devices to mach-omap2)

2012-11-07 Thread Pantelis Antoniou
Hi Grant,

On Nov 6, 2012, at 9:45 PM, Grant Likely wrote:

> On Tue, Nov 6, 2012 at 7:34 PM, Pantelis Antoniou
>  wrote:
>> On Nov 6, 2012, at 12:14 PM, Grant Likely wrote:
>>> On Tue, Nov 6, 2012 at 10:30 AM, Pantelis Antoniou
>>>  wrote:
 For hot-plugging, you need it. Whether kernel code can deal with
 large parts of the DT going away... How about we use the dead
 properties method and move/tag the removed modes as such, and not
 really remove them.
>>> 
>>> Nodes already use krefs, and I'm thinking about making them kobjects
>>> so that they appear in sysfs and we'll have some tools to figure out
>>> when reference counts don't get decremented properly.
>>> 
>> 
>> From the little I've looked in the of code, and the drivers, it's going
>> to be pretty bad. I don't think all users take references properly, and
>> we have a big global lock for accessing the DT.
> 
> I'm a lot more optimistic on this front... I wrote a patch today to
> make the change and took some measurements:
> 
> On the versatile express qemu model I measured the free memory with
> /proc/device-tree, with /sys/device-tree, and with both. Here's what I
> found:
> 
> /proc/device-tree only: 114776kB free
> /sys/device-tree only: 114792kB free
> both enabled: 114716kB free
> 
> The back of a napkin calculation indicates that on this platform
> /proc/devicetree costs 76kB and /sys/device-tree costs 60kb. I'm happy
> to see that using /sys instead of /proc appears to be slightly cheaper
> which makes it easier to justify the change. The diffstat makes me
> even happier:
> 
> arch/arm/plat-omap/Kconfig|1 -
> arch/powerpc/platforms/pseries/dlpar.c|   23 ---
> arch/powerpc/platforms/pseries/reconfig.c |   40 --
> drivers/of/Kconfig|8 
> drivers/of/base.c |  116
> 
> drivers/of/fdt.c  |5 ++-
> fs/proc/Makefile  |1 -
> fs/proc/proc_devtree.c|   13 +-
> fs/proc/root.c|4 +-
> include/linux/of.h|   35 
> include/linux/proc_fs.h   |   16 
> include/linux/string.h|   11 +
> 12 files changed, 107 insertions(+), 166 deletions(-)
> 

Interesting. Not so bad then.

> There are still a few odds and ends that need to be tidied up, but
> I'll get it out for review shortly. I've not touched the sparc code
> yet, and I need to take another look over the existing OF_DYNAMIC
> code. I think that CONFIG_OF_DYNAMIC will probably go away and the add
> node/property functions will get used by fdt.c and pdt.c for initial
> construction of the device tree.

CONFIG_OF_DYNAMIC never made sense to me. Glad to see the config option
gone. I'm not totally up to date with the -next dt stuff, but if we're
there can we rename all the prom_ functions to something saner?

> 
>> Adding and removing nodes at runtime as part of the normal operation of
>> the system (and not as something that happens once in a blue moon under
>> controlled conditions) will uncover lots of bugs.
> 
> I'm hoping so! Its time to clean that mess up. :-) Fortunately adding
> nodes is not where we're going to have problems. The problems will be
> on node removal. Addition-only at least means we can have something
> useful before hunting down and squashing all the bugs.

I'll admit that removing nodes is going to be quite rare at least for
me use cases. I did come across a couple of people that do hot-plugging
(using something completely different) that could use it for sure.

> 
>> So let's think about locking too
> 
> Yes, the locking does need to be sorted out.
> 

Perhaps come up with a dt-stress test tool/boot time validator?

> g.

Regards

-- Pantelis

P.S. Lots of teeth grinding in the ELCE about the lack of a DT preprocessor.
The pinctrl arguments have been mentioned more than once.


--
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: [RFC] Device Tree Overlays Proposal (Was Re: capebus moving omap_devices to mach-omap2)

2012-11-07 Thread Pantelis Antoniou
Hi Grant

On Nov 6, 2012, at 9:45 PM, Grant Likely wrote:

> On Tue, Nov 6, 2012 at 7:34 PM, Pantelis Antoniou
>  wrote:

[ snip ]
> 
> g.

Since we've started talking about longer term goals, and the versioning
provision seems to stand, I hope we address how much the fragment versioning
thing is similar to the way board revisions progress.

If a versioning syntax is available then one could create a single DT 
file for a bunch of 'almost' similar board and board revisions.

Using a single DTB in the same manner you have a single uImage would
make some people quite happy, since you won't have to do any bootloader
magic to make sure you pass the correct DTB for the specific revision.

Regards

-- Pantelis

--
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] mm, mempolicy: remove duplicate code

2012-11-07 Thread David Rientjes
Remove some duplicate code and simplify alloc_pages_vma().  No functional
change.

Signed-off-by: David Rientjes 
---
 mm/mempolicy.c |   21 -
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1907,7 +1907,6 @@ alloc_pages_vma(gfp_t gfp, int order, struct 
vm_area_struct *vma,
unsigned long addr, int node)
 {
struct mempolicy *pol;
-   struct zonelist *zl;
struct page *page;
unsigned int cpuset_mems_cookie;
 
@@ -1926,23 +1925,11 @@ retry_cpuset:
 
return page;
}
-   zl = policy_zonelist(gfp, pol, node);
-   if (unlikely(mpol_needs_cond_ref(pol))) {
-   /*
-* slow path: ref counted shared policy
-*/
-   struct page *page =  __alloc_pages_nodemask(gfp, order,
-   zl, policy_nodemask(gfp, pol));
-   __mpol_put(pol);
-   if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
-   goto retry_cpuset;
-   return page;
-   }
-   /*
-* fast path:  default or task policy
-*/
-   page = __alloc_pages_nodemask(gfp, order, zl,
+   page = __alloc_pages_nodemask(gfp, order,
+ policy_zonelist(gfp, pol, node),
  policy_nodemask(gfp, pol));
+   if (unlikely(mpol_needs_cond_ref(pol)))
+   __mpol_put(pol);
if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
goto retry_cpuset;
return page;
--
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: Network routing problem after upgrading to 3.6.2

2012-11-07 Thread Melby Sjamsuddin
Hi Richard,

I tested 3.5.7 and everything seems to be normal, so it must be 3.6.
Let me know if there's anything I can help.


Melby Sjamsuddin
Software Developermobile. 0403 714 482
www.vulytrampolines.com  ◦  like us on Facebook
For more general enquiries email: sa...@vulytrampolines.com or call 1300 667 514
 

On 05/11/2012, at 7:15 PM, richard -rw- weinberger wrote:

> On Mon, Nov 5, 2012 at 10:02 AM, Melby Sjamsuddin
>  wrote:
>> I have a network issue with two routers at work. They're setup with vrrp and 
>> do load balancing with
>> 'ip route nexthop' and iptables connmark, using different vlan to connect to 
>> different modems.
>> 
>> They have been working fine until recently where suddenly http connections 
>> just never finish
>> loading and very slow. I thought it was just slow until I recall that it 
>> started to happen after fedora 16
>> updated the kernel to 3.6.2.
>> 
>> If I boot to older kernel (3.4.11), everything becomes normal again.
> 
> Does 3.5 work?
> Please find out the exact release where it broke...
> 
> -- 
> Thanks,
> //richard



smime.p7s
Description: S/MIME cryptographic signature


Re: [RFC v4+ hot_track 03/19] vfs: add I/O frequency update function

2012-11-07 Thread Zhi Yong Wu
On Wed, Nov 7, 2012 at 6:45 AM, Darrick J. Wong  wrote:
> On Mon, Oct 29, 2012 at 12:30:45PM +0800, zwu.ker...@gmail.com wrote:
>> From: Zhi Yong Wu 
>>
>>   Add some util helpers to update access frequencies
>> for one file or its range.
>>
>> Signed-off-by: Zhi Yong Wu 
>> ---
>>  fs/hot_tracking.c|  179 
>> ++
>>  fs/hot_tracking.h|7 ++
>>  include/linux/hot_tracking.h |2 +
>>  3 files changed, 188 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c
>> index 68591f0..0a7d9a3 100644
>> --- a/fs/hot_tracking.c
>> +++ b/fs/hot_tracking.c
>> @@ -172,6 +172,137 @@ static void hot_inode_tree_exit(struct hot_info *root)
>>   }
>>  }
>>
>> +struct hot_inode_item
>> +*hot_inode_item_find(struct hot_info *root, u64 ino)
>> +{
>> + struct hot_inode_item *he;
>> + int ret;
>> +
>> +again:
>> + spin_lock(&root->lock);
>> + he = radix_tree_lookup(&root->hot_inode_tree, ino);
>> + if (he) {
>> + kref_get(&he->hot_inode.refs);
>> + spin_unlock(&root->lock);
>> + return he;
>> + }
>> + spin_unlock(&root->lock);
>> +
>> + he = kmem_cache_zalloc(hot_inode_item_cachep,
>> + GFP_KERNEL | GFP_NOFS);
>> + if (!he)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + hot_inode_item_init(he, ino, &root->hot_inode_tree);
>> +
>> + ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
>> + if (ret) {
>> + kmem_cache_free(hot_inode_item_cachep, he);
>> + return ERR_PTR(ret);
>> + }
>> +
>> + spin_lock(&root->lock);
>> + ret = radix_tree_insert(&root->hot_inode_tree, ino, he);
>> + if (ret == -EEXIST) {
>> + kmem_cache_free(hot_inode_item_cachep, he);
>> + spin_unlock(&root->lock);
>> + radix_tree_preload_end();
>> + goto again;
>> + }
>> + spin_unlock(&root->lock);
>> + radix_tree_preload_end();
>> +
>> + kref_get(&he->hot_inode.refs);
>> + return he;
>> +}
>> +EXPORT_SYMBOL_GPL(hot_inode_item_find);
>> +
>> +static struct hot_range_item
>> +*hot_range_item_find(struct hot_inode_item *he,
>> + u32 start)
>> +{
>> + struct hot_range_item *hr;
>> + int ret;
>> +
>> +again:
>> + spin_lock(&he->lock);
>> + hr = radix_tree_lookup(&he->hot_range_tree, start);
>> + if (hr) {
>> + kref_get(&hr->hot_range.refs);
>> + spin_unlock(&he->lock);
>> + return hr;
>> + }
>> + spin_unlock(&he->lock);
>> +
>> + hr = kmem_cache_zalloc(hot_range_item_cachep,
>> + GFP_KERNEL | GFP_NOFS);
>> + if (!hr)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + hot_range_item_init(hr, start, he);
>> +
>> + ret = radix_tree_preload(GFP_NOFS & ~__GFP_HIGHMEM);
>> + if (ret) {
>> + kmem_cache_free(hot_range_item_cachep, hr);
>> + return ERR_PTR(ret);
>> + }
>> +
>> + spin_lock(&he->lock);
>> + ret = radix_tree_insert(&he->hot_range_tree, start, hr);
>> + if (ret == -EEXIST) {
>> + kmem_cache_free(hot_range_item_cachep, hr);
>> + spin_unlock(&he->lock);
>> + radix_tree_preload_end();
>> + goto again;
>> + }
>> + spin_unlock(&he->lock);
>> + radix_tree_preload_end();
>> +
>> + kref_get(&hr->hot_range.refs);
>> + return hr;
>> +}
>> +
>> +/*
>> + * This function does the actual work of updating
>> + * the frequency numbers, whatever they turn out to be.
>> + */
>> +static u64 hot_average_update(struct timespec old_atime,
>> + struct timespec cur_time, u64 old_avg)
>> +{
>> + struct timespec delta_ts;
>> + u64 new_avg;
>> + u64 new_delta;
>> +
>> + delta_ts = timespec_sub(cur_time, old_atime);
>> + new_delta = timespec_to_ns(&delta_ts) >> FREQ_POWER;
>> +
>> + new_avg = (old_avg << FREQ_POWER) - old_avg + new_delta;
>> + new_avg = new_avg >> FREQ_POWER;
>> +
>> + return new_avg;
>> +}
>> +
>> +static void hot_freq_data_update(struct hot_freq_data *freq_data, bool 
>> write)
>> +{
>> + struct timespec cur_time = current_kernel_time();
>> +
>> + if (write) {
>> + freq_data->nr_writes += 1;
>> + freq_data->avg_delta_writes = hot_average_update(
>> + freq_data->last_write_time,
>> + cur_time,
>> + freq_data->avg_delta_writes);
>> + freq_data->last_write_time = cur_time;
>> + } else {
>> + freq_data->nr_reads += 1;
>> + freq_data->avg_delta_reads = hot_average_update(
>> + freq_data->last_read_time,
>> + cur_time,
>> + freq_data->avg_delta_reads);
>
> I think you could just pass in a pointer to
> freq_data->avg_delta_{writes,reads} here

Re: [patch 02/16] sched: maintain per-rq runnable averages

2012-11-07 Thread Preeti U Murthy
On 10/29/2012 11:08 PM, Benjamin Segall wrote:
> Preeti Murthy  writes:
> 
>> Hi Paul, Ben,
>>
>> A few queries regarding this patch:
>>
>> 1.What exactly is the significance of introducing sched_avg structure
>> for a runqueue? If I have
>>understood correctly, sched_avg keeps track of how long a task has
>> been active,
>>how long has it been serviced by the processor and its lifetime.How
>> does this apply analogously
>>to the runqueue?
> 
> Remember that sched_avg's are not just for tasks, they're for any CFS
> group entity (sched_entity), for which they track the time runnable and
> the time used, which allows the system-wide per-task_group computation
> of runnable and usage.
> 
> Computing these on the root has no usage in this patchset, but any
> extensions of this using hierarchy-based fractional usage or runnable
> time would need it, and retrofitting it afterwards would be a pain.
>>
>> 2.Is this a right measure to overwrite rq->load.weight because the
>> rq->sched_avg does not seem to
>>take care of task priorities.IOW, what is the idea behind
>> introducing this metric for the runqueue?
>>Why cant the run queue load be updated the same way as the cfs_rq
>> load is updated:
>> cfs_rq->runnable_load_avg and cfs_rq->blocked_load_avg.
> 
> Loadwise you would indeed want the cfs_rq statistics, that is what they
> are there for. The sched_avg numbers are only useful in computing the
> parent's load (irrelevant on the root), or for extensions using raw
> usage/runnable numbers.
>>
>> 3.What is the significance of passing rq->nr_running in
>> enqueue_task_fair while updating
>>the run queue load? Because __update_entity_runnable_avg does not
>> treat this argument
>>any differently if it is >1.
> 
> That could just as well be rq->nr_running != 0, it would behave the same.

Hi Ben,
After going through your suggestions,below is a patch which I wish to begin
with in my effort to integrate the per-entity-load-tracking metric with the
scheduler.I had posted out a patchset earlier,
(https://lkml.org/lkml/2012/10/25/162) but due to various drawbacks,
I am redoing it along the lines of the suggestions posted in reply to it.
Please do let me know if I am using the metric in the right way.Thanks.

Regards
Preeti U Murthy

START OF PATCH

Since load balancing requires runqueue load to track the load of the sched
groups and hence the sched domains,introduce the cfs_rq equivalent metric of
current runnable load to the run queue as well.

The idea is something like this:

1.The entire load balancing framework is hinged upon what
weighted_cpuload() has to say about the load of the sched group which in turn
adds upto the weight of the sched domain and will ultimately be used to decide
whether to do load balance and to calculate the imbalance.

2.Currently weighted_cpuload() is returning rq->load.weight,but it needs to
use the per-entity-load-tracking metric to reflect the runqueue load.So it
needs to be replaced it with rq->runnable_load_avg.

3.This being the first step towards integrating the per-entity-load tracking
metric with the load balancer.

Signed-off-by: Preeti U Murthy
---
 kernel/sched/fair.c  |9 -
 kernel/sched/sched.h |1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a9cdc8f..6c89b28 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1499,8 +1499,11 @@ static inline void update_entity_load_avg(struct 
sched_entity *se,
if (!update_cfs_rq)
return;

-   if (se->on_rq)
+   if (se->on_rq) {
cfs_rq->runnable_load_avg += contrib_delta;
+   if(!parent_entity(se))
+   rq->runnable_load_avg += contrib_delta;
+   }
else
subtract_blocked_load_contrib(cfs_rq, -contrib_delta);
 }
@@ -1579,6 +1582,8 @@ static inline void enqueue_entity_load_avg(struct cfs_rq 
*cfs_rq,
}

cfs_rq->runnable_load_avg += se->avg.load_avg_contrib;
+   if(!parent_entity(se))
+   rq->runnable_load_avg += se->avg.load_avg_contrib;
/* we force update consideration on load-balancer moves */
update_cfs_rq_blocked_load(cfs_rq, !wakeup);
 }
@@ -1597,6 +1602,8 @@ static inline void dequeue_entity_load_avg(struct cfs_rq 
*cfs_rq,
update_cfs_rq_blocked_load(cfs_rq, !sleep);

cfs_rq->runnable_load_avg -= se->avg.load_avg_contrib;
+   if(!parent_entity(se))
+   rq->runnable_load_avg -= se->avg.load_avg_contrib;
if (sleep) {
cfs_rq->blocked_load_avg += se->avg.load_avg_contrib;
se->avg.decay_count = atomic64_read(&cfs_rq->decay_counter);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index bfd004a..3001d97 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -382,6 +382,7 @@ struct rq {
/* list of leaf cfs_rq on this cpu:

Re: [RFC v4+ hot_track 10/19] vfs: introduce hot func register framework

2012-11-07 Thread Zhi Yong Wu
On Wed, Nov 7, 2012 at 7:30 AM, Darrick J. Wong  wrote:
> On Mon, Oct 29, 2012 at 12:30:52PM +0800, zwu.ker...@gmail.com wrote:
>> From: Zhi Yong Wu 
>>
>>   Introduce one framwork to enable that specific FS
>> can register its own hot tracking functions.
>>
>> Signed-off-by: Zhi Yong Wu 
>> ---
>>  fs/hot_tracking.c|   78 
>> ++
>>  include/linux/hot_tracking.h |   25 +
>>  2 files changed, 96 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c
>> index 0ef9cad..c6c6138 100644
>> --- a/fs/hot_tracking.c
>> +++ b/fs/hot_tracking.c
>> @@ -24,6 +24,9 @@
>>  #include 
>>  #include "hot_tracking.h"
>>
>> +static DEFINE_SPINLOCK(hot_func_list_lock);
>> +static LIST_HEAD(hot_func_list);
>> +
>>  /* kmem_cache pointers for slab caches */
>>  static struct kmem_cache *hot_inode_item_cachep __read_mostly;
>>  static struct kmem_cache *hot_range_item_cachep __read_mostly;
>> @@ -305,20 +308,23 @@ static u64 hot_average_update(struct timespec 
>> old_atime,
>>   return new_avg;
>>  }
>>
>> -static void hot_freq_data_update(struct hot_freq_data *freq_data, bool 
>> write)
>> +static void hot_freq_data_update(struct hot_info *root,
>> + struct hot_freq_data *freq_data, bool write)
>>  {
>>   struct timespec cur_time = current_kernel_time();
>>
>>   if (write) {
>>   freq_data->nr_writes += 1;
>> - freq_data->avg_delta_writes = hot_average_update(
>> + freq_data->avg_delta_writes =
>> + root->hot_func_type->ops.hot_rw_freq_calc_fn(
>>   freq_data->last_write_time,
>>   cur_time,
>>   freq_data->avg_delta_writes);
>>   freq_data->last_write_time = cur_time;
>>   } else {
>>   freq_data->nr_reads += 1;
>> - freq_data->avg_delta_reads = hot_average_update(
>> + freq_data->avg_delta_reads =
>> + root->hot_func_type->ops.hot_rw_freq_calc_fn(
>>   freq_data->last_read_time,
>>   cur_time,
>>   freq_data->avg_delta_reads);
>> @@ -430,7 +436,7 @@ static void hot_map_array_update(struct hot_freq_data 
>> *freq_data,
>>   struct hot_comm_item *comm_item;
>>   struct hot_inode_item *he;
>>   struct hot_range_item *hr;
>> - u32 temp = hot_temp_calc(freq_data);
>> + u32 temp = root->hot_func_type->ops.hot_temp_calc_fn(freq_data);
>>   u8 a_temp = temp >> (32 - HEAT_MAP_BITS);
>>   u8 b_temp = freq_data->last_temp >> (32 - HEAT_MAP_BITS);
>>
>> @@ -511,7 +517,7 @@ static void hot_range_update(struct hot_inode_item *he,
>>   &hr_nodes[i]->hot_range.hot_freq_data, root);
>>
>>   spin_lock(&hr_nodes[i]->hot_range.lock);
>> - obsolete = hot_is_obsolete(
>> + obsolete = root->hot_func_type->ops.hot_is_obsolete_fn(
>>   &hr_nodes[i]->hot_range.hot_freq_data);
>>   spin_unlock(&hr_nodes[i]->hot_range.lock);
>>
>> @@ -668,7 +674,7 @@ void hot_update_freqs(struct inode *inode, u64 start,
>>   }
>>
>>   spin_lock(&he->hot_inode.lock);
>> - hot_freq_data_update(&he->hot_inode.hot_freq_data, rw);
>> + hot_freq_data_update(root, &he->hot_inode.hot_freq_data, rw);
>>   spin_unlock(&he->hot_inode.lock);
>>
>>   /*
>> @@ -685,7 +691,7 @@ void hot_update_freqs(struct inode *inode, u64 start,
>>   }
>>
>>   spin_lock(&hr->hot_range.lock);
>> - hot_freq_data_update(&hr->hot_range.hot_freq_data, rw);
>> + hot_freq_data_update(root, &hr->hot_range.hot_freq_data, rw);
>>   spin_unlock(&hr->hot_range.lock);
>>
>>   hot_range_item_put(hr);
>> @@ -695,6 +701,61 @@ void hot_update_freqs(struct inode *inode, u64 start,
>>  }
>>  EXPORT_SYMBOL_GPL(hot_update_freqs);
>>
>> +static struct hot_func_type hot_func_def = {
>> + .hot_func_name = "hot_type_def",
>> + .ops = {
>> + .hot_rw_freq_calc_fn = hot_average_update,
>> + .hot_temp_calc_fn= hot_temp_calc,
>> + .hot_is_obsolete_fn  = hot_is_obsolete,
>> + },
>> +};
>
> If these hot_ops are per-filesystem, why not just embed a struct hot_func_ops
> inside of struct file_system_type?  That eliminates this _get function,
this _get function is very small, only some loc, if hot_func_ops is
embedded in struct file_system_type, i am afraid to introduce some
regressions
> collision avoidance, etc.  You can fill in NULL function pointers in
fill in NULL func pointer? why?
> hot_track_init (or just code around them).
>
> --D
>
>> +
>> +static struct hot_func_type *hot_func_get(const char *name)
>> +{
>> + struct hot_func_type *f, *h = &hot_func_def;
>> +
>> + spin_lock(&hot_func_list_loc

Need assistance fixing a tg3 driver side-effect on IPMI

2012-11-07 Thread Steffen Grunewald
Hi everyone,

I've been running into a problem while installing Debian Wheezy on a bunch
of 6-year old machines which have been running Squeeze happily for years.

They are SuperMicro-based (H8SSL opteron board), with two BCM95704A6 (Tigon3) 
interfaces, and a BMC/IPMI card (SuperMicro 1U) which shares eth0.

With a 2.6.32 kernel (and the 3.102 version of the tg3 driver) everything is 
fine.

With Debian's 3.2 (and tg3 3.121) I lose access to the IPMI LAN (or LANplus)
interface as soon as the tg3 module has been loaded. Even shutting down doesn't
give the interface back - I've got to pull the power plug.

Trying to git bisect the corresponding changes to the tg3 driver, I'm running
against a wall at the point where the source code has been moved to another
subtree back in 2011 (still a long time past Squeeze). I appear to be unable
to go back beyond that.

Can you advise how to find out when IPMI access got lost, and how to re-enable
it? Any suggestion is appreciated.
I suppose it wouldn't be as easy as "get the old source from 2.6.32, and plug
it into drivers/net/ethernet/broadcom, then rebuild the kernel" -?

Please keep me on CC, thanks.

Regards,
 Steffen
--
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] mtd: map: Fix compilation warning

2012-11-07 Thread Viresh Kumar
On 29 October 2012 22:47, Viresh Kumar  wrote:
> This patch is an attempt to fix following compilation warning.
>
> In file included from drivers/mtd/chips/cfi_cmdset_0001.c:35:0:
> drivers/mtd/chips/cfi_cmdset_0001.c: In function 'cfi_intelext_write_words':
> include/linux/mtd/map.h:331:11: warning: 'r.x[0]' may be used uninitialized 
> in this function [-Wmaybe-uninitialized]
>
> I could have used uninitialized_var() too, but didn't used it as the final 
> else
> part of map_word_load() is missing. So there is a chance that it might be 
> passed
> uninitialized. Better initialize to zero.
>
> Signed-off-by: Viresh Kumar 

Ping!!
--
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] xfs: add hot tracking support.

2012-11-07 Thread Zhi Yong Wu
HI, Dave,

I guess that you should add some hot tracking stuff in some
xfs_show_xxx function, right?

On Tue, Oct 16, 2012 at 8:04 AM, Dave Chinner  wrote:
>
> From: Dave Chinner 
>
> Connect up the VFS hot tracking support so XFS filesystems can make
> use of it.
>
> Signed-off-by: Dave Chinner 
> ---
>  fs/xfs/xfs_mount.h |1 +
>  fs/xfs/xfs_super.c |9 +
>  2 files changed, 10 insertions(+)
>
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index a631ca3..d5e7277 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -215,6 +215,7 @@ typedef struct xfs_mount {
>  #define XFS_MOUNT_WSYNC(1ULL << 0) /* for nfs - all 
> metadata ops
>must be synchronous except
>for space allocations */
> +#define XFS_MOUNT_HOTTRACK (1ULL << 1) /* hot inode tracking */
>  #define XFS_MOUNT_WAS_CLEAN(1ULL << 3)
>  #define XFS_MOUNT_FS_SHUTDOWN  (1ULL << 4) /* atomic stop of all 
> filesystem
>operations, typically for
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 56c2537..17786ff 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -61,6 +61,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static const struct super_operations xfs_super_operations;
>  static kmem_zone_t *xfs_ioend_zone;
> @@ -114,6 +115,7 @@ mempool_t *xfs_ioend_pool;
>  #define MNTOPT_NODELAYLOG  "nodelaylog"/* Delayed logging disabled */
>  #define MNTOPT_DISCARD"discard"/* Discard unused blocks */
>  #define MNTOPT_NODISCARD   "nodiscard" /* Do not discard unused blocks */
> +#define MNTOPT_HOTTRACK"hot_track" /* hot inode tracking */
>
>  /*
>   * Table driven mount option parser.
> @@ -371,6 +373,8 @@ xfs_parseargs(
> mp->m_flags |= XFS_MOUNT_DISCARD;
> } else if (!strcmp(this_char, MNTOPT_NODISCARD)) {
> mp->m_flags &= ~XFS_MOUNT_DISCARD;
> +   } else if (!strcmp(this_char, MNTOPT_HOTTRACK)) {
> +   mp->m_flags |= XFS_MOUNT_HOTTRACK;
> } else if (!strcmp(this_char, "ihashsize")) {
> xfs_warn(mp,
> "ihashsize no longer used, option is deprecated.");
> @@ -1040,6 +1044,9 @@ xfs_fs_put_super(
>  {
> struct xfs_mount*mp = XFS_M(sb);
>
> +   if (mp->m_flags & XFS_MOUNT_HOTTRACK)
> +   hot_track_exit(sb);
> +
> xfs_filestream_unmount(mp);
> xfs_unmountfs(mp);
>
> @@ -1470,6 +1477,8 @@ xfs_fs_fill_super(
> error = ENOMEM;
> goto out_unmount;
> }
> +   if (mp->m_flags & XFS_MOUNT_HOTTRACK)
> +   hot_track_init(sb);
>
> return 0;
>



-- 
Regards,

Zhi Yong Wu
--
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: [Xen-devel] [PATCH 1/2] xen/generic: Disable fallback build on ARM.

2012-11-07 Thread Jan Beulich
>>> On 07.11.12 at 08:19, Ian Campbell  wrote:
> On Tue, 2012-11-06 at 22:13 +, Konrad Rzeszutek Wilk wrote:
>> As there is no need for it (the fallback code is for older
>> hypervisors and they won't run under ARM), 
> 
> I think more specifically they won't run on anything other than x86.
> 
> [...]
>> diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>> index 46de6cd..273d2b9 100644
>> --- a/drivers/xen/Makefile
>> +++ b/drivers/xen/Makefile
>> @@ -1,8 +1,8 @@
>>  ifneq ($(CONFIG_ARM),y)
>> -obj-y   += manage.o balloon.o
>> +obj-y   += manage.o balloon.o fallback.o
>>  obj-$(CONFIG_HOTPLUG_CPU)   += cpu_hotplug.o
>>  endif
> 
> I think :
>   obj-$(CONFIG_X86) += fallback.o
> would better reflect what is going on here.

Yes please.

Jan

--
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: Network routing problem after upgrading to 3.6.2

2012-11-07 Thread richard -rw- weinberger
On Wed, Nov 7, 2012 at 9:18 AM, Melby Sjamsuddin
 wrote:
> Hi Richard,
>
> I tested 3.5.7 and everything seems to be normal, so it must be 3.6.
> Let me know if there's anything I can help.

Now you can do a git bisect between 3.5 and 3.6 to find the bad commit.
And you can report the issue (in detail!) to net...@vger.kernel.org

-- 
Thanks,
//richard
--
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 0/2] Provide more precise dump info for memcg-oom

2012-11-07 Thread Sha Zhengju
From: Sha Zhengju 


When memcg oom is happening the current memcg related dump information
is limited for debugging. The patches provide more detailed memcg page 
statistics
and also take hierarchy into consideration.
The previous primitive version can be reached here: 
https://lkml.org/lkml/2012/7/30/179.

Change log:
1. some modification towards hierarchy
2. rework dump_tasks
3. rebased on Michal's mm tree since-3.6  

Any comments are welcomed. : )


Sha Zhengju (2):
memcg-oom-provide-more-precise-dump-info-while-memcg.patch
oom-rework-dump_tasks-to-optimize-memcg-oom-situatio.patch

 include/linux/memcontrol.h |7 
 include/linux/oom.h|2 +
 mm/memcontrol.c|   85 +++-
 mm/oom_kill.c  |   61 +++
 4 files changed, 122 insertions(+), 33 deletions(-)
--
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] memcg, oom: provide more precise dump info while memcg oom happening

2012-11-07 Thread Sha Zhengju
From: Sha Zhengju 

Current, when a memcg oom is happening the oom dump messages is still global
state and provides few useful info for users. This patch prints more pointed
memcg page statistics for memcg-oom.

Signed-off-by: Sha Zhengju 
Cc: Michal Hocko 
Cc: KAMEZAWA Hiroyuki 
Cc: David Rientjes 
Cc: Andrew Morton 
---
 mm/memcontrol.c |   71 ---
 mm/oom_kill.c   |6 +++-
 2 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0eab7d5..2df5e72 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -118,6 +118,14 @@ static const char * const mem_cgroup_events_names[] = {
"pgmajfault",
 };
 
+static const char * const mem_cgroup_lru_names[] = {
+   "inactive_anon",
+   "active_anon",
+   "inactive_file",
+   "active_file",
+   "unevictable",
+};
+
 /*
  * Per memcg event counter is incremented at every pagein/pageout. With THP,
  * it will be incremated by the number of pages. This counter is used for
@@ -1501,8 +1509,59 @@ static void move_unlock_mem_cgroup(struct mem_cgroup 
*memcg,
spin_unlock_irqrestore(&memcg->move_lock, *flags);
 }
 
+#define K(x) ((x) << (PAGE_SHIFT-10))
+static void mem_cgroup_print_oom_stat(struct mem_cgroup *memcg)
+{
+   struct mem_cgroup *mi;
+   unsigned int i;
+
+   if (!memcg->use_hierarchy && memcg != root_mem_cgroup) {
+   for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
+   if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
+   continue;
+   printk(KERN_CONT "%s:%ldKB ", mem_cgroup_stat_names[i],
+   K(mem_cgroup_read_stat(memcg, i)));
+   }
+
+   for (i = 0; i < MEM_CGROUP_EVENTS_NSTATS; i++)
+   printk(KERN_CONT "%s:%lu ", mem_cgroup_events_names[i],
+   mem_cgroup_read_events(memcg, i));
+
+   for (i = 0; i < NR_LRU_LISTS; i++)
+   printk(KERN_CONT "%s:%luKB ", mem_cgroup_lru_names[i],
+   K(mem_cgroup_nr_lru_pages(memcg, BIT(i;
+   } else {
+
+   for (i = 0; i < MEM_CGROUP_STAT_NSTATS; i++) {
+   long long val = 0;
+
+   if (i == MEM_CGROUP_STAT_SWAP && !do_swap_account)
+   continue;
+   for_each_mem_cgroup_tree(mi, memcg)
+   val += mem_cgroup_read_stat(mi, i);
+   printk(KERN_CONT "%s:%lldKB ", 
mem_cgroup_stat_names[i], K(val));
+   }
+
+   for (i = 0; i < MEM_CGROUP_EVENTS_NSTATS; i++) {
+   unsigned long long val = 0;
+
+   for_each_mem_cgroup_tree(mi, memcg)
+   val += mem_cgroup_read_events(mi, i);
+   printk(KERN_CONT "%s:%llu ",
+   mem_cgroup_events_names[i], val);
+   }
+
+   for (i = 0; i < NR_LRU_LISTS; i++) {
+   unsigned long long val = 0;
+
+   for_each_mem_cgroup_tree(mi, memcg)
+   val += mem_cgroup_nr_lru_pages(mi, BIT(i));
+   printk(KERN_CONT "%s:%lluKB ", mem_cgroup_lru_names[i], 
K(val));
+   }
+   }
+   printk(KERN_CONT "\n");
+}
 /**
- * mem_cgroup_print_oom_info: Called from OOM with tasklist_lock held in read 
mode.
  * @memcg: The memory cgroup that went over limit
  * @p: Task that is going to be killed
  *
@@ -1569,6 +1628,8 @@ done:
res_counter_read_u64(&memcg->kmem, RES_USAGE) >> 10,
res_counter_read_u64(&memcg->kmem, RES_LIMIT) >> 10,
res_counter_read_u64(&memcg->kmem, RES_FAILCNT));
+
+   mem_cgroup_print_oom_stat(memcg);
 }
 
 /*
@@ -5195,14 +5256,6 @@ static int memcg_numa_stat_show(struct cgroup *cont, 
struct cftype *cft,
 }
 #endif /* CONFIG_NUMA */
 
-static const char * const mem_cgroup_lru_names[] = {
-   "inactive_anon",
-   "active_anon",
-   "inactive_file",
-   "active_file",
-   "unevictable",
-};
-
 static inline void mem_cgroup_lru_names_not_uptodate(void)
 {
BUILD_BUG_ON(ARRAY_SIZE(mem_cgroup_lru_names) != NR_LRU_LISTS);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 7e9e911..4b8a6dd 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -421,8 +421,10 @@ static void dump_header(struct task_struct *p, gfp_t 
gfp_mask, int order,
cpuset_print_task_mems_allowed(current);
task_unlock(current);
dump_stack();
-   mem_cgroup_print_oom_info(memcg, p);
-   show_mem(SHOW_MEM_FILTER_NODES);
+   if (memcg)
+   mem_cgroup_print_oom_info(memcg, p);
+   else
+   show_mem(SHOW_MEM_FILTER_NODES);
if (sysctl_oom_dump_tasks)
dump_tasks(memcg, nodemask);
 }
-- 
1.7.6.1

-

[PATCH 2/2] oom: rework dump_tasks to optimize memcg-oom situation

2012-11-07 Thread Sha Zhengju
From: Sha Zhengju 

If memcg oom happening, don't scan all system tasks to dump memory state of
eligible tasks, instead we iterates only over the process attached to the oom
memcg and avoid the rcu lock.


Signed-off-by: Sha Zhengju 
Cc: Michal Hocko 
Cc: KAMEZAWA Hiroyuki 
Cc: David Rientjes 
Cc: Andrew Morton 
---
 include/linux/memcontrol.h |7 +
 include/linux/oom.h|2 +
 mm/memcontrol.c|   14 +++
 mm/oom_kill.c  |   55 ++-
 4 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index c91e3c1..4322ca8 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -122,6 +122,8 @@ unsigned long mem_cgroup_get_lru_size(struct lruvec 
*lruvec, enum lru_list);
 void mem_cgroup_update_lru_size(struct lruvec *, enum lru_list, int);
 extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
struct task_struct *p);
+extern void dump_tasks_memcg(const struct mem_cgroup *memcg,
+   const nodemask_t *nodemask);
 extern void mem_cgroup_replace_page_cache(struct page *oldpage,
struct page *newpage);
 
@@ -337,6 +339,11 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct 
task_struct *p)
 {
 }
 
+static inline void
+dump_tasks_memcg(const struct mem_cgroup *memcg, const nodemask_t *nodemask)
+{
+}
+
 static inline void mem_cgroup_begin_update_page_stat(struct page *page,
bool *locked, unsigned long *flags)
 {
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 20b5c46..9ba3344 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -57,6 +57,8 @@ extern enum oom_scan_t oom_scan_process_thread(struct 
task_struct *task,
unsigned long totalpages, const nodemask_t *nodemask,
bool force_kill);
 
+extern inline void dump_per_task(struct task_struct *p,
+   const nodemask_t *nodemask);
 extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
int order, nodemask_t *mask, bool force_kill);
 extern int register_oom_notifier(struct notifier_block *nb);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2df5e72..fe648f8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1665,6 +1665,20 @@ static u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
return min(limit, memsw);
 }
 
+void dump_tasks_memcg(const struct mem_cgroup *memcg, const nodemask_t 
*nodemask)
+{
+   struct cgroup_iter it;
+   struct task_struct *task;
+   struct cgroup *cgroup = memcg->css.cgroup;
+
+   cgroup_iter_start(cgroup, &it);
+   while ((task = cgroup_iter_next(cgroup, &it))) {
+   dump_per_task(task, nodemask);
+   }
+
+   cgroup_iter_end(cgroup, &it);
+}
+
 static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
 int order)
 {
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 4b8a6dd..aaf6237 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -367,6 +367,32 @@ static struct task_struct *select_bad_process(unsigned int 
*ppoints,
return chosen;
 }
 
+inline void dump_per_task(struct task_struct *p, const nodemask_t *nodemask)
+{
+   struct task_struct *task;
+
+   if (oom_unkillable_task(p, NULL, nodemask))
+   return;
+
+   task = find_lock_task_mm(p);
+   if (!task) {
+   /*
+* This is a kthread or all of p's threads have already
+* detached their mm's.  There's no need to report
+* them; they can't be oom killed anyway.
+*/
+   return;
+   }
+
+   pr_info("[%5d] %5d %5d %8lu %8lu %7lu %8lu %5d %s\n",
+   task->pid, from_kuid(&init_user_ns, task_uid(task)),
+   task->tgid, task->mm->total_vm, get_mm_rss(task->mm),
+   task->mm->nr_ptes,
+   get_mm_counter(task->mm, MM_SWAPENTS),
+   task->signal->oom_score_adj, task->comm);
+   task_unlock(task);
+}
+
 /**
  * dump_tasks - dump current memory state of all system tasks
  * @memcg: current's memory controller, if constrained
@@ -381,32 +407,17 @@ static struct task_struct *select_bad_process(unsigned 
int *ppoints,
 static void dump_tasks(const struct mem_cgroup *memcg, const nodemask_t 
*nodemask)
 {
struct task_struct *p;
-   struct task_struct *task;
 
pr_info("[ pid ]   uid  tgid total_vm  rss nr_ptes swapents 
oom_score_adj name\n");
-   rcu_read_lock();
-   for_each_process(p) {
-   if (oom_unkillable_task(p, memcg, nodemask))
-   continue;
-
-   task = find_lock_task_mm(p);
-   if (!task) {
-   /*
-* This is a kthread o

[PATCH v2 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu
From: Qing Xu 

Signed-off-by: Qing Xu 
---
 drivers/regulator/max8925-regulator.c |   72 +++-
 1 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/max8925-regulator.c 
b/drivers/regulator/max8925-regulator.c
index 9bb0be3..5e84921 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define SD1_DVM_VMIN   85
 #define SD1_DVM_VMAX   100
@@ -187,6 +189,34 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.enable_reg = MAX8925_LDOCTL##_id,  \
 }
 
+#ifdef CONFIG_OF
+static struct of_regulator_match max8925_regulator_matches[] = {
+   { .name = "SDV1",},
+   { .name = "SDV2",},
+   { .name = "SDV3",},
+   { .name = "LDO1",},
+   { .name = "LDO2",},
+   { .name = "LDO3",},
+   { .name = "LDO4",},
+   { .name = "LDO5",},
+   { .name = "LDO6",},
+   { .name = "LDO7",},
+   { .name = "LDO8",},
+   { .name = "LDO9",},
+   { .name = "LDO10",},
+   { .name = "LDO11",},
+   { .name = "LDO12",},
+   { .name = "LDO13",},
+   { .name = "LDO14",},
+   { .name = "LDO15",},
+   { .name = "LDO16",},
+   { .name = "LDO17",},
+   { .name = "LDO18",},
+   { .name = "LDO19",},
+   { .name = "LDO20",},
+};
+#endif
+
 static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_SDV(1, 637.5, 1425, 12.5),
MAX8925_SDV(2,   650, 2225,   25),
@@ -214,6 +244,36 @@ static struct max8925_regulator_info 
max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
 };
 
+#ifdef CONFIG_OF
+static int max8925_regulator_dt_init(struct platform_device *pdev,
+   struct max8925_regulator_info *info,
+   struct regulator_config *config,
+   int ridx)
+{
+   struct device_node *nproot, *np;
+   int rcount;
+   nproot = pdev->dev.parent->of_node;
+   if (!nproot)
+   return -ENODEV;
+   np = of_find_node_by_name(nproot, "regulators");
+   if (!np) {
+   dev_err(&pdev->dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+
+   rcount = of_regulator_match(&pdev->dev, np,
+   &max8925_regulator_matches[ridx], 1);
+   if (rcount < 0)
+   return -ENODEV;
+   config->init_data = max8925_regulator_matches[ridx].init_data;
+   config->of_node = max8925_regulator_matches[ridx].of_node;
+
+   return 0;
+}
+#else
+#define max8925_regulator_dt_init(x, y, z) (-1)
+#endif
+
 static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -222,7 +282,7 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
struct max8925_regulator_info *ri;
struct resource *res;
struct regulator_dev *rdev;
-   int i;
+   int i, regulator_idx;
 
res = platform_get_resource(pdev, IORESOURCE_REG, 0);
if (!res) {
@@ -231,9 +291,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
}
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
-   if (ri->vol_reg == res->start)
+   if (ri->vol_reg == res->start) {
+   regulator_idx = i;
break;
+   }
}
+
if (i == ARRAY_SIZE(max8925_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n",
(unsigned long long)res->start);
@@ -243,9 +306,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
ri->chip = chip;
 
config.dev = &pdev->dev;
-   config.init_data = pdata;
config.driver_data = ri;
 
+   if (max8925_regulator_dt_init(pdev, ri, &config, regulator_idx))
+   if (pdata)
+   config.init_data = pdata;
+
rdev = regulator_register(&ri->desc, &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
-- 
1.7.0.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] gpiolib: iron out include ladder mistakes

2012-11-07 Thread Mika Westerberg
On Tue, Nov 06, 2012 at 05:21:03PM +0100, Linus Walleij wrote:
> +static inline int
> +gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
> +unsigned int pin_base, unsigned int npins)
> +{
> +}

Should you return some value above? Like -ENOSYS?
--
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: [RFC] Device Tree Overlays Proposal (Was Re: capebus moving omap_devices to mach-omap2)

2012-11-07 Thread Pantelis Antoniou
Hi Stephen,

On Nov 6, 2012, at 11:37 PM, Stephen Warren wrote:

> On 11/05/2012 01:40 PM, Grant Likely wrote:
>> Hey folks,
>> 
>> As promised, here is my early draft to try and capture what device
>> tree overlays need to do and how to get there. Comments and
>> suggestions greatly appreciated.
> 
> Interesting. This just came up internally at NVIDIA within the last
> couple weeks, and was discussed on the U-Boot mailing list very recently
> too:
> 
> http://lists.denx.de/pipermail/u-boot/2012-October/thread.html#138227
> (it spills into the November archive too)

I am aware of this discussion. For our use case u-boot DT manipulation was
tried, but then abandoned. Asking our user base to modify anything in u-boot
was ruled out.
 
> 
>> For these cases it is proposed to implement an overlay feature for the
>> so that the initial device tree data can be modified by userspace at
> 
> I don't know if you're maintaining this as a document and taking patches
> to it, but if so:
> 
> "for the so" split across those two lines.
> 
>> Jane solves this problem by storing an FDT overlay for each cape in the
>> root filesystem. When the kernel detects that a cape is installed it
>> reads the cape's eeprom to identify it and uses request_firmware() to
>> obtain the appropriate overlay. Userspace passes the overlay to the
>> kernel in the normal way. If the cape doesn't have an eeprom, then the
>> kernel will still use firmware_request(), but userspace needs to already
>> know which cape is installed.
> 
> As mentioned by Pantelis, multiple versions of a board is also very
> common. We already have the following .dts files in the kernel where
> this applies, for the main board even:
> 
> arch/arm/boot/dts/tegra30-cardhu.dtsi
> arch/arm/boot/dts/tegra30-cardhu-a02.dts
> arch/arm/boot/dts/tegra30-cardhu-a04.dts
> 

Exactly. I've made this point in another email, but IMHO board-revision
management is exactly the same with cape revision management.

Ideally you'd like to get rid of those three, and replace it with only
one that's properly versioned.


>> Summary points:
> 
>>  - SHOULD reliably handle changes between different underlying overlays
>>(ie. what happens to existing .dtb overly files if the structure of
>>the dtb it is layered over changes. If not possible, then SHALL
>>detect when the base tree doesn't match and refuse to apply the
>>overlay.
> 
> Perhaps use (versioned) DT bindings to represent the interface between
> the two .dts files? See the links to the U-Boot mailing list discussions
> below?
> 
>> - What is the model for overlays?
>>  - Can an overlay modify existing properties?
>>  - Can an overlay add new properties to existing nodes?
>>  - Can an overlay delete existing nodes/properties?
> 
> This proposal is very oriented at an overlay-based approach. I'm not
> totally convinced that a pure overlay approach (as in how dtc does
> overlayed DT nodes) will be flexible enough, but would love to be
> persuaded. Again see below.
> 
>> It may be sufficient to solve it by making the phandle values less
>> volatile. Right now dtc generates phandles linearly. Generated phandles
>> could be overridden with explicit phandle properties, but it isn't a
>> fantastic solution. Perhaps generating the phandle from a hash of the
>> node name would be sufficient.
> 
> Node names don't have to be unique though right; perhaps hash the
> path-name instead of the node-name? But then, why not just reference by
> path name; similar to <{&/path/to/node}> rather than <&label>?
> 

It would work for references to the known base DTS. If you have a
cape that's cross-device compatible that can simply fail.

I like this for it's simplicity though.

>> This handles many of the use cases, but it assumes that an overlay is
>> board specific. If it ever is required to support multiple base boards
>> with a single overlay file then there is a problem. The .dtb overlays
>> generated in this manor cannot handle different phandles or nodes that
>> are in a different place. On the other hand, the overlay source files
>> should have no problem being compiled for multiple targets.
> 
> s/manor/manner/
> 
> I do rather suspect this use-case is quite common. NVIDIA certainly has
> a bunch of development boards with pluggable
> PMIC/audio/WiFi/display/..., and I believe there's some ability to
> re-use the pluggable components with a variety of base-boards.
> 
> Given people within NVIDIA started talking about this recently, I asked
> them to enumerate all the boards we have that support pluggable
> components, and how common it is that some boards support being plugged
> into different main boards. I don't know when that enumeration will
> complete (or even start) but hopefully I can provide some feedback on
> how common the use-case is for us once it's done.
> 
> My earlier thoughts on how to support this included explicit
> inter-board/-component connector objects in the .dts files that allow
> "renaming" of GPIOs, I2C buses,

Re: [RFC v4+ hot_track 00/19] vfs: hot data tracking

2012-11-07 Thread Zhi Yong Wu
On Mon, Oct 29, 2012 at 12:30 PM,   wrote:
> From: Zhi Yong Wu 
>
> NOTE:
>
>   The patchset can be obtained via my kernel dev git on github:
> g...@github.com:wuzhy/kernel.git hot_tracking
>   If you're interested, you can also can review them via
> https://github.com/wuzhy/kernel/commits/hot_tracking
hi, guys,

The latest code change has been pushed into my above dev git tree. If
no further comments are done, i will post next version soon.

>
>   For more info, please check hot_tracking.txt in Documentation
>
> TODO List:
>
>  1.) Need to do scalability or performance tests.
>  2.) Need one simpler but effective temp calc'ing function
>  3.) How to save the file temperature among the umount to be able to
>  preserve the file tempreture after reboot
>
> Ben Chociej, Matt Lupfer and Conor Scott originally wrote this code to
>  be very btrfs-specific.  I've taken their code and attempted to
> make it more generic and integrate it at the VFS level.
>
> Changelog from v3:
>  1.) Rewritten debugfs support based seq_file operation. [Dave Chinner]
>  2.) Refactored workqueue support. [Dave Chinner]
>  3.) Turn some Micro into be tunable   [Zhiyong, Zheng Liu]
>TIME_TO_KICK, and HEAT_UPDATE_DELAY
>  4.) Introduce hot func registering framework [Zhiyong]
>  5.) Remove global variable for hot tracking [Zhiyong]
>  6.) Add xfs hot tracking support [Dave Chinner]
>  7.) Add ext4 hot tracking support [Zheng Liu]
>  8.) Cleanedup a lot of other issues [Dave Chinner]
>
> v3:
>  1.) Converted to Radix trees, not RB-tree [Zhiyong, Dave Chinner]
>  2.) Added memory shrinker [Dave Chinner]
>
> v2:
>  1.) Converted to one workqueue to update map info periodically [Dave Chinner]
>  2.) Cleanedup a lot of other issues [Dave Chinner]
>
> v1:
>  1.) Reduce new files and put all in fs/hot_tracking.[ch] [Dave Chinner]
>  2.) Add btrfs hot tracking support [Zhiyong]
>  3.) The first three patches can probably just be flattened into one.
> [Marco Stornelli , Dave Chinner]
>
> Dave Chinner (1):
>   xfs: add hot tracking support
>
> Zheng Liu (1):
>   ext4: add hot tracking support
>
> Zhi Yong Wu (17):
>   vfs: introduce private radix tree structures
>   vfs: initialize and free data structures
>   vfs: add I/O frequency update function
>   vfs: add two map arrays
>   vfs: add hooks to enable hot tracking
>   vfs: add temp calculation function
>   vfs: add map info update function
>   vfs: add aging function
>   vfs: add one work queue
>   vfs: introduce hot func register framework
>   vfs: register one shrinker
>   vfs: add one ioctl interface
>   debugfs: introduce one function
>   vfs: add debugfs support
>   sysfs: add two hot_track proc files
>   btrfs: add hot tracking support
>   vfs: add documentation
>
>  Documentation/filesystems/00-INDEX |2 +
>  Documentation/filesystems/hot_tracking.txt |  262 ++
>  fs/Makefile|2 +-
>  fs/btrfs/ctree.h   |1 +
>  fs/btrfs/super.c   |   22 +-
>  fs/compat_ioctl.c  |5 +
>  fs/dcache.c|2 +
>  fs/debugfs/inode.c |   26 +
>  fs/direct-io.c |6 +
>  fs/ext4/ext4.h |3 +
>  fs/ext4/super.c|   13 +-
>  fs/hot_tracking.c  | 1367 
> 
>  fs/hot_tracking.h  |   58 ++
>  fs/ioctl.c |   78 ++
>  fs/xfs/xfs_mount.h |1 +
>  fs/xfs/xfs_super.c |   16 +
>  include/linux/debugfs.h|9 +
>  include/linux/fs.h |4 +
>  include/linux/hot_tracking.h   |  149 +++
>  kernel/sysctl.c|   14 +
>  mm/filemap.c   |6 +
>  mm/page-writeback.c|   12 +
>  mm/readahead.c |6 +
>  23 files changed, 2061 insertions(+), 3 deletions(-)
>  create mode 100644 Documentation/filesystems/hot_tracking.txt
>  create mode 100644 fs/hot_tracking.c
>  create mode 100644 fs/hot_tracking.h
>  create mode 100644 include/linux/hot_tracking.h
>
> --
> 1.7.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Regards,

Zhi Yong Wu
--
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 1/3] gpio / ACPI: add ACPI support

2012-11-07 Thread Mika Westerberg
On Tue, Nov 06, 2012 at 11:15:21AM +0100, Linus Walleij wrote:
> On Tue, Nov 6, 2012 at 10:39 AM, Mika Westerberg
>  wrote:
> > On Mon, Nov 05, 2012 at 03:40:14PM +0100, Linus Walleij wrote:
> >> > I forgot to mention that we want to hook up _existing_ drivers to those 
> >> > things,
> >> > and they already use the global GPIO numbers, don't they?
> >>
> >> Yes they do, usually this is either passed from the platform using platform
> >> data or handled by device tree lookups to individual drivers.
> >>
> >> So you will have to modify each such existing driver to do ACPI
> >> probe akin to the DT codepath and call acpi_get_gpio() on every pin they
> >> need going forward. But that is the plan I guess.
> >
> > Yes, that's the plan.
> >
> > Do you think it is OK to go with this implementation (acpi_get_gpio()) for
> > now? We will try to make sure that the gpio_get() (or whatever it will be
> > called that time) supports ACPI as well.
> 
> Yes I'll be OK with it but I don't dare to merge it unless Grant
> ACKs it.

Is that an Ack from you? ;-)

Since there is a dependency to linux-pm tree (we use the new
dev->acpi_handle member) I would like this series merged via that tree.

Grant, are you OK with this?
--
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 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu

On 11/06/2012 05:01 PM, Mark Brown wrote:

On Tue, Nov 06, 2012 at 03:44:52PM +0800, Qing Xu wrote:

From: Qing Xu 

Signed-off-by: Qing Xu 
---
  drivers/regulator/max8925-regulator.c |   35 -
  1 files changed, 34 insertions(+), 1 deletions(-)

There is no binding document here, documentation is required for all new
bindings.


+   nproot = of_find_node_by_name(nproot, "regulators");
+   if (!nproot) {
+   dev_err(&pdev->dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+   for_each_child_of_node(nproot, np) {
+   if (!of_node_cmp(np->name, info->desc.name)) {
+   config->init_data =
+   of_get_regulator_init_data(&pdev->dev, np);
+   config->of_node = np;
+   break;
+   }
+   }

You appear to be open coding something like the standard helpers in
of_regulator.h, you should use those helpers.
Mark, thanks for your so quick response! I updated the patch in v2, 
please help me review it again.

--
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: tools, perf: Fix up for x86 UAPI disintegration

2012-11-07 Thread Namhyung Kim
Hi David,

On Mon, 05 Nov 2012 23:18:27 +, David Howells wrote:
> David Howells  wrote:
>
>> David Howells  wrote:
>> 
>> > I've posted a revised version of my perf patches to my UAPI disintegration
>> > GIT tree.
>> 
>> Hmmm...  It seems to break some things according to Fengguang's kbuild test
>> robot.
>
> Okay.  I've fixed that.  Revised stuff pushed to the GIT tree.

I've tested your branch and it seems that it conflicts with Jiri's
latest perf test patchset which merged into Arnaldo's perf/core branch.

Simple fix will be adding '-Iutil -I.' right after '-I$(OUTPUT)util' in
BASIC_CFLAGS.

Thanks,
Namhyung
--
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 v6 25/29] memcg/sl[au]b: shrink dead caches

2012-11-07 Thread Glauber Costa
On 11/07/2012 08:16 AM, Andrew Morton wrote:
> On Wed, 7 Nov 2012 08:13:08 +0100 Glauber Costa  wrote:
> 
>> On 11/06/2012 01:48 AM, Andrew Morton wrote:
>>> On Thu,  1 Nov 2012 16:07:41 +0400
>>> Glauber Costa  wrote:
>>>
 This means that when we destroy a memcg cache that happened to be empty,
 those caches may take a lot of time to go away: removing the memcg
 reference won't destroy them - because there are pending references, and
 the empty pages will stay there, until a shrinker is called upon for any
 reason.

 In this patch, we will call kmem_cache_shrink for all dead caches that
 cannot be destroyed because of remaining pages. After shrinking, it is
 possible that it could be freed. If this is not the case, we'll schedule
 a lazy worker to keep trying.
>>>
>>> This patch is really quite nasty.  We poll the cache once per minute
>>> trying to shrink then free it?  a) it gives rise to concerns that there
>>> will be scenarios where the system could suffer unlimited memory windup
>>> but mainly b) it's just lame.
>>>
>>> The kernel doesn't do this sort of thing.  The kernel tries to be
>>> precise: in a situation like this we keep track of the number of
>>> outstanding objects and when that falls to zero, we free their
>>> container synchronously.  If those objects are normally left floating
>>> around in an allocated but reclaimable state then we can address that
>>> by synchronously freeing them if their container has been destroyed.
>>>
>>> Or something like that.  If it's something else then fine, but not this.
>>>
>>> What do we need to do to fix this?
>>>
>> The original patch had a unlikely() test in the free path, conditional
>> on whether or not the cache is dead, that would then call this is the
>> cache would now be empty.
>>
>> I got several requests to remove it and change it to something like
>> this, because that is a fast path (I myself think an unlikely branch is
>> not that bad)
>>
>> If you think such a test is acceptable, I can bring it back and argue in
>> the basis of "akpm made me do it!". But meanwhile I will give this extra
>> though to see if there is any alternative way I can do it...
> 
> OK, thanks, please do take a look at it.
> 
> I'd be interested in seeing the old version of the patch which had this
> test-n-branch.  Perhaps there's some trick we can pull to lessen its cost.
> 
Attached.

This is the last version that used it (well, I believe it is). There is
other unrelated things in this patch, that I got rid of. Look for
kmem_cache_verify_dead().

In a summary, all calls to the free function would as a last step do:
kmem_cache_verify_dead() that would either be an empty placeholder, or:

+static inline void kmem_cache_verify_dead(struct kmem_cache *s)
+{
+   if (unlikely(s->memcg_params.dead))
+   schedule_work(&s->memcg_params.cache_shrinker);
+}


cache_shrinker got changed to the destroy worker. So if we are freeing
an object from a cache that is dead, we try to schedule a worker that
will eventually call kmem_cache_srhink(), and hopefully
kmem_cache_destroy() - if last object.

>From c99404a760fa69e8ccda0ff4b2636c6abd1ac990 Mon Sep 17 00:00:00 2001
From: Glauber Costa 
Date: Thu, 3 May 2012 13:33:03 -0300
Subject: [PATCH v3 15/16] memcg/sl[au]b: shrink dead caches

In the slub allocator, when the last object of a page goes away, we
don't necessarily free it - there is not necessarily a test for empty
page in any slab_free path.

This means that when we destroy a memcg cache that happened to be empty,
those caches may take a lot of time to go away: removing the memcg
reference won't destroy them - because there are pending references, and
the empty pages will stay there, until a shrinker is called upon for any
reason.

This patch marks all memcg caches as dead. kmem_cache_shrink is called
for the ones who are not yet dead - this will force internal cache
reorganization, and then all references to empty pages will be removed.

An unlikely branch is used to make sure this case does not affect
performance in the usual slab_free path.

The slab allocator has a time based reaper that would eventually get rid
of the objects, but we can also call it explicitly, since dead caches
are not a likely event.

[ v2: also call verify_dead for the slab ]

Signed-off-by: Glauber Costa 
CC: Christoph Lameter 
CC: Pekka Enberg 
CC: Michal Hocko 
CC: Kamezawa Hiroyuki 
CC: Johannes Weiner 
CC: Suleiman Souhlal 
---
 include/linux/slab.h |  3 +++
 mm/memcontrol.c  | 44 +++-
 mm/slab.c|  2 ++
 mm/slab.h| 10 ++
 mm/slub.c|  1 +
 5 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 9badb8c..765e12c 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -182,6 +182,8 @@ unsigned int kmem_cache_size(struct kmem_cache *);
 #endif
 
 #ifdef CONFIG_MEMCG_KMEM
+#include 
+
 struct m

Re: [PATCH v2 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Mark Brown
On Wed, Nov 07, 2012 at 04:41:50PM +0800, Qing Xu wrote:
> From: Qing Xu 
> 
> Signed-off-by: Qing Xu 

Applied, thanks - I'm assuming that the documentation for this binding
is in the core MFD patch along with the bindings for the core?  It's
mandatory to have binding documentation for new bindings.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] leds/tca6507: Add support for devicetree.

2012-11-07 Thread Jingoo Han
On Wednesday, November 07, 2012 3:25 AM Bryan Wu wrote
> 
> On Tue, Oct 30, 2012 at 2:45 PM, Marek Belisko
>  wrote:
> > Support added only for leds (not for gpio's).
> >
> > Signed-off-by: Marek Belisko 
> > ---
> >  drivers/leds/leds-tca6507.c |   73 
> > +--
> >  1 file changed, 70 insertions(+), 3 deletions(-)
> >
> 
> Overall, this looks good to me. Maybe some question as below,
> 
> -Bryan
> 
> > diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
> > index dabcf7a..496dd98 100644
> > --- a/drivers/leds/leds-tca6507.c
> > +++ b/drivers/leds/leds-tca6507.c
> > @@ -667,6 +667,69 @@ static void tca6507_remove_gpio(struct tca6507_chip 
> > *tca)
> >  }
> >  #endif /* CONFIG_GPIOLIB */
> >
> > +#ifdef CONFIG_OF
> > +static struct tca6507_platform_data * __devinit tca6507_led_dt_init(struct 
> > i2c_client *client)
> > +{
> > +   struct device_node *np = client->dev.of_node, *child;
> > +   struct tca6507_platform_data *pdata;
> > +   struct led_info *tca_leds;
> > +   int count = 0;
> > +
> > +   for_each_child_of_node(np, child)
> > +   count++;
> > +   if (!count)
> > +   return NULL;
> > +
> 
> I saw many 'return NULL' here, why not return some error code in ERR_PTR?
> 
> > +   if (count > NUM_LEDS)
> > +   return NULL;
> > +
> > +   tca_leds = devm_kzalloc(&client->dev, sizeof(struct led_info) * 
> > NUM_LEDS, GFP_KERNEL);
> > +
> 
> useless empty line.
> 
> > +   if (!tca_leds)
> > +   return NULL;
> > +
> > +
> 
> useless empty line.
> 
> > +   for_each_child_of_node(np, child) {
> > +   struct led_info led;
> > +   u32 reg;
> > +   int ret;
> > +
> > +   led.name = of_get_property(child, "label", NULL) ? : 
> > child->name;
> > +   led.default_trigger =
> > +   of_get_property(child, "linux,default-trigger", 
> > NULL);
> > +
> > +   ret = of_property_read_u32(child, "reg", ®);
> > +
> > +   if (ret != 0)
> > +   continue;
> > +   tca_leds[reg] = led;
> > +   }
> > +   pdata = devm_kzalloc(&client->dev, sizeof(struct 
> > tca6507_platform_data), GFP_KERNEL);
> > +   if (!pdata) {
> > +   kfree(tca_leds);
> 
> Do we need to kfree here? I think devm_zalloc() will take care of this
> if the driver failed to register.

If devm_kzalloc() fails, tca6507_probe() will return '-ENODEV'.
In this case, kfree() is unnecessary in this case, when devm_kzalloc()
is used.

Moreover, even if kfree() is necessary, devm_kfree() should be used
instead of kfree().

Marek Belisko, please refer to this document.
: http://www.kernel.org/doc/htmldocs/device-drivers/API-devm-kzalloc.html

Thank you.


Best regards,
Jingoo Han


> 
> > +   return NULL;
> > +   }
> > +
> > +   pdata->leds.leds = tca_leds;
> > +   pdata->leds.num_leds = NUM_LEDS;
> > +
> > +   return pdata;
> > +}
> > +
> > +static const struct of_device_id of_tca6507_leds_match[] = {
> > +   { .compatible = "leds-tca6507", },
> > +   {},
> > +};
> > +
> > +#else
> > +static int __devinit tca6507_led_dt_init(struct i2c_client *client, struct 
> > tca6507_platform_data
> *data)
> > +{
> > +   return -1;
> > +}
> > +
> > +#define of_tca6507_leds_match NULL
> > +#endif
> > +
> >  static int __devinit tca6507_probe(struct i2c_client *client,
> >const struct i2c_device_id *id)
> >  {
> > @@ -683,9 +746,12 @@ static int __devinit tca6507_probe(struct i2c_client 
> > *client,
> > return -EIO;
> >
> > if (!pdata || pdata->leds.num_leds != NUM_LEDS) {
> > -   dev_err(&client->dev, "Need %d entries in platform-data 
> > list\n",
> > -   NUM_LEDS);
> > -   return -ENODEV;
> > +   pdata = tca6507_led_dt_init(client);
> > +   if (!pdata) {
> > +   dev_err(&client->dev, "Need %d entries in 
> > platform-data list\n",
> > +   NUM_LEDS);
> > +   return -ENODEV;
> > +   }
> > }
> > tca = devm_kzalloc(&client->dev, sizeof(*tca), GFP_KERNEL);
> > if (!tca)
> > @@ -750,6 +816,7 @@ static struct i2c_driver tca6507_driver = {
> > .driver   = {
> > .name= "leds-tca6507",
> > .owner   = THIS_MODULE,
> > +   .of_match_table = of_tca6507_leds_match,
> > },
> > .probe= tca6507_probe,
> > .remove   = __devexit_p(tca6507_remove),
> > --
> > 1.7.9.5
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body o

Re: + binfmt_elfc-use-get_random_int-to-fix-entropy-depleting.patch added to -mm tree

2012-11-07 Thread Theodore Ts'o
On Tue, Nov 06, 2012 at 05:11:17PM -0800, Kees Cook wrote:
> Hrm, I don't like this. get_random_int() specifically says: "Get a
> random word for internal kernel use only." The intent of AT_RANDOM is
> for userspace pRNG seeding (though glibc currently uses it directly
> for stack protector and pointer mangling), which is not "internal
> kernel use only". :) Though I suppose this is already being used for
> the randomize_stack_top(), but I think it'd still be better to use
> higher quality bits.

Well, in practice, right now, get_random_int() is only being used for
different cases of ASLR of one variety or another (either by the
kernel in exec or mmap, or in userspace).  So I'm not sure it really
is a major issue.  

If we also change get_random_int() to use a more secure cryptographic
random generator (i.e., maybe AES instead of MD5), would that be
sufficient to address your concerns?  We're not using get_random_int()
for anything that's timing sensitive, so that shouldn't be a problem.

Or maybe we should just add an explicit CRNG set of routines (like the
similar discussions to make an explicitly named PRNG set of routines),
so callers can use whatever random number generator is appropriate for
their performance and security needs.

- Ted
--
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 V2 3/3] checkpatch: Emit an warning when floating point values are used

2012-11-07 Thread Andy Whitcroft
On Tue, Nov 06, 2012 at 03:36:25PM -0800, Andrew Morton wrote:
> On Thu,  1 Nov 2012 00:12:18 -0700
> Joe Perches  wrote:
> 
> > Linux kernel doesn't like floating point, say so.
> > 
> > ...
> >
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2332,6 +2332,13 @@ sub process {
> >  "do not add new typedefs\n" . $herecurr);
> > }
> >  
> > +# check for floating point constants
> > +
> > +   if ($line =~ /\b$Float\b/) {
> > +   WARN("KERNEL_FLOAT",
> > +"Floating point is not supported in linux kernel 
> > source\n" . $herecurr);
> > +   }
> > +
> >  # * goes on variable not on type
> > # (char*[ const])
> > while ($line =~ 
> > m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
> 
> The earlier review comments were not addressed.
> 
> In particular, I don't see a problem with people doing
> 
>   int foo = 1.1 * 2.2;

I thought there was also now a way to enable floats in kernel space and
some use thereof.

-apw
--
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: Need assistance fixing a tg3 driver side-effect on IPMI

2012-11-07 Thread 王金浦
2012/11/7 Steffen Grunewald :
> Hi everyone,
>
> I've been running into a problem while installing Debian Wheezy on a bunch
> of 6-year old machines which have been running Squeeze happily for years.
>
> They are SuperMicro-based (H8SSL opteron board), with two BCM95704A6 (Tigon3)
> interfaces, and a BMC/IPMI card (SuperMicro 1U) which shares eth0.
>
> With a 2.6.32 kernel (and the 3.102 version of the tg3 driver) everything is 
> fine.
>
> With Debian's 3.2 (and tg3 3.121) I lose access to the IPMI LAN (or LANplus)
> interface as soon as the tg3 module has been loaded. Even shutting down 
> doesn't
> give the interface back - I've got to pull the power plug.
>
> Trying to git bisect the corresponding changes to the tg3 driver, I'm running
> against a wall at the point where the source code has been moved to another
> subtree back in 2011 (still a long time past Squeeze). I appear to be unable
> to go back beyond that.
>
> Can you advise how to find out when IPMI access got lost, and how to re-enable
> it? Any suggestion is appreciated.
> I suppose it wouldn't be as easy as "get the old source from 2.6.32, and plug
> it into drivers/net/ethernet/broadcom, then rebuild the kernel" -?
>
> Please keep me on CC, thanks.
>
> Regards,
>  Steffen
> --
Ferenc met samilar problem :

"Michael Chan"  writes:

> On Tue, 2012-10-02 at 18:49 +0200, Ferenc Wagner wrote:
>
>> Going into the opposite direction: I found that Linux 3.6 does not
>> permanently break the SoL console on upping eth0!  I'll try to find
>> the commit which (sort of) fixed it.
>
> These are the likely fixes:
>
> commit cf9ecf4b631f649a964fa611f1a5e8874f2a76db
> Author: Matt Carlson 
> Date: Mon Nov 28 09:41:03 2011 +
>
> tg3: Fix TSO CAP for 5704 devs w / ASF enabled

You are exactly right: cf9ecf4b fixed the premanent SoL breakage
introduced by dabc5c67.  Looks like ASF utilizes similar technology to
that of the HS20 BMC.  Thanks for the tip, it greatly reduced our CPU
wear. :)  It's a pity ethtool -k did not give a hint.  Do you think it's
possible to work around in 3.2 by eg. fiddling some ethtool setting?

the fix already go into Precise update to 3.2.31 stable release

So update your kernel should fix your problem.

Jack
--
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 v3 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu
From: Qing Xu 

Signed-off-by: Qing Xu 
---
 .../bindings/regulator/max8925-regulator.txt   |   29 
 drivers/regulator/max8925-regulator.c  |   72 +++-
 2 files changed, 98 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/max8925-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/max8925-regulator.txt 
b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
new file mode 100644
index 000..073b41d
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
@@ -0,0 +1,29 @@
+Max8925 Voltage regulators
+
+max8925 regulator device register is still handled by mfd_add_devices, not by
+of_xxx, so, it is not necessary to add compatible name. Also, those reg
+offset and id info is stored in mfd_cell(see max8925-core.c), as a result
+there is not private properties in dts.
+
+node's name should match with the definition in max8925_regulator_matches
+(see max8925-regulator.c)
+
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+
+Example:
+
+
+   regulators {
+   SDV1 {
+   regulator-min-microvolt = <637500>;
+   regulator-max-microvolt = <1425000>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   ...
+   ...
+   }
diff --git a/drivers/regulator/max8925-regulator.c 
b/drivers/regulator/max8925-regulator.c
index 9bb0be3..5e84921 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define SD1_DVM_VMIN   85
 #define SD1_DVM_VMAX   100
@@ -187,6 +189,34 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.enable_reg = MAX8925_LDOCTL##_id,  \
 }
 
+#ifdef CONFIG_OF
+static struct of_regulator_match max8925_regulator_matches[] = {
+   { .name = "SDV1",},
+   { .name = "SDV2",},
+   { .name = "SDV3",},
+   { .name = "LDO1",},
+   { .name = "LDO2",},
+   { .name = "LDO3",},
+   { .name = "LDO4",},
+   { .name = "LDO5",},
+   { .name = "LDO6",},
+   { .name = "LDO7",},
+   { .name = "LDO8",},
+   { .name = "LDO9",},
+   { .name = "LDO10",},
+   { .name = "LDO11",},
+   { .name = "LDO12",},
+   { .name = "LDO13",},
+   { .name = "LDO14",},
+   { .name = "LDO15",},
+   { .name = "LDO16",},
+   { .name = "LDO17",},
+   { .name = "LDO18",},
+   { .name = "LDO19",},
+   { .name = "LDO20",},
+};
+#endif
+
 static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_SDV(1, 637.5, 1425, 12.5),
MAX8925_SDV(2,   650, 2225,   25),
@@ -214,6 +244,36 @@ static struct max8925_regulator_info 
max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
 };
 
+#ifdef CONFIG_OF
+static int max8925_regulator_dt_init(struct platform_device *pdev,
+   struct max8925_regulator_info *info,
+   struct regulator_config *config,
+   int ridx)
+{
+   struct device_node *nproot, *np;
+   int rcount;
+   nproot = pdev->dev.parent->of_node;
+   if (!nproot)
+   return -ENODEV;
+   np = of_find_node_by_name(nproot, "regulators");
+   if (!np) {
+   dev_err(&pdev->dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+
+   rcount = of_regulator_match(&pdev->dev, np,
+   &max8925_regulator_matches[ridx], 1);
+   if (rcount < 0)
+   return -ENODEV;
+   config->init_data = max8925_regulator_matches[ridx].init_data;
+   config->of_node = max8925_regulator_matches[ridx].of_node;
+
+   return 0;
+}
+#else
+#define max8925_regulator_dt_init(x, y, z) (-1)
+#endif
+
 static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -222,7 +282,7 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
struct max8925_regulator_info *ri;
struct resource *res;
struct regulator_dev *rdev;
-   int i;
+   int i, regulator_idx;
 
res = platform_get_resource(pdev, IORESOURCE_REG, 0);
if (!res) {
@@ -231,9 +291,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
}
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
-   if (ri->vol_reg == res->start)
+   if (ri->vol_reg == res->start) {
+   regulator_idx = i;
break;
+   }
}
+
if (i == ARRAY_SIZE(max8

[RFC PATCH v1 02/31] ARC: irqflags

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h  |  114 +++
 arch/arc/include/asm/irqflags.h |  143 +++
 arch/arc/kernel/irq.c   |   32 +
 3 files changed, 289 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/arcregs.h
 create mode 100644 arch/arc/include/asm/irqflags.h
 create mode 100644 arch/arc/kernel/irq.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
new file mode 100644
index 000..8ca8faf
--- /dev/null
+++ b/arch/arc/include/asm/arcregs.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_ARCREGS_H
+#define _ASM_ARC_ARCREGS_H
+
+#ifdef __KERNEL__
+
+/* status32 Bits Positions */
+#define STATUS_H_BIT   0   /* CPU Halted */
+#define STATUS_E1_BIT  1   /* Int 1 enable */
+#define STATUS_E2_BIT  2   /* Int 2 enable */
+#define STATUS_A1_BIT  3   /* Int 1 active */
+#define STATUS_A2_BIT  4   /* Int 2 active */
+#define STATUS_AE_BIT  5   /* Exception active */
+#define STATUS_DE_BIT  6   /* PC is in delay slot */
+#define STATUS_U_BIT   7   /* User/Kernel mode */
+#define STATUS_L_BIT   12  /* Loop inhibit */
+
+/* These masks correspond to the status word(STATUS_32) bits */
+#define STATUS_H_MASK  (1<
+
+#ifndef __ASSEMBLY__
+
+/**
+ * IRQ Control Macros
+ **/
+
+/*
+ * Save IRQ state and disable IRQs
+ */
+static inline long arch_local_irq_save(void)
+{
+   unsigned long temp, flags;
+
+   __asm__ __volatile__(
+   "   lr  %1, [status32]  \n"
+   "   bic %0, %1, %2  \n"
+   "   and.f 0, %1, %2 \n"
+   "   flag.nz %0  \n"
+   : "=r"(temp), "=r"(flags)
+   : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
+   : "cc");
+
+   return flags;
+}
+
+/*
+ * restore saved IRQ state
+ */
+static inline void arch_local_irq_restore(unsigned long flags)
+{
+
+   __asm__ __volatile__(
+   "   flag %0 \n"
+   :
+   : "r"(flags));
+}
+
+/*
+ * Conditionally Enable IRQs
+ */
+extern void arch_local_irq_enable(void);
+
+/*
+ * Unconditionally Disable IRQs
+ */
+static inline void arch_local_irq_disable(void)
+{
+   unsigned long temp;
+
+   __asm__ __volatile__(
+   "   lr  %0, [status32]  \n"
+   "   and %0, %0, %1  \n"
+   "   flag %0 \n"
+   : "=&r"(temp)
+   : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK)));
+}
+
+/*
+ * save IRQ state
+ */
+static inline long arch_local_save_flags(void)
+{
+   unsigned long temp;
+
+   __asm__ __volatile__(
+   "   lr  %0, [status32]  \n"
+   : "=&r"(temp));
+
+   return temp;
+}
+
+/*
+ * Query IRQ state
+ */
+static inline int arch_irqs_disabled_flags(unsigned long flags)
+{
+   return !(flags & (STATUS_E1_MASK));
+}
+
+static inline int arch_irqs_disabled(void)
+{
+   return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
+static inline void arch_mask_irq(unsigned int irq)
+{
+   unsigned int ienb;
+
+   ienb = read_aux_reg(AUX_IENABLE);
+   ienb &= ~(1 << irq);
+   write_aux_reg(AUX_IENABLE, ienb);
+}
+
+static inline void arch_unmask_irq(unsigned int irq)
+{
+   unsigned int ienb;
+
+   ienb = read_aux_reg(AUX_IENABLE);
+   ienb |= (1 << irq);
+   write_aux_reg(AUX_IENABLE, ienb);
+}
+
+#else
+
+.macro IRQ_DISABLE  scratch
+   lr  \scratch, [status32]
+   bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
+   flag\scratch
+.endm
+
+.macro IRQ_DISABLE_SAVE  scratch, save
+   lr  \scratch, [status32]
+   mov \save, \scratch /* Make a copy */
+   bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
+   flag\scratch
+.endm
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* KERNEL */
+
+#endif
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
new file mode 100644
index 000..16fcbe8
--- /dev/null
+++ b/arch/arc/kernel/irq.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-12 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+void arch_local_irq_enable(void)
+{
+
+   unsigned long flags;
+   flags = arch_local_save_flags();
+   flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
+

[RFC PATCH v1 04/31] asm-generic headers: uaccess.h to conditionally define segment_eq()

2012-11-07 Thread Vineet Gupta
This is because mm_segment_t is exported by arch code, while seqment_eq
assumes it will have .seg element.

Acked-by: Arnd Bergmann 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/uaccess.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 9788568..5f6ee61 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -7,7 +7,6 @@
  * address space, e.g. all NOMMU machines.
  */
 #include 
-#include 
 #include 
 
 #include 
@@ -32,7 +31,9 @@ static inline void set_fs(mm_segment_t fs)
 }
 #endif
 
+#ifndef segment_eq
 #define segment_eq(a, b) ((a).seg == (b).seg)
+#endif
 
 #define VERIFY_READ0
 #define VERIFY_WRITE   1
-- 
1.7.4.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/


[RFC PATCH v1 07/31] ARC: checksum/byteorder/swab routines

2012-11-07 Thread Vineet Gupta
TBD: do_csum still needs to be written in asm

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/byteorder.h |   18 +++
 arch/arc/include/asm/checksum.h  |  101 ++
 arch/arc/include/asm/swab.h  |   99 +
 3 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/byteorder.h
 create mode 100644 arch/arc/include/asm/checksum.h
 create mode 100644 arch/arc/include/asm/swab.h

diff --git a/arch/arc/include/asm/byteorder.h b/arch/arc/include/asm/byteorder.h
new file mode 100644
index 000..9da71d4
--- /dev/null
+++ b/arch/arc/include/asm/byteorder.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_BYTEORDER_H
+#define __ASM_ARC_BYTEORDER_H
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#include 
+#else
+#include 
+#endif
+
+#endif /* ASM_ARC_BYTEORDER_H */
diff --git a/arch/arc/include/asm/checksum.h b/arch/arc/include/asm/checksum.h
new file mode 100644
index 000..1095729
--- /dev/null
+++ b/arch/arc/include/asm/checksum.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Joern Rennecke  : Jan 2012
+ *  -Insn Scheduling improvements to csum core routines.
+ *  = csum_fold( ) largely derived from ARM version.
+ *  = ip_fast_cum( ) to have module scheduling
+ *  -gcc 4.4.x broke networking. Alias analysis needed to be primed.
+ *   worked around by adding memory clobber to ip_fast_csum( )
+ *
+ * vineetg: May 2010
+ *  -Rewrote ip_fast_cscum( ) and csum_fold( ) with fast inline asm
+ */
+
+#ifndef _ASM_ARC_CHECKSUM_H
+#define _ASM_ARC_CHECKSUM_H
+
+/*
+ * Fold a partial checksum
+ *
+ *  The 2 swords comprising the 32bit sum are added, any carry to 16th bit
+ *  added back and final sword result inverted.
+ */
+static inline __sum16 csum_fold(__wsum s)
+{
+   unsigned r = s << 16 | s >> 16; /* ror */
+   s = ~s;
+   s -= r;
+   return s >> 16;
+}
+
+/*
+ * This is a version of ip_compute_csum() optimized for IP headers,
+ * which always checksum on 4 octet boundaries.
+ */
+static inline __sum16
+ip_fast_csum(const void *iph, unsigned int ihl)
+{
+   const void *ptr = iph;
+   unsigned int tmp, tmp2, sum;
+
+   __asm__(
+   "   ld.ab  %0, [%3, 4]  \n"
+   "   ld.ab  %2, [%3, 4]  \n"
+   "   sub%1, %4, 2\n"
+   "   lsr.f  lp_count, %1, 1  \n"
+   "   bcc0f   \n"
+   "   add.f  %0, %0, %2   \n"
+   "   ld.ab  %2, [%3, 4]  \n"
+   "0: lp 1f   \n"
+   "   ld.ab  %1, [%3, 4]  \n"
+   "   adc.f  %0, %0, %2   \n"
+   "   ld.ab  %2, [%3, 4]  \n"
+   "   adc.f  %0, %0, %1   \n"
+   "1: adc.f  %0, %0, %2   \n"
+   "   add.cs %0,%0,1  \n"
+   : "=&r"(sum), "=r"(tmp), "=&r"(tmp2), "+&r" (ptr)
+   : "r"(ihl)
+   : "cc", "lp_count", "memory");
+
+   return csum_fold(sum);
+}
+
+/*
+ * TCP pseudo Header is 12 bytes:
+ * SA [4], DA [4], zeroes [1], Proto[1], TCP Seg(hdr+data) Len [2]
+ */
+static inline __wsum
+csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+  unsigned short proto, __wsum sum)
+{
+   __asm__ __volatile__(
+   "   add.f %0, %0, %1\n"
+   "   adc.f %0, %0, %2\n"
+   "   adc.f %0, %0, %3\n"
+   "   adc.f %0, %0, %4\n"
+   "   adc   %0, %0, 0 \n"
+   : "+&r"(sum)
+   : "r"(saddr), "r"(daddr),
+#ifdef CONFIG_CPU_BIG_ENDIAN
+ "r"(len),
+#else
+ "r"(len << 8),
+#endif
+ "r"(htons(proto))
+   : "cc");
+
+   return sum;
+}
+
+#define csum_fold csum_fold
+#define ip_fast_csum ip_fast_csum
+#define csum_tcpudp_nofold csum_tcpudp_nofold
+
+#include 
+
+#endif /* _ASM_ARC_CHECKSUM_H */
diff --git a/arch/arc/include/asm/swab.h b/arch/arc/include/asm/swab.h
new file mode 100644
index 000..9f6dcbb
--- /dev/null
+++ b/arch/arc/include/asm/swab.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: May 2011
+ *  -Support si

[RFC Patch v1 00/31] Synopsys ARC Linux kernel Port

2012-11-07 Thread Vineet Gupta
Hi,

This patchset based off-of 3.7-rc3, introduces the Linux kernel port to
ARC700 processor family (750D and 770D) from Synopsys.

ARC700 is highly configurable and power efficient 32-bit RISC core with MMU.
It is embedded in SoCs deployed in TV Set Top boxes, Digital Media Players,
all the way to Network-on-Chips.

More information is available @
http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/Pages/default.aspx

This series is part #1 of the entire port - just enough to build the kernel
and bring up a Busybox shell on console (on ARCAngel4 FPGA ref platform)
The console driver has already been accepted/merged into tty-next tree for 3.8

The part #2 series containing additional features ptrace/SMP/perf/OProfile..
will follow as we move along the review cycle. It has been withheld just to
make it easier for reviewers.

The entire series however is available at
git://github.com/foss-for-synopsys-dwc-arc-processors/linux.git arc-3.7-rc3

The GNU tool-chain, based off of gcc 4.4  + uClibc 0.9.30.3 is also available
from github. Please refer to Readme.md in "toolchain" repository also in same
hierarchy as kernel above.

We are already working on a buildroot based distro, to be made available soon.

More info about the kernel port can also be found in the ELCE-Barclone '12
talk on same topic.

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

P.S. Despite 3.7 based, we are still short of the UAPI split for arch headers.
That is also being worked upon with help from David. That will show up in v2
of the patchseries.

Thx,
-Vineet

Vineet Gupta (31):
  ARC: Generic Headers
  ARC: irqflags
  ARC: atomic/bitops/cmpxchg/barriers
  asm-generic headers: uaccess.h to conditionally define segment_eq()
  ARC: uaccess friends
  asm-generic headers: Allow yet more arch overrides in checksum.h
  ARC: checksum/byteorder/swab routines
  ARC: Fundamental ARCH data-types/defines
  ARC: spinlock/rwlock/mutex primitives
  ARC: string library
  ARC: Low level IRQ/Trap/Exception(non-MMU) Handling
  ARC: Interrupt Handling
  ARC: Non-MMU Exception Handling
  ARC: syscall support
  ARC: Process/scheduling/clock/Timers/Delay Management
  ARC: Signal handling
  ARC: Cache Flush Management
  ARC: Page Table Management
  ARC: MMU Context Management
  ARC: MMU Exception Handling
  ARC: TLB flush Handling
  ARC: Page Fault handling (incl uaccess fixup)
  ARC: I/O and DMA Mappings
  ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init
  ARC: [plat-arcfpga] Hooking up platform to ARC UART
  ARC: Build system: Makefiles, Kconfig, Linker script
  ARC: Last bits (stubs) to get to a running kernel with UART
  ARC: split ret_from_fork, simplify kernel_thread()
  ARC: switch to generic kernel_thread()
  ARC: switch to generic kernel_execve() and sys_execve()
  ARC: [plat-arcfpga] defconfig

 arch/arc/Kbuild   |2 +
 arch/arc/Kconfig  |  338 ++
 arch/arc/Kconfig.debug|   34 +
 arch/arc/Makefile |  115 
 arch/arc/boot/Makefile|   27 +
 arch/arc/configs/fpga_defconfig   |  607 ++
 arch/arc/include/asm/Kbuild   |   58 ++
 arch/arc/include/asm/arcregs.h|  330 ++
 arch/arc/include/asm/asm-offsets.h|9 +
 arch/arc/include/asm/atomic.h |  232 +++
 arch/arc/include/asm/barrier.h|   42 ++
 arch/arc/include/asm/bitops.h |  507 +++
 arch/arc/include/asm/bug.h|   37 ++
 arch/arc/include/asm/byteorder.h  |   18 +
 arch/arc/include/asm/cache.h  |   75 +++
 arch/arc/include/asm/cachectl.h   |   30 +
 arch/arc/include/asm/cacheflush.h |   67 ++
 arch/arc/include/asm/checksum.h   |  101 +++
 arch/arc/include/asm/cmpxchg.h|  143 +
 arch/arc/include/asm/delay.h  |   68 ++
 arch/arc/include/asm/dma-mapping.h|  176 ++
 arch/arc/include/asm/dma.h|   14 +
 arch/arc/include/asm/elf.h|   97 +++
 arch/arc/include/asm/entry.h  |  495 +++
 arch/arc/include/asm/exec.h   |   15 +
 arch/arc/include/asm/io.h |   26 +
 arch/arc/include/asm/irq.h|   26 +
 arch/arc/include/asm/irqflags.h   |  143 +
 arch/arc/include/asm/kdebug.h |   19 +
 arch/arc/include/asm/linkage.h|   30 +
 arch/arc/include/asm/mmu.h|   23 +
 arch/arc/include/asm/mmu_context.h|  209 ++
 arch/arc/include/asm/module.h |   17 +
 arch/arc/include/asm/mutex.h  |9 +
 arch/arc/include/asm/page.h   |  134 
 arch/arc/include/asm/pgalloc.h 

[RFC PATCH v1 09/31] ARC: spinlock/rwlock/mutex primitives

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/mutex.h  |9 ++
 arch/arc/include/asm/spinlock.h   |  144 +
 arch/arc/include/asm/spinlock_types.h |   35 
 3 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/mutex.h
 create mode 100644 arch/arc/include/asm/spinlock.h
 create mode 100644 arch/arc/include/asm/spinlock_types.h

diff --git a/arch/arc/include/asm/mutex.h b/arch/arc/include/asm/mutex.h
new file mode 100644
index 000..3be5e64
--- /dev/null
+++ b/arch/arc/include/asm/mutex.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
diff --git a/arch/arc/include/asm/spinlock.h b/arch/arc/include/asm/spinlock.h
new file mode 100644
index 000..f158197
--- /dev/null
+++ b/arch/arc/include/asm/spinlock.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_SPINLOCK_H
+#define __ASM_SPINLOCK_H
+
+#include 
+#include 
+#include 
+
+#define arch_spin_is_locked(x) ((x)->slock != __ARCH_SPIN_LOCK_UNLOCKED__)
+#define arch_spin_lock_flags(lock, flags)  arch_spin_lock(lock)
+#define arch_spin_unlock_wait(x) \
+   do { while (arch_spin_is_locked(x)) cpu_relax(); } while (0)
+
+static inline void arch_spin_lock(arch_spinlock_t *lock)
+{
+   unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__;
+
+   __asm__ __volatile__(
+   "1: ex  %0, [%1]\n"
+   "   breq  %0, %2, 1b\n"
+   : "+&r" (tmp)
+   : "r"(&(lock->slock)), "ir"(__ARCH_SPIN_LOCK_LOCKED__)
+   : "memory");
+}
+
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
+{
+   unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__;
+
+   __asm__ __volatile__(
+   "1: ex  %0, [%1]\n"
+   : "+r" (tmp)
+   : "r"(&(lock->slock))
+   : "memory");
+
+   return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__);
+}
+
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
+{
+   lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__;
+   smp_mb();
+}
+
+/*
+ * Read-write spinlocks, allowing multiple readers but only one writer.
+ *
+ * The spinlock itself is contained in @counter and access to it is
+ * serialized with @lock_mutex.
+ *
+ * Unfair locking as Writers could be starved indefinitely by Reader(s)
+ */
+
+/* Would read_trylock() succeed? */
+#define arch_read_can_lock(x)  ((x)->counter > 0)
+
+/* Would write_trylock() succeed? */
+#define arch_write_can_lock(x) ((x)->counter == __ARCH_RW_LOCK_UNLOCKED__)
+
+/* 1 - lock taken successfully */
+static inline int arch_read_trylock(arch_rwlock_t *rw)
+{
+   int ret = 0;
+
+   arch_spin_lock(&(rw->lock_mutex));
+
+   /*
+* zero means writer holds the lock exclusively, deny Reader.
+* Otherwise grant lock to first/subseq reader
+*/
+   if (rw->counter > 0) {
+   rw->counter--;
+   ret = 1;
+   }
+
+   arch_spin_unlock(&(rw->lock_mutex));
+
+   smp_mb();
+   return ret;
+}
+
+/* 1 - lock taken successfully */
+static inline int arch_write_trylock(arch_rwlock_t *rw)
+{
+   int ret = 0;
+
+   arch_spin_lock(&(rw->lock_mutex));
+
+   /*
+* If reader(s) hold lock (lock < __ARCH_RW_LOCK_UNLOCKED__),
+* deny writer. Otherwise if unlocked grant to writer
+* Hence the claim that Linux rwlocks are unfair to writers.
+* (can be starved for an indefinite time by readers).
+*/
+   if (rw->counter == __ARCH_RW_LOCK_UNLOCKED__) {
+   rw->counter = 0;
+   ret = 1;
+   }
+   arch_spin_unlock(&(rw->lock_mutex));
+
+   return ret;
+}
+
+static inline void arch_read_lock(arch_rwlock_t *rw)
+{
+   while (!arch_read_trylock(rw))
+   cpu_relax();
+}
+
+static inline void arch_write_lock(arch_rwlock_t *rw)
+{
+   while (!arch_write_trylock(rw))
+   cpu_relax();
+}
+
+static inline void arch_read_unlock(arch_rwlock_t *rw)
+{
+   arch_spin_lock(&(rw->lock_mutex));
+   rw->counter++;
+   arch_spin_unlock(&(rw->lock_mutex));
+}
+
+static inline void arch_write_unlock(arch_rwlock_t *rw)
+{
+   arch_spin_lock(&(rw->lock_mutex));
+   rw->counter = __ARCH_RW_LOCK_UNLOCKED__;
+   arch_spin_unlock(&(rw->lock_mutex));
+}
+
+#define arch_read_lock_flags(lock, flags)  arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
+
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(

[RFC PATCH v1 12/31] ARC: Interrupt Handling

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h |3 ++
 arch/arc/include/asm/hw_irq.h  |7 
 arch/arc/include/asm/irq.h |   25 +
 arch/arc/kernel/irq.c  |   79 +++-
 arch/arc/plat-arcfpga/irq.c|   41 +
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 arch/arc/include/asm/hw_irq.h
 create mode 100644 arch/arc/include/asm/irq.h
 create mode 100644 arch/arc/plat-arcfpga/irq.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 8ca8faf..3fccb04 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -11,6 +11,9 @@
 
 #ifdef __KERNEL__
 
+/* Build Configuration Registers */
+#define ARC_REG_VECBASE_BCR0x68
+
 /* status32 Bits Positions */
 #define STATUS_H_BIT   0   /* CPU Halted */
 #define STATUS_E1_BIT  1   /* Int 1 enable */
diff --git a/arch/arc/include/asm/hw_irq.h b/arch/arc/include/asm/hw_irq.h
new file mode 100644
index 000..fd565ab
--- /dev/null
+++ b/arch/arc/include/asm/hw_irq.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
diff --git a/arch/arc/include/asm/irq.h b/arch/arc/include/asm/irq.h
new file mode 100644
index 000..633416c
--- /dev/null
+++ b/arch/arc/include/asm/irq.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_IRQ_H
+#define __ASM_ARC_IRQ_H
+
+/* Platform Inependent IRQs */
+#define TIMER0_IRQ  3
+#define TIMER1_IRQ  4
+
+#include 
+
+extern void __init arc_init_IRQ(void);
+extern void __init plat_init_IRQ(void);
+extern int __init get_hw_config_num_irq(void);
+
+void __cpuinit arc_clockevent_init(void);
+void __cpuinit arc_clock_counter_setup(void);
+
+#endif
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index 16fcbe8..03a125c 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -9,8 +9,83 @@
 
 #include 
 #include 
-#include 
-#include 
+#include 
+#include 
+
+/*
+ * Early Interrupt sub-system setup
+ * -Called very early (start_kernel -> setup_arch -> setup_processor)
+ * -Platform Independent (must for any ARC700)
+ * -Needed for each CPU (hence not foldable into init_IRQ)
+ *
+ * what it does ?
+ * -setup Vector Table Base Reg - in case Linux not linked at 0x8000_
+ * -Disable all IRQs (on CPU side)
+ */
+void __init arc_init_IRQ(void)
+{
+   int level_mask = level_mask;
+
+   write_aux_reg(AUX_INTR_VEC_BASE, _int_vec_base_lds);
+
+   /* Disable all IRQs: enable them as devices request */
+   write_aux_reg(AUX_IENABLE, 0);
+}
+
+/*
+ * Late Interrupt system init called from start_kernel for Boot CPU only
+ *
+ * Since slab must already be initialized, platforms can start doing any
+ * needed request_irq( )s
+ */
+void __init init_IRQ(void)
+{
+   const int irq = TIMER0_IRQ;
+
+   /*
+* Each CPU needs to register irq of it's private TIMER0.
+* The APIs request_percpu_irq()/enable_percpu_irq() will not be
+* functional, if we don't "prep" the generic IRQ sub-system with
+* the following:
+* -Ensure that devid passed to request_percpu_irq() is indeed per cpu
+* -disable NOAUTOEN, w/o which the device handler never gets called
+*/
+   irq_set_percpu_devid(irq);
+   irq_modify_status(irq, IRQ_NOAUTOEN, 0);
+
+   plat_init_IRQ();
+}
+
+/*
+ * "C" Entry point for any ARC ISR, called from low level vector handler
+ */
+void arch_do_IRQ(unsigned int irq, struct pt_regs *regs)
+{
+   struct pt_regs *old_regs = set_irq_regs(regs);
+
+   irq_enter();
+   generic_handle_irq(irq);
+   irq_exit();
+   set_irq_regs(old_regs);
+}
+
+int __init get_hw_config_num_irq(void)
+{
+   uint32_t val = read_aux_reg(ARC_REG_VECBASE_BCR);
+
+   switch (val & 0x03) {
+   case 0:
+   return 16;
+   case 1:
+   return 32;
+   case 2:
+   return 8;
+   default:
+   return 0;
+   }
+
+   return 0;
+}
 
 void arch_local_irq_enable(void)
 {
diff --git a/arch/arc/plat-arcfpga/irq.c b/arch/arc/plat-arcfpga/irq.c
new file mode 100644
index 000..a308057
--- /dev/null
+++ b/arch/arc/plat-arcfpga/irq.c
@@ -0,0 +1,41 @@
+/*
+ * ARC FPGA Platform IRQ hookups
+ *
+ * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License vers

[RFC PATCH v1 17/31] ARC: Cache Flush Management

2012-11-07 Thread Vineet Gupta
* ARC700 has VIPT L1 Caches (L1 only)
* Caches don't snoop and are not coherent
* Given the PAGE_SIZE and Cache associativity, we don't support aliasing
  D$ configurations, but so allow aliasing I$ configs

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h|   80 
 arch/arc/include/asm/cache.h  |   54 +++
 arch/arc/include/asm/cachectl.h   |   30 ++
 arch/arc/include/asm/cacheflush.h |   67 +++
 arch/arc/mm/cache_arc700.c|  838 +
 5 files changed, 1069 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/cachectl.h
 create mode 100644 arch/arc/include/asm/cacheflush.h
 create mode 100644 arch/arc/mm/cache_arc700.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 5131bb3..c6e2805 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -58,6 +58,33 @@
 #define TIMER_CTRL_IE  (1 << 0) /* Interupt when Count reachs limit */
 #define TIMER_CTRL_NH  (1 << 1) /* Count only when CPU NOT halted */
 
+/* Instruction cache related Auxiliary registers */
+#define ARC_REG_IC_BCR 0x77/* Build Config reg */
+#define ARC_REG_IC_IVIC0x10
+#define ARC_REG_IC_CTRL0x11
+#define ARC_REG_IC_IVIL0x19
+#if (CONFIG_ARC_MMU_VER > 2)
+#define ARC_REG_IC_PTAG0x1E
+#endif
+
+/* Bit val in IC_CTRL */
+#define IC_CTRL_CACHE_DISABLE   0x1
+
+/* Data cache related Auxiliary registers */
+#define ARC_REG_DC_BCR 0x72
+#define ARC_REG_DC_IVDC0x47
+#define ARC_REG_DC_CTRL0x48
+#define ARC_REG_DC_IVDL0x4A
+#define ARC_REG_DC_FLSH0x4B
+#define ARC_REG_DC_FLDL0x4C
+#if (CONFIG_ARC_MMU_VER > 2)
+#define ARC_REG_DC_PTAG0x5C
+#endif
+
+/* Bit val in DC_CTRL */
+#define DC_CTRL_INV_MODE_FLUSH  0x40
+#define DC_CTRL_FLUSH_STATUS0x100
+
 /*
  * Floating Pt Registers
  * Status regs are read-only (build-time) so need not be saved/restored
@@ -132,6 +159,31 @@
 
 #endif
 
+#define READ_BCR(reg, into)\
+{  \
+   unsigned int tmp;   \
+   tmp = read_aux_reg(reg);\
+   if (sizeof(tmp) == sizeof(into)) {  \
+   into = *((typeof(into) *)&tmp); \
+   } else {\
+   extern void bogus_undefined(void);  \
+   bogus_undefined();  \
+   }   \
+}
+
+#define WRITE_BCR(reg, into)   \
+{  \
+   unsigned int tmp;   \
+   if (sizeof(tmp) == sizeof(into)) {  \
+   tmp = (*(unsigned int *)(into));\
+   write_aux_reg(reg, tmp);\
+   } else  {   \
+   extern void bogus_undefined(void);  \
+   bogus_undefined();  \
+   }   \
+}
+
+
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
 /* These DPFP regs need to be saved/restored across ctx-sw */
 struct arc_fpu {
@@ -141,6 +193,34 @@ struct arc_fpu {
 };
 #endif
 
+/*
+ ***
+ * Build Configuration Registers, with encoded hardware config
+ */
+
+struct bcr_cache {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+   unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
+#else
+   unsigned int ver:8, config:4, sz:4, line_len:4, pad:12;
+#endif
+};
+
+/*
+ ***
+ * Generic structures to hold build configuration used at runtime
+ */
+
+struct cpuinfo_arc_cache {
+   unsigned int has_aliasing, sz, line_len, assoc, ver;
+};
+
+struct cpuinfo_arc {
+   struct cpuinfo_arc_cache icache, dcache;
+};
+
+extern struct cpuinfo_arc cpuinfo_arc700[];
+
 #endif /* __ASEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index 30c72a4..6632273 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -18,4 +18,58 @@
 
 #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
 
+#define ARC_ICACHE_WAYS2
+#define ARC_DCACHE_WAYS4
+
+/* Helpers */
+#define ARC_ICACHE_LINE_LENL1_CACHE_BYTES
+#define ARC_DCACHE_LINE_LENL1_CACHE_BYTES
+
+#define ICACHE_LINE_MASK   (~(ARC_ICACHE_LINE_LEN - 1))
+#define DCACHE_LINE_MASK   (~(ARC_DCACHE_LINE_LEN - 1))
+
+#if ARC_ICACHE_LINE_LEN != ARC_DCACHE_LINE_LEN
+#error "Need to fix some code as I/D cache lines not same"
+#else
+#define is_not_cache_aligned(p)((unsigned long)p & (~DCACHE_LINE_MASK))
+#endif
+
+#ifndef __ASSEMBLY__
+
+/* Un

[RFC PATCH v1 22/31] ARC: Page Fault handling (incl uaccess fixup)

2012-11-07 Thread Vineet Gupta
This includes recent changes to make handler "retry" and/or "killable"

The killable (early exit) logic is loosely based on how SH implements it
return if SIGKILL + either of VM_FAULT_OOM or VM_FAULT_RETRY
which is different from Hexagon implementation which would NOT early
exit for
SIGKILL + VM_FAULT_OOM + !VM_FAULT_RETRY

Signed-off-by: Vineet Gupta 
---
 arch/arc/mm/extable.c |   26 ++
 arch/arc/mm/fault.c   |  228 +
 2 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/mm/extable.c
 create mode 100644 arch/arc/mm/fault.c

diff --git a/arch/arc/mm/extable.c b/arch/arc/mm/extable.c
new file mode 100644
index 000..f05b677
--- /dev/null
+++ b/arch/arc/mm/extable.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Borrowed heavily from MIPS
+ */
+
+#include 
+#include 
+
+int fixup_exception(struct pt_regs *regs)
+{
+   const struct exception_table_entry *fixup;
+
+   fixup = search_exception_tables(instruction_pointer(regs));
+   if (fixup) {
+   regs->ret = fixup->fixup;
+
+   return 1;
+   }
+
+   return 0;
+}
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
new file mode 100644
index 000..af55aab
--- /dev/null
+++ b/arch/arc/mm/fault.c
@@ -0,0 +1,228 @@
+/* Page Fault Handling for ARC (TLB Miss / ProtV)
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long address)
+{
+   /*
+* Synchronize this task's top level page-table
+* with the 'reference' page table.
+*/
+   pgd_t *pgd, *pgd_k;
+   pud_t *pud, *pud_k;
+   pmd_t *pmd, *pmd_k;
+
+   pgd = pgd_offset_fast(mm, address);
+   pgd_k = pgd_offset_k(address);
+
+   if (!pgd_present(*pgd_k))
+   goto bad_area;
+
+   pud = pud_offset(pgd, address);
+   pud_k = pud_offset(pgd_k, address);
+   if (!pud_present(*pud_k))
+   goto bad_area;
+
+   pmd = pmd_offset(pud, address);
+   pmd_k = pmd_offset(pud_k, address);
+   if (!pmd_present(*pmd_k))
+   goto bad_area;
+
+   set_pmd(pmd, *pmd_k);
+
+   /* XXX: create the TLB entry here */
+   return 0;
+
+bad_area:
+   return 1;
+}
+
+void do_page_fault(struct pt_regs *regs, int write, unsigned long address,
+  unsigned long cause_code)
+{
+   struct vm_area_struct *vma = NULL;
+   struct task_struct *tsk = current;
+   struct mm_struct *mm = tsk->mm;
+   siginfo_t info;
+   int fault, ret;
+   unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
+   (write ? FAULT_FLAG_WRITE : 0);
+
+   /*
+* We fault-in kernel-space virtual memory on-demand. The
+* 'reference' page table is init_mm.pgd.
+*
+* NOTE! We MUST NOT take any locks for this case. We may
+* be in an interrupt or a critical region, and should
+* only copy the information from the master page table,
+* nothing more.
+*/
+   if (address >= VMALLOC_START && address <= VMALLOC_END) {
+   ret = handle_vmalloc_fault(mm, address);
+   if (unlikely(ret))
+   goto bad_area_nosemaphore;
+   else
+   return;
+   }
+
+   info.si_code = SEGV_MAPERR;
+
+   /*
+* If we're in an interrupt or have no user
+* context, we must not take the fault..
+*/
+   if (in_atomic() || !mm)
+   goto no_context;
+
+retry:
+   down_read(&mm->mmap_sem);
+   vma = find_vma(mm, address);
+   if (!vma)
+   goto bad_area;
+   if (vma->vm_start <= address)
+   goto good_area;
+   if (!(vma->vm_flags & VM_GROWSDOWN))
+   goto bad_area;
+   if (expand_stack(vma, address))
+   goto bad_area;
+
+   /*
+* Ok, we have a good vm_area for this memory access, so
+* we can handle it..
+*/
+good_area:
+   info.si_code = SEGV_ACCERR;
+
+   /* Handle protection violation, execute on heap or stack */
+
+   if (cause_code == ((ECR_V_PROTV << 16) | ECR_C_PROTV_INST_FETCH))
+   goto bad_area;
+
+   if (write) {
+   if (!(vma->vm_flags & VM_WRITE))
+   goto bad_a

[RFC PATCH v1 31/31] ARC: [plat-arcfpga] defconfig

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/configs/fpga_defconfig |  607 +++
 1 files changed, 607 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/configs/fpga_defconfig

diff --git a/arch/arc/configs/fpga_defconfig b/arch/arc/configs/fpga_defconfig
new file mode 100644
index 000..cfdca3c
--- /dev/null
+++ b/arch/arc/configs/fpga_defconfig
@@ -0,0 +1,607 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arc 3.7.0-rc3 Kernel Configuration
+#
+CONFIG_ARC=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_UID16=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_MMU=y
+CONFIG_NO_IOPORT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_BINFMT_ELF=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+# CONFIG_NO_DMA is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+# CONFIG_EXPERIMENTAL is not set
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE="arc-elf32-"
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="(none)"
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
+# CONFIG_FHANDLE is not set
+CONFIG_HAVE_GENERIC_HARDIRQS=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+
+#
+# Timers subsystem
+#
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+
+#
+# CPU/Task time and stats accounting
+#
+CONFIG_TICK_CPU_ACCOUNTING=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_RCU=y
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_CHECKPOINT_RESTORE is not set
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_UIDGID_CONVERTED=y
+# CONFIG_UIDGID_STRICT_TYPE_CHECKS is not set
+# CONFIG_SCHED_AUTOGROUP is not set
+# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="../arc_initramfs"
+CONFIG_INITRAMFS_ROOT_UID=0
+CONFIG_INITRAMFS_ROOT_GID=0
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+CONFIG_INITRAMFS_COMPRESSION_NONE=y
+# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_EXPERT=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_SHMEM is not set
+# CONFIG_AIO is not set
+CONFIG_EMBEDDED=y
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_GENERIC_KERNEL_THREAD=y
+CONFIG_MODULES_USE_ELF_RELA=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_BASE_SMALL=1
+# CONFIG_MODULES is not set
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_NOOP=y
+CONFIG_DEFAULT_IOSCHED="noop"
+CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
+CONFIG_INLINE_READ_UNLOCK=y
+CONFIG_INLINE_READ_UNLOCK_IRQ=y
+CONFIG_INLINE_WRITE_UNLOCK=y
+CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
+# CONFIG_FREEZER is not set
+
+#
+# ARC Architecture Configuration
+#
+CONFIG_ARC_PLAT_FPGA_LEGACY=y
+
+#
+# ARC CPU Configuration
+#
+# CONFIG_ARC_CPU_750D is not set
+CONFIG_ARC_CPU_770=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_ARC_CACHE=y
+CONFIG_ARC_CACHE_LINE_SHIFT=6
+CONFIG_ARC_HAS_ICACHE=y
+CONFIG_ARC_HAS_DCACHE=y
+CONFIG_ARC_CACHE_PAGES=y
+CONFIG_ARC_HAS_HW_MPY=y
+# CONFIG_ARC_MMU_V1 is not set
+# CONFIG_ARC_MMU_V2 is not set
+CONFIG_ARC_MMU_V3=y
+CONFIG_ARC_PAGE_SIZE_8K=y
+# CONFIG_ARC_PAGE_SIZE_16K is not set
+# CONFIG_ARC_PAGE_SIZE_4K is not set
+# CONFIG_ARC_FPU_SAVE_RESTORE is not set
+CONFIG_ARC_CPU_REL_4_10=y
+CONFIG_ARC_HAS_LLSC=y
+CONFIG_ARC_HAS_SWAPE=y
+CONFIG_ARC_HAS_RTSC=y
+
+#
+# Platform Board Configuration
+#
+CONFIG_ARC_BOARD_ANGEL4=y
+# CONFIG_ARC_BOARD_ML509 is not set
+CONFIG_ARC_SERIAL_BAUD=115200
+CONFIG_ARC_PLAT_CLK=8000
+CONFIG_LINUX_LINK_BASE=0x8000
+CONFIG_ARC_PLAT_SDRAM_SIZE=0x1000
+# CONFIG_ARC_STACK_NONEXEC is not set
+CON

Re: [PATCH 0/4] x86, cacheinfo: Use AMD topology extensions

2012-11-07 Thread H. Peter Anvin
Too many of us at LCE right now...

Jacob Shin  wrote:

>On Fri, Oct 19, 2012 at 10:55:19AM +0200, Andreas Herrmann wrote:
>> Hi,
>> 
>> Following patches modify cachinfo code to make use of AMD's topology
>> extension CPUID functions. Thus (hopefully) we can avoid CPU specific
>> modifications whenever cache topology changes.
>> 
>> Please apply.
>
>Acked-by: Jacob Shin 
>
>
>
>Ping ?
>
>Any feedback ? If not could we get it into tip ?
>
>Thank you,
>
>> 
>> 
>> Thanks,
>> 
>> Andreas
>> 
>> --
>> 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/
>> 
>> 
>> 

-- 
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/


[RFC PATCH v1 29/31] ARC: switch to generic kernel_thread()

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/Kconfig  |1 +
 arch/arc/kernel/process.c |   29 +
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index d6983afa..f3aacfc 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -17,6 +17,7 @@ config ARC
select GENERIC_FIND_FIRST_BIT
# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
select GENERIC_IRQ_SHOW
+   select GENERIC_KERNEL_THREAD
select GENERIC_PENDING_IRQ if SMP
select GENERIC_SMP_IDLE_THREAD
select HAVE_GENERIC_HARDIRQS
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index fee3e11..d2bb27f 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -142,22 +142,6 @@ void cpu_idle(void)
}
 }
 
-int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
-{
-   struct pt_regs regs = {
-   .r0 = (unsigned long)arg,
-   .r1 = (unsigned long)fn
-   };
-
-   regs.status32 = read_aux_reg(0xa);
-
-   /* Ok, create the new process.. */
-   return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, NULL,
-  NULL);
-
-}
-EXPORT_SYMBOL(kernel_thread);
-
 asmlinkage void ret_from_fork(void);
 asmlinkage void ret_from_kernel_thread(void) __attribute__((noreturn));
 
@@ -192,7 +176,7 @@ asmlinkage void ret_from_kernel_thread(void) 
__attribute__((noreturn));
  * --  <= END of PAGE
  */
 int copy_thread(unsigned long clone_flags,
-   unsigned long usp, unsigned long topstk,
+   unsigned long usp, unsigned long arg,
struct task_struct *p, struct pt_regs *regs)
 {
struct pt_regs *c_regs;/* child's pt_regs */
@@ -213,10 +197,12 @@ int copy_thread(unsigned long clone_flags,
 */
p->thread.ksp = (unsigned long)c_callee;/* THREAD_KSP */
 
-   /* Copy parents pt regs on child's kernel mode stack */
-   *c_regs = *regs;
+   if (unlikely(p->flags & PF_KTHREAD)) {
+   memset(c_regs, 0, sizeof(struct pt_regs));
+   c_regs->r0 = arg; /* argument to kernel thread */
+   c_regs->r1 = usp;  /* function */
+   c_regs->status32 = read_aux_reg(0xa);
 
-   if (!(user_mode(regs))) {
c_regs->sp =
(unsigned long)task_thread_info(p) + (THREAD_SIZE - 4);
 
@@ -232,6 +218,9 @@ int copy_thread(unsigned long clone_flags,
childksp[0] = 0;/* for POP fp */
childksp[1] = (unsigned long)ret_from_fork; /* for POP blink */
 
+   /* Copy parents pt regs on child's kernel mode stack */
+   *c_regs = *regs;
+
c_regs->sp = usp;
c_regs->r0 = 0; /* fork returns 0 in child */
 
-- 
1.7.4.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/


[RFC PATCH v1 27/31] ARC: Last bits (stubs) to get to a running kernel with UART

2012-11-07 Thread Vineet Gupta
=>8=
Linux version 3.7.0-rc3+ (vineetg@vineetg-Latitude) (gcc version 4.4.7
(ARCompact elf32 toolchain (built 20120928)) ) #5 Tue Nov 6 17:05:37 CET
2012
[plat-arcfpga]: registering early dev resources
bootconsole [early_ARCuart0] enabled
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on.  Total pages:
32624
Kernel command line: print-fatal-signals=1
PID hash table entries: 1024 (order: -1, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 4, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 3, 65536 bytes)
Memory Available: 248M / 256M (1219K code, 412K data, 4192K init, 1400K
reserv)
SLUB: Genslabs=12, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:16
Device [ARC Timer0] clockevent mode now [1]
Device [ARC Timer0] clockevent mode now [2]
Console: colour dummy device 80x25
Calibrating delay loop... 39.73 BogoMIPS (lpj=198656)
pid_max: default: 4096 minimum: 301
Mount-cache hash table entries: 1024
devtmpfs: initialized
[plat-arcfpga]: registering device resources
bio: create slab  at 0
Switching to clocksource ARC Timer1
Device [ARC Timer0] clockevent mode now [3]
io scheduler noop registered (default)
arc-uart.0: ttyARC0 at MMIO 0xc0fc1000 (irq = 5) is a arc-uart
console [ttyARC0] enabled, bootconsole disabled
console [ttyARC0] enabled, bootconsole disabled
Warning: unable to open an initial console.
Freeing unused kernel memory: 4192k [80002000] to [8041a000]
Mounting proc
Mounting sysfs
Mounting devpts
Setting hostname to ARCLinux
Starting System logger (syslogd)
Bringing up loopback device
ifconfig: socket: Function not implemented
route: socket: Function not implemented
Disk not detected !
Mounting tmpfs
/etc/init.d/rcS: line 76: can't create /proc/sys/kernel/msgmni:
nonexistent directory

Please press Enter to activate this console.
***
Welcome to ARCLinux
***
[ARCLinux]$

=>8=

Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/ptrace.c   |   26 
 arch/arc/kernel/stacktrace.c   |   43 
 arch/arc/kernel/troubleshoot.c |   17 +++
 3 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/kernel/ptrace.c
 create mode 100644 arch/arc/kernel/stacktrace.c
 create mode 100644 arch/arc/kernel/troubleshoot.c

diff --git a/arch/arc/kernel/ptrace.c b/arch/arc/kernel/ptrace.c
new file mode 100644
index 000..1cf944a
--- /dev/null
+++ b/arch/arc/kernel/ptrace.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+void ptrace_disable(struct task_struct *child)
+{
+}
+
+long arch_ptrace(struct task_struct *child, long request,
+unsigned long addr, unsigned long data)
+{
+   int ret = -EIO;
+   return ret;
+}
+
+
+const struct user_regset_view *task_user_regset_view(struct task_struct *task)
+{
+   return (const struct user_regset_view *)NULL;
+}
diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c
new file mode 100644
index 000..b9d1646
--- /dev/null
+++ b/arch/arc/kernel/stacktrace.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+/*-
+ *  APIs expected by various kernel sub-systems
+ *-
+ */
+
+noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs)
+{
+   pr_info("\nStack Trace: NOT Available\n");
+}
+EXPORT_SYMBOL(show_stacktrace);
+
+/* Expected by sched Code */
+void show_stack(struct task_struct *tsk, unsigned long *sp)
+{
+   show_stacktrace(tsk, NULL);
+}
+
+/* Expected by Rest of kernel code */
+void dump_stack(void)
+{
+   show_stacktrace(NULL, NULL);
+}
+EXPORT_SYMBOL(dump_stack);
+
+/* Another API expected by schedular, shows up in "ps" as Wait Channel
+ * Ofcourse just returning schedule( ) would be pointless so unwind until
+ * the function is not in schedular code
+ */
+unsigned int get_wchan(struct task_struct *tsk)
+{
+   return 0;
+}
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
new file mode 100644
index 000..80bfe2a
--- /dev/null

[RFC PATCH v1 13/31] ARC: Non-MMU Exception Handling

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/hw_irq.h |7 --
 arch/arc/kernel/traps.c   |  125 +
 2 files changed, 125 insertions(+), 7 deletions(-)
 delete mode 100644 arch/arc/include/asm/hw_irq.h
 create mode 100644 arch/arc/kernel/traps.c

diff --git a/arch/arc/include/asm/hw_irq.h b/arch/arc/include/asm/hw_irq.h
deleted file mode 100644
index fd565ab..000
--- a/arch/arc/include/asm/hw_irq.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
new file mode 100644
index 000..fd2457c
--- /dev/null
+++ b/arch/arc/kernel/traps.c
@@ -0,0 +1,125 @@
+/*
+ * Traps/Non-MMU Exception handling for ARC
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Rahul Trivedi: Codito Technologies 2004
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void __init trap_init(void)
+{
+   return;
+}
+
+void die(const char *str, struct pt_regs *regs, unsigned long address,
+unsigned long cause_reg)
+{
+   show_kernel_fault_diag(str, regs, address, cause_reg);
+
+   /* DEAD END */
+   __asm__("flag 1");
+}
+
+/*
+ * Helper called for bulk of exceptions NOT needing specific handling
+ *  -for user faults enqueues requested signal
+ *  -for kernel, chk if due to copy_(to|from)_user, otherwise die()
+ */
+static noinline int handle_exception(unsigned long cause, char *str,
+struct pt_regs *regs, siginfo_t *info)
+{
+   if (user_mode(regs)) {
+   struct task_struct *tsk = current;
+
+   tsk->thread.fault_address = (__force unsigned int)info->si_addr;
+   tsk->thread.cause_code = cause;
+
+   force_sig_info(info->si_signo, info, tsk);
+
+   } else {
+   /* If not due to copy_(to|from)_user, we are doomed */
+   if (fixup_exception(regs))
+   return 0;
+
+   die(str, regs, (unsigned long)info->si_addr, cause);
+   }
+
+   return 1;
+}
+
+#define DO_ERROR_INFO(signr, str, name, sicode) \
+int name(unsigned long cause, unsigned long address, struct pt_regs *regs) \
+{  \
+   siginfo_t info = {  \
+   .si_signo = signr,  \
+   .si_errno = 0,  \
+   .si_code  = sicode, \
+   .si_addr = (void __user *)address,  \
+   };  \
+   return handle_exception(cause, str, regs, &info);\
+}
+
+/*
+ * Entry points for exceptions NOT needing specific handling
+ */
+DO_ERROR_INFO(SIGILL, "Priv Op/Disabled Extn", do_privilege_fault, ILL_PRVOPC)
+DO_ERROR_INFO(SIGILL, "Invalid Extn Insn", do_extension_fault, ILL_ILLOPC)
+DO_ERROR_INFO(SIGILL, "Illegal Insn (or Seq)", insterror_is_error, ILL_ILLOPC)
+DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", do_memory_error, BUS_ADRERR)
+DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT)
+
+DO_ERROR_INFO(SIGSEGV, "Misaligned Access", do_misaligned_access, SEGV_ACCERR)
+
+/*
+ * Entry point for miscll errors such as Nested Exceptions
+ *  -Duplicate TLB entry is handled seperately though
+ */
+void do_machine_check_fault(unsigned long cause, unsigned long address,
+   struct pt_regs *regs)
+{
+   die("Machine Check Exception", regs, address, cause);
+}
+
+/*
+ * Entry point for traps induced by ARCompact TRAP_S  insn
+ * This is same family as TRAP0/SWI insn (use the same vector).
+ * The only difference being SWI insn take no operand, while TRAP_S does
+ * which reflects in ECR Reg as 8 bit param.
+ * Thus TRAP_S  can be used for specific purpose
+ *  -1 used for software breakpointing (gdb)
+ *  -2 used by kprobes
+ */
+void do_non_swi_trap(unsigned long cause, unsigned long address,
+   struct pt_regs *regs)
+{
+   unsigned int param = cause & 0xff;
+
+   switch (param) {
+   case 1:
+   trap_is_brkpt(cause, address, regs);
+   break;
+
+   default:
+   break;
+   }
+}
+
+/*
+ * Entry point for Instruction Error Exception
+ */
+void do_insterror_or_kprobe(unsigned long cause,
+  unsigned long address,
+  struct pt_regs *regs)
+{
+   insterror_is_error(cause, address, regs);
+}
-- 
1.7.4.1

--
To unsubscribe from this list: se

[RFC PATCH v1 18/31] ARC: Page Table Management

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/page.h|   92 +
 arch/arc/include/asm/pgalloc.h |  134 +
 arch/arc/include/asm/pgtable.h |  401 
 3 files changed, 627 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/pgalloc.h
 create mode 100644 arch/arc/include/asm/pgtable.h

diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 7cd1224..d111d0c 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -35,6 +35,98 @@
 
 #define PAGE_MASK  (~(PAGE_SIZE-1))
 
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+#define get_user_page(vaddr)   __get_free_page(GFP_KERNEL)
+#define free_user_page(page, addr) free_page(addr)
+
+/* TBD: for now don't worry about VIPT D$ aliasing */
+#define clear_page(paddr)  memset((paddr), 0, PAGE_SIZE)
+#define copy_page(to, from)memcpy((to), (from), PAGE_SIZE)
+
+#define clear_user_page(addr, vaddr, pg)   clear_page(addr)
+#define copy_user_page(vto, vfrom, vaddr, pg)  copy_page(vto, vfrom)
+
+#undef STRICT_MM_TYPECHECKS
+
+#ifdef STRICT_MM_TYPECHECKS
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef struct {
+   unsigned long pte;
+} pte_t;
+typedef struct {
+   unsigned long pgd;
+} pgd_t;
+typedef struct {
+   unsigned long pgprot;
+} pgprot_t;
+typedef unsigned long pgtable_t;
+
+#define pte_val(x)  ((x).pte)
+#define pgd_val(x)  ((x).pgd)
+#define pgprot_val(x)   ((x).pgprot)
+
+#define __pte(x)((pte_t) { (x) })
+#define __pgd(x)((pgd_t) { (x) })
+#define __pgprot(x) ((pgprot_t) { (x) })
+
+#else /* !STRICT_MM_TYPECHECKS */
+
+typedef unsigned long pte_t;
+typedef unsigned long pgd_t;
+typedef unsigned long pgprot_t;
+typedef unsigned long pgtable_t;
+
+#define pte_val(x) (x)
+#define pgd_val(x) (x)
+#define pgprot_val(x)  (x)
+#define __pte(x)   (x)
+#define __pgprot(x)(x)
+
+#endif
+
+#define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT)
+
+#define pfn_valid(pfn)  (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
+
+/*
+ * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
+ *
+ * These macros have historically been misnamed
+ * virt here means link-address/program-address as embedded in object code.
+ * So if kernel img is linked at 0x8000_ onwards, 0x8010_ will be
+ * 128th page, and virt_to_page( ) will return the struct page corresp to it.
+ * mem_map[ ] is an array of struct page for each page frame in the system
+ *
+ * Independent of where linux is linked at, link-addr = physical address
+ * So the old macro  __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE
+ * would have been wrong in case kernel is not at 0x8zs
+ */
+#define __pa(vaddr)  ((unsigned long)vaddr)
+#define __va(paddr)  ((void *)((unsigned long)(paddr)))
+
+#define virt_to_page(kaddr)\
+   (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT))
+
+#define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+
+/* Default Permissions for page, used in mmap.c */
+#ifdef CONFIG_ARC_STACK_NONEXEC
+#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
+#else
+#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
+VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+#endif
+
+#define WANT_PAGE_VIRTUAL   1
+
+#include/* page_to_pfn, pfn_to_page */
+#include 
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/arc/include/asm/pgalloc.h b/arch/arc/include/asm/pgalloc.h
new file mode 100644
index 000..36a9f20
--- /dev/null
+++ b/arch/arc/include/asm/pgalloc.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: June 2011
+ *  -"/proc/meminfo | grep PageTables" kept on increasing
+ *   Recently added pgtable dtor was not getting called.
+ *
+ * vineetg: May 2011
+ *  -Variable pg-sz means that Page Tables could be variable sized themselves
+ *So calculate it based on addr traversal split [pgd-bits:pte-bits:xxx]
+ *  -Page Table size capped to max 1 to save memory - hence verified.
+ *  -Since these deal with constants, gcc compile-time optimizes them.
+ *
+ * vineetg: Nov 2010
+ *  -Added pgtable ctor/dtor used for pgtable mem accounting
+ *
+ * vineetg: April 2010
+ *  -Switched pgtable_t from being struct page * to unsigned long
+ *  =Needed so that Page Table allocator (pte_alloc_one) is not forced to
+ *   to deal with struct page. Thay way in future we can make it allocate
+ *   multiple PG Tbls in one Page Frame
+ *  =sweet side effect is avoiding calls to ugly page_address( ) from the
+ *   pg-tlb allocator sub-sys (pte_alloc_one, ptr_free,

[RFC PATCH v1 19/31] ARC: MMU Context Management

2012-11-07 Thread Vineet Gupta
ARC700 MMU provides for tagging TLB entries with a 8-bit ASID to avoid
having to flush the TLB every task switch.

It also allows for a quick way to invalidate all the TLB entries for
task useful for:
* COW sementics during fork()
* task exit()ing

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h |7 ++
 arch/arc/include/asm/mmu.h |   23 
 arch/arc/include/asm/mmu_context.h |  209 
 arch/arc/mm/tlb.c  |   23 
 4 files changed, 262 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/mmu.h
 create mode 100644 arch/arc/include/asm/mmu_context.h
 create mode 100644 arch/arc/mm/tlb.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index c6e2805..c12eb9b 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -85,6 +85,13 @@
 #define DC_CTRL_INV_MODE_FLUSH  0x40
 #define DC_CTRL_FLUSH_STATUS0x100
 
+/* MMU Management regs */
+#define ARC_REG_PID0x409
+#define ARC_REG_SCRATCH_DATA0  0x418
+
+/* Bits in MMU PID register */
+#define MMU_ENABLE (1 << 31)   /* Enable MMU for process */
+
 /*
  * Floating Pt Registers
  * Status regs are read-only (build-time) so need not be saved/restored
diff --git a/arch/arc/include/asm/mmu.h b/arch/arc/include/asm/mmu.h
new file mode 100644
index 000..56b0232
--- /dev/null
+++ b/arch/arc/include/asm/mmu.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_MMU_H
+#define _ASM_ARC_MMU_H
+
+#ifndef __ASSEMBLY__
+
+typedef struct {
+   unsigned long asid; /* Pvt Addr-Space ID for mm */
+#ifdef CONFIG_ARC_TLB_DBG
+   struct task_struct *tsk;
+#endif
+} mm_context_t;
+
+#endif
+
+#endif
diff --git a/arch/arc/include/asm/mmu_context.h 
b/arch/arc/include/asm/mmu_context.h
new file mode 100644
index 000..d12f3de
--- /dev/null
+++ b/arch/arc/include/asm/mmu_context.h
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: May 2011
+ *  -Refactored get_new_mmu_context( ) to only handle live-mm.
+ *   retiring-mm handled in other hooks
+ *
+ * Vineetg: March 25th, 2008: Bug #92690
+ *  -Major rewrite of Core ASID allocation routine get_new_mmu_context
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_MMU_CONTEXT_H
+#define _ASM_ARC_MMU_CONTEXT_H
+
+#include 
+#include 
+
+#include 
+
+/* ARC700 ASID Management
+ *
+ * ARC MMU provides 8-bit ASID (0..255) to TAG TLB entries, allowing entries
+ * with same vaddr (different tasks) to co-exit. This provides for
+ * "Fast Context Switch" i.e. no TLB flush on ctxt-switch
+ *
+ * Linux assigns each task a unique ASID. A simple round-robin allocation
+ * of H/w ASID is done using software tracker @asid_cache.
+ * When it reaches max 255, the allocation cycle starts afresh by flushing
+ * the entire TLB and wrapping ASID back to zero.
+ *
+ * For book-keeping, Linux uses a couple of data-structures:
+ *  -mm_struct has an @asid field to keep a note of task's ASID (needed at the
+ *   time of say switch_mm( )
+ *  -An array of mm structs @asid_mm_map[] for asid->mm the reverse mapping,
+ *  given an ASID, finding the mm struct associated.
+ *
+ * The round-robin allocation algorithm allows for ASID stealing.
+ * If asid tracker is at "x-1", a new req will allocate "x", even if "x" was
+ * already assigned to another (switched-out) task. Obviously the prev owner
+ * is marked with an invalid ASID to make it request for a new ASID when it
+ * gets scheduled next time. However its TLB entries (with ASID "x") could
+ * exist, which must be cleared before the same ASID is used by the new owner.
+ * Flushing them would be plausible but costly solution. Instead we force a
+ * allocation policy quirk, which ensures that a stolen ASID won't have any
+ * TLB entries associates, alleviating the need to flush.
+ * The quirk essentially is not allowing ASID allocated in prev cycle
+ * to be used past a roll-over in the next cycle.
+ * When this happens (i.e. task ASID > asid tracker), task needs to refresh
+ * its ASID, aligning it to current value of tracker. If the task doesn't get
+ * scheduled past a roll-over, hence its ASID is not yet realigned with
+ * tracker, such ASID is anyways safely reusable because it is
+ * gauranteed that TLB entries with that ASID wont exist.
+ */
+
+#define FIRST_ASID  0
+#define MAX_ASID255/* 8 bit PID field in PID Aux 
reg *

[RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/irq.h  |1 +
 arch/arc/plat-arcfpga/include/plat/irq.h|   27 +++
 arch/arc/plat-arcfpga/include/plat/memmap.h |   31 
 arch/arc/plat-arcfpga/platform.c|  105 +++
 4 files changed, 164 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/plat-arcfpga/include/plat/irq.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/memmap.h

diff --git a/arch/arc/include/asm/irq.h b/arch/arc/include/asm/irq.h
index 633416c..8e771f6 100644
--- a/arch/arc/include/asm/irq.h
+++ b/arch/arc/include/asm/irq.h
@@ -13,6 +13,7 @@
 #define TIMER0_IRQ  3
 #define TIMER1_IRQ  4
 
+#include   /* Board Specific IRQ assignments */
 #include 
 
 extern void __init arc_init_IRQ(void);
diff --git a/arch/arc/plat-arcfpga/include/plat/irq.h 
b/arch/arc/plat-arcfpga/include/plat/irq.h
new file mode 100644
index 000..b34e087
--- /dev/null
+++ b/arch/arc/plat-arcfpga/include/plat/irq.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Feb 2009
+ *  -For AA4 board, IRQ assignments to peripherals
+ */
+
+#ifndef __PLAT_IRQ_H
+#define __PLAT_IRQ_H
+
+#define NR_IRQS16
+
+#define UART0_IRQ  5
+#define UART1_IRQ  10
+#define UART2_IRQ  11
+
+#define VMAC_IRQ   6
+
+#define IDE_IRQ13
+#define PCI_IRQ14
+#define PS2_IRQ15
+
+#endif
diff --git a/arch/arc/plat-arcfpga/include/plat/memmap.h 
b/arch/arc/plat-arcfpga/include/plat/memmap.h
new file mode 100644
index 000..1663f33
--- /dev/null
+++ b/arch/arc/plat-arcfpga/include/plat/memmap.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Feb 2009
+ *  -For AA4 board, System Memory Map for Peripherals etc
+ */
+
+#ifndef __PLAT_MEMMAP_H
+#define __PLAT_MEMMAP_H
+
+#define UART0_BASE  0xC0FC1000
+#define UART1_BASE  0xC0FC1100
+
+#define VMAC_REG_BASEADDR   0xC0FC2000
+
+#define IDE_CONTROLLER_BASE 0xC0FC9000
+
+#define AHB_PCI_HOST_BRG_BASE   0xC0FD
+
+#define PGU_BASEADDR0xC0FC8000
+#define VLCK_ADDR   0xC0FCF028
+
+#define BVCI_LAT_UNIT_BASE  0xC0FED000
+
+#define PS2_BASE_ADDR  0xC0FCC000
+
+#endif
diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c
index 7b5dcab..3243091 100644
--- a/arch/arc/plat-arcfpga/platform.c
+++ b/arch/arc/plat-arcfpga/platform.c
@@ -10,7 +10,99 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
+#include 
+#include 
+
+/*--- Platform Devices -*/
+
+#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE)
+
+static unsigned long arc_uart_info[] = {
+   CONFIG_ARC_SERIAL_BAUD, /* uart->baud */
+   CONFIG_ARC_PLAT_CLK,/* uart->port.uartclk */
+   -1, /* uart->is_emulated (runtime @running_on_hw) */
+   0
+};
+
+#define ARC_UART_DEV(n)\
+   \
+static struct resource arc_uart##n##_res[] = { \
+   {   \
+   .start = UART##n##_BASE,\
+   .end   = UART##n##_BASE + 0xFF, \
+   .flags = IORESOURCE_MEM,\
+   },  \
+   {   \
+   .start = UART##n##_IRQ, \
+   .end   = UART##n##_IRQ, \
+   .flags = IORESOURCE_IRQ,\
+   },  \
+}; \
+   \
+static struct platform_device arc_uart##n##_dev = {\
+   .name = "arc-uart", \
+   .id = n,\
+   .num_resources = ARRAY_SIZE(arc_uart##n##_res), \
+   .resource = arc_uart##n##_res,  \
+   .dev = {\
+   .platform_data = &arc_uart_info,\
+   },  \
+}
+
+ARC_UART_DEV(0);
+#if CONFIG_SERIAL_ARC_NR_PORTS > 1
+ARC_UART_DEV(1);
+#endif
+
+static struct platform_device *fpga_early_devs[] __initdata = {
+#if defined(CONFIG_SERIAL_ARC_

[RFC PATCH v1 24/31] ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h   |5 +
 arch/arc/include/asm/setup.h |   22 +
 arch/arc/kernel/head.S   |   78 
 arch/arc/kernel/reset.c  |   33 +++
 arch/arc/kernel/setup.c  |  166 ++
 arch/arc/mm/init.c   |  185 ++
 arch/arc/plat-arcfpga/platform.c |   29 ++
 7 files changed, 518 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/setup.h
 create mode 100644 arch/arc/kernel/head.S
 create mode 100644 arch/arc/kernel/reset.c
 create mode 100644 arch/arc/kernel/setup.c
 create mode 100644 arch/arc/mm/init.c
 create mode 100644 arch/arc/plat-arcfpga/platform.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index aedfbf1..725b94c 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -257,6 +257,11 @@
}   \
 }
 
+/* Helpers */
+#define TO_KB(bytes)   ((bytes) >> 10)
+#define TO_MB(bytes)   (TO_KB(bytes) >> 10)
+#define PAGES_TO_KB(n_pages)   ((n_pages) << (PAGE_SHIFT - 10))
+#define PAGES_TO_MB(n_pages)   (PAGES_TO_KB(n_pages) >> 10)
 
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
 /* These DPFP regs need to be saved/restored across ctx-sw */
diff --git a/arch/arc/include/asm/setup.h b/arch/arc/include/asm/setup.h
new file mode 100644
index 000..ab427e6
--- /dev/null
+++ b/arch/arc/include/asm/setup.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASMARC_SETUP_H
+#define __ASMARC_SETUP_H
+
+#include 
+
+#define COMMAND_LINE_SIZE 256
+
+extern int root_mountflags, end_mem;
+extern int running_on_hw;
+
+void __init setup_processor(void);
+void __init setup_arch_memory(void);
+
+#endif /* __ASMARC_SETUP_H */
diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
new file mode 100644
index 000..e63f6a4
--- /dev/null
+++ b/arch/arc/kernel/head.S
@@ -0,0 +1,78 @@
+/*
+ * ARC CPU startup Code
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Vineetg: Dec 2007
+ *  -Check if we are running on Simulator or on real hardware
+ *  to skip certain things during boot on simulator
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+   .cpu A7
+
+   .section .init.text, "ax",@progbits
+   .type stext, @function
+   .globl stext
+stext:
+   ;---
+   ; Don't clobber r0-r4 yet. It might have bootloader provided info
+   ;---
+
+   ; Clear BSS before updating any globals
+   ; XXX: use ZOL here
+   mov r5, __bss_start
+   mov r6, __bss_stop
+1:
+   st.ab   0, [r5,4]
+   brltr5, r6, 1b
+
+#ifdef CONFIG_CMDLINE_UBOOT
+   ; support for bootloader provided cmdline
+   ;If cmdline passed by u-boot, then
+   ;r0 = 1  (because ATAGS parsing, now retired, used to use 0)
+   ;r1 = magic number (board identity)
+   ;r2 = addr of cmdline string (somewhere in memory/flash)
+
+   brner0, 1, .Lother_bootup_chores; u-boot didn't pass cmdline
+   breqr2, 0, .Lother_bootup_chores; or cmdline is NULL
+
+   mov r5, @command_line
+1:
+   ldb.ab  r6, [r2, 1]
+   breqr6, 0, .Lother_bootup_chores
+   b.d 1b
+   stb.ab  r6, [r5, 1]
+#endif
+
+.Lother_bootup_chores:
+
+   ; Identify if running on ISS vs Silicon
+   ;   IDENTITY Reg [ 3  2  1  0 ]
+   ;   (chip-id)  ^==> 0x for ISS
+   lr  r0, [identity]
+   lsr r3, r0, 16
+   cmp r3, 0x
+   mov.z   r4, 0
+   mov.nz  r4, 1
+   st  r4, [@running_on_hw]
+
+   ; setup "current" tsk and optionally cache it in dedicated r25
+   mov r9, @init_task
+   SET_CURR_TASK_ON_CPU  r9, r0; r9 = tsk, r0 = scratch
+
+   ; setup stack (fp, sp)
+   mov fp, 0
+
+   ; tsk->thread_info is really a PAGE, whose bottom hoists stack
+   GET_TSK_STACK_BASE r9, sp   ; r9 = tsk, sp = stack base(output)
+
+   j   start_kernel; "C" entry point
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c
new file mode 100644
index 000..e227a2b
--- /dev/null
+++ b/arch/arc/kernel/reset.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is fre

[RFC PATCH v1 16/31] ARC: Signal handling

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/sigcontext.h |   23 +++
 arch/arc/include/asm/signal.h |   27 +++
 arch/arc/kernel/signal.c  |  360 +
 3 files changed, 410 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/sigcontext.h
 create mode 100644 arch/arc/include/asm/signal.h
 create mode 100644 arch/arc/kernel/signal.c

diff --git a/arch/arc/include/asm/sigcontext.h 
b/arch/arc/include/asm/sigcontext.h
new file mode 100644
index 000..f21b541
--- /dev/null
+++ b/arch/arc/include/asm/sigcontext.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SIGCONTEXT_H
+#define _ASM_ARC_SIGCONTEXT_H
+
+#include 
+
+/*
+ * Signal context structure - contains all info to do with the state
+ * before the signal handler was invoked.  Note: only add new entries
+ * to the end of the structure.
+ */
+struct sigcontext {
+   struct pt_regs regs;
+};
+
+#endif /* _ASM_ARC_SIGCONTEXT_H */
diff --git a/arch/arc/include/asm/signal.h b/arch/arc/include/asm/signal.h
new file mode 100644
index 000..fad62f7
--- /dev/null
+++ b/arch/arc/include/asm/signal.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_SIGNAL_H
+#define _ASM_ARC_SIGNAL_H
+
+/*
+ * This is much needed for ARC sigreturn optimization.
+ * This allows uClibc to piggback the addr of a sigreturn stub in sigaction,
+ * which allows sigreturn based re-entry into kernel after handling signal.
+ * W/o this kernel needs to "synthesize" the sigreturn trampoline on user
+ * mode stack which in turn forces the following:
+ * -TLB Flush (after making the stack page executable)
+ * -Cache line Flush (to make I/D Cache lines coherent)
+ */
+#define SA_RESTORER0x0400
+
+#include 
+
+#endif /* _ASM_ARC_SIGNAL_H */
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c
new file mode 100644
index 000..bc834da
--- /dev/null
+++ b/arch/arc/kernel/signal.c
@@ -0,0 +1,360 @@
+/*
+ * Signal Handling for ARC
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Jan 2010 (Restarting of timer related syscalls)
+ *
+ * vineetg: Nov 2009 (Everything needed for TIF_RESTORE_SIGMASK)
+ *  -do_signal() supports TIF_RESTORE_SIGMASK
+ *  -do_signal() no loner needs oldset, required by OLD sys_sigsuspend
+ *  -sys_rt_sigsuspend() now comes from generic code, so discard arch implemen
+ *  -sys_sigsuspend() no longer needs to fudge ptregs, hence that arg removed
+ *  -sys_sigsuspend() no longer loops for do_signal(), sets TIF_xxx and leaves
+ *   the job to do_signal()
+ *
+ * vineetg: July 2009
+ *  -Modified Code to support the uClibc provided userland sigreturn stub
+ *   to avoid kernel synthesing it on user stack at runtime, costing TLB
+ *   probes and Cache line flushes.
+ *
+ * vineetg: July 2009
+ *  -In stash_usr_regs( ) and restore_usr_regs( ), save/restore of user regs
+ *   in done in block copy rather than one word at a time.
+ *   This saves around 2K of code and improves LMBench lat_sig 
+ *
+ * rajeshwarr: Feb 2009
+ *  - Support for Realtime Signals
+ *
+ * vineetg: Aug 11th 2008: Bug #94183
+ *  -ViXS were still seeing crashes when using insmod to load drivers.
+ *   It turned out that the code to change Execute permssions for TLB entries
+ *   of user was not guarded for interrupts (mod_tlb_permission)
+ *   This was cauing TLB entries to be overwritten on unrelated indexes
+ *
+ * Vineetg: July 15th 2008: Bug #94183
+ *  -Exception happens in Delay slot of a JMP, and before user space resumes,
+ *   Signal is delivered (Ctrl + C) = >SIGINT.
+ *   setup_frame( ) sets up PC,SP,BLINK to enable user space signal handler
+ *   to run, but doesn't clear the Delay slot bit from status32. As a result,
+ *   on resuming user mode, signal handler branches off to BTA of orig JMP
+ *  -FIX: clear the DE bit from status32 in setup_frame( )
+ *
+ * Rahul Trivedi, Kanika Nema: Codito Technologies 2004
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
+
+asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
+{
+   struct pt_regs *regs 

[RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h   |   31 +
 arch/arc/include/asm/delay.h |   68 +++
 arch/arc/include/asm/processor.h |3 +
 arch/arc/include/asm/switch_to.h |   41 +++
 arch/arc/include/asm/timex.h |   18 +++
 arch/arc/kernel/ctx_sw.c |   91 +++
 arch/arc/kernel/ctx_sw_asm.S |   58 +
 arch/arc/kernel/fpu.c|   55 +
 arch/arc/kernel/process.c|  201 
 arch/arc/kernel/time.c   |  237 ++
 10 files changed, 803 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/delay.h
 create mode 100644 arch/arc/include/asm/switch_to.h
 create mode 100644 arch/arc/include/asm/timex.h
 create mode 100644 arch/arc/kernel/ctx_sw.c
 create mode 100644 arch/arc/kernel/ctx_sw_asm.S
 create mode 100644 arch/arc/kernel/fpu.c
 create mode 100644 arch/arc/kernel/time.c

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 3fccb04..5131bb3 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -47,6 +47,28 @@
 #define AUX_ITRIGGER   0x40d
 #define AUX_IPULSE 0x415
 
+/* Timer related Aux registers */
+#define ARC_REG_TIMER0_LIMIT   0x23/* timer 0 limit */
+#define ARC_REG_TIMER0_CTRL0x22/* timer 0 control */
+#define ARC_REG_TIMER0_CNT 0x21/* timer 0 count */
+#define ARC_REG_TIMER1_LIMIT   0x102   /* timer 1 limit */
+#define ARC_REG_TIMER1_CTRL0x101   /* timer 1 control */
+#define ARC_REG_TIMER1_CNT 0x100   /* timer 1 count */
+
+#define TIMER_CTRL_IE  (1 << 0) /* Interupt when Count reachs limit */
+#define TIMER_CTRL_NH  (1 << 1) /* Count only when CPU NOT halted */
+
+/*
+ * Floating Pt Registers
+ * Status regs are read-only (build-time) so need not be saved/restored
+ */
+#define ARC_AUX_FP_STAT 0x300
+#define ARC_AUX_DPFP_1L 0x301
+#define ARC_AUX_DPFP_1H 0x302
+#define ARC_AUX_DPFP_2L 0x303
+#define ARC_AUX_DPFP_2H 0x304
+#define ARC_AUX_DPFP_STAT   0x305
+
 #ifndef __ASSEMBLY__
 
 /*
@@ -110,6 +132,15 @@
 
 #endif
 
+#ifdef CONFIG_ARC_FPU_SAVE_RESTORE
+/* These DPFP regs need to be saved/restored across ctx-sw */
+struct arc_fpu {
+   struct {
+   unsigned int l, h;
+   } aux_dpfp[2];
+};
+#endif
+
 #endif /* __ASEMBLY__ */
 
 #endif /* __KERNEL__ */
diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h
new file mode 100644
index 000..442ce5d
--- /dev/null
+++ b/arch/arc/include/asm/delay.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Delay routines using pre computed loops_per_jiffy value.
+ *
+ * vineetg: Feb 2012
+ *  -Rewrote in "C" to avoid dealing with availability of H/w MPY
+ *  -Also reduced the num of MPY operations from 3 to 2
+ *
+ * Amit Bhor: Codito Technologies 2004
+ */
+
+#ifndef __ASM_ARC_UDELAY_H
+#define __ASM_ARC_UDELAY_H
+
+#include  /* HZ */
+
+static inline void __delay(unsigned long loops)
+{
+   __asm__ __volatile__(
+   "1: sub.f %0, %0, 1 \n"
+   "   jpnz 1b \n"
+   : "+r"(loops)
+   :
+   : "cc");
+}
+
+extern void __bad_udelay(void);
+
+/*
+ * Normal Math for computing loops in "N" usecs
+ *  -we have precomputed @loops_per_jiffy
+ *  -1 sec has HZ jiffies
+ * loops per "N" usecs = ((loops_per_jiffy * HZ / 100) * N)
+ *
+ * Approximate Division by multiplication:
+ *  -Mathematically if we multiply and divide a number by same value the
+ *   result remains unchanged:  In this case, we use 2^32
+ *  -> (loops_per_N_usec * 2^32 ) / 2^32
+ *  -> (((loops_per_jiffy * HZ / 100) * N) * 2^32) / 2^32
+ *  -> (loops_per_jiffy * HZ * N * 4295) / 2^32
+ *
+ *  -Divide by 2^32 is very simply right shift by 32
+ *  -We simply need to ensure that the multiply per above eqn happens in
+ *   64-bit precision (if CPU doesn't support it - gcc can emaulate it)
+ */
+
+static inline void __udelay(unsigned long usecs)
+{
+   unsigned long loops;
+
+   /* (long long) cast ensures 64 bit MPY - real or emulated
+* HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops
+*/
+   loops = ((long long)(usecs * 4295 * HZ) *
+(long long)(loops_per_jiffy)) >> 32;
+
+   __delay(loops);
+}
+
+#define udelay(n) (__builtin_constant_p(n) ? ((n) > 2 ? __bad_udelay() \
+   : __udelay(n)) : __udelay(n))
+
+#endif /* __ASM_ARC_UDELAY_H */
diff --git a/arch/arc/include/asm/processor.h b/arch/arc/include/asm/processor.h
index e2445bc..38ea5fb 100644
--- a/arch/arc/include/asm/processor.h
+++ b/arch/arc/include/asm/processor.h
@@ -29,6

[RFC PATCH v1 14/31] ARC: syscall support

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/ptrace.h   |5 ++
 arch/arc/include/asm/syscall.h  |   72 +++
 arch/arc/include/asm/syscalls.h |   30 ++
 arch/arc/include/asm/unistd.h   |   44 ++
 arch/arc/kernel/entry.S |   49 
 arch/arc/kernel/process.c   |  119 +++
 arch/arc/kernel/sys.c   |   19 ++
 arch/arc/mm/mmap.c  |   21 +++
 8 files changed, 359 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/syscall.h
 create mode 100644 arch/arc/include/asm/syscalls.h
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/kernel/process.c
 create mode 100644 arch/arc/kernel/sys.c
 create mode 100644 arch/arc/mm/mmap.c

diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index c178357..ee31d8a 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -115,6 +115,11 @@ struct user_regs_struct {
 /* return 1 if user mode or 0 if kernel mode */
 #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
 
+
+/* return 1 if in syscall, 0 if Intr or Exception */
+#define in_syscall(regs) (((regs->orig_r8) >= 0 && \
+  (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_PTRACE_H */
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
new file mode 100644
index 000..33ab304
--- /dev/null
+++ b/arch/arc/include/asm/syscall.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SYSCALL_H
+#define _ASM_ARC_SYSCALL_H  1
+
+#include 
+#include 
+#include 
+#include /* in_syscall() */
+
+static inline long
+syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+   if (user_mode(regs) && in_syscall(regs))
+   return regs->orig_r8;
+   else
+   return -1;
+}
+
+static inline void
+syscall_rollback(struct task_struct *task, struct pt_regs *regs)
+{
+   /* XXX: I can't fathom how pt_regs->r8 will be clobbered ? */
+   regs->r8 = regs->orig_r8;
+}
+
+static inline long
+syscall_get_error(struct task_struct *task, struct pt_regs *regs)
+{
+   /* 0 if syscall succeeded, otherwise -Errorcode */
+   return IS_ERR_VALUE(regs->r0) ? regs->r0 : 0;
+}
+
+static inline long
+syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
+{
+   return regs->r0;
+}
+
+static inline void
+syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
+int error, long val)
+{
+   regs->r0 = (long) error ?: val;
+}
+
+/*
+ * @i:  argument index [0,5]
+ * @n:  number of arguments; n+i must be [1,6].
+ */
+static inline void
+syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+ unsigned int i, unsigned int n, unsigned long *args)
+{
+   unsigned long *inside_ptregs = &(regs->r0);
+   inside_ptregs -= i;
+
+   BUG_ON((i + n) > 6);
+
+   while (n--) {
+   args[i++] = (*inside_ptregs);
+   inside_ptregs--;
+   }
+}
+
+#endif
diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
new file mode 100644
index 000..cf5d2f5
--- /dev/null
+++ b/arch/arc/include/asm/syscalls.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SYSCALLS_H
+#define _ASM_ARC_SYSCALLS_H  1
+
+#ifdef __KERNEL__
+
+#include 
+#include 
+#include 
+
+int sys_execve_wrapper(int, int, int);
+int sys_clone_wrapper(int, int, int, int, int);
+int sys_fork_wrapper(void);
+int sys_vfork_wrapper(void);
+int sys_cacheflush(uint32_t, uint32_t uint32_t);
+int sys_arc_settls(void *);
+int sys_arc_gettls(void);
+
+#include 
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/arch/arc/include/asm/unistd.h b/arch/arc/include/asm/unistd.h
new file mode 100644
index 000..754d588
--- /dev/null
+++ b/arch/arc/include/asm/unistd.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * Being uClibc based we need some of the deprecated syscalls:
+ * -Not emulated by uClibc at all
+ * unlink, mkdir,... (needed by Busybox, LTP etc)
+ * times (needed by LTP pan t

[RFC PATCH v1 11/31] ARC: Low level IRQ/Trap/Exception(non-MMU) Handling

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/entry.h |  495 
 arch/arc/kernel/entry.S  |  577 ++
 2 files changed, 1072 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/entry.h
 create mode 100644 arch/arc/kernel/entry.S

diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
new file mode 100644
index 000..3e0a9f4
--- /dev/null
+++ b/arch/arc/include/asm/entry.h
@@ -0,0 +1,495 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Vineetg: Aug 28th 2008: Bug #94984
+ *  -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap
+ *   Normally CPU does this automatically, however when doing FAKE rtie,
+ *   we also need to explicitly do this. The problem in macros
+ *   FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit
+ *   was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context
+ *
+ * Vineetg: May 5th 2008
+ *  - Defined Stack Switching Macro to be reused in all intr/excp hdlrs
+ *  - Shaved off 11 instructions from RESTORE_ALL_INT1 by using the
+ *  address Write back load ld.ab instead of seperate ld/add instn
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef __ASM_ARC_ENTRY_H
+#define __ASM_ARC_ENTRY_H
+
+#ifdef __ASSEMBLY__
+#include /* For NR_syscalls defination */
+#include 
+#include 
+#include 
+#include/* For THREAD_SIZE */
+
+/* Note on the LD/ST addr modes with addr reg wback
+ *
+ * LD.a same as LD.aw
+ *
+ * LD.areg1, [reg2, x]  => Pre Incr
+ *  Eff Addr for load = [reg2 + x]
+ *
+ * LD.ab   reg1, [reg2, x]  => Post Incr
+ *  Eff Addr for load = [reg2]
+ */
+
+/*--
+ * Save caller saved registers (scratch registers) ( r0 - r12 )
+ * Registers are pushed / popped in the order defined in struct ptregs
+ * in asm/ptrace.h
+ *-*/
+.macro  SAVE_CALLER_SAVED
+   st.ar0, [sp, -4]
+   st.ar1, [sp, -4]
+   st.ar2, [sp, -4]
+   st.ar3, [sp, -4]
+   st.ar4, [sp, -4]
+   st.ar5, [sp, -4]
+   st.ar6, [sp, -4]
+   st.ar7, [sp, -4]
+   st.ar8, [sp, -4]
+   st.ar9, [sp, -4]
+   st.ar10, [sp, -4]
+   st.ar11, [sp, -4]
+   st.ar12, [sp, -4]
+.endm
+
+/*--
+ * Restore caller saved registers (scratch registers)
+ *-*/
+.macro RESTORE_CALLER_SAVED
+   ld.ab   r12, [sp, 4]
+   ld.ab   r11, [sp, 4]
+   ld.ab   r10, [sp, 4]
+   ld.ab   r9, [sp, 4]
+   ld.ab   r8, [sp, 4]
+   ld.ab   r7, [sp, 4]
+   ld.ab   r6, [sp, 4]
+   ld.ab   r5, [sp, 4]
+   ld.ab   r4, [sp, 4]
+   ld.ab   r3, [sp, 4]
+   ld.ab   r2, [sp, 4]
+   ld.ab   r1, [sp, 4]
+   ld.ab   r0, [sp, 4]
+.endm
+
+
+/*--
+ * Save callee saved registers (non scratch registers) ( r13 - r25 )
+ *  on kernel stack.
+ * User mode callee regs need to be saved in case of
+ *-fork and friends for replicating from parent to child
+ *-before going into do_signal( ) for ptrace/core-dump
+ * Special case handling is required for r25 in case it is used by kernel
+ *  for caching task ptr. Low level exception/ISR save user mode r25
+ *  into task->thread.user_r25. So it needs to be retrieved from there and
+ *  saved into kernel stack wit rest of callee reg-file
+ *-*/
+.macro SAVE_CALLEE_SAVED_USER
+   st.ar13, [sp, -4]
+   st.ar14, [sp, -4]
+   st.ar15, [sp, -4]
+   st.ar16, [sp, -4]
+   st.ar17, [sp, -4]
+   st.ar18, [sp, -4]
+   st.ar19, [sp, -4]
+   st.ar20, [sp, -4]
+   st.ar21, [sp, -4]
+   st.ar22, [sp, -4]
+   st.ar23, [sp, -4]
+   st.ar24, [sp, -4]
+   st.ar25, [sp, -4]
+
+   /* move up by 1 word to "create" callee_regs->"stack_place_holder" */
+   sub sp, sp, 4
+.endm
+
+/*--
+ * Save callee saved registers (non scratch registers) ( r13 - r25 )
+ * kernel mode callee regs needed to be saved in case of context switch
+ * If r25 is used for caching task pointer then that need not be saved
+ * as it can be re-created from current task global
+ *-*/
+.macro SAVE_CALLEE_SAVED_KERNEL
+   st.ar13, [sp, -4]
+   st.ar14, [sp, -4]
+   st.a  

[RFC PATCH v1 10/31] ARC: string library

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/string.h |   40 +
 arch/arc/lib/memcmp.S |  124 +
 arch/arc/lib/memcpy-700.S |   66 ++
 arch/arc/lib/memset.S |   59 +++
 arch/arc/lib/strchr-700.S |  123 
 arch/arc/lib/strcmp.S |   96 +++
 arch/arc/lib/strcpy-700.S |   70 +++
 arch/arc/lib/strlen.S |   83 +++
 8 files changed, 661 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/string.h
 create mode 100644 arch/arc/lib/memcmp.S
 create mode 100644 arch/arc/lib/memcpy-700.S
 create mode 100644 arch/arc/lib/memset.S
 create mode 100644 arch/arc/lib/strchr-700.S
 create mode 100644 arch/arc/lib/strcmp.S
 create mode 100644 arch/arc/lib/strcpy-700.S
 create mode 100644 arch/arc/lib/strlen.S

diff --git a/arch/arc/include/asm/string.h b/arch/arc/include/asm/string.h
new file mode 100644
index 000..87676c8
--- /dev/null
+++ b/arch/arc/include/asm/string.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: May 2011
+ *  -We had half-optimised memset/memcpy, got better versions of those
+ *  -Added memcmp, strchr, strcpy, strcmp, strlen
+ *
+ * Amit Bhor: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_STRING_H
+#define _ASM_ARC_STRING_H
+
+#include 
+
+#ifdef __KERNEL__
+
+#define __HAVE_ARCH_MEMSET
+#define __HAVE_ARCH_MEMCPY
+#define __HAVE_ARCH_MEMCMP
+#define __HAVE_ARCH_STRCHR
+#define __HAVE_ARCH_STRCPY
+#define __HAVE_ARCH_STRCMP
+#define __HAVE_ARCH_STRLEN
+
+extern void *memset(void *ptr, int, __kernel_size_t);
+extern void *memcpy(void *, const void *, __kernel_size_t);
+extern void memzero(void *ptr, __kernel_size_t n);
+extern int memcmp(const void *, const void *, __kernel_size_t);
+extern char *strchr(const char *s, int c);
+extern char *strcpy(char *dest, const char *src);
+extern int strcmp(const char *cs, const char *ct);
+extern __kernel_size_t strlen(const char *);
+
+#endif /* __KERNEL__ */
+#endif /* _ASM_ARC_STRING_H */
diff --git a/arch/arc/lib/memcmp.S b/arch/arc/lib/memcmp.S
new file mode 100644
index 000..bc813d5
--- /dev/null
+++ b/arch/arc/lib/memcmp.S
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+#ifdef __LITTLE_ENDIAN__
+#define WORD2 r2
+#define SHIFT r3
+#else /* BIG ENDIAN */
+#define WORD2 r3
+#define SHIFT r2
+#endif
+
+ARC_ENTRY memcmp
+   or  r12,r0,r1
+   asl_s   r12,r12,30
+   sub r3,r2,1
+   brlsr2,r12,.Lbytewise
+   ld  r4,[r0,0]
+   ld  r5,[r1,0]
+   lsr.f   lp_count,r3,3
+   lpne.Loop_end
+   ld_sWORD2,[r0,4]
+   ld_sr12,[r1,4]
+   brner4,r5,.Leven
+   ld.ar4,[r0,8]
+   ld.ar5,[r1,8]
+   brneWORD2,r12,.Lodd
+.Loop_end:
+   asl_s   SHIFT,SHIFT,3
+   bhs_s   .Last_cmp
+   brner4,r5,.Leven
+   ld  r4,[r0,4]
+   ld  r5,[r1,4]
+#ifdef __LITTLE_ENDIAN__
+   nop_s
+   ; one more load latency cycle
+.Last_cmp:
+   xor r0,r4,r5
+   bsetr0,r0,SHIFT
+   sub_s   r1,r0,1
+   bic_s   r1,r1,r0
+   normr1,r1
+   b.d .Leven_cmp
+   and r1,r1,24
+.Leven:
+   xor r0,r4,r5
+   sub_s   r1,r0,1
+   bic_s   r1,r1,r0
+   normr1,r1
+   ; slow track insn
+   and r1,r1,24
+.Leven_cmp:
+   asl r2,r4,r1
+   asl r12,r5,r1
+   lsr_s   r2,r2,1
+   lsr_s   r12,r12,1
+   j_s.d   [blink]
+   sub r0,r2,r12
+   .balign 4
+.Lodd:
+   xor r0,WORD2,r12
+   sub_s   r1,r0,1
+   bic_s   r1,r1,r0
+   normr1,r1
+   ; slow track insn
+   and r1,r1,24
+   asl_s   r2,r2,r1
+   asl_s   r12,r12,r1
+   lsr_s   r2,r2,1
+   lsr_s   r12,r12,1
+   j_s.d   [blink]
+   sub r0,r2,r12
+#else /* BIG ENDIAN */
+.Last_cmp:
+   neg_s   SHIFT,SHIFT
+   lsr r4,r4,SHIFT
+   lsr r5,r5,SHIFT
+   ; slow track insn
+.Leven:
+   sub.f   r0,r4,r5
+   mov.ne  r0,1
+   j_s.d   [blink]
+   bset.cs r0,r0,31
+.Lodd:
+   cmp_s   WORD2,r12
+
+   mov_s   r0,1
+   j_s.d   [blink]
+   bset.cs r0,r0,31
+#endif /* ENDIAN */
+   .balign 4
+.Lbytewise:
+   breqr2,0,.Lnil
+   ldb r4,[r0,0]
+   ldb r5,[r1,0]
+   lsr.f   lp_count,r3
+   lpne

[RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

2012-11-07 Thread Vineet Gupta
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/bug.h |   37 +
 arch/arc/include/asm/cache.h   |   21 +
 arch/arc/include/asm/elf.h |   97 
 arch/arc/include/asm/exec.h|   15 
 arch/arc/include/asm/kdebug.h  |   19 +
 arch/arc/include/asm/linkage.h |   30 
 arch/arc/include/asm/module.h  |   17 
 arch/arc/include/asm/page.h|   42 +++
 arch/arc/include/asm/processor.h   |  143 
 arch/arc/include/asm/ptrace.h  |  120 ++
 arch/arc/include/asm/sections.h|   17 
 arch/arc/include/asm/thread_info.h |  120 ++
 12 files changed, 678 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/bug.h
 create mode 100644 arch/arc/include/asm/cache.h
 create mode 100644 arch/arc/include/asm/elf.h
 create mode 100644 arch/arc/include/asm/exec.h
 create mode 100644 arch/arc/include/asm/kdebug.h
 create mode 100644 arch/arc/include/asm/linkage.h
 create mode 100644 arch/arc/include/asm/module.h
 create mode 100644 arch/arc/include/asm/page.h
 create mode 100644 arch/arc/include/asm/processor.h
 create mode 100644 arch/arc/include/asm/ptrace.h
 create mode 100644 arch/arc/include/asm/sections.h
 create mode 100644 arch/arc/include/asm/thread_info.h

diff --git a/arch/arc/include/asm/bug.h b/arch/arc/include/asm/bug.h
new file mode 100644
index 000..2ad8f9b
--- /dev/null
+++ b/arch/arc/include/asm/bug.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_BUG_H
+#define _ASM_ARC_BUG_H
+
+#ifndef __ASSEMBLY__
+
+#include 
+
+struct task_struct;
+
+void show_regs(struct pt_regs *regs);
+void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs);
+void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
+   unsigned long address, unsigned long cause_reg);
+void die(const char *str, struct pt_regs *regs, unsigned long address,
+unsigned long cause_reg);
+
+#define BUG()  do {\
+   dump_stack();   \
+   pr_warn("Kernel BUG in %s: %s: %d!\n",  \
+   __FILE__, __func__,  __LINE__); \
+} while (0)
+
+#define HAVE_ARCH_BUG
+
+#include 
+
+#endif /* !__ASSEMBLY__ */
+
+#endif
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
new file mode 100644
index 000..30c72a4
--- /dev/null
+++ b/arch/arc/include/asm/cache.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ARC_ASM_CACHE_H
+#define __ARC_ASM_CACHE_H
+
+/* In case $$ not config, setup a dummy number for rest of kernel */
+#ifndef CONFIG_ARC_CACHE_LINE_SHIFT
+#define L1_CACHE_SHIFT 6
+#else
+#define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT
+#endif
+
+#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
+
+#endif /* _ASM_CACHE_H */
diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
new file mode 100644
index 000..147284f
--- /dev/null
+++ b/arch/arc/include/asm/elf.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_ELF_H
+#define __ASM_ARC_ELF_H
+
+#include 
+
+#define EM_ARCOMPACT   93
+
+/* Machine specific ELF Hdr flags */
+#define EF_ARC_OSABI_MSK   0x0f00
+#define EF_ARC_OSABI_ORIG  0x   /* MUST be zero for back-compat */
+#define EF_ARC_OSABI_V20x0200
+
+/* ARC Relocations (kernel Modules only) */
+#define  R_ARC_32  0x4
+#define  R_ARC_32_ME   0x1B
+#define  R_ARC_S25H_PCREL  0x10
+#define  R_ARC_S25W_PCREL  0x11
+
+typedef unsigned long elf_greg_t;
+typedef unsigned long elf_fpregset_t;
+
+
+/* core dump regs is in the order pt_regs, callee_regs, stop_pc (for gdb) */
+#define ELF_NGREG  ((sizeof(struct pt_regs) + sizeof(struct callee_regs) \
+ + sizeof(unsigned long)) / sizeof(elf_greg_t))
+
+typedef elf_greg_t elf_gre

[RFC PATCH v1 06/31] asm-generic headers: Allow yet more arch overrides in checksum.h

2012-11-07 Thread Vineet Gupta
arches can have more efficient implementation of these routines

Acked-by: Arnd Bergmann 
Signed-off-by: Vineet Gupta 
---
 include/asm-generic/checksum.h |4 
 lib/checksum.c |2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/asm-generic/checksum.h b/include/asm-generic/checksum.h
index c084767..59811df 100644
--- a/include/asm-generic/checksum.h
+++ b/include/asm-generic/checksum.h
@@ -38,12 +38,15 @@ extern __wsum csum_partial_copy_from_user(const void __user 
*src, void *dst,
csum_partial_copy((src), (dst), (len), (sum))
 #endif
 
+#ifndef ip_fast_csum
 /*
  * This is a version of ip_compute_csum() optimized for IP headers,
  * which always checksum on 4 octet boundaries.
  */
 extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+#endif
 
+#ifndef csum_fold
 /*
  * Fold a partial checksum
  */
@@ -54,6 +57,7 @@ static inline __sum16 csum_fold(__wsum csum)
sum = (sum & 0x) + (sum >> 16);
return (__force __sum16)~sum;
 }
+#endif
 
 #ifndef csum_tcpudp_nofold
 /*
diff --git a/lib/checksum.c b/lib/checksum.c
index 12dceb2..129775e 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -102,6 +102,7 @@ out:
 }
 #endif
 
+#ifndef ip_fast_csum
 /*
  * This is a version of ip_compute_csum() optimized for IP headers,
  * which always checksum on 4 octet boundaries.
@@ -111,6 +112,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
return (__force __sum16)~do_csum(iph, ihl*4);
 }
 EXPORT_SYMBOL(ip_fast_csum);
+#endif
 
 /*
  * computes the checksum of a memory block at buff, length len,
-- 
1.7.4.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/


[RFC PATCH v1 05/31] ARC: uaccess friends

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/segment.h |   24 ++
 arch/arc/include/asm/uaccess.h |  605 
 2 files changed, 629 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/segment.h
 create mode 100644 arch/arc/include/asm/uaccess.h

diff --git a/arch/arc/include/asm/segment.h b/arch/arc/include/asm/segment.h
new file mode 100644
index 000..da2c459
--- /dev/null
+++ b/arch/arc/include/asm/segment.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASMARC_SEGMENT_H
+#define __ASMARC_SEGMENT_H
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned long mm_segment_t;
+
+#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
+
+#define KERNEL_DS  MAKE_MM_SEG(0)
+#define USER_DSMAKE_MM_SEG(TASK_SIZE)
+
+#define segment_eq(a, b)   ((a) == (b))
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASMARC_SEGMENT_H */
diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
new file mode 100644
index 000..503c98d
--- /dev/null
+++ b/arch/arc/include/asm/uaccess.h
@@ -0,0 +1,605 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: June 2010
+ *-__clear_user( ) called multiple times during elf load was byte loop
+ *converted to do as much word clear as possible.
+ *
+ * vineetg: Dec 2009
+ *-Hand crafted constant propagation for "constant" copy sizes
+ *-stock kernel shrunk by 33K at -O3
+ *
+ * vineetg: Sept 2009
+ *-Added option to (UN)inline copy_(to|from)_user to reduce code sz
+ *-kernel shrunk by 200K even at -O3 (gcc 4.2.1)
+ *-Enabled when doing -Os
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_UACCESS_H
+#define _ASM_ARC_UACCESS_H
+
+#include 
+#include 
+#include   /* for generic string functions */
+
+
+#define __kernel_ok(segment_eq(get_fs(), KERNEL_DS))
+#define __user_ok(addr, sz)(((sz) <= TASK_SIZE) && \
+(((addr)+(sz)) <= get_fs()))
+#define __access_ok(addr, sz)  (unlikely(__kernel_ok) || \
+likely(__user_ok((addr), (sz
+
+static inline unsigned long
+__arc_copy_from_user(void *to, const void __user *from, unsigned long n)
+{
+   long res = 0;
+   char val;
+   unsigned long tmp1, tmp2, tmp3, tmp4;
+   unsigned long orig_n = n;
+
+   if (n == 0)
+   return 0;
+
+   /* unaligned */
+   if (((unsigned long)to & 0x3) || ((unsigned long)from & 0x3)) {
+
+   unsigned char tmp;
+
+   __asm__ __volatile__ (
+   "   mov.f   lp_count, %0\n"
+   "   lpnz 2f \n"
+   "1: ldb.ab  %1, [%3, 1] \n"
+   "   stb.ab  %1, [%2, 1] \n"
+   "   sub %0,%0,1 \n"
+   "2: ;nop\n"
+   "   .section .fixup, \"ax\" \n"
+   "   .align 4\n"
+   "3: j   2b  \n"
+   "   .previous   \n"
+   "   .section __ex_table, \"a\"  \n"
+   "   .align 4\n"
+   "   .word   1b, 3b  \n"
+   "   .previous   \n"
+
+   : "+r" (n),
+   /*
+* Note as an '&' earlyclobber operand to make sure the
+* temporary register inside the loop is not the same as
+*  FROM or TO.
+   */
+ "=&r" (tmp), "+r" (to), "+r" (from)
+   :
+   : "lp_count", "lp_start", "lp_end", "memory");
+
+   return n;
+   }
+
+   /*
+* Hand-crafted constant propagation to reduce code sz of the
+* laddered copy 16x,8,4,2,1
+*/
+   if (__builtin_constant_p(orig_n)) {
+   res = orig_n;
+
+   if (orig_n / 16) {
+   orig_n = orig_n % 16;
+
+   __asm__ __volatile__(
+   "   lsr   lp_count, %7,4\n"
+   "   lp3f\n"
+   "1: ld.ab   %3, [%2, 4] \n"
+   "11:ld.ab   %4, [%2, 4] \n"
+   "12:ld.ab   %5, [%

Re: [PATCH 2/3] spi / ACPI: add ACPI enumeration support

2012-11-07 Thread Mika Westerberg
On Tue, Nov 06, 2012 at 11:18:11PM +0100, Rafael J. Wysocki wrote:
> > How is the SPI controller different than this?  Is there some logical
> > difference that requires a different framework?  Or are you proposing
> > that we get rid of acpi_bus_register_driver() and migrate everything
> > to this new framework?
> 
> Yes, I do, but let's just do it gradually.

Bjorn, here is a concrete example how this is supposed to be used.

Lets say we have an existing SPI slave driver that we want to extend to
support enumeration from ACPI. Instead of writing acpi_driver glue for that
(and registering it using acpi_bus_register_driver()) what we do is simple
add these to the existing SPI driver:

#ifdef CONFIG_ACPI
static struct acpi_device_id my_spidrv_match[] = {
/* ACPI IDs here */
{ }
};
MODULE_DEVICE_TABLE(acpi, my_spidrv_match);
#endif

static struct spi_driver my_spidrv = {
...
.driver = {
.acpi_match_table = ACPI_PTR(my_spidrv_match),
},
};

The same thing works with platform, I2c and SPI drivers and can be extented
to others as well. If the driver needs to do some ACPI specific
configuration it can get the ACPI handle using its dev->acpi_handle.

The above example now supports both, normal SPI (where the devices are
enumerated by populating spi_board_info()) and ACPI. Adding support for
Device Tree is similar than ACPI so a single driver can support all three
easily at the same time.
--
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/


[RFC PATCH v1 03/31] ARC: atomic/bitops/cmpxchg/barriers

2012-11-07 Thread Vineet Gupta
This covers the UP / SMP (with no hardware assist for atomic r-m-w) as
well as ARC700 LLOCK/SCOND insns based.

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/atomic.h  |  232 ++
 arch/arc/include/asm/barrier.h |   42 
 arch/arc/include/asm/bitops.h  |  507 
 arch/arc/include/asm/cmpxchg.h |  143 +++
 arch/arc/include/asm/smp.h |   34 +++
 5 files changed, 958 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/atomic.h
 create mode 100644 arch/arc/include/asm/barrier.h
 create mode 100644 arch/arc/include/asm/bitops.h
 create mode 100644 arch/arc/include/asm/cmpxchg.h
 create mode 100644 arch/arc/include/asm/smp.h

diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h
new file mode 100644
index 000..543d496
--- /dev/null
+++ b/arch/arc/include/asm/atomic.h
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_ATOMIC_H
+#define _ASM_ARC_ATOMIC_H
+
+#if defined(__KERNEL__)
+
+#if !defined(__ASSEMBLY__)
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define atomic_read(v)  ((v)->counter)
+
+#ifdef CONFIG_ARC_HAS_LLSC
+
+#define atomic_set(v, i) (((v)->counter) = (i))
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+   unsigned int temp;
+
+   __asm__ __volatile__(
+   "1: llock   %0, [%1]\n"
+   "   add %0, %0, %2  \n"
+   "   scond   %0, [%1]\n"
+   "   bnz 1b  \n"
+   : "=&r"(temp)   /* Early clobber, to prevent reg reuse */
+   : "r"(&v->counter), "ir"(i)
+   : "cc");
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+   unsigned int temp;
+
+   __asm__ __volatile__(
+   "1: llock   %0, [%1]\n"
+   "   sub %0, %0, %2  \n"
+   "   scond   %0, [%1]\n"
+   "   bnz 1b  \n"
+   : "=&r"(temp)
+   : "r"(&v->counter), "ir"(i)
+   : "cc");
+}
+
+/* add and also return the new value */
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+   unsigned int temp;
+
+   __asm__ __volatile__(
+   "1: llock   %0, [%1]\n"
+   "   add %0, %0, %2  \n"
+   "   scond   %0, [%1]\n"
+   "   bnz 1b  \n"
+   : "=&r"(temp)
+   : "r"(&v->counter), "ir"(i)
+   : "cc");
+
+   return temp;
+}
+
+static inline int atomic_sub_return(int i, atomic_t *v)
+{
+   unsigned int temp;
+
+   __asm__ __volatile__(
+   "1: llock   %0, [%1]\n"
+   "   sub %0, %0, %2  \n"
+   "   scond   %0, [%1]\n"
+   "   bnz 1b  \n"
+   : "=&r"(temp)
+   : "r"(&v->counter), "ir"(i)
+   : "cc");
+
+   return temp;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+   unsigned int temp;
+
+   __asm__ __volatile__(
+   "1: llock   %0, [%1]\n"
+   "   bic %0, %0, %2  \n"
+   "   scond   %0, [%1]\n"
+   "   bnz 1b  \n"
+   : "=&r"(temp)
+   : "r"(addr), "ir"(mask)
+   : "cc");
+}
+
+#else  /* !CONFIG_ARC_HAS_LLSC */
+
+#ifndef CONFIG_SMP
+
+ /* violating atomic_xxx API locking protocol in UP for optimization sake */
+#define atomic_set(v, i) (((v)->counter) = (i))
+
+#else
+
+static inline void atomic_set(atomic_t *v, int i)
+{
+   /*
+* Independent of hardware support, all of the atomic_xxx() APIs need
+* to follow the same locking rules to make sure that a "hardware"
+* atomic insn (e.g. LD) doesn't clobber an "emulated" atomic insn
+* sequence
+*
+* Thus atomic_set() despite being 1 insn (and seemingly atomic)
+* requires the locking.
+*/
+   unsigned long flags;
+
+   atomic_ops_lock(flags);
+   v->counter = i;
+   atomic_ops_unlock(flags);
+}
+#endif
+
+/*
+ * Non hardware assisted Atomic-R-M-W
+ * Locking would change to irq-disabling only (UP) and spinlocks (SMP)
+ */
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+   unsigned long flags;
+
+   atomic_ops_lock(flags);
+   v->counter += i;
+   atomic_ops_unlock(flags);
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+   unsigned long flags;
+
+   atomic_ops_lock(flags);
+   v->counter -= i;
+   atomic_ops_unlock(flags);
+}
+
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+   unsigned long flags;
+   unsigned long temp;
+
+   atomic_ops_lock(flags);
+   temp = v->counter;
+   temp += i;
+   v->counter = temp;
+   atomic_ops_

[RFC PATCH v1 01/31] ARC: Generic Headers

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/Kbuild|   57 
 arch/arc/include/asm/asm-offsets.h |9 ++
 2 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/Kbuild
 create mode 100644 arch/arc/include/asm/asm-offsets.h

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
new file mode 100644
index 000..d6c037a
--- /dev/null
+++ b/arch/arc/include/asm/Kbuild
@@ -0,0 +1,57 @@
+include include/asm-generic/Kbuild.asm
+
+# 7-Oct-12: Jeremy Bennett . Some of these
+# headers, beyond those specified in the generic set are needed by user code.
+
+header-y += page.h
+header-y += cachectl.h
+
+generic-y += auxvec.h
+generic-y += bugs.h
+generic-y += bitsperlong.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += device.h
+generic-y += div64.h
+generic-y += emergency-restart.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += fb.h
+generic-y += ftrace.h
+generic-y += hardirq.h
+generic-y += hw_irq.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += irq_regs.h
+generic-y += kmap_types.h
+generic-y += kvm_para.h
+generic-y += local.h
+generic-y += local64.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += parport.h
+generic-y += percpu.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += resource.h
+generic-y += scatterlist.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
+generic-y += shmparam.h
+generic-y += siginfo.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += topology.h
+generic-y += types.h
+generic-y += ucontext.h
+generic-y += unaligned.h
+generic-y += user.h
+generic-y += vga.h
+generic-y += xor.h
diff --git a/arch/arc/include/asm/asm-offsets.h 
b/arch/arc/include/asm/asm-offsets.h
new file mode 100644
index 000..dad1876
--- /dev/null
+++ b/arch/arc/include/asm/asm-offsets.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
-- 
1.7.4.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 1/1] isdn: Make CONFIG_ISDN depend on CONFIG_NETDEVICES

2012-11-07 Thread Lee Jones
It doesn't make much sense to enable ISDN services if you don't
intend to connect to a network. Therefore insisting that ISDN
depends on NETDEVICES seems logical. We can then remove any
guards mentioning NETDEVICES inside all subordinate drivers.

This also has the nice side-effect of fixing the warning below
when ISDN_I4L && !CONFIG_NETDEVICES at compile time.

This patch fixes:
drivers/isdn/i4l/isdn_common.c: In function ‘isdn_ioctl’:
drivers/isdn/i4l/isdn_common.c:1278:8: warning: unused variable ‘s’ 
[-Wunused-variable]

Cc: Karsten Keil 
Cc: net...@vger.kernel.org
Signed-off-by: Lee Jones 
---
 drivers/isdn/Kconfig   |2 +-
 drivers/isdn/i4l/Kconfig   |2 +-
 drivers/isdn/i4l/isdn_common.c |4 
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
index a233ed5..86cd75a 100644
--- a/drivers/isdn/Kconfig
+++ b/drivers/isdn/Kconfig
@@ -4,7 +4,7 @@
 
 menuconfig ISDN
bool "ISDN support"
-   depends on NET
+   depends on NET && NETDEVICES
depends on !S390 && !UML
---help---
  ISDN ("Integrated Services Digital Network", called RNIS in France)
diff --git a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
index 2302fbe..9c6650e 100644
--- a/drivers/isdn/i4l/Kconfig
+++ b/drivers/isdn/i4l/Kconfig
@@ -6,7 +6,7 @@ if ISDN_I4L
 
 config ISDN_PPP
bool "Support synchronous PPP"
-   depends on INET && NETDEVICES
+   depends on INET
select SLHC
help
  Over digital connections such as ISDN, there is no need to
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 8c610fa..e2a945e 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1312,7 +1312,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
} else
return -EINVAL;
break;
-#ifdef CONFIG_NETDEVICES
case IIOCNETGPN:
/* Get peer phone number of a connected
 * isdn network interface */
@@ -1322,7 +1321,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
return isdn_net_getpeer(&phone, argp);
} else
return -EINVAL;
-#endif
default:
return -EINVAL;
}
@@ -1352,7 +1350,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
case IIOCNETLCR:
printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not 
enabled\n");
return -ENODEV;
-#ifdef CONFIG_NETDEVICES
case IIOCNETAIF:
/* Add a network-interface */
if (arg) {
@@ -1491,7 +1488,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
return -EFAULT;
return isdn_net_force_hangup(name);
break;
-#endif  /* CONFIG_NETDEVICES */
case IIOCSETVER:
dev->net_verbose = arg;
printk(KERN_INFO "isdn: Verbose-Level is %d\n", 
dev->net_verbose);
-- 
1.7.9.5

--
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 8/9] isdn: Make CONFIG_ISDN depend on CONFIG_NETDEVICES

2012-11-07 Thread Lee Jones
On Tue, 06 Nov 2012, David Miller wrote:

> From: Lee Jones 
> Date: Mon, 5 Nov 2012 11:31:26 +0100
> 
> > Does something like look like a better solution?
> > 
> > Author: Lee Jones 
> > Date:   Sat Nov 3 22:06:02 2012 +0100
> > 
> > isdn: Make CONFIG_ISDN depend on CONFIG_NETDEVICES
> 
> Yes, it looks good, please resubmit it formally.

Done. Thanks for reviewing.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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/3] spi / ACPI: add ACPI enumeration support

2012-11-07 Thread Mika Westerberg
On Tue, Nov 06, 2012 at 11:36:08PM +0100, Rafael J. Wysocki wrote:
> > 
> > OK, but then we need to pass the information obtained from _CRS
> > (presumably after some adjustments through _SRS) to drivers, or rather to
> > things like the SPI core, I2C core etc. so that they can create device
> > objects for drivers to bind to and quite frankly I don't see why not to use
> > ACPI resources for that.
> 
> Nevertheless, the routines for parsing those resources should belong
> to the ACPI core, mostly to avoid code duplication.

Rafael,

So is the idea now that the ACPI core parses the resources and passes them
forward via struct acpi_device? I'm just wondering how to proceed with
these I2C and SPI enumeration patches.

Thanks.
--
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] Revert "serial: omap: fix software flow control"

2012-11-07 Thread Andreas Bießmann
On 16.10.2012 16:09, Felipe Balbi wrote:
> This reverts commit 957ee7270d632245b43f6feb0e70d9a5e9ea6cf6
> (serial: omap: fix software flow control).
> 
> As Russell has pointed out, that commit isn't fixing
> Software Flow Control at all, and it actually makes
> it even more broken.
> 
> It was agreed to revert this commit and use Russell's
> latest UART patches instead.
> 
> Cc: Russell King 
> Signed-off-by: Felipe Balbi 

since 957ee7270d632245b43f6feb0e70d9a5e9ea6cf6 made it into stable (at
least 3.4) I think it would be good decision to also apply this revert
to stable until a working solution exists.

Best regards

Andreas Bießmann

> ---
> 
> Hi Greg,
> 
> you might prefer to do the revert yourself, in that case just
> revert commit 957ee7270d632245b43f6feb0e70d9a5e9ea6cf6.
> 
> thanks
> 
>  arch/arm/plat-omap/include/plat/omap-serial.h |  4 ++--
>  drivers/tty/serial/omap-serial.c  | 12 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h 
> b/arch/arm/plat-omap/include/plat/omap-serial.h
> index f4a4cd0..1957a85 100644
> --- a/arch/arm/plat-omap/include/plat/omap-serial.h
> +++ b/arch/arm/plat-omap/include/plat/omap-serial.h
> @@ -40,10 +40,10 @@
>  #define OMAP_UART_WER_MOD_WKUP   0X7F
>  
>  /* Enable XON/XOFF flow control on output */
> -#define OMAP_UART_SW_TX  0x8
> +#define OMAP_UART_SW_TX  0x04
>  
>  /* Enable XON/XOFF flow control on input */
> -#define OMAP_UART_SW_RX  0x2
> +#define OMAP_UART_SW_RX  0x04
>  
>  #define OMAP_UART_SYSC_RESET 0X07
>  #define OMAP_UART_TCR_TRIG   0X0F
> diff --git a/drivers/tty/serial/omap-serial.c 
> b/drivers/tty/serial/omap-serial.c
> index 6ede6fd..6d3d26a 100644
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -671,19 +671,19 @@ serial_omap_configure_xonxoff
>  
>   /*
>* IXON Flag:
> -  * Flow control for OMAP.TX
> -  * OMAP.RX should listen for XON/XOFF
> +  * Enable XON/XOFF flow control on output.
> +  * Transmit XON1, XOFF1
>*/
>   if (termios->c_iflag & IXON)
> - up->efr |= OMAP_UART_SW_RX;
> + up->efr |= OMAP_UART_SW_TX;
>  
>   /*
>* IXOFF Flag:
> -  * Flow control for OMAP.RX
> -  * OMAP.TX should send XON/XOFF
> +  * Enable XON/XOFF flow control on input.
> +  * Receiver compares XON1, XOFF1.
>*/
>   if (termios->c_iflag & IXOFF)
> - up->efr |= OMAP_UART_SW_TX;
> + up->efr |= OMAP_UART_SW_RX;
>  
>   serial_out(up, UART_EFR, up->efr | UART_EFR_ECB);
>   serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
> 

--
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/


[RFC PATCH v1 20/31] ARC: MMU Exception Handling

2012-11-07 Thread Vineet Gupta
* MMU I-TLB / D-TLB Miss Exceptions
  - Fast Path TLB Refill Handler
  - slowpath TLB creation via do_page_fault() -> update_mmu_cache()
* Duplicate PD Exception Handler

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/arcregs.h  |   90 ++
 arch/arc/include/asm/tlb-mmu1.h |  104 
 arch/arc/include/asm/tlb.h  |   41 +
 arch/arc/mm/tlb.c   |  252 
 arch/arc/mm/tlbex.S |  351 +++
 5 files changed, 838 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/tlb-mmu1.h
 create mode 100644 arch/arc/include/asm/tlb.h
 create mode 100644 arch/arc/mm/tlbex.S

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index c12eb9b..aedfbf1 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -13,6 +13,7 @@
 
 /* Build Configuration Registers */
 #define ARC_REG_VECBASE_BCR0x68
+#define ARC_REG_MMU_BCR0x6f
 
 /* status32 Bits Positions */
 #define STATUS_H_BIT   0   /* CPU Halted */
@@ -36,6 +37,34 @@
 #define STATUS_U_MASK  (1<= 2)
+#define TLBWriteNI  0x5/* write JTLB without inv uTLBs */
+#define TLBIVUTLB   0x6/* explicitly inv uTLBs */
+#else
+#undef TLBWriteNI  /* These cmds don't exist on older MMU */
+#undef TLBIVUTLB
+#endif
+
 /* Instruction cache related Auxiliary registers */
 #define ARC_REG_IC_BCR 0x77/* Build Config reg */
 #define ARC_REG_IC_IVIC0x10
@@ -205,6 +272,24 @@ struct arc_fpu {
  * Build Configuration Registers, with encoded hardware config
  */
 
+struct bcr_mmu_1_2 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+   unsigned int ver:8, ways:4, sets:4, u_itlb:8, u_dtlb:8;
+#else
+   unsigned int u_dtlb:8, u_itlb:8, sets:4, ways:4, ver:8;
+#endif
+};
+
+struct bcr_mmu_3 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+   unsigned int ver:8, ways:4, sets:4, osm:1, reserv:3, pg_sz:4,
+u_itlb:4, u_dtlb:4;
+#else
+   unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, reserv:3, osm:1, sets:4,
+ways:4, ver:8;
+#endif
+};
+
 struct bcr_cache {
 #ifdef CONFIG_CPU_BIG_ENDIAN
unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
@@ -218,12 +303,17 @@ struct bcr_cache {
  * Generic structures to hold build configuration used at runtime
  */
 
+struct cpuinfo_arc_mmu {
+   unsigned int ver, pg_sz, sets, ways, u_dtlb, u_itlb, num_tlb;
+};
+
 struct cpuinfo_arc_cache {
unsigned int has_aliasing, sz, line_len, assoc, ver;
 };
 
 struct cpuinfo_arc {
struct cpuinfo_arc_cache icache, dcache;
+   struct cpuinfo_arc_mmu mmu;
 };
 
 extern struct cpuinfo_arc cpuinfo_arc700[];
diff --git a/arch/arc/include/asm/tlb-mmu1.h b/arch/arc/include/asm/tlb-mmu1.h
new file mode 100644
index 000..a5ff961
--- /dev/null
+++ b/arch/arc/include/asm/tlb-mmu1.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_TLB_MMU_V1_H__
+#define __ASM_TLB_MMU_V1_H__
+
+#if defined(__ASSEMBLY__) && defined(CONFIG_ARC_MMU_VER == 1)
+
+#include 
+
+.macro TLB_WRITE_HEURISTICS
+
+#define JH_HACK1
+#undef JH_HACK2
+#undef JH_HACK3
+
+#ifdef JH_HACK3
+; Calculate set index for 2-way MMU
+; -avoiding use of GetIndex from MMU
+;   and its unpleasant LFSR pseudo-random sequence
+;
+; r1 = TLBPD0 from TLB_RELOAD above
+;
+; -- jh_ex_way_set not cleared on startup
+;didn't want to change setup.c
+;hence extra instruction to clean
+;
+; -- should be in cache since in same line
+;as r0/r1 saves above
+;
+ld  r0,[jh_ex_way_sel]  ; victim pointer
+and r0,r0,1 ; clean
+xor.f   r0,r0,1 ; flip
+st  r0,[jh_ex_way_sel]  ; store back
+asr r0,r1,12; get set # <<1, note bit 12=R=0
+or.nz   r0,r0,1 ; set way bit
+and r0,r0,0xff  ; clean
+sr  r0,[ARC_REG_TLBINDEX]
+#endif
+
+#ifdef JH_HACK2
+; JH hack #2
+;  Faster than hack #1 in non-thrash case, but hard-coded for 2-way MMU
+;  Slower in thrash case (where it matters) because more code is executed
+;  Inefficient due to two-register paradigm of this miss handler
+;
+/* r1 = data TLBPD0 at this point */
+lr  r0,[eret]   /* instruction address */
+xor r0,r0,r1/* compare set #   */
+and.f   r0,r0,0x000fe000/* 2-way MMU mask  */
+bne 88f /* not in same set - no need to probe */
+
+lr  r0,[eret]   /* instruction address */
+and r0,r0,PAGE_MASK /* VPN of instruction address */
+; lr  r1,[ARC_REG_TLBPD0] /* Data VPN+ASID - already in r1 from 
TLB_RELOAD*/
+and r1,r1,0xff  /* Data ASID */
+or  r0,r0,r1/* Instruction address 

[RFC PATCH v1 28/31] ARC: split ret_from_fork, simplify kernel_thread()

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/entry.S   |8 
 arch/arc/kernel/process.c |   32 +---
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index fe9a17c..46d0280 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -580,6 +580,14 @@ ARC_ENTRY ret_from_fork
b @ret_from_exception
 ARC_EXIT ret_from_fork
 
+ARC_ENTRY ret_from_kernel_thread
+   bl  @schedule_tail
+   ld  r1, [sp, PT_r1]
+   j.d [r1]
+   ld  r0, [sp, PT_r0]
+   j   @sys_exit
+ARC_EXIT ret_from_kernel_thread
+
 ;### Special Sys Call Wrappers ##
 
 ARC_ENTRY sys_execve_wrapper
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index c116fa5..fee3e11 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -142,24 +142,13 @@ void cpu_idle(void)
}
 }
 
-void kernel_thread_helper(void)
-{
-   __asm__ __volatile__(
-   "mov   r0, r2   \n\t"
-   "mov   r1, r3   \n\t"
-   "j [r1] \n\t");
-}
-
 int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
 {
-   struct pt_regs regs;
+   struct pt_regs regs = {
+   .r0 = (unsigned long)arg,
+   .r1 = (unsigned long)fn
+   };
 
-   memset(®s, 0, sizeof(regs));
-
-   regs.r2 = (unsigned long)arg;
-   regs.r3 = (unsigned long)fn;
-   regs.blink = (unsigned long)do_exit;
-   regs.ret = (unsigned long)kernel_thread_helper;
regs.status32 = read_aux_reg(0xa);
 
/* Ok, create the new process.. */
@@ -170,6 +159,7 @@ int kernel_thread(int (*fn) (void *), void *arg, unsigned 
long flags)
 EXPORT_SYMBOL(kernel_thread);
 
 asmlinkage void ret_from_fork(void);
+asmlinkage void ret_from_kernel_thread(void) __attribute__((noreturn));
 
 /* Layout of Child kernel mode stack as setup at the end of this function is
  *
@@ -226,18 +216,22 @@ int copy_thread(unsigned long clone_flags,
/* Copy parents pt regs on child's kernel mode stack */
*c_regs = *regs;
 
-   /* __switch_to expects FP(0), BLINK(return addr) at top of stack */
-   childksp[0] = 0;/* for POP fp */
-   childksp[1] = (unsigned long)ret_from_fork; /* for POP blink */
-
if (!(user_mode(regs))) {
c_regs->sp =
(unsigned long)task_thread_info(p) + (THREAD_SIZE - 4);
+
+   /* __switch_to expects FP(0), BLINK(return addr) at top */
+   childksp[0] = 0;/* fp */
+   childksp[1] = (unsigned long)ret_from_kernel_thread; /* blink */
return 0;
}
 
/*- User Task Only --*/
 
+   /* __switch_to expects FP(0), BLINK(return addr) at top of stack */
+   childksp[0] = 0;/* for POP fp */
+   childksp[1] = (unsigned long)ret_from_fork; /* for POP blink */
+
c_regs->sp = usp;
c_regs->r0 = 0; /* fork returns 0 in child */
 
-- 
1.7.4.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: mm: NULL ptr deref in anon_vma_interval_tree_verify

2012-11-07 Thread Bob Liu
Hi Michel,

On Wed, Nov 7, 2012 at 11:54 AM, Michel Lespinasse  wrote:
> On Tue, Nov 6, 2012 at 12:24 AM, Michel Lespinasse  wrote:
>> On Mon, Nov 5, 2012 at 5:41 AM, Michel Lespinasse  wrote:
>>> On Sun, Nov 4, 2012 at 8:44 PM, Michel Lespinasse  wrote:
 On Sun, Nov 4, 2012 at 8:14 PM, Bob Liu  wrote:
> Hmm, I attached a simple fix patch.

 Reviewed-by: Michel Lespinasse 
 (also ran some tests with it, but I could never reproduce the original
 issue anyway).
>>>
>>> Wait a minute, this is actually wrong. You need to call
>>> vma_lock_anon_vma() / vma_unlock_anon_vma() to avoid the issue with
>>> vma->anon_vma == NULL.
>>>
>>> I'll fix it and integrate it into my next patch series, which I intend
>>> to send later today. (I am adding new code into validate_mm(), so that
>>> it's easier to have it in the same patch series to avoid merge
>>> conflicts)
>>
>> Hmmm, now I'm getting confused about anon_vma locking again :/
>>
>> As Hugh privately remarked to me, the same_vma linked list is supposed
>> to be protected by exclusive mmap_sem ownership, not by anon_vma lock.
>> So now looking at it a bit more, I'm not sure what race we're
>> preventing by taking the anon_vma lock in validate_mm() ???
>
> Looking at it a bit more:
>
> the same_vma linked list is *generally* protected by *exclusive*
> mmap_sem ownership. However, in expand_stack() we only have *shared*
> mmap_sem ownership, so that two concurrent expand_stack() calls
> (possibly on different vmas that have a different anon_vma lock) could
> race with each other. For this reason we do need the validate_mm()
> taking each vma's anon_vma lock (if any) before calling
> anon_vma_interval_tree_verify().
>

Sorry for the late response.
Actually my origin concern was:
avc was removed in some race place which caused the NULL pointer deref
in validate_mm().

But after looking it more, i didn't find out the race place.
I think avc only freed at free_pgtable() --> unlink_anon_vmas().

> While this justifies Bob's patch, this does not explain Sasha's
> reports - in both of them the backtrace did not involve
> expand_stack(), and there should be exclusive mmap_sem ownership, so
> I'm still unclear as to what could be causing Sasha's issue.
>
> Sasha, how reproduceable is this ?
>
> Also, would the following change print something when the issue triggers ?
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 619b280505fe..4c09e7ebcfa7 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -404,8 +404,13 @@ void validate_mm(struct mm_struct *mm)
> while (vma) {
> struct anon_vma_chain *avc;
> vma_lock_anon_vma(vma);

And for our patch, i think vma_lock_anon_vma()/anon_vma_lock() is used
to protect
the same_anon_vma list.
It seems not suitable here.

> -   list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
> +   list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) {
> +   if (avc->vma != vma) {
> +   printk("avc->vma %p vma %p\n", avc->vma, vma);
> +   bug = 1;
> +   }
> anon_vma_interval_tree_verify(avc);
> +   }
> vma_unlock_anon_vma(vma);
> highest_address = vma->vm_end;
> vma = vma->vm_next;
>
> --
> Michel "Walken" Lespinasse
> A program is never fully debugged until the last user dies.

-- 
Thanks,
--Bob
--
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/


[RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/Kbuild|2 +
 arch/arc/Kconfig   |  337 
 arch/arc/Kconfig.debug |   34 
 arch/arc/Makefile  |  115 
 arch/arc/boot/Makefile |   27 +++
 arch/arc/include/asm/Kbuild|1 +
 arch/arc/include/asm/vmlinux.lds.h |   12 ++
 arch/arc/kernel/Makefile   |   16 ++
 arch/arc/kernel/arcksyms.c |   56 ++
 arch/arc/kernel/asm-offsets.c  |   46 +
 arch/arc/kernel/vmlinux.lds.S  |  117 +
 arch/arc/lib/Makefile  |9 +
 arch/arc/mm/Makefile   |   10 +
 arch/arc/plat-arcfpga/Kconfig  |   33 
 arch/arc/plat-arcfpga/Makefile |9 +
 15 files changed, 824 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/Kbuild
 create mode 100644 arch/arc/Kconfig
 create mode 100644 arch/arc/Kconfig.debug
 create mode 100644 arch/arc/Makefile
 create mode 100644 arch/arc/boot/Makefile
 create mode 100644 arch/arc/include/asm/vmlinux.lds.h
 create mode 100644 arch/arc/kernel/Makefile
 create mode 100644 arch/arc/kernel/arcksyms.c
 create mode 100644 arch/arc/kernel/asm-offsets.c
 create mode 100644 arch/arc/kernel/vmlinux.lds.S
 create mode 100644 arch/arc/lib/Makefile
 create mode 100644 arch/arc/mm/Makefile
 create mode 100644 arch/arc/plat-arcfpga/Kconfig
 create mode 100644 arch/arc/plat-arcfpga/Makefile

diff --git a/arch/arc/Kbuild b/arch/arc/Kbuild
new file mode 100644
index 000..082d329
--- /dev/null
+++ b/arch/arc/Kbuild
@@ -0,0 +1,2 @@
+obj-y += kernel/
+obj-y += mm/
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
new file mode 100644
index 000..d6983afa
--- /dev/null
+++ b/arch/arc/Kconfig
@@ -0,0 +1,337 @@
+#
+# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+
+config ARC
+   def_bool y
+   select ARCH_WANT_IPC_PARSE_VERSION
+   # ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+   # DEVTMPS in turn needs HOTPLUG
+   select DEVTMPFS if !INITRAMFS_SOURCE=""
+   select GENERIC_ATOMIC64
+   select GENERIC_CLOCKEVENTS
+   select GENERIC_FIND_FIRST_BIT
+   # for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+   select GENERIC_IRQ_SHOW
+   select GENERIC_PENDING_IRQ if SMP
+   select GENERIC_SMP_IDLE_THREAD
+   select HAVE_GENERIC_HARDIRQS
+   select HOTPLUG if !INITRAMFS_SOURCE=""
+   select MODULES_USE_ELF_RELA
+
+config SCHED_OMIT_FRAME_POINTER
+   def_bool y
+
+config GENERIC_CSUM
+   def_bool y
+
+config RWSEM_GENERIC_SPINLOCK
+   def_bool y
+
+# for old_[ug]id_t - do we need this ?
+config UID16
+   def_bool y
+
+config ARCH_FLATMEM_ENABLE
+   def_bool y
+
+config MMU
+   def_bool y
+
+config NO_IOPORT
+   def_bool y
+
+config GENERIC_CALIBRATE_DELAY
+   def_bool y
+
+config GENERIC_HWEIGHT
+   def_bool y
+
+config BINFMT_ELF
+   def_bool y
+
+config STACKTRACE_SUPPORT
+   def_bool y
+   select STACKTRACE
+
+config HAVE_LATENCYTOP_SUPPORT
+   def_bool y
+
+config NO_DMA
+   def_bool n
+
+source "init/Kconfig"
+source "kernel/Kconfig.freezer"
+
+menu "ARC Architecture Configuration"
+
+choice
+   prompt "ARC Platform"
+   default ARC_PLAT_FPGA_LEGACY
+
+config ARC_PLAT_FPGA_LEGACY
+   bool "\"Legacy\" ARC FPGA dev platform"
+   help
+ Support for ARC development platforms, provided by Synopsys.
+ These are based on FPGA or ISS. e.g.
+ - ARCAngel4
+ - ML509
+ - MetaWare ISS
+
+#New platform adds here
+endchoice
+
+menu "ARC CPU Configuration"
+
+choice
+   prompt "ARC Core"
+   default ARC_CPU_770
+
+config ARC_CPU_750D
+   bool "ARC750D"
+   help
+ Support for ARC750 core
+
+config ARC_CPU_770
+   bool "ARC770"
+   select ARC_CPU_REL_4_10
+   help
+ Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
+ This core has a bunch of cool new features:
+ -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
+   Shared Address Spaces (for sharing TLB entires in MMU)
+ -Caches: New Prog Model, Region Flush
+ -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
+
+endchoice
+
+config CPU_BIG_ENDIAN
+   bool "Enable Big Endian Mode"
+   default n
+   help
+ Build kernel for Big Endian Mode of ARC CPU
+
+menuconfig ARC_CACHE
+   bool "Enable Cache Support"
+   default y
+
+if ARC_CACHE
+
+config ARC_CACHE_LINE_SHIFT
+   int "Cache Line Length (as power of 2)"
+   range 5 7
+   default "6"
+   help
+ Starting with ARC700 4.9, Cache line length is configurable,
+ Th

[RFC PATCH v1 30/31] ARC: switch to generic kernel_execve() and sys_execve()

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/ptrace.h |8 +++
 arch/arc/include/asm/unistd.h |2 +
 arch/arc/kernel/entry.S   |   17 ---
 arch/arc/kernel/process.c |   44 -
 arch/arc/kernel/sys.c |1 -
 5 files changed, 19 insertions(+), 53 deletions(-)

diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index ee31d8a..bc2229f 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -120,6 +120,14 @@ struct user_regs_struct {
 #define in_syscall(regs) (((regs->orig_r8) >= 0 && \
   (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
 
+#define current_pt_regs()  \
+({ \
+   /* open-coded current_thread_info() */  \
+   register unsigned long sp asm ("sp");   \
+   unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
+   (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \
+})
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_PTRACE_H */
diff --git a/arch/arc/include/asm/unistd.h b/arch/arc/include/asm/unistd.h
index 754d588..09144a8 100644
--- a/arch/arc/include/asm/unistd.h
+++ b/arch/arc/include/asm/unistd.h
@@ -22,6 +22,8 @@
 #define __ARCH_WANT_SYSCALL_NO_FLAGS
 #define __ARCH_WANT_SYSCALL_OFF_T
 #define __ARCH_WANT_SYSCALL_DEPRECATED
+#define __ARCH_WANT_KERNEL_EXECVE
+#define __ARCH_WANT_SYS_EXECVE
 
 #define sys_mmap2 sys_mmap_pgoff
 
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index 46d0280..deb2652 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -588,15 +588,16 @@ ARC_ENTRY ret_from_kernel_thread
j   @sys_exit
 ARC_EXIT ret_from_kernel_thread
 
-;### Special Sys Call Wrappers ##
-
-ARC_ENTRY sys_execve_wrapper
-   ; copy pointer to pt_regs as a parameter
-   mov  r3, sp
-   bl  @sys_execve
+; When we land here, pt_regs have already been updated in-place correctly
+; A pointer to them is also passed by kernel_execve, we just need to make sure
+; that SP is set to point to them.
+ARC_ENTRY ret_from_kernel_execve
+   ; Force SP to "normal" pt_regs just populated.
+   b.d   ret_from_system_call
+   mov   sp, r0
+ARC_EXIT ret_from_kernel_execve
 
-   b ret_from_system_call
-ARC_EXIT sys_execve_wrapper
+;### Special Sys Call Wrappers ##
 
 ; TBD: call do_fork directly from here
 ARC_ENTRY sys_fork_wrapper
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index d2bb27f..65dfa89 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -53,50 +53,6 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned 
long newsp,
   child_tidptr);
 }
 
-int sys_execve(const char __user *filenamei, const char __user *__user *argv,
-  const char __user *__user *envp, struct pt_regs *regs)
-{
-   long error;
-   struct filename *filename;
-
-   filename = getname(filenamei);
-   error = PTR_ERR(filename);
-   if (IS_ERR(filename))
-   goto out;
-
-   error = do_execve(filename->name, argv, envp, regs);
-   putname(filename);
-out:
-   return error;
-}
-
-int kernel_execve(const char *filename, const char *const argv[],
- const char *const envp[])
-{
-   /*
-* Although the arguments (order, number) to this function are
-* same as sys call, we don't need to setup args in regs again.
-* However in case mainline kernel changes the order of args to
-* kernel_execve, that assumtion will break.
-* So to be safe, let gcc know the args for sys call.
-* If they match no extra code will be generated
-*/
-   register int arg2 asm("r1") = (int)argv;
-   register int arg3 asm("r2") = (int)envp;
-
-   register int filenm_n_ret asm("r0") = (int)filename;
-
-   __asm__ __volatile__(
-   "mov   r8, %1   \n\t"
-   "trap0  \n\t"
-   : "+r"(filenm_n_ret)
-   : "i"(__NR_execve), "r"(arg2), "r"(arg3)
-   : "r8", "memory");
-
-   return filenm_n_ret;
-}
-EXPORT_SYMBOL(kernel_execve);
-
 SYSCALL_DEFINE1(arc_settls, void *, user_tls_data_ptr)
 {
task_thread_info(current)->thr_ptr = (unsigned int)user_tls_data_ptr;
diff --git a/arch/arc/kernel/sys.c b/arch/arc/kernel/sys.c
index 4c30345..f6bdd07 100644
--- a/arch/arc/kernel/sys.c
+++ b/arch/arc/kernel/sys.c
@@ -5,7 +5,6 @@
 
 #include 
 
-#define sys_execve sys_execve_wrapper
 #define sys_clone  sys_clone_wrapper
 #define sys_fork   sys_fork_wrapper
 #define sys_vfork  sys_vfork_wrapper
-- 
1.7.4.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 

[RFC PATCH v1 21/31] ARC: TLB flush Handling

2012-11-07 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/tlb.h  |   17 ++
 arch/arc/include/asm/tlbflush.h |   28 
 arch/arc/mm/tlb.c   |  311 +++
 3 files changed, 356 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/tlbflush.h

diff --git a/arch/arc/include/asm/tlb.h b/arch/arc/include/asm/tlb.h
index b571e12..3eb2ce0 100644
--- a/arch/arc/include/asm/tlb.h
+++ b/arch/arc/include/asm/tlb.h
@@ -21,6 +21,23 @@
 
 #ifndef __ASSEMBLY__
 
+#define tlb_flush(tlb) local_flush_tlb_mm((tlb)->mm)
+
+/*
+ * This pair is called at time of munmap/exit to flush cache and TLB entries
+ * for mappings being torn down.
+ * 1) cache-flush part -implemented via tlb_start_vma( ) can be NOP (for now)
+ *as we don't support aliasing configs in our VIPT D$.
+ * 2) tlb-flush part - implemted via tlb_end_vma( ) can be NOP as well-
+ *albiet for difft reasons - its better handled by moving to new ASID
+ *
+ * Note, read http://lkml.org/lkml/2004/1/15/6
+ */
+#define tlb_start_vma(tlb, vma)
+#define tlb_end_vma(tlb, vma)
+
+#define __tlb_remove_tlb_entry(tlb, ptep, address)
+
 #include 
 #include 
 
diff --git a/arch/arc/include/asm/tlbflush.h b/arch/arc/include/asm/tlbflush.h
new file mode 100644
index 000..b2f9bc7
--- /dev/null
+++ b/arch/arc/include/asm/tlbflush.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_TLBFLUSH__
+#define __ASM_ARC_TLBFLUSH__
+
+#include 
+
+void local_flush_tlb_all(void);
+void local_flush_tlb_mm(struct mm_struct *mm);
+void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
+void local_flush_tlb_kernel_range(unsigned long start, unsigned long end);
+void local_flush_tlb_range(struct vm_area_struct *vma,
+  unsigned long start, unsigned long end);
+
+/* XXX: Revisit for SMP */
+#define flush_tlb_range(vma, s, e) local_flush_tlb_range(vma, s, e)
+#define flush_tlb_page(vma, page)  local_flush_tlb_page(vma, page)
+#define flush_tlb_kernel_range(s, e)   local_flush_tlb_kernel_range(s, e)
+#define flush_tlb_all()local_flush_tlb_all()
+#define flush_tlb_mm(mm)   local_flush_tlb_mm(mm)
+
+#endif
diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c
index 41afc84..c10111d 100644
--- a/arch/arc/mm/tlb.c
+++ b/arch/arc/mm/tlb.c
@@ -6,13 +6,97 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
+ *
+ * vineetg: Aug 2011
+ *  -Reintroduce duplicate PD fixup - some customer chips still have the issue
+ *
+ * vineetg: May 2011
+ *  -No need to flush_cache_page( ) for each call to update_mmu_cache()
+ *   some of the LMBench tests improved amazingly
+ *  = page-fault thrice as fast (75 usec to 28 usec)
+ *  = mmap twice as fast (9.6 msec to 4.6 msec),
+ *  = fork (5.3 msec to 3.7 msec)
+ *
+ * vineetg: April 2011 :
+ *  -MMU v3: PD{0,1} bits layout changed: They don't overlap anymore,
+ *  helps avoid a shift when preparing PD0 from PTE
+ *
+ * vineetg: April 2011 : Preparing for MMU V3
+ *  -MMU v2/v3 BCRs decoded differently
+ *  -Remove TLB_SIZE hardcoding as it's variable now: 256 or 512
+ *  -tlb_entry_erase( ) can be void
+ *  -local_flush_tlb_range( ):
+ *  = need not "ceil" @end
+ *  = walks MMU only if range spans < 32 entries, as opposed to 256
+ *
+ * Vineetg: Sept 10th 2008
+ *  -Changes related to MMU v2 (Rel 4.8)
+ *
+ * Vineetg: Aug 29th 2008
+ *  -In TLB Flush operations (Metal Fix MMU) there is a explict command to
+ *flush Micro-TLBS. If TLB Index Reg is invalid prior to TLBIVUTLB cmd,
+ *it fails. Thus need to load it with ANY valid value before invoking
+ *TLBIVUTLB cmd
+ *
+ * Vineetg: Aug 21th 2008:
+ *  -Reduced the duration of IRQ lockouts in TLB Flush routines
+ *  -Multiple copies of TLB erase code seperated into a "single" function
+ *  -In TLB Flush routines, interrupt disabling moved UP to retrieve ASID
+ *   in interrupt-safe region.
+ *
+ * Vineetg: April 23rd Bug #93131
+ *Problem: tlb_flush_kernel_range() doesnt do anything if the range to
+ *  flush is more than the size of TLB itself.
+ *
+ * Rahul Trivedi : Codito Technologies 2004
  */
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+/* Need for ARC MMU v2
+ *
+ * ARC700 MMU-v1 had a Joint-TLB for Code and Data and is 2 way set-assoc.
+ * For a memcpy operation with 3 players (src/dst/code) such that all 3 pages
+ * map into same set, there would be contention for the 2 ways causing severe
+ * Thrashing.
+ *
+ * Although J-TLB is 2 way set assoc, ARC700 caches J-TLB int

[RFC PATCH v1 23/31] ARC: I/O and DMA Mappings

2012-11-07 Thread Vineet Gupta
TBD: Do we need early ioremap support like openrisc

Signed-off-by: Vineet Gupta 
---
 arch/arc/include/asm/dma-mapping.h|  176 +
 arch/arc/include/asm/dma.h|   14 ++
 arch/arc/include/asm/io.h |   26 
 arch/arc/mm/dma.c |   91 +
 arch/arc/mm/ioremap.c |   62 +
 arch/arc/plat-arcfpga/include/plat/dma_addr.h |   45 +++
 6 files changed, 414 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/dma-mapping.h
 create mode 100644 arch/arc/include/asm/dma.h
 create mode 100644 arch/arc/include/asm/io.h
 create mode 100644 arch/arc/mm/dma.c
 create mode 100644 arch/arc/mm/ioremap.c
 create mode 100644 arch/arc/plat-arcfpga/include/plat/dma_addr.h

diff --git a/arch/arc/include/asm/dma-mapping.h 
b/arch/arc/include/asm/dma-mapping.h
new file mode 100644
index 000..ea0f56f
--- /dev/null
+++ b/arch/arc/include/asm/dma-mapping.h
@@ -0,0 +1,176 @@
+/*
+ * DMA Mapping glue for ARC
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ASM_ARC_DMA_MAPPING_H
+#define ASM_ARC_DMA_MAPPING_H
+
+#include 
+#include 
+
+void *dma_alloc_noncoherent(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t gfp);
+
+void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
+ dma_addr_t dma_handle);
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+dma_addr_t *dma_handle, gfp_t gfp);
+
+void dma_free_coherent(struct device *dev, size_t size, void *kvaddr,
+  dma_addr_t dma_handle);
+
+/*
+ * streaming DMA Mapping API...
+ * CPU accesses page via normal paddr, thus needs to explicitly made
+ * consistent before each use
+ */
+
+static inline void __inline_dma_cache_sync(unsigned long paddr, size_t size,
+  enum dma_data_direction dir)
+{
+   switch (dir) {
+   case DMA_FROM_DEVICE:
+   dma_cache_inv(paddr, size);
+   break;
+   case DMA_TO_DEVICE:
+   dma_cache_wback(paddr, size);
+   break;
+   case DMA_BIDIRECTIONAL:
+   dma_cache_wback_inv(paddr, size);
+   break;
+   default:
+   pr_err("Invalid DMA dir [%d] for OP @ %lx\n", dir, paddr);
+   }
+}
+
+void __arc_dma_cache_sync(unsigned long paddr, size_t size,
+ enum dma_data_direction dir);
+
+#define _dma_cache_sync(addr, sz, dir) \
+do {   \
+   if (__builtin_constant_p(dir))  \
+   __inline_dma_cache_sync(addr, sz, dir); \
+   else\
+   __arc_dma_cache_sync(addr, sz, dir);\
+}  \
+while (0);
+
+static inline dma_addr_t
+dma_map_single(struct device *dev, void *cpu_addr, size_t size,
+  enum dma_data_direction dir)
+{
+   _dma_cache_sync((unsigned long)cpu_addr, size, dir);
+   return plat_kernel_addr_to_dma(dev, cpu_addr);
+}
+
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
+size_t size, enum dma_data_direction dir)
+{
+}
+
+static inline dma_addr_t
+dma_map_page(struct device *dev, struct page *page,
+unsigned long offset, size_t size,
+enum dma_data_direction dir)
+{
+   unsigned long paddr = page_to_phys(page) + offset;
+   return dma_map_single(dev, (void *)paddr, size, dir);
+}
+
+static inline void
+dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
+  size_t size, enum dma_data_direction dir)
+{
+}
+
+static inline int
+dma_map_sg(struct device *dev, struct scatterlist *sg,
+  int nents, enum dma_data_direction dir)
+{
+   struct scatterlist *s;
+   int i;
+
+   for_each_sg(sg, s, nents, i)
+   sg->dma_address = dma_map_page(dev, sg_page(s), s->offset,
+  s->length, dir);
+
+   return nents;
+}
+
+static inline void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+int nents, enum dma_data_direction dir)
+{
+   struct scatterlist *s;
+   int i;
+
+   for_each_sg(sg, s, nents, i)
+   dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
+}
+
+static inline void
+dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+   size_t size, enum dma_data_direction dir)
+{
+   _dma_cache_sync(plat_dma_addr_to_kernel(dev, dma_handle), size,
+   DMA_FROM_DEVICE);
+}
+
+s

Re: [PATCH v2 00/16] perf: add memory access sampling support

2012-11-07 Thread Stephane Eranian
On Wed, Nov 7, 2012 at 8:38 AM, Namhyung Kim  wrote:
> Hi Arnaldo,
>
> On Tue, 6 Nov 2012 17:52:21 -0300, Arnaldo Carvalho de Melo wrote:
>> Em Mon, Nov 05, 2012 at 02:50:47PM +0100, Stephane Eranian escreveu:
>> [root@sandy acme]# perf mem -t load rep --stdio 
>> --sort=symbol,symbol_daddr,cost
>> # Samples: 30  of event 'cpu/mem-loads/pp'
>> # Total cost : 640
>> # Sort order : symbol,symbol_daddr,cost
>> #
>> # Overhead  Samples  Symbol Data Symbol 
>> Cost
>> #   ...  ..  ..  
>> ...
>> #
>> 55.00%1  [k] lookup_fast [k] 0x8803b7521bd4  
>> 352
>>  5.47%1  [k] cache_alloc_refill  [k] 0x880407705024  
>>  35
>>  3.44%1  [k] cache_alloc_refill  [k] 0x88041d8527d8  
>>  22
>>  3.28%1  [k] run_timer_softirq   [k] 0x88041e2c3e90  
>>  21
>>  2.50%1  [k] __list_add  [k] 0x8803b7521d68  
>>  16
>>  2.19%1  [.] __strcoll_l [.] 0x7fffa8d44080  
>>  14
>>  1.88%1  [.] __strcoll_l [.] 0x7fffa8d44104  
>>  12
>>
>> If we go to the annotation browser to see where is that lookup_fast hitting 
>> we get:
>>
>> 100.00 │   mov-0x34(%rbp),%eax
>>
>> How to map 0x8803b7521bd4 to a stack variable, struct members and all?
>>

Yes, you need dwarf to achieve this. But I think we should first fix the problem
with global variables at the user and kernel levels and there all you
need is the
data symbol table (which we load because of the -d option) and correct
base+offset
calculations. For now, I am getting perf-.map for global variables.

For instance, I use the following simple test program with:
$ perf mem rec mcol 1

I expect to see symbol aa+offset in the data symbol column and mcol in the
data object column. But instance, I get raw hex and perf-.map.

I think that's what we need to fix first.

/* mcol.c */
#include 
#include 
#include 
#include 
#include 

typedef struct {
long real;
long img;
} elem_t;

#define NB  10ULL
static elem_t aa[NB * 2];

uint64_t
mat_column(elem_t *m, size_t nr, size_t nc, elem_t *n)
{
uint64_t real = 0 , img = 0;
elem_t *p;
size_t i, j;

/* scan by columns */
for(i=0; i < nc; i++) {
for(j=0; j < nr; j++) {
real += (m+i+nc*j)->real;
img += (m+i+nc*j)->img;
}
}
return (real+img) > 0 ? 0 : 1;
}

int main(int argc, char **argv)
{
size_t rows, cols;
unsigned long long nloop, nl;
elem_t number;

number.real = 1;
number.img = 5;

nloop = nl = argc > 1 ? strtoul(argv[1], NULL, 0) : 1;
rows = NB;
cols = 2;
printf("mat[%p:%p] size=%zuMiB\n", aa, &aa[-1+NB*2], sizeof(aa) >> 20);
while(nl--) {
number.img++;
number.real += mat_column(aa, rows, cols, &number);
}
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/


[PATCH 0/4] IPC: CRIU enhancements fixes and cleanup

2012-11-07 Thread Stanislav Kinsbursky
This patch set simplifies message queue copy feature and clean up it's
implementation.
It also adds some debug and fixes an issue, when copy_msg() fails. In this
case error have to returned instead of breaking messages loop, because error
message pointer is interpreted as -EAGAIN in current implemetation of further
message handling.

The following series implements...

---

Stanislav Kinsbursky (4):
  ipc: simplify free_copy() call
  ipc: convert prepare_copy() from macro to function
  ipc: simplify message copying
  ipc: add more comments to message copying related code


 ipc/msg.c |   55 +--
 ipc/msgutil.c |5 +
 2 files changed, 38 insertions(+), 22 deletions(-)


--
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/4] ipc: simplify free_copy() call

2012-11-07 Thread Stanislav Kinsbursky
Passing and checking of msgflg to free_copy() is redundant.
This patch sets copy to NULL on declaration instead and checks for non-NULL in
free_copy().

Note: in case of copy allocation failure, error is returned immediately. So
no need to check for IS_ERR() in free_copy().

Signed-off-by: Stanislav Kinsbursky 
---
 ipc/msg.c |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index a0b0224..f1070c3 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -797,15 +797,17 @@ static inline struct msg_msg *prepare_copy(void __user 
*buf, size_t bufsz,
return copy;
 }
 
-static inline void free_copy(int msgflg, struct msg_msg *copy)
+static inline void free_copy(struct msg_msg *copy)
 {
-   if (msgflg & MSG_COPY)
+   if (copy)
free_msg(copy);
 }
 #else
-#define free_copy(msgflg, copy)do {} while (0)
 #define prepare_copy(buf, sz, msgflg, msgtyp, copy_nr) ERR_PTR(-ENOSYS)
 #define fill_copy(copy_nr, msg_nr, msg, copy)  NULL
+static inline void free_copy(struct msg_msg *copy)
+{
+}
 #endif
 
 long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
@@ -816,7 +818,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
struct msg_msg *msg;
int mode;
struct ipc_namespace *ns;
-   struct msg_msg *copy;
+   struct msg_msg *copy = NULL;
unsigned long __maybe_unused copy_number;
 
if (msqid < 0 || (long) bufsz < 0)
@@ -831,7 +833,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
 
msq = msg_lock_check(ns, msqid);
if (IS_ERR(msq)) {
-   free_copy(msgflg, copy);
+   free_copy(copy);
return PTR_ERR(msq);
}
 
@@ -964,7 +966,7 @@ out_unlock:
}
}
if (IS_ERR(msg)) {
-   free_copy(msgflg, copy);
+   free_copy(copy);
return PTR_ERR(msg);
}
 

--
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] ipc: convert prepare_copy() from macro to function

2012-11-07 Thread Stanislav Kinsbursky
This code works if CONFIG_CHECKPOINT_RESTORE is disabled.

Signed-off-by: Stanislav Kinsbursky 
---
 ipc/msg.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index f1070c3..ad194f8 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -803,8 +803,15 @@ static inline void free_copy(struct msg_msg *copy)
free_msg(copy);
 }
 #else
-#define prepare_copy(buf, sz, msgflg, msgtyp, copy_nr) ERR_PTR(-ENOSYS)
 #define fill_copy(copy_nr, msg_nr, msg, copy)  NULL
+
+static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
+  int msgflg, long *msgtyp,
+  unsigned long *copy_number)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void free_copy(struct msg_msg *copy)
 {
 }
@@ -819,7 +826,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
int mode;
struct ipc_namespace *ns;
struct msg_msg *copy = NULL;
-   unsigned long __maybe_unused copy_number;
+   unsigned long __maybe_unused copy_number = 0;
 
if (msqid < 0 || (long) bufsz < 0)
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/


[PATCH 3/4] ipc: simplify message copying

2012-11-07 Thread Stanislav Kinsbursky
This patch removed redundant and confusing fill_copy(). It also adds
copy_msg() check for error. In this case exit from the function have to be
done instead of break, because further code interprets any error as EAGAIN.

It also defines copy_msg() for the case when CONFIG_CHECKPOINT_RESTORE is
disabled.

Signed-off-by: Stanislav Kinsbursky 
---
 ipc/msg.c |   24 +---
 ipc/msgutil.c |5 +
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index ad194f8..5e317fe 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -770,16 +770,6 @@ static long do_msg_fill(void __user *dest, struct msg_msg 
*msg, size_t bufsz)
 }
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
-static inline struct msg_msg *fill_copy(unsigned long copy_nr,
-   unsigned long msg_nr,
-   struct msg_msg *msg,
-   struct msg_msg *copy)
-{
-   if (copy_nr == msg_nr)
-   return copy_msg(msg, copy);
-   return NULL;
-}
-
 static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
   int msgflg, long *msgtyp,
   unsigned long *copy_number)
@@ -803,8 +793,6 @@ static inline void free_copy(struct msg_msg *copy)
free_msg(copy);
 }
 #else
-#define fill_copy(copy_nr, msg_nr, msg, copy)  NULL
-
 static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
   int msgflg, long *msgtyp,
   unsigned long *copy_number)
@@ -868,10 +856,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
walk_msg->m_type != 1) {
msgtyp = walk_msg->m_type - 1;
} else if (msgflg & MSG_COPY) {
-   msg = fill_copy(copy_number, 
msg_counter,
-   walk_msg, copy);
-   if (msg)
+   if (copy_number == msg_counter) {
+   /*
+* Found requested message.
+* Copy it.
+*/
+   msg = copy_msg(msg, copy);
+   if (IS_ERR(msg))
+   goto out_unlock;
break;
+   }
} else
break;
msg_counter++;
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index b281f5c..4168bb8 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -138,6 +138,11 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct 
msg_msg *dst)
 
return dst;
 }
+#else
+struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
+{
+   return ERR_PTR(-ENOSYS);
+}
 #endif
 int store_msg(void __user *dest, struct msg_msg *msg, int len)
 {

--
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 4/4] ipc: add more comments to message copying related code

2012-11-07 Thread Stanislav Kinsbursky
Signed-off-by: Stanislav Kinsbursky 
---
 ipc/msg.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index 5e317fe..4a4725c 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -770,6 +770,10 @@ static long do_msg_fill(void __user *dest, struct msg_msg 
*msg, size_t bufsz)
 }
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
+/*
+ * This function creates new kernel message structure, large enough to store
+ * bufsz message bytes.
+ */
 static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
   int msgflg, long *msgtyp,
   unsigned long *copy_number)
@@ -881,6 +885,10 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
msg = ERR_PTR(-E2BIG);
goto out_unlock;
}
+   /*
+* If we are copying, then do not unlink message and do
+* not update queue parameters.
+*/
if (msgflg & MSG_COPY)
goto out_unlock;
list_del(&msg->m_list);

--
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 v4 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu
From: Qing Xu 

Signed-off-by: Qing Xu 
---
 .../bindings/regulator/max8925-regulator.txt   |   29 
 drivers/regulator/max8925-regulator.c  |   72 +++-
 2 files changed, 98 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/regulator/max8925-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/max8925-regulator.txt 
b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
new file mode 100644
index 000..073b41d
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8925-regulator.txt
@@ -0,0 +1,29 @@
+Max8925 Voltage regulators
+
+max8925 regulator device register is still handled by mfd_add_devices, not by
+of_xxx, so, it is not necessary to add compatible name. Also, those reg
+offset and id info is stored in mfd_cell(see max8925-core.c), as a result
+there is not private properties in dts.
+
+node's name should match with the definition in max8925_regulator_matches
+(see max8925-regulator.c)
+
+
+Optional properties:
+- Any optional property defined in bindings/regulator/regulator.txt
+
+
+Example:
+
+
+   regulators {
+   SDV1 {
+   regulator-min-microvolt = <637500>;
+   regulator-max-microvolt = <1425000>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   ...
+   ...
+   }
diff --git a/drivers/regulator/max8925-regulator.c 
b/drivers/regulator/max8925-regulator.c
index 9bb0be3..2b54979 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define SD1_DVM_VMIN   85
 #define SD1_DVM_VMAX   100
@@ -187,6 +189,34 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.enable_reg = MAX8925_LDOCTL##_id,  \
 }
 
+#ifdef CONFIG_OF
+static struct of_regulator_match max8925_regulator_matches[] = {
+   { .name = "SDV1",},
+   { .name = "SDV2",},
+   { .name = "SDV3",},
+   { .name = "LDO1",},
+   { .name = "LDO2",},
+   { .name = "LDO3",},
+   { .name = "LDO4",},
+   { .name = "LDO5",},
+   { .name = "LDO6",},
+   { .name = "LDO7",},
+   { .name = "LDO8",},
+   { .name = "LDO9",},
+   { .name = "LDO10",},
+   { .name = "LDO11",},
+   { .name = "LDO12",},
+   { .name = "LDO13",},
+   { .name = "LDO14",},
+   { .name = "LDO15",},
+   { .name = "LDO16",},
+   { .name = "LDO17",},
+   { .name = "LDO18",},
+   { .name = "LDO19",},
+   { .name = "LDO20",},
+};
+#endif
+
 static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_SDV(1, 637.5, 1425, 12.5),
MAX8925_SDV(2,   650, 2225,   25),
@@ -214,6 +244,36 @@ static struct max8925_regulator_info 
max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
 };
 
+#ifdef CONFIG_OF
+static int max8925_regulator_dt_init(struct platform_device *pdev,
+   struct max8925_regulator_info *info,
+   struct regulator_config *config,
+   int ridx)
+{
+   struct device_node *nproot, *np;
+   int rcount;
+   nproot = pdev->dev.parent->of_node;
+   if (!nproot)
+   return -ENODEV;
+   np = of_find_node_by_name(nproot, "regulators");
+   if (!np) {
+   dev_err(&pdev->dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+
+   rcount = of_regulator_match(&pdev->dev, np,
+   &max8925_regulator_matches[ridx], 1);
+   if (rcount < 0)
+   return -ENODEV;
+   config->init_data = max8925_regulator_matches[ridx].init_data;
+   config->of_node = max8925_regulator_matches[ridx].of_node;
+
+   return 0;
+}
+#else
+#define max8925_regulator_dt_init(w, x, y, z)  (-1)
+#endif
+
 static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -222,7 +282,7 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
struct max8925_regulator_info *ri;
struct resource *res;
struct regulator_dev *rdev;
-   int i;
+   int i, regulator_idx;
 
res = platform_get_resource(pdev, IORESOURCE_REG, 0);
if (!res) {
@@ -231,9 +291,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
}
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i];
-   if (ri->vol_reg == res->start)
+   if (ri->vol_reg == res->start) {
+   regulator_idx = i;
break;
+   }
}
+
if (i == ARRAY_SIZE(max8

Re: [RFC] Device Tree Overlays Proposal (Was Re: capebus moving omap_devices to mach-omap2)

2012-11-07 Thread Benoit Cousson
Hi Panto,

On 11/07/2012 09:13 AM, Pantelis Antoniou wrote:
> Hi Grant
> 
> On Nov 6, 2012, at 9:45 PM, Grant Likely wrote:
> 
>> On Tue, Nov 6, 2012 at 7:34 PM, Pantelis Antoniou
>>  wrote:
> 
> [ snip ]
>>
>> g.
> 
> Since we've started talking about longer term goals, and the versioning
> provision seems to stand, I hope we address how much the fragment versioning
> thing is similar to the way board revisions progress.
> 
> If a versioning syntax is available then one could create a single DT 
> file for a bunch of 'almost' similar board and board revisions.

I even think that the version issue is probably much more important for the 
short term than the overlay aspect. Well at least as important. We start having 
as well a bunch a panda board version with different HW setup.

Having a single board-XXX.dts that will support all these versions is probably 
the best approach to avoid choosing that from the bootloader.

We need to figure out a format + mechanism compatible with the current 
non-versioned format to allow filtering the nodes at runtime to keep only the 
relevant one.

Something that can find the driver that will provide the proper board version 
or subsystem version or whatever like that:

compatible-version = "ti,panda-version", "panda";

Then at runtime we should create only the node with the correct match between 
the driver version and the string version.


/* regular panda audio routing */
sound: sound {
compatible = "ti,abe-twl6040";
ti,model = "PandaBoard";
compatible-version = "ti,panda-version", "panda";

/* Audio routing */
ti,audio-routing =
"Headset Stereophone", "HSOL",
"Headset Stereophone", "HSOR",
"Ext Spk", "HFL",
"Ext Spk", "HFR",
"Line Out", "AUXL",
"Line Out", "AUXR",
"HSMIC", "Headset Mic",
"Headset Mic", "Headset Mic Bias",
"AFML", "Line In",
"AFMR", "Line In";
};


/* Audio routing is different between PandaBoard4430 and PandaBoardES */
&sound {
ti,model = "PandaBoardES";
compatible-version = "ti,panda-version", "panda-es";

/* Audio routing */
ti,audio-routing =
"Headset Stereophone", "HSOL",
"Headset Stereophone", "HSOR",
"Ext Spk", "HFL",
"Ext Spk", "HFR",
"Line Out", "AUXL",
"Line Out", "AUXR",
"AFML", "Line In",
"AFMR", "Line In";
};


Maybe some extra version match table can just be passed during the board 
machine_init 

of_platform_populate(NULL, omap_dt_match_table, NULL, NULL, 
panda_version_match_table);


Regards,
Benoit  
--
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 V4 0/2] Upstream ST-Ericsson thermal driver

2012-11-07 Thread hongbo.zhang
From: "hongbo.zhang" 

V3->V4 Changes:

1. In previous patch set V3 "Fix thermal bugs and Upstream ST-Ericsson thermal
driver", there were 5 patches in total, since the first 3 for fixing thermal
layer bugs have been accepted by the maintainer, I'd like to send out the
updated last 2 only this time, for upstreaming ST-Ericsson thermal driver.

2. In patch "Thermal: Add ST-Ericsson DB8500 thermal driver"
  - typo in commit message: diver -> driver;
  - add more explanation of device tree properties are optional or required.
  - in function db8500_thermal_match_cdev: remove cdev_name, use
trip_points->cdev_name[i] directly instead;
  - in function db8500_cdev_bind: move cdev->ops->get_max_state(cdev,
&max_state) out of for loop to call it only once;
  - in function db8500_thermal_parse_dt: update checking strlen(tmp_str) >=
THERMAL_NAME_LENGTH
  - add Reviewed-by: Viresh Kumar 
  - add Reviewed-by: Francesco Lavra 

3. In patch "Thermal: Add ST-Ericsson DB8500 thermal properties and platform
data"
  - add Reviewed-by: Viresh Kumar 

hongbo.zhang (2):
  Thermal: Add ST-Ericsson DB8500 thermal driver.
  Thermal: Add ST-Ericsson DB8500 thermal properties and platform data.

 .../devicetree/bindings/thermal/db8500-thermal.txt |  44 ++
 arch/arm/boot/dts/dbx5x0.dtsi  |  14 +
 arch/arm/boot/dts/snowball.dts |  31 ++
 arch/arm/configs/u8500_defconfig   |   2 +
 arch/arm/mach-ux500/board-mop500.c |  64 +++
 drivers/thermal/Kconfig|  20 +
 drivers/thermal/Makefile   |   2 +
 drivers/thermal/db8500_cpufreq_cooling.c   | 108 +
 drivers/thermal/db8500_thermal.c   | 530 +
 include/linux/platform_data/db8500_thermal.h   |  38 ++
 10 files changed, 853 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/db8500-thermal.txt
 create mode 100644 drivers/thermal/db8500_cpufreq_cooling.c
 create mode 100644 drivers/thermal/db8500_thermal.c
 create mode 100644 include/linux/platform_data/db8500_thermal.h

-- 
1.7.11.3

--
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 V4 1/2] Thermal: Add ST-Ericsson DB8500 thermal driver.

2012-11-07 Thread hongbo.zhang
From: "hongbo.zhang" 

This driver is based on the thermal management framework in thermal_sys.c. A
thermal zone device is created with the trip points to which cooling devices
can be bound, the current cooling device is cpufreq, e.g. CPU frequency is
clipped down to cool the CPU, and other cooling devices can be added and bound
to the trip points dynamically.  The platform specific PRCMU interrupts are
used to active thermal update when trip points are reached.

Signed-off-by: hongbo.zhang 
Reviewed-by: Viresh Kumar 
Reviewed-by: Francesco Lavra 
---
 .../devicetree/bindings/thermal/db8500-thermal.txt |  44 ++
 drivers/thermal/Kconfig|  20 +
 drivers/thermal/Makefile   |   2 +
 drivers/thermal/db8500_cpufreq_cooling.c   | 108 +
 drivers/thermal/db8500_thermal.c   | 530 +
 include/linux/platform_data/db8500_thermal.h   |  38 ++
 6 files changed, 742 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/db8500-thermal.txt
 create mode 100644 drivers/thermal/db8500_cpufreq_cooling.c
 create mode 100644 drivers/thermal/db8500_thermal.c
 create mode 100644 include/linux/platform_data/db8500_thermal.h

diff --git a/Documentation/devicetree/bindings/thermal/db8500-thermal.txt 
b/Documentation/devicetree/bindings/thermal/db8500-thermal.txt
new file mode 100644
index 000..2a03c49
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/db8500-thermal.txt
@@ -0,0 +1,44 @@
+* ST-Ericsson DB8500 Thermal
+
+** Thermal node properties:
+
+- compatible : "stericsson,db8500-thermal";
+- reg : address range of the thermal sensor registers;
+- interrupts : interrupts generated from PRCMU;
+- interrupt-names : "IRQ_HOTMON_LOW" and "IRQ_HOTMON_HIGH";
+- num-trips : number of total trip points, this is required, set it 0 if none,
+  if greater than 0, the following properties must be defined;
+- tripN-temp : temperature of trip point N, should be in ascending order;
+- tripN-type : type of trip point N, should be one of "active" "passive" "hot"
+  "critical";
+- tripN-cdev-num : number of the cooling devices which can be bound to trip
+  point N, this is required if trip point N is defined, set it 0 if none,
+  otherwise the following cooling device names must be defined;
+- tripN-cdev-nameM : name of the No. M cooling device of trip point N;
+
+Usually the num-trips and tripN-*** are separated in board related dts files.
+
+Example:
+thermal@801573c0 {
+   compatible = "stericsson,db8500-thermal";
+   reg = <0x801573c0 0x40>;
+   interrupts = <21 0x4>, <22 0x4>;
+   interrupt-names = "IRQ_HOTMON_LOW", "IRQ_HOTMON_HIGH";
+
+   num-trips = <3>;
+
+   trip0-temp = <7>;
+   trip0-type = "active";
+   trip0-cdev-num = <1>;
+   trip0-cdev-name0 = "thermal-cpufreq-0";
+
+   trip1-temp = <75000>;
+   trip1-type = "active";
+   trip1-cdev-num = <2>;
+   trip1-cdev-name0 = "thermal-cpufreq-0";
+   trip1-cdev-name1 = "thermal-fan";
+
+   trip2-temp = <85000>;
+   trip2-type = "critical";
+   trip2-cdev-num = <0>;
+}
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index e1cb6bd..54c8fd0 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -31,6 +31,26 @@ config CPU_THERMAL
  and not the ACPI interface.
  If you want this support, you should say Y here.
 
+config DB8500_THERMAL
+   bool "DB8500 thermal management"
+   depends on THERMAL
+   default y
+   help
+ Adds DB8500 thermal management implementation according to the thermal
+ management framework. A thermal zone with several trip points will be
+ created. Cooling devices can be bound to the trip points to cool this
+ thermal zone if trip points reached.
+
+config DB8500_CPUFREQ_COOLING
+   tristate "DB8500 cpufreq cooling"
+   depends on CPU_THERMAL
+   default y
+   help
+ Adds DB8500 cpufreq cooling devices, and these cooling devices can be
+ bound to thermal zone trip points. When a trip point reached, the
+ bound cpufreq cooling device turns active to set CPU frequency low to
+ cool down the CPU.
+
 config SPEAR_THERMAL
bool "SPEAr thermal sensor driver"
depends on THERMAL
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 885550d..c7a8dab 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -7,3 +7,5 @@ obj-$(CONFIG_CPU_THERMAL)   += cpu_cooling.o
 obj-$(CONFIG_SPEAR_THERMAL)+= spear_thermal.o
 obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
 obj-$(CONFIG_EXYNOS_THERMAL)   += exynos_thermal.o
+obj-$(CONFIG_DB8500_THERMAL)   += db8500_thermal.o
+obj-$(CONFIG_DB8500_CPUFREQ_COOLING)   += db8500_cpufreq_cooling.o
diff --git a/drivers/thermal/db8500_cpufreq_cooling.c 
b/drivers/thermal/db8500_cpufreq_cooling.c
new file mode 100644
index 

[PATCH V4 2/2] Thermal: Add ST-Ericsson DB8500 thermal properties and platform data.

2012-11-07 Thread hongbo.zhang
From: "hongbo.zhang" 

This patch adds device tree properties for ST-Ericsson DB8500 thermal driver,
also adds the platform data to support the old fashion.

Signed-off-by: hongbo.zhang 
Reviewed-by: Viresh Kumar 
---
 arch/arm/boot/dts/dbx5x0.dtsi  | 14 +
 arch/arm/boot/dts/snowball.dts | 31 ++
 arch/arm/configs/u8500_defconfig   |  2 ++
 arch/arm/mach-ux500/board-mop500.c | 64 ++
 4 files changed, 111 insertions(+)

diff --git a/arch/arm/boot/dts/dbx5x0.dtsi b/arch/arm/boot/dts/dbx5x0.dtsi
index 4b0e0ca..731086b 100644
--- a/arch/arm/boot/dts/dbx5x0.dtsi
+++ b/arch/arm/boot/dts/dbx5x0.dtsi
@@ -203,6 +203,14 @@
reg = <0x80157450 0xC>;
};
 
+   thermal@801573c0 {
+   compatible = "stericsson,db8500-thermal";
+   reg = <0x801573c0 0x40>;
+   interrupts = <21 0x4>, <22 0x4>;
+   interrupt-names = "IRQ_HOTMON_LOW", 
"IRQ_HOTMON_HIGH";
+   status = "disabled";
+};
+
db8500-prcmu-regulators {
compatible = 
"stericsson,db8500-prcmu-regulator";
 
@@ -660,5 +668,11 @@
ranges = <0 0x5000 0x400>;
status = "disabled";
};
+
+   cpufreq-cooling {
+   compatible = "stericsson,db8500-cpufreq-cooling";
+   status = "disabled";
+};
+
};
 };
diff --git a/arch/arm/boot/dts/snowball.dts b/arch/arm/boot/dts/snowball.dts
index 702c0ba..c6f85f0 100644
--- a/arch/arm/boot/dts/snowball.dts
+++ b/arch/arm/boot/dts/snowball.dts
@@ -99,6 +99,33 @@
status = "okay";
};
 
+   prcmu@80157000 {
+   thermal@801573c0 {
+   num-trips = <4>;
+
+   trip0-temp = <7>;
+   trip0-type = "active";
+   trip0-cdev-num = <1>;
+   trip0-cdev-name0 = "thermal-cpufreq-0";
+
+   trip1-temp = <75000>;
+   trip1-type = "active";
+   trip1-cdev-num = <1>;
+   trip1-cdev-name0 = "thermal-cpufreq-0";
+
+   trip2-temp = <8>;
+   trip2-type = "active";
+   trip2-cdev-num = <1>;
+   trip2-cdev-name0 = "thermal-cpufreq-0";
+
+   trip3-temp = <85000>;
+   trip3-type = "critical";
+   trip3-cdev-num = <0>;
+
+   status = "okay";
+};
+   };
+
external-bus@5000 {
status = "okay";
 
@@ -183,5 +210,9 @@
reg = <0x33>;
};
};
+
+   cpufreq-cooling {
+   status = "okay";
+   };
};
 };
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index da68454..250625d 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -69,6 +69,8 @@ CONFIG_GPIO_TC3589X=y
 CONFIG_POWER_SUPPLY=y
 CONFIG_AB8500_BM=y
 CONFIG_AB8500_BATTERY_THERM_ON_BATCTRL=y
+CONFIG_THERMAL=y
+CONFIG_CPU_THERMAL=y
 CONFIG_MFD_STMPE=y
 CONFIG_MFD_TC3589X=y
 CONFIG_AB5500_CORE=y
diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index 416d436..b03216b 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -229,6 +230,67 @@ static struct ab8500_platform_data ab8500_platdata = {
 };
 
 /*
+ * Thermal Sensor
+ */
+
+static struct resource db8500_thsens_resources[] = {
+   {
+   .name = "IRQ_HOTMON_LOW",
+   .start  = IRQ_PRCMU_HOTMON_LOW,
+   .end= IRQ_PRCMU_HOTMON_LOW,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .name = "IRQ_HOTMON_HIGH",
+   .start  = IRQ_PRCMU_HOTMON_HIGH,
+   .end= IRQ_PRCMU_HOTMON_HIGH,
+   .flags  = IORESOURCE_IRQ,
+   },
+};
+
+static struct db8500_thsens_platform_data db8500_thsens_data = {
+   .trip_points[0] = {
+   .temp = 7,
+   .type = THERMAL_TRIP_ACTIVE,
+   .cdev_name = {
+   [0] = "thermal-cpufreq-0",
+   },
+   },
+   .trip_points[1] = {
+   .temp = 75000,
+   .type = THERMAL_TRIP_ACTIVE,

Re: [PATCH 2/2] xen/arm: Fix compile errors when drivers are compiled as modules.

2012-11-07 Thread Stefano Stabellini
On Tue, 6 Nov 2012, Konrad Rzeszutek Wilk wrote:
> We end up with:
> 
> ERROR: "HYPERVISOR_event_channel_op" [drivers/xen/xen-gntdev.ko] undefined!
> ERROR: "privcmd_call" [drivers/xen/xen-privcmd.ko] undefined!
> ERROR: "HYPERVISOR_grant_table_op" [drivers/net/xen-netback/xen-netback.ko] 
> undefined!
> 
> and this patch exports said function (which is implemented in hypercall.S).
> 
> Signed-off-by: Konrad Rzeszutek Wilk 

Thank you very much for going out of your way to fix this issue (I am
currently at LinuxCon).


>  arch/arm/xen/enlighten.c |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 59bcb96..96d969d 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -166,3 +166,8 @@ void free_xenballooned_pages(int nr_pages, struct page 
> **pages)
>   *pages = NULL;
>  }
>  EXPORT_SYMBOL_GPL(free_xenballooned_pages);
> +
> +/* In the hypervisor.S file. */
> +EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op);
> +EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op);
> +EXPORT_SYMBOL_GPL(privcmd_call);
 
I think the patch is OK and I tested it: it fixes the issue reported
by Russell.
However I am wondering, does it actually make sense only to export 3
hypercalls among the set implemented in hypercall.S?
Maybe it does make sense only to export a subset, but I wouldn't
necessarly do the differentiation here, I would just export all the
hypercalls implemented in hypercalls.S.
In fact if we separate the hypercalls in two sets, I would like to
see a similar differentiation on x86 too.
--
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 V2 RFC 2/3] kvm: Handle yield_to failure return code for potential undercommit case

2012-11-07 Thread Raghavendra K T
* Raghavendra K T  [2012-10-31 22:36:25]:

> On 10/31/2012 07:11 PM, Avi Kivity wrote:
> >On 10/31/2012 03:15 PM, Raghavendra K T wrote:
> >>On 10/31/2012 06:11 PM, Raghavendra K T wrote:
> >>>On 10/31/2012 06:08 PM, Avi Kivity wrote:
> On 10/29/2012 04:07 PM, Raghavendra K T wrote:
> >From: Raghavendra K T 
> >
> >Also we do not update last boosted vcpu in failure cases.
> >
> >   #endif
> >+
> >   void kvm_vcpu_on_spin(struct kvm_vcpu *me)
> >   {
> >   struct kvm *kvm = me->kvm;
> >@@ -1727,11 +1727,12 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
> >   continue;
> >   if (!kvm_vcpu_eligible_for_directed_yield(vcpu))
> >   continue;
> >-if (kvm_vcpu_yield_to(vcpu)) {
> >+
> >+yielded = kvm_vcpu_yield_to(vcpu);
> >+if (yielded > 0)
> >   kvm->last_boosted_vcpu = i;
> >-yielded = 1;
> >+if (yielded)
> >   break;
> >-}
> >   }
> 
> If yielded == -ESRCH, should we not try to yield to another vcpu?
> 
> >>>
> >>>   Yes. plan is to abort the iteration. since it means we are mostly
> >>>undercommitted.
> >>
> >>Sorry if it was ambiguous. I wanted to say we do not want to continue
> >>yield to another vcpu..
> >>
> >
> >
> >Why not?  We found that this particular vcpu is running and therefore
> >likely not a lock holder.  That says nothing about other vcpus.  The
> >next in line might be runnable-but-not-running on another runqueue.
> 
> Agree that next in the line might be runnable-not-running.  But here we
> are optimistic that, that is not the case and we save time by
> returning back instead of iterating, thinking we are mostly in
> undercommitted case and each vcpu has dedicated cpu.
> 
> Probably an alternative we have here is to look for say 2-3 successive
> failures before breaking out?

Hi Avi,

I tried the idea of bailing out only when we have successive failure
too (hunk below). results are as follows.

base = 3.7.0-rc1 
A = base +  patch 1 +  patch 2 (original series except patch 3)
B = A + bail out on successive failures patch (hunk below)

% improvements w.r.t base kernel 32 vcpu guest on 32 core PLE machine

  A   B
kernbench_1x 1.83959 0.95158
kernbench_2x 5.58283 8.31783

ebizzy_1x144.96959   147.47995  
ebizzy_2x-11.52278   -4.52835   
ebizzy_3x-7.59141-5.17241   

dbench_1x87.4693561.14888   
dbench_2x-7.16749-4.17130   
dbench_3x-0.34115-3.18740


IMO, 
the original patch would have affceted moderate overcommits more
when we have average runqueue length less than two but we are still 
overcommitted.

With this patch though we may get litlle less improvement for
1x overcommit, probability of this affetcting moderate overcommit
situation reduces drastically.

If we consider cases where, we have average run queue length as follows,
and corresponding probability of we considering it as undercommitted (wrongly)
case with rough/simple math is as follows: (correct me if something is
wrong here)

( In precise math it should be the probability of we hitting
a source and target runqueue length one when we are overcommitted for
two successive trials, noting that source of the yield_to remains same)

(Probability = p^3 where p is the probability that we hit a cpu having
rq length = 1. I have taken out #cpus from calculation here though it affects)

average Probability 
rq length
-
1.25   27/64  Note: we are slightly overcommitted here and hopefully it 
does not afftect much.
1.51/8 
1.75   1/64

for original patch it was p^2 and hence 9/16, 1/4, 1/16 respectively.

I think continuing to yield_to beyond this would make us go back to
square one, unnecessarily wasting time.

Please let me know if you have any comments on idea of bailing out after 
successive trials?

(Side) Note: Dynamic ple window built on top of this logic is already done. and
will be posting it with results in a separate patch.

Changed hunk:
---8<---
@@ -1697,12 +1696,14 @@ bool kvm_vcpu_eligible_for_directed_yield(struct 
kvm_vcpu *vcpu)
return eligible;
 }
 #endif
+
 void kvm_vcpu_on_spin(struct kvm_vcpu *me)
 {
struct kvm *kvm = me->kvm;
struct kvm_vcpu *vcpu;
int last_boosted_vcpu = me->kvm->last_boosted_vcpu;
int yielded = 0;
+   int try = 2;
int pass;
int i;
 
@@ -1714,7 +1715,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
 * VCPU is holding the lock that we need and will release it.
 * We approximate round-robin by starting at the last boosted VCPU.
 */
-   for (pass = 0; pass < 2 && !yielded; pass++) {
+   for (pass = 0; pass < 2 && !

Re: [PATCH 08/19] mm: numa: Create basic numa page hinting infrastructure

2012-11-07 Thread Mel Gorman
On Tue, Nov 06, 2012 at 01:58:26PM -0500, Rik van Riel wrote:
> On 11/06/2012 04:14 AM, Mel Gorman wrote:
> >Note: This patch started as "mm/mpol: Create special PROT_NONE
> > infrastructure" and preserves the basic idea but steals *very*
> > heavily from "autonuma: numa hinting page faults entry points" for
> > the actual fault handlers without the migration parts.  The end
> > result is barely recognisable as either patch so all Signed-off
> > and Reviewed-bys are dropped. If Peter, Ingo and Andrea are ok with
> > this version, I will re-add the signed-offs-by to reflect the history.
> >
> >In order to facilitate a lazy -- fault driven -- migration of pages, create
> >a special transient PAGE_NUMA variant, we can then use the 'spurious'
> >protection faults to drive our migrations from.
> >
> >Pages that already had an effective PROT_NONE mapping will not be detected
> 
> The patch itself is good, but the changelog needs a little
> fix. While you are defining _PAGE_NUMA to _PAGE_PROTNONE on
> x86, this may be different on other architectures.
> 
> Therefore, the changelog should refer to PAGE_NUMA, not
> PROT_NONE.
> 

Fair point. I still want to record the point that PROT_NONE will not
generate the faults though. How about this?

In order to facilitate a lazy -- fault driven -- migration of pages, create
a special transient PAGE_NUMA variant, we can then use the 'spurious'
protection faults to drive our migrations from.

The meaning of PAGE_NUMA depends on the architecture but on x86 it is
effectively PROT_NONE. In this case, PROT_NONE mappings will not be detected
to generate these 'spurious' faults for the simple reason that we cannot
distinguish them on their protection bits, see pte_numa(). This isn't
a problem since PROT_NONE (and possible PROT_WRITE with dirty tracking)
aren't used or are rare enough for us to not care about their placement.

> >to generate these 'spurious' faults for the simple reason that we cannot
> >distinguish them on their protection bits, see pte_numa(). This isn't
> >a problem since PROT_NONE (and possible PROT_WRITE with dirty tracking)
> >aren't used or are rare enough for us to not care about their placement.
> >
> >Signed-off-by: Mel Gorman 
> 
> Other than the changelog ...
> 
> Reviewed-by: Rik van Riel 

Thanks.

-- 
Mel Gorman
SUSE Labs
--
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] firmware loader: Fix the race FW_STATUS_DONE is followed by class_timeout

2012-11-07 Thread Ming Lei
On Thu, Nov 8, 2012 at 12:45 AM, Chuansheng Liu
 wrote:
>
> There is a race condition as below when calling request_firmware():
>
> CPU1CPU2
> write 0 > loading
> mutex_lock(&fw_lock);
> ...
> set_bit FW_STATUS_DONE  class_timeout is coming
> set_bit FW_STATUS_ABORT
> complete_all &completion
> ...
> mutex_unlock(&fw_lock)

Good catch, but your fix isn't correct.

>
> In this time, the bit FW_STATUS_DONE and FW_STATUS_ABORT are set,
> and request_firmware() will return failure due to condition in
> _request_firmware_load():
>
> if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status))
> retval = -ENOENT;
>
> But from the above scenerio, it should be a succcessful requesting.
> So we need judge if the FW_STATUS_DONE is set before calling abort
> in timeout function firmware_class_timeout().
>
> Signed-off-by: liu chuansheng 
> ---
>  drivers/base/firmware_class.c |7 +++
>  1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 8945f4e..35fffd8 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -671,6 +671,13 @@ static void firmware_class_timeout(u_long data)
>  {
> struct firmware_priv *fw_priv = (struct firmware_priv *) data;
>
> +   mutex_lock(&fw_lock);

mutex can't be used in interrupt context, so one candidate fix is
to convert the timeout timer into delayed work, and hold the
'fw_lock' during the work function.

> +   if (test_bit(FW_STATUS_DONE, &(fw_priv->buf->status))) {
> +   mutex_unlock(&fw_lock);
> +   return;
> +   }
> +   mutex_unlock(&fw_lock);
> +
> fw_load_abort(fw_priv);
>  }

Also the lock of 'fw_lock' should be held when setting 'FW_STATUS_DONE'
in _request_firmware_load().

Could you send out a new patch to fix the race?

Thanks,
--
Ming Lei
--
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/7] GFS2: Fix an unchecked error from gfs2_rs_alloc

2012-11-07 Thread Steven Whitehouse
From: Andrew Price 

Check the return value of gfs2_rs_alloc(ip) and avoid a possible null
pointer dereference.

Signed-off-by: Andrew Price 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 40c4b0d..c5af8e1 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -497,8 +497,11 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 
gid)
struct gfs2_quota_data **qd;
int error;
 
-   if (ip->i_res == NULL)
-   gfs2_rs_alloc(ip);
+   if (ip->i_res == NULL) {
+   error = gfs2_rs_alloc(ip);
+   if (error)
+   return error;
+   }
 
qd = ip->i_res->rs_qa_qd;
 
-- 
1.7.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 2/7] GFS2: Fix possible null pointer deref in gfs2_rs_alloc

2012-11-07 Thread Steven Whitehouse
From: Andrew Price 

Despite the return value from kmem_cache_zalloc() being checked, the
error wasn't being returned until after a possible null pointer
dereference. This patch returns the error immediately, allowing the
removal of the error variable.

Signed-off-by: Andrew Price 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 3cc402c..43d1a20 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -553,7 +553,6 @@ void gfs2_free_clones(struct gfs2_rgrpd *rgd)
  */
 int gfs2_rs_alloc(struct gfs2_inode *ip)
 {
-   int error = 0;
struct gfs2_blkreserv *res;
 
if (ip->i_res)
@@ -561,7 +560,7 @@ int gfs2_rs_alloc(struct gfs2_inode *ip)
 
res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS);
if (!res)
-   error = -ENOMEM;
+   return -ENOMEM;
 
RB_CLEAR_NODE(&res->rs_node);
 
@@ -571,7 +570,7 @@ int gfs2_rs_alloc(struct gfs2_inode *ip)
else
ip->i_res = res;
up_write(&ip->i_rw_mutex);
-   return error;
+   return 0;
 }
 
 static void dump_rs(struct seq_file *seq, const struct gfs2_blkreserv *rs)
-- 
1.7.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 5/7] GFS2: Fix FITRIM argument handling

2012-11-07 Thread Steven Whitehouse
From: Lukas Czerner 

Currently implementation in gfs2 uses FITRIM arguments as it were in
file system blocks units which is wrong. The FITRIM arguments
(fstrim_range.start, fstrim_range.len and fstrim_range.minlen) are
actually in bytes.

Moreover, check for start argument beyond the end of file system, len
argument being smaller than file system block and minlen argument being
bigger than biggest resource group were missing.

This commit converts the code to convert FITRIM argument to file system
blocks and also adds appropriate checks mentioned above.

All the problems were recognised by xfstests 251 and 260.

Signed-off-by: Lukas Czerner 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index b6bbf71..38fe18f 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1262,7 +1262,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
int ret = 0;
u64 amt;
u64 trimmed = 0;
+   u64 start, end, minlen;
unsigned int x;
+   unsigned bs_shift = sdp->sd_sb.sb_bsize_shift;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -1277,8 +1279,18 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
if (ret)
return ret;
 
-   rgd = gfs2_blk2rgrpd(sdp, r.start, 0);
-   rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0);
+   start = r.start >> bs_shift;
+   end = start + (r.len >> bs_shift);
+   minlen = max_t(u64, r.minlen,
+  q->limits.discard_granularity) >> bs_shift;
+
+   rgd = gfs2_blk2rgrpd(sdp, start, 0);
+   rgd_end = gfs2_blk2rgrpd(sdp, end - 1, 0);
+
+   if (end <= start ||
+   minlen > sdp->sd_max_rg_data ||
+   start > rgd_end->rd_data0 + rgd_end->rd_data)
+   return -EINVAL;
 
while (1) {
 
@@ -1290,7 +1302,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
/* Trim each bitmap in the rgrp */
for (x = 0; x < rgd->rd_length; x++) {
struct gfs2_bitmap *bi = rgd->rd_bits + x;
-   ret = gfs2_rgrp_send_discards(sdp, 
rgd->rd_data0, NULL, bi, r.minlen, &amt);
+   ret = gfs2_rgrp_send_discards(sdp,
+   rgd->rd_data0, NULL, bi, minlen,
+   &amt);
if (ret) {
gfs2_glock_dq_uninit(&gh);
goto out;
-- 
1.7.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 6/7] GFS2: Don't call file_accessed() with a shared glock

2012-11-07 Thread Steven Whitehouse
From: Benjamin Marzinski 

file_accessed() was being called by gfs2_mmap() with a shared glock. If it
needed to update the atime, it was crashing because it dirtied the inode in
gfs2_dirty_inode() without holding an exclusive lock. gfs2_dirty_inode()
checked if the caller was already holding a glock, but it didn't make sure that
the glock was in the exclusive state. Now, instead of calling file_accessed()
while holding the shared lock in gfs2_mmap(), file_accessed() is called after
grabbing and releasing the glock to update the inode.  If file_accessed() needs
to update the atime, it will grab an exclusive lock in gfs2_dirty_inode().

gfs2_dirty_inode() now also checks to make sure that if the calling process has
already locked the glock, it has an exclusive lock.

Signed-off-by: Benjamin Marzinski 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 377a68d..e056b4c 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -516,15 +516,13 @@ static int gfs2_mmap(struct file *file, struct 
vm_area_struct *vma)
struct gfs2_holder i_gh;
int error;
 
-   gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
-   error = gfs2_glock_nq(&i_gh);
-   if (error == 0) {
-   file_accessed(file);
-   gfs2_glock_dq(&i_gh);
-   }
-   gfs2_holder_uninit(&i_gh);
+   error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
+  &i_gh);
if (error)
return error;
+   /* grab lock to update inode */
+   gfs2_glock_dq_uninit(&i_gh);
+   file_accessed(file);
}
vma->vm_ops = &gfs2_vm_ops;
 
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index bc73726..d648867 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -810,7 +810,8 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
return;
}
need_unlock = 1;
-   }
+   } else if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE))
+   return;
 
if (current->journal_info == NULL) {
ret = gfs2_trans_begin(sdp, RES_DINODE, 0);
-- 
1.7.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/


GFS2: Pre-pull patch posting (fixes)

2012-11-07 Thread Steven Whitehouse
Hi,

Here are a number of GFS2 bug fixes. There are three from Andy Price
which fix various issues spotted by automated code analysis. There are two
from Lukas Czerner fixing my mistaken assumptions as to how FITRIM
should work. Finally Ben Marzinski has fixed a bug relating to mmap and
atime and also a bug relating to a locking issue in the transaction code.

Steve.

--
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 7/7] GFS2: Test bufdata with buffer locked and gfs2_log_lock held

2012-11-07 Thread Steven Whitehouse
From: Benjamin Marzinski 

In gfs2_trans_add_bh(), gfs2 was testing if a there was a bd attached to the
buffer without having the gfs2_log_lock held. It was then assuming it would
stay attached for the rest of the function. However, without either the log
lock being held of the buffer locked, __gfs2_ail_flush() could detach bd at any
time.  This patch moves the locking before the test.  If there isn't a bd
already attached, gfs2 can safely allocate one and attach it before locking.
There is no way that the newly allocated bd could be on the ail list,
and thus no way for __gfs2_ail_flush() to detach it.

Signed-off-by: Benjamin Marzinski 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 01e444b..9ceccb1 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -393,12 +393,10 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
struct gfs2_meta_header *mh;
struct gfs2_trans *tr;
 
-   lock_buffer(bd->bd_bh);
-   gfs2_log_lock(sdp);
tr = current->journal_info;
tr->tr_touched = 1;
if (!list_empty(&bd->bd_list))
-   goto out;
+   return;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
@@ -414,9 +412,6 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
sdp->sd_log_num_buf++;
list_add(&bd->bd_list, &sdp->sd_log_le_buf);
tr->tr_num_buf_new++;
-out:
-   gfs2_log_unlock(sdp);
-   unlock_buffer(bd->bd_bh);
 }
 
 static void gfs2_check_magic(struct buffer_head *bh)
@@ -775,12 +770,10 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
struct address_space *mapping = bd->bd_bh->b_page->mapping;
struct gfs2_inode *ip = GFS2_I(mapping->host);
 
-   lock_buffer(bd->bd_bh);
-   gfs2_log_lock(sdp);
if (tr)
tr->tr_touched = 1;
if (!list_empty(&bd->bd_list))
-   goto out;
+   return;
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
if (gfs2_is_jdata(ip)) {
@@ -791,9 +784,6 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
} else {
list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered);
}
-out:
-   gfs2_log_unlock(sdp);
-   unlock_buffer(bd->bd_bh);
 }
 
 /**
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index adbd278..4136270 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -155,14 +155,22 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct 
buffer_head *bh, int meta)
struct gfs2_sbd *sdp = gl->gl_sbd;
struct gfs2_bufdata *bd;
 
+   lock_buffer(bh);
+   gfs2_log_lock(sdp);
bd = bh->b_private;
if (bd)
gfs2_assert(sdp, bd->bd_gl == gl);
else {
+   gfs2_log_unlock(sdp);
+   unlock_buffer(bh);
gfs2_attach_bufdata(gl, bh, meta);
bd = bh->b_private;
+   lock_buffer(bh);
+   gfs2_log_lock(sdp);
}
lops_add(sdp, bd);
+   gfs2_log_unlock(sdp);
+   unlock_buffer(bh);
 }
 
 void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
-- 
1.7.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 4/7] GFS2: Require user to provide argument for FITRIM

2012-11-07 Thread Steven Whitehouse
From: Lukas Czerner 

When the fstrim_range argument is not provided by user in FITRIM ioctl
we should just return EFAULT and not promoting bad behaviour by filling
the structure in kernel. Let the user deal with it.

Signed-off-by: Lukas Czerner 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 43d1a20..b6bbf71 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1270,11 +1270,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
if (!blk_queue_discard(q))
return -EOPNOTSUPP;
 
-   if (argp == NULL) {
-   r.start = 0;
-   r.len = ULLONG_MAX;
-   r.minlen = 0;
-   } else if (copy_from_user(&r, argp, sizeof(r)))
+   if (copy_from_user(&r, argp, sizeof(r)))
return -EFAULT;
 
ret = gfs2_rindex_update(sdp);
@@ -1323,7 +1319,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
 
 out:
r.len = trimmed << 9;
-   if (argp && copy_to_user(argp, &r, sizeof(r)))
+   if (copy_to_user(argp, &r, sizeof(r)))
return -EFAULT;
 
return ret;
-- 
1.7.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 3/7] GFS2: Clean up some unused assignments

2012-11-07 Thread Steven Whitehouse
From: Andrew Price 

Cleans up two cases where variables were assigned values but then never
used again.

Signed-off-by: Andrew Price 
Signed-off-by: Steven Whitehouse 

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 0def050..377a68d 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -677,10 +677,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, 
const struct iovec *iov,
size_t writesize = iov_length(iov, nr_segs);
struct dentry *dentry = file->f_dentry;
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
-   struct gfs2_sbd *sdp;
int ret;
 
-   sdp = GFS2_SB(file->f_mapping->host);
ret = gfs2_rs_alloc(ip);
if (ret)
return ret;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 8ff95a2..01e444b 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -621,7 +621,6 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct 
gfs2_bufdata *bd)
 
 static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 {
-   struct gfs2_log_descriptor *ld;
struct gfs2_meta_header *mh;
unsigned int offset;
struct list_head *head = &sdp->sd_log_le_revoke;
@@ -634,7 +633,6 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 
length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(u64));
page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, 
sdp->sd_log_num_revoke);
-   ld = page_address(page);
offset = sizeof(struct gfs2_log_descriptor);
 
list_for_each_entry(bd, head, bd_list) {
-- 
1.7.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 08/19] mm: numa: Create basic numa page hinting infrastructure

2012-11-07 Thread Rik van Riel

On 11/07/2012 05:38 AM, Mel Gorman wrote:

On Tue, Nov 06, 2012 at 01:58:26PM -0500, Rik van Riel wrote:

On 11/06/2012 04:14 AM, Mel Gorman wrote:

Note: This patch started as "mm/mpol: Create special PROT_NONE
infrastructure" and preserves the basic idea but steals *very*
heavily from "autonuma: numa hinting page faults entry points" for
the actual fault handlers without the migration parts.  The end
result is barely recognisable as either patch so all Signed-off
and Reviewed-bys are dropped. If Peter, Ingo and Andrea are ok with
this version, I will re-add the signed-offs-by to reflect the history.

In order to facilitate a lazy -- fault driven -- migration of pages, create
a special transient PAGE_NUMA variant, we can then use the 'spurious'
protection faults to drive our migrations from.

Pages that already had an effective PROT_NONE mapping will not be detected


The patch itself is good, but the changelog needs a little
fix. While you are defining _PAGE_NUMA to _PAGE_PROTNONE on
x86, this may be different on other architectures.

Therefore, the changelog should refer to PAGE_NUMA, not
PROT_NONE.



Fair point. I still want to record the point that PROT_NONE will not
generate the faults though. How about this?

 In order to facilitate a lazy -- fault driven -- migration of pages, create
 a special transient PAGE_NUMA variant, we can then use the 'spurious'
 protection faults to drive our migrations from.

 The meaning of PAGE_NUMA depends on the architecture but on x86 it is
 effectively PROT_NONE. In this case, PROT_NONE mappings will not be 
detected
 to generate these 'spurious' faults for the simple reason that we cannot
 distinguish them on their protection bits, see pte_numa(). This isn't
 a problem since PROT_NONE (and possible PROT_WRITE with dirty tracking)
 aren't used or are rare enough for us to not care about their placement.


Actual PROT_NONE mappings will not generate these NUMA faults
for the reason that the page fault code checks the permission
on the VMA (and will throw a segmentation fault on actual
PROT_NONE mappings), before it ever calls handle_mm_fault.

--
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 5/5] virtio-scsi: tidy up the goto label in init()

2012-11-07 Thread Wanlong Gao
Tidy up the goto label in init(), and remove the useless
NULL pointer assignment.

Cc: James E.J. Bottomley 
Cc: Paolo Bonzini 
Cc: Rusty Russell 
Cc: linux-s...@vger.kernel.org
Cc: k...@vger.kernel.org
Signed-off-by: Wanlong Gao 
---
 drivers/scsi/virtio_scsi.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index fc05240..afee1d4 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -793,13 +793,13 @@ static int __init init(void)
virtscsi_wq = alloc_workqueue("virtio-scsi", 0, 0);
if (!virtscsi_wq) {
pr_err("alloc_workqueue() for virtscsi_wq failed\n");
-   goto error;
+   goto workqueue_failed;
}
 
virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
if (!virtscsi_cmd_cache) {
pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
-   goto error;
+   goto kmem_cache_failed;
}
 
 
@@ -808,27 +808,21 @@ static int __init init(void)
 virtscsi_cmd_cache);
if (!virtscsi_cmd_pool) {
pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
-   goto error;
+   goto mempool_failed;
}
ret = register_virtio_driver(&virtio_scsi_driver);
if (ret < 0)
-   goto error;
+   goto register_failed;
 
return 0;
 
-error:
-   if (virtscsi_cmd_pool) {
-   mempool_destroy(virtscsi_cmd_pool);
-   virtscsi_cmd_pool = NULL;
-   }
-   if (virtscsi_cmd_cache) {
-   kmem_cache_destroy(virtscsi_cmd_cache);
-   virtscsi_cmd_cache = NULL;
-   }
-   if (virtscsi_wq) {
-   destroy_workqueue(virtscsi_wq);
-   virtscsi_wq = NULL;
-   }
+register_failed:
+   mempool_destroy(virtscsi_cmd_pool);
+mempool_failed:
+   kmem_cache_destroy(virtscsi_cmd_cache);
+kmem_cache_failed:
+   destroy_workqueue(virtscsi_wq);
+workqueue_failed:
return ret;
 }
 
-- 
1.8.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/


[PATCH 4/5] virtio-scsi: create a separate work queue for virtio-scsi

2012-11-07 Thread Wanlong Gao
Create a separate work queue for virtio-scsi to improve the performance.

Cc: James E.J. Bottomley 
Cc: Paolo Bonzini 
Cc: Rusty Russell 
Cc: linux-s...@vger.kernel.org
Cc: k...@vger.kernel.org
Signed-off-by: Wanlong Gao 
---
 drivers/scsi/virtio_scsi.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 765138a..fc05240 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -27,6 +27,8 @@
 #define VIRTIO_SCSI_MEMPOOL_SZ 64
 #define VIRTIO_SCSI_EVENT_LEN 8
 
+struct workqueue_struct *virtscsi_wq;
+
 /* Command queue element */
 struct virtio_scsi_cmd {
struct scsi_cmnd *sc;
@@ -337,7 +339,7 @@ static void virtscsi_complete_event(void *buf)
struct virtio_scsi_event_node *event_node = buf;
 
INIT_WORK(&event_node->work, virtscsi_handle_event);
-   schedule_work(&event_node->work);
+   queue_work(virtscsi_wq, &event_node->work);
 }
 
 static void virtscsi_event_done(struct virtqueue *vq)
@@ -788,6 +790,12 @@ static int __init init(void)
 {
int ret = -ENOMEM;
 
+   virtscsi_wq = alloc_workqueue("virtio-scsi", 0, 0);
+   if (!virtscsi_wq) {
+   pr_err("alloc_workqueue() for virtscsi_wq failed\n");
+   goto error;
+   }
+
virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
if (!virtscsi_cmd_cache) {
pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
@@ -817,6 +825,10 @@ error:
kmem_cache_destroy(virtscsi_cmd_cache);
virtscsi_cmd_cache = NULL;
}
+   if (virtscsi_wq) {
+   destroy_workqueue(virtscsi_wq);
+   virtscsi_wq = NULL;
+   }
return ret;
 }
 
@@ -825,6 +837,7 @@ static void __exit fini(void)
unregister_virtio_driver(&virtio_scsi_driver);
mempool_destroy(virtscsi_cmd_pool);
kmem_cache_destroy(virtscsi_cmd_cache);
+   destroy_workqueue(virtscsi_wq);
 }
 module_init(init);
 module_exit(fini);
-- 
1.8.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/


[PATCH 3/5] virtio-scsi: use pr_err instead of printk

2012-11-07 Thread Wanlong Gao
Use pr_err() instead of printk() for code cleanups.

Cc: James E.J. Bottomley 
Cc: Paolo Bonzini 
Cc: Rusty Russell 
Cc: linux-s...@vger.kernel.org
Cc: k...@vger.kernel.org
Signed-off-by: Wanlong Gao 
---
 drivers/scsi/virtio_scsi.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 5390229..765138a 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -790,8 +790,7 @@ static int __init init(void)
 
virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
if (!virtscsi_cmd_cache) {
-   printk(KERN_ERR "kmem_cache_create() for "
-   "virtscsi_cmd_cache failed\n");
+   pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
goto error;
}
 
@@ -800,8 +799,7 @@ static int __init init(void)
mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
 virtscsi_cmd_cache);
if (!virtscsi_cmd_pool) {
-   printk(KERN_ERR "mempool_create() for"
-   "virtscsi_cmd_pool failed\n");
+   pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
goto error;
}
ret = register_virtio_driver(&virtio_scsi_driver);
-- 
1.8.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/


Re: [PATCH 15/19] mm: numa: Add fault driven placement and migration

2012-11-07 Thread Mel Gorman
On Tue, Nov 06, 2012 at 02:41:13PM -0500, Rik van Riel wrote:
> On 11/06/2012 04:14 AM, Mel Gorman wrote:
> >From: Peter Zijlstra 
> >
> >NOTE: This patch is based on "sched, numa, mm: Add fault driven
> > placement and migration policy" but as it throws away all the policy
> > to just leave a basic foundation I had to drop the signed-offs-by.
> >
> >This patch creates a bare-bones method for setting PTEs pte_numa in the
> >context of the scheduler that when faulted later will be faulted onto the
> >node the CPU is running on.  In itself this does nothing useful but any
> >placement policy will fundamentally depend on receiving hints on placement
> >from fault context and doing something intelligent about it.
> >
> >Signed-off-by: Mel Gorman 
> 
> Excellent basis for implementing a smarter NUMA
> policy.
> 
> Not sure if such a policy should be implemented
> as a replacement for this patch, or on top of it...
> 

I'm expecting on top of it. As a POC, I'm looking at implementing the CPU
Follows Memory algorithm (mostly from autonuma) on top of this but using the
home-node logic from schednuma to handle how processes get scheduled. MORON
will need to relax to take the home node into account to avoid fighting
the home-node decisions. task_numa_fault() determines if the home node
needs to change based on statistics it gathers from faults. So far I am
keeping within the framework but it is still a WIP.

> Either way, thank you for cleaning up all of the
> NUMA base code, while I was away at conferences
> and stuck in airports :)
> 

My pleasure. Thanks a lot for reviewing this!

-- 
Mel Gorman
SUSE Labs
--
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/5] virtio-scsi: remove the useless assignment

2012-11-07 Thread Wanlong Gao
Reassign err is not needed, just a cleanup.

Cc: James E.J. Bottomley 
Cc: Paolo Bonzini 
Cc: Rusty Russell 
Cc: linux-s...@vger.kernel.org
Cc: k...@vger.kernel.org
Signed-off-by: Wanlong Gao 
---
 drivers/scsi/virtio_scsi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index d5f9f45..8746c37 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -669,7 +669,6 @@ static int virtscsi_init(struct virtio_device *vdev,
goto out;
}
}
-   err = 0;
 
 out:
if (err)
-- 
1.8.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/


  1   2   3   4   5   6   >