Re: [RFC 00/26] perf tools: Introduce hists specific format entries

2016-02-02 Thread Jiri Olsa
On Tue, Feb 02, 2016 at 07:42:16PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Feb 02, 2016 at 07:22:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Ok, so I rebased it on top of my perf/core branch, adjusting some stuff
> > wrt recent patchkits from Namhyung (hist_entry__callchain_fprintf() is
> > no more, etc), and renaming that perf_hpp_list->{list,sort_list} to
> > ->{fields,sorts} as Namhyung suggested and you agreed, it builds...
> > 
> > But perf top isn't showing the overhead column... there were some
> > changes to perf report in this patchkit to move some initializations...
> > will check there...
> 
> Fixed, doing the same change you made for 'perf report', moving the
> setup_sorting call to after the setup_browser one, inserted a new patch
> with that just before the patch where the problem was bisected, please
> check.
> 
> To recap:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tmp.perf/hists/hpp_list
> 
> https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=tmp.perf/hists/hpp_list=7d105448f8922679956728a7f5106218378c450e

I'll check on that, thanks a lot

jirka


[PATCH v2] pinctrl: sunxi: H3 requires irq_read_needs_mux

2016-02-02 Thread Krzysztof Adamski

It seems that on H3, just like on A10, when GPIOs are configured as
external interrupt data registers does not contain their value.  When
value is read, GPIO function must be temporary switched to input for
reads.

Signed-off-by: Krzysztof Adamski 
---

Changes compared to v1:
- None, but the patch was sent with wrong "From:", if you want to apply 
 it, please apply this one. Sorry for confusion.



drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c 
b/drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c
index 77d4cf0..11760bb 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c
@@ -492,6 +492,7 @@ static const struct sunxi_pinctrl_desc 
sun8i_h3_pinctrl_data = {
.pins = sun8i_h3_pins,
.npins = ARRAY_SIZE(sun8i_h3_pins),
.irq_banks = 2,
+   .irq_read_needs_mux = true
};

static int sun8i_h3_pinctrl_probe(struct platform_device *pdev)
--
2.4.2



Re: [PATCH] iio: chemical: select IRQ_WORK for ATLAS ph sensor

2016-02-02 Thread Matt Ranostay
Reviewed-by: Matt Ranostay 

On Tue, Feb 2, 2016 at 6:36 AM, Arnd Bergmann  wrote:
> The newly added atlas-ph-sensor driver uses irq_work_queue, which
> may not always be enabled:
>
> ERROR: "irq_work_queue" [drivers/iio/chemical/atlas-ph-sensor.ko] undefined!
>
> This adds a 'select' statement to Kconfig to ensure it's there
> when we need it.
>
> Signed-off-by: Arnd Bergmann 
> Fixes: 27dec00ecf2d ("iio: chemical: add Atlas pH-SM sensor support")
>
> diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig
> index ce7cd1370f74..f73290f84c90 100644
> --- a/drivers/iio/chemical/Kconfig
> +++ b/drivers/iio/chemical/Kconfig
> @@ -10,6 +10,7 @@ config ATLAS_PH_SENSOR
> select REGMAP_I2C
> select IIO_BUFFER
> select IIO_TRIGGERED_BUFFER
> +   select IRQ_WORK
> help
>  Say Y here to build I2C interface support for the Atlas
>  Scientific OEM pH-SM sensor.
>


Re: [PATCH 03/10] arm64: add Armada 3700 architecture entry

2016-02-02 Thread Gregory CLEMENT
Hi Jisheng,
 
 On mer., févr. 03 2016, Jisheng Zhang  wrote:

> On Tue, 2 Feb 2016 19:07:41 +0100 Gregory CLEMENT wrote:
>
>> The Armada 3700 is an mvebu ARM64 SoC using one or two Cortex-A53 cores
>> depending of the variant.
>> 
>> Signed-off-by: Gregory CLEMENT 
>> Reviewed-by: Thomas Petazzoni 
>> ---
>>  arch/arm64/Kconfig.platforms | 6 ++
>>  1 file changed, 6 insertions(+)
>> 
>> diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
>> index 21074f674bde..7da341f7b90d 100644
>> --- a/arch/arm64/Kconfig.platforms
>> +++ b/arch/arm64/Kconfig.platforms
>> @@ -1,5 +1,11 @@
>>  menu "Platform selection"
>>  
>> +config ARCH_ARMADA_3700
>
> Would it be better to use ARCH_MVEBU? IMHO, there will be more ARMv8 SoCs
> from our EBU, do we plan to add one CONFIG_ARMADA_yyzz for each SoC?

Not for each SoC but for each family, yes. As we did for the other mvebu
SoC families.

Gregory

>
>> +bool "Armada 3700 SoC Family"
>> +help
>> +  This enables support for Armada 3700 SoC Family. It is is an
>> +  ARMv8 based chipset belonging to the mvebu family.
>> +
>>  config ARCH_BCM_IPROC
>>  bool "Broadcom iProc SoC Family"
>>  help
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


Re: [PATCH] dax: allow DAX to look up an inode's block device

2016-02-02 Thread Dave Chinner
On Tue, Feb 02, 2016 at 04:33:16PM -0800, Jared Hulbert wrote:
> On Tue, Feb 2, 2016 at 3:41 PM, Dan Williams  wrote:
> > On Tue, Feb 2, 2016 at 3:36 PM, Jared Hulbert  wrote:
> >> On Tue, Feb 2, 2016 at 3:19 PM, Al Viro  wrote:
> >>>
> >>> On Tue, Feb 02, 2016 at 04:11:42PM -0700, Ross Zwisler wrote:
> >>>
> >>> > However, for raw block devices and for XFS with a real-time device, the
> >>> > value in inode->i_sb->s_bdev is not correct.  With the code as it is
> >>> > currently written, an fsync or msync to a DAX enabled raw block device 
> >>> > will
> >>> > cause a NULL pointer dereference kernel BUG.  For this to work 
> >>> > correctly we
> >>> > need to ask the block device or filesystem what struct block_device is
> >>> > appropriate for our inode.
> >>> >
> >>> > To that end, add a get_bdev(struct inode *) entry point to struct
> >>> > super_operations.  If this function pointer is non-NULL, this notifies 
> >>> > DAX
> >>> > that it needs to use it to look up the correct block_device.  If
> >>> > i_sb->get_bdev() is NULL DAX will default to inode->i_sb->s_bdev.
> >>>
> >>> Umm...  It assumes that bdev will stay pinned for as long as inode is
> >>> referenced, presumably?  If so, that needs to be documented (and verified
> >>> for existing fs instances).  In principle, multi-disk fs might want to
> >>> support things like "silently move the inodes backed by that disk to other
> >>> ones"...
> >>
> >> Dan, This is exactly the kind of thing I'm taking about WRT the
> >> weirder device models and directly calling bdev_direct_access().
> >> Filesystems don't have the monogamous relationship with a device that
> >> is implicitly assumed in DAX, you have to ask the filesystem what the
> >> relationship is and is migrating to, and allow the filesystem to
> >> update DAX when the relationship is changing.
> >
> > That's precisely what ->get_bdev() does.  When the answer
> > inode->i_sb->s_bdev lookup is invalid, use ->get_bdev().
> >
> >> As we start to see many
> >> DIMM's and 10s TiB pmem systems this is going be an even bigger deal
> >> as load balancing, wear leveling, and fault tolerance concerned are
> >> inevitably driven by the filesystem.
> >
> > No, there are no plans on the horizon for an fs to manage these media
> > specific concerns for persistent memory.
> 
> So the filesystem is now directly in charge of mapping user pages to
> physical memory.  The filesystem is effectively bypassing NUMA and
> zones and all that stuff that tries to balance memory bus and QPI
> traffic etc.

No, it's isn't bypassing NUMA, zones, etc.

The pmem block device can linearise a typical NUMA layout quite
sanely.  i.e. if there is 10GB of pmem per node, the pmem device
would need to map that as:

node   block device offsets
 0   0..10GB
 1  10..20GB
 2  20..30GB
 
 n   N..(N+1)GB

i.e. present a *linear concatentation* of discrete nodes in a linear
address space.

Then, we can use the fact that XFS has a piecewise address space
architecture that can map linear chunks of the block device address
space to different logical domains. Each piece of an XFS filesystem
is an allocation group. Hence we tell mkfs.xfs to set the allocation
group size to 10GB, thereby mapping each individual allocation group
to a different physical node of pmem.  Suddenly all the filesystem
allocation control algorithms become physical device locality
control algorithms.

Then we simply map process locality control (cpusets or
memcgs or whatever is being used for that now) to the allocator -
instead of selecting AGs for allocation based on inode/parent inode
locality, we select AGs based on the allowed CPU/numa node mask of
the process that is running...

An even better architecture would be to present a pmem device per
discrete node and then use DM to build the concat as required. Or
enable us to stripe across nodes for higher performance in large
concurrent applications, or configure RAID mirrors in physically
separate parts of the NUMA topology for redundancy (e.g a water leak
that physically destroys a rack doesn't cause data loss because the
copies are in different racks (i.e. located in different failure
domains)) then we can concat/stripe those mirrors together, etc.

IOWs, we've already got all the pieces in place that we need to
handle pmem in just about any way you can imagine in NUMA machines;
the filesystem is just one of the pieces.

This is just another example of how yet another new-fangled storage
technology maps precisely to a well known, long serving storage
architecture that we already have many, many experts out there that
know to build reliable, performant storage from... :)

> You don't think the filesystem will therefore be in
> charge of memory bus hotspots?

Filesystems and DM are already in charge of avoiding hotspots on
disks, RAID arrays or in storage fabrics that can sustain tens of
GB/s throughput. This really 

[PATCHv3] mm/slab: fix race with dereferencing NULL ptr in alloc_calls_show

2016-02-02 Thread Dmitry Safonov
memcg_destroy_kmem_caches shutdowns in the first place kmem_caches under
slab_mutex which involves freeing NUMA node structures for kmem_cache
and only then under release_caches removes corresponding sysfs files for
these caches. Which may lead to dereferencing NULL ptr on read.
Lets remove sysfs files right there.

