Re: [PATCH 1/2] ubifs: Fix inode data budget in ubifs_mknod

2017-05-16 Thread Richard Weinberger
Hyunchul,

Am 17.05.2017 um 01:57 schrieb Hyunchul Lee:
> Assign inode data budget to budget request correctly.
> 
> Signed-off-by: Hyunchul Lee 
> ---
>  fs/ubifs/dir.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index b777bdd..df67236 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1050,7 +1050,6 @@ static int ubifs_mknod(struct inode *dir, struct dentry 
> *dentry,
>   int sz_change;
>   int err, devlen = 0;
>   struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
> - .new_ino_d = ALIGN(devlen, 8),
>   .dirtied_ino = 1 };
>   struct fscrypt_name nm;
>  
> @@ -1068,6 +1067,7 @@ static int ubifs_mknod(struct inode *dir, struct dentry 
> *dentry,
>   devlen = ubifs_encode_dev(dev, rdev);
>   }
>  
> + req.new_ino_d = ALIGN(devlen, 8);

Good find!

Thanks,
//richard


Re: [PATCH] sched: Do not bug in __sched_setscheduler() when pi is not used

2017-05-16 Thread Peter Zijlstra
On Tue, May 16, 2017 at 06:55:20PM -0400, Steven Rostedt wrote:
> 
> Peter,
> 
> I've just been pinged by someone that triggered this bug again. Can you
> take this patch and it probably should be marked for stable too.
> 

Oh, rite. Sorry for letting it slip.


Re: [patch V2 15/17] mm/vmscan: Adjust system_state checks

2017-05-16 Thread Vlastimil Babka
On 05/16/2017 08:42 PM, Thomas Gleixner wrote:
> To enable smp_processor_id() and might_sleep() debug checks earlier, it's
> required to add system states between SYSTEM_BOOTING and SYSTEM_RUNNING.
> 
> Adjust the system_state check in kswapd_run() to handle the extra states.
> 
> Signed-off-by: Thomas Gleixner 
> Reviewed-by: Steven Rostedt (VMware) 
> Cc: Andrew Morton 
> Cc: Johannes Weiner 
> Cc: Mel Gorman 
> Cc: Michal Hocko 
> Cc: Vlastimil Babka 
> Cc: linux...@kvack.org

Acked-by: Vlastimil Babka 

> ---
>  mm/vmscan.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3643,7 +3643,7 @@ int kswapd_run(int nid)
>   pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
>   if (IS_ERR(pgdat->kswapd)) {
>   /* failure at boot is fatal */
> - BUG_ON(system_state == SYSTEM_BOOTING);
> + BUG_ON(system_state < SYSTEM_RUNNING);
>   pr_err("Failed to start kswapd on node %d\n", nid);
>   ret = PTR_ERR(pgdat->kswapd);
>   pgdat->kswapd = NULL;
> 
> 



Re: [PATCH] KVM: x86: update master clock before computing kvmclock_offset

2017-05-16 Thread Paolo Bonzini
>   I regret not pressing harder when we sanctified this frequency
>   difference ... too late to make kvm clock follow the boot clock? :)
> ---
>  arch/x86/kvm/x86.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index b54125b590e8..b8aad0969690 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4180,9 +4180,15 @@ long kvm_arch_vm_ioctl(struct file *filp,
>   goto out;
>  
>   r = 0;
> + /*
> +  * TODO: userspace has to take care of races with VCPU_RUN, so
> +  * kvm_gen_update_masterclock() can be cut down to locked
> +  * pvclock_update_vm_gtod_copy().
> +  */
> + kvm_gen_update_masterclock(kvm);
>   now_ns = get_kvmclock_ns(kvm);
>   kvm->arch.kvmclock_offset += user_ns.clock - now_ns;
> - kvm_gen_update_masterclock(kvm);
> + kvm_make_all_cpus_request(kvm, KVM_REQ_CLOCK_UPDATE);
>   break;

Looks good, though I'd still prefer to do what the TODO says...  I'll
try to put together a patch today.

Paolo


[PATCH 2/2] drm: drop drm_[cm]alloc* helpers

2017-05-16 Thread Michal Hocko
From: Michal Hocko 

Now that drm_[cm]alloc* helpers are simple one line wrappers around
kvmalloc_array and drm_free_large is just kvfree alias we can drop
them and replace by their native forms.

This shouldn't introduce any functional change.

Suggested-by: Daniel Vetter 
Signed-off-by: Michal Hocko 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c| 16 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 19 
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  7 +--
 drivers/gpu/drm/drm_gem.c  |  6 +--
 drivers/gpu/drm/etnaviv/etnaviv_gem.c  | 12 ++---
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c|  4 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c   | 12 ++---
 drivers/gpu/drm/exynos/exynos_drm_gem.c| 11 +++--
 drivers/gpu/drm/i915/i915_debugfs.c|  4 +-
 drivers/gpu/drm/i915/i915_gem.c|  4 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 34 +++---
 drivers/gpu/drm/i915/i915_gem_gtt.c|  6 +--
 drivers/gpu/drm/i915/i915_gem_userptr.c|  8 ++--
 drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c | 12 ++---
 drivers/gpu/drm/msm/msm_gem.c  | 10 ++--
 drivers/gpu/drm/radeon/radeon_cs.c | 11 +++--
 drivers/gpu/drm/radeon/radeon_gem.c|  2 +-
 drivers/gpu/drm/radeon/radeon_ring.c   |  4 +-
 drivers/gpu/drm/radeon/radeon_vm.c |  4 +-
 drivers/gpu/drm/ttm/ttm_tt.c   | 13 +++---
 drivers/gpu/drm/udl/udl_dmabuf.c   |  2 +-
 drivers/gpu/drm/udl/udl_gem.c  |  2 +-
 drivers/gpu/drm/vc4/vc4_gem.c  | 15 +++---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 27 +--
 include/drm/drmP.h |  1 -
 include/drm/drm_mem_util.h | 53 --
 26 files changed, 126 insertions(+), 173 deletions(-)
 delete mode 100644 include/drm/drm_mem_util.h

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index a6649874e6ce..9f0247cdda5e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -96,7 +96,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
int r;
unsigned long total_size = 0;
 
-   array = drm_malloc_ab(num_entries, sizeof(struct amdgpu_bo_list_entry));
+   array = kvmalloc_array(num_entries, sizeof(struct 
amdgpu_bo_list_entry), GFP_KERNEL);
if (!array)
return -ENOMEM;
memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
@@ -148,7 +148,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
for (i = 0; i < list->num_entries; ++i)
amdgpu_bo_unref(&list->array[i].robj);
 
-   drm_free_large(list->array);
+   kvfree(list->array);
 
list->gds_obj = gds_obj;
list->gws_obj = gws_obj;
@@ -163,7 +163,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 error_free:
while (i--)
amdgpu_bo_unref(&array[i].robj);
-   drm_free_large(array);
+   kvfree(array);
return r;
 }
 
@@ -224,7 +224,7 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)
amdgpu_bo_unref(&list->array[i].robj);
 
mutex_destroy(&list->lock);
-   drm_free_large(list->array);
+   kvfree(list->array);
kfree(list);
 }
 
@@ -244,8 +244,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
 
int r;
 
-   info = drm_malloc_ab(args->in.bo_number,
-sizeof(struct drm_amdgpu_bo_list_entry));
+   info = kvmalloc_array(args->in.bo_number,
+sizeof(struct drm_amdgpu_bo_list_entry), 
GFP_KERNEL);
if (!info)
return -ENOMEM;
 
@@ -311,11 +311,11 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void 
*data,
 
memset(args, 0, sizeof(*args));
args->out.list_handle = handle;
-   drm_free_large(info);
+   kvfree(info);
 
return 0;
 
 error_free:
-   drm_free_large(info);
+   kvfree(info);
return r;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 4e6b9501ab0a..5b3e0f63a115 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -194,7 +194,7 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void 
*data)
size = p->chunks[i].length_dw;
cdata = (void __user *)(uintptr_t)user_chunk.chunk_data;
 
-   p->chunks[i].kdata = drm_malloc_ab(size, sizeof(uint32_t));
+   p->chunks[i].kdata = kvmalloc_array(size, sizeof(uint32_t), 
GFP_KERNEL);
if (p->chunks[i].kdata == NULL) {
ret = -ENOMEM;
i--;
@@ -

[PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives

2017-05-16 Thread Michal Hocko
From: Michal Hocko 

drm_[cm]alloc* has grown their own kvmalloc with vmalloc fallback
implementations. MM has grown kvmalloc* helpers in the meantime. Let's
use those because it a) reduces the code and b) MM has a better idea
how to implement fallbacks (e.g. do not vmalloc before kmalloc is tried
with __GFP_NORETRY).

drm_calloc_large needs to get __GFP_ZERO explicitly but it is the same
thing as kvmalloc_array in principle.

Signed-off-by: Michal Hocko 
---

Hi,
I didn't add Reviewed-by from Chris because the original patch [1]
didn't change drm_calloc_large which I have missed in that posting.
This patch is the same otherwwise.

[1] http://lkml.kernel.org/r/20170516090606.5891-1-mho...@kernel.org

 include/drm/drm_mem_util.h | 31 +++
 1 file changed, 3 insertions(+), 28 deletions(-)

diff --git a/include/drm/drm_mem_util.h b/include/drm/drm_mem_util.h
index d0f6cf2e5324..a1ddf55fda67 100644
--- a/include/drm/drm_mem_util.h
+++ b/include/drm/drm_mem_util.h
@@ -31,43 +31,18 @@
 
 static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
 {
-   if (size != 0 && nmemb > SIZE_MAX / size)
-   return NULL;
-
-   if (size * nmemb <= PAGE_SIZE)
-   return kcalloc(nmemb, size, GFP_KERNEL);
-
-   return vzalloc(size * nmemb);
+   return kvmalloc_array(nmemb, size, GFP_KERNEL | __GFP_ZERO);
 }
 
 /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. 
*/
 static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
 {
-   if (size != 0 && nmemb > SIZE_MAX / size)
-   return NULL;
-
-   if (size * nmemb <= PAGE_SIZE)
-   return kmalloc(nmemb * size, GFP_KERNEL);
-
-   return vmalloc(size * nmemb);
+   return kvmalloc_array(nmemb, size, GFP_KERNEL);
 }
 
 static __inline__ void *drm_malloc_gfp(size_t nmemb, size_t size, gfp_t gfp)
 {
-   if (size != 0 && nmemb > SIZE_MAX / size)
-   return NULL;
-
-   if (size * nmemb <= PAGE_SIZE)
-   return kmalloc(nmemb * size, gfp);
-
-   if (gfp & __GFP_RECLAIMABLE) {
-   void *ptr = kmalloc(nmemb * size,
-   gfp | __GFP_NOWARN | __GFP_NORETRY);
-   if (ptr)
-   return ptr;
-   }
-
-   return __vmalloc(size * nmemb, gfp, PAGE_KERNEL);
+   return kvmalloc_array(nmemb, size, gfp);
 }
 
 static __inline void drm_free_large(void *ptr)
-- 
2.11.0



Re: [PATCH] KVM: x86: lower default for halt_poll_ns

2017-05-16 Thread Paolo Bonzini

> Still, I think we have dynamic polling to mitigate this overhead;
> how was it behaving?

Correctly: the polling stopped as soon as the benchmark ended. :)

> I noticed a questionable decision in growing the window:
> we know how long the polling should have been (block_ns), but we do not
> use that information to set the next halt_poll_ns.
> 
> Has something like this been tried?
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index f0fe9d02f6bb..d8dbf50957fc 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2193,7 +2193,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
>   /* we had a short halt and our poll time is too small */
>   else if (vcpu->halt_poll_ns < halt_poll_ns &&
>   block_ns < halt_poll_ns)
> - grow_halt_poll_ns(vcpu);
> + vcpu->halt_poll_ns = block_ns /* + x ? */;

IIUC the idea was to grow slower than just, say, 10 ns -> 150 ns.
Taking into account block_ns might also be useful, but it shouldn't
matter much since the shrinking is very aggressive.

Paolo

>   } else
>   vcpu->halt_poll_ns = 0;
>  
> 
> It would avoid a case where several halts in a row were interrupted
> after 300 us, but on the first one we'd schedule out after 10 us, then
> after 20, 40, 80, 160, and finally have the successful poll at 320 us,
> but we have just wasted time if the window is reset at any point before
> that.
> 
> (I really don't like benchmarking ...)
> 
> Thanks.
> 


Re: [RFC][PATCH 00/14] sched/fair: A bit of a cgroup/PELT overhaul (again)..

2017-05-16 Thread Peter Zijlstra
On Tue, May 16, 2017 at 06:02:17PM -0400, Tejun Heo wrote:
> Hello,
> 
> On Fri, May 12, 2017 at 06:44:16PM +0200, Peter Zijlstra wrote:
> > 
> > Hi all,
> > 
> > So after staring at all that PELT stuff and working my way through it again:
> > 
> >   
> > https://lkml.kernel.org/r/20170505154117.6zldxuki2fgyo...@hirez.programming.kicks-ass.net
> > 
> > I started doing some patches to fix some of the identified broken.
> > 
> > So here are a few too many patches that do:
> > 
> >  - fix 'reweight_entity' to instantly propagate the change in 
> > se->load.weight.
> > 
> >  - rewrite/fix the propagate on migrate (attach/detach)
> > 
> >  - introduce the hierarchical runnable_load_avg, as proposed by Tejun.
> > 
> >  - synchronous detach for runnable migrates
> > 
> >  - aligns the PELT windows between a cfs_rq and all its se's
> > 
> >  - deals with random fallout from the above (some of this needs folding back
> >and reordering, but its all well past the point I should post this 
> > anyway).
> 
> The schbench results look good here.  I'll put it under more realistic
> test tomorrow and see how it performs.

Josef reported some problems with these patches and narrowed it down to:

  "sched/fair: Remove se->load.weight from se->avg.load_sum"

I'm currently stuck chasing a regression in other code, but I'll try and
get back to this shortly.


[PATCH v3] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Arvind Yadav
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav 
---
 drivers/cpufreq/kirkwood-cpufreq.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c 
b/drivers/cpufreq/kirkwood-cpufreq.c
index 1b9bcd7..c2dd43f 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
return PTR_ERR(priv.cpu_clk);
}
 
-   clk_prepare_enable(priv.cpu_clk);
+   err = clk_prepare_enable(priv.cpu_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare cpuclk\n");
+   return err;
+   }
+
kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
 
priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
@@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
goto out_cpu;
}
 
-   clk_prepare_enable(priv.ddr_clk);
+   err = clk_prepare_enable(priv.ddr_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare ddrclk\n");
+   goto out_cpu;
+   }
kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
 
priv.powersave_clk = of_clk_get_by_name(np, "powersave");
@@ -146,7 +155,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
err = PTR_ERR(priv.powersave_clk);
goto out_ddr;
}
-   clk_prepare_enable(priv.powersave_clk);
+   err = clk_prepare_enable(priv.powersave_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare powersave clk\n");
+   goto out_ddr;
+   }
 
of_node_put(np);
np = NULL;
-- 
1.9.1



Re: [PATCH] mmc: sdhci-xenon: kill xenon_clean_phy()

2017-05-16 Thread Hu Ziji
On 2017/5/16 14:17, Jisheng Zhang wrote:
> Currently, the xenon_clean_phy() is only used for freeing phy_params.
> The phy_params is allocated by devm_kzalloc(), there's no need to free
> is explicitly.
> 
> Signed-off-by: Jisheng Zhang 

Thanks for the fix.

Acked-by Hu Ziji 

Best regards,
Hu Ziji

> ---
>  drivers/mmc/host/sdhci-xenon-phy.c | 14 +-
>  drivers/mmc/host/sdhci-xenon.c |  6 +-
>  drivers/mmc/host/sdhci-xenon.h |  1 -
>  3 files changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-xenon-phy.c 
> b/drivers/mmc/host/sdhci-xenon-phy.c
> index 6356781f1cca..f7e26b031e76 100644
> --- a/drivers/mmc/host/sdhci-xenon-phy.c
> +++ b/drivers/mmc/host/sdhci-xenon-phy.c
> @@ -787,14 +787,6 @@ int xenon_phy_adj(struct sdhci_host *host, struct 
> mmc_ios *ios)
>   return ret;
>  }
>  
> -void xenon_clean_phy(struct sdhci_host *host)
> -{
> - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> - struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
> -
> - kfree(priv->phy_params);
> -}
> -
>  static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
>const char *phy_name)
>  {
> @@ -819,11 +811,7 @@ static int xenon_add_phy(struct device_node *np, struct 
> sdhci_host *host,
>   if (ret)
>   return ret;
>  
> - ret = xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params);
> - if (ret)
> - xenon_clean_phy(host);
> -
> - return ret;
> + return xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params);
>  }
>  
>  int xenon_phy_parse_dt(struct device_node *np, struct sdhci_host *host)
> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
> index 67246655315b..bc1781bb070b 100644
> --- a/drivers/mmc/host/sdhci-xenon.c
> +++ b/drivers/mmc/host/sdhci-xenon.c
> @@ -486,7 +486,7 @@ static int xenon_probe(struct platform_device *pdev)
>  
>   err = xenon_sdhc_prepare(host);
>   if (err)
> - goto clean_phy_param;
> + goto err_clk;
>  
>   err = sdhci_add_host(host);
>   if (err)
> @@ -496,8 +496,6 @@ static int xenon_probe(struct platform_device *pdev)
>  
>  remove_sdhc:
>   xenon_sdhc_unprepare(host);
> -clean_phy_param:
> - xenon_clean_phy(host);
>  err_clk:
>   clk_disable_unprepare(pltfm_host->clk);
>  free_pltfm:
> @@ -510,8 +508,6 @@ static int xenon_remove(struct platform_device *pdev)
>   struct sdhci_host *host = platform_get_drvdata(pdev);
>   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>  
> - xenon_clean_phy(host);
> -
>   sdhci_remove_host(host, 0);
>  
>   xenon_sdhc_unprepare(host);
> diff --git a/drivers/mmc/host/sdhci-xenon.h b/drivers/mmc/host/sdhci-xenon.h
> index 6e6523ea01ce..73debb42dc2f 100644
> --- a/drivers/mmc/host/sdhci-xenon.h
> +++ b/drivers/mmc/host/sdhci-xenon.h
> @@ -93,7 +93,6 @@ struct xenon_priv {
>  };
>  
>  int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios);
> -void xenon_clean_phy(struct sdhci_host *host);
>  int xenon_phy_parse_dt(struct device_node *np,
>  struct sdhci_host *host);
>  void xenon_soc_pad_ctrl(struct sdhci_host *host,
> 



Re: [PATCH v2] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Arvind Yadav

Sorry, I missed it. Now I am going to add.

Thanks
-Arvind


On Wednesday 17 May 2017 12:15 PM, Viresh Kumar wrote:

On 17-05-17, 12:12, Arvind Yadav wrote:

Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

You missed my comment for the commit log.





Re: [PATCH 2/3] arm: dts: rk322x: correct uart2 pinctrl and add another sets

2017-05-16 Thread Kever Yang

Hi Frank,


On 05/17/2017 11:40 AM, Frank Wang wrote:

Correct UART2 PINCTRL flag and add another PINCTRL sets for UART2
in case of confict with SDMMC.

Signed-off-by: Frank Wang 
---
  arch/arm/boot/dts/rk322x.dtsi | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index cc6a27d..ea1239a 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -222,7 +222,7 @@
clocks = <&cru SCLK_UART2>, <&cru PCLK_UART2>;
clock-names = "baudclk", "apb_pclk";
pinctrl-names = "default";
-   pinctrl-0 = <&uart2_xfer>;
+   pinctrl-0 = <&uart21_xfer>;


There are more than one group of UART in rk322x, maybe we need to move
or add this setting in the dts file to override dtsi setting?

Thanks,
- Kever

reg-shift = <2>;
reg-io-width = <4>;
status = "disabled";
@@ -693,7 +693,7 @@
  
  		uart2 {

uart2_xfer: uart2-xfer {
-   rockchip,pins = <1 18 RK_FUNC_2 
&pcfg_pull_none>,
+   rockchip,pins = <1 18 RK_FUNC_2 &pcfg_pull_up>,
<1 19 RK_FUNC_2 
&pcfg_pull_none>;
};
  
@@ -705,5 +705,12 @@

rockchip,pins = <0 24 RK_FUNC_1 
&pcfg_pull_none>;
};
};
+
+   uart2-1 {
+   uart21_xfer: uart21-xfer {
+   rockchip,pins = <1 10 RK_FUNC_2 &pcfg_pull_up>,
+   <1 9 RK_FUNC_2 &pcfg_pull_none>;
+   };
+   };
};
  };





Re: [PATCH v4 1/1] x86, relocs: add printf attribute to die()

2017-05-16 Thread Nicolas Iooss
Hello,

The patch I sent a few months ago still applies cleanly on top of
4.12-rc1. What should I do in order to get it merged in 4.13?

In case you no longer have my initial email, the patch has been
archived in https://patchwork.kernel.org/patch/9604651/ .

Thanks,
Nicolas

On Tue, Mar 28, 2017 at 11:06 PM, Nicolas Iooss
 wrote:
> On Tue, Mar 7, 2017 at 1:37 PM, Nicolas Iooss
>  wrote:
>> On Tue, Mar 7, 2017 at 10:16 AM, Ingo Molnar  wrote:
>>>
>>> * Nicolas Iooss  wrote:
>>>
 Adding such an attribute helps to detect errors in the format string at
 build time. After doing this, the compiler complains about some issues:

 arch/x86/tools/relocs.c:460:5: error: format specifies type 'int'
 but the argument has type 'Elf64_Xword' (aka 'unsigned long')
 [-Werror,-Wformat]
 sec->shdr.sh_size);
 ^
 arch/x86/tools/relocs.c:464:5: error: format specifies type 'int'
 but the argument has type 'Elf64_Off' (aka 'unsigned long')
 [-Werror,-Wformat]
 sec->shdr.sh_offset, strerror(errno));
 ^~~

 When relocs.c is included by relocs_32.c, sec->shdr.sh_size and
 sec->shdr.sh_offset are 32-bit unsigned integers. When the file is
 included by relocs_64.c, these expressions are 64-bit unsigned integers.

 Add casts to unsigned long long, which length is always 64-bit, and use
 %llu to format sec->shdr.sh_size and sec->shdr.sh_offset in relocs.c.

 While at it, constify the format attribute of die().

 Signed-off-by: Nicolas Iooss 
 ---
  arch/x86/tools/relocs.c| 31 +--
  arch/x86/tools/relocs.h|  3 ++-
  arch/x86/tools/relocs_common.c |  2 +-
  3 files changed, 20 insertions(+), 16 deletions(-)

 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
 index 73eb7fd4aec4..3cc02065c677 100644
 --- a/arch/x86/tools/relocs.c
 +++ b/arch/x86/tools/relocs.c
 @@ -397,8 +397,8 @@ static void read_shdrs(FILE *fp)
   ehdr.e_shnum);
   }
   if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
 - die("Seek to %d failed: %s\n",
 - ehdr.e_shoff, strerror(errno));
 + die("Seek to %llu failed: %s\n",
 + (unsigned long long)ehdr.e_shoff, strerror(errno));
>>>
>>> Isn't "(u64)" shorter to write?
>>
>> u64 does not seem to be defined in this file right now. Adding
>> "#include " defines u64 and __u64 in the following way:
>> - "typedef uint64_t u64;" from tools/include/linux/types.h
>> - "typedef unsigned long long __u64;" from 
>> /usr/include/asm-generic/int-ll64.h
>>
>> uint64_t is unsigned long on x86-64 and gcc complains when using %llu
>> on such a type, so using a cast to u64 forces using PRIu64 too.
>>
>> Nevertheless "(__u64)" is shorter than "(unsigned long long)" and
>> seems to work fine in my quick tests because it is always unsigned
>> long long (on both x86-32 and x86-64). Would you prefer to use this
>> cast?
>
> Hello,
> After the question I had on the 4th revision of this patch, I have not
> received any reply or comment for three weeks. What should I do in
> order to get this merged?
>
> Thanks,
> Nicolas


Re: [PATCH v2] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Viresh Kumar
On 17-05-17, 12:12, Arvind Yadav wrote:
> Here, Clock enable can failed. So adding an error check for
> clk_prepare_enable.

You missed my comment for the commit log.

-- 
viresh


[PATCH v2] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Arvind Yadav
Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Signed-off-by: Arvind Yadav 
---
 drivers/cpufreq/kirkwood-cpufreq.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c 
b/drivers/cpufreq/kirkwood-cpufreq.c
index 1b9bcd7..c2dd43f 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
return PTR_ERR(priv.cpu_clk);
}
 
-   clk_prepare_enable(priv.cpu_clk);
+   err = clk_prepare_enable(priv.cpu_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare cpuclk\n");
+   return err;
+   }
+
kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
 
priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
@@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
goto out_cpu;
}
 
-   clk_prepare_enable(priv.ddr_clk);
+   err = clk_prepare_enable(priv.ddr_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare ddrclk\n");
+   goto out_cpu;
+   }
kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
 
priv.powersave_clk = of_clk_get_by_name(np, "powersave");
@@ -146,7 +155,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
err = PTR_ERR(priv.powersave_clk);
goto out_ddr;
}
-   clk_prepare_enable(priv.powersave_clk);
+   err = clk_prepare_enable(priv.powersave_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare powersave clk\n");
+   goto out_ddr;
+   }
 
of_node_put(np);
np = NULL;
-- 
1.9.1



Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Nikita Yushchenko
>> Code should be consistent.
>>
> 
> Yes.
> 
>> There is no good reason to have sport->lpuart32 inside sport, but
>> lpuart_is_be outside of it. Both these values describe properties of
>> particular device, and thus should be in per-device structure.
>>
> 
> That's for special case, normally we wouldn't do that.

For me this "special case" looks like "let's break data structure
consistency to reuse several lines of code".

With code snippets you show, it looks even worse: you assign same global
variable in several places for different uses. implicitly assuming that
it is for same device. Which can be true in your current system, but not
elsewhere (e.g. why not having lpuart programmed into fpga)?

Alternative solution could be - have separate write path for earlycon.
At a glance, it is dozen lines of code.


Re: [PATCH v2] perf report: distinguish between inliners in the same function

2017-05-16 Thread Namhyung Kim
On Tue, May 16, 2017 at 03:18:13PM +0200, Milian Wolff wrote:
> On Dienstag, 16. Mai 2017 02:53:32 CEST Namhyung Kim wrote:
> > On Mon, May 15, 2017 at 12:01:54PM +0200, Milian Wolff wrote:
> > > On Monday, May 15, 2017 3:21:58 AM CEST Namhyung Kim wrote:
> > > > Hi Milian,
> > > > 
> > > > On Sun, May 14, 2017 at 08:10:50PM +0200, Milian Wolff wrote:
> > > > > On Freitag, 12. Mai 2017 15:01:29 CEST Namhyung Kim wrote:
> > > > I think you'd be better adding (fake) dso and sym to keep the inline
> > > > information.  The fake dso can be paired with the original dso and
> > > > maintain a tree of (inlined) symbols.  You may need a fake map to
> > > > point the fake dso then.  It seems a bit compilcated but that way the
> > > > code will be more consistent and easier to handle (e.g. for caching
> > > > and/or deletion) IMHO.
> > > 
> > > Can you expand on this please? How would that solve the problem of finding
> > > a function name or srcline for a given inline frame?
> > > 
> > > I.e.: the function name is, currently, part of the sym. So the fake
> > > dso/map
> > > would contain an internal, fake, string table which fake symbols could
> > > leverage for the function name?
> > > 
> > > Sounds like doable, but also sounds like *a lot* of work. And I don't see
> > > how that would solve the srcline situation: That one is queried on-demand
> > > based on the IP of a frame. I would say that inline frames should keep
> > > the IP of the first non-inlined frame. But that would make it impossible
> > > to find the srcline for the N'th inlined frame... Am I missing something?
> > 
> > I agree that srcline info can be kept in callchain cursor nodes, but I
> > still think function name should be in (fake) symbols.  Sharing a
> > symbol for all inlined frames would not work for the children mode
> > IMHO.
> 
> I'm running into a bit of trouble here. I hoped to be able to store the 
> inlined symbol in the DSO to reuse it for other inlined entries that use the 
> same function. I also hope that this will then take care of the deletion of 
> the fake symbols, once the dso is freed.

I don't want to store inlined functions to an original DSO as it would
confuse symbol lookups in the DSO.  As you said those inlined
functions will have same address so multiple symbols exist for an
address.

I thought they can be kept in a fake DSO which should be linked to the
original DSO, but it doesn't need to be a DSO.  Instead a DSO can have
a tree that maintains lists of (inlined) symbols and srclines sorted
by address.


> 
> To do this, I thought I could use dso__find_symbol_by_name and, if nothing 
> was 
> found, I create the new fake symbol by symbol__new and insert it via 
> dso__insert_symbol. Apparently, I also need to update the sorted lookup 
> table, 
> so I call dso__sort_by_name, but that then leads to crashes:
> 
> ==22675== Invalid write of size 8
> ==22675==at 0x4D89FC: rb_link_node (rbtree.h:82)
> ==22675==by 0x4D89FC: symbols__insert_by_name (symbol.c:387)
> ==22675==by 0x4D89FC: symbols__sort_by_name (symbol.c:398)
> ==22675==by 0x4D89FC: dso__sort_by_name (symbol.c:512)
> ==22675==by 0x4EB704: unwind_entry (machine.c:2061)
> ==22675==by 0x55BCF7: entry (unwind-libunwind-local.c:600)
> ==22675==by 0x55BCF7: get_entries (unwind-libunwind-local.c:723)
> ==22675==by 0x55BE01: _unwind__get_entries (unwind-libunwind-local.c:745)
> ==22675==by 0x4E8B20: sample__resolve_callchain (callchain.c:1016)
> ==22675==by 0x5196F9: hist_entry_iter__add (hist.c:1039)
> ==22675==by 0x448044: process_sample_event (builtin-report.c:204)
> ==22675==by 0x4F61DD: perf_evlist__deliver_sample (session.c:1211)
> ==22675==by 0x4F61DD: machines__deliver_event (session.c:1248)
> ==22675==by 0x4F66D3: perf_session__deliver_event (session.c:1310)
> ==22675==by 0x4F66D3: ordered_events__deliver_event (session.c:119)
> ==22675==by 0x4F9CD2: __ordered_events__flush (ordered-events.c:210)
> ==22675==by 0x4F9CD2: ordered_events__flush.part.3 (ordered-events.c:277)
> ==22675==by 0x4F6DEC: perf_session__process_user_event (session.c:1349)
> ==22675==by 0x4F6DEC: perf_session__process_event (session.c:1475)
> ==22675==by 0x4F8C5C: __perf_session__process_events (session.c:1867)
> ==22675==by 0x4F8C5C: perf_session__process_events (session.c:1921)
> ==22675==  Address 0xd1fae38 is 24 bytes before a block of size 54 alloc'd
> ==22675==at 0x4C2CF35: calloc (in /usr/lib/valgrind/vgpreload_memcheck-
> amd64-linux.so)
> ==22675==by 0x4D80F0: symbol__new (symbol.c:240)
> ==22675==by 0x54750E: dso__load_sym (symbol-elf.c:1121)
> ==22675==by 0x4D9D3E: dso__load (symbol.c:1535)
> ==22675==by 0x4F262B: map__load (map.c:292)
> ==22675==by 0x4F262B: map__find_symbol (map.c:335)
> ==22675==by 0x4B3B55: thread__find_addr_location (event.c:1458)
> ==22675==by 0x55BC70: entry (unwind-libunwind-local.c:588)
> ==22675==by 0x55BC70: get_entries (unwind-lib

Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Dong Aisheng
On Wed, May 17, 2017 at 08:50:39AM +0300, Nikita Yushchenko wrote:
> >  static u32 lpuart32_read(void __iomem *addr)
> >  {
> > -   return ioread32be(addr);
> > +   return lpuart_is_be ? ioread32be(addr) : readl(addr);
> >  }
> >  
> >  static void lpuart32_write(u32 val, void __iomem *addr)
> >  {
> > -   iowrite32be(val, addr);
> > +   if (lpuart_is_be)
> > +   iowrite32be(val, addr);
> > +   else
> > +   writel(val, addr);
> >  }
> 
>  What if this is ever executed on big endian system?
> 
> >>>
> >>> Sorry, not catching the point...
> >>>
> >>> What issues will meet?
> >>
> >> Isn't writel() in host endian?
> > 
> > On big endian systems, it is supposed to run iowrite32be.
> 
> Your code states, "force BE if lpuart_is_be, don't care otherwise".
> This semantics looks questionable for code reviewer.
> If driver handles endian, should't it be explicit in both cases?
> And if indeed driver means handling BE explicitly, but don't caring
> otherwise, maybe variable name should suggest that (i.e. "force_be")?
> 

For lpuart32, only two cases that LS platforms is Big endian while
IMX is little endian.

It's SoC IP native property, i don't think force_be is better.

Regards
Dong Aisheng

> Although driver maintainer could think differently. I won't insist on this.
> 
> Nikita


[PATCH v2] hwspinlock: sprd: Add hardware spinlock driver

2017-05-16 Thread Baolin Wang
The Spreadtrum hardware spinlock device can provide hardware assistance
for synchronization between the multiple subsystems.

Signed-off-by: Baolin Wang 
---
Changes since v1:
 - Remove some unused macros and functions.
 - Convert readl/writel_relaxed() to readl/writel.
 - Remove some redundant error printing.
 - Get clock with devm_clk_get().
 - Other small optimization.
---
 drivers/hwspinlock/Kconfig   |9 ++
 drivers/hwspinlock/Makefile  |1 +
 drivers/hwspinlock/sprd_hwspinlock.c |  183 ++
 3 files changed, 193 insertions(+)
 create mode 100644 drivers/hwspinlock/sprd_hwspinlock.c

diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig
index 73a4016..02018b8 100644
--- a/drivers/hwspinlock/Kconfig
+++ b/drivers/hwspinlock/Kconfig
@@ -42,6 +42,15 @@ config HWSPINLOCK_SIRF
  It's safe to say n here if you're not interested in SIRF hardware
  spinlock or just want a bare minimum kernel.
 
+config HWSPINLOCK_SPRD
+   tristate "SPRD Hardware Spinlock device"
+   depends on ARCH_SPRD
+   select HWSPINLOCK
+   help
+ Say y here to support the SPRD Hardware Spinlock device.
+
+ If unsure, say N.
+
 config HSEM_U8500
tristate "STE Hardware Semaphore functionality"
depends on ARCH_U8500
diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile
index 6b59cb5a..14928aa 100644
--- a/drivers/hwspinlock/Makefile
+++ b/drivers/hwspinlock/Makefile
@@ -6,4 +6,5 @@ obj-$(CONFIG_HWSPINLOCK)+= hwspinlock_core.o
 obj-$(CONFIG_HWSPINLOCK_OMAP)  += omap_hwspinlock.o
 obj-$(CONFIG_HWSPINLOCK_QCOM)  += qcom_hwspinlock.o
 obj-$(CONFIG_HWSPINLOCK_SIRF)  += sirf_hwspinlock.o
+obj-$(CONFIG_HWSPINLOCK_SPRD)  += sprd_hwspinlock.o
 obj-$(CONFIG_HSEM_U8500)   += u8500_hsem.o
diff --git a/drivers/hwspinlock/sprd_hwspinlock.c 
b/drivers/hwspinlock/sprd_hwspinlock.c
new file mode 100644
index 000..638e64a
--- /dev/null
+++ b/drivers/hwspinlock/sprd_hwspinlock.c
@@ -0,0 +1,183 @@
+/*
+ * Spreadtrum hardware spinlock driver
+ * Copyright (C) 2017 Spreadtrum  - http://www.spreadtrum.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "hwspinlock_internal.h"
+
+/* hwspinlock registers definition */
+#define HWSPINLOCK_RECCTRL 0x4
+#define HWSPINLOCK_MASTERID(_X_)   (0x80 + 0x4 * (_X_))
+#define HWSPINLOCK_TOKEN(_X_)  (0x800 + 0x4 * (_X_))
+
+/* unlocked value */
+#define HWSPINLOCK_NOTTAKEN0x55aa10c5
+/* bits definition of RECCTRL reg */
+#define HWSPINLOCK_USER_BITS   0x1
+
+/* hwspinlock number */
+#define SPRD_HWLOCKS_NUM   32
+
+struct sprd_hwspinlock_dev {
+   void __iomem *base;
+   struct clk *clk;
+   struct hwspinlock_device bank;
+};
+
+/* try to lock the hardware spinlock */
+static int sprd_hwspinlock_trylock(struct hwspinlock *lock)
+{
+   struct sprd_hwspinlock_dev *sprd_hwlock =
+   dev_get_drvdata(lock->bank->dev);
+   void __iomem *addr = lock->priv;
+   int user_id, lock_id;
+
+   if (!readl(addr))
+   return 1;
+
+   lock_id = hwlock_to_id(lock);
+   /* get the hardware spinlock master/user id */
+   user_id = readl(sprd_hwlock->base + HWSPINLOCK_MASTERID(lock_id));
+   dev_warn(sprd_hwlock->bank.dev,
+"hwspinlock [%d] lock failed and master/user id = %d!\n",
+lock_id, user_id);
+   return 0;
+}
+
+/* unlock the hardware spinlock */
+static void sprd_hwspinlock_unlock(struct hwspinlock *lock)
+{
+   void __iomem *lock_addr = lock->priv;
+
+   writel(HWSPINLOCK_NOTTAKEN, lock_addr);
+}
+
+/* The specs recommended below number as the retry delay time */
+static void sprd_hwspinlock_relax(struct hwspinlock *lock)
+{
+   ndelay(10);
+}
+
+static const struct hwspinlock_ops sprd_hwspinlock_ops = {
+   .trylock = sprd_hwspinlock_trylock,
+   .unlock = sprd_hwspinlock_unlock,
+   .relax = sprd_hwspinlock_relax,
+};
+
+static int sprd_hwspinlock_probe(struct platform_device *pdev)
+{
+   struct sprd_hwspinlock_dev *sprd_hwlock;
+   struct hwspinlock *lock;
+   struct resource *res;
+   int i, ret;
+
+   if (!pdev->dev.of_node)
+   return -ENODEV;
+
+   sprd_hwlock = devm_kzalloc(&pdev->dev,
+  sizeof(struct sprd_hwspinlock_dev)

RE: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread A.S. Dong
> -Original Message-
> From: Nikita Yushchenko [mailto:nikita.yo...@cogentembedded.com]
> Sent: Wednesday, May 17, 2017 1:44 PM
> To: Dong Aisheng
> Cc: A.S. Dong; linux-ser...@vger.kernel.org; Andy Duan;
> gre...@linuxfoundation.org; Y.B. Lu; linux-kernel@vger.kernel.org;
> ste...@agner.ch; Mingkai Hu; jsl...@suse.com; linux-arm-
> ker...@lists.infradead.org
> Subject: Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit
> register support
> 
> >>> @@ -2000,6 +2007,7 @@ static int lpuart_probe(struct platform_device
> *pdev)
> >>>   }
> >>>   sport->port.line = ret;
> >>>   sport->lpuart32 = sdata->is_32;
> >>> + lpuart_is_be = sdata->is_be;
> >>
> >> Setting a global variable in per-device routine is quite bad design.
> >>
> >
> > There is a reason for that we don't want to change the exist
> > lpuart32_read[write] API which is widely used in driver.
> > Making a global lpuart_is_be is the simplest way to do it.
> >
> > Any strong blocking reason?
> 
> Code should be consistent.
> 

Yes.

> There is no good reason to have sport->lpuart32 inside sport, but
> lpuart_is_be outside of it. Both these values describe properties of
> particular device, and thus should be in per-device structure.
> 

That's for special case, normally we wouldn't do that.

> If that implies adding sport arg to lpuart32_(read|write), just do that.

There's another reason that we have to deal with earlycon which is
executed much early before driver probe.

And I need specificly align the endian data.
e.g.
static int __init lpuart32_early_console_setup(struct earlycon_device *device,
  const char *opt)
{
if (!device->port.membase)
return -ENODEV;

lpuart_is_be = true;
device->con->write = lpuart32_early_write;
return 0;
}

static int __init lpuart32_imx_early_console_setup(struct earlycon_device 
*device,
   const char *opt)
{
if (!device->port.membase)
return -ENODEV;

lpuart_is_be = false;
device->port.membase += IMX_REG_OFF;
device->con->write = lpuart32_early_write;

return 0;
}

Regards
Dong Aisheng


device tree file

2017-05-16 Thread Karthik BalaGuru T
Hi,

Can someone point me to a specific device tree file for Intel Atom processor 
for reference ?

Thanks in advance,
Karthik Balaguru
Disclaimer : 
This email communication may contain privileged and confidential information 
and is intended for the use of the addressee only. If you are not an intended 
recipient you are requested not to reproduce, copy disseminate or in any manner 
distribute this email communication as the same is strictly prohibited. If you 
have received this email in error, please notify the sender immediately by 
return e-mail and delete the communication sent in error. Email communications 
cannot be guaranteed to be secure & error free and Incedo Inc. is not liable 
for any errors in the email communication or for the proper, timely and 
complete transmission thereof.



Re: [PATCH v1] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Arvind Yadav

Yes, I will add check for powersave clk.

Thanks
- Arvind

On Wednesday 17 May 2017 10:04 AM, Viresh Kumar wrote:

On 16-05-17, 12:41, Arvind Yadav wrote:

Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Rewrite it as:

clk_prepare_enable() can fail here and we must check its return value.


Signed-off-by: Arvind Yadav 
---
  drivers/cpufreq/kirkwood-cpufreq.c | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c 
b/drivers/cpufreq/kirkwood-cpufreq.c
index 1b9bcd7..4c30103 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
return PTR_ERR(priv.cpu_clk);
}
  
-	clk_prepare_enable(priv.cpu_clk);

+   err = clk_prepare_enable(priv.cpu_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare cpuclk\n");
+   return err;
+   }
+
kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
  
  	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");

@@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
*pdev)
goto out_cpu;
}
  
-	clk_prepare_enable(priv.ddr_clk);

+   err = clk_prepare_enable(priv.ddr_clk);
+   if (err) {
+   dev_err(priv.dev, "Unable to prepare ddrclk\n");
+   goto out_cpu;
+   }
kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
  
  	priv.powersave_clk = of_clk_get_by_name(np, "powersave");

There is one more prepare-enable after this. Why not fix that as well
?





Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Nikita Yushchenko
>  static u32 lpuart32_read(void __iomem *addr)
>  {
> - return ioread32be(addr);
> + return lpuart_is_be ? ioread32be(addr) : readl(addr);
>  }
>  
>  static void lpuart32_write(u32 val, void __iomem *addr)
>  {
> - iowrite32be(val, addr);
> + if (lpuart_is_be)
> + iowrite32be(val, addr);
> + else
> + writel(val, addr);
>  }

 What if this is ever executed on big endian system?

>>>
>>> Sorry, not catching the point...
>>>
>>> What issues will meet?
>>
>> Isn't writel() in host endian?
> 
> On big endian systems, it is supposed to run iowrite32be.

Your code states, "force BE if lpuart_is_be, don't care otherwise".
This semantics looks questionable for code reviewer.
If driver handles endian, should't it be explicit in both cases?
And if indeed driver means handling BE explicitly, but don't caring
otherwise, maybe variable name should suggest that (i.e. "force_be")?

Although driver maintainer could think differently. I won't insist on this.

Nikita


rcu: NO_HZ_FULL_SYSIDLE leftovers

2017-05-16 Thread Valentin Rothberg
Hi Paul,