Fixes the following panic:
[43963.463055] BUG: unable to handle kernel
[43963.463090] NULL pointer dereference at 0020
[43963.463146] IP: [] list_locations+0x169/0x4e0
[43963.463185] PGD 257304067 PUD 438456067 PMD 0
[43963.463220] Oops:  [#1] SMP
[43963.463850] CPU: 3 PID: 973074 Comm: cat ve: 0 Not tainted 
3.10.0-229.7.2.ovz.9.30-7-japdoll-dirty #2 9.30
[43963.463913] Hardware name: DEPO Computers To Be Filled By O.E.M./H67DE3, 
BIOS L1.60c 07/14/2011
[43963.463976] task: 88042a5dc5b0 ti: 88037f8d8000 task.ti: 
88037f8d8000
[43963.464036] RIP: 0010:[]  [] 
list_locations+0x169/0x4e0
[43963.464725] Call Trace:
[43963.464756]  [] alloc_calls_show+0x1d/0x30
[43963.464793]  [] slab_attr_show+0x1b/0x30
[43963.464829]  [] sysfs_read_file+0x9a/0x1a0
[43963.464865]  [] vfs_read+0x9c/0x170
[43963.464900]  [] SyS_read+0x58/0xb0
[43963.464936]  [] system_call_fastpath+0x16/0x1b
[43963.464970] Code: 5e 07 12 00 b9 00 04 00 00 3d 00 04 00 00 0f 4f c1 3d 00 
04 00 00 89 45 b0 0f 84 c3 00 00 00 48 63 45 b0 49 8b 9c c4 f8 00 00 00 <48> 8b 
43 20 48 85 c0 74 b6 48 89 df e8 46 37 44 00 48 8b 53 10
[43963.465119] RIP  [] list_locations+0x169/0x4e0
[43963.465155]  RSP 
[43963.465185] CR2: 0020

Cc: Vladimir Davydov 
Signed-off-by: Dmitry Safonov 
---
v2: Down with SLAB_SUPPORTS_SYSFS thing.
v3: Moved sysfs_slab_remove inside shutdown_cache

 include/linux/slub_def.h | 10 --
 mm/slab.h|  8 
 mm/slab_common.c | 10 --
 mm/slub.c|  6 --
 4 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index b7e57927..43634cd 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -101,16 +101,6 @@ struct kmem_cache {
struct kmem_cache_node *node[MAX_NUMNODES];
 };
 
-#ifdef CONFIG_SYSFS
-#define SLAB_SUPPORTS_SYSFS
-void sysfs_slab_remove(struct kmem_cache *);
-#else
-static inline void sysfs_slab_remove(struct kmem_cache *s)
-{
-}
-#endif
-
-
 /**
  * virt_to_obj - returns address of the beginning of object.
  * @s: object's kmem_cache
diff --git a/mm/slab.h b/mm/slab.h
index 834ad24..2983ab2 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -367,6 +367,14 @@ static inline struct kmem_cache_node *get_node(struct 
kmem_cache *s, int node)
 
 #endif
 
+#if defined(CONFIG_SLUB) && defined(CONFIG_SYSFS)
+void sysfs_slab_remove(struct kmem_cache *);
+#else
+static inline void sysfs_slab_remove(struct kmem_cache *s)
+{
+}
+#endif
+
 void *slab_start(struct seq_file *m, loff_t *pos);
 void *slab_next(struct seq_file *m, void *p, loff_t *pos);
 void slab_stop(struct seq_file *m, void *p);
diff --git a/mm/slab_common.c b/mm/slab_common.c
index b50aef0..2bfc0b1 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -451,6 +451,8 @@ EXPORT_SYMBOL(kmem_cache_create);
 static int shutdown_cache(struct kmem_cache *s,
struct list_head *release, bool *need_rcu_barrier)
 {
+   sysfs_slab_remove(s);
+
if (__kmem_cache_shutdown(s) != 0)
return -EBUSY;
 
@@ -468,13 +470,8 @@ static void release_caches(struct list_head *release, bool 
need_rcu_barrier)
if (need_rcu_barrier)
rcu_barrier();
 
-   list_for_each_entry_safe(s, s2, release, list) {
-#ifdef SLAB_SUPPORTS_SYSFS
-   sysfs_slab_remove(s);
-#else
+   list_for_each_entry_safe(s, s2, release, list)
slab_kmem_cache_release(s);
-#endif
-   }
 }
 
 #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB)
@@ -614,6 +611,7 @@ void memcg_destroy_kmem_caches(struct mem_cgroup *memcg)
list_for_each_entry_safe(s, s2, _caches, list) {
if (is_root_cache(s) || s->memcg_params.memcg != memcg)
continue;
+
/*
 * The cgroup is about to be freed and therefore has no charges
 * left. Hence, all its caches must be empty by now.
diff --git a/mm/slub.c b/mm/slub.c
index 2e1355a..b6a68b7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5296,11 +5296,6 @@ static void memcg_propagate_slab_attrs(struct kmem_cache 
*s)
 #endif
 }
 
-static void kmem_cache_release(struct kobject *k)
-{
-   slab_kmem_cache_release(to_slab(k));
-}
-
 static const struct sysfs_ops slab_sysfs_ops = {
.show = slab_attr_show,
.store = slab_attr_store,
@@ -5308,7 +5303,6 @@ static const struct sysfs_ops slab_sysfs_ops = {
 
 static struct kobj_type slab_ktype = {
.sysfs_ops = _sysfs_ops,
-   .release = kmem_cache_release,
 };
 
 static int uevent_filter(struct kset *kset, struct kobject *kobj)
-- 
2.7.0



[RESEND PATCH 1/9] ipv4: Namespaceify tcp syn retries sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  2 ++
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 18 +-
 net/ipv4/tcp.c |  3 ++-
 net/ipv4/tcp_ipv4.c|  2 ++
 net/ipv4/tcp_timer.c   |  4 ++--
 6 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index ffa2777b6475..59c6155e4896 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -95,6 +95,8 @@ struct netns_ipv4 {
int sysctl_tcp_keepalive_probes;
int sysctl_tcp_keepalive_intvl;
 
+   int sysctl_tcp_syn_retries;
+
struct ping_group_range ping_group_range;
 
atomic_t dev_addr_genid;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3ed10fc89c7d..a7f6f25297d7 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -240,7 +240,6 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
-extern int sysctl_tcp_syn_retries;
 extern int sysctl_tcp_synack_retries;
 extern int sysctl_tcp_retries1;
 extern int sysctl_tcp_retries2;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index fccf8e92bf81..db95287d2b94 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -293,15 +293,6 @@ static struct ctl_table ipv4_table[] = {
.extra2 = _ttl_max,
},
{
-   .procname   = "tcp_syn_retries",
-   .data   = _tcp_syn_retries,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec_minmax,
-   .extra1 = _syn_retries_min,
-   .extra2 = _syn_retries_max
-   },
-   {
.procname   = "tcp_synack_retries",
.data   = _tcp_synack_retries,
.maxlen = sizeof(int),
@@ -950,6 +941,15 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec_jiffies,
},
+   {
+   .procname   = "tcp_syn_retries",
+   .data   = _net.ipv4.sysctl_tcp_syn_retries,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra1 = _syn_retries_min,
+   .extra2 = _syn_retries_max
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c82cca18c90f..bb36a39b5685 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2722,6 +2722,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
 {
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
int val, len;
 
if (get_user(len, optlen))
@@ -2756,7 +2757,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
val = keepalive_probes(tp);
break;
case TCP_SYNCNT:
-   val = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
+   val = icsk->icsk_syn_retries ? : 
net->ipv4.sysctl_tcp_syn_retries;
break;
case TCP_LINGER2:
val = tp->linger2;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 9db9bdb14449..c9944e0c48d3 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2382,6 +2382,8 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_keepalive_probes = TCP_KEEPALIVE_PROBES;
net->ipv4.sysctl_tcp_keepalive_intvl = TCP_KEEPALIVE_INTVL;
 
+   net->ipv4.sysctl_tcp_syn_retries = TCP_SYN_RETRIES;
+
return 0;
 fail:
tcp_sk_exit(net);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index a4730a28b220..c5d51f530c65 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 
-int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
 int sysctl_tcp_retries1 __read_mostly = TCP_RETR1;
 int sysctl_tcp_retries2 __read_mostly = TCP_RETR2;
@@ -157,6 +156,7 @@ static int tcp_write_timeout(struct sock *sk)
 {
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
int retry_until;
bool do_reset, syn_set = false;
 
@@ -169,7 +169,7 @@ static int tcp_write_timeout(struct sock *sk)
NET_INC_STATS_BH(sock_net(sk),
 
LINUX_MIB_TCPFASTOPENACTIVEFAIL);
}
-   retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
+   retry_until = icsk->icsk_syn_retries ? : 
net->ipv4.sysctl_tcp_syn_retries;

[RESEND PATCH 2/9] ipv4: Namespaceify tcp synack retries sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h|  1 +
 include/net/tcp.h   |  1 -
 net/ipv4/inet_connection_sock.c |  7 ++-
 net/ipv4/sysctl_net_ipv4.c  | 14 +++---
 net/ipv4/tcp_ipv4.c |  1 +
 net/ipv4/tcp_timer.c|  3 +--
 6 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 59c6155e4896..bca049102441 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -96,6 +96,7 @@ struct netns_ipv4 {
int sysctl_tcp_keepalive_intvl;
 
int sysctl_tcp_syn_retries;
+   int sysctl_tcp_synack_retries;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index a7f6f25297d7..5a162875e80c 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -240,7 +240,6 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
-extern int sysctl_tcp_synack_retries;
 extern int sysctl_tcp_retries1;
 extern int sysctl_tcp_retries2;
 extern int sysctl_tcp_orphan_retries;
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 46b9c887bede..9b17c1792dce 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -482,10 +482,6 @@ EXPORT_SYMBOL_GPL(inet_csk_route_child_sock);
 #define AF_INET_FAMILY(fam) true
 #endif
 
-/* Only thing we need from tcp.h */
-extern int sysctl_tcp_synack_retries;
-
-
 /* Decide when to expire the request and when to resend SYN-ACK */
 static inline void syn_ack_recalc(struct request_sock *req, const int thresh,
  const int max_retries,
@@ -557,6 +553,7 @@ static void reqsk_timer_handler(unsigned long data)
 {
struct request_sock *req = (struct request_sock *)data;
struct sock *sk_listener = req->rsk_listener;
+   struct net *net = sock_net(sk_listener);
struct inet_connection_sock *icsk = inet_csk(sk_listener);
struct request_sock_queue *queue = >icsk_accept_queue;
int qlen, expire = 0, resend = 0;
@@ -566,7 +563,7 @@ static void reqsk_timer_handler(unsigned long data)
if (sk_state_load(sk_listener) != TCP_LISTEN)
goto drop;
 
-   max_retries = icsk->icsk_syn_retries ? : sysctl_tcp_synack_retries;
+   max_retries = icsk->icsk_syn_retries ? : 
net->ipv4.sysctl_tcp_synack_retries;
thresh = max_retries;
/* Normally all the openreqs are young and become mature
 * (i.e. converted to established socket) for first timeout.
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index db95287d2b94..5dd89de5bf8d 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -293,13 +293,6 @@ static struct ctl_table ipv4_table[] = {
.extra2 = _ttl_max,
},
{
-   .procname   = "tcp_synack_retries",
-   .data   = _tcp_synack_retries,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_max_orphans",
.data   = _tcp_max_orphans,
.maxlen = sizeof(int),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.extra1 = _syn_retries_min,
.extra2 = _syn_retries_max
},
+   {
+   .procname   = "tcp_synack_retries",
+   .data   = _net.ipv4.sysctl_tcp_synack_retries,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c9944e0c48d3..a5268576021c 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2383,6 +2383,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_keepalive_intvl = TCP_KEEPALIVE_INTVL;
 
net->ipv4.sysctl_tcp_syn_retries = TCP_SYN_RETRIES;
+   net->ipv4.sysctl_tcp_synack_retries = TCP_SYNACK_RETRIES;
 
return 0;
 fail:
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index c5d51f530c65..ca25fdf0c525 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 
-int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
 int sysctl_tcp_retries1 __read_mostly = TCP_RETR1;
 int sysctl_tcp_retries2 __read_mostly = TCP_RETR2;
 int sysctl_tcp_orphan_retries __read_mostly;
@@ -332,7 +331,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk)
 {
struct inet_connection_sock *icsk = inet_csk(sk);
int max_retries = icsk->icsk_syn_retries ? :
-   sysctl_tcp_synack_retries + 1; /* add one more retry for fastopen */
+   

[RESEND PATCH 5/9] ipv4: Namespaceify tcp_retries1 sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 16 
 net/ipv4/tcp_ipv4.c|  1 +
 net/ipv4/tcp_timer.c   |  8 
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index dff8879e02fe..250bd940eb94 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -99,6 +99,7 @@ struct netns_ipv4 {
int sysctl_tcp_synack_retries;
int sysctl_tcp_syncookies;
int sysctl_tcp_reordering;
+   int sysctl_tcp_retries1;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 64d01d289441..60ee244772c9 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -240,7 +240,6 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
-extern int sysctl_tcp_retries1;
 extern int sysctl_tcp_retries2;
 extern int sysctl_tcp_orphan_retries;
 extern int sysctl_tcp_fastopen;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 12d752e6380b..12216ec333b4 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -321,14 +321,6 @@ static struct ctl_table ipv4_table[] = {
.proc_handler   = proc_dointvec
},
{
-   .procname   = "tcp_retries1",
-   .data   = _tcp_retries1,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec_minmax,
-   .extra2 = _retr1_max
-   },
-   {
.procname   = "tcp_retries2",
.data   = _tcp_retries2,
.maxlen = sizeof(int),
@@ -950,6 +942,14 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec
},
+   {
+   .procname   = "tcp_retries1",
+   .data   = _net.ipv4.sysctl_tcp_retries1,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_minmax,
+   .extra2 = _retr1_max
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 785bbebd6768..ea5ed84f4fb1 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2385,6 +2385,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_synack_retries = TCP_SYNACK_RETRIES;
net->ipv4.sysctl_tcp_syncookies = 0;
net->ipv4.sysctl_tcp_reordering = TCP_FASTRETRANS_THRESH;
+   net->ipv4.sysctl_tcp_retries1 = TCP_RETR1;
 
return 0;
 fail:
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index ca25fdf0c525..6694e33149b9 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 
-int sysctl_tcp_retries1 __read_mostly = TCP_RETR1;
 int sysctl_tcp_retries2 __read_mostly = TCP_RETR2;
 int sysctl_tcp_orphan_retries __read_mostly;
 int sysctl_tcp_thin_linear_timeouts __read_mostly;
@@ -171,7 +170,7 @@ static int tcp_write_timeout(struct sock *sk)
retry_until = icsk->icsk_syn_retries ? : 
net->ipv4.sysctl_tcp_syn_retries;
syn_set = true;
} else {
-   if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0, 0)) {
+   if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0, 
0)) {
/* Some middle-boxes may black-hole Fast Open _after_
 * the handshake. Therefore we conservatively disable
 * Fast Open on this path on recurring timeouts with
@@ -180,7 +179,7 @@ static int tcp_write_timeout(struct sock *sk)
if (tp->syn_data_acked &&
tp->bytes_acked <= tp->rx_opt.mss_clamp) {
tcp_fastopen_cache_set(sk, 0, NULL, true, 0);
-   if (icsk->icsk_retransmits == 
sysctl_tcp_retries1)
+   if (icsk->icsk_retransmits == 
net->ipv4.sysctl_tcp_retries1)
NET_INC_STATS_BH(sock_net(sk),
 
LINUX_MIB_TCPFASTOPENACTIVEFAIL);
}
@@ -359,6 +358,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk)
 void tcp_retransmit_timer(struct sock *sk)
 {
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
 
if (tp->fastopen_rsk) {
@@ -489,7 +489,7 @@ out_reset_timer:
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
}
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, 
TCP_RTO_MAX);
- 

[RESEND PATCH 0/9] Namespaceify more of the tcp sysctl knobs

2016-02-02 Thread Nikolay Borisov
This patch series continues making more of the tcp-related
sysctl knobs be per net-namespace. Most of these apply per
socket and have global defaults so should be safe and I
don't expect any breakages. 

Having those per net-namespace is useful when multiple  
containers are hosted and it is required to tune the 
tcp settings for each independently of the host node. 

I've split the patches to be per-sysctl but after
the review if the outcome is positive I'm happy
to either send it in one big blob or just.  

Nikolay Borisov (9):
  ipv4: Namespaceify tcp syn retries sysctl knob
  ipv4: Namespaceify tcp synack retries sysctl knob
  ipv4: Namespaceify tcp syncookies sysctl knob
  ipv4: Namespaceify tcp reordering sysctl knob
  ipv4: Namespaceify tcp_retries1 sysctl knob
  ipv4: Namespaceify tcp_retries2 sysctl knob
  ipv4: Namespaceify tcp_orphan_retries sysctl knob
  ipv4: Namespaceify tcp_fin_timeout sysctl knob
  ipv4: Namespaceify tcp_notsent_lowat sysctl knob

 include/net/netns/ipv4.h|  10 +++
 include/net/tcp.h   |  17 ++---
 net/ipv4/inet_connection_sock.c |   7 +--
 net/ipv4/syncookies.c   |   4 +-
 net/ipv4/sysctl_net_ipv4.c  | 136 
 net/ipv4/tcp.c  |  12 ++--
 net/ipv4/tcp_input.c|  22 ---
 net/ipv4/tcp_ipv4.c |  11 +++-
 net/ipv4/tcp_metrics.c  |   3 +-
 net/ipv4/tcp_minisocks.c|   3 -
 net/ipv4/tcp_output.c   |   6 +-
 net/ipv4/tcp_timer.c|  23 +++
 net/ipv6/syncookies.c   |   2 +-
 13 files changed, 130 insertions(+), 126 deletions(-)

-- 
2.5.0



[RESEND PATCH 3/9] ipv4: Namespaceify tcp syncookies sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  2 ++
 include/net/tcp.h  |  1 -
 net/ipv4/syncookies.c  |  4 +---
 net/ipv4/sysctl_net_ipv4.c | 18 +-
 net/ipv4/tcp_input.c   | 10 ++
 net/ipv4/tcp_ipv4.c|  3 ++-
 net/ipv4/tcp_minisocks.c   |  3 ---
 net/ipv6/syncookies.c  |  2 +-
 8 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index bca049102441..80da0d095eaf 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -98,6 +98,8 @@ struct netns_ipv4 {
int sysctl_tcp_syn_retries;
int sysctl_tcp_synack_retries;
 
+   int sysctl_tcp_syncookies;
+
struct ping_group_range ping_group_range;
 
atomic_t dev_addr_genid;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5a162875e80c..5497cc809601 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -243,7 +243,6 @@ extern int sysctl_tcp_fin_timeout;
 extern int sysctl_tcp_retries1;
 extern int sysctl_tcp_retries2;
 extern int sysctl_tcp_orphan_retries;
-extern int sysctl_tcp_syncookies;
 extern int sysctl_tcp_fastopen;
 extern int sysctl_tcp_retrans_collapse;
 extern int sysctl_tcp_stdurg;
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 4cbe9f0a4281..1c2bfda72c07 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -19,8 +19,6 @@
 #include 
 #include 
 
-extern int sysctl_tcp_syncookies;
-
 static u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS] __read_mostly;
 
 #define COOKIEBITS 24  /* Upper bits store count */
@@ -307,7 +305,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct 
sk_buff *skb)
__u8 rcv_wscale;
struct flowi4 fl4;
 
-   if (!sysctl_tcp_syncookies || !th->ack || th->rst)
+   if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst)
goto out;
 
if (tcp_synq_no_recent_overflow(sk))
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 5dd89de5bf8d..007b9f8f7a2a 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -342,15 +342,6 @@ static struct ctl_table ipv4_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec_jiffies,
},
-#ifdef CONFIG_SYN_COOKIES
-   {
-   .procname   = "tcp_syncookies",
-   .data   = _tcp_syncookies,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-#endif
{
.procname   = "tcp_fastopen",
.data   = _tcp_fastopen,
@@ -950,6 +941,15 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec
},
+#ifdef CONFIG_SYN_COOKIES
+   {
+   .procname   = "tcp_syncookies",
+   .data   = _net.ipv4.sysctl_tcp_syncookies,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
+#endif
{ }
 };
 
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 2d656eef7f8e..dc8fe6c8a2e0 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6114,9 +6114,10 @@ static bool tcp_syn_flood_action(const struct sock *sk,
struct request_sock_queue *queue = _csk(sk)->icsk_accept_queue;
const char *msg = "Dropping request";
bool want_cookie = false;
+   struct net *net = sock_net(sk);
 
 #ifdef CONFIG_SYN_COOKIES
-   if (sysctl_tcp_syncookies) {
+   if (net->ipv4.sysctl_tcp_syncookies) {
msg = "Sending cookies";
want_cookie = true;
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDOCOOKIES);
@@ -6125,7 +6126,7 @@ static bool tcp_syn_flood_action(const struct sock *sk,
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
 
if (!queue->synflood_warned &&
-   sysctl_tcp_syncookies != 2 &&
+   net->ipv4.sysctl_tcp_syncookies != 2 &&
xchg(>synflood_warned, 1) == 0)
pr_info("%s: Possible SYN flooding on port %d. %s.  Check SNMP 
counters.\n",
proto, ntohs(tcp_hdr(skb)->dest), msg);
@@ -6158,6 +6159,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
__u32 isn = TCP_SKB_CB(skb)->tcp_tw_isn;
struct tcp_options_received tmp_opt;
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
struct sock *fastopen_sk = NULL;
struct dst_entry *dst = NULL;
struct request_sock *req;
@@ -6168,7 +6170,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
 * limitations, they conserve resources and peer is
 * evidently real one.
 */
-   if ((sysctl_tcp_syncookies == 2 ||
+   if 

[RESEND PATCH 9/9] ipv4: Namespaceify tcp_notsent_lowat sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  4 ++--
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp_ipv4.c|  1 +
 net/ipv4/tcp_output.c  |  3 ---
 5 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index a1caddadecc2..df265ea5bc72 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -103,6 +103,7 @@ struct netns_ipv4 {
int sysctl_tcp_retries2;
int sysctl_tcp_orphan_retries;
int sysctl_tcp_fin_timeout;
+   unsigned int sysctl_tcp_notsent_lowat;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index f8c3f75e6c99..83de2b9f970e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -267,7 +267,6 @@ extern int sysctl_tcp_thin_dupack;
 extern int sysctl_tcp_early_retrans;
 extern int sysctl_tcp_limit_output_bytes;
 extern int sysctl_tcp_challenge_ack_limit;
-extern unsigned int sysctl_tcp_notsent_lowat;
 extern int sysctl_tcp_min_tso_segs;
 extern int sysctl_tcp_min_rtt_wlen;
 extern int sysctl_tcp_autocorking;
@@ -1665,7 +1664,8 @@ void __tcp_v4_send_check(struct sk_buff *skb, __be32 
saddr, __be32 daddr);
 
 static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
 {
-   return tp->notsent_lowat ?: sysctl_tcp_notsent_lowat;
+   struct net *net = sock_net((struct sock *)tp);
+   return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat;
 }
 
 static inline bool tcp_stream_memory_free(const struct sock *sk)
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 20e086f88438..23afa08641c2 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -457,13 +457,6 @@ static struct ctl_table ipv4_table[] = {
.extra1 = ,
},
{
-   .procname   = "tcp_notsent_lowat",
-   .data   = _tcp_notsent_lowat,
-   .maxlen = sizeof(sysctl_tcp_notsent_lowat),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec,
-   },
-   {
.procname   = "tcp_rmem",
.data   = _tcp_rmem,
.maxlen = sizeof(sysctl_tcp_rmem),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec_jiffies,
},
+   {
+   .procname   = "tcp_notsent_lowat",
+   .data   = _net.ipv4.sysctl_tcp_notsent_lowat,
+   .maxlen = sizeof(unsigned int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec,
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3c263c00f5ea..2871acf8f4b9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2389,6 +2389,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_retries2 = TCP_RETR2;
net->ipv4.sysctl_tcp_orphan_retries = 0;
net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
+   net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
 
return 0;
 fail:
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e997488b2f8f..54455739e851 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -62,9 +62,6 @@ int sysctl_tcp_tso_win_divisor __read_mostly = 3;
 /* By default, RFC2861 behavior.  */
 int sysctl_tcp_slow_start_after_idle __read_mostly = 1;
 
-unsigned int sysctl_tcp_notsent_lowat __read_mostly = UINT_MAX;
-EXPORT_SYMBOL(sysctl_tcp_notsent_lowat);
-
 static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
   int push_one, gfp_t gfp);
 
-- 
2.5.0



[RESEND PATCH 6/9] ipv4: Namespaceify tcp_retries2 sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp_ipv4.c|  1 +
 net/ipv4/tcp_output.c  |  3 ++-
 net/ipv4/tcp_timer.c   |  5 ++---
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 250bd940eb94..3cb2073c55f5 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -100,6 +100,7 @@ struct netns_ipv4 {
int sysctl_tcp_syncookies;
int sysctl_tcp_reordering;
int sysctl_tcp_retries1;
+   int sysctl_tcp_retries2;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 60ee244772c9..9b3aabbac85e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -240,7 +240,6 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
-extern int sysctl_tcp_retries2;
 extern int sysctl_tcp_orphan_retries;
 extern int sysctl_tcp_fastopen;
 extern int sysctl_tcp_retrans_collapse;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 12216ec333b4..39c302fda534 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -321,13 +321,6 @@ static struct ctl_table ipv4_table[] = {
.proc_handler   = proc_dointvec
},
{
-   .procname   = "tcp_retries2",
-   .data   = _tcp_retries2,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_fin_timeout",
.data   = _tcp_fin_timeout,
.maxlen = sizeof(int),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.proc_handler   = proc_dointvec_minmax,
.extra2 = _retr1_max
},
+   {
+   .procname   = "tcp_retries2",
+   .data   = _net.ipv4.sysctl_tcp_retries2,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index ea5ed84f4fb1..3a2db4a7d651 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2386,6 +2386,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_syncookies = 0;
net->ipv4.sysctl_tcp_reordering = TCP_FASTRETRANS_THRESH;
net->ipv4.sysctl_tcp_retries1 = TCP_RETR1;
+   net->ipv4.sysctl_tcp_retries2 = TCP_RETR2;
 
return 0;
 fail:
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 9bfc39ff2285..e997488b2f8f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3471,6 +3471,7 @@ void tcp_send_probe0(struct sock *sk)
 {
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
unsigned long probe_max;
int err;
 
@@ -3484,7 +3485,7 @@ void tcp_send_probe0(struct sock *sk)
}
 
if (err <= 0) {
-   if (icsk->icsk_backoff < sysctl_tcp_retries2)
+   if (icsk->icsk_backoff < net->ipv4.sysctl_tcp_retries2)
icsk->icsk_backoff++;
icsk->icsk_probes_out++;
probe_max = TCP_RTO_MAX;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 6694e33149b9..09f4e0297e56 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 
-int sysctl_tcp_retries2 __read_mostly = TCP_RETR2;
 int sysctl_tcp_orphan_retries __read_mostly;
 int sysctl_tcp_thin_linear_timeouts __read_mostly;
 
@@ -189,7 +188,7 @@ static int tcp_write_timeout(struct sock *sk)
dst_negative_advice(sk);
}
 
-   retry_until = sysctl_tcp_retries2;
+   retry_until = net->ipv4.sysctl_tcp_retries2;
if (sock_flag(sk, SOCK_DEAD)) {
const bool alive = icsk->icsk_rto < TCP_RTO_MAX;
 
@@ -303,7 +302,7 @@ static void tcp_probe_timer(struct sock *sk)
 (s32)(tcp_time_stamp - start_ts) > icsk->icsk_user_timeout)
goto abort;
 
-   max_probes = sysctl_tcp_retries2;
+   max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2;
if (sock_flag(sk, SOCK_DEAD)) {
const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < 
TCP_RTO_MAX;
 
-- 
2.5.0



Re: [PATCH v3 3/3] input: touchscreen: ad7879: add device tree support

2016-02-02 Thread Michael Hennerich

On 02/03/2016 12:20 AM, Stefan Agner wrote:

Add device tree support for the I2C and SPI variant of AD7879(-1).
This allows to specify the touchscreen controller as a I2C client
node or SPI slave device. Most of the options available in platform
data are also available as device tree properties, the only exception
being GPIO capabilities, which can not be activated through device
tree currently.

Acked-by: Rob Herring 
Signed-off-by: Stefan Agner 


Acked-by: Michael Hennerich 


---
Changes since v2:
- do not free driver data and irq on remove (since we are using devm now)
Changes since v1:
- Move device tree parsing to main driver file ad7879.c
- Use common touchscreen_parse_properties for common properties
- Use device_property_* API
- Use struct ad7879 directly to store parsed values
- Support SPI variant through device tree too (untested)
- Add vendor prefix to vendor specific dt properties

  .../bindings/input/touchscreen/ad7879.txt  |  53 
  drivers/input/touchscreen/ad7879-i2c.c |  10 ++
  drivers/input/touchscreen/ad7879-spi.c |  10 ++
  drivers/input/touchscreen/ad7879.c | 145 +
  4 files changed, 161 insertions(+), 57 deletions(-)
  create mode 100644 
Documentation/devicetree/bindings/input/touchscreen/ad7879.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt 
b/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt
new file mode 100644
index 000..e3f22d2
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt
@@ -0,0 +1,53 @@
+* Analog Devices AD7879(-1)/AD7889(-1) touchscreen interface (SPI/I2C)
+
+Required properties:
+- compatible   : for SPI slave, use "adi,ad7879"
+ for I2C slave, use "adi,ad7879-1"
+- reg  : SPI chipselect/I2C slave address
+ See spi-bus.txt for more SPI slave properties
+- interrupt-parent : the phandle for the interrupt controller
+- interrupts   : touch controller interrupt
+- touchscreen-max-pressure : maximum reported pressure
+- adi,resistance-plate-x   : total resistance of X-plate (for pressure
+ calculation)
+Optional properties:
+- touchscreen-swapped-x-y  : X and Y axis are swapped (boolean)
+- adi,first-conversion-delay   : 0-12: In 128us steps (starting with 128us)
+ 13  : 2.560ms
+ 14  : 3.584ms
+ 15  : 4.096ms
+ This property has to be a '/bits/ 8' value
+- adi,acquisition-time : 0: 2us
+ 1: 4us
+ 2: 8us
+ 3: 16us
+ This property has to be a '/bits/ 8' value
+- adi,median-filter-size   : 0: disabled
+ 1: 4 measurements
+ 2: 8 measurements
+ 3: 16 measurements
+ This property has to be a '/bits/ 8' value
+- adi,averaging: 0: 2 middle values (1 if median 
disabled)
+ 1: 4 middle values
+ 2: 8 middle values
+ 3: 16 values
+ This property has to be a '/bits/ 8' value
+- adi,conversion-interval: : 0: convert one time only
+ 1-255: 515us + val * 35us (up to 9.440ms)
+ This property has to be a '/bits/ 8' value
+
+Example:
+
+   ad7879@2c {
+   compatible = "adi,ad7879-1";
+   reg = <0x2c>;
+   interrupt-parent = <>;
+   interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+   touchscreen-max-pressure = <4096>;
+   adi,resistance-plate-x = <120>;
+   adi,first-conversion-delay = /bits/ 8 <3>;
+   adi,acquisition-time = /bits/ 8 <1>;
+   adi,median-filter-size = /bits/ 8 <2>;
+   adi,averaging = /bits/ 8 <1>;
+   adi,conversion-interval = /bits/ 8 <255>;
+   };
diff --git a/drivers/input/touchscreen/ad7879-i2c.c 
b/drivers/input/touchscreen/ad7879-i2c.c
index d66962c..58f72e0 100644
--- a/drivers/input/touchscreen/ad7879-i2c.c
+++ b/drivers/input/touchscreen/ad7879-i2c.c
@@ -10,6 +10,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 

  #include "ad7879.h"
@@ -91,10 +92,19 @@ static const struct i2c_device_id ad7879_id[] = {
  };
  MODULE_DEVICE_TABLE(i2c, ad7879_id);

+#ifdef CONFIG_OF
+static const struct of_device_id ad7879_i2c_dt_ids[] = {
+   { .compatible = "adi,ad7879-1", },
+   { }
+};
+MODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids);
+#endif
+
  static struct i2c_driver ad7879_i2c_driver 

Re: + x86-add-support-for-pud-sized-transparent-hugepages-checkpatch-fixes.patch added to -mm tree

2016-02-02 Thread Ingo Molnar

* a...@linux-foundation.org  wrote:

> diff -puN 
> arch/x86/include/asm/pgtable_64.h~x86-add-support-for-pud-sized-transparent-hugepages-checkpatch-fixes
>  arch/x86/include/asm/pgtable_64.h
> --- 
> a/arch/x86/include/asm/pgtable_64.h~x86-add-support-for-pud-sized-transparent-hugepages-checkpatch-fixes
> +++ a/arch/x86/include/asm/pgtable_64.h
> @@ -111,8 +111,10 @@ static inline pud_t native_pudp_get_and_
>  #ifdef CONFIG_SMP
>   return native_make_pud(xchg(>pud, 0));
>  #else
> - /* native_local_pudp_get_and_clear,
> -but duplicated because of cyclic dependency */
> + /*
> +  * native_local_pudp_get_and_clear, but duplicated because of cyclic
> +  * dependency
> +  */
>   pud_t ret = *pudp;
>   native_pud_clear(pudp);
>   return ret;

When referring to functions in comments (or changelogs) please use () to make 
it 
clear on sight what is being referred to.

Also, please try to construct proper English sentences with verbs and such!

I.e. something like this would work for me:

> + /*
> +  * This is a duplicate of native_local_pudp_get_and_clear(),
> +  * because we cannot use the original due to a cyclic header
> +  * file dependency:
> +  */

(Assuming I managed to decode the shorthand form properly.)

Thanks,

Ingo


Re: [PATCH v3 2/3] input: touchscreen: ad7879: fix default x/y axis assignment

2016-02-02 Thread Michael Hennerich

On 02/03/2016 12:20 AM, Stefan Agner wrote:

The X/Y position measurements read from the controller are interpreted
wrong. The first measurement X+ contains the Y position, and the second
measurement Y+ the X position (see also Table 11 Register Table in the
data sheet).

The problem is already known and a swap option has been introduced:
commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")

However, the meaning of the new boolean is inverted since the underlying
values are already swapped. Let ts->swap_xy set to true actually be the
swapped configuration of the two axis.

Signed-off-by: Stefan Agner 


Acked-by: Michael Hennerich 


---
Changes since v2:
- (none)
Changes since v1:
- Keep axis swapped by default when using platform data

  drivers/input/touchscreen/ad7879.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/ad7879.c 
b/drivers/input/touchscreen/ad7879.c
index 93b8ea2..abd0220 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -94,8 +94,8 @@
  #define AD7879_TEMP_BIT   (1<<1)

  enum {
-   AD7879_SEQ_XPOS  = 0,
-   AD7879_SEQ_YPOS  = 1,
+   AD7879_SEQ_YPOS  = 0,
+   AD7879_SEQ_XPOS  = 1,
AD7879_SEQ_Z1= 2,
AD7879_SEQ_Z2= 3,
AD7879_NR_SENSE  = 4,
@@ -517,7 +517,9 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, 
unsigned int irq,
ts->dev = dev;
ts->input = input_dev;
ts->irq = irq;
-   ts->swap_xy = pdata->swap_xy;
+
+   /* Use swapped axis by default (backward compatibility) */
+   ts->swap_xy = !pdata->swap_xy;

setup_timer(>timer, ad7879_timer, (unsigned long) ts);





--
Greetings,
Michael

--
Analog Devices GmbH  Wilhelm-Wagenfeld-Str. 6  80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif


Re: [PATCH v6 20/22] usb: dwc2: host: Properly set even/odd frame

2016-02-02 Thread Kever Yang

Doug,

Thanks for your detail debug information, pls add my Reviewed-by for 
this patch.


Thanks,
- Kever
On 02/03/2016 06:47 AM, Doug Anderson wrote:

Kever,

On Mon, Feb 1, 2016 at 11:46 PM, Kever Yang  wrote:

Doug,


On 01/29/2016 10:20 AM, Douglas Anderson wrote:

When setting up ISO and INT transfers dwc2 needs to specify whether the
transfer is for an even or an odd frame (or microframe if the controller
is running in high speed mode).

The controller appears to use this as a simple way to figure out if a
transfer should happen right away (in the current microframe) or should
happen at the start of the next microframe.  Said another way:

- If you set "odd" and the current frame number is odd it appears that
the controller will try to transfer right away.  Same thing if you set
"even" and the current frame number is even.
- If the oddness you set and the oddness of the frame number are
_different_, the transfer will be delayed until the frame number
changes.

As I understand it, the above technique allows you to plan ahead of time
where possible by always working on the next frame.  ...but it still
allows you to properly respond immediately to things that happened in
the previous frame.

The old dwc2_hc_set_even_odd_frame() didn't really handle this concept.
It always looked at the frame number and setup the transfer to happen in
the next frame.  In some cases that meant that certain transactions
would be transferred in the wrong frame.

We'll try our best to set the even / odd to do the transfer in the
scheduled frame.  If that fails then we'll do an ugly "schedule ASAP".
We'll also modify the scheduler code to handle this and not try to
schedule a second transfer for the same frame.

Note that this change relies on the work to redo the microframe
scheduler.  It can work atop ("usb: dwc2: host: Manage frame nums better
in scheduler") but it works even better after ("usb: dwc2: host: Totally
redo the microframe scheduler").

With this change my stressful USB test (USB webcam + USB audio +
keyboards) has less audio crackling than before.

Seems this really help for your case?

Yes, I believe it does.  Of course my test case is pretty "black box"
for the most part in that I play music on youtube while having a
webcam open and several USB input devices connected.  I then try to
decide whether I hear more static or less static.  ...clearly a less
subjective test would be better...

* I tried with http://crosreview.com/325451 (see below) and I hear
more static with "use_old = true" than with "use_old = "false".

* I tried with this entire patch reverted and I hear about the same
static as with "use_old = true".

Note that counting reported MISS lines from my logging also shows that
the new code is better...



Do you check if the transfer can happen right in the current frame? I know
it's
quite difficult to check it, but this changes what I know for the dwc core
schedule the transaction.

Yes.  I just tried again, too.  I coded up
 and included it.  I
then opened up a USB webcam.

With things set to the old way:

   115.355370  QH=dc6ba8c0 next(0) fn=10cb, sch=10ca=>10cb (+1) miss=0
   115.355373  QH=dc6ba8c0 IMM ready fn=10cb, nxt=10cb
   115.355518  QH=dc6ba8c0 next(0) fn=10cc, sch=10cb=>10cc (+1) miss=0
   115.355522  QH=dc6ba8c0 IMM ready fn=10cc, nxt=10cc
   115.355637  QH=dc6ba8c0 next(0) fn=10cd, sch=10cc=>10cd (+1) miss=0
   115.355641  QH=dc6ba8c0 IMM ready fn=10cd, nxt=10cd
   115.355857  QH=dc6ba8c0 next(0) fn=10ce, sch=10cd=>10ce (+1) miss=0
   115.355859  QH=dc6ba8c0 IMM ready fn=10ce, nxt=10ce
   115.355867  QH=dc6ba8c0, wire=10cf, old_wire=10d0, EO diff (use OLD)
   115.355870  QH=dc6ba8c0 EO MISS w/ old (10ce != 10cf)
   115.356037  QH=dc6ba8c0 next(0) fn=10d0, sch=10cf=>10d0 (+1) miss=1 MISS
   115.356039  QH=dc6ba8c0 IMM ready fn=10d0, nxt=10d0
   115.356169  QH=dc6ba8c0 next(0) fn=10d1, sch=10d0=>10d1 (+1) miss=0
   115.356170  QH=dc6ba8c0 IMM ready fn=10d1, nxt=10d1
   115.356269  QH=dc6ba8c0 next(0) fn=10d2, sch=10d1=>10d2 (+1) miss=0
   115.356273  QH=dc6ba8c0 IMM ready fn=10d2, nxt=10d2
   115.356404  QH=dc6ba8c0 next(0) fn=10d3, sch=10d2=>10d3 (+1) miss=0
   115.356407  QH=dc6ba8c0 IMM ready fn=10d3, nxt=10d3

With the new way:

87.814741  QH=e2fd7880 next(0) fn=32e4, sch=32e3=>32e4 (+1) miss=0
87.814744  QH=e2fd7880 IMM ready fn=32e4, nxt=32e4
87.814858  QH=e2fd7880 next(0) fn=32e5, sch=32e4=>32e5 (+1) miss=0
87.814862  QH=e2fd7880 IMM ready fn=32e5, nxt=32e5
87.815010  QH=e2fd7880 next(0) fn=32e6, sch=32e5=>32e6 (+1) miss=0
87.815012  QH=e2fd7880 IMM ready fn=32e6, nxt=32e6
87.815220  QH=e2fd7880 next(0) fn=32e8, sch=32e6=>32e7 (+1) miss=0
87.815222  QH=e2fd7880 IMM ready fn=32e8, nxt=32e7
87.815230  QH=e2fd7880, wire=32e8, old_wire=32e9, EO diff (use NEW)
87.815278  QH=e2fd7880 next(0) fn=32e8, sch=32e7=>32e8 (+1) miss=0
87.815280  QH=e2fd7880 IMM ready fn=32e8, 

Re: sound: deadlock between snd_rawmidi_kernel_open/snd_seq_port_connect

2016-02-02 Thread Takashi Iwai
On Tue, 02 Feb 2016 22:23:55 +0100,
Dmitry Vyukov wrote:
> 
> On Mon, Jan 25, 2016 at 11:47 AM, Takashi Iwai  wrote:
> > On Sun, 24 Jan 2016 10:44:34 +0100,
> > Dmitry Vyukov wrote:
> >>
> >> Hello,
> >>
> >> While running syzkaller fuzzer I've got the following lockdep report:
> >>
> >> ==
> >> [ INFO: possible circular locking dependency detected ]
> >> 4.4.0+ #276 Not tainted
> >> ---
> >> syz-executor/21025 is trying to acquire lock:
> >>  (register_mutex#5){+.+.+.}, at: []
> >> snd_rawmidi_kernel_open+0x4b/0x260 sound/core/rawmidi.c:341
> >>
> >> but task is already holding lock:
> >>  (>list_mutex/1){+.+...}, at: []
> >> snd_seq_port_connect+0x1ba/0x840 sound/core/seq/seq_ports.c:506
> >>
> >> which lock already depends on the new lock.
> >>
> >>
> >> the existing dependency chain (in reverse order) is:
> >>
> >> -> #2 (>list_mutex/1){+.+...}:
> >>[] lock_acquire+0x1dc/0x430
> >> kernel/locking/lockdep.c:3585
> >>[] down_write_nested+0x4a/0xa0
> >> kernel/locking/rwsem.c:149
> >>[] snd_seq_port_connect+0x1ba/0x840
> >> sound/core/seq/seq_ports.c:506
> >>[] snd_seq_ioctl_subscribe_port+0x1c4/0x290
> >> sound/core/seq/seq_clientmgr.c:1464
> >>[] snd_seq_do_ioctl+0x19d/0x1c0
> >> sound/core/seq/seq_clientmgr.c:2209
> >>[] snd_seq_kernel_client_ctl+0xdb/0x170
> >> sound/core/seq/seq_clientmgr.c:2423
> >>[] snd_seq_oss_create_client+0x253/0x2d5
> >> sound/core/seq/oss/seq_oss_init.c:119
> >>[] alsa_seq_oss_init+0x1af/0x23e
> >> sound/core/seq/oss/seq_oss.c:89
> >>[] do_one_initcall+0x159/0x380 init/main.c:794
> >>[< inline >] do_initcall_level init/main.c:859
> >>[< inline >] do_initcalls init/main.c:867
> >>[< inline >] do_basic_setup init/main.c:885
> >>[] kernel_init_freeable+0x474/0x52d 
> >> init/main.c:1010
> >>[] kernel_init+0x13/0x150 init/main.c:936
> >>[] ret_from_fork+0x3f/0x70
> >> arch/x86/entry/entry_64.S:468
> >>
> >> -> #1 (>list_mutex){.+}:
> >>[] lock_acquire+0x1dc/0x430
> >> kernel/locking/lockdep.c:3585
> >>[] down_read+0x47/0x60 kernel/locking/rwsem.c:22
> >>[< inline >] deliver_to_subscribers
> >> sound/core/seq/seq_clientmgr.c:679
> >>[] snd_seq_deliver_event+0x5a9/0x800
> >> sound/core/seq/seq_clientmgr.c:817
> >>[] snd_seq_kernel_client_dispatch+0x126/0x170
> >> sound/core/seq/seq_clientmgr.c:2401
> >>[] snd_seq_system_broadcast+0xb2/0xf0
> >> sound/core/seq/seq_system.c:101
> >>[] snd_seq_create_kernel_client+0x21e/0x300
> >> sound/core/seq/seq_clientmgr.c:2280
> >>[< inline >] snd_virmidi_dev_attach_seq
> >> sound/core/seq/seq_virmidi.c:372
> >>[] snd_virmidi_dev_register+0x29f/0x750
> >> sound/core/seq/seq_virmidi.c:439
> >>[] snd_rawmidi_dev_register+0x30c/0xd40
> >> sound/core/rawmidi.c:1589
> >>[] __snd_device_register.part.0+0x63/0xc0
> >> sound/core/device.c:164
> >>[< inline >] __snd_device_register sound/core/device.c:162
> >>[] snd_device_register_all+0xad/0x110
> >> sound/core/device.c:212
> >>[] snd_card_register+0xef/0x6a0 
> >> sound/core/init.c:749
> >>[] snd_virmidi_probe+0x3ef/0x590
> >> sound/drivers/virmidi.c:123
> >>[] platform_drv_probe+0x8c/0x160
> >> drivers/base/platform.c:562
> >>[< inline >] really_probe drivers/base/dd.c:377
> >>[] driver_probe_device+0x37e/0xc90
> >> drivers/base/dd.c:499
> >>[] __device_attach_driver+0x19e/0x250
> >> drivers/base/dd.c:584
> >>[] bus_for_each_drv+0x13f/0x1d0 
> >> drivers/base/bus.c:464
> >>[] __device_attach+0x1ef/0x2e0 
> >> drivers/base/dd.c:641
> >>[] device_initial_probe+0x1a/0x20 
> >> drivers/base/dd.c:688
> >>[] bus_probe_device+0x1e9/0x290 
> >> drivers/base/bus.c:558
> >>[] device_add+0x84b/0x1490 
> >> drivers/base/core.c:1120
> >>[] platform_device_add+0x389/0x790
> >> drivers/base/platform.c:403
> >>[] platform_device_register_full+0x396/0x4c0
> >> drivers/base/platform.c:535
> >>[< inline >] platform_device_register_resndata
> >> include/linux/platform_device.h:111
> >>[< inline >] platform_device_register_simple
> >> include/linux/platform_device.h:140
> >>[] alsa_card_virmidi_init+0x104/0x1da
> >> sound/drivers/virmidi.c:172
> >>[] do_one_initcall+0x159/0x380 init/main.c:794
> >>[< inline >] do_initcall_level init/main.c:859
> >>[< inline >] do_initcalls init/main.c:867
> >>[< inline >] do_basic_setup init/main.c:885
> >>[] kernel_init_freeable+0x474/0x52d 
> >> init/main.c:1010
> >>[] kernel_init+0x13/0x150 init/main.c:936
> >>[] ret_from_fork+0x3f/0x70
> >> arch/x86/entry/entry_64.S:468
> >>
> >> -> 

[RESEND PATCH 7/9] ipv4: Namespaceify tcp_orphan_retries sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  1 -
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp_ipv4.c|  1 +
 net/ipv4/tcp_timer.c   |  3 +--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 3cb2073c55f5..6903335fbe3a 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -101,6 +101,7 @@ struct netns_ipv4 {
int sysctl_tcp_reordering;
int sysctl_tcp_retries1;
int sysctl_tcp_retries2;
+   int sysctl_tcp_orphan_retries;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 9b3aabbac85e..606a0a1a6d15 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -240,7 +240,6 @@ extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
 extern int sysctl_tcp_fin_timeout;
-extern int sysctl_tcp_orphan_retries;
 extern int sysctl_tcp_fastopen;
 extern int sysctl_tcp_retrans_collapse;
 extern int sysctl_tcp_stdurg;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 39c302fda534..e866e9fe6d84 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -421,13 +421,6 @@ static struct ctl_table ipv4_table[] = {
.proc_handler   = proc_dointvec_jiffies,
},
{
-   .procname   = "tcp_orphan_retries",
-   .data   = _tcp_orphan_retries,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_fack",
.data   = _tcp_fack,
.maxlen = sizeof(int),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec
},
+   {
+   .procname   = "tcp_orphan_retries",
+   .data   = _net.ipv4.sysctl_tcp_orphan_retries,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3a2db4a7d651..fc4d4ee38012 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2387,6 +2387,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_reordering = TCP_FASTRETRANS_THRESH;
net->ipv4.sysctl_tcp_retries1 = TCP_RETR1;
net->ipv4.sysctl_tcp_retries2 = TCP_RETR2;
+   net->ipv4.sysctl_tcp_orphan_retries = 0;
 
return 0;
 fail:
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 09f4e0297e56..49bc474f8e35 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 
-int sysctl_tcp_orphan_retries __read_mostly;
 int sysctl_tcp_thin_linear_timeouts __read_mostly;
 
 static void tcp_write_err(struct sock *sk)
@@ -78,7 +77,7 @@ static int tcp_out_of_resources(struct sock *sk, bool 
do_reset)
 /* Calculate maximal number or retries on an orphaned socket. */
 static int tcp_orphan_retries(struct sock *sk, bool alive)
 {
-   int retries = sysctl_tcp_orphan_retries; /* May be zero. */
+   int retries = sock_net(sk)->ipv4.sysctl_tcp_orphan_retries; /* May be 
zero. */
 
/* We know from an ICMP that something is wrong. */
if (sk->sk_err_soft && !alive)
-- 
2.5.0



[RESEND PATCH 4/9] ipv4: Namespaceify tcp reordering sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  2 +-
 include/net/tcp.h  |  4 +++-
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp.c |  2 +-
 net/ipv4/tcp_input.c   | 12 ++--
 net/ipv4/tcp_ipv4.c|  2 +-
 net/ipv4/tcp_metrics.c |  3 ++-
 7 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 80da0d095eaf..dff8879e02fe 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -97,8 +97,8 @@ struct netns_ipv4 {
 
int sysctl_tcp_syn_retries;
int sysctl_tcp_synack_retries;
-
int sysctl_tcp_syncookies;
+   int sysctl_tcp_reordering;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5497cc809601..64d01d289441 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -959,9 +959,11 @@ static inline void tcp_enable_fack(struct tcp_sock *tp)
  */
 static inline void tcp_enable_early_retrans(struct tcp_sock *tp)
 {
+   struct net *net = sock_net((struct sock *)tp);
+
tp->do_early_retrans = sysctl_tcp_early_retrans &&
sysctl_tcp_early_retrans < 4 && !sysctl_tcp_thin_dupack &&
-   sysctl_tcp_reordering == 3;
+   net->ipv4.sysctl_tcp_reordering == 3;
 }
 
 static inline void tcp_disable_early_retrans(struct tcp_sock *tp)
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 007b9f8f7a2a..12d752e6380b 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -457,13 +457,6 @@ static struct ctl_table ipv4_table[] = {
.proc_handler   = proc_dointvec,
},
{
-   .procname   = "tcp_reordering",
-   .data   = _tcp_reordering,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec
-   },
-   {
.procname   = "tcp_max_reordering",
.data   = _tcp_max_reordering,
.maxlen = sizeof(int),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.proc_handler   = proc_dointvec
},
 #endif
+   {
+   .procname   = "tcp_reordering",
+   .data   = _net.ipv4.sysctl_tcp_reordering,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index bb36a39b5685..d0547395d81d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -405,7 +405,7 @@ void tcp_init_sock(struct sock *sk)
tp->mss_cache = TCP_MSS_DEFAULT;
u64_stats_init(>syncp);
 
-   tp->reordering = sysctl_tcp_reordering;
+   tp->reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;
tcp_enable_early_retrans(tp);
tcp_assign_congestion_control(sk);
 
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index dc8fe6c8a2e0..3f08bba46147 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -80,9 +80,7 @@ int sysctl_tcp_timestamps __read_mostly = 1;
 int sysctl_tcp_window_scaling __read_mostly = 1;
 int sysctl_tcp_sack __read_mostly = 1;
 int sysctl_tcp_fack __read_mostly = 1;
-int sysctl_tcp_reordering __read_mostly = TCP_FASTRETRANS_THRESH;
 int sysctl_tcp_max_reordering __read_mostly = 300;
-EXPORT_SYMBOL(sysctl_tcp_reordering);
 int sysctl_tcp_dsack __read_mostly = 1;
 int sysctl_tcp_app_win __read_mostly = 31;
 int sysctl_tcp_adv_win_scale __read_mostly = 1;
@@ -1873,6 +1871,7 @@ void tcp_enter_loss(struct sock *sk)
 {
const struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
+   struct net *net = sock_net(sk);
struct sk_buff *skb;
bool new_recovery = icsk->icsk_ca_state < TCP_CA_Recovery;
bool is_reneg;  /* is receiver reneging on SACKs? */
@@ -1923,9 +1922,9 @@ void tcp_enter_loss(struct sock *sk)
 * suggests that the degree of reordering is over-estimated.
 */
if (icsk->icsk_ca_state <= TCP_CA_Disorder &&
-   tp->sacked_out >= sysctl_tcp_reordering)
+   tp->sacked_out >= net->ipv4.sysctl_tcp_reordering)
tp->reordering = min_t(unsigned int, tp->reordering,
-  sysctl_tcp_reordering);
+  net->ipv4.sysctl_tcp_reordering);
tcp_set_ca_state(sk, TCP_CA_Loss);
tp->high_seq = tp->snd_nxt;
tcp_ecn_queue_cwr(tp);
@@ -2109,6 +2108,7 @@ static bool tcp_time_to_recover(struct sock *sk, int flag)
 {
struct tcp_sock *tp = tcp_sk(sk);
__u32 packets_out;
+   int tcp_reordering = sock_net(sk)->ipv4.sysctl_tcp_reordering;
 
/* Trick#1: The loss is proven. */
if (tp->lost_out)
@@ -2123,7 +2123,7 @@ static 

[RESEND PATCH 8/9] ipv4: Namespaceify tcp_fin_timeout sysctl knob

2016-02-02 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov 
---
 include/net/netns/ipv4.h   |  1 +
 include/net/tcp.h  |  3 +--
 net/ipv4/sysctl_net_ipv4.c | 14 +++---
 net/ipv4/tcp.c |  7 +++
 net/ipv4/tcp_ipv4.c|  1 +
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 6903335fbe3a..a1caddadecc2 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -102,6 +102,7 @@ struct netns_ipv4 {
int sysctl_tcp_retries1;
int sysctl_tcp_retries2;
int sysctl_tcp_orphan_retries;
+   int sysctl_tcp_fin_timeout;
 
struct ping_group_range ping_group_range;
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 606a0a1a6d15..f8c3f75e6c99 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -239,7 +239,6 @@ extern struct inet_timewait_death_row tcp_death_row;
 extern int sysctl_tcp_timestamps;
 extern int sysctl_tcp_window_scaling;
 extern int sysctl_tcp_sack;
-extern int sysctl_tcp_fin_timeout;
 extern int sysctl_tcp_fastopen;
 extern int sysctl_tcp_retrans_collapse;
 extern int sysctl_tcp_stdurg;
@@ -1245,7 +1244,7 @@ static inline u32 keepalive_time_elapsed(const struct 
tcp_sock *tp)
 
 static inline int tcp_fin_time(const struct sock *sk)
 {
-   int fin_timeout = tcp_sk(sk)->linger2 ? : sysctl_tcp_fin_timeout;
+   int fin_timeout = tcp_sk(sk)->linger2 ? : 
sock_net(sk)->ipv4.sysctl_tcp_fin_timeout;
const int rto = inet_csk(sk)->icsk_rto;
 
if (fin_timeout < (rto << 2) - (rto >> 1))
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index e866e9fe6d84..20e086f88438 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -321,13 +321,6 @@ static struct ctl_table ipv4_table[] = {
.proc_handler   = proc_dointvec
},
{
-   .procname   = "tcp_fin_timeout",
-   .data   = _tcp_fin_timeout,
-   .maxlen = sizeof(int),
-   .mode   = 0644,
-   .proc_handler   = proc_dointvec_jiffies,
-   },
-   {
.procname   = "tcp_fastopen",
.data   = _tcp_fastopen,
.maxlen = sizeof(int),
@@ -950,6 +943,13 @@ static struct ctl_table ipv4_net_table[] = {
.mode   = 0644,
.proc_handler   = proc_dointvec
},
+   {
+   .procname   = "tcp_fin_timeout",
+   .data   = _net.ipv4.sysctl_tcp_fin_timeout,
+   .maxlen = sizeof(int),
+   .mode   = 0644,
+   .proc_handler   = proc_dointvec_jiffies,
+   },
{ }
 };
 
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d0547395d81d..ad903790c0a4 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -281,8 +281,6 @@
 #include 
 #include 
 
-int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
-
 int sysctl_tcp_min_tso_segs __read_mostly = 2;
 
 int sysctl_tcp_autocorking __read_mostly = 1;
@@ -2324,6 +2322,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 {
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
+   struct net *net = sock_net(sk);
int val;
int err = 0;
 
@@ -2520,7 +2519,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
case TCP_LINGER2:
if (val < 0)
tp->linger2 = -1;
-   else if (val > sysctl_tcp_fin_timeout / HZ)
+   else if (val > net->ipv4.sysctl_tcp_fin_timeout / HZ)
tp->linger2 = 0;
else
tp->linger2 = val * HZ;
@@ -2762,7 +2761,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
case TCP_LINGER2:
val = tp->linger2;
if (val >= 0)
-   val = (val ? : sysctl_tcp_fin_timeout) / HZ;
+   val = (val ? : net->ipv4.sysctl_tcp_fin_timeout) / HZ;
break;
case TCP_DEFER_ACCEPT:
val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept,
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fc4d4ee38012..3c263c00f5ea 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2388,6 +2388,7 @@ static int __net_init tcp_sk_init(struct net *net)
net->ipv4.sysctl_tcp_retries1 = TCP_RETR1;
net->ipv4.sysctl_tcp_retries2 = TCP_RETR2;
net->ipv4.sysctl_tcp_orphan_retries = 0;
+   net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
 
return 0;
 fail:
-- 
2.5.0



Re: + kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch added to -mm tree

2016-02-02 Thread Ingo Molnar

* a...@linux-foundation.org  wrote:

> 
> The patch titled
>  Subject: kernel/locking/lockdep.c: make lockdep initialize itself on 
> demand
> has been added to the -mm tree.  Its filename is
>  kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch
> 
> This patch should soon appear at
> 
> http://ozlabs.org/~akpm/mmots/broken-out/kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch
> and later at
> 
> http://ozlabs.org/~akpm/mmotm/broken-out/kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand.patch
> 
> Before you just go and hit "reply", please:
>a) Consider who else should be cc'ed
>b) Prefer to cc a suitable mailing list as well
>c) Ideally: find the original patch on the mailing list and do a
>   reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
> 
> The -mm tree is included into linux-next and is updated
> there every 3-4 working days
> 
> --
> From: Andrew Morton 
> Subject: kernel/locking/lockdep.c: make lockdep initialize itself on demand
> 
> Mike said:
> 
> : CONFIG_UBSAN_ALIGNMENT breaks x86-64 kernel with lockdep enabled, i.  e
> : kernel with CONFIG_UBSAN_ALIGNMENT fails to load without even any error
> : message.
> : 
> : The problem is that ubsan callbacks use spinlocks and might be called
> : before lockdep is initialized.  Particularly this line in the
> : reserve_ebda_region function causes problem:
> : 
> : lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
> : 
> : If i put lockdep_init() before reserve_ebda_region call in
> : x86_64_start_reservations kernel loads well.
> 
> Fix this ordering issue permanently: change lockdep so that it ensures
> that the hash tables are initialized when they are about to be used.
> 
> The overhead will be pretty small: a test-n-branch in places where lockdep
> is about to do a lot of work anyway.
> 
> Possibly lockdep_initialized should be made __read_mostly.
> 
> A better fix would be to simply initialize these (32768 entry) arrays of
> empty list_heads at compile time, but I don't think there's a way of
> teaching gcc to do this.
> 
> We could write a little script which, at compile time, emits a file
> containing
> 
>   [0] = LIST_HEAD_INIT(__chainhash_table[0]),
>   [1] = LIST_HEAD_INIT(__chainhash_table[1]),
>   ...
>   [32767] = LIST_HEAD_INIT(__chainhash_table[32767]),
> 
> and then #include this file into lockdep.c.  Sounds like a lot of fuss.
> 
> Reported-by: Mike Krinkin 
> Cc: Andrey Ryabinin 
> Cc: Ingo Molnar 
> Cc: Peter Zijlstra 
> Signed-off-by: Andrew Morton 
> ---
> 
>  kernel/locking/lockdep.c |   35 ++-
>  1 file changed, 26 insertions(+), 9 deletions(-)
> 
> diff -puN 
> kernel/locking/lockdep.c~kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand
>  kernel/locking/lockdep.c
> --- 
> a/kernel/locking/lockdep.c~kernel-locking-lockdepc-make-lockdep-initialize-itself-on-demand
> +++ a/kernel/locking/lockdep.c
> @@ -290,9 +290,20 @@ LIST_HEAD(all_lock_classes);
>  #define CLASSHASH_BITS   (MAX_LOCKDEP_KEYS_BITS - 1)
>  #define CLASSHASH_SIZE   (1UL << CLASSHASH_BITS)
>  #define __classhashfn(key)   hash_long((unsigned long)key, CLASSHASH_BITS)
> -#define classhashentry(key)  (classhash_table + __classhashfn((key)))
>  
> -static struct list_head classhash_table[CLASSHASH_SIZE];
> +static struct list_head __classhash_table[CLASSHASH_SIZE];
> +
> +static inline struct list_head *get_classhash_table(void)
> +{
> + if (unlikely(!lockdep_initialized))
> + lockdep_init();
> + return __classhash_table;
> +}
> +
> +static inline struct list_head *classhashentry(struct lockdep_subclass_key 
> *key)
> +{
> + return get_classhash_table() + __classhashfn(key);
> +}
>  
>  /*
>   * We put the lock dependency chains into a hash-table as well, to cache
> @@ -301,9 +312,15 @@ static struct list_head classhash_table[
>  #define CHAINHASH_BITS   (MAX_LOCKDEP_CHAINS_BITS-1)
>  #define CHAINHASH_SIZE   (1UL << CHAINHASH_BITS)
>  #define __chainhashfn(chain) hash_long(chain, CHAINHASH_BITS)
> -#define chainhashentry(chain)(chainhash_table + 
> __chainhashfn((chain)))
>  
> -static struct list_head chainhash_table[CHAINHASH_SIZE];
> +static struct list_head __chainhash_table[CHAINHASH_SIZE];
> +
> +static struct list_head *chainhashentry(unsigned long chain)
> +{
> + if (unlikely(!lockdep_initialized))
> + lockdep_init();
> + return __chainhash_table + __chainhashfn(chain);
> +}

Yuck, I don't really like this.

Lockdep initialization must happen early on, and it should happen in a well 
defined place, not be opportunistic (and relatively random) like this, making 
it 
dependent on config options and calling contexts.

Also, in addition to properly ordering UBSAN 

[PATCH][perf/urgent] perf stat: Fix interval output values

2016-02-02 Thread Jiri Olsa
We broke interval data displays with commit:
  3f416f22d1e2 perf stat: Do not clean event's private stats

This commit removed stats cleaning, which is important
for '-r' option to carry counters data over the whole
run. But it's necessary to clean it for interval mode,
otherwise the displayed value is avg of all previous
values.

Before:
  $ perf stat -e cycles -a -I 1000 record
  #   time counts unit events
   1.000240796 75,216,287  cycles
   2.000512791107,823,524  cycles

  $ perf stat report
  #   time counts unit events
   1.000240796 75,216,287  cycles
   2.000512791 91,519,906  cycles

Now:
  $ perf stat report
  #   time counts unit events
   1.000240796 75,216,287  cycles
   2.000512791107,823,524  cycles

Notice the second value being bigger (91,.. < 107,..).

This could be easily verified by using perf script which
displays raw stat data:

  $ perf script
  CPU   THREAD VAL ENA RUNTIME 
EVENT
0   -123855779  1000209530  1000209530  1000240796 
cycles
1   -133340397  1000224964  1000224964  1000240796 
cycles
2   -115835415  1000226695  1000226695  1000240796 
cycles
3   -1 2184696  1000228245  1000228245  1000240796 
cycles
0   -197014312  2000514533  2000514533  2000512791 
cycles
1   -146121497  2000543795  2000543795  2000512791 
cycles
2   -132269530  2000543566  2000543566  2000512791 
cycles
3   -1 7634472  2000544108  2000544108  2000512791 
cycles

The sum of the first 4 values is the first interval
aggregated value:
  23855779 + 33340397 + 15835415 + 2184696 = 75,216,287

The sum of the second 4 values minus first value is
the second interval aggregated value:
  97014312 + 46121497 + 32269530 + 7634472 - 75216287 = 107,823,524

Link: http://lkml.kernel.org/n/tip-4xawgmi82euqnq9t87l2l...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/util/stat.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index beeed0bd3bee..4d9b481cf3b6 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -311,6 +311,16 @@ int perf_stat_process_counter(struct perf_stat_config 
*config,
 
aggr->val = aggr->ena = aggr->run = 0;
 
+   /*
+* We calculate counter's data every interval,
+* and the display code shows ps->res_stats
+* avg value. We need to zero the stats for
+* interval mode, otherwise overall avg running
+* averages will be shown for each interval.
+*/
+   if (config->interval)
+   init_stats(ps->res_stats);
+
if (counter->per_pkg)
zero_per_pkg(counter);
 
-- 
2.4.3



Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()

2016-02-02 Thread Sergey Senozhatsky
On (02/03/16 08:28), Ingo Molnar wrote:
[..]
> So why not move printk away from semaphores? Semaphores are classical 
> constructs 
> that have legacies and are somewhat non-obvious to use, compared to modern, 
> simpler locking primitives. I'd not touch their implementation, unless we are 
> absolutely sure this is a safe optimization.

semaphore's spin_lock is not the only spin lock that printk acquires. it also 
takes the
logbuf_lock (and different locks in console drivers (up to console driver)).

Jan Kara posted a patch that offloads printing job 
(console_trylock()-console_unlock())
from printk() call (when printk can offload it). so semaphore and console 
driver's locks
will go away (mostly) with Jan's patch. logbug spin_lock, however, will stay.

-ss


Re: [PATCH] x86: Use named address spaces in asm/percpu.h

2016-02-02 Thread Ingo Molnar

* Richard Henderson  wrote:

> GCC 6 adds support for __seg_fs and __seg_gs as named address spaces,
> producing the obvious segment overrides for objects so marked.
> 
> Exposing the memory reference allows slightly better code generation
> in some cases (and in others, merely affects the scheduling).  E.g.:
> 
> [1]
> - mov%gs:0x0(%rip),%eax
> -R_X86_64_PC32  context_tracking+0x4
> - cmp$0x1,%eax
> + cmpl   $0x1,%gs:0x0(%rip)
> +R_X86_64_PC32  context_tracking+0x3
> 
> [2]
> - mov%gs:0x0(%rip),%ebx
> -R_X86_64_PC32  cpu_number-0x4
> - movslq %ebx,%rax
> + movslq %gs:0x0(%rip),%rax
> +R_X86_64_PC32  cpu_number-0x4
> 
> [3]
> - mov%gs:0x0(%rip),%rdx
> -R_X86_64_PC32  cpu_info+0x20
> - test   $0x100,%edx
> + testb  $0x1,%gs:0x0(%rip)
> +R_X86_64_PC32  cpu_info+0x22
> 
> [4]
> - mov$0x0,%rax
> -R_X86_64_32S   __uv_hub_info
> - mov%rax,%rcx
> - add%gs:0x0(%rip),%rcx
> -R_X86_64_PC32  this_cpu_off-0x4
> - movzbl 0x15(%rcx),%ecx
> ...
> - mov%rax,%rdx
> - add%gs:0x0(%rip),%rdx
> -R_X86_64_PC32  this_cpu_off-0x4
> - or (%rdx),%rcx
> + mov%gs:0x0(%rip),%r9
> +R_X86_64_PC32  this_cpu_off-0x4
> + mov$0x0,%rax
> +R_X86_64_32S   __uv_hub_info
> ...
> + movzbl 0x15(%rax,%r9,1),%ecx
> ...
> + or (%rax,%r9,1),%rdx
> 
> The final vmlinux text size is reduced by about 5k for a standard
> Fedora configure.

Very nice!

> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Signed-off-by: Richard Henderson 
> ---
>  arch/x86/include/asm/percpu.h | 145 
> +-
>  1 file changed, 86 insertions(+), 59 deletions(-)

I have a small request: since this depends on a very new compiler feature, and 
to 
make this easier to revert (even just for testing), could you split it into two 
patches: the first patch introduces the __percpu_addrspace machinery, the 
second 
one activates it by defining it?

The second patch will be easy to bisect to and will be easy to revert even many 
releases down the road, as GCC6 is tested more widely. We could also add a 
CONFIG_ 
switch for this - but that might be overkill.

> +#ifdef __percpu_addrspace
> +/* Produce an address-space lvalue for VAR.  */
> +#define __percpu_as(VAR) \
> +  (*(typeof(VAR) __kernel __force __percpu_addrspace *)(uintptr_t)&(VAR))
> +
> +/* We cannot allow __my_cpu_offset to recurse through this_cpu_read, as
> +   this will change based on CONFIG_X86_64, with which games are played
> +   in 32-bit compatibility files.  */

Small nit: please use the customary (multi-line) comment style:

  /*
   * Comment .
   * .. goes here.
   */

Thanks,

Ingo


Re: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()

2016-02-02 Thread Ingo Molnar

* Byungchul Park  wrote:

>  void up(struct semaphore *sem)
>  {
>   unsigned long flags;
> + struct task_struct *p = NULL;
>  
>   raw_spin_lock_irqsave(>lock, flags);
>   if (likely(list_empty(>wait_list)))
>   sem->count++;
>   else
> - __up(sem);
> + p = __up(sem);
>   raw_spin_unlock_irqrestore(>lock, flags);
> +
> + /*
> +  * wake_up_process() needs not to be protected by a spinlock.
> +  * Thus move it from the protected region to here. What is
> +  * worse, this unnecessary protection can cause a deadlock by
> +  * acquiring the same sem->lock within wake_up_process().
> +  */
> + if (unlikely(p))
> + wake_up_process(p);

So I'm not sure this is completely race free, for cases where a semaphore is 
attached to a task and is managed/destroyed on task exit.

Since we don't have a guaranteed reference to 'p' here, the task might wake up 
(via a signal) and exit (and its task struct might be freed and the semaphore 
might be freed), after we unlocked the semaphore but before we wake the task up.

So why not move printk away from semaphores? Semaphores are classical 
constructs 
that have legacies and are somewhat non-obvious to use, compared to modern, 
simpler locking primitives. I'd not touch their implementation, unless we are 
absolutely sure this is a safe optimization.

Thanks,

Ingo


[PATCH v3 2/2] phy: add a driver for the Rockchip SoC internal eMMC PHY

2016-02-02 Thread Shawn Lin
This patch to add a generic PHY driver for ROCKCHIP eMMC PHY.
Access the PHY via registers provided by GRF (general register
files) module.

Signed-off-by: Shawn Lin 

---

Changes in v3:
- remove empty init/exit
- fix copyright timestamp
- add comment for delay

Changes in v2:
- remove phy from rockchip_emmc_phy
- remove state from rockchip_emmc_phy
- remove on/off from init/exit

 drivers/phy/Kconfig |   7 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-rockchip-emmc.c | 229 
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/phy/phy-rockchip-emmc.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index e7e117d..d90e798 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -336,6 +336,13 @@ config PHY_ROCKCHIP_USB
help
  Enable this to support the Rockchip USB 2.0 PHY.
 
+config PHY_ROCKCHIP_EMMC
+   tristate "Rockchip EMMC PHY Driver"
+   depends on ARCH_ROCKCHIP && OF
+   select GENERIC_PHY
+   help
+ Enable this to support the Rockchip EMMC PHY.
+
 config PHY_ST_SPEAR1310_MIPHY
tristate "ST SPEAR1310-MIPHY driver"
select GENERIC_PHY
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c80f09d..50260b4 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -37,6 +37,7 @@ phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)+= 
phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS5_USBDRD)   += phy-exynos5-usbdrd.o
 obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)+= phy-qcom-apq8064-sata.o
 obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
+obj-$(CONFIG_PHY_ROCKCHIP_EMMC) += phy-rockchip-emmc.o
 obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)+= phy-qcom-ipq806x-sata.o
 obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY)   += phy-spear1310-miphy.o
 obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY)   += phy-spear1340-miphy.o
diff --git a/drivers/phy/phy-rockchip-emmc.c b/drivers/phy/phy-rockchip-emmc.c
new file mode 100644
index 000..887b4c2
--- /dev/null
+++ b/drivers/phy/phy-rockchip-emmc.c
@@ -0,0 +1,229 @@
+/*
+ * Rockchip emmc PHY driver
+ *
+ * Copyright (C) 2016 Shawn Lin 
+ * Copyright (C) 2016 ROCKCHIP, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * The higher 16-bit of this register is used for write protection
+ * only if BIT(x + 16) set to 1 the BIT(x) can be written.
+ */
+#define HIWORD_UPDATE(val, mask, shift) \
+   ((val) << (shift) | (mask) << ((shift) + 16))
+
+/* Register definition */
+#define GRF_EMMCPHY_CON0   0x0
+#define GRF_EMMCPHY_CON1   0x4
+#define GRF_EMMCPHY_CON2   0x8
+#define GRF_EMMCPHY_CON3   0xc
+#define GRF_EMMCPHY_CON4   0x10
+#define GRF_EMMCPHY_CON5   0x14
+#define GRF_EMMCPHY_CON6   0x18
+#define GRF_EMMCPHY_STATUS 0x20
+
+#define PHYCTRL_PDB_MASK   0x1
+#define PHYCTRL_PDB_SHIFT  0x0
+#define PHYCTRL_PDB_PWR_ON 0x1
+#define PHYCTRL_PDB_PWR_OFF0x0
+#define PHYCTRL_ENDLL_MASK 0x1
+#define PHYCTRL_ENDLL_SHIFT 0x1
+#define PHYCTRL_ENDLL_ENABLE   0x1
+#define PHYCTRL_ENDLL_DISABLE  0x0
+#define PHYCTRL_CALDONE_MASK   0x1
+#define PHYCTRL_CALDONE_SHIFT   0x6
+#define PHYCTRL_CALDONE_DONE   0x1
+#define PHYCTRL_CALDONE_GOING  0x0
+#define PHYCTRL_DLLRDY_MASK0x1
+#define PHYCTRL_DLLRDY_SHIFT   0x5
+#define PHYCTRL_DLLRDY_DONE0x1
+#define PHYCTRL_DLLRDY_GOING   0x0
+
+struct rockchip_emmc_phy {
+   unsigned intreg_offset;
+   struct regmap   *reg_base;
+};
+
+static int rockchip_emmc_phy_power(struct rockchip_emmc_phy *rk_phy,
+  bool on_off)
+{
+   unsigned int caldone;
+   unsigned int dllrdy;
+
+   /*
+* Keep phyctrl_pdb and phyctrl_endll low to allow
+* initialization of CALIO state M/C DFFs
+*/
+   regmap_write(rk_phy->reg_base,
+rk_phy->reg_offset + GRF_EMMCPHY_CON6,
+HIWORD_UPDATE(PHYCTRL_PDB_PWR_OFF,
+  PHYCTRL_PDB_MASK,
+  PHYCTRL_PDB_SHIFT));
+   regmap_write(rk_phy->reg_base,
+rk_phy->reg_offset + GRF_EMMCPHY_CON6,
+HIWORD_UPDATE(PHYCTRL_ENDLL_DISABLE,
+  PHYCTRL_ENDLL_MASK,
+  PHYCTRL_ENDLL_SHIFT));
+
+   /* Already finish power_off above */
+   if (on_off == PHYCTRL_PDB_PWR_OFF)
+   return 0;
+
+   /*
+* According to the user 

[PATCH v3 1/2] Documentation: bindings: add dt documentation for Rockchip eMMC PHY

2016-02-02 Thread Shawn Lin
This patch adds a binding that describes the Rockchip eMMC PHYs
found on Rockchip SoCs eMMC interface.

Signed-off-by: Shawn Lin 
---

Changes in v3: None
Changes in v2: None

 .../devicetree/bindings/phy/rockchip-emmc-phy.txt | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt 
b/Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt
new file mode 100644
index 000..61916f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt
@@ -0,0 +1,19 @@
+Rockchip EMMC PHY
+---
+
+Required properties:
+ - compatible: rockchip,rk3399-emmc-phy
+ - rockchip,grf : phandle to the syscon managing the "general
+   register files"
+ - #phy-cells: must be 0
+ - reg: PHY configure reg address offset in "general
+   register files"
+
+Example:
+
+emmcphy: phy {
+   compatible = "rockchip,rk3399-emmc-phy";
+   rockchip,grf = <>;
+   reg = <0xf780>;
+   #phy-cells = <0>;
+};
-- 
2.3.7




Re: [PATCH v3 1/2] dt-bindings: add sun4i SPDIF transceiver bindings

2016-02-02 Thread Code Kipper
On 2 February 2016 at 23:31, Maxime Ripard
 wrote:
> Hi,
>
> On Tue, Feb 02, 2016 at 03:49:53PM +0100, codekip...@gmail.com wrote:
>> From: Marcus Cooper 
>>
>> Add devicetree bindings for the SPDIF transceiver found on
>> found on Allwinners A10 and A20 SoCs.
>>
>> Signed-off-by: Marcus Cooper 
>> ---
>>  .../devicetree/bindings/sound/sun4i,spdif.txt  | 46 
>> ++
>>  1 file changed, 46 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/sound/sun4i,spdif.txt
>>
>> diff --git a/Documentation/devicetree/bindings/sound/sun4i,spdif.txt 
>> b/Documentation/devicetree/bindings/sound/sun4i,spdif.txt
>> new file mode 100644
>> index 000..55ed2f6
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/sound/sun4i,spdif.txt
>> @@ -0,0 +1,46 @@
>> +Allwinner Sony/Philips Digital Interface Format (S/PDIF) Controller
>> +
>> +The Allwinner S/PDIF audio block is a transceiver that allows the
>> +processor to receive and transmit digital audio via an coaxial cable or
>> +a fibre cable.
>> +
>> +Required properties:
>> +
>> +  - compatible   : should be one of the following:
>> +- "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
>> +
>> +  - reg  : Offset and length of the register set for 
>> the device.
>> +
>> +  - interrupts   : Contains the spdif interrupt.
>> +
>> +  - dmas : Generic dma devicetree binding as described in
>> +   Documentation/devicetree/bindings/dma/dma.txt.
>> +
>> +  - dma-names: Two dmas have to be defined, "tx" and "rx".
>> +
>> +  - clocks   : Contains an entry for each entry in clock-names.
>> +
>> +  - clock-names  : Includes the following entries:
>> + "apb" clock for the spdif bus.
>> + "spdif"   clock for spdif controller.
>> +
>> +Optional:
>> +
>> +  - spdif-in : Enable block for capturing an SPDIF signal.
>> +
>> +  - spdif-out: Enable block for transmitting an SPDIF 
>> signal.
>
> Is that a generic property? What values can it hold?
Hi Maxime,

thanks for the review. I'm starting to prep a v4 patch series and I'm
here wondering if I should drop the spdif-in/out for now and just rely
on the status property to enable playback. It would simplify the
driver even more and it could be added back when someone gets around
to delivering spdif capture. I think that's going to be pretty low on
my list of things to do as I've only got one dev board where it's
possible.
BR,
Lazy Lazy CK
>
> Thanks,
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com


Re: [PATCH v2 2/2] phy: add a driver for the Rockchip SoC internal eMMC PHY

2016-02-02 Thread Shawn Lin

Hi Kishon,

On 2016/2/3 14:39, Kishon Vijay Abraham I wrote:

Hi,

On Tuesday 05 January 2016 06:38 AM, Shawn Lin wrote:

This patch to add a generic PHY driver for ROCKCHIP eMMC PHY.
Access the PHY via registers provided by GRF (general register


[...]


+ *
+ * Copyright (C) 2015 Shawn Lin 
+ * Copyright (C) 2015 ROCKCHIP, Inc.


2016?


:) I will update it.


+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by


[...]


+   }
+
+   /*
+* Enable analog DLL circuits, and we need extra 10.2us
+* for dll to be ready for work.
+*/
+   regmap_write(rk_phy->reg_base,
+rk_phy->reg_offset + GRF_EMMCPHY_CON6,
+HIWORD_UPDATE(PHYCTRL_ENDLL_ENABLE,
+  PHYCTRL_ENDLL_MASK,
+  PHYCTRL_ENDLL_SHIFT));
+   udelay(11);


add a comment for this delay too.


Got it.


+   regmap_read(rk_phy->reg_base,
+   rk_phy->reg_offset + GRF_EMMCPHY_STATUS,
+   );
+   dllrdy = (dllrdy >> PHYCTRL_DLLRDY_SHIFT) & PHYCTRL_DLLRDY_MASK;
+   if (dllrdy != PHYCTRL_DLLRDY_DONE) {
+   pr_err("rockchip_emmc_phy_power: dllrdy timeout.\n");
+   return -ETIMEDOUT;
+   }
+
+   return 0;
+}
+


[...]


+static int rockchip_emmc_phy_init(struct phy *phy)
+{
+   return 0;
+}
+
+static int rockchip_emmc_phy_exit(struct phy *phy)
+{
+   return 0;
+}


empty init/exit functions are not required.



yep.


Thanks
Kishon






--
Best Regards
Shawn Lin



Re: [PATCH v6 1/9] ppc64 (le): prepare for -mprofile-kernel

2016-02-02 Thread AKASHI Takahiro

Hi,

On 01/26/2016 12:26 AM, Torsten Duwe wrote:

The gcc switch -mprofile-kernel, available for ppc64 on gcc > 4.8.5,
allows to call _mcount very early in the function, which low-level
ASM code and code patching functions need to consider.
Especially the link register and the parameter registers are still
alive and not yet saved into a new stack frame.


I'm thinking of implementing live patch support *for arm64*, and as part of
those efforts, we are proposing[1] a new *generic* gcc option, -fprolog-add=N.
This option will insert N nop instructions at the beginning of each function.
So we have to initialize those codes at the boot time to later utilize
them for FTRACE_WITH_REGS. Other than that, it will work similarly
with -mfentry on x86 (and -mprofile-kernel?).

I'm totally unfamiliar with ppc architecture, but just wondering
whether this option will also be useful for other architectures.

I will really appreciate you if you share your thoughts with me, please?

[1]  https://gcc.gnu.org/ml/gcc/2015-05/msg00267.html, and
 https://gcc.gnu.org/ml/gcc/2015-10/msg00090.html

Thanks,
-Takahiro AKASHI


Signed-off-by: Torsten Duwe 
---
  arch/powerpc/kernel/entry_64.S  | 45 +++--
  arch/powerpc/kernel/ftrace.c| 12 +--
  arch/powerpc/kernel/module_64.c | 14 +
  3 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index a94f155..e7cd043 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1206,7 +1206,12 @@ _GLOBAL(enter_prom)
  #ifdef CONFIG_DYNAMIC_FTRACE
  _GLOBAL(mcount)
  _GLOBAL(_mcount)
-   blr
+   std r0,LRSAVE(r1) /* gcc6 does this _after_ this call _only_ */
+   mflrr0
+   mtctr   r0
+   ld  r0,LRSAVE(r1)
+   mtlrr0
+   bctr

  _GLOBAL_TOC(ftrace_caller)
/* Taken from output of objdump from lib64/glibc */
@@ -1262,13 +1267,28 @@ _GLOBAL(ftrace_stub)

  #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  _GLOBAL(ftrace_graph_caller)
+#ifdef CC_USING_MPROFILE_KERNEL
+   /* with -mprofile-kernel, parameter regs are still alive at _mcount */
+   std r10, 104(r1)
+   std r9, 96(r1)
+   std r8, 88(r1)
+   std r7, 80(r1)
+   std r6, 72(r1)
+   std r5, 64(r1)
+   std r4, 56(r1)
+   std r3, 48(r1)
+   mfctr   r4  /* ftrace_caller has moved local addr here */
+   std r4, 40(r1)
+   mflrr3  /* ftrace_caller has restored LR from stack */
+#else
/* load r4 with local address */
ld  r4, 128(r1)
-   subir4, r4, MCOUNT_INSN_SIZE

/* Grab the LR out of the caller stack frame */
ld  r11, 112(r1)
ld  r3, 16(r11)
+#endif
+   subir4, r4, MCOUNT_INSN_SIZE

bl  prepare_ftrace_return
nop
@@ -1277,6 +1297,26 @@ _GLOBAL(ftrace_graph_caller)
 * prepare_ftrace_return gives us the address we divert to.
 * Change the LR in the callers stack frame to this.
 */
+
+#ifdef CC_USING_MPROFILE_KERNEL
+   mtlrr3
+
+   ld  r0, 40(r1)
+   mtctr   r0
+   ld  r10, 104(r1)
+   ld  r9, 96(r1)
+   ld  r8, 88(r1)
+   ld  r7, 80(r1)
+   ld  r6, 72(r1)
+   ld  r5, 64(r1)
+   ld  r4, 56(r1)
+   ld  r3, 48(r1)
+
+   addir1, r1, 112
+   mflrr0
+   std r0, LRSAVE(r1)
+   bctr
+#else
ld  r11, 112(r1)
std r3, 16(r11)

@@ -1284,6 +1324,7 @@ _GLOBAL(ftrace_graph_caller)
mtlrr0
addir1, r1, 112
blr
+#endif

  _GLOBAL(return_to_handler)
/* need to save return values */
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 44d4d8e..080c525 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -306,11 +306,19 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long 
addr)
 * The load offset is different depending on the ABI. For simplicity
 * just mask it out when doing the compare.
 */
+#ifndef CC_USING_MPROFILE_KERNEL
if ((op[0] != 0x4808) || ((op[1] & 0x) != 0xe841)) {
-   pr_err("Unexpected call sequence: %x %x\n", op[0], op[1]);
+   pr_err("Unexpected call sequence at %p: %x %x\n",
+   ip, op[0], op[1]);
return -EINVAL;
}
-
+#else
+   /* look for patched "NOP" on ppc64 with -mprofile-kernel */
+   if (op[0] != 0x6000) {
+   pr_err("Unexpected call at %p: %x\n", ip, op[0]);
+   return -EINVAL;
+   }
+#endif
/* If we never set up a trampoline to ftrace_caller, then bail */
if (!rec->arch.mod->arch.tramp) {
pr_err("No ftrace trampoline\n");
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 

[PATCH v4] misc: Move panel driver out of staging

2016-02-02 Thread Ksenija Stanojevic
Move panel driver from drivers/staging/panel to drivers/misc.

Signed-off-by: Ksenija Stanojevic 
Acked-by: Willy Tarreau 
---
Changes in v4:
- modify driver location in MAINTAINERS file

Changes in v3:
- modify driver location in MAINTAINERS file

Changes in v2:
- modify MAINTAINERS file
- move lcd-panel-cgram.txt to Documentation/

 .../misc-devices}/lcd-panel-cgram.txt  |   0
 MAINTAINERS|   4 +-
 drivers/misc/Kconfig   | 278 +
 drivers/misc/Makefile  |   1 +
 drivers/{staging/panel => misc}/panel.c|   0
 drivers/staging/Kconfig|   2 -
 drivers/staging/Makefile   |   1 -
 drivers/staging/panel/Kconfig  | 278 -
 drivers/staging/panel/Makefile |   1 -
 drivers/staging/panel/TODO |   8 -
 10 files changed, 282 insertions(+), 291 deletions(-)
 rename {drivers/staging/panel => 
Documentation/misc-devices}/lcd-panel-cgram.txt (100%)
 rename drivers/{staging/panel => misc}/panel.c (100%)
 delete mode 100644 drivers/staging/panel/Kconfig
 delete mode 100644 drivers/staging/panel/Makefile
 delete mode 100644 drivers/staging/panel/TODO

diff --git a/drivers/staging/panel/lcd-panel-cgram.txt 
b/Documentation/misc-devices/lcd-panel-cgram.txt
similarity index 100%
rename from drivers/staging/panel/lcd-panel-cgram.txt
rename to Documentation/misc-devices/lcd-panel-cgram.txt
diff --git a/MAINTAINERS b/MAINTAINERS
index 369f6ae..62d8bcd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10393,8 +10393,10 @@ F: drivers/staging/nvec/
 
 STAGING - PARALLEL LCD/KEYPAD PANEL DRIVER
 M: Willy Tarreau 
+M: Ksenija Stanojevic 
 S: Odd Fixes
-F: drivers/staging/panel/
+F: Documentation/misc-devices/lcd-panel-cgram.txt
+F: drivers/misc/panel.c
 
 STAGING - REALTEK RTL8712U DRIVERS
 M: Larry Finger 
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 054fc10..f0ba782 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -525,6 +525,284 @@ config VEXPRESS_SYSCFG
  ARM Ltd. Versatile Express uses specialised platform configuration
  bus. System Configuration interface is one of the possible means
  of generating transactions on this bus.
+config PANEL
+   tristate "Parallel port LCD/Keypad Panel support"
+   depends on PARPORT
+   ---help---
+ Say Y here if you have an HD44780 or KS-0074 LCD connected to your
+ parallel port. This driver also features 4 and 6-key keypads. The LCD
+ is accessible through the /dev/lcd char device (10, 156), and the
+ keypad through /dev/keypad (10, 185). Both require misc device to be
+ enabled. This code can either be compiled as a module, or linked into
+ the kernel and started at boot. If you don't understand what all this
+ is about, say N.
+
+config PANEL_PARPORT
+   int "Default parallel port number (0=LPT1)"
+   depends on PANEL
+   range 0 255
+   default "0"
+   ---help---
+ This is the index of the parallel port the panel is connected to. One
+ driver instance only supports one parallel port, so if your keypad
+ and LCD are connected to two separate ports, you have to start two
+ modules with different arguments. Numbering starts with '0' for LPT1,
+ and so on.
+
+config PANEL_PROFILE
+   int "Default panel profile (0-5, 0=custom)"
+   depends on PANEL
+   range 0 5
+   default "5"
+   ---help---
+ To ease configuration, the driver supports different configuration
+ profiles for past and recent wirings. These profiles can also be
+ used to define an approximative configuration, completed by a few
+ other options. Here are the profiles :
+
+   0 = custom (see further)
+   1 = 2x16 parallel LCD, old keypad
+   2 = 2x16 serial LCD (KS-0074), new keypad
+   3 = 2x16 parallel LCD (Hantronix), no keypad
+   4 = 2x16 parallel LCD (Nexcom NSA1045) with Nexcom's keypad
+   5 = 2x40 parallel LCD (old one), with old keypad
+
+ Custom configurations allow you to define how your display is
+ wired to the parallel port, and how it works. This is only intended
+ for experts.
+
+config PANEL_KEYPAD
+   depends on PANEL && PANEL_PROFILE="0"
+   int "Keypad type (0=none, 1=old 6 keys, 2=new 6 keys, 3=Nexcom 4 keys)"
+   range 0 3
+   default 0
+   ---help---
+ This enables and configures a keypad connected to the parallel port.
+ The keys will be read from character device 10,185. Valid values are :
+
+   0 : do not enable this driver
+   1 : old 6 keys keypad
+   2 : new 6 keys keypad, as used on the server at 

Re: sound: another WARNING in rawmidi_transmit_ack

2016-02-02 Thread Takashi Iwai
On Tue, 02 Feb 2016 22:59:49 +0100,
Dmitry Vyukov wrote:
> 
> On Mon, Feb 1, 2016 at 12:55 PM, Takashi Iwai  wrote:
> > On Mon, 01 Feb 2016 12:31:20 +0100,
> > Dmitry Vyukov wrote:
> >>
> >> Hello,
> >>
> >> The following program triggers a splash of WARNINGs in 
> >> rawmidi_transmit_ack.
> >> Takashi, I am on commit 36f90b0a2ddd60823fe193a85e60ff1906c2a9b3 + a
> >> bunch of your recent fixes:
> >> https://gist.githubusercontent.com/dvyukov/40640128a433ad16a56a/raw/ab3a08637ce3654b969b778c5700fe4a80f14456/gistfile1.txt
> >
> > Ouch, this is another spot with an open race between
> > snd_rawmidi_transmit_peek() and snd_rawmidi_transmit_ack().
> >
> > Could you drop the previous fix and apply the one below instead?
> >
> > FWIW, I pushed sound.git tree topic/core-fixes branch containing all
> > pending fixes.  This should be pullable cleanly onto 4.5-rc1/rc2.
> >
> >  git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git 
> > topic/core-fixes
> >
> >
> > Thanks!
> >
> > Takashi
> 
> 
> Now this program hangs the machine with:

Mea culpa, the spinlock was applied at the wrong place.
Below is the revised patch.  I updated topic/core-fixes branch as
well.


thanks,

Takashi

-- 8< --
From: Takashi Iwai 
Subject: [PATCH v2] ALSA: rawmidi: Make snd_rawmidi_transmit() race-free

A kernel WARNING in snd_rawmidi_transmit_ack() is triggered by
syzkaller fuzzer:
  WARNING: CPU: 1 PID: 20739 at sound/core/rawmidi.c:1136
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
 [] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482
 [] warn_slowpath_null+0x29/0x30 kernel/panic.c:515
 [] snd_rawmidi_transmit_ack+0x275/0x400 
sound/core/rawmidi.c:1136
 [] snd_virmidi_output_trigger+0x4b1/0x5a0 
sound/core/seq/seq_virmidi.c:163
 [< inline >] snd_rawmidi_output_trigger sound/core/rawmidi.c:150
 [] snd_rawmidi_kernel_write1+0x549/0x780 
sound/core/rawmidi.c:1223
 [] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1273
 [] __vfs_write+0x113/0x480 fs/read_write.c:528
 [] vfs_write+0x167/0x4a0 fs/read_write.c:577
 [< inline >] SYSC_write fs/read_write.c:624
 [] SyS_write+0x111/0x220 fs/read_write.c:616
 [] entry_SYSCALL_64_fastpath+0x16/0x7a 
arch/x86/entry/entry_64.S:185

Also a similar warning is found but in another path:
Call Trace:
 [< inline >] __dump_stack lib/dump_stack.c:15
 [] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
 [] warn_slowpath_common+0xd9/0x140 kernel/panic.c:482
 [] warn_slowpath_null+0x29/0x30 kernel/panic.c:515
 [] rawmidi_transmit_ack+0x24a/0x3b0 sound/core/rawmidi.c:1133
 [] snd_rawmidi_transmit_ack+0x51/0x80 
sound/core/rawmidi.c:1163
 [] snd_virmidi_output_trigger+0x2b6/0x570 
sound/core/seq/seq_virmidi.c:185
 [< inline >] snd_rawmidi_output_trigger sound/core/rawmidi.c:150
 [] snd_rawmidi_kernel_write1+0x4bb/0x760 
sound/core/rawmidi.c:1252
 [] snd_rawmidi_write+0x543/0xb30 sound/core/rawmidi.c:1302
 [] __vfs_write+0x113/0x480 fs/read_write.c:528
 [] vfs_write+0x167/0x4a0 fs/read_write.c:577
 [< inline >] SYSC_write fs/read_write.c:624
 [] SyS_write+0x111/0x220 fs/read_write.c:616
 [] entry_SYSCALL_64_fastpath+0x16/0x7a 
arch/x86/entry/entry_64.S:185

In the former case, the reason is that virmidi has an open code
calling snd_rawmidi_transmit_ack() with the value calculated outside
the spinlock.   We may use snd_rawmidi_transmit() in a loop just for
consuming the input data, but even there, there is a race between
snd_rawmidi_transmit_peek() and snd_rawmidi_tranmit_ack().

Similarly in the latter case, it calls snd_rawmidi_transmit_peek() and
snd_rawmidi_tranmit_ack() separately without protection, so they are
racy as well.

The patch tries to address these issues by the following ways:
- Introduce the unlocked versions of snd_rawmidi_transmit_peek() and
  snd_rawmidi_transmit_ack() to be called inside the explicit lock.
- Rewrite snd_rawmidi_transmit() to be race-free (the former case).
- Make the split calls (the latter case) protected in the rawmidi spin
  lock.

BugLink: 
http://lkml.kernel.org/r/cact4y+ypq1+cylkadwjwa5xjzf1_vki1ehnvn-lm0hzhspu...@mail.gmail.com
BugLink: 
http://lkml.kernel.org/r/cact4y+acg4iyphdozx47nyq_vhgbpjqk-6xnpiqujazyqsx...@mail.gmail.com
Reported-by: Dmitry Vyukov 
Cc: 
Signed-off-by: Takashi Iwai 
---
 include/sound/rawmidi.h  |  4 ++
 sound/core/rawmidi.c | 98 
 sound/core/seq/seq_virmidi.c | 17 +---
 3 files changed, 88 insertions(+), 31 deletions(-)

diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h
index fdabbb4ddba9..f730b91e472f 100644
--- a/include/sound/rawmidi.h
+++ b/include/sound/rawmidi.h
@@ -167,6 +167,10 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream 
*substream,
 int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int 
count);
 int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
 unsigned char *buffer, int 

Re: [PATCH] locking/mutex: Avoid spinner vs waiter starvation

2016-02-02 Thread Ding Tianhong
On 2016/2/3 5:19, Davidlohr Bueso wrote:
> On Mon, 01 Feb 2016, Peter Zijlstra wrote:
> 
>> Subject: locking/mutex: Avoid spinner vs waiter starvation
>> From: Peter Zijlstra 
>> Date: Fri, 22 Jan 2016 12:06:53 +0100
>>
>> Ding Tianhong reported that under his load the optimistic spinners
>> would totally starve a task that ended up on the wait list.
>>
>> Fix this by ensuring the top waiter also partakes in the optimistic
>> spin queue.
>>
>> There are a few subtle differences between the assumed state of
>> regular optimistic spinners and those already on the wait list, which
>> result in the @acquired complication of the acquire path.
>>
>> Most notable are:
>>
>> - waiters are on the wait list and need to be taken off
>> - mutex_optimistic_spin() sets the lock->count to 0 on acquire
>>   even though there might be more tasks on the wait list.
> 
> Right, the main impact I see with these complications are that the
> window of when a waiter takes the lock via spinning and then acquires
> the wait_lock to remove itself from the list, will allow an unlock
> thread to set the lock as available in the fastpath which could in
> turn allow a third thread the steal the lock. With high contention,
> this window will be come obviously larger as we contend for the
> wait_lock.
> 
> CPU-0  CPU-1CPU-3
> __mutex_lock_common  mutex_optimistic_spin
>   (->count now 0)
> __mutex_fastpath_unlock
> (->count now 1) __mutex_fastpath_lock
>   (stolen)
>
> spin_lock_mutex(>wait_lock, flags);
> 
> But we've always been bad when it comes to counter and waiters.
> 

Agree, but this patch is going to help the waiter in the wait list to get the 
lock, your scene probability looks more
too low and I don't think it is a problem.

Thanks
Ding


> Thanks,
> Davidlohr
> 
> .
> 




Re: [PATCH 2/2] perf tools: Fix fault in error patch of intel_pt_process_auxtrace_info()

2016-02-02 Thread Adrian Hunter

On 2/02/2016 5:52 p.m., Arnaldo Carvalho de Melo wrote:

Em Tue, Feb 02, 2016 at 12:24:19PM +0200, Adrian Hunter escreveu:

This patch does not fix the problem because the thread__zput() will still
segfault later if the error path is not taken.

Sorry, I didn't look closely at this patch because I was not expecting it
to be taken because of the fix I had already sent:

http://marc.info/?l=linux-kernel=145431692623940

However if you want to keep the struct thread rbtree / list union, the
simple fix would be to reinstate the list initialization in this particular
case i.e.:


So, can I go with the following patch+description+authorship?


Fine by me.  Thank you!



 From 3a4acda1ecbd290973de08250d7dcdfaf5b2fe0f Mon Sep 17 00:00:00 2001
From: Adrian Hunter 
Date: Mon, 1 Feb 2016 03:21:04 +
Subject: [PATCH 1/1] perf tools: Fix thread lifetime related segfaut in intel_pt

intel_pt_process_auxtrace_info() creates a pt->unknown_thread thread
that eventually needs to be freed by the last thread__put() on it, when
its refcount hits zero, which may happen in
intel_pt_process_auxtrace_info() error handling path and triggers the
following segfault, which would happen as well at intel_pt_free, when
tools using this intel_pt codebase frees up resources:

   # perf record -I -e intel_pt/tsc=1,noretcomp=1/u /bin/ls
   0  a  anaconda-ks.cfg  bin   perf.data   perf.data.old  
perf-f23-bringup.todo
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.217 MB perf.data ]
   #
   # perf script -F event,comm,pid,tid,time,addr,ip,sym,dso,iregs
   Samples for 'instructions:u' event do not have IREGS attribute set. Cannot 
print 'iregs' field.
   intel_pt_synth_events: failed to synthesize 'instructions' event type
   Segmentation fault (core dumped)
   #

The problem is: there's a union in 'struct thread' combines a list_head
and a rb_node. The standard life cycle of a thread is: init rb_node in
the constructor, insert it into machine->threads rbtree using rb_node,
move it to machine->dead_threads using list_head, clean in the last
thread__put: list_del_init(>node).

In the above command, it clean a thread before adding it into list,
causes the above segfault.

Since pt->unknown_thread will never live in an rbtree, initialize its
list node so that when list_del_init() is done on it we don't segfault.

After this patch:

   # perf script -F event,comm,pid,tid,time,addr,ip,sym,dso,iregs
   Samples for 'instructions:u' event do not have IREGS attribute set. Cannot 
print 'iregs' field.
   intel_pt_synth_events: failed to synthesize 'instructions' event type
   0x248 [0x88]: failed to process type: 70
   #

Reported-by: Tong Zhang 
Reported-by: Wang Nan 
Signed-off-by: Adrian Hunter 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Josh Poimboeuf 
Link: 
http://lkml.kernel.org/r/1454296865-19749-1-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
  tools/perf/util/intel-pt.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 81a2eb77ba7f..05d815851be1 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -2068,6 +2068,15 @@ int intel_pt_process_auxtrace_info(union perf_event 
*event,
err = -ENOMEM;
goto err_free_queues;
}
+
+   /*
+* Since this thread will not be kept in any rbtree not in a
+* list, initialize its list node so that at thread__put() the
+* current thread lifetime assuption is kept and we don't segfault
+* at list_del_init().
+*/
+   INIT_LIST_HEAD(>unknown_thread->node);
+
err = thread__set_comm(pt->unknown_thread, "unknown", 0);
if (err)
goto err_delete_thread;



[PATCH] x86: Use named address spaces in asm/percpu.h

2016-02-02 Thread Richard Henderson
GCC 6 adds support for __seg_fs and __seg_gs as named address spaces,
producing the obvious segment overrides for objects so marked.

Exposing the memory reference allows slightly better code generation
in some cases (and in others, merely affects the scheduling).  E.g.:

[1]
- mov%gs:0x0(%rip),%eax
-R_X86_64_PC32  context_tracking+0x4
- cmp$0x1,%eax
+ cmpl   $0x1,%gs:0x0(%rip)
+R_X86_64_PC32  context_tracking+0x3

[2]
- mov%gs:0x0(%rip),%ebx
-R_X86_64_PC32  cpu_number-0x4
- movslq %ebx,%rax
+ movslq %gs:0x0(%rip),%rax
+R_X86_64_PC32  cpu_number-0x4

[3]
- mov%gs:0x0(%rip),%rdx
-R_X86_64_PC32  cpu_info+0x20
- test   $0x100,%edx
+ testb  $0x1,%gs:0x0(%rip)
+R_X86_64_PC32  cpu_info+0x22

[4]
- mov$0x0,%rax
-R_X86_64_32S   __uv_hub_info
- mov%rax,%rcx
- add%gs:0x0(%rip),%rcx
-R_X86_64_PC32  this_cpu_off-0x4
- movzbl 0x15(%rcx),%ecx
...
- mov%rax,%rdx
- add%gs:0x0(%rip),%rdx
-R_X86_64_PC32  this_cpu_off-0x4
- or (%rdx),%rcx
+ mov%gs:0x0(%rip),%r9
+R_X86_64_PC32  this_cpu_off-0x4
+ mov$0x0,%rax
+R_X86_64_32S   __uv_hub_info
...
+ movzbl 0x15(%rax,%r9,1),%ecx
...
+ or (%rax,%r9,1),%rdx

The final vmlinux text size is reduced by about 5k for a standard
Fedora configure.

Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Signed-off-by: Richard Henderson 
---
 arch/x86/include/asm/percpu.h | 145 +-
 1 file changed, 86 insertions(+), 59 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index e0ba66c..537787c 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -4,9 +4,15 @@
 #ifdef CONFIG_X86_64
 #define __percpu_seg   gs
 #define __percpu_mov_opmovq
+# ifdef __SEG_GS
+#  define __percpu_addrspace   __seg_gs
+# endif
 #else
 #define __percpu_seg   fs
 #define __percpu_mov_opmovl
+# ifdef __SEG_FS
+#  define __percpu_addrspace   __seg_fs
+# endif
 #endif
 
 #ifdef __ASSEMBLY__
@@ -46,6 +52,17 @@
 
 #ifdef CONFIG_SMP
 #define __percpu_prefix"%%"__stringify(__percpu_seg)":"
+
+#ifdef __percpu_addrspace
+/* Produce an address-space lvalue for VAR.  */
+#define __percpu_as(VAR) \
+  (*(typeof(VAR) __kernel __force __percpu_addrspace *)(uintptr_t)&(VAR))
+
+/* We cannot allow __my_cpu_offset to recurse through this_cpu_read, as
+   this will change based on CONFIG_X86_64, with which games are played
+   in 32-bit compatibility files.  */
+#define __my_cpu_offset(__percpu_as(this_cpu_off) + 0)
+#else
 #define __my_cpu_offsetthis_cpu_read(this_cpu_off)
 
 /*
@@ -60,9 +77,11 @@
 : "m" (this_cpu_off), "0" (ptr));  \
(typeof(*(ptr)) __kernel __force *)tcp_ptr__;   \
 })
+#endif /* __percpu_addrspace */
 #else
 #define __percpu_prefix""
-#endif
+#undef __percpu_addrspace
+#endif /* SMP */
 
 #define __percpu_arg(x)__percpu_prefix "%" #x
 
@@ -86,7 +105,14 @@
  * don't give an lvalue though). */
 extern void __bad_percpu_size(void);
 
-#define percpu_to_op(op, var, val) \
+#ifdef __percpu_addrspace
+#define percpu_to_op(op, cop, var, val)\
+do {   \
+   typeof(var) pto_tmp__ = (val);  \
+   __percpu_as(var) cop pto_tmp__; \
+} while (0)
+#else
+#define percpu_to_op(op, cop, var, val)\
 do {   \
typedef typeof(var) pto_T__;\
if (0) {\
@@ -118,11 +144,15 @@ do {  
\
default: __bad_percpu_size();   \
}   \
 } while (0)
+#endif /* __percpu_addrspace */
 
 /*
  * Generate a percpu add to memory instruction and optimize code
  * if one is added or subtracted.
  */
+#ifdef __percpu_addrspace
+#define percpu_add_op(var, val)  percpu_to_op("add", +=, var, val)
+#else
 #define percpu_add_op(var, val)
\
 do {   \
typedef typeof(var) pao_T__;\
@@ -178,7 +208,9 @@ do {
\
default: __bad_percpu_size();   \
}   \
 } while (0)
+#endif /* __percpu_addrspace */
 
+/* ??? Note that percpu_from_op is only ever used with mov.  */
 #define percpu_from_op(op, var)\
 ({ \
typeof(var) pfo_ret__;   

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

2016-02-02 Thread Sergey Senozhatsky
Hello,

On (02/03/16 16:27), Stephen Rothwell wrote:
> Hi Andrew,
> 
> After merging the akpm-current tree, today's linux-next build (arm
> allnoconfig) failed like this:
> 
> In file included from kernel/memremap.c:17:0:
> include/linux/pfn_t.h:108:7: error: 'pud_mkdevmap' declared as function 
> returning an array
> 
> Caused by commit
> 
>   a27da20ed50e ("mm: add support for PUD-sized transparent hugepages")
> 
> Discovered after the linux-next release.


.config

  CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y
# CONFIG_TRANSPARENT_HUGEPAGE is not set


makes the build unhappy

fs/proc/task_mmu.c: In function ‘smaps_pud_range’:
fs/proc/task_mmu.c:596:6: error: implicit declaration of function 
‘is_huge_zero_pud’ [-Werror=implicit-function-declaration]
  if (is_huge_zero_pud(*pud))
  ^


seems there is no ‘is_huge_zero_pud’ for !CONFIG_TRANSPARENT_HUGEPAGE.


and a bunch of other errors as a result


In file included from include/asm-generic/bug.h:4:0,
 from ./arch/x86/include/asm/bug.h:35,
 from include/linux/bug.h:4,
 from include/linux/mmdebug.h:4,
 from include/linux/mm.h:8,
 from fs/proc/task_mmu.c:1:
include/linux/compiler.h:505:38: error: call to ‘__compiletime_assert_599’ 
declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/compiler.h:488:4: note: in definition of macro 
‘__compiletime_assert’
prefix ## suffix();\
^
include/linux/compiler.h:505:2: note: in expansion of macro 
‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
 ^
include/linux/bug.h:84:21: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
 ^
include/linux/huge_mm.h:221:27: note: in expansion of macro ‘BUILD_BUG’
 #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; })
   ^
fs/proc/task_mmu.c:599:19: note: in expansion of macro ‘HPAGE_PUD_SIZE’
  mss->resident += HPAGE_PUD_SIZE;
   ^
In function ‘smaps_pud_range.part.10’,
inlined from ‘smaps_pud_range’:
include/linux/compiler.h:505:38: error: call to ‘__compiletime_assert_602’ 
declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/compiler.h:488:4: note: in definition of macro 
‘__compiletime_assert’
prefix ## suffix();\
^
include/linux/compiler.h:505:2: note: in expansion of macro 
‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
 ^
include/linux/bug.h:84:21: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
 ^
include/linux/huge_mm.h:221:27: note: in expansion of macro ‘BUILD_BUG’
 #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; })
   ^
fs/proc/task_mmu.c:602:25: note: in expansion of macro ‘HPAGE_PUD_SIZE’
mss->shared_dirty += HPAGE_PUD_SIZE;
 ^
include/linux/compiler.h:505:38: error: call to ‘__compiletime_assert_604’ 
declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/compiler.h:488:4: note: in definition of macro 
‘__compiletime_assert’
prefix ## suffix();\
^
include/linux/compiler.h:505:2: note: in expansion of macro 
‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
 ^
include/linux/bug.h:84:21: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
 ^
include/linux/huge_mm.h:221:27: note: in expansion of macro ‘BUILD_BUG’
 #define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; })
   ^
fs/proc/task_mmu.c:604:25: note: in expansion of macro ‘HPAGE_PUD_SIZE’
mss->shared_clean += HPAGE_PUD_SIZE;
 ^
fs/proc/task_mmu.c: In function ‘smaps_pud_range’:
include/linux/compiler.h:505:38: error: call to ‘__compiletime_assert_607’ 
declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^

Re: [PATCH v2 1/5] clk: sunxi: Add apb0 gates for H3

2016-02-02 Thread Chen-Yu Tsai
On Wed, Feb 3, 2016 at 5:21 AM, Krzysztof Adamski  wrote:
> This patch adds support for APB0 in H3. It seems to be compatible with
> earlier SOCs. apb0 gates controls R_ block peripherals (R_PIO, R_IR,
> etc).
>
> Signed-off-by: Krzysztof Adamski 
> ---
>  Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
>  drivers/clk/sunxi/clk-simple-gates.c  | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt 
> b/Documentation/devicetree/bindings/clock/sunxi.txt
> index e59f57b..6ee6875 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -32,6 +32,7 @@ Required properties:
> "allwinner,sun8i-h3-ahb2-clk" - for the AHB2 clock on H3
> "allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
> "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
> +   "allwinner,sun8i-h3-abp0-gates-clk" - for the APB0 gates on H3

The list is grouped by clock type (AHB/APB/...) then family then SoC.
Please put this in the apb0 section below.

ChenYu

> "allwinner,sun9i-a80-ahb0-gates-clk" - for the AHB0 gates on A80
> "allwinner,sun9i-a80-ahb1-gates-clk" - for the AHB1 gates on A80
> "allwinner,sun9i-a80-ahb2-gates-clk" - for the AHB2 gates on A80
> diff --git a/drivers/clk/sunxi/clk-simple-gates.c 
> b/drivers/clk/sunxi/clk-simple-gates.c
> index f4da52b..8a1fa3e 100644
> --- a/drivers/clk/sunxi/clk-simple-gates.c
> +++ b/drivers/clk/sunxi/clk-simple-gates.c
> @@ -130,6 +130,8 @@ CLK_OF_DECLARE(sun8i_a23_apb2, 
> "allwinner,sun8i-a23-apb2-gates-clk",
>sunxi_simple_gates_init);
>  CLK_OF_DECLARE(sun8i_a33_ahb1, "allwinner,sun8i-a33-ahb1-gates-clk",
>sunxi_simple_gates_init);
> +CLK_OF_DECLARE(sun8i_h3_abp0, "allwinner,sun8i-h3-abp0-gates-clk",
> +  sunxi_simple_gates_init);
>  CLK_OF_DECLARE(sun9i_a80_ahb0, "allwinner,sun9i-a80-ahb0-gates-clk",
>sunxi_simple_gates_init);
>  CLK_OF_DECLARE(sun9i_a80_ahb1, "allwinner,sun9i-a80-ahb1-gates-clk",
> --
> 2.1.4
>


Re: [PATCH v2 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set

2016-02-02 Thread Chen-Yu Tsai
Hi,

On Wed, Feb 3, 2016 at 5:21 AM, Krzysztof Adamski  wrote:
> sunxi_pmx_set accepts pin number and then calculates offset by
> subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand,
> gets offset so we have to convert it to pin number so we won't get
> negative value in sunxi_pmx_set.
>
> This was only used on A10 so far, where there is only one GPIO chip with
> pin_base set to 0 so it didn't matter. However H3 also requires this
> workaround but have two pinmux sections, triggering problem for PL port.
>
> Signed-off-by: Krzysztof Adamski 
> ---
>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index 7a2465f..9e5bac9 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -460,14 +460,17 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip 
> *chip, unsigned offset)
> u32 set_mux = pctl->desc->irq_read_needs_mux &&
> test_bit(FLAG_USED_AS_IRQ, >desc[offset].flags);
> u32 val;
> +   u32 pin;
>
> -   if (set_mux)
> -   sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_INPUT);
> +   if (set_mux) {
> +   pin = offset + pctl->desc->pin_base;

You can use chip->base directly. It's value is set to pin_base in the
init function.
You could also move this out of the if block, and not add the braces.

Otherwise this looks good.

ChenYu

> +   sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_INPUT);
> +   }
>
> val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
>
> if (set_mux)
> -   sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_IRQ);
> +   sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_IRQ);
>
> return !!val;
>  }
> --
> 2.1.4
>


Re: [RFC PATCH 11/19] cpufreq: assert policy->rwsem is held in __cpufreq_governor

2016-02-02 Thread Viresh Kumar
On 02-02-16, 21:06, Saravana Kannan wrote:
> I disagree. I think it's way better and simpler than this patch set. It also
> doesn't tie into cpufreq_governor.* which is a good thing IMO since it keeps
> things simpler for sched-dvfs too.

Lets discuss it further on the other thread .. 

-- 
viresh


Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops

2016-02-02 Thread Viresh Kumar
On 02-02-16, 22:23, Rafael J. Wysocki wrote:
> On Tue, Feb 2, 2016 at 11:57 AM, Viresh Kumar  wrote:

> "The ondemand and conservative governors use the global-attr or
> freq-attr structures to represent sysfs attributes corresponding to
> their tunables

> (which of them is actually used depends on whether or
> not different policy objects can use different governors at the same
> time

Not exactly. Different policies can always use different governors.
What made the difference was that different policies using same
governor, with different tunables or separate governor directories.

I have reworded this para like:

The ondemand and conservative governors use the global-attr or freq-attr
structures to represent sysfs attributes corresponding to their tunables
(which of them is actually used depends on whether or not different
policy objects can use same governor with different tunables at the same
time and, consequently, on where those attributes are located in sysfs).

Please let me know if isn't clear.

> > --- a/drivers/cpufreq/cpufreq_governor.c
> > +   ret = kobject_init_and_add(_data->kobj, _data->kobj_type,
> > +  get_governor_parent_kobj(policy),
> > +  attr_group->name);
> > +   if (ret) {
> > +   pr_err("%s: failed to init dbs_data kobj: %d\n", __func__, 
> > ret);
> 
> pr_debug() would be better here.

Its a real error, why pr_debug for that ?

> > goto reset_gdbs_data;
> > +   }
> >
> > return 0;
> >
> > @@ -426,8 +457,7 @@ static int cpufreq_governor_exit(struct cpufreq_policy 
> > *policy,
> > return -EBUSY;
> >
> > if (!--dbs_data->usage_count) {
> > -   sysfs_remove_group(get_governor_parent_kobj(policy),
> > -  get_sysfs_attr(dbs_data));
> > +   kobject_put(_data->kobj);
> 
> Don't we need a ->release callback for this kobject?

There is nothing that we need to free from the ->release() callback.
We are using the kobject here just to get separate show/store
callbacks.

Here is the new version based on the review comments received until
now:

-8<-

From: Viresh Kumar 
Date: Tue, 2 Feb 2016 12:35:01 +0530
Subject: [PATCH] cpufreq: governor: New sysfs show/store callbacks for
 governor tunables

The ondemand and conservative governors use the global-attr or freq-attr
structures to represent sysfs attributes corresponding to their tunables
(which of them is actually used depends on whether or not different
policy objects can use same governor with different tunables at the same
time and, consequently, on where those attributes are located in sysfs).

Unfortunately, in the freq-attr case, the standard cpufreq show/store
sysfs attribute callbacks are applied to the governor tunable attributes
and they always acquire the policy->rwsem lock before carrying out the
operation.  That may lead to an ABBA deadlock if governor tunable
attributes are removed under policy->rwsem while one of them is being
accessed concurrently (if sysfs attributes removal wins the race, it
will wait for the access to complete with policy->rwsem held while the
attribute callback will block on policy->rwsem indefinitely).

We attempted to address this issue by dropping policy->rwsem around
governor tunable attributes removal (that is, around invocations of the
->governor callback with the event arg equal to CPUFREQ_GOV_POLICY_EXIT)
in cpufreq_set_policy(), but that opened up race conditions that had not
been possible with policy->rwsem held all the time.  Therefore
policy->rwsem cannot be dropped in cpufreq_set_policy() at any point,
but the deadlock situation described above must be avoided too.

To that end, use the observation that in principle governor tunables may
be represented by the same data type regardless of whether the governor
is system-wide or per-policy and introduce a new structure, struct
governor_attr, for representing them and new corresponding macros for
creating show/store sysfs callbacks for them.  Also make their parent
kobject use a new kobject type whose default show/store callbacks are
not related to the standard core cpufreq ones in any way (and they don't
acquire policy->rwsem in particular).

[ Rafael: Written changelog ]
Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq_conservative.c | 73 --
 drivers/cpufreq/cpufreq_governor.c | 71 -
 drivers/cpufreq/cpufreq_governor.h | 34 ++--
 drivers/cpufreq/cpufreq_ondemand.c | 73 --
 4 files changed, 144 insertions(+), 107 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_conservative.c 
b/drivers/cpufreq/cpufreq_conservative.c
index 57750367bd26..c749fb4fe5d2 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -275,54 

Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops

2016-02-02 Thread Viresh Kumar
On 02-02-16, 20:03, Saravana Kannan wrote:
> This is the hotplug case I mentioned. The sysfs file removals will happen
> only for the last CPU in that policy (we thankfully optimized that part last
> year). We also know that multiple CPUs can't be hotplugged at the same time.
> So, in the start of cpufreq_offline_prepare, we just need to check if this
> is the last CPU in the policy and if that's the case, do the gov sysfs
> remove and then grab the policy lock and do all our crap. If a read is going
> on, that's going to finish before the sysfs attr remove can go ahead and it
> can grab the policy lock if it needs to and that still won't cause a
> deadlock because we haven't yet grabbed the policy lock in
> cpufreq_offline_prepare(). If the read comes after the sysfs remove, then
> the read is obviously going to fail (we can depend on the sysfs framework on
> doing its job there).

IMHO, these are all dirty hacks we should stay away from. Adding such
hunks in code is considered a band-aid kind of solution and hurts
readability badly. The new solution (new governor show/store)
implement this in a very clean and proper way I feel..

Others are free to disagree though :)

-- 
viresh


Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops

2016-02-02 Thread Viresh Kumar
On 02-02-16, 17:32, Saravana Kannan wrote:
> But if we are expecting sched dvfs to come in, why make it worse for it. It
> would be completely pointless to try and shoehorn sched dvfs to use
> cpufreq_governor.c

We can move the common part to cpufreq core and not make sched-dvfs
reuse cpufreq_governor.c

-- 
viresh


Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops

2016-02-02 Thread Viresh Kumar
On 02-02-16, 14:21, Saravana Kannan wrote:
> I also don't like this patch because it forces governors to either implement
> their own macros and management of their attributes or force them to use the
> governor structs that come with cpufreq_governor.h. cpufreq_governor.h IMHO
> is very ondemand and conservative governor specific and is very irrelevant
> for sched-dvfs or any other governors (hint hint).

But who is stopping us from breaking that file and moving some of it
into include/linux/cpufreq.h ?

We can do that today as well, but it would be fine to do that, when we
add more governors to the core. Though, it would only take a simple
patch if people want me to do it now.

> The only time this ABBA locking is an issue is when governor are changing
> and trying to add/remove attributes. That can easily be checked in
> store_governor

store_scaling_governor ??

> and dealt with without holding the policy rwsem if the

Are you saying that we could have taken the rwsem from the generic
cpufreq.c:store() and dropped it from store_scaling_governor() ? That
would have been something similar to what I tried earlier, which I
never posted (I gave the link to that few days back).

> governors can provide their per sys and per policy attribute arrays as part
> of registering themselves.

These per-sys and per-policy attributes really suck. There is nothing
really different in the implementation, just that the show/store
callbacks have different prototype. One accept 'kboj' as the parameter,
other accept 'policy'. I would call that a HACK as well (I only
implemented it though).

That should just die. A single list of attributes is what we should
have had initially as well.

-- 
viresh


RE: [patch] bfa: use strncpy() instead of memcpy()

2016-02-02 Thread Anil Gurumurthy
Acked-by: Anil Gurumurthy 

-Original Message-
From: Dan Carpenter [mailto:dan.carpen...@oracle.com] 
Sent: 30 January 2016 20:06
To: Anil Gurumurthy 
Cc: Sudarsana Kalluru ; James E.J. Bottomley 
; Martin K. Petersen ; 
linux-scsi ; linux-kernel 
; kernel-janit...@vger.kernel.org
Subject: [patch] bfa: use strncpy() instead of memcpy()

BFA_MFG_NAME is "QLogic" which is only 7 bytes, but we are copying 8 bytes.  
It's harmless because the badding byte is likely zero but it makes static 
checkers complain.

Signed-off-by: Dan Carpenter 
---
Technically the memset() is not needed because strncpy() will pad the rest of 
the buffer with zeros but I was worried that people would be paranoid.

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 
251e2ff..a1ada4a 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -2803,7 +2803,7 @@ void
 bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer)  {
memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
-   memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
+   strncpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
 }
 
 void


Re: [linux-sunxi] [PATCH 01/11] MAINTAINERS: Add entry for X-Powers AXP family PMIC drivers

2016-02-02 Thread Chen-Yu Tsai
On Wed, Feb 3, 2016 at 9:28 AM, Joe Perches  wrote:
> On Wed, 2016-02-03 at 11:19 +1100, Julian Calaby wrote:
>> On Tue, Feb 2, 2016 at 9:27 PM, Chen-Yu Tsai  wrote:
>> > Add an entry for X-Powers AXP family PMIC drivers and list myself
>> > as maintainer.
> []
>> > diff --git a/MAINTAINERS b/MAINTAINERS
> []
>> > @@ -11941,6 +11941,12 @@ F: include/linux/workqueue.h
>> >  F: kernel/workqueue.c
>> >  F: Documentation/workqueue.txt
>> >
>> > +X-POWERS MULTIFUNCTION PMIC DEVICE DRIVERS
>> > +M: Chen-Yu Tsai 
>> > +L: linux-kernel@vger.kernel.org
>> > +S: Maintained
>> > +N: axp[128]
>>
>> Should you list the files maintained and this list also?
>
> This "N:" pattern is kind of a wildcard.
>
> The difference between F: and N: is that git history
> is also used by default for files that match.
>
> There are no files in -next today that match "*axp8*"
> Dunno if this patchset added any.

This set adds a "axp809.dtsi". A subsequent set will add "axp806.dtsi".

> This matches:
>
> $ git ls-files | grep "axp[128]"
> Documentation/devicetree/bindings/mfd/axp20x.txt
> Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt
> arch/arm/boot/dts/axp152.dtsi
> arch/arm/boot/dts/axp209.dtsi
> arch/arm/boot/dts/axp22x.dtsi
> drivers/extcon/extcon-axp288.c
> drivers/iio/adc/axp288_adc.c
> drivers/input/misc/axp20x-pek.c
> drivers/mfd/axp20x.c
> drivers/power/axp20x_usb_power.c
> drivers/power/axp288_charger.c
> drivers/power/axp288_fuel_gauge.c
> drivers/regulator/axp20x-regulator.c
> include/linux/mfd/axp20x.h
>
> Are all these files appropriate?
>

Yes.

ChenYu


[PATCHv2] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2:kbuild test robot reported warnings on ununsed
   variables.Those warnings are fixed.
---
 drivers/staging/android/ion/ion_cma_heap.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..8cd720b 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -92,13 +90,8 @@ err:
 
 static void ion_cma_free(struct ion_buffer *buffer)
 {
-   struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
-   struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


Re: [PATCH 0/2] scsi: Fix endless loop of ATA hard resets due to VPD reads

2016-02-02 Thread Kirill A. Shutemov
On Tue, Feb 02, 2016 at 09:45:48PM -0500, Martin K. Petersen wrote:
> > "Kirill" == Kirill A Shutemov  writes:
> 
> Kirill> I have the same problem.
> 
> Kirill> Shouldn't we put quirk for that?
> 
> I was hoping that Hannes' patch would do the trick so we could avoid
> blacklisting:
> 
>   https://patchwork.kernel.org/patch/8079011/

It didn't help me.

-- 
 Kirill A. Shutemov


Re: [PATCH 07/10] arm64: dts: add the Marvell Armada 3700 family and a development board

2016-02-02 Thread Jisheng Zhang
On Tue, 2 Feb 2016 19:07:45 +0100 Gregory CLEMENT wrote:

> Add initial dtsi files to support Marvell Armada 3700 SoC with Cortex-A53
> CPUs. There are two members in this family: the Armada 3710 (Single CPU)
> and the Armada 3720 (Dual CPUs).
> 
> It also adds a dts file for the Marvell Armada 3720 DB board.
> 
> Signed-off-by: Gregory CLEMENT 
> ---
>  arch/arm64/boot/dts/marvell/Makefile   |   4 +
>  arch/arm64/boot/dts/marvell/armada-371x.dtsi   |  53 ++
>  arch/arm64/boot/dts/marvell/armada-3720-db.dts |  87 
>  arch/arm64/boot/dts/marvell/armada-372x.dtsi   |  63 
>  arch/arm64/boot/dts/marvell/armada-37xx.dtsi   | 131 
> +
>  5 files changed, 338 insertions(+)
>  create mode 100644 arch/arm64/boot/dts/marvell/armada-371x.dtsi
>  create mode 100644 arch/arm64/boot/dts/marvell/armada-3720-db.dts
>  create mode 100644 arch/arm64/boot/dts/marvell/armada-372x.dtsi
>  create mode 100644 arch/arm64/boot/dts/marvell/armada-37xx.dtsi
> 
> diff --git a/arch/arm64/boot/dts/marvell/Makefile 
> b/arch/arm64/boot/dts/marvell/Makefile
> index 348f4db4f313..bc2eabe1cab1 100644
> --- a/arch/arm64/boot/dts/marvell/Makefile
> +++ b/arch/arm64/boot/dts/marvell/Makefile
> @@ -1,6 +1,10 @@
> +# Berlin SoC Family
>  dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-dmp.dtb
>  dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-stb.dtb
>  
> +# Mvebu SoC Family
> +dtb-$(CONFIG_ARCH_ARMADA_3700) += armada-3720-db.dtb
> +
>  always   := $(dtb-y)
>  subdir-y := $(dts-dirs)
>  clean-files  := *.dtb
> diff --git a/arch/arm64/boot/dts/marvell/armada-371x.dtsi 
> b/arch/arm64/boot/dts/marvell/armada-371x.dtsi
> new file mode 100644
> index ..c9e5325b8ac3
> --- /dev/null
> +++ b/arch/arm64/boot/dts/marvell/armada-371x.dtsi
> @@ -0,0 +1,53 @@
> +/*
> + * Device Tree Include file for Marvell Armada 371x family of SoCs
> + * (also named 88F3710)
> + *
> + * Copyright (C) 2016 Marvell

Is it better to Add full Marvell company name, eg. Marvell Technology Group Ltd.

> + *
> + * Gregory CLEMENT 

Do we need to put "Author: " at the head?

> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of the
> + * License, or (at your option) any later version.
> + *
> + * This file is distributed in the hope that it will be useful
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Or, alternatively
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * files (the "Software"), to deal in the Software without
> + * restriction, including without limitation the rights to use
> + * copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following
> + * conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
> + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#include "armada-37xx.dtsi"
> +
> +/ {
> + model = "Marvell Armada 3710 SoC";
> + compatible = "marvell,armada3710", "marvell,armada3700";
> +};
> diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts 
> b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
> new file mode 100644
> index ..76cae6ba2bd6
> --- /dev/null
> +++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
> @@ -0,0 +1,87 @@
> +/*
> + * Device Tree file for Marvell Armada 3720 development board
> + * (DB-88F3720-DDR3)
> + * Copyright (C) 2016 Marvell
> + *
> + * Gregory CLEMENT 
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is 

Re: FW: [RFC 3/3] CMDQ: Mediatek CMDQ driver

2016-02-02 Thread Daniel Kurtz
> Hi Dan,
>
> Thanks for your comment.
> This solution looks good to me.
> I will change it as your suggestion.
>
> But, I have a question about 'mask out the provided *device virtual*
> address'.
> Are lower 16-bits (or 24-bits for JUMP op) of device virtual address the
> same as device physical address?

I'm not sure.  But I doubt it we can rely on this.
My guess would be that the ioremap only preserves the lower 12 bits
(4k page size).

> If not, we still need to pass in physical address into CMDQ driver.

Or, instead of the iommu/slot approach, we can just provide a
registration function for the gce driver.
Each gce consumer could then have a simple gce node, with no slot/address:

  mediatek,gce = <>;

Then on probe, the gce consumer could pass in its (struct device *) to
gce_register_device().  gce_register_device() could then access the
device's of_node to extract its physical address range, and look up
its physical address in its table of per-soc of
"device_address:gce_subsys_address" entries.  If the physical address
is in a valid subsys ranges, the gce_register_device would cache the
subsys address, and an offset in a (struct gce_consumer).
gce_register_device() could then add this struct to a struct list_head
of gce_consumers, and finally return a pointer to it back to the
caller.

Later, the gce consumer could pass in ths (struct gce_consumer *) when
make gce calls, along with the *offset* (not the physical address or
virtual address) for the register that it wishes to access.  Then the
gce driver can simply use the gce_consumer->subsys entry to create a
gce address from the passed in offset.

This will keep the binding very simple, and would remove the need to
convert from device virtual to physical addresses by the gce consumer,
but require a little more per-gce-consumer setup.

-Dan


Re: [PATCH v2 2/2] phy: add a driver for the Rockchip SoC internal eMMC PHY

2016-02-02 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 05 January 2016 06:38 AM, Shawn Lin wrote:
> This patch to add a generic PHY driver for ROCKCHIP eMMC PHY.
> Access the PHY via registers provided by GRF (general register
> files) module.
> 
> Signed-off-by: Shawn Lin 
> 
> ---
> 
> Changes in v2:
> - remove phy from rockchip_emmc_phy
> - remove state from rockchip_emmc_phy
> - remove on/off from init/exit
> 
>  drivers/phy/Kconfig |   7 ++
>  drivers/phy/Makefile|   1 +
>  drivers/phy/phy-rockchip-emmc.c | 241 
> 
>  3 files changed, 249 insertions(+)
>  create mode 100644 drivers/phy/phy-rockchip-emmc.c
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 03cb3ea..47d16e3 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -320,6 +320,13 @@ config PHY_ROCKCHIP_USB
>   help
> Enable this to support the Rockchip USB 2.0 PHY.
>  
> +config PHY_ROCKCHIP_EMMC
> + tristate "Rockchip EMMC PHY Driver"
> + depends on ARCH_ROCKCHIP && OF
> + select GENERIC_PHY
> + help
> +   Enable this to support the Rockchip EMMC PHY.
> +
>  config PHY_ST_SPEAR1310_MIPHY
>   tristate "ST SPEAR1310-MIPHY driver"
>   select GENERIC_PHY
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 075db1a..ed8f175 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -35,6 +35,7 @@ phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2)  += 
> phy-s5pv210-usb2.o
>  obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o
>  obj-$(CONFIG_PHY_QCOM_APQ8064_SATA)  += phy-qcom-apq8064-sata.o
>  obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
> +obj-$(CONFIG_PHY_ROCKCHIP_EMMC) += phy-rockchip-emmc.o
>  obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA)  += phy-qcom-ipq806x-sata.o
>  obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
>  obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
> diff --git a/drivers/phy/phy-rockchip-emmc.c b/drivers/phy/phy-rockchip-emmc.c
> new file mode 100644
> index 000..6a157c2
> --- /dev/null
> +++ b/drivers/phy/phy-rockchip-emmc.c
> @@ -0,0 +1,241 @@
> +/*
> + * Rockchip emmc PHY driver
> + *
> + * Copyright (C) 2015 Shawn Lin 
> + * Copyright (C) 2015 ROCKCHIP, Inc.

2016?
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * The higher 16-bit of this register is used for write protection
> + * only if BIT(x + 16) set to 1 the BIT(x) can be written.
> + */
> +#define HIWORD_UPDATE(val, mask, shift) \
> + ((val) << (shift) | (mask) << ((shift) + 16))
> +
> +/* Register definition */
> +#define GRF_EMMCPHY_CON0 0x0
> +#define GRF_EMMCPHY_CON1 0x4
> +#define GRF_EMMCPHY_CON2 0x8
> +#define GRF_EMMCPHY_CON3 0xc
> +#define GRF_EMMCPHY_CON4 0x10
> +#define GRF_EMMCPHY_CON5 0x14
> +#define GRF_EMMCPHY_CON6 0x18
> +#define GRF_EMMCPHY_STATUS   0x20
> +
> +#define PHYCTRL_PDB_MASK 0x1
> +#define PHYCTRL_PDB_SHIFT0x0
> +#define PHYCTRL_PDB_PWR_ON   0x1
> +#define PHYCTRL_PDB_PWR_OFF  0x0
> +#define PHYCTRL_ENDLL_MASK   0x1
> +#define PHYCTRL_ENDLL_SHIFT 0x1
> +#define PHYCTRL_ENDLL_ENABLE 0x1
> +#define PHYCTRL_ENDLL_DISABLE0x0
> +#define PHYCTRL_CALDONE_MASK 0x1
> +#define PHYCTRL_CALDONE_SHIFT   0x6
> +#define PHYCTRL_CALDONE_DONE 0x1
> +#define PHYCTRL_CALDONE_GOING0x0
> +#define PHYCTRL_DLLRDY_MASK  0x1
> +#define PHYCTRL_DLLRDY_SHIFT 0x5
> +#define PHYCTRL_DLLRDY_DONE  0x1
> +#define PHYCTRL_DLLRDY_GOING 0x0
> +
> +struct rockchip_emmc_phy {
> + unsigned intreg_offset;
> + struct regmap   *reg_base;
> +};
> +
> +static int rockchip_emmc_phy_power(struct rockchip_emmc_phy *rk_phy,
> +bool on_off)
> +{
> + unsigned int caldone;
> + unsigned int dllrdy;
> +
> + /*
> +  * Keep phyctrl_pdb and phyctrl_endll low to allow
> +  * initialization of CALIO state M/C DFFs
> +  */
> + regmap_write(rk_phy->reg_base,
> +  rk_phy->reg_offset + GRF_EMMCPHY_CON6,
> +  HIWORD_UPDATE(PHYCTRL_PDB_PWR_OFF,
> +PHYCTRL_PDB_MASK,
> +PHYCTRL_PDB_SHIFT));
> + regmap_write(rk_phy->reg_base,
> +  rk_phy->reg_offset + GRF_EMMCPHY_CON6,
> +  HIWORD_UPDATE(PHYCTRL_ENDLL_DISABLE,
> +PHYCTRL_ENDLL_MASK,
> +PHYCTRL_ENDLL_SHIFT));
> 

Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops

2016-02-02 Thread Viresh Kumar
On 02-02-16, 17:01, Juri Lelli wrote:
> Hi Rafael,
> 
> On 02/02/16 17:35, Rafael J. Wysocki wrote:
> > On Tue, Feb 2, 2016 at 4:47 PM, Juri Lelli  wrote:

> > > This patch cleans things up a lot, that's good.
> > >
> > > One thing I'm still concerned about, though: don't we need some locking
> > > in place for some of the store operations on governors attributes? Are
> > > store_{ignore_nice_load, sampling_down_fact, etc} safe without locking?
> > 
> > That would require some investigation I suppose.

Yeah, that protection is required. Sorry about that.

> > > It seems that we can call them from different cpus concurrently.
> > 
> > Yes, we can.
> > 
> > One quick-and-dirty way of dealing with that might be to introduce a
> > "sysfs lock" into struct dbs_data and hold that around the invocation
> > of gattr->store() in the sysfs_ops's ->store callback.

s/dirty/sane ? :)

> Can't we actually try to use the policy->rwsem (or one of the core
> locks) + wait_for_completion approach as we do in cpufreq core?

policy->rwsem will defeat the purpose of this change as it will
reintroduce the ABBA issue.

-- 
viresh


Re: [PATCH 03/10] arm64: add Armada 3700 architecture entry

2016-02-02 Thread Jisheng Zhang
On Tue, 2 Feb 2016 19:07:41 +0100 Gregory CLEMENT wrote:

> The Armada 3700 is an mvebu ARM64 SoC using one or two Cortex-A53 cores
> depending of the variant.
> 
> Signed-off-by: Gregory CLEMENT 
> Reviewed-by: Thomas Petazzoni 
> ---
>  arch/arm64/Kconfig.platforms | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
> index 21074f674bde..7da341f7b90d 100644
> --- a/arch/arm64/Kconfig.platforms
> +++ b/arch/arm64/Kconfig.platforms
> @@ -1,5 +1,11 @@
>  menu "Platform selection"
>  
> +config ARCH_ARMADA_3700

Would it be better to use ARCH_MVEBU? IMHO, there will be more ARMv8 SoCs
from our EBU, do we plan to add one CONFIG_ARMADA_yyzz for each SoC?

> + bool "Armada 3700 SoC Family"
> + help
> +   This enables support for Armada 3700 SoC Family. It is is an
> +   ARMv8 based chipset belonging to the mvebu family.
> +
>  config ARCH_BCM_IPROC
>   bool "Broadcom iProc SoC Family"
>   help



Re: [PATCH 0/5] Fix races & improve the radix tree iterator patterns

2016-02-02 Thread Konstantin Khlebnikov
On Thu, Jan 28, 2016 at 10:17 AM, Konstantin Khlebnikov
 wrote:
> On Thu, Jan 28, 2016 at 12:17 AM, Matthew Wilcox
>  wrote:
>> From: Matthew Wilcox 
>>
>> The first two patches here are bugfixes, and I would like to see them
>> make their way into stable ASAP since they can lead to data corruption
>> (very low probabilty).
>>
>> The last three patches do not qualify as bugfixes.  They simply improve
>> the standard pattern used to do radix tree iterations by removing the
>> 'goto restart' part.  Partially this is because this is an ugly &
>> confusing goto, and partially because with multi-order entries in the
>> tree, it'll be more likely that we'll see an indirect_ptr bit, and
>> it's more efficient to kep going from the point of the iteration we're
>> currently in than restart from the beginning each time.
>
> Ack  whole set.
>
> I think we should go deeper in hide dereference/retry inside iterator.
> Something like radix_tree_for_each_data(data, slot, root, iter, start).
> I'll prepare patch for that.

After second thought: there'ra not so many users for new sugar.
This scheme with radix_tree_deref_retry - radix_tree_iter_retry
complicated but fine.

>
>>
>> Matthew Wilcox (5):
>>   radix-tree: Fix race in gang lookup
>>   hwspinlock: Fix race between radix tree insertion and lookup
>>   btrfs: Use radix_tree_iter_retry()
>>   mm: Use radix_tree_iter_retry()
>>   radix-tree,shmem: Introduce radix_tree_iter_next()
>>
>>  drivers/hwspinlock/hwspinlock_core.c |  4 +++
>>  fs/btrfs/tests/btrfs-tests.c |  3 +-
>>  include/linux/radix-tree.h   | 31 +
>>  lib/radix-tree.c | 12 ++--
>>  mm/filemap.c | 53 
>> 
>>  mm/shmem.c   | 30 ++--
>>  6 files changed, 78 insertions(+), 55 deletions(-)
>>
>> --
>> 2.7.0.rc3
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majord...@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: mailto:"d...@kvack.org;> em...@kvack.org 


Re: wl12xx regression on 4.5 (was: Re: linux-4.5-rc1 TI pandboard-es wifi wlcore locks and reset)

2016-02-02 Thread Ross Green
On Wed, Feb 3, 2016 at 3:05 AM, Sebastian Reichel  wrote:
> Hi Ross,
>
> Please don't top-post on kernel mailinglists. Use either inline
> style or bottom posting.
>
> On Tue, Feb 02, 2016 at 04:41:13PM +1100, Ross Green wrote:
>> On Tue, Feb 2, 2016 at 3:34 PM, Sebastian Reichel  wrote:
>> > On Mon, Feb 01, 2016 at 11:38:38PM +1100, Ross Green wrote:
>> >> On Mon, Jan 25, 2016 at 11:47 PM, Ross Green  wrote:
>> >> > Just tried the new kernel release on faithful pandaboard es with the
>> >> > new 4.5-rc1 release.
>> >> >
>> >> > There is a problem with the wifi modules once the modules are loaded.
>> >> > Looks like the wifi firmware gets loaded put no response after that
>> >> > causing recovery action.
>> >> >
>> >> > the kernel 4.4 works quite happily with this board.
>> >> >
>> >> > Here is a dmesg dump in the attachment.
>> >> >
>> >> > Anyone have any ideas here?
>>
>> [...]
>>
>> If I get time, this evening, I'll see if I can give a bisect a try.
>
> On N950 [wl1271 via SPI, using extra patches to init from DT] I get wifi
> working again on 4.5-rc1 with 3719c17e1816 ("wlcore/wl18xx: fw logger
> over sdio") reverted.
>
> -- Sebastian

For the pandaboard using

for 4.5

CONFIG_WLAN_VENDOR_TI=y
CONFIG_WL12XX=m
CONFIG_WLCORE=m
CONFIG_WLCORE_SDIO=m
CONFIG_WILINK_PLATFORM_DATA=y

so I suspect it is something to do with modifications to wlcore,
wlcore_sdio, or wl12xx that have been applied.

Given there are similar problems with the SPI interface then it is
more likely to be problems in the wlcore modifications.

Shahar have these been tested on a pandaboard omap4 setup?

Regards,

Ross


Re: [PATCH] phy: core: fix wrong err handle for phy_power_on

2016-02-02 Thread Kishon Vijay Abraham I
Hi,

On Thursday 28 January 2016 01:44 PM, Shawn Lin wrote:
> If phy_pm_runtime_get_sync failed but we already
> enable regulator, current code return directly without
> doing regulator_disable. This patch fix this problem
> and cleanup err handle of phy_power_on to be more readable.
> 
> Fixes: 3be88125d85d ("phy: core: Support regulator ...")
> Cc: Roger Quadros 
> Cc: Axel Lin 
> Signed-off-by: Shawn Lin 

Thank you for fixing this. Merged it.

Thanks
Kishon

> ---
> 
>  drivers/phy/phy-core.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 8c7f27d..e7e574d 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit);
>  
>  int phy_power_on(struct phy *phy)
>  {
> - int ret;
> + int ret = 0;
>  
>   if (!phy)
> - return 0;
> + goto out;
>  
>   if (phy->pwr) {
>   ret = regulator_enable(phy->pwr);
>   if (ret)
> - return ret;
> + goto out;
>   }
>  
>   ret = phy_pm_runtime_get_sync(phy);
>   if (ret < 0 && ret != -ENOTSUPP)
> - return ret;
> + goto err_pm_sync;
> +
>   ret = 0; /* Override possible ret == -ENOTSUPP */
>  
>   mutex_lock(>mutex);
> @@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy)
>   ret = phy->ops->power_on(phy);
>   if (ret < 0) {
>   dev_err(>dev, "phy poweron failed --> %d\n", ret);
> - goto out;
> + goto err_pwr_on;
>   }
>   }
>   ++phy->power_count;
>   mutex_unlock(>mutex);
>   return 0;
>  
> -out:
> +err_pwr_on:
>   mutex_unlock(>mutex);
>   phy_pm_runtime_put_sync(phy);
> +err_pm_sync:
>   if (phy->pwr)
>   regulator_disable(phy->pwr);
> -
> +out:
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(phy_power_on);
> 


Re: [PATCH 08/10] fs: ceph: replace CURRENT_TIME by current_fs_time()

2016-02-02 Thread Yan, Zheng

> On Feb 3, 2016, at 14:07, Deepa Dinamani  wrote:
> 
> CURRENT_TIME macro is not appropriate for filesystems as it
> doesn't use the right granularity for filesystem timestamps.
> Use current_fs_time() instead.
> 
> Signed-off-by: Deepa Dinamani 
> Cc: "Yan, Zheng" 
> Cc: Sage Weil 
> Cc: Ilya Dryomov 
> Cc: ceph-de...@vger.kernel.org

applied, thanks

Yan, Zheng

> ---
> fs/ceph/file.c  | 4 ++--
> fs/ceph/inode.c | 2 +-
> fs/ceph/xattr.c | 4 ++--
> 3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 86a9c38..9b338ff 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -783,7 +783,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct 
> iov_iter *iter,
>   int num_pages = 0;
>   int flags;
>   int ret;
> - struct timespec mtime = CURRENT_TIME;
> + struct timespec mtime = current_fs_time(inode->i_sb);
>   size_t count = iov_iter_count(iter);
>   loff_t pos = iocb->ki_pos;
>   bool write = iov_iter_rw(iter) == WRITE;
> @@ -988,7 +988,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter 
> *from, loff_t pos,
>   int flags;
>   int check_caps = 0;
>   int ret;
> - struct timespec mtime = CURRENT_TIME;
> + struct timespec mtime = current_fs_time(inode->i_sb);
>   size_t count = iov_iter_count(from);
> 
>   if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index fb4ba2e..63d0198 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -1959,7 +1959,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr 
> *attr)
>   if (dirtied) {
>   inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied,
>  _cf);
> - inode->i_ctime = CURRENT_TIME;
> + inode->i_ctime = current_fs_time(inode->i_sb);
>   }
> 
>   release &= issued;
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index 819163d..1e1c00a 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -999,7 +999,7 @@ retry:
>   dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
>  _cf);
>   ci->i_xattrs.dirty = true;
> - inode->i_ctime = CURRENT_TIME;
> + inode->i_ctime = current_fs_time(inode->i_sb);
>   }
> 
>   spin_unlock(>i_ceph_lock);
> @@ -1136,7 +1136,7 @@ retry:
>   dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
>  _cf);
>   ci->i_xattrs.dirty = true;
> - inode->i_ctime = CURRENT_TIME;
> + inode->i_ctime = current_fs_time(inode->i_sb);
>   spin_unlock(>i_ceph_lock);
>   if (lock_snap_rwsem)
>   up_read(>snap_rwsem);
> -- 
> 1.9.1
> 



Re: [PATCH 02/22] phy: Fix dependencies for !HAS_IOMEM archs

2016-02-02 Thread Kishon Vijay Abraham I


On Tuesday 26 January 2016 03:54 AM, Richard Weinberger wrote:
> Not every arch has io memory.
> So, unbreak the build by fixing the dependencies.
> 
> Signed-off-by: Richard Weinberger 

Acked-by: Kishon Vijay Abraham I 
> ---
>  drivers/phy/Kconfig | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index e7e117d..ddfbaf9 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -33,6 +33,7 @@ config ARMADA375_USBCLUSTER_PHY
>   def_bool y
>   depends on MACH_ARMADA_375 || COMPILE_TEST
>   depends on OF
> + depends on HAS_IOMEM
>   select GENERIC_PHY
>  
>  config PHY_DM816X_USB
> @@ -128,6 +129,7 @@ config PHY_RCAR_GEN3_USB2
>  config OMAP_CONTROL_PHY
>   tristate "OMAP CONTROL PHY Driver"
>   depends on ARCH_OMAP2PLUS || COMPILE_TEST
> + depends on HAS_IOMEM
>   help
> Enable this to add support for the PHY part present in the control
> module. This driver has API to power on the USB2 PHY and to write to
> @@ -224,6 +226,7 @@ config PHY_MT65XX_USB3
>  
>  config PHY_HI6220_USB
>   tristate "hi6220 USB PHY support"
> + depends on HAS_IOMEM
>   select GENERIC_PHY
>   select MFD_SYSCON
>   help
> @@ -400,6 +403,7 @@ config PHY_BRCMSTB_SATA
>  config PHY_CYGNUS_PCIE
>   tristate "Broadcom Cygnus PCIe PHY driver"
>   depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
> + depends on HAS_IOMEM
>   select GENERIC_PHY
>   default ARCH_BCM_CYGNUS
>   help
> 


RE: [PATCH v2 17/17] drivers:mtd:ubi: Kconfig Makefile

2016-02-02 Thread beanhuo
> >On Tue, Feb 02, 2016 at 04:15:43AM +, Bean Huo 霍斌斌 wrote:
> > > Hi Bean,
> > >
> > > [auto build test WARNING on v4.5-rc2]
> >
> > This version 2.0 patches are based on 4.2-rc7.
> 
> Please don't send patches against ancient kernel versions.
Brian 
Sorry for this. this patches codes are too long,
Next time I will push my patches based on latest kernel.

Beat Regards!
Beanhuo


RE: [PATCH v2 00/17] Add a bakvol module in UBI layer for MLC paired page power loss issue

2016-02-02 Thread beanhuo
Dear Richard
Thanks for reviewing my patches and valuable feedback. 
I also want to work with you and Boris on such solution, 
I know this is a complicated task, need our joint effort.

Following is my explanation for each of concerns:

> Bean,
> 
> Am 02.02.2016 um 03:30 schrieb Bean Huo:
> > This version patches based on Linux kernel 4.2-rc7.
> >
> >  v2:
> >1.Add CRC32 protection for user OOB area data.
> >2.Move recovery action from attach step to ubifs mount step.
> >3.Add more comments for some key function.
> >4.standard multi-plane program function.
> >5.Standard send-mail patches
> 
> It is sad to see that you've ignored almost all review comments that have
> been made.
> Both comments made by Boris and me on the public mailing list as well as the
> comments and I made on our phone call.
> 
> To summarize, I see the following major issues with this patch series:
> 1. It makes use of OOB, it was very clearly stated that this violates one of
> UBI's design principles.
Currently I still cannot find a good method on how to manage backup info.
So now I still use OOB.
Backup page OOB stores source page address, and source page OOB store backup 
page address,
They store each other's page address, one is in order to indicate that backup 
page
is really one copy data of source page, in case of source block being erased 
and re-mapped again.
Another is in order to quickly find corresponding source page.

> 2. It is not generic, you use hard coded constants for Micron 70s/80s MLC
> NANDs.
>And AFAICT it is not guaranteed that all MLC NANDs support multi pane
> writes.
Yes, so far ,different NAND vendor with different paired page sequence,
So if guarantee all vendor NAND, should involve every vendor NAND paired page
Sequence table or calculator function, but now I don't have other NAND vendor 
datasheet.

> 3. Not all data is protected. Most of UBI's meta data (EC headers,
> volume table)
>are explicitly not protected, as well as UBIFS's superblock and master
> nodes.
For master node: 
current UBIFS master node already has one copy for power loss,
Just not cover MLC paired page power loss issue, if my previous Master node 
issue 
patch be accepted, master node totally does not need to protection.

EC:
For EC header, according to my testing result data and our NAND PE cycle 
requirement,
If EC header be damaged by power loss , mean erase count is ok, no impact on 
NAND life.
But for VID header, because my solution uses dual plane page program, it has 
special page address
Requirement on dual plane page address, that is page number should be the same.
UBI already pre-program page 0 and page 1, so no page 1 is for VID.


> 4. It mixes UBI and UBIFS code. Having code like this in UBI's EBA code is not
> acceptable:
>ubi_io_write_data(ubi, buf, pnum, offset, len, ((lnum < 3) ? 0 : 1));
>This hack is here to void safe writes of UBIFS's suberblock and master
> nodes.
>But UBIFS specific code has no business in UBI core code. Also See 3.
These codes need to modify. Thanks.

> 5. It does not scale. Having a backup of every important page would require
> much more space.
>Especially UBI EC and VID headers. I bet this is also the reason why the
> current implementation
>does not protect them. Otherwise the bakvol would fill up immediately.
>Another scalability problem is that the whole bakvol has to be scanned
> which will slow down
>the attach/mount process and may void the speedup gained by Fastmap.
This is also my concern, maybe next version I can fix this by store bakvol PEB 
info
Into flash.

> 6. It focuses only on UBIFS. ubi_corrupted_data_recovery() is only called
> from UBIFS code.
>If UBI is changed, we need a solution for all users on top of UBI.
>Now I understand also why you want the "fs:ubifs:recovery:fixup UBIFS
> cannot recover master node issue"
>patch. As UBIFS master nodes are not protected by bakvol they will
> corrupt and UBIFS is not able to recover
>nor can run ubi_corrupted_data_recovery().
> 
> 7. A full bakvol is not proper handled. The implementation falls back to
> "unsafe" writes.
> dbg_gen("Allocate new PEB for Bakvol.\n");
> pbk = allo_new_block_for_bakvol(ubi, oppe_plane);
> if (!pbk) {
> ubi_err(ubi, "Allocate new PEB failed.\n");
> nobak = 1;
> goto Only_source;
> }
>You cannot expect users to query the kernel log for such error messages.
> 
> 
> Beside of these issues there are a lot of small implementation issues.
> For example Fastmap is broken as UBI_FM_SB_VOLUME_ID clashes with
> UBI_BACKUP_VOLUME_ID.
> Or struct list_head is part of on-Flash data structures.
> 
> That said, it don't think the bakvol approach is the solution we're looking 
> for.
> A proper solution has to fulfill the following conditions:
> 1. No dependency on OOB data.
> 2. Can work with any MLC NANDs 

[PATCH 09/10] fs: ceph: Replace CURRENT_TIME by ktime_get_real_ts()

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned series.

Filesystems will use current_fs_time() instead of
CURRENT_TIME.
Use ktime_get_real_ts() here as this is not filesystem time.
ktime_get_real_ts() returns the timestamp in ns which can
be used to calculate MDS request timestamp.

Signed-off-by: Deepa Dinamani 
Cc: "Yan, Zheng" 
Cc: Sage Weil 
Cc: Ilya Dryomov 
Cc: ceph-de...@vger.kernel.org
---
 fs/ceph/mds_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index e7b130a..348b22e 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1721,7 +1721,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, 
int op, int mode)
init_completion(>r_safe_completion);
INIT_LIST_HEAD(>r_unsafe_item);
 
-   req->r_stamp = CURRENT_TIME;
+   ktime_get_real_ts(>r_stamp);
 
req->r_op = op;
req->r_direct_mode = mode;
-- 
1.9.1



[PATCH 07/10] fs: ext4: Replace CURRENT_TIME with ext4_current_time()

2016-02-02 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use ext4_current_time() instead which is appropriate for ext4
timestamps.

Signed-off-by: Deepa Dinamani 
Cc: "Theodore Ts'o" 
Cc: Andreas Dilger 
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3ed01ec..5e6c866 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5139,7 +5139,7 @@ static int ext4_quota_off(struct super_block *sb, int 
type)
handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
if (IS_ERR(handle))
goto out;
-   inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
ext4_mark_inode_dirty(handle, inode);
ext4_journal_stop(handle);
 
-- 
1.9.1



[PATCH 06/10] fs: ext4: Replace CURRENT_TIME_SEC with current_fs_time_sec()

2016-02-02 Thread Deepa Dinamani
The macro CURRENT_TIME_SEC does not represent filesystem times
correctly as it cannot perform range checks.
current_fs_time_sec() will be extended to include this.

CURRENT_TIME_SEC is also not y2038 safe. current_fs_time_sec()
will be transitioned to use 64 bit time along with vfs in a
separate series.

Signed-off-by: Deepa Dinamani 
Cc: "Theodore Ts'o" 
Cc: Andreas Dilger 
Cc: linux-e...@vger.kernel.org
---
 fs/ext4/ext4.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0662b28..8dd04f8 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1489,7 +1489,7 @@ static inline struct ext4_inode_info *EXT4_I(struct inode 
*inode)
 static inline struct timespec ext4_current_time(struct inode *inode)
 {
return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
-   current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
+   current_fs_time(inode->i_sb) : current_fs_time_sec(inode->i_sb);
 }
 
 static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
-- 
1.9.1



[PATCH 08/10] fs: ceph: replace CURRENT_TIME by current_fs_time()

2016-02-02 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

Signed-off-by: Deepa Dinamani 
Cc: "Yan, Zheng" 
Cc: Sage Weil 
Cc: Ilya Dryomov 
Cc: ceph-de...@vger.kernel.org
---
 fs/ceph/file.c  | 4 ++--
 fs/ceph/inode.c | 2 +-
 fs/ceph/xattr.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 86a9c38..9b338ff 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -783,7 +783,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter 
*iter,
int num_pages = 0;
int flags;
int ret;
-   struct timespec mtime = CURRENT_TIME;
+   struct timespec mtime = current_fs_time(inode->i_sb);
size_t count = iov_iter_count(iter);
loff_t pos = iocb->ki_pos;
bool write = iov_iter_rw(iter) == WRITE;
@@ -988,7 +988,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, 
loff_t pos,
int flags;
int check_caps = 0;
int ret;
-   struct timespec mtime = CURRENT_TIME;
+   struct timespec mtime = current_fs_time(inode->i_sb);
size_t count = iov_iter_count(from);
 
if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index fb4ba2e..63d0198 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1959,7 +1959,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr 
*attr)
if (dirtied) {
inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied,
   _cf);
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
}
 