I stumbled upon your commit 1cb830954ef9 ("rcu: Remove nohz_full
full-system-idle state machine") as ./scripts/checkkconfigsymbols.py
reported that there are some remaining references on the removed
Kconfig symbol 'NO_HZ_FULL_SYSIDLE'. I couldn't find any commit
removing them on LKML, and as I am unsure if you like to keep the
affected code, I want to report it to you.

To get the report in linux-next:
$ checkkconfigsymbols.py --diff next-20170516..next-20170517 --find

Kind regards,
 Valentin


[PATCH] dlm: Make dismatch error message more clear

2017-05-16 Thread Gang He
This change will try to make this error message more clear,
since the upper applications (e.g. ocfs2) invoke dlm_new_lockspace
to create a new lockspace with passing a cluster name. Sometimes,
dlm_new_lockspace return failure while two cluster names dismatch,
the user is a little confused since this line error message is not
enough obvious.

Signed-off-by: Gang He 
---
 fs/dlm/lockspace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 91592b7..b03d808 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -455,7 +455,8 @@ static int new_lockspace(const char *name, const char 
*cluster,
 
if (dlm_config.ci_recover_callbacks && cluster &&
strncmp(cluster, dlm_config.ci_cluster_name, DLM_LOCKSPACE_LEN)) {
-   log_print("dlm cluster name %s mismatch %s",
+   log_print("dlm configured cluster name '%s' does not match "
+ "the passed cluster name '%s'",
  dlm_config.ci_cluster_name, cluster);
error = -EBADR;
goto out;
-- 
1.8.5.6



Re: [PATCH] usb: class: usblp: Fixed assignments inside if conditions

2017-05-16 Thread Alberto Ladron
On Tue, May 16, 2017 at 01:44:47PM +0800, kbuild test robot wrote:
Hi,

   Here is the fix.  Or I have to resubmit the whole patch?

Signed-off-by: Alberto Ladron 
---
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index b1879ff..c335878 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1018,7 +1018,7 @@ static int usblp_submit_read(struct usblp *usblp)
usblp->rcomplete = 0;
spin_unlock_irqrestore(&usblp->lock, flags);
rc = usb_submit_urb(urb, GFP_KERNEL);
-   if (rv < 0) {
+   if (rc < 0) {
dev_dbg(&usblp->intf->dev, "error submitting urb (%d)\n", rc);
spin_lock_irqsave(&usblp->lock, flags);
usblp->rstatus = rc;



> Hi Alberto,
> 
> [auto build test ERROR on usb/usb-testing]
> [also build test ERROR on v4.12-rc1 next-20170515]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Alberto-Ladron/usb-class-usblp-Fixed-assignments-inside-if-conditions/20170513-140010
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
> usb-testing
> config: x86_64-rhel (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
>drivers//usb/class/usblp.c: In function 'usblp_submit_read':
> >> drivers//usb/class/usblp.c:1021:6: error: 'rv' undeclared (first use in 
> >> this function)
>  if (rv < 0) {
>  ^~
>drivers//usb/class/usblp.c:1021:6: note: each undeclared identifier is 
> reported only once for each function it appears in
> 
> vim +/rv +1021 drivers//usb/class/usblp.c
> 
>   1005urb = usb_alloc_urb(0, GFP_KERNEL);
>   1006if (urb == NULL)
>   1007goto raise_urb;
>   1008
>   1009usb_fill_bulk_urb(urb, usblp->dev,
>   1010usb_rcvbulkpipe(usblp->dev,
>   1011  
> usblp->protocol[usblp->current_protocol].epread->bEndpointAddress),
>   1012usblp->readbuf, USBLP_BUF_SIZE_IN,
>   1013usblp_bulk_read, usblp);
>   1014usb_anchor_urb(urb, &usblp->urbs);
>   1015
>   1016spin_lock_irqsave(&usblp->lock, flags);
>   1017usblp->readcount = 0; /* XXX Why here? */
>   1018usblp->rcomplete = 0;
>   1019spin_unlock_irqrestore(&usblp->lock, flags);
>   1020rc = usb_submit_urb(urb, GFP_KERNEL);
> > 1021if (rv < 0) {
>   1022dev_dbg(&usblp->intf->dev, "error submitting 
> urb (%d)\n", rc);
>   1023spin_lock_irqsave(&usblp->lock, flags);
>   1024usblp->rstatus = rc;
>   1025usblp->rcomplete = 1;
>   1026spin_unlock_irqrestore(&usblp->lock, flags);
>   1027goto raise_submit;
>   1028}
>   1029
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation




Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Nikita Yushchenko
>>> @@ -2000,6 +2007,7 @@ static int lpuart_probe(struct platform_device *pdev)
>>> }
>>> sport->port.line = ret;
>>> sport->lpuart32 = sdata->is_32;
>>> +   lpuart_is_be = sdata->is_be;
>>
>> Setting a global variable in per-device routine is quite bad design.
>>
> 
> There is a reason for that we don't want to change the exist 
> lpuart32_read[write] API which is widely used in driver.
> Making a global lpuart_is_be is the simplest way to do it.
> 
> Any strong blocking reason?

Code should be consistent.

There is no good reason to have sport->lpuart32 inside sport, but
lpuart_is_be outside of it. Both these values describe properties of
particular device, and thus should be in per-device structure.

If that implies adding sport arg to lpuart32_(read|write), just do that.


Re: [PATCH-RFT 2/2] pinctrl: samsung: Split Exynos drivers per ARMv7 and ARMv8

2017-05-16 Thread Marek Szyprowski

Hi Krzysztof,

On 2017-05-16 22:06, Krzysztof Kozlowski wrote:

Exynos pinctrl drivers contain pretty big per-SoC data structures.  The
pinctrl-exynos object file contained code and data for both ARMv7 and
ARMv8 SoCs thus it grew big.  There will not be a shared image between
ARMv7 and ARMv8 so there is no need to combine all of this into one
driver.

Splitting the data allows to make it more granular (e.g. code related to
ARMv8 Exynos is self-contained), slightly speed up the compilation and
reduce the effective size of compiled kernel.

The common data structures and functions reside still in existing
pinctrl-exynos.c.  Only the SoC-specific parts were moved out to new
files.  Except marking few functions non-static and adding them to
header, there were no functional changes in the code.

Signed-off-by: Krzysztof Kozlowski 
---

Not tested on ARMv8 (Exynos5433, Exynos7).


Works fine on TM2 (Exynos5433).

Tested-by: Marek Szyprowski 


---
  drivers/pinctrl/samsung/Kconfig|   10 +
  drivers/pinctrl/samsung/Makefile   |2 +
  drivers/pinctrl/samsung/pinctrl-exynos-arm.c   |  815 +
  drivers/pinctrl/samsung/pinctrl-exynos-arm64.c |  399 
  drivers/pinctrl/samsung/pinctrl-exynos.c   | 1163 +---
  drivers/pinctrl/samsung/pinctrl-exynos.h   |8 +
  drivers/pinctrl/samsung/pinctrl-samsung.c  |8 +-
  7 files changed, 1245 insertions(+), 1160 deletions(-)
  create mode 100644 drivers/pinctrl/samsung/pinctrl-exynos-arm.c
  create mode 100644 drivers/pinctrl/samsung/pinctrl-exynos-arm64.c

diff --git a/drivers/pinctrl/samsung/Kconfig b/drivers/pinctrl/samsung/Kconfig
index d0461cd5d707..c33ee6293c30 100644
--- a/drivers/pinctrl/samsung/Kconfig
+++ b/drivers/pinctrl/samsung/Kconfig
@@ -10,6 +10,16 @@ config PINCTRL_EXYNOS
bool "Pinctrl driver data for Samsung EXYNOS SoCs other than 5440"
depends on OF && GPIOLIB && (ARCH_EXYNOS || ARCH_S5PV210)
select PINCTRL_SAMSUNG
+   select PINCTRL_EXYNOS_ARM if ARM && ARCH_EXYNOS
+   select PINCTRL_EXYNOS_ARM64 if ARM64 && ARCH_EXYNOS
+
+config PINCTRL_EXYNOS_ARM
+   bool "ARMv7-specific pinctrl driver data for Exynos (except 
Exynos5440)" if COMPILE_TEST
+   depends on PINCTRL_EXYNOS
+
+config PINCTRL_EXYNOS_ARM64
+   bool "ARMv8-specific pinctrl driver data for Exynos" if COMPILE_TEST
+   depends on PINCTRL_EXYNOS
  
  config PINCTRL_EXYNOS5440

bool "Samsung EXYNOS5440 SoC pinctrl driver"
diff --git a/drivers/pinctrl/samsung/Makefile b/drivers/pinctrl/samsung/Makefile
index 70160c059edd..595995851ea5 100644
--- a/drivers/pinctrl/samsung/Makefile
+++ b/drivers/pinctrl/samsung/Makefile
@@ -2,6 +2,8 @@
  
  obj-$(CONFIG_PINCTRL_SAMSUNG)	+= pinctrl-samsung.o

  obj-$(CONFIG_PINCTRL_EXYNOS)  += pinctrl-exynos.o
+obj-$(CONFIG_PINCTRL_EXYNOS_ARM)   += pinctrl-exynos-arm.o
+obj-$(CONFIG_PINCTRL_EXYNOS_ARM64) += pinctrl-exynos-arm64.o
  obj-$(CONFIG_PINCTRL_EXYNOS5440)  += pinctrl-exynos5440.o
  obj-$(CONFIG_PINCTRL_S3C24XX) += pinctrl-s3c24xx.o
  obj-$(CONFIG_PINCTRL_S3C64XX) += pinctrl-s3c64xx.o
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c 
b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
new file mode 100644
index ..62e1cc376e2e
--- /dev/null
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -0,0 +1,815 @@
+/*
+ * Exynos specific support for Samsung pinctrl/gpiolib driver with eint 
support.
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Copyright (c) 2012 Linaro Ltd
+ * http://www.linaro.org
+ *
+ * Author: Thomas Abraham 
+ *
+ * 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, or
+ * (at your option) any later version.
+ *
+ * This file contains the Samsung Exynos specific information required by the
+ * the Samsung pinctrl/gpiolib driver. It also includes the implementation of
+ * external gpio and wakeup interrupt support.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pinctrl-samsung.h"
+#include "pinctrl-exynos.h"
+
+static const struct samsung_pin_bank_type bank_type_off = {
+   .fld_width = { 4, 1, 2, 2, 2, 2, },
+   .reg_offset = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, },
+};
+
+static const struct samsung_pin_bank_type bank_type_alive = {
+   .fld_width = { 4, 1, 2, 2, },
+   .reg_offset = { 0x00, 0x04, 0x08, 0x0c, },
+};
+
+/* Retention control for S5PV210 are located at the end of clock controller */
+#define S5P_OTHERS 0xE000
+
+#define S5P_OTHERS_RET_IO  (1 << 31)
+#define S5P_OTHERS_RET_CF  (1 << 30)
+#define S5P_OTHERS_RET_MMC (1 << 29)
+#define S5P_OTHERS_RET_UART(1 << 28)
+
+static void s5pv210_retention_disable(struct samsung_pinctrl_drv_data *drvdata)
+{
+   v

Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Dong Aisheng
On Wed, May 17, 2017 at 08:37:41AM +0300, Nikita Yushchenko wrote:
> 
> 
> 17.05.2017 06:39, Dong Aisheng wrote:
> > On Tue, May 16, 2017 at 02:15:08PM +0300, Nikita Yushchenko wrote:
> >>>  static u32 lpuart32_read(void __iomem *addr)
> >>>  {
> >>> - return ioread32be(addr);
> >>> + return lpuart_is_be ? ioread32be(addr) : readl(addr);
> >>>  }
> >>>  
> >>>  static void lpuart32_write(u32 val, void __iomem *addr)
> >>>  {
> >>> - iowrite32be(val, addr);
> >>> + if (lpuart_is_be)
> >>> + iowrite32be(val, addr);
> >>> + else
> >>> + writel(val, addr);
> >>>  }
> >>
> >> What if this is ever executed on big endian system?
> >>
> > 
> > Sorry, not catching the point...
> > 
> > What issues will meet?
> 
> Isn't writel() in host endian?

On big endian systems, it is supposed to run iowrite32be.

Regards
Dong Aisheng


[PATCH 2/4] mtd: mchp23k256: switch to mtd_device_register()

2017-05-16 Thread Chris Packham
Use mtd_device_register() instead of mtd_device_parse_register() to
eliminate two unused parameters.

Signed-off-by: Chris Packham 
---
 drivers/mtd/devices/mchp23k256.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 9d8306a15833..2542f5b8b63f 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -151,9 +151,8 @@ static int mchp23k256_probe(struct spi_device *spi)
flash->mtd._read= mchp23k256_read;
flash->mtd._write   = mchp23k256_write;
 
-   err = mtd_device_parse_register(&flash->mtd, NULL, NULL,
-   data ? data->parts : NULL,
-   data ? data->nr_parts : 0);
+   err = mtd_device_register(&flash->mtd, data ? data->parts : NULL,
+ data ? data->nr_parts : 0);
if (err)
return err;
 
-- 
2.11.0.24.ge6920cf



[PATCH 3/4] mtd: mchp23k256: add partitioning support

2017-05-16 Thread Chris Packham
Setting the of_node for the mtd device allows the generic mtd code to
setup the partitions. Additionally we must specify a non-zero erasesize
for the partitions to be writeable.

Signed-off-by: Chris Packham 
---
 drivers/mtd/devices/mchp23k256.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 2542f5b8b63f..02c6b9dcbd3e 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -143,6 +143,7 @@ static int mchp23k256_probe(struct spi_device *spi)
 
data = dev_get_platdata(&spi->dev);
 
+   mtd_set_of_node(&flash->mtd, spi->dev.of_node);
flash->mtd.dev.parent   = &spi->dev;
flash->mtd.type = MTD_RAM;
flash->mtd.flags= MTD_CAP_RAM;
@@ -151,6 +152,10 @@ static int mchp23k256_probe(struct spi_device *spi)
flash->mtd._read= mchp23k256_read;
flash->mtd._write   = mchp23k256_write;
 
+   flash->mtd.erasesize = PAGE_SIZE;
+   while (flash->mtd.size & (flash->mtd.erasesize - 1))
+   flash->mtd.erasesize >>= 1;
+
err = mtd_device_register(&flash->mtd, data ? data->parts : NULL,
  data ? data->nr_parts : 0);
if (err)
-- 
2.11.0.24.ge6920cf



[PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024

2017-05-16 Thread Chris Packham
The mchp23lcv1024 is software compatible with the mchp23k256, the
only difference (from a software point of view) is the size. There
is no way to detect the size so we must be told via a Device Tree.

Signed-off-by: Chris Packham 
---
 .../bindings/mtd/microchip,mchp23k256.txt   |  2 +-
 drivers/mtd/devices/mchp23k256.c| 21 +++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt 
b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
index 25e5ad38b0f0..7328eb92a03c 100644
--- a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
+++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
@@ -3,7 +3,7 @@
 Required properties:
 - #address-cells, #size-cells : Must be present if the device has sub-nodes
   representing partitions.
-- compatible : Must be "microchip,mchp23k256"
+- compatible : Must be one of "microchip,mchp23k256" or 
"microchip,mchp23lcv1024"
 - reg : Chip-Select number
 - spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
 
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 02c6b9dcbd3e..d1eba587633c 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 
+enum chips { mchp23k256, mchp23lcv1024 };
+
 struct mchp23k256_flash {
struct spi_device   *spi;
struct mutexlock;
@@ -128,6 +130,7 @@ static int mchp23k256_probe(struct spi_device *spi)
struct mchp23k256_flash *flash;
struct flash_platform_data *data;
int err;
+   enum chips chip;
 
flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
if (!flash)
@@ -143,15 +146,28 @@ static int mchp23k256_probe(struct spi_device *spi)
 
data = dev_get_platdata(&spi->dev);
 
+   if (spi->dev.of_node)
+   chip = (enum chips)of_device_get_match_data(&spi->dev);
+   else
+   chip = mchp23k256;
+
mtd_set_of_node(&flash->mtd, spi->dev.of_node);
flash->mtd.dev.parent   = &spi->dev;
flash->mtd.type = MTD_RAM;
flash->mtd.flags= MTD_CAP_RAM;
flash->mtd.writesize= 1;
-   flash->mtd.size = SZ_32K;
flash->mtd._read= mchp23k256_read;
flash->mtd._write   = mchp23k256_write;
 
+   switch (chip){
+   case mchp23lcv1024:
+   flash->mtd.size = SZ_128K;
+   break;
+   default:
+   flash->mtd.size = SZ_32K;
+   break;
+   }
+
flash->mtd.erasesize = PAGE_SIZE;
while (flash->mtd.size & (flash->mtd.erasesize - 1))
flash->mtd.erasesize >>= 1;
@@ -172,7 +188,8 @@ static int mchp23k256_remove(struct spi_device *spi)
 }
 
 static const struct of_device_id mchp23k256_of_table[] = {
-   { .compatible = "microchip,mchp23k256" },
+   { .compatible = "microchip,mchp23k256", .data = (void *)mchp23k256 },
+   { .compatible = "microchip,mchp23lcv1024", .data = (void 
*)mchp23lcv1024 },
{}
 };
 MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
-- 
2.11.0.24.ge6920cf



[PATCH 1/4] mtd: mchp23k256: Add OF device ID table

2017-05-16 Thread Chris Packham
This allows registering of this device via a Device Tree.

Signed-off-by: Chris Packham 
---
 .../devicetree/bindings/mtd/microchip,mchp23k256.txt   | 18 ++
 drivers/mtd/devices/mchp23k256.c   |  8 
 2 files changed, 26 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt

diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt 
b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
new file mode 100644
index ..25e5ad38b0f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
@@ -0,0 +1,18 @@
+* MTD SPI driver for Microchip 23K256 (and similar) serial SRAM
+
+Required properties:
+- #address-cells, #size-cells : Must be present if the device has sub-nodes
+  representing partitions.
+- compatible : Must be "microchip,mchp23k256"
+- reg : Chip-Select number
+- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
+
+Example:
+
+   spi-sram@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "microchip,mchp23k256";
+   reg = <0>;
+   spi-max-frequency = <2000>;
+   };
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index e237db9f1bdb..9d8306a15833 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct mchp23k256_flash {
struct spi_device   *spi;
@@ -166,9 +167,16 @@ static int mchp23k256_remove(struct spi_device *spi)
return mtd_device_unregister(&flash->mtd);
 }
 
+static const struct of_device_id mchp23k256_of_table[] = {
+   { .compatible = "microchip,mchp23k256" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
+
 static struct spi_driver mchp23k256_driver = {
.driver = {
.name   = "mchp23k256",
+   .of_match_table = of_match_ptr(mchp23k256_of_table),
},
.probe  = mchp23k256_probe,
.remove = mchp23k256_remove,
-- 
2.11.0.24.ge6920cf



[PATCH 0/4] mtd: mchp23k256: device tree and mchp23lcv1024

2017-05-16 Thread Chris Packham
This series adds device tree support to the mchp23k256 driver and
support for the mchp23lcv1024 chip. I suspect there are more compatible
variants that we could now enumerate if desired.

Chris Packham (4):
  mtd: mchp23k256: Add OF device ID table
  mtd: mchp23k256: switch to mtd_device_register()
  mtd: mchp23k256: add partitioning support
  mtd: mchp23k256: Add support for mchp23lcv1024

 .../bindings/mtd/microchip,mchp23k256.txt  | 18 +++
 drivers/mtd/devices/mchp23k256.c   | 37 +++---
 2 files changed, 51 insertions(+), 4 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt

-- 
2.11.0.24.ge6920cf



Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Nikita Yushchenko


17.05.2017 06:39, Dong Aisheng wrote:
> On Tue, May 16, 2017 at 02:15:08PM +0300, Nikita Yushchenko wrote:
>>>  static u32 lpuart32_read(void __iomem *addr)
>>>  {
>>> -   return ioread32be(addr);
>>> +   return lpuart_is_be ? ioread32be(addr) : readl(addr);
>>>  }
>>>  
>>>  static void lpuart32_write(u32 val, void __iomem *addr)
>>>  {
>>> -   iowrite32be(val, addr);
>>> +   if (lpuart_is_be)
>>> +   iowrite32be(val, addr);
>>> +   else
>>> +   writel(val, addr);
>>>  }
>>
>> What if this is ever executed on big endian system?
>>
> 
> Sorry, not catching the point...
> 
> What issues will meet?

Isn't writel() in host endian?


Re: [PATCH 2/4] arm: dts: rk322x: add operating-points-v2 property for cpu

2017-05-16 Thread Viresh Kumar
On 17-05-17, 12:45, Frank Wang wrote:
> From: Finley Xiao 
> 
> This patch adds a new opp table for cpu on rk322x SoC.
> 
> Signed-off-by: Frank Wang 
> ---
>  arch/arm/boot/dts/rk322x.dtsi | 36 
>  1 file changed, 32 insertions(+), 4 deletions(-)

Acked-by: Viresh Kumar 

-- 
viresh


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

2017-05-16 Thread Takashi Iwai
On Wed, 17 May 2017 03:29:21 +0200,
Stephen Rothwell wrote:
> 
> Hi Takashi,
> 
> After merging the sound tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
> 
> In file included from include/linux/delay.h:21:0,
>  from sound/pcmcia/vx/vxp_ops.c:23:
> sound/pcmcia/vx/vxp_ops.c: In function 'vxp_dma_read':
> sound/pcmcia/vx/vxp_ops.c:406:43: error: '_chip' undeclared (first use in 
> this function)
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> include/linux/kernel.h:854:49: note: in definition of macro 'container_of'
>   const typeof( ((type *)0)->member ) *__mptr = (ptr); \
>  ^
> sound/pcmcia/vx/vxp_ops.c:406:31: note: in expansion of macro 'to_vxpocket'
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> sound/pcmcia/vx/vxp_ops.c:406:43: note: each undeclared identifier is 
> reported only once for each function it appears in
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> include/linux/kernel.h:854:49: note: in definition of macro 'container_of'
>   const typeof( ((type *)0)->member ) *__mptr = (ptr); \
>  ^
> sound/pcmcia/vx/vxp_ops.c:406:31: note: in expansion of macro 'to_vxpocket'
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> sound/pcmcia/vx/vxp_ops.c: In function 'vx_set_mic_boost':
> sound/pcmcia/vx/vxp_ops.c:470:43: error: '_chip' undeclared (first use in 
> this function)
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> include/linux/kernel.h:854:49: note: in definition of macro 'container_of'
>   const typeof( ((type *)0)->member ) *__mptr = (ptr); \
>  ^
> sound/pcmcia/vx/vxp_ops.c:470:31: note: in expansion of macro 'to_vxpocket'
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> sound/pcmcia/vx/vxp_ops.c: In function 'vx_set_mic_level':
> sound/pcmcia/vx/vxp_ops.c:512:43: error: '_chip' undeclared (first use in 
> this function)
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> include/linux/kernel.h:854:49: note: in definition of macro 'container_of'
>   const typeof( ((type *)0)->member ) *__mptr = (ptr); \
>  ^
> sound/pcmcia/vx/vxp_ops.c:512:31: note: in expansion of macro 'to_vxpocket'
>   struct snd_vxpocket *pchip = to_vxpocket(_chip);
>^
> 
> Caused by commit
> 
>   7c46696e8fef ("ALSA: vxpocket: Use container_of()")
> 
> I have used the sound tree from next-20170516 for today.

My bad, I applied the wrong version of the patch.
Now fixed and pushed out.


thanks,

Takashi


Re: [PATCH 3/4] arm: dts: rk3229: add a new cpu opp table

2017-05-16 Thread Viresh Kumar
On 17-05-17, 12:45, Frank Wang wrote:
> From: Finley Xiao 
> 
> This patch adds some new frequencies for rk3229 board.
> 
> Signed-off-by: Frank Wang 
> ---
>  arch/arm/boot/dts/rk3229-cpu-opp.dtsi | 85 
> +++
>  1 file changed, 85 insertions(+)
>  create mode 100644 arch/arm/boot/dts/rk3229-cpu-opp.dtsi

Acked-by: Viresh Kumar 

-- 
viresh


Re: [kbuild-all] [PATCH v4 2/3] hwmon: (adt7475) temperature smoothing

2017-05-16 Thread Guenter Roeck

On 05/16/2017 09:39 PM, Ye Xiaolong wrote:

On 05/17, Chris Packham wrote:

On 17/05/17 15:09, Ye Xiaolong wrote:

On 05/16, Chris Packham wrote:

On 16/05/17 20:23, kbuild test robot wrote:

Hi Chris,

[auto build test ERROR on hwmon/hwmon-next]
[also build test ERROR on v4.12-rc1 next-20170516]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Chris-Packham/hwmon-adt7475-fan-stall-prevention/20170515-093530
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
hwmon-next
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

   drivers/hwmon/adt7475.c: In function 'set_temp_st':

drivers/hwmon/adt7475.c:622:9: error: implicit declaration of function 
'find_closest_descending' [-Werror=implicit-function-declaration]

  val = find_closest_descending(val, ad7475_st_map,
^~~
   cc1: some warnings being treated as errors

vim +/find_closest_descending +622 drivers/hwmon/adt7475.c

   616  shift = 4;
   617  idx = 1;
   618  break;
   619  }
   620  
   621  if (val > 0) {
 > 622   val = find_closest_descending(val, ad7475_st_map,
   623
ARRAY_SIZE(ad7475_st_map));
   624  val |= 0x8;
   625  }

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



I'm not sure how this is failing. find_closest_descending() is a macro
defined in linux/util_macros.h which is explicitly included in
drivers/hwmon/adt7475.c. Aside from the include guards there's nothing
conditional about it.


Hi,

0day bot applied your patchset on top of commit 6eaaea1 ("hwmon: (pmbus) Add client 
driver for IR35221"),
is it wrong or you have some prerequisite patches?


Thanks for the info, seems we need to improve the kbuild bot by pulling the
latest tree before applying new patches.



No worries. I don't mind the occasional false positive. Better a false positive 
than a missed bug.

Guenter


Thanks,
Xiaolong




Looks like it's missing
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?h=hwmon-next&id=bbb4dd0ff
which was part of the series but was applied after v3 so I didn't send
it out with v4.






Re: [PATCH 03/18] xen/pvcalls: initialize the module and register the xenbus backend

2017-05-16 Thread Juergen Gross
On 16/05/17 21:58, Stefano Stabellini wrote:
> On Tue, 16 May 2017, Juergen Gross wrote:
>> On 15/05/17 22:35, Stefano Stabellini wrote:
>>> The pvcalls backend has one ioworker per cpu: the ioworkers are
>>> implemented as a cpu bound workqueue, and will deal with the actual
>>> socket and data ring reads/writes.
>>>
>>> ioworkers are global: we only have one set for all the frontends. They
>>> process requests on their wqs list in order, once they are done with a
>>> request, they'll remove it from the list. A spinlock is used for
>>> protecting the list. Each ioworker is bound to a different cpu to
>>> maximize throughput.
>>>
>>> Signed-off-by: Stefano Stabellini 
>>> CC: boris.ostrov...@oracle.com
>>> CC: jgr...@suse.com
>>> ---
>>>  drivers/xen/pvcalls-back.c | 64 
>>> ++
>>>  1 file changed, 64 insertions(+)
>>>
>>> diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
>>> index 2dbf7d8..46a889a 100644
>>> --- a/drivers/xen/pvcalls-back.c
>>> +++ b/drivers/xen/pvcalls-back.c
>>> @@ -25,6 +25,26 @@
>>>  #include 
>>>  #include 
>>>  
>>> +struct pvcalls_ioworker {
>>> +   struct work_struct register_work;
>>> +   atomic_t io;
>>> +   struct list_head wqs;
>>> +   spinlock_t lock;
>>> +   int num;
>>> +};
>>> +
>>> +struct pvcalls_back_global {
>>> +   struct pvcalls_ioworker *ioworkers;
>>> +   int nr_ioworkers;
>>> +   struct workqueue_struct *wq;
>>> +   struct list_head privs;
>>> +   struct rw_semaphore privs_lock;
>>> +} pvcalls_back_global;
>>> +
>>> +static void pvcalls_back_ioworker(struct work_struct *work)
>>> +{
>>> +}
>>> +
>>>  static int pvcalls_back_probe(struct xenbus_device *dev,
>>>   const struct xenbus_device_id *id)
>>>  {
>>> @@ -59,3 +79,47 @@ static int pvcalls_back_uevent(struct xenbus_device 
>>> *xdev,
>>> .uevent = pvcalls_back_uevent,
>>> .otherend_changed = pvcalls_back_changed,
>>>  };
>>> +
>>> +static int __init pvcalls_back_init(void)
>>> +{
>>> +   int ret, i, cpu;
>>> +
>>> +   if (!xen_domain())
>>> +   return -ENODEV;
>>> +
>>> +   ret = xenbus_register_backend(&pvcalls_back_driver);
>>> +   if (ret < 0)
>>> +   return ret;
>>> +
>>> +   init_rwsem(&pvcalls_back_global.privs_lock);
>>> +   INIT_LIST_HEAD(&pvcalls_back_global.privs);
>>> +   pvcalls_back_global.wq = alloc_workqueue("pvcalls_io", 0, 0);
>>> +   if (!pvcalls_back_global.wq)
>>> +   goto error;
>>> +   pvcalls_back_global.nr_ioworkers = num_online_cpus();
>>
>> Really? Recently I cam across a system with 640 dom0 cpus. I don't think
>> we want 640 workers initialized when loading the backend module. I'd
>> prefer one or a few workers per connected frontend.
> 
> I think we want to keep the ioworker allocation to be based on the
> number of vcpus: we do not want more ioworkers than vcpus because it is
> a waste of resources and leads to worse performance.  Also, given that
> they do memcpy's, I also think it is a good idea to bind them to vcpus
> (and pin vcpus to pcpus) to get best performance.

This will cause a lot of pain for the cpu offline case. Please don't try
to work against the hypervisor scheduler by designing a backend based on
a vcpu pin policy. This might result in best performance for your
special workload, but generally it is a bad idea!

> However, you have a point there: we need to handle systems with an
> extremely large number of Dom0 vcpus. I suggest we introduce an
> upper limit for the number of ioworkers. Something like:
> 
> #define MAX_IOWORKERS 64
> nr_ioworkers = min(MAX_IOWORKERS, num_online_cpus())
> 
> MAX_IOWORKERS could be configurable via a command line option.

Later you are assigning each active socket to exactly one ioworker.
Wouldn't it make more sense to allocate the ioworker when doing
the connect? This would avoid the problem of having only a statistical
distribution, possibly with all sockets on the same ioworker.

Basically you are re-inventing the wheel by using an own workqueue
implementation in each ioworker looping through all assigned sockets.


Juergen


Re: [PATCH] iommu: of: Fix check for returning EPROBE_DEFER

2017-05-16 Thread Sricharan R
Hi,

On 5/16/2017 7:39 PM, Jonathan Neuschäfer wrote:
> Hi, I have a few suggestions on how to make this commit message more
> readable:
> 
> On Tue, May 16, 2017 at 10:54:13AM +0530, Sricharan R wrote:
>> While returning EPROBE_DEFER for iommu masters
> 
> Add a comma at the end of this line
> 
>> take in to account of iommu nodes that could be
> 
> s/in to/into/
> s/of iommu/of_iommu/
> 

ok, will correct the above.

Regards,
 Sricharan

>> marked in DT as 'status=disabled', in which case
>> simply return NULL and let the master's probe
>> continue rather than deferring.
>>
>> Signed-off-by: Sricharan R 
>> Tested-by: Will Deacon 
>> Acked-by: Will Deacon 
> 
> 
> Thanks,
> Jonathan Neuschäfer
> 

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


Re: [PATCH v2] perf report: fix off-by-one for non-activation frames

2017-05-16 Thread Namhyung Kim
On Tue, May 16, 2017 at 06:26:47PM +0200, Milian Wolff wrote:
> On Dienstag, 16. Mai 2017 18:17:26 CEST Milian Wolff wrote:
> > On Dienstag, 16. Mai 2017 16:38:29 CEST Namhyung Kim wrote:
> > > On Tue, May 16, 2017 at 10:59:51AM +0200, Milian Wolff wrote:
> > > > As the documentation for dwfl_frame_pc says, frames that
> > > > are no activation frames need to have their program counter
> > > > decremented by one to properly find the function of the caller.
> > > > 
> > > > This fixes many cases where perf report currently attributes
> > > > the cost to the next line. I.e. I have code like this:
> > > > 
> > > > ~~~
> > > > 
> > > >   #include 
> > > >   #include 
> > > >   
> > > >   using namespace std;
> > > >   
> > > >   int main()
> > > >   {
> > > >   
> > > > this_thread::sleep_for(chrono::milliseconds(1000));
> > > > this_thread::sleep_for(chrono::milliseconds(100));
> > > > this_thread::sleep_for(chrono::milliseconds(10));
> > > > 
> > > > return 0;
> > > >   
> > > >   }
> > > > 
> > > > ~~~
> > > 
> > > It'd be nice if the test program has a signal frame for verification.
> > 
> > I have pretty much zero experience about signals. Would it be enough to add
> > a signal handler for, say, SIGUSR1 to my test application and then trigger
> > a sleep when that signal is delivered? If that should be enough, I'll write
> > and test it out.
> 
> ~~~
> #include 
> #include 
> #include 
> 
> using namespace std;
> 
> volatile bool run_loop = true;
> 
> void my_handler(int signum)
> {
> this_thread::sleep_for(chrono::milliseconds(1000));
> this_thread::sleep_for(chrono::milliseconds(100));
> this_thread::sleep_for(chrono::milliseconds(10));
> run_loop = false;
> }
> 
> int main()
> {
> signal(SIGUSR1, my_handler);
> 
> while (run_loop) {}
> 
> return 0;
> }
> ~~~
> 
> This does not properly unwind neither before nor after this patch. I only 
> ever 
> get:
> 
>100.00%  core.c:0
> |
> ---__schedule core.c:0
>schedule
>do_nanosleep hrtimer.c:0
>hrtimer_nanosleep
>sys_nanosleep
>entry_SYSCALL_64_fastpath .tmp_entry_64.o:0
>__nanosleep_nocancel .:0
>std::this_thread::sleep_for > 
> thread:323
> 
> So... should this work? Please tell me how to test this properly.

How did you send the SIGUSR1 to the process?

Anyway it does nothing to do with inlining, right?  I just wrote a
test code below to burn a cpu with or without a signal frame.

  $ nl -ba frame-addr.c
 1  #include 
 2  #include 
 3  #include 
 4  
 5  #define __noinline  __attribute__((noinline))
 6  
 7  __noinline void bar(void)
 8  {
 9volatile long cnt = 0;
10  
11for (cnt = 0; cnt < 1; cnt++);
12  }
13  
14  __noinline void foo(void)
15  {
16bar();
17  }
18  
19  void sig_handler(int sig)
20  {
21foo();
22  }
23  
24  int main(void)
25  {
26signal(SIGUSR1, sig_handler);
27raise(SIGUSR1);
28  
29foo();
30return 0;
31  }

  $ gcc -O2 -g -fno-optimize-sibling-calls -o frame-addr frame-addr.c

  $ perf record --call-graph dwarf ./frame-addr

  $ perf report -q -g srcline | head -15
  99.88%  frame-addr  frame-addr[.] bar
  |
  ---bar frame-addr.c:11
 foo frame-addr.c:16
 |  
 |--51.12%--main frame-addr.c:29
 |  __libc_start_main
 |  _start
 |  
  --48.76%--sig_handler frame-addr.c:21
0x33a8f
raise .:0
main frame-addr.c:29   <--- bad
__libc_start_main
_start

Note that 'raise' was called at line 27.  It seems that simply
checking current frame fixes it.

Thanks,
Namhyung



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

2017-05-16 Thread Willem de Bruijn
On Tue, May 16, 2017 at 11:45 PM, Stephen Rothwell  
wrote:
> Hi all,
>
> After merging the netfilter tree, today's linux-next build (i386
> defconfig) failed like this:
>
> net/netfilter/x_tables.c: In function 'xt_match_to_user':
> net/netfilter/x_tables.c:303:13: error: implicit declaration of function 
> 'COMPAT_XT_ALIGN' [-Werror=implicit-function-declaration]
> C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) :  \
>  ^
> net/netfilter/x_tables.c:310:9: note: in expansion of macro 'XT_DATA_TO_USER'
>  XT_DATA_TO_USER(u, m, match, 0);
>  ^
>
> Caused by commit
>
>   324318f0248c ("netfilter: xtables: zero padding in data_to_user")
>
> In the !CONFIG_COMPAT case C_SIZE will always be zero, but the compiler
> is still looking for the macro :-(

Apologies for the breakage.

> I added this cludge patch (I am sure it can be done better):
>
> From: Stephen Rothwell 
> Date: Wed, 17 May 2017 13:36:26 +1000
> Subject: [PATCH] netfilter: xtables: fix for zero padding in data_to_user
>
> Signed-off-by: Stephen Rothwell 
> ---
>  net/netfilter/x_tables.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index d17769599c10..2b1785993a92 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -296,12 +296,20 @@ int xt_data_to_user(void __user *dst, const void *src,
>  }
>  EXPORT_SYMBOL_GPL(xt_data_to_user);
>
> +#ifdef CONFIG_COMPAT
>  #define XT_DATA_TO_USER(U, K, TYPE, C_SIZE)\
> xt_data_to_user(U->data, K->data,   \
> K->u.kernel.TYPE->usersize, \
> C_SIZE ? : K->u.kernel.TYPE->TYPE##size,\
> C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) :  \
>  XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
> +#else
> +#define XT_DATA_TO_USER(U, K, TYPE, C_SIZE)\
> +   xt_data_to_user(U->data, K->data,   \
> +   K->u.kernel.TYPE->usersize, \
> +   C_SIZE ? : K->u.kernel.TYPE->TYPE##size,\
> +   C_SIZE ? : XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
> +#endif
>

I will send a patch to the netfilter to define a separate
COMPAT_XT_DATA_TO_USER inside the CONFIG_COMPAT region further down
the file. This also allows simplifying XT_DATA_TO_USER by removing
those ternary statements.

-#define XT_DATA_TO_USER(U, K, TYPE, C_SIZE)\
+#define XT_DATA_TO_USER(U, K, TYPE)\
xt_data_to_user(U->data, K->data,   \
K->u.kernel.TYPE->usersize, \
-   C_SIZE ? : K->u.kernel.TYPE->TYPE##size,\
-   C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) :  \
-XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
+   K->u.kernel.TYPE->TYPE##size,   \
+   XT_ALIGN(K->u.kernel.TYPE->TYPE##size))

and

+#define COMPAT_XT_DATA_TO_USER(U, K, TYPE, C_SIZE) \
+   xt_data_to_user(U->data, K->data,   \
+   K->u.kernel.TYPE->usersize, \
+   C_SIZE, \
+   COMPAT_XT_ALIGN(C_SIZE))
+


Re: linux-next: build warning after merge of the overlayfs tree

2017-05-16 Thread Amir Goldstein
On Wed, May 17, 2017 at 3:19 AM, Stephen Rothwell  wrote:
> Hi Miklos,
>
> After merging the overlayfs tree, today's linux-next build (powerpc
> ppc64_defconfig) produced this warning:
>
> fs/overlayfs/dir.c: In function 'ovl_rename':
> fs/overlayfs/dir.c:1060:2: warning: 'newdentry' may be used uninitialized in 
> this function [-Wmaybe-uninitialized]
>   dput(newdentry);
>   ^
> fs/overlayfs/dir.c:1062:2: warning: 'olddentry' may be used uninitialized in 
> this function [-Wmaybe-uninitialized]
>   dput(olddentry);
>   ^
>
> Introduced by commit
>
>   02cac3227a28 ("ovl: mark upper dir with type origin entries "impure"")
>

Posted a fix for that ("ovl: fix wrong error handling of ovl_set_impure()")

Thanks!


[PATCH 3/4] arm: dts: rk3229: add a new cpu opp table

2017-05-16 Thread Frank Wang
From: Finley Xiao 

This patch adds some new frequencies for rk3229 board.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk3229-cpu-opp.dtsi | 85 +++
 1 file changed, 85 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3229-cpu-opp.dtsi

diff --git a/arch/arm/boot/dts/rk3229-cpu-opp.dtsi 
b/arch/arm/boot/dts/rk3229-cpu-opp.dtsi
new file mode 100644
index 000..89e8413
--- /dev/null
+++ b/arch/arm/boot/dts/rk3229-cpu-opp.dtsi
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * 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 library 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 library 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 "AS IS", 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.
+ */
+
+/ {
+   /delete-node/ opp-table0;
+
+   cpu0_opp_table: opp_table0 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp-40800 {
+   opp-hz = /bits/ 64 <40800>;
+   opp-microvolt = <95>;
+   clock-latency-ns = <4>;
+   opp-suspend;
+   };
+   opp-6 {
+   opp-hz = /bits/ 64 <6>;
+   opp-microvolt = <975000>;
+   };
+   opp-81600 {
+   opp-hz = /bits/ 64 <81600>;
+   opp-microvolt = <100>;
+   };
+   opp-100800 {
+   opp-hz = /bits/ 64 <100800>;
+   opp-microvolt = <1175000>;
+   };
+   opp-12 {
+   opp-hz = /bits/ 64 <12>;
+   opp-microvolt = <1275000>;
+   };
+   opp-129600 {
+   opp-hz = /bits/ 64 <129600>;
+   opp-microvolt = <1325000>;
+   };
+   opp-139200 {
+   opp-hz = /bits/ 64 <139200>;
+   opp-microvolt = <1375000>;
+   };
+   opp-146400 {
+   opp-hz = /bits/ 64 <146400>;
+   opp-microvolt = <140>;
+   };
+   };
+};
-- 
2.0.0




[PATCH 2/4] arm: dts: rk322x: add operating-points-v2 property for cpu

2017-05-16 Thread Frank Wang
From: Finley Xiao 

This patch adds a new opp table for cpu on rk322x SoC.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 36 
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index 40044e8..7809e56 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -66,10 +66,7 @@
compatible = "arm,cortex-a7";
reg = <0xf00>;
resets = <&cru SRST_CORE0>;
-   operating-points = <
-   /* KHzuV */
-816000 100
-   >;
+   operating-points-v2 = <&cpu0_opp_table>;
#cooling-cells = <2>; /* min followed by max */
clock-latency = <4>;
clocks = <&cru ARMCLK>;
@@ -80,6 +77,7 @@
compatible = "arm,cortex-a7";
reg = <0xf01>;
resets = <&cru SRST_CORE1>;
+   operating-points-v2 = <&cpu0_opp_table>;
};
 
cpu2: cpu@f02 {
@@ -87,6 +85,7 @@
compatible = "arm,cortex-a7";
reg = <0xf02>;
resets = <&cru SRST_CORE2>;
+   operating-points-v2 = <&cpu0_opp_table>;
};
 
cpu3: cpu@f03 {
@@ -94,6 +93,35 @@
compatible = "arm,cortex-a7";
reg = <0xf03>;
resets = <&cru SRST_CORE3>;
+   operating-points-v2 = <&cpu0_opp_table>;
+   };
+   };
+
+   cpu0_opp_table: opp_table0 {
+   compatible = "operating-points-v2";
+   opp-shared;
+
+   opp-40800 {
+   opp-hz = /bits/ 64 <40800>;
+   opp-microvolt = <95>;
+   clock-latency-ns = <4>;
+   opp-suspend;
+   };
+   opp-6 {
+   opp-hz = /bits/ 64 <6>;
+   opp-microvolt = <975000>;
+   };
+   opp-81600 {
+   opp-hz = /bits/ 64 <81600>;
+   opp-microvolt = <100>;
+   };
+   opp-100800 {
+   opp-hz = /bits/ 64 <100800>;
+   opp-microvolt = <1175000>;
+   };
+   opp-12 {
+   opp-hz = /bits/ 64 <12>;
+   opp-microvolt = <1275000>;
};
};
 
-- 
2.0.0




[PATCH 0/4] amend some properties related clk and cpu for rk322x

2017-05-16 Thread Frank Wang
These series of patches amend some assigned-clocks and add cpu opp table
for rk322x SoCs.

the following patches on patchwork are required for this changes.
https://patchwork.kernel.org/patch/9627639/
https://patchwork.kernel.org/patch/9703945/
https://patchwork.kernel.org/patch/9703939/
https://patchwork.kernel.org/patch/9707517/

Elaine Zhang (1):
  arm: dts: rk322x: add some assigned-clocks

Finley Xiao (2):
  arm: dts: rk322x: add operating-points-v2 property for cpu
  arm: dts: rk3229: add a new cpu opp table

Rocky Hao (1):
  arm: dts: rk322x: update tsadc's frequence setting

 arch/arm/boot/dts/rk3229-cpu-opp.dtsi | 85 +++
 arch/arm/boot/dts/rk322x.dtsi | 52 ++---
 2 files changed, 131 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/boot/dts/rk3229-cpu-opp.dtsi

-- 
2.0.0




[PATCH 1/4] arm: dts: rk322x: add some assigned-clocks

2017-05-16 Thread Frank Wang
From: Elaine Zhang 

Add CPLL, GPLL and some other assigned-clocks for rk322x SoC.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index 221251a..40044e8 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -346,8 +346,18 @@
rockchip,grf = <&grf>;
#clock-cells = <1>;
#reset-cells = <1>;
-   assigned-clocks = <&cru PLL_GPLL>;
-   assigned-clock-rates = <59400>;
+   assigned-clocks =
+   <&cru PLL_GPLL>, <&cru ARMCLK>,
+   <&cru PLL_CPLL>, <&cru ACLK_PERI>,
+   <&cru HCLK_PERI>, <&cru PCLK_PERI>,
+   <&cru ACLK_CPU>, <&cru HCLK_CPU>,
+   <&cru PCLK_CPU>;
+   assigned-clock-rates =
+   <59400>, <81600>,
+   <5>, <15000>,
+   <15000>, <7500>,
+   <15000>, <15000>,
+   <7500>;
};
 
thermal-zones {
-- 
2.0.0




[PATCH 4/4] arm: dts: rk322x: update tsadc's frequence setting

2017-05-16 Thread Frank Wang
From: Rocky Hao 

Update freq of tsadc's working clock as 32768 hz, if not set, tsadc
will work at a default frequence.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index 7809e56..d2e9641 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -434,6 +434,8 @@
interrupts = ;
clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
clock-names = "tsadc", "apb_pclk";
+   assigned-clocks = <&cru SCLK_TSADC>;
+   assigned-clock-rates = <32768>;
resets = <&cru SRST_TSADC>;
reset-names = "tsadc-apb";
pinctrl-names = "init", "default", "sleep";
-- 
2.0.0




[PATCH 2/4] PM / OPP: Don't create copy of regulators unnecessarily

2017-05-16 Thread Viresh Kumar
This code was required while the OPP core was managed with help of RCUs,
but not anymore. Get rid of unnecessary alloc/memcpy operations.

Signed-off-by: Viresh Kumar 
---
 drivers/base/power/opp/core.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 402b9e86d77c..898f19ea0f60 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -180,7 +180,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device 
*dev)
 {
struct opp_table *opp_table;
struct dev_pm_opp *opp;
-   struct regulator *reg, **regulators;
+   struct regulator *reg;
unsigned long latency_ns = 0;
int ret, i, count;
struct {
@@ -198,15 +198,9 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct 
device *dev)
if (!count)
goto put_opp_table;
 
-   regulators = kmalloc_array(count, sizeof(*regulators), GFP_KERNEL);
-   if (!regulators)
-   goto put_opp_table;
-
uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
if (!uV)
-   goto free_regulators;
-
-   memcpy(regulators, opp_table->regulators, count * sizeof(*regulators));
+   goto put_opp_table;
 
mutex_lock(&opp_table->lock);
 
@@ -232,15 +226,13 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct 
device *dev)
 * isn't freed, while we are executing this routine.
 */
for (i = 0; i < count; i++) {
-   reg = regulators[i];
+   reg = opp_table->regulators[i];
ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max);
if (ret > 0)
latency_ns += ret * 1000;
}
 
kfree(uV);
-free_regulators:
-   kfree(regulators);
 put_opp_table:
dev_pm_opp_put_opp_table(opp_table);
 
-- 
2.13.0.303.g4ebf3021692d



Re: [kbuild-all] [PATCH v4 2/3] hwmon: (adt7475) temperature smoothing

2017-05-16 Thread Ye Xiaolong
On 05/17, Chris Packham wrote:
>On 17/05/17 15:09, Ye Xiaolong wrote:
>> On 05/16, Chris Packham wrote:
>>> On 16/05/17 20:23, kbuild test robot wrote:
>>>> Hi Chris,
>>>>
>>>> [auto build test ERROR on hwmon/hwmon-next]
>>>> [also build test ERROR on v4.12-rc1 next-20170516]
>>>> [if your patch is applied to the wrong git tree, please drop us a note to 
>>>> help improve the system]
>>>>
>>>> url:
>>>> https://github.com/0day-ci/linux/commits/Chris-Packham/hwmon-adt7475-fan-stall-prevention/20170515-093530
>>>> base:   
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
>>>> hwmon-next
>>>> config: x86_64-rhel (attached as .config)
>>>> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
>>>> reproduce:
>>>> # save the attached .config to linux build tree
>>>> make ARCH=x86_64
>>>>
>>>> All errors (new ones prefixed by >>):
>>>>
>>>>drivers/hwmon/adt7475.c: In function 'set_temp_st':
>>>>>> drivers/hwmon/adt7475.c:622:9: error: implicit declaration of function 
>>>>>> 'find_closest_descending' [-Werror=implicit-function-declaration]
>>>>   val = find_closest_descending(val, ad7475_st_map,
>>>> ^~~
>>>>cc1: some warnings being treated as errors
>>>>
>>>> vim +/find_closest_descending +622 drivers/hwmon/adt7475.c
>>>>
>>>>616 shift = 4;
>>>>617 idx = 1;
>>>>618 break;
>>>>619 }
>>>>620 
>>>>621 if (val > 0) {
>>>>  > 622 val = find_closest_descending(val, 
>>>> ad7475_st_map,
>>>>623   
>>>> ARRAY_SIZE(ad7475_st_map));
>>>>624 val |= 0x8;
>>>>625 }
>>>>
>>>> ---
>>>> 0-DAY kernel test infrastructureOpen Source Technology 
>>>> Center
>>>> https://lists.01.org/pipermail/kbuild-all   Intel 
>>>> Corporation
>>>>
>>>
>>> I'm not sure how this is failing. find_closest_descending() is a macro
>>> defined in linux/util_macros.h which is explicitly included in
>>> drivers/hwmon/adt7475.c. Aside from the include guards there's nothing
>>> conditional about it.
>>
>> Hi,
>>
>> 0day bot applied your patchset on top of commit 6eaaea1 ("hwmon: (pmbus) Add 
>> client driver for IR35221"),
>> is it wrong or you have some prerequisite patches?

Thanks for the info, seems we need to improve the kbuild bot by pulling the
latest tree before applying new patches.

Thanks,
Xiaolong
>>
>
>Looks like it's missing 
>https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?h=hwmon-next&id=bbb4dd0ff
> 
>which was part of the series but was applied after v3 so I didn't send 
>it out with v4.


[PATCH 3/4] PM / OPP: opp-microvolt is not optional if regulators are set

2017-05-16 Thread Viresh Kumar
If dev_pm_opp_set_regulators() is called for a device and its regulators
are set in the OPP core, the OPP nodes for the device must contain the
"opp-microvolt" property, otherwise there is something wrong and we
better error out.

Signed-off-by: Viresh Kumar 
---
 drivers/base/power/opp/of.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/opp/of.c b/drivers/base/power/opp/of.c
index 779428676f63..c6fc8cbad10d 100644
--- a/drivers/base/power/opp/of.c
+++ b/drivers/base/power/opp/of.c
@@ -131,8 +131,15 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, 
struct device *dev,
prop = of_find_property(opp->np, name, NULL);
 
/* Missing property isn't a problem, but an invalid entry is */
-   if (!prop)
-   return 0;
+   if (!prop) {
+   /* The regulator-count must be zero here */
+   if (!opp_table->regulator_count)
+   return 0;
+
+   dev_err(dev, "%s: opp-microvolt missing even if 
regulators are available\n",
+   __func__);
+   return -EINVAL;
+   }
}
 
vcount = of_property_count_u32_elems(opp->np, name);
-- 
2.13.0.303.g4ebf3021692d



[PATCH 4/4] PM / OPP: Don't create debugfs "supply-0" directory unnecessarily

2017-05-16 Thread Viresh Kumar
We create "supply-0" debugfs directory even if the device doesn't do
voltage scaling. That looks confusing, as if the regulator is found but
we never managed to get voltage levels for it.

Avoid creating such a directory unnecessarily.

Signed-off-by: Viresh Kumar 
---
 drivers/base/power/opp/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c
index 95f433db4ac7..ce6f4832946b 100644
--- a/drivers/base/power/opp/debugfs.c
+++ b/drivers/base/power/opp/debugfs.c
@@ -40,11 +40,11 @@ static bool opp_debug_create_supplies(struct dev_pm_opp 
*opp,
  struct dentry *pdentry)
 {
struct dentry *d;
-   int i = 0;
+   int i = -1;
char *name;
 
/* Always create at least supply-0 directory */
-   do {
+   while (++i < opp_table->regulator_count) {
name = kasprintf(GFP_KERNEL, "supply-%d", i);
 
/* Create per-opp directory */
@@ -70,7 +70,7 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
  &opp->supplies[i].u_amp))
return false;
-   } while (++i < opp_table->regulator_count);
+   }
 
return true;
 }
-- 
2.13.0.303.g4ebf3021692d



[PATCH 1/4] PM / OPP: Reorganize _generic_set_opp_regulator()

2017-05-16 Thread Viresh Kumar
The code was overly complicated here because of the limitations that we
had with RCUs (Couldn't use opp-table and OPPs outside RCU protected
section and can't call sleep-able routines from within that). But that
is long gone now.

Reorganize _generic_set_opp_regulator() in order to avoid using "struct
dev_pm_set_opp_data" and copying data into it for the case where
opp_table->set_opp is not set.

Signed-off-by: Viresh Kumar 
---
 drivers/base/power/opp/core.c | 73 ---
 1 file changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index dae61720b314..402b9e86d77c 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -543,17 +543,18 @@ _generic_set_opp_clk_only(struct device *dev, struct clk 
*clk,
return ret;
 }
 
-static int _generic_set_opp(struct dev_pm_set_opp_data *data)
+static int _generic_set_opp_regulator(struct opp_table *opp_table,
+ struct device *dev,
+ unsigned long old_freq,
+ unsigned long freq,
+ struct dev_pm_opp_supply *old_supply,
+ struct dev_pm_opp_supply *new_supply)
 {
-   struct dev_pm_opp_supply *old_supply = data->old_opp.supplies;
-   struct dev_pm_opp_supply *new_supply = data->new_opp.supplies;
-   unsigned long old_freq = data->old_opp.rate, freq = data->new_opp.rate;
-   struct regulator *reg = data->regulators[0];
-   struct device *dev= data->dev;
+   struct regulator *reg = opp_table->regulators[0];
int ret;
 
/* This function only supports single regulator per device */
-   if (WARN_ON(data->regulator_count > 1)) {
+   if (WARN_ON(opp_table->regulator_count > 1)) {
dev_err(dev, "multiple regulators are not supported\n");
return -EINVAL;
}
@@ -566,7 +567,7 @@ static int _generic_set_opp(struct dev_pm_set_opp_data 
*data)
}
 
/* Change frequency */
-   ret = _generic_set_opp_clk_only(dev, data->clk, old_freq, freq);
+   ret = _generic_set_opp_clk_only(dev, opp_table->clk, old_freq, freq);
if (ret)
goto restore_voltage;
 
@@ -580,12 +581,12 @@ static int _generic_set_opp(struct dev_pm_set_opp_data 
*data)
return 0;
 
 restore_freq:
-   if (_generic_set_opp_clk_only(dev, data->clk, freq, old_freq))
+   if (_generic_set_opp_clk_only(dev, opp_table->clk, freq, old_freq))
dev_err(dev, "%s: failed to restore old-freq (%lu Hz)\n",
__func__, old_freq);
 restore_voltage:
/* This shouldn't harm even if the voltages weren't updated earlier */
-   if (old_supply->u_volt)
+   if (old_supply)
_set_opp_voltage(dev, reg, old_supply);
 
return ret;
@@ -603,10 +604,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long 
target_freq)
 {
struct opp_table *opp_table;
unsigned long freq, old_freq;
-   int (*set_opp)(struct dev_pm_set_opp_data *data);
struct dev_pm_opp *old_opp, *opp;
-   struct regulator **regulators;
-   struct dev_pm_set_opp_data *data;
struct clk *clk;
int ret, size;
 
@@ -661,38 +659,35 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long 
target_freq)
dev_dbg(dev, "%s: switching OPP: %lu Hz --> %lu Hz\n", __func__,
old_freq, freq);
 
-   regulators = opp_table->regulators;
-
/* Only frequency scaling */
-   if (!regulators) {
+   if (!opp_table->regulators) {
ret = _generic_set_opp_clk_only(dev, clk, old_freq, freq);
-   goto put_opps;
-   }
+   } else if (!opp_table->set_opp) {
+   ret = _generic_set_opp_regulator(opp_table, dev, old_freq, freq,
+IS_ERR(old_opp) ? NULL : 
old_opp->supplies,
+opp->supplies);
+   } else {
+   struct dev_pm_set_opp_data *data;
 
-   if (opp_table->set_opp)
-   set_opp = opp_table->set_opp;
-   else
-   set_opp = _generic_set_opp;
-
-   data = opp_table->set_opp_data;
-   data->regulators = regulators;
-   data->regulator_count = opp_table->regulator_count;
-   data->clk = clk;
-   data->dev = dev;
-
-   data->old_opp.rate = old_freq;
-   size = sizeof(*opp->supplies) * opp_table->regulator_count;
-   if (IS_ERR(old_opp))
-   memset(data->old_opp.supplies, 0, size);
-   else
-   memcpy(data->old_opp.supplies, old_opp->supplies, size);
+   data = opp_table->set_opp_data;
+   data->regulators = opp_table->regulators;
+   data->regulator_count = opp_table->regulator_count;
+   data->clk = clk;
+  

[PATCH 0/4] PM / OPP: Minor cleanups

2017-05-16 Thread Viresh Kumar
Hi,

Here are few cleanup patches for the OPP core. The first two simplify
the code that was written specifically due to the limitations that we
had because of RCUs. We don't RCUs anymore and this can be simplified.

The last two take care of specific corner cases.

Rebased over pm/linux-next and tested on Exynos dual core board.

Viresh Kumar (4):
  PM / OPP: Reorganize _generic_set_opp_regulator()
  PM / OPP: Don't create copy of regulators unnecessarily
  PM / OPP: opp-microvolt is not optional if regulators are set
  PM / OPP: Don't create debugfs "supply-0" directory unnecessarily

 drivers/base/power/opp/core.c| 87 +---
 drivers/base/power/opp/debugfs.c |  6 +--
 drivers/base/power/opp/of.c  | 11 -
 3 files changed, 49 insertions(+), 55 deletions(-)

-- 
2.13.0.303.g4ebf3021692d



Re: [PATCH v1] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

2017-05-16 Thread Viresh Kumar
On 16-05-17, 12:41, Arvind Yadav wrote:
> Here, Clock enable can failed. So adding an error check for
> clk_prepare_enable.

Rewrite it as:

clk_prepare_enable() can fail here and we must check its return value.

> Signed-off-by: Arvind Yadav 
> ---
>  drivers/cpufreq/kirkwood-cpufreq.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c 
> b/drivers/cpufreq/kirkwood-cpufreq.c
> index 1b9bcd7..4c30103 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device 
> *pdev)
>   return PTR_ERR(priv.cpu_clk);
>   }
>  
> - clk_prepare_enable(priv.cpu_clk);
> + err = clk_prepare_enable(priv.cpu_clk);
> + if (err) {
> + dev_err(priv.dev, "Unable to prepare cpuclk\n");
> + return err;
> + }
> +
>   kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
>  
>   priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
> @@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device 
> *pdev)
>   goto out_cpu;
>   }
>  
> - clk_prepare_enable(priv.ddr_clk);
> + err = clk_prepare_enable(priv.ddr_clk);
> + if (err) {
> + dev_err(priv.dev, "Unable to prepare ddrclk\n");
> + goto out_cpu;
> + }
>   kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
>  
>   priv.powersave_clk = of_clk_get_by_name(np, "powersave");

There is one more prepare-enable after this. Why not fix that as well
?

-- 
viresh


[PATCH v3 2/2] powerpc/mm/hugetlb: Add support for 1G huge pages

2017-05-16 Thread Aneesh Kumar K.V
POWER9 supports hugepages of size 2M and 1G in radix MMU mode. This patch
enables the usage of 1G page size for hugetlbfs. This also update the helper
such we can do 1G page allocation at runtime.

We still don't enable 1G page size on DD1 version. This is to avoid doing
workaround mentioned in commit: 6d3a0379ebdc8 (powerpc/mm: Add
radix__tlb_flush_pte_p9_dd1()

Signed-off-by: Aneesh Kumar K.V 
---
 arch/powerpc/include/asm/book3s/64/hugetlb.h | 10 ++
 arch/powerpc/mm/hugetlbpage.c|  7 +--
 arch/powerpc/platforms/Kconfig.cputype   |  1 +
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h 
b/arch/powerpc/include/asm/book3s/64/hugetlb.h
index cd366596..5c28bd6f2ae1 100644
--- a/arch/powerpc/include/asm/book3s/64/hugetlb.h
+++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h
@@ -50,4 +50,14 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct 
vm_area_struct *vma,
else
return entry;
 }
+
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void)
+{
+   if (radix_enabled())
+   return true;
+   return false;
+}
+#endif
+
 #endif
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index a4f33de4008e..80f6d2ed551a 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -763,8 +763,11 @@ static int __init add_huge_page_size(unsigned long long 
size)
 * Hash: 16M and 16G
 */
if (radix_enabled()) {
-   if (mmu_psize != MMU_PAGE_2M)
-   return -EINVAL;
+   if (mmu_psize != MMU_PAGE_2M) {
+   if (cpu_has_feature(CPU_FTR_POWER9_DD1) ||
+   (mmu_psize != MMU_PAGE_1G))
+   return -EINVAL;
+   }
} else {
if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)
return -EINVAL;
diff --git a/arch/powerpc/platforms/Kconfig.cputype 
b/arch/powerpc/platforms/Kconfig.cputype
index 684e886eaae4..b76ef6637016 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -344,6 +344,7 @@ config PPC_STD_MMU_64
 config PPC_RADIX_MMU
bool "Radix MMU Support"
depends on PPC_BOOK3S_64
+   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
default y
help
  Enable support for the Power ISA 3.0 Radix style MMU. Currently this
-- 
2.7.4



[PATCH v3 1/2] mm/hugetlb: Cleanup ARCH_HAS_GIGANTIC_PAGE

2017-05-16 Thread Aneesh Kumar K.V
This moves the #ifdef in C code to a Kconfig dependency. Also we move the
gigantic_page_supported() function to be arch specific. This gives arch to
conditionally enable runtime allocation of gigantic huge page. Architectures
like ppc64 supports different gigantic huge page size (16G and 1G) based on the
translation mode selected. This provides an opportunity for ppc64 to enable
runtime allocation only w.r.t 1G hugepage.

No functional change in this patch.

Signed-off-by: Aneesh Kumar K.V 
---
Changes from V2:
* Fix build error with x86
* Update the Kconfig change to match the C #ifdef

 arch/arm64/Kconfig   | 2 +-
 arch/arm64/include/asm/hugetlb.h | 4 
 arch/s390/Kconfig| 2 +-
 arch/s390/include/asm/hugetlb.h  | 3 +++
 arch/x86/Kconfig | 2 +-
 arch/x86/include/asm/hugetlb.h   | 4 
 mm/hugetlb.c | 7 ++-
 7 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 3741859765cf..87240dcb6a07 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -11,7 +11,7 @@ config ARM64
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_GCOV_PROFILE_ALL
-   select ARCH_HAS_GIGANTIC_PAGE
+   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
select ARCH_HAS_KCOV
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SG_CHAIN
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index bbc1e35aa601..793bd73b0d07 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -83,4 +83,8 @@ extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
 extern void huge_ptep_clear_flush(struct vm_area_struct *vma,
  unsigned long addr, pte_t *ptep);
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
+
 #endif /* __ASM_HUGETLB_H */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index a2dcef0aacc7..f3637b641d7e 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -67,7 +67,7 @@ config S390
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_GCOV_PROFILE_ALL
-   select ARCH_HAS_GIGANTIC_PAGE
+   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
select ARCH_HAS_KCOV
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SG_CHAIN
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index cd546a245c68..89057b2cc8fe 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -112,4 +112,7 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t 
newprot)
return pte_modify(pte, newprot);
 }
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
 #endif /* _ASM_S390_HUGETLB_H */
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cc98d5a294ee..e39b3b6b7d16 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -22,7 +22,7 @@ config X86_64
def_bool y
depends on 64BIT
# Options that are inherently 64-bit kernel only:
-   select ARCH_HAS_GIGANTIC_PAGE
+   select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA
select ARCH_SUPPORTS_INT128
select ARCH_USE_CMPXCHG_LOCKREF
select HAVE_ARCH_SOFT_DIRTY
diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index 3a106165e03a..535af0f2d8ac 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -85,4 +85,8 @@ static inline void arch_clear_hugepage_flags(struct page 
*page)
 {
 }
 
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
+static inline bool gigantic_page_supported(void) { return true; }
+#endif
+
 #endif /* _ASM_X86_HUGETLB_H */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 3d0aab9ee80d..ce090186b992 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1024,9 +1024,7 @@ static int hstate_next_node_to_free(struct hstate *h, 
nodemask_t *nodes_allowed)
((node = hstate_next_node_to_free(hs, mask)) || 1); \
nr_nodes--)
 
-#if defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) && \
-   ((defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || \
-   defined(CONFIG_CMA))
+#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
 static void destroy_compound_gigantic_page(struct page *page,
unsigned int order)
 {
@@ -1158,8 +1156,7 @@ static int alloc_fresh_gigantic_page(struct hstate *h,
return 0;
 }
 
-static inline bool gigantic_page_supported(void) { return true; }
-#else
+#else /* !CONFIG_ARCH_HAS_GIGANTIC_PAGE */
 static inline bool gigantic_page_supported(void) { return false; }
 static inline void free_gigantic_page(struct page *page, unsigned int order) { 
}
 static inline void destroy_compound_gigantic_page(stru

Re: [PATCH] perf report: do not drop last inlined frame

2017-05-16 Thread Namhyung Kim
On Tue, May 16, 2017 at 11:54:33PM +0200, Milian Wolff wrote:
> The very last inlined frame, i.e. the one furthest away from the
> non-inlined frame, was silently dropped. This is apparent when
> comparing the output of `perf script` and `addr2line`:
> 
> ~~
> $ perf script --inline
> ...
> a.out 26722 80836.309329:  72425 cycles:
>21493 __hypot_finite (/usr/lib/libm-2.25.so)
>  a4a std::abs (inline) (/tmp/a.out)
>  a4a std::_Norm_helper::_S_do_it (inline) 
> (/tmp/a.out)
>  a4a std::norm (inline) (/tmp/a.out)
>  a4a main (/tmp/a.out)
>20510 __libc_start_main (/usr/lib/libc-2.25.so)
>  bd9 _start (/tmp/a.out)
> 
> $ addr2line -a -f -i -e /tmp/a.out a4a | c++filt
> 0x0a4a
> std::__complex_abs(doublecomplex )
> /usr/include/c++/6.3.1/complex:589
> double std::abs(std::complex const&)
> /usr/include/c++/6.3.1/complex:597
> double std::_Norm_helper::_S_do_it(std::complex const&)
> /usr/include/c++/6.3.1/complex:654
> double std::norm(std::complex const&)
> /usr/include/c++/6.3.1/complex:664
> main
> /tmp/inlining.cpp:14
> ~
> 
> Note how `std::__complex_abs` is missing from the `perf script`
> output. This is similarly showing up in `perf report`. The patch
> here fixes this issue, and the output becomes:
> 
> ~
> a.out 26722 80836.309329:  72425 cycles:
>21493 __hypot_finite (/usr/lib/libm-2.25.so)
> ace3 hypot (/usr/lib/libm-2.25.so)
>  a4a std::__complex_abs (inline) (/tmp/a.out)
>  a4a std::abs (inline) (/tmp/a.out)
>  a4a std::_Norm_helper::_S_do_it (inline) 
> (/tmp/a.out)
>  a4a std::norm (inline) (/tmp/a.out)
>  a4a main (/tmp/a.out)
>20510 __libc_start_main (/usr/lib/libc-2.25.so)
>  bd9 _start (/tmp/a.out)
> ~
> 
> Cc: Arnaldo Carvalho de Melo 
> Cc: David Ahern 
> Cc: Namhyung Kim 
> Cc: Peter Zijlstra 
> Cc: Yao Jin 
> Signed-off-by: Milian Wolff 

I also noticed this and thank you for fixing it.

Acked-by: Namhyung Kim 

Thanks,
Namhyung


> ---
>  tools/perf/util/srcline.c | 22 +++---
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index 8df6b29bf984..160999c51fb0 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -208,6 +208,16 @@ static void addr2line_cleanup(struct a2l_data *a2l)
>  
>  #define MAX_INLINE_NEST 1024
>  
> +static int inline_list__append_dso_a2l(struct dso *dso,
> +struct inline_node *node)
> +{
> + struct a2l_data *a2l = dso->a2l;
> + char *funcname = a2l->funcname ? strdup(a2l->funcname) : NULL;
> + char *filename = a2l->filename ? strdup(a2l->filename) : NULL;
> +
> + return inline_list__append(filename, funcname, a2l->line, node, dso);
> +}
> +
>  static int addr2line(const char *dso_name, u64 addr,
>char **file, unsigned int *line, struct dso *dso,
>bool unwind_inlines, struct inline_node *node)
> @@ -233,17 +243,15 @@ static int addr2line(const char *dso_name, u64 addr,
>   if (a2l->found && unwind_inlines) {
>   int cnt = 0;
>  
> + if (node && inline_list__append_dso_a2l(dso, node))
> + return 0;
> +
>   while (bfd_find_inliner_info(a2l->abfd, &a2l->filename,
>&a2l->funcname, &a2l->line) &&
>  cnt++ < MAX_INLINE_NEST) {
>  
> - if (node != NULL) {
> - if (inline_list__append(strdup(a2l->filename),
> - strdup(a2l->funcname),
> - a2l->line, node,
> - dso) != 0)
> - return 0;
> - }
> + if (node && inline_list__append_dso_a2l(dso, node))
> + return 0;
>   }
>   }
>  
> -- 
> 2.13.0
> 


Re: [PATCH] perf report: always honor callchain order for inlined nodes

2017-05-16 Thread Namhyung Kim
On Tue, May 16, 2017 at 11:54:22PM +0200, Milian Wolff wrote:
> So far, the inlined nodes where only reversed when we built perf
> against libbfd. If that was not available, the addr2line fallback
> code path was missing the inline_list__reverse call.
> 
> Now this is done at the central place inside dso__parse_addr_inlines.

What about changing inline_list__append() instead to honor callchain
order?

if (ORDER_CALLEE)
list_add_tail(...);
else
list_add(...);

Thanks,
Namhyung


> 
> Cc: Arnaldo Carvalho de Melo 
> Cc: David Ahern 
> Cc: Namhyung Kim 
> Cc: Peter Zijlstra 
> Cc: Yao Jin 
> Signed-off-by: Milian Wolff 
> ---
>  tools/perf/util/srcline.c | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index 62cf42c36955..8df6b29bf984 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -61,6 +61,14 @@ static int inline_list__append(char *filename, char 
> *funcname, int line_nr,
>   return 0;
>  }
>  
> +static void inline_list__reverse(struct inline_node *node)
> +{
> + struct inline_list *ilist, *n;
> +
> + list_for_each_entry_safe_reverse(ilist, n, &node->val, list)
> + list_move_tail(&ilist->list, &node->val);
> +}
> +
>  #ifdef HAVE_LIBBFD_SUPPORT
>  
>  /*
> @@ -200,14 +208,6 @@ static void addr2line_cleanup(struct a2l_data *a2l)
>  
>  #define MAX_INLINE_NEST 1024
>  
> -static void inline_list__reverse(struct inline_node *node)
> -{
> - struct inline_list *ilist, *n;
> -
> - list_for_each_entry_safe_reverse(ilist, n, &node->val, list)
> - list_move_tail(&ilist->list, &node->val);
> -}
> -
>  static int addr2line(const char *dso_name, u64 addr,
>char **file, unsigned int *line, struct dso *dso,
>bool unwind_inlines, struct inline_node *node)
> @@ -245,11 +245,6 @@ static int addr2line(const char *dso_name, u64 addr,
>   return 0;
>   }
>   }
> -
> - if ((node != NULL) &&
> - (callchain_param.order != ORDER_CALLEE)) {
> - inline_list__reverse(node);
> - }
>   }
>  
>   if (a2l->found && a2l->filename) {
> @@ -493,12 +488,17 @@ char *get_srcline(struct dso *dso, u64 addr, struct 
> symbol *sym,
>  struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr)
>  {
>   const char *dso_name;
> + struct inline_node *node;
>  
>   dso_name = dso__name(dso);
>   if (dso_name == NULL)
>   return NULL;
>  
> - return addr2inlines(dso_name, addr, dso);
> + node = addr2inlines(dso_name, addr, dso);
> + if (node && callchain_param.order != ORDER_CALLEE)
> + inline_list__reverse(node);
> +
> + return node;
>  }
>  
>  void inline_node__delete(struct inline_node *node)
> -- 
> 2.13.0
> 


[PATCH V2] i2c: xgene: Set ACPI_COMPANION_I2C

2017-05-16 Thread Tin Huynh
With ACPI, i2c-core requires ACPI companion to be set in order for it
to create slave device.
This patch sets the ACPI companion accordingly.

Signed-off-by: Tin Huynh 

---
 drivers/i2c/busses/i2c-xgene-slimpro.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Change from V1: 
 - Add Signed-off and full name to the mail header.

diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c 
b/drivers/i2c/busses/i2c-xgene-slimpro.c
index dbe7e44..6ba6c83 100644
--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -416,6 +416,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device 
*pdev)
adapter->class = I2C_CLASS_HWMON;
adapter->dev.parent = &pdev->dev;
adapter->dev.of_node = pdev->dev.of_node;
+   ACPI_COMPANION_SET(&adapter->dev, ACPI_COMPANION(&pdev->dev));
i2c_set_adapdata(adapter, ctx);
rc = i2c_add_adapter(adapter);
if (rc) {
-- 
1.7.1



Re: [PATCH v3 00/11] Broadcom Stingray SOC Initial Support

2017-05-16 Thread Anup Patel
On Wed, May 17, 2017 at 12:23 AM, Olof Johansson  wrote:
> Hi,
>
>
>
> On Tue, May 16, 2017 at 4:30 AM, Anup Patel  wrote:
>> This patchset adds initial support of Broadcom Stingray SOC
>> by reusing existing Broadcom iProc device drivers.
>>
>> Most of the patches in this patchset are DT patches except
>> the Stingray clock tree support which just one patch.
>>
>> This patchset is based on Linux-4.12-rc1 and it is also available
>> at stingray-v3 branch of https://github.com/Broadcom/arm64-linux.git
>>
>> Changes since v2:
>>  - Remove default bootargs from chosen DT node
>>  - Remove "linux" prefix from stdout DT attribute of chosen DT node
>>  - Remove use of GIC_CPU_MASK_xxx() for PPIs
>>
>> Changes since v1:
>>  - Rebased patches for Linux-4.12-rc1
>>  - Removed unwanted /memreserve/ from bcm958742-base.dtsi
>>  - Use ranges DT property to clear view of memory-layout
>>  - Make bcm-sr.h part of clock DT bindings patch
>>
>> Anup Patel (3):
>>   dt-bindings: bcm: Add Broadcom Stingray bindings document
>>   arm64: dts: Initial DTS files for Broadcom Stingray SOC
>>   arm64: dts: Add PL022, PL330 and SP805 DT nodes for Stingray
>>
>> Oza Pawandeep (1):
>>   arm64: dts: Add I2C DT nodes for Stingray SoC
>>
>> Pramod Kumar (3):
>>   arm64: dts: Add NAND DT nodes for Stingray SOC
>>   arm64: dts: Add pinctrl DT nodes for Stingray SOC
>>   arm64: dts: Add GPIO DT nodes for Stingray SOC
>>
>> Sandeep Tripathy (3):
>>   dt-bindings: clk: Extend binding doc for Stingray SOC
>>   clk: bcm: Add clocks for Stingray SOC
>>   arm64: dts: Add clock DT nodes for Stingray SOC
>>
>> Srinath Mannam (1):
>>   arm64: dts: Add PWM and SDHCI DT nodes for Stingray SOC
>>
>>  .../devicetree/bindings/arm/bcm/brcm,stingray.txt  |  12 +
>>  .../bindings/clock/brcm,iproc-clocks.txt   |  76 
>>  arch/arm64/boot/dts/broadcom/Makefile  |   1 +
>>  arch/arm64/boot/dts/broadcom/stingray/Makefile |   6 +
>>  .../boot/dts/broadcom/stingray/bcm958742-base.dtsi | 131 ++
>>  .../boot/dts/broadcom/stingray/bcm958742k.dts  |  78 
>>  .../boot/dts/broadcom/stingray/bcm958742t.dts  |  40 ++
>>  .../boot/dts/broadcom/stingray/stingray-clock.dtsi | 170 
>>  .../dts/broadcom/stingray/stingray-pinctrl.dtsi| 345 
>>  .../arm64/boot/dts/broadcom/stingray/stingray.dtsi | 460 
>> +
>>  drivers/clk/bcm/Kconfig|   8 +
>>  drivers/clk/bcm/Makefile   |   1 +
>>  drivers/clk/bcm/clk-sr.c   | 300 ++
>>  include/dt-bindings/clock/bcm-sr.h | 101 +
>>  .../dt-bindings/pinctrl/brcm,pinctrl-stingray.h|  68 +++
>>  15 files changed, 1797 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/arm/bcm/brcm,stingray.txt
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/Makefile
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/bcm958742-base.dtsi
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/stingray-clock.dtsi
>>  create mode 100644 
>> arch/arm64/boot/dts/broadcom/stingray/stingray-pinctrl.dtsi
>>  create mode 100644 arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
>>  create mode 100644 drivers/clk/bcm/clk-sr.c
>>  create mode 100644 include/dt-bindings/clock/bcm-sr.h
>>  create mode 100644 include/dt-bindings/pinctrl/brcm,pinctrl-stingray.h
>
> Grouping as one patchset for review is fine, but when you submit this
> for merge you need to split it up:
>
> - Documentation/devicetree can go with the driver pieces or with the
> DT changes, your choice
> - DTS/DTSI changes should go through the Broadcom maintainers to arm-soc
> - clk changes should go to clk maintainers.

Only PATCH3 needs to go through clk maintainers rest all patches
are DT bindings document and DTS changes which can go through
Broadcom tree. Right ??

>
> Also, there's usually no need to split up a DT introduction and having
> separate pieces for NAND/pinctrl/GPIO/etc: They can all go in the main
> DT submission patch.

Yes, we have already squashed DTS patches from same author into
one DTS patch except NAND, PINCTRL and GPIO patches.

The NAND, PINCTRL, and GPIO patches were not squashed into
one patch for easy review but since you suggest I will squash these
three DTS patches into one DTS patch.

Regards,
Anup


Re: [PATCH] perf report: fix memory leak in addr2line when called by addr2inlines

2017-05-16 Thread Namhyung Kim
On Tue, May 16, 2017 at 11:53:59PM +0200, Milian Wolff wrote:
> When a filename was found in addr2line it was duplicated via strdup
> but never freed. Now we pass NULL and handle this gracefully in
> addr2line.
> 
> Detected by Valgrind:
> 
> ==16331== 1,680 bytes in 21 blocks are definitely lost in loss record 148 of 
> 220
> ==16331==at 0x4C2AF1F: malloc (in 
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==16331==by 0x672FA69: strdup (in /usr/lib/libc-2.25.so)
> ==16331==by 0x52769F: addr2line (srcline.c:256)
> ==16331==by 0x52769F: addr2inlines (srcline.c:294)
> ==16331==by 0x52769F: dso__parse_addr_inlines (srcline.c:502)
> ==16331==by 0x574D7A: inline__fprintf (hist.c:41)
> ==16331==by 0x574D7A: ipchain__fprintf_graph (hist.c:147)
> ==16331==by 0x57518A: __callchain__fprintf_graph (hist.c:212)
> ==16331==by 0x5753CF: callchain__fprintf_graph.constprop.6 (hist.c:337)
> ==16331==by 0x57738E: hist_entry__fprintf (hist.c:628)
> ==16331==by 0x57738E: hists__fprintf (hist.c:882)
> ==16331==by 0x44A20F: perf_evlist__tty_browse_hists (builtin-report.c:399)
> ==16331==by 0x44A20F: report__browse_hists (builtin-report.c:491)
> ==16331==by 0x44A20F: __cmd_report (builtin-report.c:624)
> ==16331==by 0x44A20F: cmd_report (builtin-report.c:1054)
> ==16331==by 0x4A49CE: run_builtin (perf.c:296)
> ==16331==by 0x4A4CC0: handle_internal_command (perf.c:348)
> ==16331==by 0x434371: run_argv (perf.c:392)
> ==16331==by 0x434371: main (perf.c:530)
> 
> Cc: Arnaldo Carvalho de Melo 
> Cc: David Ahern 
> Cc: Namhyung Kim 
> Cc: Peter Zijlstra 
> Cc: Yao Jin 
> Signed-off-by: Milian Wolff 
> ---
>  tools/perf/util/srcline.c | 13 ++---
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index df051a52393c..62cf42c36955 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -253,10 +253,11 @@ static int addr2line(const char *dso_name, u64 addr,
>   }
>  
>   if (a2l->found && a2l->filename) {

Not related, but I think it'd be better checking "a2l->found" after
bfd_map_over_sections() and bail out if not.


> - *file = strdup(a2l->filename);
> - *line = a2l->line;
> -
> - if (*file)
> + if (file)
> + *file = strdup(a2l->filename);
> + if (line)
> + *line = a2l->line;
> + if (*a2l->filename)

Didn't you want to check a2l->filename being non-NULL instead?  And if
so, this can be :

if (!file || *file)
>   ret = 1;
>   }

Thanks,
Namhyung


>  
> @@ -278,8 +279,6 @@ void dso__free_a2l(struct dso *dso)
>  static struct inline_node *addr2inlines(const char *dso_name, u64 addr,
>   struct dso *dso)
>  {
> - char *file = NULL;
> - unsigned int line = 0;
>   struct inline_node *node;
>  
>   node = zalloc(sizeof(*node));
> @@ -291,7 +290,7 @@ static struct inline_node *addr2inlines(const char 
> *dso_name, u64 addr,
>   INIT_LIST_HEAD(&node->val);
>   node->addr = addr;
>  
> - if (!addr2line(dso_name, addr, &file, &line, dso, TRUE, node))
> + if (!addr2line(dso_name, addr, NULL, NULL, dso, TRUE, node))
>   goto out_free_inline_node;
>  
>   if (list_empty(&node->val))
> -- 
> 2.13.0
> 


linux-next: Tree for May 17

2017-05-16 Thread Stephen Rothwell
Hi all,

Changes since 20170516:

New trees: nand-fixes (yesterday)
spi-nor-fixes

The file-locks tree gained a build failure so I used the version from
next-20170516.

The netfilter tree gained a build failure for which I applied a fix patch.

The sound tree gained a build failure so I used the version from
next-20170516.

The scsi-mkp tree gained a build failure so I used the version from
next-20170516.

Non-merge commits (relative to Linus' tree): 1206
 1254 files changed, 34634 insertions(+), 21339 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
and pseries_le_defconfig and i386, sparc and sparc64 defconfig.

Below is a summary of the state of the merge.

I am currently merging 260 trees (counting Linus' and 40 trees of bug
fix patches pending for the current merge release).

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 (b23afd384801 Merge tag 'pstore-v4.12-rc2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux)
Merging fixes/master (97da3854c526 Linux 4.11-rc3)
Merging kbuild-current/fixes (2ea659a9ef48 Linux 4.12-rc1)
Merging arc-current/for-curr (2ea659a9ef48 Linux 4.12-rc1)
Merging arm-current/fixes (2ea659a9ef48 Linux 4.12-rc1)
Merging m68k-current/for-linus (f6ab4d59a5fe nubus: Add MVC and VSC video card 
definitions)
Merging metag-fixes/fixes (b884a190afce metag/usercopy: Add missing fixups)
Merging powerpc-fixes/fixes (be5c5e843c4a powerpc/64: Fix HMI exception on LE 
with CONFIG_RELOCATABLE=y)
Merging sparc/master (3c7f62212018 sparc64: fix fault handling in NGbzero.S and 
GENbzero.S)
Merging fscrypt-current/for-stable (42d97eb0ade3 fscrypt: fix renaming and 
linking special files)
Merging net/master (2432a3fb5cff mlx5e: add CONFIG_INET dependency)
Merging ipsec/master (2c1497bbc8fd xfrm: Fix NETDEV_DOWN with IPSec offload)
Merging netfilter/master (c953d6354820 ebtables: arpreply: Add the standard 
target sanity check)
Merging ipvs/master (3c5ab3f395d6 ipvs: SNAT packet replies only for NATed 
connections)
Merging wireless-drivers/master (d77facb88448 brcmfmac: use local iftype 
avoiding use-after-free of virtual interface)
Merging mac80211/master (29cee56c0be4 Merge tag 'mac80211-for-davem-2017-05-08' 
of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211)
Merging sound-current/for-linus (fa16b69f1299 ALSA: hda - No loopback on ALC299 
codec)
Merging pci-current/for-linus (2ea659a9ef48 Linux 4.12-rc1)
Merging driver-core.current/driver-core-linus (2ea659a9ef48 Linux 4.12-rc1)
Merging tty.current/tty-linus (2ea659a9ef48 Linux 4.12-rc1)
Merging usb.current/usb-linus (2ea659a9ef48 Linux 4.12-rc1)
Merging usb-gadget-fixes/fixes (a351e9b9fc24 Linux 4.11)
Merging usb-serial-fixes/usb-linus (b004ee894f53 USB: serial: ftdi_sio: add 
Olimex ARM-USB-TINY(H) PIDs)
Merging usb-chipidea-fixes/ci-for-usb-stable (c7fbb09b2ea1 usb: chipidea: move 
the lock initialization to core file)
Merging phy/fixes (3f34d7fc76fa phy: Group vendor specific phy drivers)
Merging staging.current/staging-linus (b72d7451209a staging: fsl-dpaa2/eth: add 
ETHERNET dependency)
Merging char-misc.current/char-misc-linus (0d83539092dd uio: fix incorrect 
memory leak cleanup)
Merging input-current/for-linus (3af9256150b3 Input: cros_ec_keyb - remove 
extraneous 'const')
Merging crypto-current/master (929562b14478 crypto: stm32 - Fix OF module alias 
information)
Merging ide/master (acfead32f3f9 ide: don't call memcpy with the same source 
and destination)
Merging vfio-fixes/for-linus (39da7c509acf Linux 4.11-rc

[PATCH net-next V5 1/9] ptr_ring: add ptr_ring_unconsume

2017-05-16 Thread Jason Wang
From: "Michael S. Tsirkin" 

Applications that consume a batch of entries in one go
can benefit from ability to return some of them back
into the ring.

Add an API for that - assuming there's space. If there's no space
naturally can't do this and have to drop entries, but this implies ring
is full so we'd likely drop some anyway.

Signed-off-by: Michael S. Tsirkin 
Signed-off-by: Jason Wang 
---
 include/linux/ptr_ring.h | 55 
 1 file changed, 55 insertions(+)

diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 6b2e0dd..796b90f 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -403,6 +403,61 @@ static inline int ptr_ring_init(struct ptr_ring *r, int 
size, gfp_t gfp)
return 0;
 }
 
+/*
+ * Return entries into ring. Destroy entries that don't fit.
+ *
+ * Note: this is expected to be a rare slow path operation.
+ *
+ * Note: producer lock is nested within consumer lock, so if you
+ * resize you must make sure all uses nest correctly.
+ * In particular if you consume ring in interrupt or BH context, you must
+ * disable interrupts/BH when doing so.
+ */
+static inline void ptr_ring_unconsume(struct ptr_ring *r, void **batch, int n,
+ void (*destroy)(void *))
+{
+   unsigned long flags;
+   int head;
+
+   spin_lock_irqsave(&r->consumer_lock, flags);
+   spin_lock(&r->producer_lock);
+
+   if (!r->size)
+   goto done;
+
+   /*
+* Clean out buffered entries (for simplicity). This way following code
+* can test entries for NULL and if not assume they are valid.
+*/
+   head = r->consumer_head - 1;
+   while (likely(head >= r->consumer_tail))
+   r->queue[head--] = NULL;
+   r->consumer_tail = r->consumer_head;
+
+   /*
+* Go over entries in batch, start moving head back and copy entries.
+* Stop when we run into previously unconsumed entries.
+*/
+   while (n) {
+   head = r->consumer_head - 1;
+   if (head < 0)
+   head = r->size - 1;
+   if (r->queue[head]) {
+   /* This batch entry will have to be destroyed. */
+   goto done;
+   }
+   r->queue[head] = batch[--n];
+   r->consumer_tail = r->consumer_head = head;
+   }
+
+done:
+   /* Destroy all entries left in the batch. */
+   while (n)
+   destroy(batch[--n]);
+   spin_unlock(&r->producer_lock);
+   spin_unlock_irqrestore(&r->consumer_lock, flags);
+}
+
 static inline void **__ptr_ring_swap_queue(struct ptr_ring *r, void **queue,
   int size, gfp_t gfp,
   void (*destroy)(void *))
-- 
2.7.4



[PATCH net-next V5 0/9] vhost_net rx batch dequeuing

2017-05-16 Thread Jason Wang
This series tries to implement rx batching for vhost-net. This is done
by batching the dequeuing from skb_array which was exported by
underlayer socket and pass the sbk back through msg_control to finish
userspace copying. This is also the requirement for more batching
implemention on rx path.

Tests shows at most 7.56% improvment bon rx pps on top of batch
zeroing and no obvious changes for TCP_STREAM/TCP_RR result.

Please review.

Thanks

Changes from V4:
- drop batch zeroing patch
- renew the performance numbers
- move skb pointer array out of vhost_net structure

Changes from V3:
- add batch zeroing patch to fix the build warnings

Changes from V2:
- rebase to net-next HEAD
- use unconsume helpers to put skb back on releasing
- introduce and use vhost_net internal buffer helpers
- renew performance numbers on top of batch zeroing

Changes from V1:
- switch to use for() in __ptr_ring_consume_batched()
- rename peek_head_len_batched() to fetch_skbs()
- use skb_array_consume_batched() instead of
  skb_array_consume_batched_bh() since no consumer run in bh
- drop the lockless peeking patch since skb_array could be resized, so
  it's not safe to call lockless one

Jason Wang (8):
  skb_array: introduce skb_array_unconsume
  ptr_ring: introduce batch dequeuing
  skb_array: introduce batch dequeuing
  tun: export skb_array
  tap: export skb_array
  tun: support receiving skb through msg_control
  tap: support receiving skb from msg_control
  vhost_net: try batch dequing from skb array

Michael S. Tsirkin (1):
  ptr_ring: add ptr_ring_unconsume

 drivers/net/tap.c |  25 +++--
 drivers/net/tun.c |  31 ---
 drivers/vhost/net.c   | 128 +++---
 include/linux/if_tap.h|   5 ++
 include/linux/if_tun.h|   5 ++
 include/linux/ptr_ring.h  | 120 +++
 include/linux/skb_array.h |  31 +++
 7 files changed, 327 insertions(+), 18 deletions(-)

-- 
2.7.4



[PATCH net-next V5 4/9] skb_array: introduce batch dequeuing

2017-05-16 Thread Jason Wang
Signed-off-by: Jason Wang 
---
 include/linux/skb_array.h | 25 +
 1 file changed, 25 insertions(+)

diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h
index 79850b6..35226cd 100644
--- a/include/linux/skb_array.h
+++ b/include/linux/skb_array.h
@@ -97,21 +97,46 @@ static inline struct sk_buff *skb_array_consume(struct 
skb_array *a)
return ptr_ring_consume(&a->ring);
 }
 
+static inline int skb_array_consume_batched(struct skb_array *a,
+   struct sk_buff **array, int n)
+{
+   return ptr_ring_consume_batched(&a->ring, (void **)array, n);
+}
+
 static inline struct sk_buff *skb_array_consume_irq(struct skb_array *a)
 {
return ptr_ring_consume_irq(&a->ring);
 }
 
+static inline int skb_array_consume_batched_irq(struct skb_array *a,
+   struct sk_buff **array, int n)
+{
+   return ptr_ring_consume_batched_irq(&a->ring, (void **)array, n);
+}
+
 static inline struct sk_buff *skb_array_consume_any(struct skb_array *a)
 {
return ptr_ring_consume_any(&a->ring);
 }
 
+static inline int skb_array_consume_batched_any(struct skb_array *a,
+   struct sk_buff **array, int n)
+{
+   return ptr_ring_consume_batched_any(&a->ring, (void **)array, n);
+}
+
+
 static inline struct sk_buff *skb_array_consume_bh(struct skb_array *a)
 {
return ptr_ring_consume_bh(&a->ring);
 }
 
+static inline int skb_array_consume_batched_bh(struct skb_array *a,
+  struct sk_buff **array, int n)
+{
+   return ptr_ring_consume_batched_bh(&a->ring, (void **)array, n);
+}
+
 static inline int __skb_array_len_with_tag(struct sk_buff *skb)
 {
if (likely(skb)) {
-- 
2.7.4



[PATCH net-next V5 9/9] vhost_net: try batch dequing from skb array

2017-05-16 Thread Jason Wang
We used to dequeue one skb during recvmsg() from skb_array, this could
be inefficient because of the bad cache utilization and spinlock
touching for each packet. This patch tries to batch them by calling
batch dequeuing helpers explicitly on the exported skb array and pass
the skb back through msg_control for underlayer socket to finish the
userspace copying. Batch dequeuing is also the requirement for more
batching improvement on receive path.

Tests were done by pktgen on tap with XDP1 in guest. Host is Intel(R)
Xeon(R) CPU E5-2650 0 @ 2.00GHz.

rx batch | pps

0   2.25Mpps
1   2.33Mpps (+3.56%)
4   2.33Mpps (+3.56%)
16  2.35Mpps (+4.44%)
64  2.42Mpps (+7.56%) <- Default rx batching
128 2.40Mpps (+6.67%)
256 2.38Mpps (+5.78%)

Signed-off-by: Jason Wang 
---
 drivers/vhost/net.c | 128 +---
 1 file changed, 122 insertions(+), 6 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index f61f852..e3d7ea1 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -85,6 +87,13 @@ struct vhost_net_ubuf_ref {
struct vhost_virtqueue *vq;
 };
 
+#define VHOST_RX_BATCH 64
+struct vhost_net_buf {
+   struct sk_buff **queue;
+   int tail;
+   int head;
+};
+
 struct vhost_net_virtqueue {
struct vhost_virtqueue vq;
size_t vhost_hlen;
@@ -99,6 +108,8 @@ struct vhost_net_virtqueue {
/* Reference counting for outstanding ubufs.
 * Protected by vq mutex. Writers must also take device mutex. */
struct vhost_net_ubuf_ref *ubufs;
+   struct skb_array *rx_array;
+   struct vhost_net_buf rxq;
 };
 
 struct vhost_net {
@@ -117,6 +128,71 @@ struct vhost_net {
 
 static unsigned vhost_net_zcopy_mask __read_mostly;
 
+static void *vhost_net_buf_get_ptr(struct vhost_net_buf *rxq)
+{
+   if (rxq->tail != rxq->head)
+   return rxq->queue[rxq->head];
+   else
+   return NULL;
+}
+
+static int vhost_net_buf_get_size(struct vhost_net_buf *rxq)
+{
+   return rxq->tail - rxq->head;
+}
+
+static int vhost_net_buf_is_empty(struct vhost_net_buf *rxq)
+{
+   return rxq->tail == rxq->head;
+}
+
+static void *vhost_net_buf_consume(struct vhost_net_buf *rxq)
+{
+   void *ret = vhost_net_buf_get_ptr(rxq);
+   ++rxq->head;
+   return ret;
+}
+
+static int vhost_net_buf_produce(struct vhost_net_virtqueue *nvq)
+{
+   struct vhost_net_buf *rxq = &nvq->rxq;
+
+   rxq->head = 0;
+   rxq->tail = skb_array_consume_batched(nvq->rx_array, rxq->queue,
+ VHOST_RX_BATCH);
+   return rxq->tail;
+}
+
+static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq)
+{
+   struct vhost_net_buf *rxq = &nvq->rxq;
+
+   if (nvq->rx_array && !vhost_net_buf_is_empty(rxq)) {
+   skb_array_unconsume(nvq->rx_array, rxq->queue + rxq->head,
+   vhost_net_buf_get_size(rxq));
+   rxq->head = rxq->tail = 0;
+   }
+}
+
+static int vhost_net_buf_peek(struct vhost_net_virtqueue *nvq)
+{
+   struct vhost_net_buf *rxq = &nvq->rxq;
+
+   if (!vhost_net_buf_is_empty(rxq))
+   goto out;
+
+   if (!vhost_net_buf_produce(nvq))
+   return 0;
+
+out:
+   return __skb_array_len_with_tag(vhost_net_buf_get_ptr(rxq));
+}
+
+static void vhost_net_buf_init(struct vhost_net_buf *rxq)
+{
+   rxq->head = rxq->tail = 0;
+}
+
 static void vhost_net_enable_zcopy(int vq)
 {
vhost_net_zcopy_mask |= 0x1 << vq;
@@ -201,6 +277,7 @@ static void vhost_net_vq_reset(struct vhost_net *n)
n->vqs[i].ubufs = NULL;
n->vqs[i].vhost_hlen = 0;
n->vqs[i].sock_hlen = 0;
+   vhost_net_buf_init(&n->vqs[i].rxq);
}
 
 }
@@ -503,15 +580,14 @@ static void handle_tx(struct vhost_net *net)
mutex_unlock(&vq->mutex);
 }
 
-static int peek_head_len(struct sock *sk)
+static int peek_head_len(struct vhost_net_virtqueue *rvq, struct sock *sk)
 {
-   struct socket *sock = sk->sk_socket;
struct sk_buff *head;
int len = 0;
unsigned long flags;
 
-   if (sock->ops->peek_len)
-   return sock->ops->peek_len(sock);
+   if (rvq->rx_array)
+   return vhost_net_buf_peek(rvq);
 
spin_lock_irqsave(&sk->sk_receive_queue.lock, flags);
head = skb_peek(&sk->sk_receive_queue);
@@ -537,10 +613,11 @@ static int sk_has_rx_data(struct sock *sk)
 
 static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk)
 {
+   struct vhost_net_virtqueue *rvq = &net->vqs[VHOST_NET_VQ_RX];
struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
struct vhost_virtqueue *vq = &nvq->vq;
unsigned long uninitialized_var(endtime);
-   int len = peek_head_len(sk);
+   int len = peek_head_len(rvq, sk);
 
if (

[PATCH net-next V5 7/9] tun: support receiving skb through msg_control

2017-05-16 Thread Jason Wang
This patch makes tun_recvmsg() can receive from skb from its caller
through msg_control. Vhost_net will be the first user.

Signed-off-by: Jason Wang 
---
 drivers/net/tun.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 3cbfc5c..f8041f9c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1510,9 +1510,8 @@ static struct sk_buff *tun_ring_recv(struct tun_file 
*tfile, int noblock,
 
 static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
   struct iov_iter *to,
-  int noblock)
+  int noblock, struct sk_buff *skb)
 {
-   struct sk_buff *skb;
ssize_t ret;
int err;
 
@@ -1521,10 +1520,12 @@ static ssize_t tun_do_read(struct tun_struct *tun, 
struct tun_file *tfile,
if (!iov_iter_count(to))
return 0;
 
-   /* Read frames from ring */
-   skb = tun_ring_recv(tfile, noblock, &err);
-   if (!skb)
-   return err;
+   if (!skb) {
+   /* Read frames from ring */
+   skb = tun_ring_recv(tfile, noblock, &err);
+   if (!skb)
+   return err;
+   }
 
ret = tun_put_user(tun, tfile, skb, to);
if (unlikely(ret < 0))
@@ -1544,7 +1545,7 @@ static ssize_t tun_chr_read_iter(struct kiocb *iocb, 
struct iov_iter *to)
 
if (!tun)
return -EBADFD;
-   ret = tun_do_read(tun, tfile, to, file->f_flags & O_NONBLOCK);
+   ret = tun_do_read(tun, tfile, to, file->f_flags & O_NONBLOCK, NULL);
ret = min_t(ssize_t, ret, len);
if (ret > 0)
iocb->ki_pos = ret;
@@ -1646,7 +1647,8 @@ static int tun_recvmsg(struct socket *sock, struct msghdr 
*m, size_t total_len,
 SOL_PACKET, TUN_TX_TIMESTAMP);
goto out;
}
-   ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT);
+   ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT,
+ m->msg_control);
if (ret > (ssize_t)total_len) {
m->msg_flags |= MSG_TRUNC;
ret = flags & MSG_TRUNC ? ret : total_len;
-- 
2.7.4



[PATCH net-next V5 5/9] tun: export skb_array

2017-05-16 Thread Jason Wang
This patch exports skb_array through tun_get_skb_array(). Caller can
then manipulate skb array directly.

Signed-off-by: Jason Wang 
---
 drivers/net/tun.c  | 13 +
 include/linux/if_tun.h |  5 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index bbd707b..3cbfc5c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2626,6 +2626,19 @@ struct socket *tun_get_socket(struct file *file)
 }
 EXPORT_SYMBOL_GPL(tun_get_socket);
 
+struct skb_array *tun_get_skb_array(struct file *file)
+{
+   struct tun_file *tfile;
+
+   if (file->f_op != &tun_fops)
+   return ERR_PTR(-EINVAL);
+   tfile = file->private_data;
+   if (!tfile)
+   return ERR_PTR(-EBADFD);
+   return &tfile->tx_array;
+}
+EXPORT_SYMBOL_GPL(tun_get_skb_array);
+
 module_init(tun_init);
 module_exit(tun_cleanup);
 MODULE_DESCRIPTION(DRV_DESCRIPTION);
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index ed6da2e..bf9bdf4 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -19,6 +19,7 @@
 
 #if defined(CONFIG_TUN) || defined(CONFIG_TUN_MODULE)
 struct socket *tun_get_socket(struct file *);
+struct skb_array *tun_get_skb_array(struct file *file);
 #else
 #include 
 #include 
@@ -28,5 +29,9 @@ static inline struct socket *tun_get_socket(struct file *f)
 {
return ERR_PTR(-EINVAL);
 }
+static inline struct skb_array *tun_get_skb_array(struct file *f)
+{
+   return ERR_PTR(-EINVAL);
+}
 #endif /* CONFIG_TUN */
 #endif /* __IF_TUN_H */
-- 
2.7.4



[PATCH net-next V5 6/9] tap: export skb_array

2017-05-16 Thread Jason Wang
This patch exports skb_array through tap_get_skb_array(). Caller can
then manipulate skb array directly.

Signed-off-by: Jason Wang 
---
 drivers/net/tap.c  | 13 +
 include/linux/if_tap.h |  5 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 4d4173d..abdaf86 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -1193,6 +1193,19 @@ struct socket *tap_get_socket(struct file *file)
 }
 EXPORT_SYMBOL_GPL(tap_get_socket);
 
+struct skb_array *tap_get_skb_array(struct file *file)
+{
+   struct tap_queue *q;
+
+   if (file->f_op != &tap_fops)
+   return ERR_PTR(-EINVAL);
+   q = file->private_data;
+   if (!q)
+   return ERR_PTR(-EBADFD);
+   return &q->skb_array;
+}
+EXPORT_SYMBOL_GPL(tap_get_skb_array);
+
 int tap_queue_resize(struct tap_dev *tap)
 {
struct net_device *dev = tap->dev;
diff --git a/include/linux/if_tap.h b/include/linux/if_tap.h
index 3482c3c..4837157 100644
--- a/include/linux/if_tap.h
+++ b/include/linux/if_tap.h
@@ -3,6 +3,7 @@
 
 #if IS_ENABLED(CONFIG_TAP)
 struct socket *tap_get_socket(struct file *);
+struct skb_array *tap_get_skb_array(struct file *file);
 #else
 #include 
 #include 
@@ -12,6 +13,10 @@ static inline struct socket *tap_get_socket(struct file *f)
 {
return ERR_PTR(-EINVAL);
 }
+static inline struct skb_array *tap_get_skb_array(struct file *f)
+{
+   return ERR_PTR(-EINVAL);
+}
 #endif /* CONFIG_TAP */
 
 #include 
-- 
2.7.4



[PATCH net-next V5 8/9] tap: support receiving skb from msg_control

2017-05-16 Thread Jason Wang
This patch makes tap_recvmsg() can receive from skb from its caller
through msg_control. Vhost_net will be the first user.

Signed-off-by: Jason Wang 
---
 drivers/net/tap.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index abdaf86..9af3239 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -824,15 +824,17 @@ static ssize_t tap_put_user(struct tap_queue *q,
 
 static ssize_t tap_do_read(struct tap_queue *q,
   struct iov_iter *to,
-  int noblock)
+  int noblock, struct sk_buff *skb)
 {
DEFINE_WAIT(wait);
-   struct sk_buff *skb;
ssize_t ret = 0;
 
if (!iov_iter_count(to))
return 0;
 
+   if (skb)
+   goto put;
+
while (1) {
if (!noblock)
prepare_to_wait(sk_sleep(&q->sk), &wait,
@@ -856,6 +858,7 @@ static ssize_t tap_do_read(struct tap_queue *q,
if (!noblock)
finish_wait(sk_sleep(&q->sk), &wait);
 
+put:
if (skb) {
ret = tap_put_user(q, skb, to);
if (unlikely(ret < 0))
@@ -872,7 +875,7 @@ static ssize_t tap_read_iter(struct kiocb *iocb, struct 
iov_iter *to)
struct tap_queue *q = file->private_data;
ssize_t len = iov_iter_count(to), ret;
 
-   ret = tap_do_read(q, to, file->f_flags & O_NONBLOCK);
+   ret = tap_do_read(q, to, file->f_flags & O_NONBLOCK, NULL);
ret = min_t(ssize_t, ret, len);
if (ret > 0)
iocb->ki_pos = ret;
@@ -1155,7 +1158,8 @@ static int tap_recvmsg(struct socket *sock, struct msghdr 
*m,
int ret;
if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
return -EINVAL;
-   ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT);
+   ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT,
+ m->msg_control);
if (ret > total_len) {
m->msg_flags |= MSG_TRUNC;
ret = flags & MSG_TRUNC ? ret : total_len;
-- 
2.7.4



[PATCH net-next V5 3/9] ptr_ring: introduce batch dequeuing

2017-05-16 Thread Jason Wang
This patch introduce a batched version of consuming, consumer can
dequeue more than one pointers from the ring at a time. We don't care
about the reorder of reading here so no need for compiler barrier.

Signed-off-by: Jason Wang 
---
 include/linux/ptr_ring.h | 65 
 1 file changed, 65 insertions(+)

diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 796b90f..d8c97ec 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -278,6 +278,22 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r)
return ptr;
 }
 
+static inline int __ptr_ring_consume_batched(struct ptr_ring *r,
+void **array, int n)
+{
+   void *ptr;
+   int i;
+
+   for (i = 0; i < n; i++) {
+   ptr = __ptr_ring_consume(r);
+   if (!ptr)
+   break;
+   array[i] = ptr;
+   }
+
+   return i;
+}
+
 /*
  * Note: resize (below) nests producer lock within consumer lock, so if you
  * call this in interrupt or BH context, you must disable interrupts/BH when
@@ -328,6 +344,55 @@ static inline void *ptr_ring_consume_bh(struct ptr_ring *r)
return ptr;
 }
 
+static inline int ptr_ring_consume_batched(struct ptr_ring *r,
+  void **array, int n)
+{
+   int ret;
+
+   spin_lock(&r->consumer_lock);
+   ret = __ptr_ring_consume_batched(r, array, n);
+   spin_unlock(&r->consumer_lock);
+
+   return ret;
+}
+
+static inline int ptr_ring_consume_batched_irq(struct ptr_ring *r,
+  void **array, int n)
+{
+   int ret;
+
+   spin_lock_irq(&r->consumer_lock);
+   ret = __ptr_ring_consume_batched(r, array, n);
+   spin_unlock_irq(&r->consumer_lock);
+
+   return ret;
+}
+
+static inline int ptr_ring_consume_batched_any(struct ptr_ring *r,
+  void **array, int n)
+{
+   unsigned long flags;
+   int ret;
+
+   spin_lock_irqsave(&r->consumer_lock, flags);
+   ret = __ptr_ring_consume_batched(r, array, n);
+   spin_unlock_irqrestore(&r->consumer_lock, flags);
+
+   return ret;
+}
+
+static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r,
+ void **array, int n)
+{
+   int ret;
+
+   spin_lock_bh(&r->consumer_lock);
+   ret = __ptr_ring_consume_batched(r, array, n);
+   spin_unlock_bh(&r->consumer_lock);
+
+   return ret;
+}
+
 /* Cast to structure type and call a function without discarding from FIFO.
  * Function must return a value.
  * Callers must take consumer_lock.
-- 
2.7.4



[PATCH net-next V5 2/9] skb_array: introduce skb_array_unconsume

2017-05-16 Thread Jason Wang
Signed-off-by: Jason Wang 
---
 include/linux/skb_array.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h
index f4dfade..79850b6 100644
--- a/include/linux/skb_array.h
+++ b/include/linux/skb_array.h
@@ -156,6 +156,12 @@ static void __skb_array_destroy_skb(void *ptr)
kfree_skb(ptr);
 }
 
+static inline void skb_array_unconsume(struct skb_array *a,
+  struct sk_buff **skbs, int n)
+{
+   ptr_ring_unconsume(&a->ring, (void **)skbs, n, __skb_array_destroy_skb);
+}
+
 static inline int skb_array_resize(struct skb_array *a, int size, gfp_t gfp)
 {
return ptr_ring_resize(&a->ring, size, gfp, __skb_array_destroy_skb);
-- 
2.7.4



[PATCH] crypto: x86/aes - Don't use %rbp as temporary register

2017-05-16 Thread Eric Biggers
From: Eric Biggers 

When using the "aes-asm" implementation of AES (*not* the AES-NI
implementation) on an x86_64, v4.12-rc1 kernel with lockdep enabled, the
following warning was reported, along with a long unwinder dump:

WARNING: kernel stack regs at c9643558 in kworker/u4:2:155 has 
bad 'bp' value 001c

The problem is that aes_enc_block() and aes_dec_block() use %rbp as a
temporary register, which breaks stack traces if an interrupt occurs.

Fix this by replacing %rbp with %r9, which was being used to hold the
saved value of %rbp.  This required rearranging the AES round macro
slightly since %r9d cannot be used as the target of a move from %ah-%dh.

Performance is essentially unchanged --- actually about 0.2% faster than
before.  Interestingly, I also measured aes-generic as being nearly 7%
faster than aes-asm, so perhaps aes-asm has outlived its usefulness...

Signed-off-by: Eric Biggers 
---
 arch/x86/crypto/aes-x86_64-asm_64.S | 47 +
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S 
b/arch/x86/crypto/aes-x86_64-asm_64.S
index 910565547163..8739cf7795de 100644
--- a/arch/x86/crypto/aes-x86_64-asm_64.S
+++ b/arch/x86/crypto/aes-x86_64-asm_64.S
@@ -42,17 +42,15 @@
 #define R5E%esi
 #define R6 %rdi
 #define R6E%edi
-#define R7 %rbp
-#define R7E%ebp
+#define R7 %r9 /* don't use %rbp; it breaks stack traces */
+#define R7E%r9d
 #define R8 %r8
-#define R9 %r9
 #define R10%r10
 #define R11%r11
 
-#define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \
+#define prologue(FUNC,KEY,B128,B192,r1,r2,r5,r6,r7,r8,r9,r10,r11) \
ENTRY(FUNC);\
movqr1,r2;  \
-   movqr3,r4;  \
leaqKEY+48(r8),r9;  \
movqr10,r11;\
movl(r7),r5 ## E;   \
@@ -70,9 +68,8 @@
je  B192;   \
leaq32(r9),r9;
 
-#define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
+#define epilogue(FUNC,r1,r2,r5,r6,r7,r8,r9) \
movqr1,r2;  \
-   movqr3,r4;  \
movlr5 ## E,(r9);   \
movlr6 ## E,4(r9);  \
movlr7 ## E,8(r9);  \
@@ -88,12 +85,12 @@
movlTAB(,r6,4),r6 ## E; \
roll$16,r2 ## E;\
shrl$16,r4 ## E;\
-   movzbl  r4 ## H,r7 ## E;\
-   movzbl  r4 ## L,r4 ## E;\
+   movzbl  r4 ## L,r7 ## E;\
+   movzbl  r4 ## H,r4 ## E;\
xorlOFFSET(r8),ra ## E; \
xorlOFFSET+4(r8),rb ## E;   \
-   xorlTAB+3072(,r7,4),r5 ## E;\
-   xorlTAB+2048(,r4,4),r6 ## E;\
+   xorlTAB+3072(,r4,4),r5 ## E;\
+   xorlTAB+2048(,r7,4),r6 ## E;\
movzbl  r1 ## L,r7 ## E;\
movzbl  r1 ## H,r4 ## E;\
movlTAB+1024(,r4,4),r4 ## E;\
@@ -101,19 +98,19 @@
roll$16,r1 ## E;\
shrl$16,r3 ## E;\
xorlTAB(,r7,4),r5 ## E; \
-   movzbl  r3 ## H,r7 ## E;\
-   movzbl  r3 ## L,r3 ## E;\
-   xorlTAB+3072(,r7,4),r4 ## E;\
-   xorlTAB+2048(,r3,4),r5 ## E;\
-   movzbl  r1 ## H,r7 ## E;\
-   movzbl  r1 ## L,r3 ## E;\
+   movzbl  r3 ## L,r7 ## E;\
+   movzbl  r3 ## H,r3 ## E;\
+   xorlTAB+3072(,r3,4),r4 ## E;\
+   xorlTAB+2048(,r7,4),r5 ## E;\
+   movzbl  r1 ## L,r7 ## E;\
+   movzbl  r1 ## H,r3 ## E;\
shrl$16,r1 ## E;\
-   xorlTAB+3072(,r7,4),r6 ## E;\
-   movlTAB+2048(,r3,4),r3 ## E;\
-   movzbl  r1 ## H,r7 ## E;\
-   movzbl  r1 ## L,r1 ## E;\
-   xorlTAB+1024(,r7,4),r6 ## E;\
-   xorlTAB(,r1,4),r3 ## E; \
+   xorlTAB+3072(,r3,4),r6 ## E;\
+   movlTAB+2048(,r7,4),r3 ## E;\
+   movzbl  r1 ## L,r7 ## E;\
+   movzbl  r1 ## H,r1 ## E;\
+   xorlTAB+1024(,r1,4),r6 ## E;\
+   xorlTAB(,r7,4),r3 ## E; \
movzbl  r2 ## H,r1 ## E;\
movzbl  r2 ## L,r7 ## E;\
shrl$16,r2 ## E;\
@@ -131,9 +128,9 @@
movlr4 ## E,r2 ## E;
 
 #define entry(FUNC,KEY,B128,B192) \
-   prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11)
+   prologue(FUNC,KEY,B128,B192,R2,R8,R1,R3,R4,R6,R10,R5,R11)
 
-#define return(FUNC) epilogue(FUNC,R8,R2,R9,R7,R5,R6,R3,R4,R11)
+#define return(FUNC) epilogue(FUNC,R8,R2,R5,R6,R3,R4,R11)
 
 #define encrypt_round(TAB,OFFSET) \
round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \
-- 
2.13.0



[PATCH net v3] net: x25: fix one potential use-after-free issue

2017-05-16 Thread linzhang
The function x25_init is not properly unregister related resources
on error handler.It is will result in kernel oops if x25_init init
failed, so add properly unregister call on error handler.

Also, i adjust the coding style and make x25_register_sysctl properly
return failure.

Signed-off-by: linzhang 
---

changelog:

v1 -> v2:
* make x25_register_sysctl properly return failure

v2 -> v3:
* keep the same lables as v1
* fix missing semicolon

---
 include/net/x25.h|  4 ++--
 net/x25/af_x25.c | 24 
 net/x25/sysctl_net_x25.c |  5 -
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/include/net/x25.h b/include/net/x25.h
index c383aa4..6d30a01 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -298,10 +298,10 @@ int x25_decode(struct sock *, struct sk_buff *, int *, 
int *, int *, int *,
 
 /* sysctl_net_x25.c */
 #ifdef CONFIG_SYSCTL
-void x25_register_sysctl(void);
+int x25_register_sysctl(void);
 void x25_unregister_sysctl(void);
 #else
-static inline void x25_register_sysctl(void) {};
+static inline int x25_register_sysctl(void) { return 0; };
 static inline void x25_unregister_sysctl(void) {};
 #endif /* CONFIG_SYSCTL */
 
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 8b911c2..5a1a98d 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1791,32 +1791,40 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
 
 static int __init x25_init(void)
 {
-   int rc = proto_register(&x25_proto, 0);
+   int rc;
 
-   if (rc != 0)
+   rc = proto_register(&x25_proto, 0);
+   if (rc)
goto out;
 
rc = sock_register(&x25_family_ops);
-   if (rc != 0)
+   if (rc)
goto out_proto;
 
dev_add_pack(&x25_packet_type);
 
rc = register_netdevice_notifier(&x25_dev_notifier);
-   if (rc != 0)
+   if (rc)
goto out_sock;
 
-   pr_info("Linux Version 0.2\n");
+   rc = x25_register_sysctl();
+   if (rc)
+   goto out_dev;
 
-   x25_register_sysctl();
rc = x25_proc_init();
-   if (rc != 0)
-   goto out_dev;
+   if (rc)
+   goto out_sysctl;
+
+   pr_info("Linux Version 0.2\n");
+
 out:
return rc;
+out_sysctl:
+   x25_unregister_sysctl();
 out_dev:
unregister_netdevice_notifier(&x25_dev_notifier);
 out_sock:
+   dev_remove_pack(&x25_packet_type);
sock_unregister(AF_X25);
 out_proto:
proto_unregister(&x25_proto);
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe1..ba078c8 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@
{ },
 };
 
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
 {
x25_table_header = register_net_sysctl(&init_net, "net/x25", x25_table);
+   if (!x25_table_header)
+   return -ENOMEM;
+   return 0;
 }
 
 void x25_unregister_sysctl(void)
-- 
1.8.3.1



RE: [PATCH 01/11] mwifiex: fixup error cases in mwifiex_add_virtual_intf()

2017-05-16 Thread Xinming Hu
Hi,

This patch serials looks fine, thanks.

> -Original Message-
> From: linux-wireless-ow...@vger.kernel.org
> [mailto:linux-wireless-ow...@vger.kernel.org] On Behalf Of Brian Norris
> Sent: 2017年5月13日 0:42
> To: Ganapathi Bhat; Nishant Sarmukadam
> Cc: linux-kernel@vger.kernel.org; Dmitry Torokhov; Amitkumar Karwar; Kalle
> Valo; linux-wirel...@vger.kernel.org; Doug Anderson; Brian Norris
> Subject: [PATCH 01/11] mwifiex: fixup error cases in 
> mwifiex_add_virtual_intf()
> 
> If we fail to add an interface in mwifiex_add_virtual_intf(), we might hit a
> BUG_ON() in the networking code, because we didn't tear things down
> properly. Among the problems:
> 
>  (a) when failing to allocate workqueues, we fail to unregister the
>  netdev before calling free_netdev()
>  (b) even if we do try to unregister the netdev, we're still holding the
>  rtnl lock, so the device never properly unregistered; we'll be at
>  state NETREG_UNREGISTERING, and then hit free_netdev()'s:
>   BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
>  (c) we're allocating some dependent resources (e.g., DFS workqueues)
>  after we've registered the interface; this may or may not cause
>  problems, but it's good practice to allocate these before registering
>  (d) we're not even trying to unwind anything when mwifiex_send_cmd() or
>  mwifiex_sta_init_cmd() fail
> 
> To fix these issues, let's:
> 
>  * add a stacked set of error handling labels, to keep error handling
>consistent and properly ordered (resolving (a) and (d))
>  * move the workqueue allocations before the registration (to resolve
>(c); also resolves (b) by avoiding error cases where we have to
>unregister)
> 
> [Incidentally, it's pretty easy to interrupt the alloc_workqueue() in, e.g., 
> the
> following:
> 
>   iw phy phy0 interface add mlan0 type station
> 
> by sending it SIGTERM.]
> 
> This bugfix covers commits like commit 7d652034d1a0 ("mwifiex: channel
> switch support for mwifiex"), but parts of this bug exist all the way back to 
> the
> introduction of dynamic interface handling in commit
> 93a1df48d224 ("mwifiex: add cfg80211 handlers add/del_virtual_intf").
> 
> Cc: 
> Signed-off-by: Brian Norris 
> ---
>  drivers/net/wireless/marvell/mwifiex/cfg80211.c | 71
> -
>  1 file changed, 35 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> index 7ec06bf13413..025bc06a19d6 100644
> --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> @@ -2964,10 +2964,8 @@ struct wireless_dev
> *mwifiex_add_virtual_intf(struct wiphy *wiphy,
>   if (!dev) {
>   mwifiex_dbg(adapter, ERROR,
>   "no memory available for netdevice\n");
> - memset(&priv->wdev, 0, sizeof(priv->wdev));
> - priv->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
> - priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
> - return ERR_PTR(-ENOMEM);
> + ret = -ENOMEM;
> + goto err_alloc_netdev;
>   }
> 
>   mwifiex_init_priv_params(priv, dev);
> @@ -2976,11 +2974,11 @@ struct wireless_dev
> *mwifiex_add_virtual_intf(struct wiphy *wiphy,
>   ret = mwifiex_send_cmd(priv, HostCmd_CMD_SET_BSS_MODE,
>  HostCmd_ACT_GEN_SET, 0, NULL, true);
>   if (ret)
> - return ERR_PTR(ret);
> + goto err_set_bss_mode;
> 
>   ret = mwifiex_sta_init_cmd(priv, false, false);
>   if (ret)
> - return ERR_PTR(ret);
> + goto err_sta_init;
> 
>   mwifiex_setup_ht_caps(&wiphy->bands[NL80211_BAND_2GHZ]->ht_cap,
> priv);
>   if (adapter->is_hw_11ac_capable)
> @@ -3011,31 +3009,14 @@ struct wireless_dev
> *mwifiex_add_virtual_intf(struct wiphy *wiphy,
> 
>   SET_NETDEV_DEV(dev, adapter->dev);
> 
> - /* Register network device */
> - if (register_netdevice(dev)) {
> - mwifiex_dbg(adapter, ERROR,
> - "cannot register virtual network device\n");
> - free_netdev(dev);
> - priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
> - priv->netdev = NULL;
> - memset(&priv->wdev, 0, sizeof(priv->wdev));
> - priv->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
> - return ERR_PTR(-EFAULT);
> - }
> -
>   priv->dfs_cac_workqueue = alloc_workqueue("MWIFIEX_DFS_CAC%s",
> WQ_HIGHPRI |
> WQ_MEM_RECLAIM |
> WQ_UNBOUND, 1, name);
>   if (!priv->dfs_cac_workqueue) {
> - mwifiex_dbg(adapter, ERROR,
> - "cannot register virtual network device\n");
> - free_netdev(dev);
> - priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED;
> -

Re: [PATCH] kprobes: Document how optimized kprobes are removed from module unload

2017-05-16 Thread Masami Hiramatsu
On Tue, 16 May 2017 22:46:02 -0400
Steven Rostedt  wrote:

> On Wed, 17 May 2017 10:47:07 +0900
> Masami Hiramatsu  wrote:
> 
> > On Tue, 16 May 2017 14:58:35 -0400
> > Steven Rostedt  wrote:
> > 
> > > From: Steven Rostedt (VMware) 
> > > 
> > > Thomas discovered a bug where the kprobe trace tests had a race
> > > condition where the kprobe_optimizer called from a delayed work queue
> > > that does the optimizing and "unoptimizing" of a kprobe, can try to
> > > modify the text after it has been freed by the init code.
> > > 
> > > The kprobe trace selftest is a special case, and Thomas and myself
> > > investigated to see if there's a chance that this could also be a bug
> > > with module unloading, as the code is not obvious to how it handles
> > > this. After adding lots of printks, I figured it out. Thomas suggested
> > > that this should be commented so that others will not have to go
> > > through this exercise again.
> > >   
> > 
> > OK, and I prefer this comment to move into kill_kprobe() right
> > before calling kill_optimized_kprobe() because that actually
> > does it.
> 
> Actually, I can add a comment in both places. I didn't put it into
> kill_kprobe() because, yes that's where it is done. I placed it in the
> module handler because that's where one will look to see if module
> unloading doesn't have any race conditions with the delayed handling.

OK, I see.

Acked-by: Masami Hiramatsu 

Thanks,

> 
> -- Steve
> 
> 
> > 
> > Thank you,
> > 
> > > Suggested-by: Thomas Gleixner 
> > > Signed-off-by: Steven Rostedt (VMware) 
> > > ---
> > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > > index 7367e0e..ac386f6 100644
> > > --- a/kernel/kprobes.c
> > > +++ b/kernel/kprobes.c
> > > @@ -2183,6 +2183,12 @@ static int kprobes_module_callback(struct 
> > > notifier_block *nb,
> > >* The vaddr this probe is installed will soon
> > >* be vfreed buy not synced to disk. Hence,
> > >* disarming the breakpoint isn't needed.
> > > +  *
> > > +  * Note, this will also move any optimized 
> > > probes
> > > +  * that are pending to be removed from their
> > > +  * corresponding lists to the freeing_list and
> > > +  * will not be touched by the delayed
> > > +  * kprobe_optimizer work handler.
> > >*/
> > >   kill_kprobe(p);
> > >   }  
> > 
> > 
> 


-- 
Masami Hiramatsu 


Re: [PATCHv2] Make initramfs honor CONFIG_DEVTMPFS_MOUNT

2017-05-16 Thread Michael Ellerman
Rob Landley  writes:

> diff --git a/init/main.c b/init/main.c
> index f866510..9ec09ff 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -1055,8 +1049,17 @@ static noinline void __init kernel_init_freeable(void)
>   if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
>   ramdisk_execute_command = NULL;
>   prepare_namespace();
> + } else if (IS_ENABLED(CONFIG_DEVTMPFS_MOUNT)) {
> + sys_mkdir("/dev", 0755);
> + devtmpfs_mount("/dev");
>   }
>  
> + /* Open the /dev/console on the rootfs, this should never fail */
> + if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)

Sorry to pile on, but while you're moving it do you want to update this
fairly misleading comment.

It definitely can fail, eg. if /dev/console doesn't exist, or if no
console driver is registered.

cheers


[PATCH] lpfc: fix build issue if NVME_FC_TARGET is not defined

2017-05-16 Thread James Smart
fix build issue if NVME_FC_TARGET is not defined. noop the code.
The code will never be invoked if target mode is not enabled.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvmet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 312f54278bd4..f94294b77b7b 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -157,6 +157,7 @@ lpfc_nvmet_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdwqe,
 void
 lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, struct lpfc_nvmet_ctxbuf 
*ctx_buf)
 {
+#if (IS_ENABLED(CONFIG_NVME_TARGET_FC))
struct lpfc_nvmet_rcv_ctx *ctxp = ctx_buf->context;
struct lpfc_nvmet_tgtport *tgtp;
struct fc_frame_header *fc_hdr;
@@ -260,6 +261,7 @@ lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, struct 
lpfc_nvmet_ctxbuf *ctx_buf)
  &phba->sli4_hba.lpfc_nvmet_ctx_list);
phba->sli4_hba.nvmet_ctx_cnt++;
spin_unlock_irqrestore(&phba->sli4_hba.nvmet_io_lock, iflag);
+#endif
 }
 
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
-- 
2.11.0



Re: [PATCH V2 6/6] tty: serial: lpuart: add a more accurate baud rate calculation method

2017-05-16 Thread Dong Aisheng
On Mon, May 15, 2017 at 10:06:41AM -0700, Stefan Agner wrote:
> On 2017-05-15 00:48, Dong Aisheng wrote:
> > On new LPUART versions, the oversampling ratio for the receiver can be
> > changed from 4x (00011) to 32x (1) which could help us get a more
> > accurate baud rate divider.
> > 
> > The idea is to use the best OSR (over-sampling rate) possible.
> > Note, OSR is typically hard-set to 16 in other LPUART instantiations.
> > Loop to find the best OSR value possible, one that generates minimum
> > baud diff iterate through the rest of the supported values of OSR.
> > 
> > Currently only i.MX7ULP is using it.
> > 
> > Cc: Greg Kroah-Hartman 
> > Cc: Jiri Slaby 
> > Cc: Stefan Agner 
> > Cc: Mingkai Hu 
> > Cc: Yangbo Lu 
> > Acked-by: Fugang Duan 
> > Signed-off-by: Dong Aisheng 
> > ---
> >  drivers/tty/serial/fsl_lpuart.c | 85 
> > ++---
> >  1 file changed, 79 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/fsl_lpuart.c 
> > b/drivers/tty/serial/fsl_lpuart.c
> > index 107d0911..bda4b0c 100644
> > --- a/drivers/tty/serial/fsl_lpuart.c
> > +++ b/drivers/tty/serial/fsl_lpuart.c
> > @@ -140,6 +140,8 @@
> >  #define UARTBAUD_SBNS  0x2000
> >  #define UARTBAUD_SBR   0x
> >  #define UARTBAUD_SBR_MASK  0x1fff
> > +#define UARTBAUD_OSR_MASK   0x1f
> > +#define UARTBAUD_OSR_SHIFT  24
> >  
> >  #define UARTSTAT_LBKDIF0x8000
> >  #define UARTSTAT_RXEDGIF   0x4000
> > @@ -1506,6 +1508,72 @@ lpuart_set_termios(struct uart_port *port,
> > struct ktermios *termios,
> >  }
> >  
> >  static void
> > +lpuart32_serial_setbrg(struct lpuart_port *sport, unsigned int baudrate)
> > +{
> > +   u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp;
> > +   u32 clk = sport->port.uartclk;
> > +
> > +   /*
> > +* The idea is to use the best OSR (over-sampling rate) possible.
> > +* Note, OSR is typically hard-set to 16 in other LPUART instantiations.
> > +* Loop to find the best OSR value possible, one that generates minimum
> > +* baud_diff iterate through the rest of the supported values of OSR.
> > +*
> > +* Calculation Formula:
> > +*  Baud Rate = baud clock / ((OSR+1) × SBR)
> > +*/
> > +   baud_diff = baudrate;
> > +   osr = 0;
> > +   sbr = 0;
> > +
> > +   for (tmp_osr = 4; tmp_osr <= 32; tmp_osr++) {
> > +   /* calculate the temporary sbr value  */
> > +   tmp_sbr = (clk / (baudrate * tmp_osr));
> > +   if (tmp_sbr == 0)
> > +   tmp_sbr = 1;
> > +
> > +   /*
> > +* calculate the baud rate difference based on the temporary
> > +* osr and sbr values
> > +*/
> > +   tmp_diff = clk / (tmp_osr * tmp_sbr) - baudrate;
> > +
> > +   /* select best values between sbr and sbr+1 */
> > +   tmp = clk / (tmp_osr * (tmp_sbr + 1));
> > +   if (tmp_diff > (baudrate - tmp)) {
> > +   tmp_diff = baudrate - tmp;
> > +   tmp_sbr++;
> > +   }
> > +
> > +   if (tmp_diff <= baud_diff) {
> > +   baud_diff = tmp_diff;
> > +   osr = tmp_osr;
> > +   sbr = tmp_sbr;
> > +   }
> > +   }
> > +
> > +   /* handle buadrate outside acceptable rate */
> > +   if (baud_diff > ((baudrate / 100) * 3))
> > +   dev_warn(sport->port.dev,
> > +"unacceptable baud rate difference of more than 
> > 3%%\n");
> > +
> > +   tmp = lpuart32_read(sport->port.membase + UARTBAUD);
> > +
> > +   if ((osr > 3) && (osr < 8))
> > +   tmp |= UARTBAUD_BOTHEDGE;
> > +
> > +   tmp &= ~(UARTBAUD_OSR_MASK << UARTBAUD_OSR_SHIFT);
> > +   tmp |= (((osr-1) & UARTBAUD_OSR_MASK) << UARTBAUD_OSR_SHIFT);
> > +
> > +   tmp &= ~UARTBAUD_SBR_MASK;
> > +   tmp |= sbr & UARTBAUD_SBR_MASK;
> > +
> > +   tmp &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE);
> > +
> > +   lpuart32_write(tmp, sport->port.membase + UARTBAUD);
> > +}
> > +
> > +static void
> >  lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
> >struct ktermios *old)
> >  {
> > @@ -1611,12 +1679,17 @@ lpuart32_set_termios(struct uart_port *port,
> > struct ktermios *termios,
> > lpuart32_write(old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE),
> > sport->port.membase + UARTCTRL);
> >  
> > -   sbr = sport->port.uartclk / (16 * baud);
> > -   bd &= ~UARTBAUD_SBR_MASK;
> > -   bd |= sbr & UARTBAUD_SBR_MASK;
> > -   bd |= UARTBAUD_BOTHEDGE;
> > -   bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE);
> > -   lpuart32_write(bd, sport->port.membase + UARTBAUD);
> > +   if (of_device_is_compatible(port->dev->of_node, "fsl,imx7ulp-lpuart")) {
> 
> Shouldn't we be consequent here and also use a flag in the soc data
> instead of of_device_is_compatible...?
> 

The original purpose is that this is a temporary code and supposed will
be deleted later once LS platforms confirmed the new baud setting API
wo

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

2017-05-16 Thread Stephen Rothwell
Hi all,

After merging the netfilter tree, today's linux-next build (i386
defconfig) failed like this:

net/netfilter/x_tables.c: In function 'xt_match_to_user':
net/netfilter/x_tables.c:303:13: error: implicit declaration of function 
'COMPAT_XT_ALIGN' [-Werror=implicit-function-declaration]
C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) :  \
 ^
net/netfilter/x_tables.c:310:9: note: in expansion of macro 'XT_DATA_TO_USER'
 XT_DATA_TO_USER(u, m, match, 0);
 ^

Caused by commit

  324318f0248c ("netfilter: xtables: zero padding in data_to_user")

In the !CONFIG_COMPAT case C_SIZE will always be zero, but the compiler
is still looking for the macro :-(

I added this cludge patch (I am sure it can be done better):

From: Stephen Rothwell 
Date: Wed, 17 May 2017 13:36:26 +1000
Subject: [PATCH] netfilter: xtables: fix for zero padding in data_to_user

Signed-off-by: Stephen Rothwell 
---
 net/netfilter/x_tables.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index d17769599c10..2b1785993a92 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -296,12 +296,20 @@ int xt_data_to_user(void __user *dst, const void *src,
 }
 EXPORT_SYMBOL_GPL(xt_data_to_user);
 
+#ifdef CONFIG_COMPAT
 #define XT_DATA_TO_USER(U, K, TYPE, C_SIZE)\
xt_data_to_user(U->data, K->data,   \
K->u.kernel.TYPE->usersize, \
C_SIZE ? : K->u.kernel.TYPE->TYPE##size,\
C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) :  \
 XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
+#else
+#define XT_DATA_TO_USER(U, K, TYPE, C_SIZE)\
+   xt_data_to_user(U->data, K->data,   \
+   K->u.kernel.TYPE->usersize, \
+   C_SIZE ? : K->u.kernel.TYPE->TYPE##size,\
+   C_SIZE ? : XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
+#endif
 
 int xt_match_to_user(const struct xt_entry_match *m,
 struct xt_entry_match __user *u)

-- 
Cheers,
Stephen Rothwell


Re: [PATCH v5 3/3] phy: Group vendor specific phy drivers

2017-05-16 Thread Vivek Gautam



On 05/16/2017 03:40 PM, Kishon Vijay Abraham I wrote:

Hi Vivek,

On Thursday 11 May 2017 12:17 PM, Vivek Gautam wrote:

Adding vendor specific directories in phy to group
phy drivers under their respective vendor umbrella.

Also updated the MAINTAINERS file to reflect the correct
directory structure for phy drivers.

Signed-off-by: Vivek Gautam 
Acked-by: Heiko Stuebner 
Acked-by: Viresh Kumar 
Acked-by: Krzysztof Kozlowski 
Acked-by: Yoshihiro Shimoda 
Reviewed-by: Jaehoon Chung 
Cc: Kishon Vijay Abraham I 
Cc: David S. Miller 
Cc: Geert Uytterhoeven 
Cc: Yoshihiro Shimoda 
Cc: Guenter Roeck 
Cc: Heiko Stuebner 
Cc: Viresh Kumar 
Cc: Maxime Ripard 
Cc: Chen-Yu Tsai 
Cc: Sylwester Nawrocki 
Cc: Krzysztof Kozlowski 
Cc: Jaehoon Chung 
Cc: Stephen Boyd 
Cc: Martin Blumenstingl 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-arm-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-o...@vger.kernel.org
Cc: linux-renesas-...@vger.kernel.org
Cc: linux-rockc...@lists.infradead.org
Cc: linux-samsung-...@vger.kernel.org
Cc: linux-...@vger.kernel.org
---

Changes since v4:
  - Reprepared the patch based on latest torvalds/master.
  - Added new directory for amlogic, since there's a new patch [1]
coming in for amlogic platforms.

Changes since v3:
  - Added 'Acked-by' and 'Reviewed by' tags received for this patch.
  - No functional change.

Changes since v2:
  - Rebased on linux-phy/next.
  - Took care of drivers added/removed for each vendors since v2.
  - Updated the 'Signed-off-by' tag with my current email id.

Changes from v1:
  - Updated the MAINTAINERS file to reflect the same change
in directory structure.
  - Removed PHY_PLAT config as pointed out by Kishon.
So we don't require the second patch in the v1 of this series:
[PATCH 2/2] arm: mach-spear: Enable PHY_PLAT to meet dependency
  - Renamed sunxi --> allwinner; rcar --> renesas.
  - Fixed error coming with qcom Makefile.

* Build tested multi_v7_defconfig.
* Build tested arm64 defconfig with all the involved configs enabled.

[1] https://patchwork.kernel.org/patch/9684303/


.
.

.
.

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index afaf7b643eeb..b353ac603ea0 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,73 +15,6 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this

.
.

.
.

-
+menu "Platform Phy drivers"

I don't think creating a new menu is required. I removed it and merged into
linux-phy.


Right. No need for a new menu. Thank you for fixing it and pushing out.

Best Regards
Vivek



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


--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 0/3] add and fix some device node for rk322x SoC

2017-05-16 Thread Frank Wang
These series of patches fix some device node errors and add watchdog
device node support for rk322x SoC.

Frank Wang (2):
  arm: dts: rk322x: correct uart2 pinctrl and add another sets
  arm: dts: rk322x: add watchdog device node.

Sugar Zhang (1):
  arm: dts: rk322x: fix i2s1 pinctrl error

 arch/arm/boot/dts/rk322x.dtsi | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

-- 
2.0.0




[PATCH 3/3] arm: dts: rk322x: add watchdog device node.

2017-05-16 Thread Frank Wang
Add watchdog device node for rk322x SoC.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index ea1239a..221251a 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -280,6 +280,14 @@
status = "disabled";
};
 
+   wdt: watchdog@110a {
+   compatible = "snps,dw-wdt";
+   reg = <0x110a 0x100>;
+   clocks = <&cru PCLK_CPU>;
+   interrupts = ;
+   status = "disabled";
+   };
+
pwm0: pwm@110b {
compatible = "rockchip,rk3288-pwm";
reg = <0x110b 0x10>;
-- 
2.0.0




[PATCH 2/3] arm: dts: rk322x: correct uart2 pinctrl and add another sets

2017-05-16 Thread Frank Wang
Correct UART2 PINCTRL flag and add another PINCTRL sets for UART2
in case of confict with SDMMC.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index cc6a27d..ea1239a 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -222,7 +222,7 @@
clocks = <&cru SCLK_UART2>, <&cru PCLK_UART2>;
clock-names = "baudclk", "apb_pclk";
pinctrl-names = "default";
-   pinctrl-0 = <&uart2_xfer>;
+   pinctrl-0 = <&uart21_xfer>;
reg-shift = <2>;
reg-io-width = <4>;
status = "disabled";
@@ -693,7 +693,7 @@
 
uart2 {
uart2_xfer: uart2-xfer {
-   rockchip,pins = <1 18 RK_FUNC_2 
&pcfg_pull_none>,
+   rockchip,pins = <1 18 RK_FUNC_2 &pcfg_pull_up>,
<1 19 RK_FUNC_2 
&pcfg_pull_none>;
};
 
@@ -705,5 +705,12 @@
rockchip,pins = <0 24 RK_FUNC_1 
&pcfg_pull_none>;
};
};
+
+   uart2-1 {
+   uart21_xfer: uart21-xfer {
+   rockchip,pins = <1 10 RK_FUNC_2 &pcfg_pull_up>,
+   <1 9 RK_FUNC_2 &pcfg_pull_none>;
+   };
+   };
};
 };
-- 
2.0.0




[PATCH 1/3] arm: dts: rk322x: fix i2s1 pinctrl error

2017-05-16 Thread Frank Wang
From: Sugar Zhang 

Refer to Chapter 5.3.2 of rk3229 TRM, we can see that GPIO1A[2,4,5]
using RK_FUNC_2 not RK_FUNC_1. This patch fixes it.

Signed-off-by: Frank Wang 
---
 arch/arm/boot/dts/rk322x.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index 48a0c1c..cc6a27d 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -621,9 +621,9 @@
<0 12 RK_FUNC_1 
&pcfg_pull_none>,
<0 13 RK_FUNC_1 
&pcfg_pull_none>,
<0 14 RK_FUNC_1 
&pcfg_pull_none>,
-   <1 2 RK_FUNC_1 &pcfg_pull_none>,
-   <1 4 RK_FUNC_1 &pcfg_pull_none>,
-   <1 5 RK_FUNC_1 &pcfg_pull_none>;
+   <1 2 RK_FUNC_2 &pcfg_pull_none>,
+   <1 4 RK_FUNC_2 &pcfg_pull_none>,
+   <1 5 RK_FUNC_2 &pcfg_pull_none>;
};
};
 
-- 
2.0.0




Re: [PATCH v3] x86/efi: Correct ident mapping of efi old_map when kalsr enabled

2017-05-16 Thread Baoquan He
On 05/17/17 at 11:35am, Baoquan He wrote:
> On 05/17/17 at 10:55am, Dave Young wrote:
> > Hi, Baoquan
> > >  arch/x86/platform/efi/efi_64.c | 69 
> > > +-
> > >  1 file changed, 61 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/arch/x86/platform/efi/efi_64.c 
> > > b/arch/x86/platform/efi/efi_64.c
> > > index c488625..c9dffec 100644
> > > --- a/arch/x86/platform/efi/efi_64.c
> > > +++ b/arch/x86/platform/efi/efi_64.c
> > > @@ -71,11 +71,13 @@ static void __init early_code_mapping_set_exec(int 
> > > executable)
> > >  
> > >  pgd_t * __init efi_call_phys_prolog(void)
> > >  {
> > > - unsigned long vaddress;
> > > - pgd_t *save_pgd;
> > > + unsigned long vaddr, addr_pgd, addr_p4d, addr_pud;
> > > + pgd_t *save_pgd, *pgd_k, *pgd_efi;
> > > + p4d_t *p4d, *p4d_k, *p4d_efi;
> > > + pud_t *pud;
> > >  
> > >   int pgd;
> > > - int n_pgds;
> > > + int n_pgds, i, j;
> > >  
> > >   if (!efi_enabled(EFI_OLD_MEMMAP)) {
> > >   save_pgd = (pgd_t *)read_cr3();
> > > @@ -88,10 +90,44 @@ pgd_t * __init efi_call_phys_prolog(void)
> > >   n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
> > >   save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL);
> > >  
> > > + /*
> > > +  * Build 1:1 ident mapping for old_map usage. It needs to be noticed
> > > +  * that PAGE_OFFSET is PGDIR_SIZE aligned with KASLR disabled, while
> > > +  * PUD_SIZE ALIGNED with KASLR enabled. So for a given physical
> > > +  * address X, the pud_index(X) != pud_index(__va(X)), we can only copy
> > > +  * pud entry of __va(X) to fill in pud entry of X to build 1:1 mapping
> > > +  * . Means here we can only reuse pmd table of direct mapping.
> > > +  */
> > >   for (pgd = 0; pgd < n_pgds; pgd++) {
> > > - save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
> > > - vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
> > > - set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), 
> > > *pgd_offset_k(vaddress));
> > > + addr_pgd = (unsigned long)(pgd * PGDIR_SIZE);
> > > + vaddr = (unsigned long)__va(pgd * PGDIR_SIZE);
> > > + pgd_efi = pgd_offset_k(addr_pgd);
> > > + save_pgd[pgd] = *pgd_efi;
> > > + p4d =  p4d_alloc(&init_mm, pgd_efi, addr_pgd);
> > > +
> > > + if (!p4d) {
> > > + pr_err("Failed to allocate p4d table \n");
> > > + goto out;
> > > + }
> > > + for(i=0; i > 
> > There is code style issue here and other for loop later..
> 
> Oops, I forget running scripts/checkpatch.pl to check patch. Will change
> and post v4. May post with sgi v4 fix about the sgi uv mmioh region
 ~~sgi uv
> issue, have discussed with HPE SGI developer about that.
> 
> Thanks for pointing it out!
> 
> Thanks
> Baoquan
> 
> > 
> > > + addr_p4d = addr_pgd + i * P4D_SIZE;
> > > + p4d_efi = p4d + p4d_index(addr_p4d);
> > > + pud = pud_alloc(&init_mm, p4d_efi, addr_p4d);
> > > + if (!pud) {
> > > + pr_err("Failed to allocate pud table \n");
> > > + goto out;
> > > + }
> > > + for(j=0; j > > + addr_pud = addr_p4d + j * PUD_SIZE;
> > > + if (addr_pud > (max_pfn << PAGE_SHIFT))
> > > + break;
> > > + vaddr = (unsigned long)__va(addr_pud);
> > > +
> > > + pgd_k = pgd_offset_k(vaddr);
> > > + p4d_k = p4d_offset(pgd_k, vaddr);
> > > + pud[j] = *pud_offset(p4d_k, vaddr);
> > > + }
> > > + }
> > >   }
> > >  out:
> > >   __flush_tlb_all();
> > > @@ -104,8 +140,11 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
> > >   /*
> > >* After the lock is released, the original page table is restored.
> > >*/
> > > - int pgd_idx;
> > > + int pgd_idx, i;
> > >   int nr_pgds;
> > > + pgd_t *pgd;
> > > +p4d_t *p4d;
> > > +pud_t *pud;
> > >  
> > >   if (!efi_enabled(EFI_OLD_MEMMAP)) {
> > >   write_cr3((unsigned long)save_pgd);
> > > @@ -115,9 +154,23 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
> > >  
> > >   nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
> > >  
> > > - for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++)
> > > + for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++) {
> > > + pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
> > >   set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
> > >  
> > > + if (!(pgd_val(*pgd) & _PAGE_PRESENT))
> > > + continue;
> > > + for(i=0; i > > + p4d = p4d_offset(pgd, pgd_idx * PGDIR_SIZE + i * 
> > > P4D_SIZE);
> > > + if (!(p4d_val(*p4d) & _PAGE_PRESENT))
> > > + continue;
> > > + pud = (pud_t*)p4d_page_vaddr(*p4d);
> > > + 

Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Dong Aisheng
On Tue, May 16, 2017 at 02:15:08PM +0300, Nikita Yushchenko wrote:
> >  static u32 lpuart32_read(void __iomem *addr)
> >  {
> > -   return ioread32be(addr);
> > +   return lpuart_is_be ? ioread32be(addr) : readl(addr);
> >  }
> >  
> >  static void lpuart32_write(u32 val, void __iomem *addr)
> >  {
> > -   iowrite32be(val, addr);
> > +   if (lpuart_is_be)
> > +   iowrite32be(val, addr);
> > +   else
> > +   writel(val, addr);
> >  }
> 
> What if this is ever executed on big endian system?
> 

Sorry, not catching the point...

What issues will meet?

Regards
Dong Aisheng


Re: [PATCH v3] x86/efi: Correct ident mapping of efi old_map when kalsr enabled

2017-05-16 Thread Baoquan He
On 05/17/17 at 10:55am, Dave Young wrote:
> Hi, Baoquan
> >  arch/x86/platform/efi/efi_64.c | 69 
> > +-
> >  1 file changed, 61 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
> > index c488625..c9dffec 100644
> > --- a/arch/x86/platform/efi/efi_64.c
> > +++ b/arch/x86/platform/efi/efi_64.c
> > @@ -71,11 +71,13 @@ static void __init early_code_mapping_set_exec(int 
> > executable)
> >  
> >  pgd_t * __init efi_call_phys_prolog(void)
> >  {
> > -   unsigned long vaddress;
> > -   pgd_t *save_pgd;
> > +   unsigned long vaddr, addr_pgd, addr_p4d, addr_pud;
> > +   pgd_t *save_pgd, *pgd_k, *pgd_efi;
> > +   p4d_t *p4d, *p4d_k, *p4d_efi;
> > +   pud_t *pud;
> >  
> > int pgd;
> > -   int n_pgds;
> > +   int n_pgds, i, j;
> >  
> > if (!efi_enabled(EFI_OLD_MEMMAP)) {
> > save_pgd = (pgd_t *)read_cr3();
> > @@ -88,10 +90,44 @@ pgd_t * __init efi_call_phys_prolog(void)
> > n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
> > save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL);
> >  
> > +   /*
> > +* Build 1:1 ident mapping for old_map usage. It needs to be noticed
> > +* that PAGE_OFFSET is PGDIR_SIZE aligned with KASLR disabled, while
> > +* PUD_SIZE ALIGNED with KASLR enabled. So for a given physical
> > +* address X, the pud_index(X) != pud_index(__va(X)), we can only copy
> > +* pud entry of __va(X) to fill in pud entry of X to build 1:1 mapping
> > +* . Means here we can only reuse pmd table of direct mapping.
> > +*/
> > for (pgd = 0; pgd < n_pgds; pgd++) {
> > -   save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
> > -   vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
> > -   set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), 
> > *pgd_offset_k(vaddress));
> > +   addr_pgd = (unsigned long)(pgd * PGDIR_SIZE);
> > +   vaddr = (unsigned long)__va(pgd * PGDIR_SIZE);
> > +   pgd_efi = pgd_offset_k(addr_pgd);
> > +   save_pgd[pgd] = *pgd_efi;
> > +   p4d =  p4d_alloc(&init_mm, pgd_efi, addr_pgd);
> > +
> > +   if (!p4d) {
> > +   pr_err("Failed to allocate p4d table \n");
> > +   goto out;
> > +   }
> > +   for(i=0; i 
> There is code style issue here and other for loop later..

Oops, I forget running scripts/checkpatch.pl to check patch. Will change
and post v4. May post with sgi v4 fix about the sgi uv mmioh region
issue, have discussed with HPE SGI developer about that.

Thanks for pointing it out!

Thanks
Baoquan

> 
> > +   addr_p4d = addr_pgd + i * P4D_SIZE;
> > +   p4d_efi = p4d + p4d_index(addr_p4d);
> > +   pud = pud_alloc(&init_mm, p4d_efi, addr_p4d);
> > +   if (!pud) {
> > +   pr_err("Failed to allocate pud table \n");
> > +   goto out;
> > +   }
> > +   for(j=0; j > +   addr_pud = addr_p4d + j * PUD_SIZE;
> > +   if (addr_pud > (max_pfn << PAGE_SHIFT))
> > +   break;
> > +   vaddr = (unsigned long)__va(addr_pud);
> > +
> > +   pgd_k = pgd_offset_k(vaddr);
> > +   p4d_k = p4d_offset(pgd_k, vaddr);
> > +   pud[j] = *pud_offset(p4d_k, vaddr);
> > +   }
> > +   }
> > }
> >  out:
> > __flush_tlb_all();
> > @@ -104,8 +140,11 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
> > /*
> >  * After the lock is released, the original page table is restored.
> >  */
> > -   int pgd_idx;
> > +   int pgd_idx, i;
> > int nr_pgds;
> > +   pgd_t *pgd;
> > +p4d_t *p4d;
> > +pud_t *pud;
> >  
> > if (!efi_enabled(EFI_OLD_MEMMAP)) {
> > write_cr3((unsigned long)save_pgd);
> > @@ -115,9 +154,23 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
> >  
> > nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
> >  
> > -   for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++)
> > +   for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++) {
> > +   pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
> > set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
> >  
> > +   if (!(pgd_val(*pgd) & _PAGE_PRESENT))
> > +   continue;
> > +   for(i=0; i > +   p4d = p4d_offset(pgd, pgd_idx * PGDIR_SIZE + i * 
> > P4D_SIZE);
> > +   if (!(p4d_val(*p4d) & _PAGE_PRESENT))
> > +   continue;
> > +   pud = (pud_t*)p4d_page_vaddr(*p4d);
> > +   pud_free(&init_mm, pud);
> > +}
> > +   p4d = (p4d_t*)pgd_page_vaddr(*pgd);
> > +   p4d_free(&init_mm, p4d);
> > +   }
> > +
> > kfre