release &= issued;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 819163d..1e1c00a 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -999,7 +999,7 @@ retry:
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
   _cf);
ci->i_xattrs.dirty = true;
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
}
 
spin_unlock(>i_ceph_lock);
@@ -1136,7 +1136,7 @@ retry:
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
   _cf);
ci->i_xattrs.dirty = true;
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
spin_unlock(>i_ceph_lock);
if (lock_snap_rwsem)
up_read(>snap_rwsem);
-- 
1.9.1



[PATCH 10/10] fs: btrfs: Replace CURRENT_TIME by current_fs_time()

2016-02-02 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

Signed-off-by: Deepa Dinamani 
Cc: Chris Mason 
Cc: Josef Bacik 
Cc: David Sterba 
Cc: linux-bt...@vger.kernel.org
---
 fs/btrfs/file.c|  4 ++--
 fs/btrfs/inode.c   | 25 +
 fs/btrfs/ioctl.c   |  8 
 fs/btrfs/root-tree.c   |  2 +-
 fs/btrfs/transaction.c |  7 +--
 fs/btrfs/xattr.c   |  2 +-
 6 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 098bb8f..610f569 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2544,7 +2544,7 @@ out_trans:
goto out_free;
 
inode_inc_iversion(inode);
-   inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);
 
trans->block_rsv = >fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode);
@@ -2794,7 +2794,7 @@ static long btrfs_fallocate(struct file *file, int mode,
if (IS_ERR(trans)) {
ret = PTR_ERR(trans);
} else {
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
i_size_write(inode, actual_end);
btrfs_ordered_update_i_size(inode, actual_end, NULL);
ret = btrfs_update_inode(trans, root, inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e28f3d4..59c0e22 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4013,7 +4013,8 @@ err:
btrfs_i_size_write(dir, dir->i_size - name_len * 2);
inode_inc_iversion(inode);
inode_inc_iversion(dir);
-   inode->i_ctime = dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+   inode->i_ctime = dir->i_mtime =
+   dir->i_ctime = current_fs_time(inode->i_sb);
ret = btrfs_update_inode(trans, root, dir);
 out:
return ret;
@@ -4156,7 +4157,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 
btrfs_i_size_write(dir, dir->i_size - name_len * 2);
inode_inc_iversion(dir);
-   dir->i_mtime = dir->i_ctime = CURRENT_TIME;
+   dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
ret = btrfs_update_inode_fallback(trans, root, dir);
if (ret)
btrfs_abort_transaction(trans, root, ret);
@@ -5588,7 +5589,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_op = _dir_ro_inode_operations;
inode->i_fop = _dir_operations;
inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
-   inode->i_mtime = CURRENT_TIME;
+   inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6160,7 +6161,7 @@ static struct inode *btrfs_new_inode(struct 
btrfs_trans_handle *trans,
inode_init_owner(inode, dir, mode);
inode_set_bytes(inode, 0);
 
-   inode->i_mtime = CURRENT_TIME;
+   inode->i_mtime = current_fs_time(inode->i_sb);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
BTRFS_I(inode)->i_otime = inode->i_mtime;
@@ -6273,7 +6274,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
btrfs_i_size_write(parent_inode, parent_inode->i_size +
   name_len * 2);
inode_inc_iversion(parent_inode);
-   parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
+   parent_inode->i_mtime = parent_inode->i_ctime =
+   current_fs_time(parent_inode->i_sb);
ret = btrfs_update_inode(trans, root, parent_inode);
if (ret)
btrfs_abort_transaction(trans, root, ret);
@@ -6491,7 +6493,7 @@ static int btrfs_link(struct dentry *old_dentry, struct 
inode *dir,
BTRFS_I(inode)->dir_index = 0ULL;
inc_nlink(inode);
inode_inc_iversion(inode);
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);
ihold(inode);
set_bit(BTRFS_INODE_COPY_EVERYTHING, _I(inode)->runtime_flags);
 
@@ -9234,7 +9236,6 @@ static int btrfs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
struct btrfs_root *dest = BTRFS_I(new_dir)->root;
struct inode *new_inode = d_inode(new_dentry);
struct inode *old_inode = d_inode(old_dentry);
-   struct timespec ctime = CURRENT_TIME;
u64 index = 0;
u64 root_objectid;
int ret;
@@ -9331,9 +9332,9 @@ static int btrfs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
inode_inc_iversion(old_dir);
inode_inc_iversion(new_dir);
inode_inc_iversion(old_inode);
-   old_dir->i_ctime = old_dir->i_mtime = ctime;
-   new_dir->i_ctime = new_dir->i_mtime = ctime;
-   old_inode->i_ctime = 

[PATCH 01/10] fs: Add current_fs_time_sec() function

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

The function is meant to replace CURRENT_TIME_SEC macro.
The macro CURRENT_TIME_SEC does not represent filesystem times
correctly as it cannot perform range checks.
current_fs_time_sec() will be extended to include these.

CURRENT_TIME_SEC is also not y2038 safe. current_fs_time_sec()
will be transitioned to use 64 bit time along with vfs in a
separate series.

The function is inline for now to maintain similar performance
to that of the macro.

The function takes super block as a parameter to allow for
future range checking of filesystem timestamps.

Signed-off-by: Deepa Dinamani 
Cc: Alexander Viro 
Cc: linux-fsde...@vger.kernel.org
---
 include/linux/fs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6a75571..4af612f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1407,6 +1407,11 @@ struct super_block {
 
 extern struct timespec current_fs_time(struct super_block *sb);
 
+static inline struct timespec current_fs_time_sec(struct super_block *sb)
+{
+   return (struct timespec) { get_seconds(), 0 };
+}
+
 /*
  * Snapshotting support.
  */
-- 
1.9.1



[PATCH 05/10] fs: cifs: Replace CURRENT_TIME by get_seconds

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned series.

Filesystems will use current_fs_time() instead of
CURRENT_TIME.
Use get_seconds() here as this is not filesystem time.
Only the seconds portion of the timestamp is necessary for
timezone calculation using server time.

Assume that the difference between server and client times
lie in the range INT_MIN..INT_MAX. This is valid because
this is the difference between current times between server
and client, and the largest timezone difference is in the
range of one day.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
---
 fs/cifs/cifssmb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 90b4f9f..1a9e43d 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,14 +478,14 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts, utc;
-   utc = CURRENT_TIME;
+   struct timespec ts;
+   unsigned long utc = get_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
-(int)ts.tv_sec, (int)utc.tv_sec,
-(int)(utc.tv_sec - ts.tv_sec));
-   val = (int)(utc.tv_sec - ts.tv_sec);
+(int)ts.tv_sec, (int)utc,
+(int)(utc - ts.tv_sec));
+   val = (int)(utc - ts.tv_sec);
seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
remain = seconds % MIN_TZ_ADJ;
-- 
1.9.1



[PATCH 04/10] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()

2016-02-02 Thread Deepa Dinamani
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned series.

Filesystem times will use current_fs_time() instead of
CURRENT_TIME.
Use ktime_get_real_ts() here as this is not filesystem time.
ktime_get_real_ts() returns the timestamp in ns which can
be used to calculate network time for NTLMv2 authentication
timestamp.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
---
 fs/cifs/cifsencrypt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index d411654..f86e07d 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -460,6 +460,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
+   struct timespec ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -484,7 +485,8 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   ktime_get_real_ts();
+   return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
-- 
1.9.1



[PATCH 02/10] vfs: Replace CURRENT_TIME by current_fs_time()

2016-02-02 Thread Deepa Dinamani
The CURRENT_TIME macro is not sufficient for filesystem timestamps since
it does not truncate the values according to filesystem granularity.

simple_link(), simple_unlink() and simple_rename() only need a single
call to current_fs_time() since they do not span filesystems.

Signed-off-by: Deepa Dinamani 
Cc: Alexander Viro 
Cc: linux-fsde...@vger.kernel.org
---
 fs/libfs.c | 21 +
 fs/nsfs.c  |  3 ++-
 fs/pipe.c  |  3 ++-
 fs/posix_acl.c |  2 +-
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 0ca80b2..e3a8ed5 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -237,7 +237,7 @@ struct dentry *mount_pseudo(struct file_system_type 
*fs_type, char *name,
 */
root->i_ino = 1;
root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-   root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
+   root->i_atime = root->i_mtime = root->i_ctime = current_fs_time(s);
dentry = __d_alloc(s, _name);
if (!dentry) {
iput(root);
@@ -267,7 +267,8 @@ int simple_link(struct dentry *old_dentry, struct inode 
*dir, struct dentry *den
 {
struct inode *inode = d_inode(old_dentry);
 
-   inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+   inode->i_ctime = dir->i_ctime =
+   dir->i_mtime = current_fs_time(dir->i_sb);
inc_nlink(inode);
ihold(inode);
dget(dentry);
@@ -301,7 +302,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
struct inode *inode = d_inode(dentry);
 
-   inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+   inode->i_ctime = dir->i_ctime =
+   dir->i_mtime = current_fs_time(dir->i_sb);
drop_nlink(inode);
dput(dentry);
return 0;
@@ -340,8 +342,9 @@ int simple_rename(struct inode *old_dir, struct dentry 
*old_dentry,
inc_nlink(new_dir);
}
 
-   old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
-   new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
+   old_dir->i_ctime = old_dir->i_mtime =
+   new_dir->i_ctime = new_dir->i_mtime =
+   inode->i_ctime = current_fs_time(inode->i_sb);
 
return 0;
 }
@@ -492,7 +495,7 @@ int simple_fill_super(struct super_block *s, unsigned long 
magic,
 */
inode->i_ino = 1;
inode->i_mode = S_IFDIR | 0755;
-   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(s);
inode->i_op = _dir_inode_operations;
inode->i_fop = _dir_operations;
set_nlink(inode, 2);
@@ -518,7 +521,8 @@ int simple_fill_super(struct super_block *s, unsigned long 
magic,
goto out;
}
inode->i_mode = S_IFREG | files->mode;
-   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_atime = inode->i_mtime =
+   inode->i_ctime = current_fs_time(s);
inode->i_fop = files->ops;
inode->i_ino = i;
d_add(dentry, inode);
@@ -1064,7 +1068,8 @@ struct inode *alloc_anon_inode(struct super_block *s)
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_flags |= S_PRIVATE;
-   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_atime = inode->i_mtime =
+   inode->i_ctime = current_fs_time(inode->i_sb);
return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 8f20d60..f0e18b2 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -82,7 +82,8 @@ slow:
return ERR_PTR(-ENOMEM);
}
inode->i_ino = ns->inum;
-   inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
+   inode->i_mtime = inode->i_atime =
+   inode->i_ctime = current_fs_time(inode->i_sb);
inode->i_flags |= S_IMMUTABLE;
inode->i_mode = S_IFREG | S_IRUGO;
inode->i_fop = _file_operations;
diff --git a/fs/pipe.c b/fs/pipe.c
index c1c1b26..ad3fc8d 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -699,7 +699,8 @@ static struct inode * get_pipe_inode(void)
inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
-   inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+   inode->i_atime = inode->i_mtime =
+   inode->i_ctime = current_fs_time(inode->i_sb);
 
return inode;
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 711dd51..778a27e 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -859,7 +859,7 @@ int simple_set_acl(struct inode *inode, struct posix_acl 
*acl, int type)
acl = NULL;
}
 
-   inode->i_ctime = CURRENT_TIME;
+   inode->i_ctime = current_fs_time(inode->i_sb);

[PATCH 03/10] fs: cifs: Replace CURRENT_TIME with current_fs_time()

2016-02-02 Thread Deepa Dinamani
CURRENT_TIME macro is not appropriate for filesystems as it
doesn't use the right granularity for filesystem timestamps.
Use current_fs_time() instead.

Change signature of helper cifs_all_info_to_fattr since it
now needs both super_block and cifs_sb_info.

Note: The inode timestamps read from the server are assumed
to have correct granularity and range.

Signed-off-by: Deepa Dinamani 
Cc: Steve French 
Cc: linux-c...@vger.kernel.org
Cc: samba-techni...@lists.samba.org
---
 fs/cifs/inode.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index aeb26db..fa72359 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -320,9 +320,8 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct 
super_block *sb)
fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU;
fattr->cf_uid = cifs_sb->mnt_uid;
fattr->cf_gid = cifs_sb->mnt_gid;
-   fattr->cf_atime = CURRENT_TIME;
-   fattr->cf_ctime = CURRENT_TIME;
-   fattr->cf_mtime = CURRENT_TIME;
+   fattr->cf_atime = fattr->cf_ctime =
+   fattr->cf_mtime = current_fs_time(sb);
fattr->cf_nlink = 2;
fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
 }
@@ -584,9 +583,10 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const 
unsigned char *path,
 /* Fill a cifs_fattr struct with info from FILE_ALL_INFO */
 static void
 cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
-  struct cifs_sb_info *cifs_sb, bool adjust_tz,
+  struct super_block *sb, bool adjust_tz,
   bool symlink)
 {
+   struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
memset(fattr, 0, sizeof(*fattr));
@@ -597,7 +597,7 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, 
FILE_ALL_INFO *info,
if (info->LastAccessTime)
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
else
-   fattr->cf_atime = CURRENT_TIME;
+   fattr->cf_atime = current_fs_time(sb);
 
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
@@ -657,7 +657,6 @@ cifs_get_file_info(struct file *filp)
FILE_ALL_INFO find_data;
struct cifs_fattr fattr;
struct inode *inode = file_inode(filp);
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
struct cifsFileInfo *cfile = filp->private_data;
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct TCP_Server_Info *server = tcon->ses->server;
@@ -669,7 +668,7 @@ cifs_get_file_info(struct file *filp)
rc = server->ops->query_file_info(xid, tcon, >fid, _data);
switch (rc) {
case 0:
-   cifs_all_info_to_fattr(, _data, cifs_sb, false,
+   cifs_all_info_to_fattr(, _data, inode->i_sb, false,
   false);
break;
case -EREMOTE:
@@ -751,7 +750,7 @@ cifs_get_inode_info(struct inode **inode, const char 
*full_path,
}
 
if (!rc) {
-   cifs_all_info_to_fattr(, data, cifs_sb, adjust_tz,
+   cifs_all_info_to_fattr(, data, sb, adjust_tz,
   symlink);
} else if (rc == -EREMOTE) {
cifs_create_dfs_fattr(, sb);
-- 
1.9.1



[PATCH 00/10] Remove CURRENT_TIME and CURRENT_TIME_SEC - PART 1

2016-02-02 Thread Deepa Dinamani
Introduction

This patch series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC
macros.

The idea for the series evolved from my discussions with Arnd Bergmann.

This was originally part of the RFC series[2]:
https://lkml.org/lkml/2016/1/7/20 (under discussion).

Dave Chinner suggested moving bug fixes out of the feature series to keep the
original series simple.

There are 354 occurrences of the the above macros in the kernel.
The series will be divided into 4 or 5 parts to keep the parts manageable
and so that each part could be reviewed and merged independently.
This is part 1 of the series. 

Motivation

The macros: CURRENT_TIME and CURRENT_TIME_SEC are primarily used for
filesystem timestamps.
But, they are not accurate as they do not perform clamping according to
filesystem timestamps ranges, nor do they truncate the nanoseconds value
to the granularity as required by the filesystem.

The series is also viewed as an ancillary to another upcoming series[2]
that attempts to transition file system timestamps to use 64 bit time to
make these y2038 safe.

There will also be another series[3] to add range checks and clamping to
filesystem time functions that are meant to substitute the above macros.

Solution

CURRENT_TIME macro has an equivalent function:

struct timespec current_fs_time(struct super_block *sb)

These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].

A new function will be added to substitute for CURRENT_TIME_SEC macro
in the current series:

struct timespec current_fs_time_sec(void)

These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].

Any use of these macros outside of filesystem timestamps will
be replaced by function calls to appropriate time functions.

Deepa Dinamani (10):
  fs: Add current_fs_time_sec() function
  vfs: Replace CURRENT_TIME by current_fs_time()
  fs: cifs: Replace CURRENT_TIME with current_fs_time()
  fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()
  fs: cifs: Replace CURRENT_TIME by get_seconds
  fs: ext4: Replace CURRENT_TIME_SEC with current_fs_time_sec()
  fs: ext4: Replace CURRENT_TIME with ext4_current_time()
  fs: ceph: replace CURRENT_TIME by current_fs_time()
  fs: ceph: Replace CURRENT_TIME by ktime_get_real_ts()
  fs: btrfs: Replace CURRENT_TIME by current_fs_time()

 fs/btrfs/file.c|  4 ++--
 fs/btrfs/inode.c   | 25 +
 fs/btrfs/ioctl.c   |  8 
 fs/btrfs/root-tree.c   |  2 +-
 fs/btrfs/transaction.c |  7 +--
 fs/btrfs/xattr.c   |  2 +-
 fs/ceph/file.c |  4 ++--
 fs/ceph/inode.c|  2 +-
 fs/ceph/mds_client.c   |  2 +-
 fs/ceph/xattr.c|  4 ++--
 fs/cifs/cifsencrypt.c  |  4 +++-
 fs/cifs/cifssmb.c  | 10 +-
 fs/cifs/inode.c| 15 +++
 fs/ext4/ext4.h |  2 +-
 fs/ext4/super.c|  2 +-
 fs/libfs.c | 21 +
 fs/nsfs.c  |  3 ++-
 fs/pipe.c  |  3 ++-
 fs/posix_acl.c |  2 +-
 include/linux/fs.h |  5 +
 20 files changed, 72 insertions(+), 55 deletions(-)

-- 
1.9.1



Re: [PATCH] rtlwifi: fix semicolon.cocci warnings

2016-02-02 Thread Larry Finger

On 02/02/2016 09:40 PM, kbuild test robot wrote:

drivers/net/wireless/realtek/rtlwifi/core.c:59:2-3: Unneeded semicolon


  Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

CC: Byeoungwook Kim 
Signed-off-by: Fengguang Wu 
---


Acked-by: Larry Finger 

Thanks,

Larry



  core.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -56,7 +56,7 @@ void rtl_addr_delay(u32 addr)
case 0xf9:
udelay(1);
break;
-   };
+   }
  }
  EXPORT_SYMBOL(rtl_addr_delay);






Re: [PATCH 5/5] cpufreq: Get rid of ->governor_enabled and its lock

2016-02-02 Thread Viresh Kumar
On 02-02-16, 16:49, Juri Lelli wrote:
> There are still paths where we call __cpufreq_governor() without holding
> policy->rwsem, but those should be fixed with my cleanups (that I intend
> to refresh and post soon). So, I'm not sure we can safely remove this
> yet.

No, we can't.. Though I haven't seen any races from happening even
after removing it, but it doesn't mean we can't.

The deal is that, the entire sequence of events needs to be guaranteed
to happen in a particular order without any other code performing
similar operations concurrently.

And so we need to preserve the other sites with proper rwsem locking
first.

> So, __cpufreq_governor() becomes effectively a wrapper around
> ->governor() calls and governors are left responsible for implementing
> the state machine with appropriate checks.

Not really. The core can now guarantee that the entire sequence
happens atomically. For example, on governor switch, we need to
guarantee that STOP/EXIT happen without any intervention for the old
governor. Or, INIT/START/LIMITS happen without any intervention for
the new governor, etc..

> Maybe we add a comment somewhere stating exactly how things are meant to
> work?

Hmm.

-- 
viresh


[PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()

2016-02-02 Thread Byungchul Park
change from v1 to v2
- remove unnecessary overhead by the redundant spin(un)lock.

Since I faced a infinite recursive printk() bug, I've tried to propose
patches the title of which is "lib/spinlock_debug.c: prevent a recursive
cycle in the debug code". But I noticed the root problem cannot be fixed
by that, through some discussion thanks to Sergey and Peter. So I focused
on preventing the deadlock.

-8<-
>From 56ce4a9c4e9a089eff798fd17015f395751abb62 Mon Sep 17 00:00:00 2001
From: Byungchul Park 
Date: Wed, 3 Feb 2016 14:44:52 +0900
Subject: [PATCH v2] lock/semaphore: Avoid an unnecessary deadlock within up()

wake_up_process() is currently protected by spinlock though it's not
necessary. Furthermore, it can cause a deadlock when it's hit from within
printk() since the wake_up_process() can printk() again.

The scenario the bad thing can happen is,

printk
  console_trylock
  console_unlock
up_console_sem
  up
raw_spin_lock_irqsave(>lock, flags)
__up
  wake_up_process
try_to_wake_up
  raw_spin_lock_irqsave(>pi_lock)
__spin_lock_debug
  spin_dump
printk
  console_trylock
raw_spin_lock_irqsave(>lock, flags)

*** DEADLOCK ***

Signed-off-by: Byungchul Park 
---
 kernel/locking/semaphore.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
index b8120ab..14d0aca 100644
--- a/kernel/locking/semaphore.c
+++ b/kernel/locking/semaphore.c
@@ -37,7 +37,7 @@ static noinline void __down(struct semaphore *sem);
 static noinline int __down_interruptible(struct semaphore *sem);
 static noinline int __down_killable(struct semaphore *sem);
 static noinline int __down_timeout(struct semaphore *sem, long timeout);
-static noinline void __up(struct semaphore *sem);
+static noinline struct task_struct *__up(struct semaphore *sem);
 
 /**
  * down - acquire the semaphore
@@ -178,13 +178,23 @@ EXPORT_SYMBOL(down_timeout);
 void up(struct semaphore *sem)
 {
unsigned long flags;
+   struct task_struct *p = NULL;
 
raw_spin_lock_irqsave(>lock, flags);
if (likely(list_empty(>wait_list)))
sem->count++;
else
-   __up(sem);
+   p = __up(sem);
raw_spin_unlock_irqrestore(>lock, flags);
+
+   /*
+* wake_up_process() needs not to be protected by a spinlock.
+* Thus move it from the protected region to here. What is
+* worse, this unnecessary protection can cause a deadlock by
+* acquiring the same sem->lock within wake_up_process().
+*/
+   if (unlikely(p))
+   wake_up_process(p);
 }
 EXPORT_SYMBOL(up);
 
@@ -253,11 +263,11 @@ static noinline int __sched __down_timeout(struct 
semaphore *sem, long timeout)
return __down_common(sem, TASK_UNINTERRUPTIBLE, timeout);
 }
 
-static noinline void __sched __up(struct semaphore *sem)
+static noinline struct task_struct *__sched __up(struct semaphore *sem)
 {
struct semaphore_waiter *waiter = list_first_entry(>wait_list,
struct semaphore_waiter, list);
list_del(>list);
waiter->up = true;
-   wake_up_process(waiter->task);
+   return waiter->task;
 }
-- 
1.9.1



Re: FW: [RFC 3/3] CMDQ: Mediatek CMDQ driver

2016-02-02 Thread Horng-Shyang Liao
On Wed, 2016-02-03 at 09:40 +0800, Cawa Cheng (鄭曄禧) wrote:
> 
> -Original Message-
> From: djku...@google.com [mailto:djku...@google.com] On Behalf Of Daniel Kurtz
> Sent: Wednesday, February 03, 2016 12:22 AM
> To: Hs Liao (廖宏祥)
> Cc: Rob Herring; Matthias Brugger; Sascha Hauer; open list:OPEN FIRMWARE 
> AND...; linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; 
> moderated list:ARM/Mediatek SoC support; srv_heupstream; Sascha Hauer; 
> Philipp Zabel; Nicolas Boichat; CK Hu (胡俊光); Cawa Cheng (鄭曄禧); Bibby Hsieh 
> (謝濟遠); YT Shen (沈岳霆); Daoyuan Huang (黃道原); Damon Chu (朱峻賢); Josh-YC Liu 
> (劉育誠); Glory Hung (洪智瑋); Yong Wu (吴勇)
> Subject: Re: [RFC 3/3] CMDQ: Mediatek CMDQ driver
> 
> On Tue, Feb 2, 2016 at 2:48 PM, Horng-Shyang Liao  
> wrote:
> > On Mon, 2016-02-01 at 18:22 +0800, Daniel Kurtz wrote:
> >> On Mon, Feb 1, 2016 at 2:20 PM, Horng-Shyang Liao  
> >> wrote:
> >> > On Mon, 2016-02-01 at 12:15 +0800, Daniel Kurtz wrote:
> >> >> On Mon, Feb 1, 2016 at 10:04 AM, Horng-Shyang Liao 
> >> >>  wrote:
> >> >> >
> >> >> > On Fri, 2016-01-29 at 21:15 +0800, Daniel Kurtz wrote:
> >> >> > > On Fri, Jan 29, 2016 at 8:24 PM, Horng-Shyang Liao 
> >> >> > >  wrote:
> >> >> > > > On Fri, 2016-01-29 at 16:42 +0800, Daniel Kurtz wrote:
> >> >> > > >> On Fri, Jan 29, 2016 at 3:39 PM, Horng-Shyang Liao 
> >> >> > > >>  wrote:
> >> >> > > >> > Hi Dan,
> >> >> > > >> >
> >> >> > > >> > Many thanks for your comments and time.
> >> >> > > >> > I reply my plan inline.
> >> >> > > >> >
> >> >> > > >> >
> >> >> > > >> > On Thu, 2016-01-28 at 12:49 +0800, Daniel Kurtz wrote:
> >> >> > > >> >> Hi HS,
> >> >> > > >> >>
> >> >> > > >> >> Sorry for the delay.  It is hard to find time to review 
> >> >> > > >> >> a >3700 line driver :-o in detail
> >> >> > > >> >>
> >> >> > > >> >> Some review comments inline, although I still do not 
> >> >> > > >> >> completely understand how all that this driver does and how 
> >> >> > > >> >> it works.
> >> >> > > >> >> I'll try to find time to go through this driver in 
> >> >> > > >> >> detail again next time you post it for review.
> >> >> > > >> >>
> >> >> > > >> >> On Tue, Jan 19, 2016 at 9:14 PM,   
> >> >> > > >> >> wrote:
> >> >> > > >> >> > From: HS Liao 
> >> >> > > >> >> >
> >> >> > > >> >> > This patch is first version of Mediatek Command 
> >> >> > > >> >> > Queue(CMDQ) driver. The CMDQ is used to help 
> >> >> > > >> >> > read/write registers with critical time limitation, 
> >> >> > > >> >> > such as updating display configuration during the vblank. 
> >> >> > > >> >> > It controls Global Command Engine (GCE) hardware to achieve 
> >> >> > > >> >> > this requirement.
> >> >> > > >> >> > Currently, CMDQ only supports display related 
> >> >> > > >> >> > hardwares, but we expect it can be extended to other 
> >> >> > > >> >> > hardwares for future requirements.
> >> >> > > >> >> >
> >> >> > > >> >> > Signed-off-by: HS Liao 
> >> >> > > >> >>
> >> >> > > >> >> [snip]
> >> >> > > >> >>
> >> >> > > >> >> > diff --git a/drivers/soc/mediatek/mtk-cmdq.c 
> >> >> > > >> >> > b/drivers/soc/mediatek/mtk-cmdq.c new file mode 100644 
> >> >> > > >> >> > index 000..7570f00
> >> >> > > >> >> > --- /dev/null
> >> >> > > >> >> > +++ b/drivers/soc/mediatek/mtk-cmdq.c
> >> >> > > >
> >> >> > > > [snip]
> >> >> > > >
> >> >> > > >> >> > +static const struct cmdq_subsys g_subsys[] = {
> >> >> > > >> >> > +   {0x1400, 1, "MMSYS"},
> >> >> > > >> >> > +   {0x1401, 2, "DISP"},
> >> >> > > >> >> > +   {0x1402, 3, "DISP"},
> >> >> > > >> >>
> >> >> > > >> >> This isn't going to scale.  These addresses could be 
> >> >> > > >> >> different on different chips.
> >> >> > > >> >> Instead of a static table like this, we probably need 
> >> >> > > >> >> specify to the connection between gce and other devices 
> >> >> > > >> >> via devicetree phandles, and then use the phandles to 
> >> >> > > >> >> lookup the corresponding device address range.
> >> >> > > >> >
> >> >> > > >> > I will define them in device tree.
> >> >> > > >> > E.g.
> >> >> > > >> > cmdq {
> >> >> > > >> >   reg_domain = 0x1400, 0x1401, 0x1402 }
> >> >> > > >>
> >> >> > > >> The devicetree should only model hardware relationships, 
> >> >> > > >> not software considerations.
> >> >> > > >>
> >> >> > > >> Is the hardware constraint here for using gce with various 
> >> >> > > >> other hardware blocks?  I think we already model this by 
> >> >> > > >> only providing a gce phandle in the device tree nodes for 
> >> >> > > >> those devices that can use gce.
> >> >> > > >>
> >> >> > > >> Looking at the driver closer, as far as I can tell, the 
> >> >> > > >> whole subsys concept is a purely software abstraction, and 
> >> >> > > >> only used to debug the CMDQ_CODE_WRITE command.  In fact, 
> >> >> > > >> AFAICT, everything would work fine if we just completely 
> >> >> > > >> removed the 'subsys' concept, and just passed through the raw 
> >> >> > > >> address provided by the driver.
> >> 

Re: [RFC PATCH] alispinlock: acceleration from lock integration on multi-core platform

2016-02-02 Thread Ling Ma
The attachment(thread.c) can tell us the new mechanism improve output
from  the user space code (thread,c) by 1.14x (1174810406/1026910602,
kernel spinlock consumption is reduced from 25% to 15%) as below:

  ORG NEW
38186815 43644156
38340186 43121265
38383155 44087753
38567102 43532586
38027878 43622700
38011581 43396376
37861959 43322857
37963215 43375528
38039247 43618315
37989106 43406187
37916912 44163029
39053184 43138581
37928359 43247866
37967417 43390352
37909796 43218250
37727531 43256009
38032818 43460496
38001860 43536100
38019929 44231331
37846621 43550597
37823231 44229887
38108158 43142689
37771900 43228168
37652536 43901042
37649114 43172690
37591314 43380004
38539678 43435592

Total 1026910602 1174810406

Thanks
Ling

2016-02-03 12:40 GMT+08:00 Ling Ma :
> Longman,
>
> The attachment include user space code(thread.c), and kernel
> patch(ali_work_queue.patch) based on 4.3.0-rc4,
> we replaced all original spinlock (list_lock) in slab.h/c  with the
> new mechanism.
>
> The thread.c in user space caused lots of hot kernel spinlock from
> __kmalloc and kfree,
> perf top -d1 shows ~25%  before ali_work_queue.patch,after appending
> this patch ,
> the synchronous operation consumption from __kmalloc and kfree is
> reduced from 25% to ~15% on Intel E5-2699V3
> (we also observed the output from user space code (thread.c) is
> improved clearly)
>
> Peter, we will send the update version according to your comments.
>
> Thanks
> Ling
>
>
> 2016-01-19 23:36 GMT+08:00 Waiman Long :
>> On 01/19/2016 03:52 AM, Ling Ma wrote:
>>>
>>> Is it acceptable for performance improvement or more comments on this
>>> patch?
>>>
>>> Thanks
>>> Ling
>>>
>>>
>>
>> Your alispinlock patchset should also include a use case where the lock is
>> used by some code within the kernel with test that can show a performance
>> improvement so that the reviewers can independently try it out and play
>> around with it. The kernel community will not accept any patch without a use
>> case in the kernel.
>>
>> Your lock_test.tar file is not good enough as it is not a performance test
>> of the patch that you sent out.
>>
>> Cheers,
>> Longman
/**
	Test Case:
		OpenDir, Get status and close it.
*/
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define TEST_DIR "/tmp/thread"
#define MAX_TEST_THREAD (80)
#define MAX_TEST_FILE 5000

static unsigned long *result[MAX_TEST_THREAD];
static int stop = 0;

static void* case_function(void *para)
{
	int id = (int)(long)para;
	DIR *pDir;
	struct stat f_stat;
	struct dirent *entry=NULL;
	char path[256];
	char cmd[512];
	
	int filecnt   = 0;
	int dircnt= 0;
	int filetotalsize = 0;
	unsigned long myresult = 0;
	int f = 0;
	
	result[id] = 

	/* Goto my path and construct empty file */
	sprintf(path, "%s/%d", TEST_DIR, id);
	printf("Creating temp file at %s\n", path);

	sprintf(cmd, "mkdir %s", path);
	system(cmd);
	chdir(path);
	for (f = 0; f < MAX_TEST_FILE; f++)
	{
		char name[256];

		sprintf(name, "%s/%d", path, f);
		int t = open(name,  O_RDWR | O_CREAT | O_TRUNC, S_IRWXU);
		if (t != -1)
			close(t);
		else
		{
			printf("Errno = %d.\n", errno);
			exit(errno);
		}		
	}

again:
	if ((pDir = opendir(path)) == NULL)
	{
		printf("打开 %s 错误:没有那个文件或目录\n", TEST_DIR);
		goto err;
	}
	
	while ((entry = readdir(pDir)) != NULL)
	{
		struct stat buf;
		if (entry->d_name[0] == '.')
			continue;
		
		//f = open(entry->d_name, 0);
		f = stat(entry->d_name, );
		
		if (f)
			close(f);
		myresult++;
		
		
		//printf("Filename %s, size %10d",entry->d_name, f_stat.st_size);
	}

	closedir(pDir);
	

	/* Need to stop */
	if (!stop)
		goto again;
	return 0;

err:
	;
}

void main()
{
	int i;
	pthread_t thread;

	system("mkdir "TEST_DIR);
		
	for (i = 0; i < MAX_TEST_THREAD; i++)
	{
		pthread_create(, NULL, case_function, (void*)(long)i);
	}

	while (1)
	{
		sleep(1);
		unsigned long times = 0;
		//printf("Statistics:\n");

		for (i = 0; i < MAX_TEST_THREAD; i++)
		{
			//printf("%d\t", *result[i]);
			times =times +  *result[i];
		}
		printf("%ld\t\n", times);
		for (i = 0; i < MAX_TEST_THREAD; i++)
			*result[i] = 0;
	}
}


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

2016-02-02 Thread Sudip Mukherjee
On Wed, Feb 03, 2016 at 04:10:30PM +1100, Stephen Rothwell wrote:
> Hi Andrew,
> 
> After merging the akpm-current tree, today's linux-next build (i386
> defconfig) failed like this:
> 
> In file included from include/linux/mm.h:67:0,
>  from include/linux/suspend.h:8,
>  from arch/x86/kernel/asm-offsets.c:12:
> arch/x86/include/asm/pgtable.h:212:24: error: redefinition of 'pud_trans_huge'
>  #define pud_trans_huge pud_trans_huge
> ^
> include/asm-generic/pgtable.h:696:19: note: in expansion of macro 
> 'pud_trans_huge'
>  static inline int pud_trans_huge(pud_t pud)
>^
> arch/x86/include/asm/pgtable.h:208:19: note: previous definition of 
> 'pud_trans_huge' was here
>  static inline int pud_trans_huge(pud_t pud)
>^
> 
> Caused by commit
> 
>   42416e8d1a10 ("x86-add-support-for-pud-sized-transparent-hugepages-fix")
> 
> Which, it turns out, is "wrong/hacky" :-)
> 
> I have reverted that patch for today and added this (also maybe
> wrong/hacky) patch:

And x86_64 defconfig also fails with:
../fs/proc/task_mmu.c: In function ‘smaps_pud_range’:
../fs/proc/task_mmu.c:596:2: error: implicit declaration of function
‘is_huge_zero_pud’ [-Werror=implicit-function-declaration]

regards
sudip


Re: [PATCH 4/5] cpufreq: Don't drop rwsem before calling CPUFREQ_GOV_POLICY_EXIT

2016-02-02 Thread Viresh Kumar
On 02-02-16, 22:53, Rafael J. Wysocki wrote:
> First of all, this is effectively reverting commit 955ef4833574, so
> the subject should be "Revert commit 955ef4833574 (cpufreq: Drop rwsem
> lock around CPUFREQ_GOV_POLICY_EXIT)".
> 
> There should be a Fixes: tag pointing to commit 955ef4833574 and a
> Reported-by: for Juri.
> 
> If there is a link to a bug report related to this, it should be
> pointed to by a Link: tag.
> 
> The changelog should say why the original commit was there and why the
> way it attempted to solve the problem was incorrect.  It also should
> say that the original problem was addressed by a previous commit, so
> this one can be reverted without consequences.

How about this:

Revert "cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT"

Earlier, when the struct freq-attr was used to represent governor
attributes, the standard cpufreq show/store sysfs attribute callbacks
were applied to the governor tunable attributes and they always acquire
the policy->rwsem lock before carrying out the operation.  That could
have resulted in an ABBA deadlock if governor tunable attributes are
removed under policy->rwsem while one of them is being accessed
concurrently (if sysfs attributes removal wins the race, it will wait
for the access to complete with policy->rwsem held while the attribute
callback will block on policy->rwsem indefinitely).