Re: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Dong Aisheng
On Tue, May 16, 2017 at 02:08:12PM +0300, Nikita Yushchenko wrote:
> > @@ -2000,6 +2007,7 @@ static int lpuart_probe(struct platform_device *pdev)
> > }
> > sport->port.line = ret;
> > sport->lpuart32 = sdata->is_32;
> > +   lpuart_is_be = sdata->is_be;
> 
> Setting a global variable in per-device routine is quite bad design.
> 

There is a reason for that we don't want to change the exist 
lpuart32_read[write] API which is widely used in driver.
Making a global lpuart_is_be is the simplest way to do it.

Any strong blocking reason?

Regards
Dong Aisheng


Re: [PATCH V2 2/6] tty: serial: lpuart: add little endian 32 bit register support

2017-05-16 Thread Dong Aisheng
On Mon, May 15, 2017 at 04:36:25PM +0300, Andy Shevchenko wrote:
> On Mon, May 15, 2017 at 10:48 AM, Dong Aisheng  wrote:
> > It's based on the exist lpuart32 read/write implementation.
> 
> Same as per previous comment (perhaps not in other UART driver, but
> some might have been using device property for that.
> 

The reason why we do that is: a) we don't want to make a churn on the
exist users. b) it's not really necessary to use dt property
when we already have a soc_data as it has no much benefit but introduce
overhead.