We attempted to address this issue by dropping policy->rwsem around
governor tunable attributes removal (that is, around invocations of the
->governor callback with the event arg equal to CPUFREQ_GOV_POLICY_EXIT)
in cpufreq_set_policy(), but that opened up race conditions that had not
been possible with policy->rwsem held all the time.

The previous commit, "cpufreq: governor: New sysfs show/store callbacks
for governor tunables", fixed the original ABBA deadlock by adding new
governor specific show/store callbacks.

We don't have to drop rwsem around invocations of governor event
CPUFREQ_GOV_POLICY_EXIT anymore, and original fix can be reverted now.

Fixes: 955ef4833574 ("cpufreq: Drop rwsem lock around 
CPUFREQ_GOV_POLICY_EXIT")
Reported-by: Juri Lelli 
Signed-off-by: Viresh Kumar 

> But I'm not going to write that changelog.  I actually am not going to
> write any changelogs for you any more, because I'm seriously tired of
> doing that.  Moreover, if I see a patch from you with a changelog
> that's not acceptable to me, it will immediately go to the "not
> applicable" trash bin no matter what the changes below look like.  You
> *have* *to* write useful changelogs.  This isn't optional or best
> effort.  This is mandatory and important.

Will try to improve, sorry about that (again).

> Now, I'm not really sure if the ordering of this patchset is right.
> Maybe we should just revert upfront with the "we'll address the
> original problem in the following commits" statement in the changelog
> and fix it in a different way?

Wouldn't that break things like 'git bisect'? People running kernels
after the reverted commits may start hitting lockdeps.

> It looks like patches [1-3/5] fix a
> problem that isn't there even, but would appear after the [4/5] if
> they were not applied previously, which doesn't sound really
> straightforward to me.

I am going to fight hard for it, if you feel 4/5 should be the first
patch here, I will do that.

-- 
viresh


Re: [PATCH] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread kbuild test robot
Hi Hari,

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.5-rc2 next-20160202]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Gujulan-Elango-Hari-Prasath-H/staging-android-ion-use-the-manged-version-of-DMA-memory-allocation/20160203-132744
config: x86_64-randconfig-x009-201605 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/staging/android/ion/ion_cma_heap.c: In function 'ion_cma_free':
>> drivers/staging/android/ion/ion_cma_heap.c:94:17: warning: unused variable 
>> 'dev' [-Wunused-variable]
 struct device *dev = cma_heap->dev;