Regards
Dong Aisheng

> 
> -- 
> With Best Regards,
> Andy Shevchenko


Re: [kbuild-all] [PATCH v4 2/3] hwmon: (adt7475) temperature smoothing

2017-05-16 Thread Chris Packham
On 17/05/17 15:09, Ye Xiaolong wrote:
> On 05/16, Chris Packham wrote:
>> On 16/05/17 20:23, kbuild test robot wrote:
>>> Hi Chris,
>>>
>>> [auto build test ERROR on hwmon/hwmon-next]
>>> [also build test ERROR on v4.12-rc1 next-20170516]
>>> [if your patch is applied to the wrong git tree, please drop us a note to 
>>> help improve the system]
>>>
>>> url:
>>> https://github.com/0day-ci/linux/commits/Chris-Packham/hwmon-adt7475-fan-stall-prevention/20170515-093530
>>> base:   
>>> https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
>>> hwmon-next
>>> config: x86_64-rhel (attached as .config)
>>> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
>>> reproduce:
>>> # save the attached .config to linux build tree
>>> make ARCH=x86_64
>>>
>>> All errors (new ones prefixed by >>):
>>>
>>>drivers/hwmon/adt7475.c: In function 'set_temp_st':
>>>>> drivers/hwmon/adt7475.c:622:9: error: implicit declaration of function 
>>>>> 'find_closest_descending' [-Werror=implicit-function-declaration]
>>>   val = find_closest_descending(val, ad7475_st_map,
>>> ^~~
>>>cc1: some warnings being treated as errors
>>>
>>> vim +/find_closest_descending +622 drivers/hwmon/adt7475.c
>>>
>>>616  shift = 4;
>>>617  idx = 1;
>>>618  break;
>>>619  }
>>>620  
>>>621  if (val > 0) {
>>>  > 622  val = find_closest_descending(val, 
>>> ad7475_st_map,
>>>623
>>> ARRAY_SIZE(ad7475_st_map));
>>>624  val |= 0x8;
>>>625  }
>>>
>>> ---
>>> 0-DAY kernel test infrastructureOpen Source Technology 
>>> Center
>>> https://lists.01.org/pipermail/kbuild-all   Intel 
>>> Corporation
>>>
>>
>> I'm not sure how this is failing. find_closest_descending() is a macro
>> defined in linux/util_macros.h which is explicitly included in
>> drivers/hwmon/adt7475.c. Aside from the include guards there's nothing
>> conditional about it.
>
> Hi,
>
> 0day bot applied your patchset on top of commit 6eaaea1 ("hwmon: (pmbus) Add 
> client driver for IR35221"),
> is it wrong or you have some prerequisite patches?
>

Looks like it's missing 
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?h=hwmon-next&id=bbb4dd0ff
 
which was part of the series but was applied after v3 so I didn't send 
it out with v4.


Re: [kbuild-all] [PATCH v4 2/3] hwmon: (adt7475) temperature smoothing

2017-05-16 Thread Ye Xiaolong
On 05/16, Chris Packham wrote:
>On 16/05/17 20:23, kbuild test robot wrote:
>> Hi Chris,
>>
>> [auto build test ERROR on hwmon/hwmon-next]
>> [also build test ERROR on v4.12-rc1 next-20170516]
>> [if your patch is applied to the wrong git tree, please drop us a note to 
>> help improve the system]
>>
>> url:
>> https://github.com/0day-ci/linux/commits/Chris-Packham/hwmon-adt7475-fan-stall-prevention/20170515-093530
>> base:   
>> https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 
>> hwmon-next
>> config: x86_64-rhel (attached as .config)
>> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
>> reproduce:
>> # save the attached .config to linux build tree
>> make ARCH=x86_64
>>
>> All errors (new ones prefixed by >>):
>>
>>drivers/hwmon/adt7475.c: In function 'set_temp_st':
>>>> drivers/hwmon/adt7475.c:622:9: error: implicit declaration of function 
>>>> 'find_closest_descending' [-Werror=implicit-function-declaration]
>>   val = find_closest_descending(val, ad7475_st_map,
>> ^~~
>>cc1: some warnings being treated as errors
>>
>> vim +/find_closest_descending +622 drivers/hwmon/adt7475.c
>>
>>616   shift = 4;
>>617   idx = 1;
>>618   break;
>>619   }
>>620   
>>621   if (val > 0) {
>>  > 622   val = find_closest_descending(val, 
>> ad7475_st_map,
>>623 
>> ARRAY_SIZE(ad7475_st_map));
>>624   val |= 0x8;
>>625   }
>>
>> ---
>> 0-DAY kernel test infrastructureOpen Source Technology Center
>> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>>
>
>I'm not sure how this is failing. find_closest_descending() is a macro 
>defined in linux/util_macros.h which is explicitly included in 
>drivers/hwmon/adt7475.c. Aside from the include guards there's nothing 
>conditional about it.

Hi,

0day bot applied your patchset on top of commit 6eaaea1 ("hwmon: (pmbus) Add 
client driver for IR35221"),
is it wrong or you have some prerequisite patches?

Thanks,
Xiaolong
>___
>kbuild-all mailing list
>kbuild-...@lists.01.org
>https://lists.01.org/mailman/listinfo/kbuild-all


Re: [PATCH v2 1/4] ftrace: Simplify glob handling in unregister_ftrace_function_probe_func()

2017-05-16 Thread Masami Hiramatsu
On Tue, 16 May 2017 23:21:25 +0530
"Naveen N. Rao"  wrote:

> Handle a NULL glob properly and simplify the check.
> 

Looks good to me.

Reviewed-by: Masami Hiramatsu 

Thanks!

> Signed-off-by: Naveen N. Rao 
> ---
>  kernel/trace/ftrace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 39dca4e86a94..c35c3e67d09a 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -4144,9 +4144,9 @@ unregister_ftrace_function_probe_func(char *glob, 
> struct trace_array *tr,
>   int i, ret = -ENODEV;
>   int size;
>  
> - if (glob && (strcmp(glob, "*") == 0 || !strlen(glob)))
> + if (!glob || !strlen(glob) || !strcmp(glob, "*"))
>   func_g.search = NULL;
> - else if (glob) {
> + else {
>   int not;
>  
>   func_g.type = filter_parse_regex(glob, strlen(glob),
> -- 
> 2.12.2
> 


-- 
Masami Hiramatsu 


Re: [Patch v2] mm/vmscan: fix unsequenced modification and access warning

2017-05-16 Thread Nick Desaulniers
> I guess it is worth reporting this to clang bugzilla. Could you take
> care of that Nick?

Done: https://bugs.llvm.org//show_bug.cgi?id=33065


linux-next: build failure after merge of the scsi-mkp tree

2017-05-16 Thread Stephen Rothwell
Hi Martin,

After merging the scsi-mkp tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

ERROR: ".nvmet_fc_rcv_fcp_req" [drivers/scsi/lpfc/lpfc.ko] undefined!

Caused by commit

  a8cf5dfeb4d8 ("scsi: lpfc: Added recovery logic for running out of NVMET IO 
context resources")

CONFIG_NVME_TARGET_FC is not set for this build.

I have used the scsi-mkp tree from next-20170516 for today.

-- 
Cheers,
Stephen Rothwell


Re: [PATCH v3] x86/efi: Correct ident mapping of efi old_map when kalsr enabled

2017-05-16 Thread Dave Young
Hi, Baoquan

On 05/13/17 at 11:56am, Baoquan He wrote:
> For EFI with 'efi=old_map' kernel option specified, Kernel will panic
> when kaslr is enabled.
> 
> The back trace is:
> 
> BUG: unable to handle kernel paging request at 7febd57e
> IP: 0x7febd57e
> PGD 1025a067
> PUD 0
> 
> Oops: 0010 [#1] SMP
> [ ... ]
> Call Trace:
>  ? efi_call+0x58/0x90
>  ? printk+0x58/0x6f
>  efi_enter_virtual_mode+0x3c5/0x50d
>  start_kernel+0x40f/0x4b8
>  ? set_init_arg+0x55/0x55
>  ? early_idt_handler_array+0x120/0x120
>  x86_64_start_reservations+0x24/0x26
>  x86_64_start_kernel+0x14c/0x16f
>  start_cpu+0x14/0x14
> 
> The root cause is the ident mapping is not built correctly in old_map case.
> 
> For nokaslr kernel, PAGE_OFFSET is 0x8800 which is PGDIR_SIZE
> aligned. We can borrow the pud table from direct mapping safely. Given a
> physical address X, we have pud_index(X) == pud_index(__va(X)). However,
> for kaslr kernel, PAGE_OFFSET is PUD_SIZE aligned. For a given physical
> address X, pud_index(X) != pud_index(__va(X)). We can't only copy pgd entry
> from direct mapping to build ident mapping, instead need copy pud entry
> one by one from direct mapping.
> 
> Fix it.
> 
> Signed-off-by: Baoquan He 
> Signed-off-by: Dave Young 
> Cc: Matt Fleming 
> Cc: Ard Biesheuvel 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: Thomas Garnier 
> Cc: Kees Cook 
> Cc: x...@kernel.org
> Cc: linux-...@vger.kernel.org
> ---
> v2->v3:
> 1. Rewrite code to copy pud entry one by one so that code can be 
> understood
> better. Usually we only have less than 1TB or several TB memory, pud entry
> copy one by one won't impact efficiency.
> 
> 2. Adding p4d page table handling.
> 
> v1->v2:
> Change code and add description according to Thomas's suggestion as below:
> 
> 1. Add checking if pud table is allocated successfully. If not just break
> the for loop.
> 
> 2. Add code comment to explain how the 1:1 mapping is built in 
> efi_call_phys_prolog
> 
> 3. Other minor change
> 
>  arch/x86/platform/efi/efi_64.c | 69 
> +-
>  1 file changed, 61 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
> index c488625..c9dffec 100644
> --- a/arch/x86/platform/efi/efi_64.c
> +++ b/arch/x86/platform/efi/efi_64.c
> @@ -71,11 +71,13 @@ static void __init early_code_mapping_set_exec(int 
> executable)
>  
>  pgd_t * __init efi_call_phys_prolog(void)
>  {
> - unsigned long vaddress;
> - pgd_t *save_pgd;
> + unsigned long vaddr, addr_pgd, addr_p4d, addr_pud;
> + pgd_t *save_pgd, *pgd_k, *pgd_efi;
> + p4d_t *p4d, *p4d_k, *p4d_efi;
> + pud_t *pud;
>  
>   int pgd;
> - int n_pgds;
> + int n_pgds, i, j;
>  
>   if (!efi_enabled(EFI_OLD_MEMMAP)) {
>   save_pgd = (pgd_t *)read_cr3();
> @@ -88,10 +90,44 @@ pgd_t * __init efi_call_phys_prolog(void)
>   n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
>   save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL);
>  
> + /*
> +  * Build 1:1 ident mapping for old_map usage. It needs to be noticed
> +  * that PAGE_OFFSET is PGDIR_SIZE aligned with KASLR disabled, while
> +  * PUD_SIZE ALIGNED with KASLR enabled. So for a given physical
> +  * address X, the pud_index(X) != pud_index(__va(X)), we can only copy
> +  * pud entry of __va(X) to fill in pud entry of X to build 1:1 mapping
> +  * . Means here we can only reuse pmd table of direct mapping.
> +  */
>   for (pgd = 0; pgd < n_pgds; pgd++) {
> - save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
> - vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
> - set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), 
> *pgd_offset_k(vaddress));
> + addr_pgd = (unsigned long)(pgd * PGDIR_SIZE);
> + vaddr = (unsigned long)__va(pgd * PGDIR_SIZE);
> + pgd_efi = pgd_offset_k(addr_pgd);
> + save_pgd[pgd] = *pgd_efi;
> + p4d =  p4d_alloc(&init_mm, pgd_efi, addr_pgd);
> +
> + if (!p4d) {
> + pr_err("Failed to allocate p4d table \n");
> + goto out;
> + }
> + for(i=0; i + addr_p4d = addr_pgd + i * P4D_SIZE;
> + p4d_efi = p4d + p4d_index(addr_p4d);
> + pud = pud_alloc(&init_mm, p4d_efi, addr_p4d);
> + if (!pud) {
> + pr_err("Failed to allocate pud table \n");
> + goto out;
> + }
> + for(j=0; j + addr_pud = addr_p4d + j * PUD_SIZE;
> + if (addr_pud > (max_pfn << PAGE_SHIFT))
> + break;
> + vaddr = (unsigned long)__va(addr_pud);
> +
> +   

Re: [PATCH] hwspinlock: sprd: Add hardware spinlock driver

2017-05-16 Thread Baolin Wang
Hi Bjorn,

On 17 May 2017 at 03:18, Bjorn Andersson  wrote:
> On Tue 16 May 00:54 PDT 2017, Baolin Wang wrote:
>
>> diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile
>> index 6b59cb5a..03c442f 100644
>> --- a/drivers/hwspinlock/Makefile
>> +++ b/drivers/hwspinlock/Makefile
>> @@ -7,3 +7,4 @@ obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o
>>  obj-$(CONFIG_HWSPINLOCK_QCOM)+= qcom_hwspinlock.o
>>  obj-$(CONFIG_HWSPINLOCK_SIRF)+= sirf_hwspinlock.o
>>  obj-$(CONFIG_HSEM_U8500) += u8500_hsem.o
>> +obj-$(CONFIG_HWSPINLOCK_SPRD)+= sprd_hwspinlock.o
>
> Please move this one line up, to keep the alphabetical sort order
> (please make sure to update the order in Kconfig accordingly).

OK.

>
>> diff --git a/drivers/hwspinlock/sprd_hwspinlock.c 
>> b/drivers/hwspinlock/sprd_hwspinlock.c
>> new file mode 100644
>> index 000..898738f
>> --- /dev/null
>> +++ b/drivers/hwspinlock/sprd_hwspinlock.c
>> @@ -0,0 +1,243 @@
>> +/*
>> + * Spreadtrum hardware spinlock driver
>> + * Copyright (C) 2017 Spreadtrum  - http://www.spreadtrum.com
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * version 2 as published by the Free Software Foundation.
>> + *
>> + * 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 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>
> I don't see a need for spinlock.h

Will remove it.

>
>> +
>> +#include "hwspinlock_internal.h"
>> +
>> +/* hwspinlock registers definition */
>> +#define HWSPINLOCK_RECCTRL   0x4
>> +#define HWSPINLOCK_TTLSTS0x8
>> +#define HWSPINLOCK_FLAG0 0x10
>> +#define HWSPINLOCK_FLAG1 0x14
>> +#define HWSPINLOCK_FLAG2 0x18
>> +#define HWSPINLOCK_FLAG3 0x1c
>
> These flags are unused.

These may be used in future, but I will remove them now.

>
>> +#define HWSPINLOCK_MASTERID(_X_) (0x80 + 0x4 * (_X_))
>> +#define HWSPINLOCK_TOKEN(_X_)(0x800 + 0x4 * (_X_))
>> +#define HWSPINLOCK_VERID 0xFFC
>
> verid is unused.

Will remove it.

>
>> +
>> +/* untoken lock value */
>
> untaken? Perhaps "unlocked value" instead?

OK.

>
>> +#define HWSPINLOCK_NOTTAKEN  0x55aa10c5
>> +/* bits definition of RECCTRL reg */
>> +#define HWSPINLOCK_ID0x0
>
> id is unused.

Will remove it now.

>
>> +#define HWSPINLOCK_USER_BITS 0x1
>> +
>> +/* hwspinlock number */
>> +#define SPRD_HWLOCKS_NUM 32
>> +
>> +struct sprd_hwspinlock_dev {
>> + void __iomem *base;
>> + struct clk *clk;
>> + unsigned char status[SPRD_HWLOCKS_NUM];
>> + struct hwspinlock_device bank;
>> +};
>> +
>> +static const struct of_device_id sprd_hwspinlock_of_match[] = {
>> + { .compatible = "sprd,hwspinlock-r3p0",},
>> + { /* sentinel */ }
>> +};
>
> Please move this next to the definition of sprd_hwspinlock_driver and
> add the missing MODULE_DEVICE_TABLE(of, sprd_hwspinlock_of_match);

OK.

>
>> +
>> +static struct sprd_hwspinlock_dev *sprd_lock_to_dev(struct hwspinlock *lock)
>> +{
>> + struct hwspinlock_device *hwbank;
>> + unsigned int lock_id = hwlock_to_id(lock);
>> +
>> + hwbank = container_of(lock, struct hwspinlock_device, lock[lock_id]);
>> + return container_of(hwbank, struct sprd_hwspinlock_dev, bank);
>
> As you platform_set_drvdata the sprd_hwspinlock_dev in probe you can
> implement this with function with
>
> return dev_get_drvdata(lock->bank->dev);

Yes, you are correct, and I will change it.

>
>> +}
>> +
>> +/* set the hardware spinlock record type */
>> +static void sprd_set_hwspinlock_record(struct sprd_hwspinlock_dev 
>> *sprd_hwlock,
>> +unsigned int type)
>> +{
>> + writel_relaxed(type, sprd_hwlock->base + HWSPINLOCK_RECCTRL);
>
> Please use writel() and please inline this write into the probe function.

OK.

>
>> +}
>> +
>> +/* get the hardware spinlock master/user id */
>> +static unsigned int sprd_get_hwspinlock_id(struct sprd_hwspinlock_dev 
>> *sprd_hwlock,
>> +unsigned int lock_id)
>> +{
>> + return readl_relaxed(sprd_hwlock->base + HWSPINLOCK_MASTERID(lock_id));
>
> Please use readl() and please inline this function in
> sprd_hwspinlock_trylock()

OK.

>
>> +}
>> +
>> +/* record the hardware spinlock status */
>> +static int sprd_record_hwspinlock_sts(struct hwspinlock *lock)
>
> The hwlock->status is not read by anyone, so please remove this
> function.

Sometime we will dump memory to analy

Re: [PATCH] kprobes: Document how optimized kprobes are removed from module unload

2017-05-16 Thread Steven Rostedt
On Wed, 17 May 2017 10:47:07 +0900
Masami Hiramatsu  wrote:

> On Tue, 16 May 2017 14:58:35 -0400
> Steven Rostedt  wrote:
> 
> > From: Steven Rostedt (VMware) 
> > 
> > Thomas discovered a bug where the kprobe trace tests had a race
> > condition where the kprobe_optimizer called from a delayed work queue
> > that does the optimizing and "unoptimizing" of a kprobe, can try to
> > modify the text after it has been freed by the init code.
> > 
> > The kprobe trace selftest is a special case, and Thomas and myself
> > investigated to see if there's a chance that this could also be a bug
> > with module unloading, as the code is not obvious to how it handles
> > this. After adding lots of printks, I figured it out. Thomas suggested
> > that this should be commented so that others will not have to go
> > through this exercise again.
> >   
> 
> OK, and I prefer this comment to move into kill_kprobe() right
> before calling kill_optimized_kprobe() because that actually
> does it.

Actually, I can add a comment in both places. I didn't put it into
kill_kprobe() because, yes that's where it is done. I placed it in the
module handler because that's where one will look to see if module
unloading doesn't have any race conditions with the delayed handling.

-- Steve


> 
> Thank you,
> 
> > Suggested-by: Thomas Gleixner 
> > Signed-off-by: Steven Rostedt (VMware) 
> > ---
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 7367e0e..ac386f6 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -2183,6 +2183,12 @@ static int kprobes_module_callback(struct 
> > notifier_block *nb,
> >  * The vaddr this probe is installed will soon
> >  * be vfreed buy not synced to disk. Hence,
> >  * disarming the breakpoint isn't needed.
> > +*
> > +* Note, this will also move any optimized 
> > probes
> > +* that are pending to be removed from their
> > +* corresponding lists to the freeing_list and
> > +* will not be touched by the delayed
> > +* kprobe_optimizer work handler.
> >  */
> > kill_kprobe(p);
> > }  
> 
> 



  1   2   3   4   5   6   7   8   9   >