^

vim +/dev +94 drivers/staging/android/ion/ion_cma_heap.c

349c9e13 Benjamin Gaignard 2013-12-13   78  goto free_table;
349c9e13 Benjamin Gaignard 2013-12-13   79  /* keep this for memory release 
*/
349c9e13 Benjamin Gaignard 2013-12-13   80  buffer->priv_virt = info;
349c9e13 Benjamin Gaignard 2013-12-13   81  dev_dbg(dev, "Allocate buffer 
%p\n", buffer);
349c9e13 Benjamin Gaignard 2013-12-13   82  return 0;
349c9e13 Benjamin Gaignard 2013-12-13   83  
349c9e13 Benjamin Gaignard 2013-12-13   84  free_table:
349c9e13 Benjamin Gaignard 2013-12-13   85  kfree(info->table);
349c9e13 Benjamin Gaignard 2013-12-13   86  err:
349c9e13 Benjamin Gaignard 2013-12-13   87  kfree(info);
349c9e13 Benjamin Gaignard 2013-12-13   88  return ION_CMA_ALLOCATE_FAILED;
349c9e13 Benjamin Gaignard 2013-12-13   89  }
349c9e13 Benjamin Gaignard 2013-12-13   90  
349c9e13 Benjamin Gaignard 2013-12-13   91  static void ion_cma_free(struct 
ion_buffer *buffer)
349c9e13 Benjamin Gaignard 2013-12-13   92  {
349c9e13 Benjamin Gaignard 2013-12-13   93  struct ion_cma_heap *cma_heap = 
to_cma_heap(buffer->heap);
349c9e13 Benjamin Gaignard 2013-12-13  @94  struct device *dev = 
cma_heap->dev;
349c9e13 Benjamin Gaignard 2013-12-13   95  struct ion_cma_buffer_info 
*info = buffer->priv_virt;
349c9e13 Benjamin Gaignard 2013-12-13   96  
349c9e13 Benjamin Gaignard 2013-12-13   97  /* release sg table */
349c9e13 Benjamin Gaignard 2013-12-13   98  sg_free_table(info->table);
349c9e13 Benjamin Gaignard 2013-12-13   99  kfree(info->table);
349c9e13 Benjamin Gaignard 2013-12-13  100  kfree(info);
349c9e13 Benjamin Gaignard 2013-12-13  101  }
349c9e13 Benjamin Gaignard 2013-12-13  102  

:: The code at line 94 was first introduced by commit
:: 349c9e13855109df99c5205a4e8d53d9fa169490 gpu: ion: add CMA heap

:: TO: Benjamin Gaignard 
:: CC: Greg Kroah-Hartman 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v7 4/9] vring: Introduce vring_use_dma_api()

2016-02-02 Thread Andy Lutomirski
This is a kludge, but no one has come up with a a better idea yet.
We'll introduce DMA API support guarded by vring_use_dma_api().
Eventually we may be able to return true on more and more systems,
and hopefully we can get rid of vring_use_dma_api() entirely some
day.

Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/virtio_ring.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index e12e385f7ac3..ab0be6c084f6 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -104,6 +104,30 @@ struct vring_virtqueue {
 
 #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
 
+/*
+ * The interaction between virtio and a possible IOMMU is a mess.
+ *
+ * On most systems with virtio, physical addresses match bus addresses,
+ * and it doesn't particularly matter whether we use the DMA API.
+ *
+ * On some systems, including Xen and any system with a physical device
+ * that speaks virtio behind a physical IOMMU, we must use the DMA API
+ * for virtio DMA to work at all.
+ *
+ * On other systems, including SPARC and PPC64, virtio-pci devices are
+ * enumerated as though they are behind an IOMMU, but the virtio host
+ * ignores the IOMMU, so we must either pretend that the IOMMU isn't
+ * there or somehow map everything as the identity.
+ *
+ * For the time being, we preserve historic behavior and bypass the DMA
+ * API.
+ */
+
+static bool vring_use_dma_api(struct virtio_device *vdev)
+{
+   return false;
+}
+
 static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
 unsigned int total_sg, gfp_t gfp)
 {
-- 
2.5.0



[PATCH v7 1/9] dma: Provide simple noop dma ops

2016-02-02 Thread Andy Lutomirski
From: Christian Borntraeger 

We are going to require dma_ops for several common drivers, even for
systems that do have an identity mapping. Lets provide some minimal
no-op dma_ops that can be used for that purpose.

Signed-off-by: Christian Borntraeger 
Reviewed-by: Joerg Roedel 
Signed-off-by: Andy Lutomirski 
---
 include/linux/dma-mapping.h |  2 ++
 lib/Makefile|  1 +
 lib/dma-noop.c  | 75 +
 3 files changed, 78 insertions(+)
 create mode 100644 lib/dma-noop.c

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 75857cda38e9..c0b27ff2c784 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -70,6 +70,8 @@ struct dma_map_ops {
int is_phys;
 };
 
+extern struct dma_map_ops dma_noop_ops;
+
 #define DMA_BIT_MASK(n)(((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
 
 #define DMA_MASK_NONE  0x0ULL
diff --git a/lib/Makefile b/lib/Makefile
index a7c26a41a738..a572b86a1b1d 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -18,6 +18,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
 obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o
 lib-$(CONFIG_MMU) += ioremap.o
 lib-$(CONFIG_SMP) += cpumask.o
+lib-$(CONFIG_HAS_DMA) += dma-noop.o
 
 lib-y  += kobject.o klist.o
 obj-y  += lockref.o
diff --git a/lib/dma-noop.c b/lib/dma-noop.c
new file mode 100644
index ..72145646857e
--- /dev/null
+++ b/lib/dma-noop.c
@@ -0,0 +1,75 @@
+/*
+ * lib/dma-noop.c
+ *
+ * Simple DMA noop-ops that map 1:1 with memory
+ */
+#include 
+#include 
+#include 
+#include 
+
+static void *dma_noop_alloc(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t gfp,
+   struct dma_attrs *attrs)
+{
+   void *ret;
+
+   ret = (void *)__get_free_pages(gfp, get_order(size));
+   if (ret)
+   *dma_handle = virt_to_phys(ret);
+   return ret;
+}
+
+static void dma_noop_free(struct device *dev, size_t size,
+ void *cpu_addr, dma_addr_t dma_addr,
+ struct dma_attrs *attrs)
+{
+   free_pages((unsigned long)cpu_addr, get_order(size));
+}
+
+static dma_addr_t dma_noop_map_page(struct device *dev, struct page *page,
+ unsigned long offset, size_t size,
+ enum dma_data_direction dir,
+ struct dma_attrs *attrs)
+{
+   return page_to_phys(page) + offset;
+}
+
+static int dma_noop_map_sg(struct device *dev, struct scatterlist *sgl, int 
nents,
+enum dma_data_direction dir, struct dma_attrs 
*attrs)
+{
+   int i;
+   struct scatterlist *sg;
+
+   for_each_sg(sgl, sg, nents, i) {
+   void *va;
+
+   BUG_ON(!sg_page(sg));
+   va = sg_virt(sg);
+   sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va);
+   sg_dma_len(sg) = sg->length;
+   }
+
+   return nents;
+}
+
+static int dma_noop_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+   return 0;
+}
+
+static int dma_noop_supported(struct device *dev, u64 mask)
+{
+   return 1;
+}
+
+struct dma_map_ops dma_noop_ops = {
+   .alloc  = dma_noop_alloc,
+   .free   = dma_noop_free,
+   .map_page   = dma_noop_map_page,
+   .map_sg = dma_noop_map_sg,
+   .mapping_error  = dma_noop_mapping_error,
+   .dma_supported  = dma_noop_supported,
+};
+
+EXPORT_SYMBOL(dma_noop_ops);
-- 
2.5.0



[PATCH v7 0/9] virtio DMA API, yet again

2016-02-02 Thread Andy Lutomirski
This switches virtio to use the DMA API on Xen and if requested by
module option.

This fixes virtio on Xen, and it should break anything because it's
off by default on everything except Xen PV on x86.

To the Xen people: is this okay?  If it doesn't work on other Xen
variants (PVH? HVM?), can you submit follow-up patches to fix it?

To everyone else: we've waffled on this for way too long.  I think
we should to get DMA API implementation in with a conservative
policy like this rather than waiting until we achieve perfection.
I'm tired of carrying these patches around.

I changed queue allocation around a bit in this version.  Per Michael's
request, we no longer use dma_zalloc_coherent in the !dma_api case.
Instead we use alloc_pages_exact, just like the current code does.
This simplifies the ring address accessors, because they can always
load from the dma addr rather than depending on vring_use_dma_api
themselves.

There's an odd warning in here if the ring's physical address
doesn't fit in a dma_addr_t.  This could only possible happen on
really weird configurations in which phys_addr_t is wider than
dma_addr_t.  AFAICT this is only possible on i386 PAE systems and on
MIPS, and even there it only happens if highmem is off.  But that
means we're safe, since we should never end up with high allocations
on non-highmem systems unless we explicitly ask for them, which we
don't.

If this is too scary, I can add yet more cruft to avoid it, but
it seems harmless enough to me, and it means that the driver will
be totally clean once all the vring_use_dma_api calls go away.

Michael, if these survive review, can you stage these in your tree?
Can you also take a look at tools/virtio?  I probably broke it, but I
couldn't get it to build without these patches either, so I'm stuck.

Changes from v6:
 - Remove HAVE_DMA_ATTRS and add Acked-by (Cornelia)
 - Add some missing signed-off-by lines from me (whoops)
 - Rework queue allocation (Michael)

Changes from v5:
 - Typo fixes (David Woodhouse)
 - Use xen_domain() to detect Xen (David Vrabel)
 - Pass struct vring_virtqueue * into vring_use_dma_api for future proofing
 - Removed module parameter (Michael)

Changes from v4:
 - Bake vring_use_dma_api in from the beginning.
 - Automatically enable only on Xen.
 - Add module parameter.
 - Add s390 and alpha DMA API implementations.
 - Rebase to 4.5-rc1.

Changes from v3:
 - More big-endian fixes.
 - Added better virtio-ring APIs that handle allocation and use them in
   virtio-mmio and virtio-pci.
 - Switch to Michael's virtio-net patch.

Changes from v2:
 - Fix vring_mapping_error incorrect argument

Changes from v1:
 - Fix an endian conversion error causing a BUG to hit.
 - Fix a DMA ordering issue (swiotlb=force works now).
 - Minor cleanups.

Andy Lutomirski (6):
  vring: Introduce vring_use_dma_api()
  virtio_ring: Support DMA APIs
  virtio: Add improved queue allocation API
  virtio_mmio: Use the DMA API if enabled
  virtio_pci: Use the DMA API if enabled
  vring: Use the DMA API on Xen

Christian Borntraeger (3):
  dma: Provide simple noop dma ops
  alpha/dma: use common noop dma ops
  s390/dma: Allow per device dma ops

 arch/alpha/kernel/pci-noop.c|  46 +---
 arch/s390/Kconfig   |   5 +-
 arch/s390/include/asm/device.h  |   6 +-
 arch/s390/include/asm/dma-mapping.h |   6 +-
 arch/s390/pci/pci.c |   1 +
 arch/s390/pci/pci_dma.c |   4 +-
 drivers/virtio/Kconfig  |   2 +-
 drivers/virtio/virtio_mmio.c|  67 ++
 drivers/virtio/virtio_pci_common.h  |   6 -
 drivers/virtio/virtio_pci_legacy.c  |  42 ++--
 drivers/virtio/virtio_pci_modern.c  |  61 ++---
 drivers/virtio/virtio_ring.c| 439 +++-
 include/linux/dma-mapping.h |   2 +
 include/linux/virtio.h  |  23 +-
 include/linux/virtio_ring.h |  35 +++
 lib/Makefile|   1 +
 lib/dma-noop.c  |  75 ++
 tools/virtio/linux/dma-mapping.h|  17 ++
 18 files changed, 594 insertions(+), 244 deletions(-)
 create mode 100644 lib/dma-noop.c
 create mode 100644 tools/virtio/linux/dma-mapping.h

-- 
2.5.0



[PATCH v7 5/9] virtio_ring: Support DMA APIs

2016-02-02 Thread Andy Lutomirski
virtio_ring currently sends the device (usually a hypervisor)
physical addresses of its I/O buffers.  This is okay when DMA
addresses and physical addresses are the same thing, but this isn't
always the case.  For example, this never works on Xen guests, and
it is likely to fail if a physical "virtio" device ever ends up
behind an IOMMU or swiotlb.

The immediate use case for me is to enable virtio on Xen guests.
For that to work, we need vring to support DMA address translation
as well as a corresponding change to virtio_pci or to another
driver.

Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/Kconfig   |   2 +-
 drivers/virtio/virtio_ring.c | 200 ---
 tools/virtio/linux/dma-mapping.h |  17 
 3 files changed, 183 insertions(+), 36 deletions(-)
 create mode 100644 tools/virtio/linux/dma-mapping.h

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index cab9f3f63a38..77590320d44c 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -60,7 +60,7 @@ config VIRTIO_INPUT
 
  config VIRTIO_MMIO
tristate "Platform bus driver for memory mapped virtio devices"
-   depends on HAS_IOMEM
+   depends on HAS_IOMEM && HAS_DMA
select VIRTIO
---help---
 This drivers provides support for memory mapped virtio
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index ab0be6c084f6..9abc008ff7ea 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef DEBUG
 /* For development, we want to crash whenever the ring is screwed. */
@@ -54,6 +55,11 @@
 #define END_USE(vq)
 #endif
 
+struct vring_desc_state {
+   void *data; /* Data for callback. */
+   struct vring_desc *indir_desc;  /* Indirect descriptor, if any. */
+};
+
 struct vring_virtqueue {
struct virtqueue vq;
 
@@ -98,8 +104,8 @@ struct vring_virtqueue {
ktime_t last_add_time;
 #endif
 
-   /* Tokens for callbacks. */
-   void *data[];
+   /* Per-descriptor state. */
+   struct vring_desc_state desc_state[];
 };
 
 #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
@@ -128,6 +134,79 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
return false;
 }
 
+/*
+ * The DMA ops on various arches are rather gnarly right now, and
+ * making all of the arch DMA ops work on the vring device itself
+ * is a mess.  For now, we use the parent device for DMA ops.
+ */
+struct device *vring_dma_dev(const struct vring_virtqueue *vq)
+{
+   return vq->vq.vdev->dev.parent;
+}
+
+/* Map one sg entry. */
+static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq,
+  struct scatterlist *sg,
+  enum dma_data_direction direction)
+{
+   if (!vring_use_dma_api(vq->vq.vdev))
+   return (dma_addr_t)sg_phys(sg);
+
+   /*
+* We can't use dma_map_sg, because we don't use scatterlists in
+* the way it expects (we don't guarantee that the scatterlist
+* will exist for the lifetime of the mapping).
+*/
+   return dma_map_page(vring_dma_dev(vq),
+   sg_page(sg), sg->offset, sg->length,
+   direction);
+}
+
+static dma_addr_t vring_map_single(const struct vring_virtqueue *vq,
+  void *cpu_addr, size_t size,
+  enum dma_data_direction direction)
+{
+   if (!vring_use_dma_api(vq->vq.vdev))
+   return (dma_addr_t)virt_to_phys(cpu_addr);
+
+   return dma_map_single(vring_dma_dev(vq),
+ cpu_addr, size, direction);
+}
+
+static void vring_unmap_one(const struct vring_virtqueue *vq,
+   struct vring_desc *desc)
+{
+   u16 flags;
+
+   if (!vring_use_dma_api(vq->vq.vdev))
+   return;
+
+   flags = virtio16_to_cpu(vq->vq.vdev, desc->flags);
+
+   if (flags & VRING_DESC_F_INDIRECT) {
+   dma_unmap_single(vring_dma_dev(vq),
+virtio64_to_cpu(vq->vq.vdev, desc->addr),
+virtio32_to_cpu(vq->vq.vdev, desc->len),
+(flags & VRING_DESC_F_WRITE) ?
+DMA_FROM_DEVICE : DMA_TO_DEVICE);
+   } else {
+   dma_unmap_page(vring_dma_dev(vq),
+  virtio64_to_cpu(vq->vq.vdev, desc->addr),
+  virtio32_to_cpu(vq->vq.vdev, desc->len),
+  (flags & VRING_DESC_F_WRITE) ?
+  DMA_FROM_DEVICE : DMA_TO_DEVICE);
+   }
+}
+
+static int vring_mapping_error(const struct vring_virtqueue *vq,
+  dma_addr_t addr)
+{
+   if (!vring_use_dma_api(vq->vq.vdev))
+   return 0;
+
+   

[PATCH v7 3/9] s390/dma: Allow per device dma ops

2016-02-02 Thread Andy Lutomirski
From: Christian Borntraeger 

As virtio-ccw will have dma ops, we can no longer default to the
zPCI ones. Make use of dev_archdata to keep the dma_ops per device.
The pci devices now use that to override the default, and the
default is changed to use the noop ops for everything that does not
specify a device specific one.
To compile without PCI support we will enable HAS_DMA all the time,
via the default config in lib/Kconfig.

Signed-off-by: Christian Borntraeger 
Reviewed-by: Joerg Roedel 
Acked-by: Cornelia Huck 
Acked-by: Sebastian Ott 
Signed-off-by: Andy Lutomirski 
---
 arch/s390/Kconfig   | 5 +
 arch/s390/include/asm/device.h  | 6 +-
 arch/s390/include/asm/dma-mapping.h | 6 --
 arch/s390/pci/pci.c | 1 +
 arch/s390/pci/pci_dma.c | 4 ++--
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 3be9c832dec1..b29c66e77e32 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -124,6 +124,7 @@ config S390
select HAVE_CMPXCHG_DOUBLE
select HAVE_CMPXCHG_LOCAL
select HAVE_DEBUG_KMEMLEAK
+   select HAVE_DMA_API_DEBUG
select HAVE_DYNAMIC_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_REGS
select HAVE_FTRACE_MCOUNT_RECORD
@@ -619,10 +620,6 @@ config HAS_IOMEM
 config IOMMU_HELPER
def_bool PCI
 
-config HAS_DMA
-   def_bool PCI
-   select HAVE_DMA_API_DEBUG
-
 config NEED_SG_DMA_LENGTH
def_bool PCI
 
diff --git a/arch/s390/include/asm/device.h b/arch/s390/include/asm/device.h
index d8f9872b0e2d..4a9f35e0973f 100644
--- a/arch/s390/include/asm/device.h
+++ b/arch/s390/include/asm/device.h
@@ -3,5 +3,9 @@
  *
  * This file is released under the GPLv2
  */
-#include 
+struct dev_archdata {
+   struct dma_map_ops *dma_ops;
+};
 
+struct pdev_archdata {
+};
diff --git a/arch/s390/include/asm/dma-mapping.h 
b/arch/s390/include/asm/dma-mapping.h
index e64bfcb9702f..3249b7464889 100644
--- a/arch/s390/include/asm/dma-mapping.h
+++ b/arch/s390/include/asm/dma-mapping.h
@@ -11,11 +11,13 @@
 
 #define DMA_ERROR_CODE (~(dma_addr_t) 0x0)
 
-extern struct dma_map_ops s390_dma_ops;
+extern struct dma_map_ops s390_pci_dma_ops;
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 {
-   return _dma_ops;
+   if (dev && dev->archdata.dma_ops)
+   return dev->archdata.dma_ops;
+   return _noop_ops;
 }
 
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 11d4f277e9f6..f5931135b9ae 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -649,6 +649,7 @@ int pcibios_add_device(struct pci_dev *pdev)
 
zdev->pdev = pdev;
pdev->dev.groups = zpci_attr_groups;
+   pdev->dev.archdata.dma_ops = _pci_dma_ops;
zpci_map_resources(pdev);
 
for (i = 0; i < PCI_BAR_COUNT; i++) {
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 4638b93c7632..a79173ec54b9 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -544,7 +544,7 @@ static int __init dma_debug_do_init(void)
 }
 fs_initcall(dma_debug_do_init);
 
-struct dma_map_ops s390_dma_ops = {
+struct dma_map_ops s390_pci_dma_ops = {
.alloc  = s390_dma_alloc,
.free   = s390_dma_free,
.map_sg = s390_dma_map_sg,
@@ -555,7 +555,7 @@ struct dma_map_ops s390_dma_ops = {
.is_phys= 0,
/* dma_supported is unconditionally true without a callback */
 };
-EXPORT_SYMBOL_GPL(s390_dma_ops);
+EXPORT_SYMBOL_GPL(s390_pci_dma_ops);
 
 static int __init s390_iommu_setup(char *str)
 {
-- 
2.5.0



[PATCH v7 7/9] virtio_mmio: Use the DMA API if enabled

2016-02-02 Thread Andy Lutomirski
This switches to vring_create_virtqueue, simplifying the driver and
adding DMA API support.

Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/virtio_mmio.c | 67 ++--
 1 file changed, 15 insertions(+), 52 deletions(-)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 745c6ee1bb3e..48bfea91dbca 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -99,12 +99,6 @@ struct virtio_mmio_vq_info {
/* the actual virtqueue */
struct virtqueue *vq;
 
-   /* the number of entries in the queue */
-   unsigned int num;
-
-   /* the virtual address of the ring queue */
-   void *queue;
-
/* the list node for the virtqueues list */
struct list_head node;
 };
@@ -322,15 +316,13 @@ static void vm_del_vq(struct virtqueue *vq)
 {
struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
struct virtio_mmio_vq_info *info = vq->priv;
-   unsigned long flags, size;
+   unsigned long flags;
unsigned int index = vq->index;
 
spin_lock_irqsave(_dev->lock, flags);
list_del(>node);
spin_unlock_irqrestore(_dev->lock, flags);
 
-   vring_del_virtqueue(vq);
-
/* Select and deactivate the queue */
writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
if (vm_dev->version == 1) {
@@ -340,8 +332,8 @@ static void vm_del_vq(struct virtqueue *vq)
WARN_ON(readl(vm_dev->base + VIRTIO_MMIO_QUEUE_READY));
}
 
-   size = PAGE_ALIGN(vring_size(info->num, VIRTIO_MMIO_VRING_ALIGN));
-   free_pages_exact(info->queue, size);
+   vring_del_virtqueue(vq);
+
kfree(info);
 }
 
@@ -356,8 +348,6 @@ static void vm_del_vqs(struct virtio_device *vdev)
free_irq(platform_get_irq(vm_dev->pdev, 0), vm_dev);
 }
 
-
-
 static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned 
index,
  void (*callback)(struct virtqueue *vq),
  const char *name)
@@ -365,7 +355,8 @@ static struct virtqueue *vm_setup_vq(struct virtio_device 
*vdev, unsigned index,
struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
struct virtio_mmio_vq_info *info;
struct virtqueue *vq;
-   unsigned long flags, size;
+   unsigned long flags;
+   unsigned int num;
int err;
 
if (!name)
@@ -388,66 +379,40 @@ static struct virtqueue *vm_setup_vq(struct virtio_device 
*vdev, unsigned index,
goto error_kmalloc;
}
 
-   /* Allocate pages for the queue - start with a queue as big as
-* possible (limited by maximum size allowed by device), drop down
-* to a minimal size, just big enough to fit descriptor table
-* and two rings (which makes it "alignment_size * 2")
-*/
-   info->num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
-
-   /* If the device reports a 0 entry queue, we won't be able to
-* use it to perform I/O, and vring_new_virtqueue() can't create
-* empty queues anyway, so don't bother to set up the device.
-*/
-   if (info->num == 0) {
+   num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
+   if (num == 0) {
err = -ENOENT;
-   goto error_alloc_pages;
-   }
-
-   while (1) {
-   size = PAGE_ALIGN(vring_size(info->num,
-   VIRTIO_MMIO_VRING_ALIGN));
-   /* Did the last iter shrink the queue below minimum size? */
-   if (size < VIRTIO_MMIO_VRING_ALIGN * 2) {
-   err = -ENOMEM;
-   goto error_alloc_pages;
-   }
-
-   info->queue = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
-   if (info->queue)
-   break;
-
-   info->num /= 2;
+   goto error_new_virtqueue;
}
 
/* Create the vring */
-   vq = vring_new_virtqueue(index, info->num, VIRTIO_MMIO_VRING_ALIGN, 
vdev,
-true, info->queue, vm_notify, callback, name);
+   vq = vring_create_virtqueue(index, num, VIRTIO_MMIO_VRING_ALIGN, vdev,
+true, true, vm_notify, callback, name);
if (!vq) {
err = -ENOMEM;
goto error_new_virtqueue;
}
 
/* Activate the queue */
-   writel(info->num, vm_dev->base + VIRTIO_MMIO_QUEUE_NUM);
+   writel(virtqueue_get_vring_size(vq), vm_dev->base + 
VIRTIO_MMIO_QUEUE_NUM);
if (vm_dev->version == 1) {
writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_QUEUE_ALIGN);
-   writel(virt_to_phys(info->queue) >> PAGE_SHIFT,
+   writel(virtqueue_get_desc_addr(vq) >> PAGE_SHIFT,
vm_dev->base + VIRTIO_MMIO_QUEUE_PFN);
} else {
u64 addr;
 
- 

[PATCH v7 6/9] virtio: Add improved queue allocation API

2016-02-02 Thread Andy Lutomirski
This leaves vring_new_virtqueue alone for compatbility, but it
adds two new improved APIs:

vring_create_virtqueue: Creates a virtqueue backed by automatically
allocated coherent memory.  (Some day it this could be extended to
support non-coherent memory, too, if there ends up being a platform
on which it's worthwhile.)

__vring_new_virtqueue: Creates a virtqueue with a manually-specified
layout.  This should allow mic_virtio to work much more cleanly.

Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/virtio_ring.c | 209 ---
 include/linux/virtio.h   |  23 -
 include/linux/virtio_ring.h  |  35 
 3 files changed, 235 insertions(+), 32 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 9abc008ff7ea..e46d08107a50 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -95,6 +95,11 @@ struct vring_virtqueue {
/* How to notify other side. FIXME: commonalize hcalls! */
bool (*notify)(struct virtqueue *vq);
 
+   /* DMA, allocation, and size information */
+   bool we_own_ring;
+   size_t queue_size_in_bytes;
+   dma_addr_t queue_dma_addr;
+
 #ifdef DEBUG
/* They're supposed to lock for us. */
unsigned int in_use;
@@ -878,36 +883,31 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
 }
 EXPORT_SYMBOL_GPL(vring_interrupt);
 
-struct virtqueue *vring_new_virtqueue(unsigned int index,
- unsigned int num,
- unsigned int vring_align,
- struct virtio_device *vdev,
- bool weak_barriers,
- void *pages,
- bool (*notify)(struct virtqueue *),
- void (*callback)(struct virtqueue *),
- const char *name)
+struct virtqueue *__vring_new_virtqueue(unsigned int index,
+   struct vring vring,
+   struct virtio_device *vdev,
+   bool weak_barriers,
+   bool (*notify)(struct virtqueue *),
+   void (*callback)(struct virtqueue *),
+   const char *name)
 {
-   struct vring_virtqueue *vq;
unsigned int i;
+   struct vring_virtqueue *vq;
 
-   /* We assume num is a power of 2. */
-   if (num & (num - 1)) {
-   dev_warn(>dev, "Bad virtqueue length %u\n", num);
-   return NULL;
-   }
-
-   vq = kmalloc(sizeof(*vq) + num * sizeof(struct vring_desc_state),
+   vq = kmalloc(sizeof(*vq) + vring.num * sizeof(struct vring_desc_state),
 GFP_KERNEL);
if (!vq)
return NULL;
 
-   vring_init(>vring, num, pages, vring_align);
+   vq->vring = vring;
vq->vq.callback = callback;
vq->vq.vdev = vdev;
vq->vq.name = name;
-   vq->vq.num_free = num;
+   vq->vq.num_free = vring.num;
vq->vq.index = index;
+   vq->we_own_ring = false;
+   vq->queue_dma_addr = 0;
+   vq->queue_size_in_bytes = 0;
vq->notify = notify;
vq->weak_barriers = weak_barriers;
vq->broken = false;
@@ -932,18 +932,145 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
 
/* Put everything in free lists. */
vq->free_head = 0;
-   for (i = 0; i < num-1; i++)
+   for (i = 0; i < vring.num-1; i++)
vq->vring.desc[i].next = cpu_to_virtio16(vdev, i + 1);
-   memset(vq->desc_state, 0, num * sizeof(struct vring_desc_state));
+   memset(vq->desc_state, 0, vring.num * sizeof(struct vring_desc_state));
 
return >vq;
 }
+EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
+
+static void *vring_alloc_queue(struct virtio_device *vdev, size_t size,
+ dma_addr_t *dma_handle, gfp_t flag)
+{
+   if (vring_use_dma_api(vdev)) {
+   return dma_alloc_coherent(vdev->dev.parent, size,
+ dma_handle, flag);
+   } else {
+   void *queue = alloc_pages_exact(PAGE_ALIGN(size), flag);
+   if (queue) {
+   phys_addr_t phys_addr = virt_to_phys(queue);
+   *dma_handle = (dma_addr_t)phys_addr;
+
+   /*
+* Sanity check: make sure we dind't truncate
+* the address.  The only arches I can find that
+* have 64-bit phys_addr_t but 32-bit dma_addr_t
+* are certain non-highmem MIPS and x86
+* configurations, but these configurations
+* should never allocate physical pages above 32
+* bits, so this 

[PATCH v7 9/9] vring: Use the DMA API on Xen

2016-02-02 Thread Andy Lutomirski
Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/virtio_ring.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index e46d08107a50..5c802d47892c 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef DEBUG
 /* For development, we want to crash whenever the ring is screwed. */
@@ -136,6 +137,17 @@ struct vring_virtqueue {
 
 static bool vring_use_dma_api(struct virtio_device *vdev)
 {
+   /*
+* In theory, it's possible to have a buggy QEMU-supposed
+* emulated Q35 IOMMU and Xen enabled at the same time.  On
+* such a configuration, virtio has never worked and will
+* not work without an even larger kludge.  Instead, enable
+* the DMA API if we're a Xen guest, which at least allows
+* all of the sensible Xen configurations to work correctly.
+*/
+   if (xen_domain())
+   return true;
+
return false;
 }
 
-- 
2.5.0



[PATCH v7 2/9] alpha/dma: use common noop dma ops

2016-02-02 Thread Andy Lutomirski
From: Christian Borntraeger 

Some of the alpha pci noop dma ops are identical to the common ones.
Use them.

Signed-off-by: Christian Borntraeger 
Reviewed-by: Joerg Roedel 
Signed-off-by: Andy Lutomirski 
---
 arch/alpha/kernel/pci-noop.c | 46 
 1 file changed, 4 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 2b1f4a1e9272..8e735b5e56bd 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -123,44 +123,6 @@ static void *alpha_noop_alloc_coherent(struct device *dev, 
size_t size,
return ret;
 }
 
-static void alpha_noop_free_coherent(struct device *dev, size_t size,
-void *cpu_addr, dma_addr_t dma_addr,
-struct dma_attrs *attrs)
-{
-   free_pages((unsigned long)cpu_addr, get_order(size));
-}
-
-static dma_addr_t alpha_noop_map_page(struct device *dev, struct page *page,
- unsigned long offset, size_t size,
- enum dma_data_direction dir,
- struct dma_attrs *attrs)
-{
-   return page_to_pa(page) + offset;
-}
-
-static int alpha_noop_map_sg(struct device *dev, struct scatterlist *sgl, int 
nents,
-enum dma_data_direction dir, struct dma_attrs 
*attrs)
-{
-   int i;
-   struct scatterlist *sg;
-
-   for_each_sg(sgl, sg, nents, i) {
-   void *va;
-
-   BUG_ON(!sg_page(sg));
-   va = sg_virt(sg);
-   sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va);
-   sg_dma_len(sg) = sg->length;
-   }
-
-   return nents;
-}
-
-static int alpha_noop_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
-   return 0;
-}
-
 static int alpha_noop_supported(struct device *dev, u64 mask)
 {
return mask < 0x00ffUL ? 0 : 1;
@@ -168,10 +130,10 @@ static int alpha_noop_supported(struct device *dev, u64 
mask)
 
 struct dma_map_ops alpha_noop_ops = {
.alloc  = alpha_noop_alloc_coherent,
-   .free   = alpha_noop_free_coherent,
-   .map_page   = alpha_noop_map_page,
-   .map_sg = alpha_noop_map_sg,
-   .mapping_error  = alpha_noop_mapping_error,
+   .free   = dma_noop_free_coherent,
+   .map_page   = dma_noop_map_page,
+   .map_sg = dma_noop_map_sg,
+   .mapping_error  = dma_noop_mapping_error,
.dma_supported  = alpha_noop_supported,
 };
 
-- 
2.5.0



[PATCH v7 8/9] virtio_pci: Use the DMA API if enabled

2016-02-02 Thread Andy Lutomirski
This switches to vring_create_virtqueue, simplifying the driver and
adding DMA API support.

This fixes virtio-pci on platforms and busses that have IOMMUs.  This
will break the experimental QEMU Q35 IOMMU support until QEMU is
fixed.  In exchange, it fixes physical virtio hardware as well as
virtio-pci running under Xen.

Signed-off-by: Andy Lutomirski 
---
 drivers/virtio/virtio_pci_common.h |  6 
 drivers/virtio/virtio_pci_legacy.c | 42 +++---
 drivers/virtio/virtio_pci_modern.c | 61 ++
 3 files changed, 33 insertions(+), 76 deletions(-)

diff --git a/drivers/virtio/virtio_pci_common.h 
b/drivers/virtio/virtio_pci_common.h
index 2cc252270b2d..28263200ed42 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -35,12 +35,6 @@ struct virtio_pci_vq_info {
/* the actual virtqueue */
struct virtqueue *vq;
 
-   /* the number of entries in the queue */
-   int num;
-
-   /* the virtual address of the ring queue */
-   void *queue;
-
/* the list node for the virtqueues list */
struct list_head node;
 
diff --git a/drivers/virtio/virtio_pci_legacy.c 
b/drivers/virtio/virtio_pci_legacy.c
index 48bc9797e530..8c4e61783441 100644
--- a/drivers/virtio/virtio_pci_legacy.c
+++ b/drivers/virtio/virtio_pci_legacy.c
@@ -119,7 +119,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device 
*vp_dev,
  u16 msix_vec)
 {
struct virtqueue *vq;
-   unsigned long size;
u16 num;
int err;
 
@@ -131,27 +130,19 @@ static struct virtqueue *setup_vq(struct 
virtio_pci_device *vp_dev,
if (!num || ioread32(vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN))
return ERR_PTR(-ENOENT);
 
-   info->num = num;
info->msix_vector = msix_vec;
 
-   size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN));
-   info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO);
-   if (info->queue == NULL)
+   /* create the vring */
+   vq = vring_create_virtqueue(index, num,
+   VIRTIO_PCI_VRING_ALIGN, _dev->vdev,
+   true, false, vp_notify, callback, name);
+   if (!vq)
return ERR_PTR(-ENOMEM);
 
/* activate the queue */
-   iowrite32(virt_to_phys(info->queue) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
+   iowrite32(virtqueue_get_desc_addr(vq) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT,
  vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
 
-   /* create the vring */
-   vq = vring_new_virtqueue(index, info->num,
-VIRTIO_PCI_VRING_ALIGN, _dev->vdev,
-true, info->queue, vp_notify, callback, name);
-   if (!vq) {
-   err = -ENOMEM;
-   goto out_activate_queue;
-   }
-
vq->priv = (void __force *)vp_dev->ioaddr + VIRTIO_PCI_QUEUE_NOTIFY;
 
if (msix_vec != VIRTIO_MSI_NO_VECTOR) {
@@ -159,17 +150,15 @@ static struct virtqueue *setup_vq(struct 
virtio_pci_device *vp_dev,
msix_vec = ioread16(vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR);
if (msix_vec == VIRTIO_MSI_NO_VECTOR) {
err = -EBUSY;
-   goto out_assign;
+   goto out_deactivate;
}
}
 
return vq;
 
-out_assign:
-   vring_del_virtqueue(vq);
-out_activate_queue:
+out_deactivate:
iowrite32(0, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
-   free_pages_exact(info->queue, size);
+   vring_del_virtqueue(vq);
return ERR_PTR(err);
 }
 
@@ -177,7 +166,6 @@ static void del_vq(struct virtio_pci_vq_info *info)
 {
struct virtqueue *vq = info->vq;
struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
-   unsigned long size;
 
iowrite16(vq->index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
 
@@ -188,13 +176,10 @@ static void del_vq(struct virtio_pci_vq_info *info)
ioread8(vp_dev->ioaddr + VIRTIO_PCI_ISR);
}
 
-   vring_del_virtqueue(vq);
-
/* Select and deactivate the queue */
iowrite32(0, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN);
 
-   size = PAGE_ALIGN(vring_size(info->num, VIRTIO_PCI_VRING_ALIGN));
-   free_pages_exact(info->queue, size);
+   vring_del_virtqueue(vq);
 }
 
 static const struct virtio_config_ops virtio_pci_config_ops = {
@@ -227,6 +212,13 @@ int virtio_pci_legacy_probe(struct virtio_pci_device 
*vp_dev)
return -ENODEV;
}
 
+   rc = dma_set_mask_and_coherent(_dev->dev, DMA_BIT_MASK(64));
+   if (rc)
+   rc = dma_set_mask_and_coherent(_dev->dev,
+   DMA_BIT_MASK(32));
+   if (rc)
+   dev_warn(_dev->dev, "Failed to enable 64-bit or 32-bit DMA. 
 Trying to continue, but this might not work.\n");
+
rc = 

Re: [PATCH] psmouse: added BYD touchpad driver

2016-02-02 Thread Richard Pospesel
New patch vs 98ee377144935857d8ad5d7d70cdab1da4ede32e on 
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input follows. 
Confirmed builds and works as expected with that kernel branch.


Signed-off-by: Richard Pospesel 
---
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
index 9425e0f..a880adb 100644
--- a/drivers/input/mouse/byd.c
+++ b/drivers/input/mouse/byd.c
@@ -1,337 +1,586 @@
 /*
- * BYD TouchPad PS/2 mouse driver
+ * BYD BTP-10463 touchpad PS/2 mouse driver
  *
- * Copyright (C) 2015 Chris Diamand 
+ * Copyright (C) 2015, Tai Chi Minh Ralph Eastwood
+ * Copyright (C) 2015, Martin Wimpress
+ * Copyright (C) 2015, Jay Kuri
+ * Copyright (C) 2015, Richard Pospesel
  *
  * 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.
+ *
+ * Protocol of BYD Touch Pad reverse-engineered from windows driver:
+ * filename:  "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip"
+ * sha1:  97a0eca8edc482bf9d08ab9509084a514dad4c4b
+ * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf
+ *
  */
+#include 
+#include 

-#include 
 #include 
-#include 
 #include 
+#include 
+#include 

 #include "psmouse.h"
 #include "byd.h"

-#define PS2_Y_OVERFLOW BIT_MASK(7)
-#define PS2_X_OVERFLOW BIT_MASK(6)
-#define PS2_Y_SIGN BIT_MASK(5)
-#define PS2_X_SIGN BIT_MASK(4)
-#define PS2_ALWAYS_1   BIT_MASK(3)
-#define PS2_MIDDLE BIT_MASK(2)
-#define PS2_RIGHT  BIT_MASK(1)
-#define PS2_LEFT   BIT_MASK(0)
+#define BYD_MODEL_ID_LEN2
+#define BYD_CMD_PAIR(c)((1 << 12) | (c))
+#define BYD_CMD_PAIR_R(r, c)   ((1 << 12) | (r << 8) | (c))
+
+/* BYD pad constants */

 /*
- * The touchpad reports gestures in the last byte of each packet. It 
can take

- * any of the following values:
+ * true device resolution is unknown, however experiments show the
+ * resolution is about 111 units/mm
+ * absolute coordinate packets are in the range 0-255 for both X and y
+ * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in
+ * the right ballpark given the touchpad's physical dimensions and estimate
+ * resolution per spec sheet, device active area dimensions are
+ * 101.6 x 60.1 mm
  */

-/* One-finger scrolling in one of the edge scroll zones. */
-#define BYD_SCROLLUP   0xCA
-#define BYD_SCROLLDOWN 0x36
-#define BYD_SCROLLLEFT 0xCB
-#define BYD_SCROLLRIGHT0x35
-/* Two-finger scrolling. */
-#define BYD_2DOWN  0x2B
-#define BYD_2UP0xD5
-#define BYD_2LEFT  0xD6
-#define BYD_2RIGHT 0x2A
-/* Pinching in or out. */
-#define BYD_ZOOMOUT0xD8
-#define BYD_ZOOMIN 0x28
-/* Three-finger swipe. */
-#define BYD_3UP0xD3
-#define BYD_3DOWN  0x2D
-#define BYD_3LEFT  0xD4
-#define BYD_3RIGHT 0x2C
-/* Four-finger swipe. */
-#define BYD_4UP0xCD
-#define BYD_4DOWN  0x33
+#define BYD_CONST_PAD_WIDTH 11264
+#define BYD_CONST_PAD_HEIGHT6656
+#define BYD_CONST_PAD_RESOLUTION111

-int byd_detect(struct psmouse *psmouse, bool set_properties)
+
+/* BYD commands reverse engineered from windows driver */
+
+/*
+ * swipe gesture from off-pad to on-pad
+ *  0 : disable
+ *  1 : enable
+ */
+#define BYD_CMD_SET_OFFSCREEN_SWIPE 0xcc
+/*
+ * tap and drag delay time
+ *  0 : disable
+ *  1 - 8 : least to most delay
+ */
+#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0xcf
+/*
+ * physical buttons function mapping
+ *  0 : enable
+ *  4 : normal
+ *  5 : left button custom command
+ *  6 : right button custom command
+ *  8 : disable
+ */
+#define BYD_CMD_SET_PHYSICAL_BUTTONS0xd0
+/*
+ * absolute mode (1 byte X/Y resolution)
+ *  0 : disable
+ *  2 : enable
+ */
+#define BYD_CMD_SET_ABSOLUTE_MODE   0xd1
+/*
+ * two finger scrolling
+ *  1 : vertical
+ *  2 : horizontal
+ *  3 : vertical + horizontal
+ *  4 : disable
+ */
+#define BYD_CMD_SET_TWO_FINGER_SCROLL   0xd2
+/*
+ * handedness
+ *  1 : right handed
+ *  2 : left handed
+ */
+#define BYD_CMD_SET_HANDEDNESS  0xd3
+/*
+ * tap to click
+ *  1 : enable
+ *  2 : disable
+ */
+#define BYD_CMD_SET_TAP 0xd4
+/*
+ * tap and drag
+ *  1 : tap and hold to drag
+ *  2 : tap and hold to drag + lock
+ *  3 : disable
+ */
+#define BYD_CMD_SET_TAP_DRAG0xd5
+/*
+ * touch sensitivity
+ *  1 - 7 : least to most sensitive
+ */
+#define BYD_CMD_SET_TOUCH_SENSITIVITY   0xd6
+/*
+ * one finger scrolling
+ *  1 : vertical
+ *  2 : horizontal
+ *  3 : vertical + horizontal
+ *  4 : disable
+ */
+#define BYD_CMD_SET_ONE_FINGER_SCROLL   0xd7
+/*
+ * one finger scrolling function
+ *  1 : free scrolling
+ *  2 : edge motion
+ *  3 : free scrolling + 

Re: [PATCH V4 2/2] regulator: mt6323: Add support for MT6323 regulator

2016-02-02 Thread menghui lin
On Tue, 2016-02-02 at 19:38 +, Mark Brown wrote:
> On Fri, Jan 29, 2016 at 08:11:19PM +0800, menghui lin wrote:
> > On Fri, 2016-01-29 at 12:27 +0100, Mark Brown wrote:
> 
> > > None of this is answering my question - I know what the current API is,
> > > describing it doesn't tell me about actual users or how they are able to
> > > sensibly use the interface.  Bear in mind that the definitions of the
> > > various modes are all relative and what one device thinks is high usage
> > > may be low usage for another device.
> 
> > Assuming valid_modes_mask and initial_mode are specified, a possible
> > way to modify regulator_set_mode() is to allow mode change only if the
> > regulator is controlled exclusively by a certain consumer or the
> > requested mode provides stronger power capability than current mode.
> > Here I assume that power capability fast > normal > idle > standby.
> 
> How does the driver know if it needs to change the mode (ie, how can it
> tell if the current mode is inadequate) and surely if we can only change
> in one direction this isn't terribly useful?

Hi Mark,

I think the datasheet of buck/ldo could provide information about power
capability of each mode. The driver should adjust regulator mode per its
device's power requirement.

Below are some actual scenarios we have now. I provide them for your
reference. If unfortunately below cases are not the actual users you
ask, please kindly let me know more about your suggestion.
Thank you. :)

case 1:

We have a USB typeC micro-controller, which has two modes - standby and
normal. It requires 1.8V and 3.3V to operate (both powers are always
on). The device stays in standby mode when there is no cable in. When
cable in, we got an interrupt and change device into normal mode.

The standby mode power consumption is quite small, so we would like the
change mode of regulator into STANDBY to save more power. And we change
into NORMAL when we receive cable-in interrupt.

case 2:

About buck regulator for CPU, it usually provides PWM mode, PWM/PFM Auto
mode, PFM mode. I think it could map to FAST, NORMAL, IDLE mode
respectively. Most of time we would use just normal mode. However, we
would change regulator into PWM mode time to time to test buck output
performance on the tested board.





[PATCH v2 2/2] bluetooth: btmrvl: parse host wakeup configuration from device tree

2016-02-02 Thread Amitkumar Karwar
From: Xinming Hu 

This patch implements a framework for board specific wakeup.
driver parse irq/gpio number from device tree, corresponding
resources will be allocated, and used for host suspend/resume.
Device tree binding file is also updated in the patch.

Signed-off-by: Xinming Hu 
Signed-off-by: Amitkumar Karwar 
---
v2: Fixed build error reported by kbuild test robot
drivers/bluetooth/btmrvl_platform.c:141:22: error:
'btmrvl_plt_pm_ops' undeclared here (not in a function)
---
 Documentation/devicetree/bindings/btmrvl.txt | 17 -
 drivers/bluetooth/btmrvl_platform.c  | 95 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/btmrvl.txt 
b/Documentation/devicetree/bindings/btmrvl.txt
index 25b804b..887c7ff 100644
--- a/Documentation/devicetree/bindings/btmrvl.txt
+++ b/Documentation/devicetree/bindings/btmrvl.txt
@@ -12,11 +12,19 @@ Optional properties:
 
   - btmrvl,gpio-gap : gpio and gap (in msecs) combination to be
  configured.
+  - interrupt-parent: phandle of the parent interrupt controller
+  - interrupts : interrupt number to the cpu
+  - gpios: specify GPIO respectively. gpio here is board specific pin.
+  while above gpio-gap represents the device side pin used to
+  wakeup host.
+  - pinctrl-names : a pinctrl state named "default" must be defined
+  - pinctrl-0 : pin control group to be used for this controller
 
 Example:
 
-GPIO pin 13 and gap 100ms are configured for host wakeup, calibration
-data is also available in below example.
+GPIO pin 119 and gap 100ms are configured for host wakeup,
+pin 13 is configured so that firmware can wakeup host using this device side
+pin, calibration data is also available in below example.
 
 btmrvl {
compatible = "marvell,btmrvl";
@@ -26,4 +34,9 @@ btmrvl {
0x00 0x00 0xba 0xce 0xc0 0xc6 0x2d 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0xf0 0x00>;
btmrvl,gpio-gap = <0x0d64>;
+   interrupt-parent = <>;
+   interrupts = <119 IRQ_TYPE_LEVEL_LOW>;
+   gpios = < 119 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
 };
diff --git a/drivers/bluetooth/btmrvl_platform.c 
b/drivers/bluetooth/btmrvl_platform.c
index 4e91d27..6f64922 100644
--- a/drivers/bluetooth/btmrvl_platform.c
+++ b/drivers/bluetooth/btmrvl_platform.c
@@ -19,9 +19,63 @@
 
 struct platform_device *btmrvl_plt_dev;
 
+struct btmrvl_wake_dev {
+   struct device   *dev;
+   int irq_bt;
+   boolwake_by_bt;
+};
+
+static irqreturn_t btmrvl_wake_irq_bt(int irq, void *priv)
+{
+   struct btmrvl_wake_dev *ctx = priv;
+
+   if (ctx->irq_bt >= 0) {
+   ctx->wake_by_bt = true;
+   disable_irq_nosync(ctx->irq_bt);
+   }
+
+   return IRQ_HANDLED;
+}
+
 static int btmrvl_plt_probe(struct platform_device *pdev)
 {
+   int ret;
+   struct btmrvl_wake_dev *ctx;
+   int gpio;
+
btmrvl_plt_dev = pdev;
+
+   ctx = devm_kzalloc(>dev, sizeof(*ctx), GFP_KERNEL);
+   if (!ctx)
+   return -ENOMEM;
+
+   ctx->dev = >dev;
+   ctx->irq_bt = platform_get_irq(pdev, 0);
+   if (ctx->irq_bt < 0)
+   dev_err(>dev, "Failed to get irq_bt\n");
+
+   gpio = of_get_gpio(pdev->dev.of_node, 0);
+   if (gpio_is_valid(gpio))
+   gpio_direction_input(gpio);
+   else
+   dev_err(>dev, "gpio bt is invalid\n");
+
+   if (ctx->irq_bt >= 0) {
+   ret = devm_request_irq(>dev, ctx->irq_bt,
+  btmrvl_wake_irq_bt,
+  IRQF_TRIGGER_LOW,
+  "bt_wake", ctx);
+   if (ret) {
+   dev_err(>dev,
+   "Failed to request irq_bt %d (%d)\n",
+   ctx->irq_bt, ret);
+   return -EINVAL;
+   }
+   disable_irq(ctx->irq_bt);
+   }
+
+   platform_set_drvdata(pdev, ctx);
+
return 0;
 }
 
@@ -31,6 +85,44 @@ static int btmrvl_plt_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int btmrvl_plt_suspend(struct device *dev)
+{
+   struct btmrvl_wake_dev *ctx = dev_get_drvdata(dev);
+   int ret;
+
+   if (ctx->irq_bt >= 0) {
+   ctx->wake_by_bt = false;
+   enable_irq(ctx->irq_bt);
+   ret = enable_irq_wake(ctx->irq_bt);
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
+static int btmrvl_plt_resume(struct device *dev)
+{
+   struct btmrvl_wake_dev *ctx = dev_get_drvdata(dev);
+   int ret;
+
+   if (ctx->irq_bt >= 0) {
+   ret = disable_irq_wake(ctx->irq_bt);
+   if (!ctx->wake_by_bt)
+   disable_irq(ctx->irq_bt);
+   if (ret)
+ 

[PATCH v2 1/2] bluetooth: btmrvl: register platform specific driver

2016-02-02 Thread Amitkumar Karwar
From: Xinming Hu 

Platform device and driver provide easy way to
interact with device-tree-enabled system.

This patch registers platform driver and reorganise
existing device tree specific code.

Signed-off-by: Xinming Hu 
Signed-off-by: Amitkumar Karwar 
---
 Documentation/devicetree/bindings/btmrvl.txt |  8 ++--
 drivers/bluetooth/Makefile   |  1 +
 drivers/bluetooth/btmrvl_drv.h   | 16 
 drivers/bluetooth/btmrvl_main.c  |  7 +++-
 drivers/bluetooth/btmrvl_platform.c  | 60 
 5 files changed, 87 insertions(+), 5 deletions(-)
 create mode 100644 drivers/bluetooth/btmrvl_platform.c

diff --git a/Documentation/devicetree/bindings/btmrvl.txt 
b/Documentation/devicetree/bindings/btmrvl.txt
index 58f964b..25b804b 100644
--- a/Documentation/devicetree/bindings/btmrvl.txt
+++ b/Documentation/devicetree/bindings/btmrvl.txt
@@ -3,7 +3,7 @@ btmrvl
 
 Required properties:
 
-  - compatible : must be "btmrvl,cfgdata"
+  - compatible : must be "marvell,btmrvl"
 
 Optional properties:
 
@@ -15,11 +15,11 @@ Optional properties:
 
 Example:
 
-GPIO pin 13 is configured as a wakeup source and GAP is set to 100 msecs
-in below example.
+GPIO pin 13 and gap 100ms are configured for host wakeup, calibration
+data is also available in below example.
 
 btmrvl {
-   compatible = "btmrvl,cfgdata";
+   compatible = "marvell,btmrvl";
 
btmrvl,cal-data = /bits/ 8 <
0x37 0x01 0x1c 0x00 0xff 0xff 0xff 0xff 0x01 0x7f 0x04 0x02
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 07c9cf3..9bc3828 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_BT_RTL)  += btrtl.o
 obj-$(CONFIG_BT_QCA)   += btqca.o
 
 btmrvl-y   := btmrvl_main.o
+btmrvl-y   += btmrvl_platform.o
 btmrvl-$(CONFIG_DEBUG_FS)  += btmrvl_debugfs.o
 
 hci_uart-y := hci_ldisc.o
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index 0590473..de6309b 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -22,8 +22,22 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
+extern struct platform_device *btmrvl_plt_dev;
+
 #define BTM_HEADER_LEN 4
 #define BTM_UPLD_SIZE  2312
 
@@ -174,6 +188,8 @@ int btmrvl_enable_ps(struct btmrvl_private *priv);
 int btmrvl_prepare_command(struct btmrvl_private *priv);
 int btmrvl_enable_hs(struct btmrvl_private *priv);
 void btmrvl_firmware_dump(struct btmrvl_private *priv);
+int btmrvl_platform_drv_init(void);
+void btmrvl_platform_drv_exit(void);
 
 #ifdef CONFIG_DEBUG_FS
 void btmrvl_debugfs_init(struct hci_dev *hdev);
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index f25a825..3604894 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -514,7 +514,8 @@ static int btmrvl_check_device_tree(struct btmrvl_private 
*priv)
int ret;
u32 val;
 
-   for_each_compatible_node(dt_node, NULL, "btmrvl,cfgdata") {
+   dt_node = btmrvl_plt_dev->dev.of_node;
+   if (dt_node) {
ret = of_property_read_u32(dt_node, "btmrvl,gpio-gap", );
if (!ret)
priv->btmrvl_dev.gpio_gap = val;
@@ -733,6 +734,8 @@ struct btmrvl_private *btmrvl_add_card(void *card)
goto err_adapter;
}
 
+   btmrvl_platform_drv_init();
+
btmrvl_init_adapter(priv);
 
BT_DBG("Starting kthread...");
@@ -776,6 +779,8 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
btmrvl_debugfs_remove(hdev);
 #endif
 
+   btmrvl_platform_drv_exit();
+
hci_unregister_dev(hdev);
 
hci_free_dev(hdev);
diff --git a/drivers/bluetooth/btmrvl_platform.c 
b/drivers/bluetooth/btmrvl_platform.c
new file mode 100644
index 000..4e91d27
--- /dev/null
+++ b/drivers/bluetooth/btmrvl_platform.c
@@ -0,0 +1,60 @@
+/* Marvell Bluetooth driver: platform specific driver
+ *
+ * Copyright (C) 2015, Marvell International Ltd.
+ *
+ * This software file (the "File") is distributed by Marvell International
+ * Ltd. under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License").  You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available on the worldwide web at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#include "btmrvl_drv.h"

Re: [PATCH v5 04/14] clk: clk-pic32: Add PIC32 clock driver

2016-02-02 Thread Purna Chandra Mandal
On 01/30/2016 05:28 AM, Stephen Boyd wrote:

> On 01/13, Joshua Henderson wrote:
>> diff --git a/drivers/clk/clk-pic32.c b/drivers/clk/clk-pic32.c
>> new file mode 100644
>> index 000..9dc5f78
>> --- /dev/null
>> +++ b/drivers/clk/clk-pic32.c
>> @@ -0,0 +1,1801 @@
>> +/*
>> + * Purna Chandra Mandal,
>> + * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
>> + *
>> + * This program is free software; you can distribute it and/or modify it
>> + * under the terms of the GNU General Public License (Version 2) as
>> + * published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>> + * for more details.
>> + */
>> +#include 
>> +#include 
> Is this used?

Yes. used below. Will remove as discussed below.

>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> Please move asm includes after all linux includes.
>
> Include  for abs usage?
>
ack.

>> +
>> +#include 
> Is this header required? I'd like to be able to build this file
> without using a MIPS compiler. For example, if we could move that
> pic32_syskey_unlock() prototype somewhere else besides
> asm/mach-pic32 then this should compile fine on non-MIPS kernels?

Yes it is good to remove the dependency for compilation purpose. But this
driver uses few more functionality/macros (like PIC32_CLR, PIC32_SET)
defined in pic32.h which are used by this driver to select
atomic-register-offset.

>> +
>> +/* OSCCON Reg fields */
>> +#define OSC_CUR_MASK0x07
>> +#define OSC_CUR_SHIFT   12
>> +#define OSC_NEW_MASK0x07
>> +#define OSC_NEW_SHIFT   8
>> +#define OSC_SWEN0x01
>> +#define OSC_CLK_FAILED  0x04
>> +
>> +/* SPLLCON Reg fields */
>> +#define PLL_RANGE_MASK  0x07
>> +#define PLL_RANGE_SHIFT 0
>> +#define PLL_ICLK_MASK   0x01
>> +#define PLL_ICLK_SHIFT  7
>> +#define PLL_IDIV_MASK   0x07
>> +#define PLL_IDIV_SHIFT  8
>> +#define PLL_ODIV_MASK   0x07
>> +#define PLL_ODIV_SHIFT  24
>> +#define PLL_MULT_MASK   0x7F
>> +#define PLL_MULT_SHIFT  16
>> +#define PLL_MULT_MAX128
>> +#define PLL_ODIV_MIN1
>> +#define PLL_ODIV_MAX5
>> +
>> +/* Peripheral Bus Clock Reg Fields */
>> +#define PB_DIV_MASK 0x7f
>> +#define PB_DIV_SHIFT0
>> +#define PB_DIV_READYBIT(11)
>> +#define PB_DIV_ENABLED  BIT(15)
>> +#define PB_DIV_MAX  128
>> +#define PB_DIV_MIN  0
>> +
>> +/* Reference Oscillator Control Reg fields */
>> +#define REFO_SEL_MASK   0x0f
>> +#define REFO_SEL_SHIFT  0
>> +#define REFO_ACTIVE BIT(8)
>> +#define REFO_DIVSW_EN   BIT(9)
>> +#define REFO_OE BIT(12)
>> +#define REFO_ON BIT(15)
>> +#define REFO_DIV_SHIFT  16
>> +#define REFO_DIV_MASK   0x7fff
>> +
>> +/* Reference Oscillator Trim Register Fields */
>> +#define REFO_TRIM_REG   0x10 /* Register offset w.r.t. 
>> REFO_CON_REG */
>> +#define REFO_TRIM_MASK  0x1ff
>> +#define REFO_TRIM_SHIFT 23
>> +#define REFO_TRIM_MAX   511
>> +
>> +/* FRC postscaler */
>> +#define OSC_FRCDIV_MASK 0x07
>> +#define OSC_FRCDIV_SHIFT24
>> +
>> +/* FRC tuning */
>> +#define OSC_FRCTUN_MASK 0x3F
>> +#define OSC_FRCTUN_SHIFT0
>> +
>> +/* SLEW Control Register fields */
>> +#define SLEW_BUSY   0x01
>> +#define SLEW_DOWNEN 0x02
>> +#define SLEW_UPEN   0x04
>> +#define SLEW_DIV0x07
>> +#define SLEW_DIV_SHIFT  8
>> +#define SLEW_SYSDIV 0x0f
>> +#define SLEW_SYSDIV_SHIFT   20
>> +
>> +/* Common clock flags */
>> +#define CLK_ENABLED_ALWAYS  CLK_IGNORE_UNUSED
>> +#define CLK_DIV_FIXED   BIT(20)
>> +
>> +/* Sys Mux clock flags */
>> +#define SYS_MUX_POSTDIV 0x1
>> +#define SYS_MUX_SLEW0x2
>> +
>> +#define LOCK_TIMEOUT_NS (100 * NSEC_PER_MSEC)
>> +
>> +/* System PLL clk */
>> +struct pic32_spll {
>> +struct clk_hw hw;
>> +void __iomem *regs;
>> +void __iomem *status_reg;
>> +u32 pll_locked;
> Maybe this could be called lock_mask?

ack.

>> +u8 idiv; /* pll-iclk divider, treating fixed */
>> +};
>> +
>> +/* System Clk */
>> +struct pic32_sclk {
>> +struct clk_hw hw;
>> +void __iomem *regs;
>> +void __iomem *slwreg;
>> +unsigned long flags;
>> +u32 *parent_idx;
> #ifdef CONFIG_DEBUGFS?

ack. Will remove it and corresponding clk operation callback 'debug_init()' as 
well.

>> +struct 

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

2016-02-02 Thread Stephen Rothwell
Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm
ep93xx_defconfig) failed like this:

mm/slab.c: In function 'is_debug_pagealloc_cache':
mm/slab.c:1608:2: error: implicit declaration of function 
'debug_pagealloc_enabled' [-Werror=implicit-function-declaration]

Caused by commit

  0a244aea1a61 ("mm/slab: clean up DEBUG_PAGEALLOC processing code")

CONFIG_DEBUG_PAGEALLOC is not enabled in this build.

Discovered after the linux-next release.
-- 
Cheers,
Stephen Rothwell


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

2016-02-02 Thread Stephen Rothwell
Hi Andrew,

After merging the akpm-current tree, today's linux-next build (arm
allnoconfig) failed like this:

In file included from kernel/memremap.c:17:0:
include/linux/pfn_t.h:108:7: error: 'pud_mkdevmap' declared as function 
returning an array

Caused by commit

  a27da20ed50e ("mm: add support for PUD-sized transparent hugepages")

Discovered after the linux-next release.

-- 
Cheers,
Stephen Rothwell


[PATCH] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/android/ion/ion_cma_heap.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..88375d9 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -96,9 +94,6 @@ static void ion_cma_free(struct ion_buffer *buffer)
struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


Re: [PATCH v4 1/4] soc: mediatek: Refine scpsys to support multiple platform

2016-02-02 Thread James Liao
Hi Matthias,

On Tue, 2016-02-02 at 11:44 +0100, Matthias Brugger wrote:
> On 02/02/16 07:56, James Liao wrote:
> > On Sun, 2016-01-31 at 12:51 +0100, Matthias Brugger wrote:
> >> >On 20/01/16 07:08, James Liao wrote:
> >>> > >Refine scpsys driver common code to support multiple SoC / platform.
> >>> > >
> >>> > >Signed-off-by: James Liao
> >>> > >---
> >>> > >   drivers/soc/mediatek/mtk-scpsys.c | 418 
> >>> > > --
> >>> > >   drivers/soc/mediatek/mtk-scpsys.h |  55 +
> >>> > >   2 files changed, 270 insertions(+), 203 deletions(-)
> >>> > >   create mode 100644 drivers/soc/mediatek/mtk-scpsys.h
> >> >
> >> >In general this approach looks fine to me, comments below.
> >> >
> >>> > >
> >>> > >diff --git a/drivers/soc/mediatek/mtk-scpsys.c 
> >>> > >b/drivers/soc/mediatek/mtk-scpsys.c
> >>> > >index 0221387..339adfc 100644
> >>> > >--- a/drivers/soc/mediatek/mtk-scpsys.c
> >>> > >+++ b/drivers/soc/mediatek/mtk-scpsys.c
> >>> > >@@ -11,29 +11,17 @@
> >>> > >* GNU General Public License for more details.
> >>> > >*/
> >>> > >   #include 
> >>> > >-#include 
> >>> > >+#include 
> >>> > >   #include 
> >>> > >-#include 
> >>> > >   #include 
> >> >
> >> >When at it, do we need this include?
> > syscon_regmap_lookup_by_phandle() is declared in this head file.
> >
> >>> > >-#include 
> >>> > >   #include 
> >>> > >   #include 
> >>> > >   #include 
> >>> > >-#include 
> >>> > >-#include 
> >>> > >   #include 
> >>> > >-#include 
> >>> > >+#include 
> >>> > >+
> >>> > >+#include "mtk-scpsys.h"
> >>> > >
> >>> > >-#define SPM_VDE_PWR_CON   0x0210
> >>> > >-#define SPM_MFG_PWR_CON   0x0214
> >>> > >-#define SPM_VEN_PWR_CON   0x0230
> >>> > >-#define SPM_ISP_PWR_CON   0x0238
> >>> > >-#define SPM_DIS_PWR_CON   0x023c
> >>> > >-#define SPM_VEN2_PWR_CON  0x0298
> >>> > >-#define SPM_AUDIO_PWR_CON 0x029c
> >>> > >-#define SPM_MFG_2D_PWR_CON0x02c0
> >>> > >-#define SPM_MFG_ASYNC_PWR_CON 0x02c4
> >>> > >-#define SPM_USB_PWR_CON   0x02cc
> >> >
> >> >I would prefer to keep this defines and declare SoC specific ones where
> >> >necessary. It makes the code more readable.
> > Some register address may be reused by other modules among SoCs, so it's
> > not easy to maintain the defines when we implement multiple SoC drivers
> > in the same file. For example, offset 0x0298 is VEN2_PWR_CON on MT8173,
> > but it is MJC_PWR_CON on other chips.
> >
> 
> So that sounds as if 0x0298 offset is MT8173 specific.
> I checked [VDE, MFG, VEN, IFR, ISP, DIS, DPY]_PWR_CON on mt8173, mt8135 
> and mt6589 and they all have the same offset. So it doesn't seem as if 
> the offset randomly changes for every SoC.
> 
> > Furthermore, these register offsets are only used in scp_domain_data[],
> > and each element has its own power domain name. So I think it's enough
> > to know which power domain are using these registers and status bits.
> >
> 
> Yes that's true, but it will make it easier for another person to 
> understand the driver, especially if he want's to implement the driver 
> for a new SoC.

There are two kinds of conflicts may happen:

1. Different modules use the same register address.
2. Different register addresses are used by the same module (on
different IC).

Type 1. for example:

#define SPM_BDP_PWR_CON 0x029c /* 2701 */
#define SPM_AUDIO_PWR_CON   0x029c /* 8173 */

We can resolve this conflict easily, such as define these two register
name to the same register address.

Type 2. for example:

#define SPM_VDE_PWR_CON 0x0300 /* 6755 */
#define SPM_VDE_PWR_CON 0x0210 /* 8173 */

We can not reuse the register defines in this case. We may need to name
the registers with its IC name, such as MT8173_SPM_VDE_PWR_CON and
MT6755_VDE_PWR_CON. But it will increase the maintain effort. That's why
I prefer to remove register defines if we implement multiple SoC's
scpsys in a single file.


Best regards,

James




[PATCH v3] rtlwifi: Fix improve function 'rtl_addr_delay()' in core.c

2016-02-02 Thread Byeoungwook Kim
Conditional codes in rtl_addr_delay() were improved in readability and
performance by using switch codes.

Reviewed-by: Julian Calaby 
Signed-off-by: Byeoungwook Kim 
Signed-off-by: Fengguang Wu 
---
V3 remove unneeded semicolon.
V2 split in separate patchs.
 drivers/net/wireless/realtek/rtlwifi/core.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index 4ae421e..63cda78 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -37,18 +37,26 @@
 
 void rtl_addr_delay(u32 addr)
 {
-   if (addr == 0xfe)
+   switch (addr) {
+   case 0xfe:
mdelay(50);
-   else if (addr == 0xfd)
+   break;
+   case 0xfd:
mdelay(5);
-   else if (addr == 0xfc)
+   break;
+   case 0xfc:
mdelay(1);
-   else if (addr == 0xfb)
+   break;
+   case 0xfb:
udelay(50);
-   else if (addr == 0xfa)
+   break;
+   case 0xfa:
udelay(5);
-   else if (addr == 0xf9)
+   break;
+   case 0xf9:
udelay(1);
+   break;
+   }
 }
 EXPORT_SYMBOL(rtl_addr_delay);
 
-- 
2.5.0



linux-next: Tree for Feb 3

2016-02-02 Thread Stephen Rothwell
Hi all,

Changes since 20160202:

The btrfs-kdave lost its build failure.

The tip tree gained a conflict against Linus' tree.

The gpio tree still had its build failure so I used the version from
next-20160128.

The aio tree still had a build failure so I used the version from
next-20160111.

The akpm-current tree gained 2 build failures for which I applied patches.

Non-merge commits (relative to Linus' tree): 2118
 2062 files changed, 79203 insertions(+), 35125 deletions(-)



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

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
(this fails its final link) and pseries_le_defconfig and i386, sparc
and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 239 trees (counting Linus' and 36 trees of patches
pending for Linus' tree).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

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

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

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (34229b277480 Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net)
Merging fixes/master (92e963f50fc7 Linux 4.5-rc1)
Merging kbuild-current/rc-fixes (3d1450d54a4f Makefile: Force gzip and xz on 
module install)
Merging arc-current/for-curr (74bf8efb5fa6 Linux 4.4-rc7)
Merging arm-current/fixes (03590cb56d5d ARM: wire up copy_file_range() syscall)
Merging m68k-current/for-linus (daf670bc9d36 m68k/defconfig: Update defconfigs 
for v4.5-rc1)
Merging metag-fixes/fixes (0164a711c97b metag: Fix ioremap_wc/ioremap_cached 
build errors)
Merging mips-fixes/mips-fixes (1795cd9b3a91 Linux 3.16-rc5)
Merging powerpc-fixes/fixes (19f97c983071 powerpc/book3s_32: Fix build error 
with checkpoint restart)
Merging powerpc-merge-mpe/fixes (bc0195aad0da Linux 4.2-rc2)
Merging sparc/master (ca0bb0798022 Add sun4v_wdt watchdog driver)
Merging net/master (34229b277480 Merge 
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net)
Merging ipsec/master (a8a572a6b5f2 xfrm: dst_entries_init() per-net dst_ops)
Merging ipvs/master (b16c29191dc8 netfilter: nf_conntrack: use safer way to 
lock all buckets)
Merging wireless-drivers/master (f9ead9beef3f Merge tag 
'iwlwifi-for-kalle-2016-01-26_2' of 
https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-fixes)
Merging mac80211/master (212c5a5e6ba6 mac80211: minstrel: Change expected 
throughput unit back to Kbps)
Merging sound-current/for-linus (c985b6bea858 ALSA: timer: Sync timer deletion 
at closing the system timer)
Merging pci-current/for-linus (d251cba56086 Merge branch 'pci/host-synopsys' 
into for-linus)
Merging driver-core.current/driver-core-linus (36f90b0a2ddd Linux 4.5-rc2)
Merging tty.current/tty-linus (36f90b0a2ddd Linux 4.5-rc2)
Merging usb.current/usb-linus (36f90b0a2ddd Linux 4.5-rc2)
Merging usb-gadget-fixes/fixes (36f90b0a2ddd Linux 4.5-rc2)
Merging usb-serial-fixes/usb-linus (4152b387da81 USB: option: fix Cinterion 
AHxx enumeration)
Merging usb-chipidea-fixes/ci-for-usb-stable (6f51bc340d2a usb: chipidea: imx: 
fix a possible NULL dereference)
Merging staging.current/staging-linus (5982557ac6ee Merge tag 
'iio-fixes-for-4.5b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio 
into staging-linus)
Merging char-misc.current/char-misc-linus (92e963f50fc7 Linux 4.5-rc1)
Merging input-current/for-linus (d4f1b06d685d Input: vmmouse - fix absolute 
device registration)
Merging crypto-current/master (49a20454e0eb crypto: atmel-aes - remove calls of 
clk_prepare() from atomic contexts)
Merging ide/master (e04a2bd6d8c9 drivers/ide: make ide-scan-pci.c driver 
explicitly non-modular)
Merging devicetree-current/devicetree/merge (f76502aa9140 of/dynamic: Fix test 
for PPC_PSERIES)
Merging rr-fixes/fixes (275d7d44d802

  1   2   3   4   5   6   7   8   9   10   >