Re: [PATCH] wcn36xx: Disable 5GHz for wcn3610

2018-03-28 Thread Rafał Miłecki

On 03/29/2018 08:20 AM, Ramon Fried wrote:

wcn3610 can only operate on 2.4GHz band due to RF limitation.
If wcn36xx digital block is associated with an external IRIS
RF module, retrieve the id and disable 5GHz band in case of
wcn3610 id.

Signed-off-by: Ramon Fried 
---
 drivers/net/wireless/ath/wcn36xx/main.c| 4 +++-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index ab5be6d2c691..833531a68c95 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1146,7 +1146,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
BIT(NL80211_IFTYPE_MESH_POINT);

wcn->hw->wiphy->bands[NL80211_BAND_2GHZ] = &wcn_band_2ghz;
-   if (wcn->rf_id != RF_IRIS_WCN3620)
+   if (wcn->rf_id != RF_IRIS_WCN3610 && wcn->rf_id != RF_IRIS_WCN3620)
wcn->hw->wiphy->bands[NL80211_BAND_5GHZ] = &wcn_band_5ghz;

wcn->hw->wiphy->max_scan_ssids = WCN36XX_MAX_SCAN_SSIDS;
@@ -1248,6 +1248,8 @@ static int wcn36xx_platform_get_resources(struct wcn36xx 
*wcn,
if (iris_node) {
if (of_device_is_compatible(iris_node, "qcom,wcn3620"))
wcn->rf_id = RF_IRIS_WCN3620;
+   else if (of_device_is_compatible(iris_node, "qcom,wcn3610"))
+   wcn->rf_id = RF_IRIS_WCN3620;


RF_IRIS_WCN3610 ?


[PATCH v2] wcn36xx: Disable 5GHz for wcn3610

2018-03-28 Thread Ramon Fried
wcn3610 can only operate on 2.4GHz band due to RF limitation.
If wcn36xx digital block is associated with an external IRIS
RF module, retrieve the id and disable 5GHz band in case of
wcn3610 id.

Signed-off-by: Ramon Fried 
---
v2: fixed wrong assignment, which is logically introduces the 
same behaviour, but for correctness.

 drivers/net/wireless/ath/wcn36xx/main.c| 4 +++-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index ab5be6d2c691..833531a68c95 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1146,7 +1146,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
BIT(NL80211_IFTYPE_MESH_POINT);
 
wcn->hw->wiphy->bands[NL80211_BAND_2GHZ] = &wcn_band_2ghz;
-   if (wcn->rf_id != RF_IRIS_WCN3620)
+   if (wcn->rf_id != RF_IRIS_WCN3610 && wcn->rf_id != RF_IRIS_WCN3620)
wcn->hw->wiphy->bands[NL80211_BAND_5GHZ] = &wcn_band_5ghz;
 
wcn->hw->wiphy->max_scan_ssids = WCN36XX_MAX_SCAN_SSIDS;
@@ -1248,6 +1248,8 @@ static int wcn36xx_platform_get_resources(struct wcn36xx 
*wcn,
if (iris_node) {
if (of_device_is_compatible(iris_node, "qcom,wcn3620"))
wcn->rf_id = RF_IRIS_WCN3620;
+   else if (of_device_is_compatible(iris_node, "qcom,wcn3610"))
+   wcn->rf_id = RF_IRIS_WCN3610;
of_node_put(iris_node);
}
 
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h 
b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index 81017e6703b4..bc4d1a10d90e 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -95,6 +95,7 @@ enum wcn36xx_ampdu_state {
 #define WCN36XX_MAX_POWER(__wcn) (__wcn->hw->conf.chandef.chan->max_power)
 
 #define RF_UNKNOWN 0x
+#define RF_IRIS_WCN36100x3610
 #define RF_IRIS_WCN36200x3620
 
 static inline void buff_to_be(u32 *buf, size_t len)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH 4/8] dma-buf: add peer2peer flag

2018-03-28 Thread Daniel Vetter
On Sun, Mar 25, 2018 at 12:59:56PM +0200, Christian König wrote:
> Add a peer2peer flag noting that the importer can deal with device
> resources which are not backed by pages.
> 
> Signed-off-by: Christian König 

Um strictly speaking they all should, but ttm never bothered to use the
real interfaces but just hacked around the provided sg list, grabbing the
underlying struct pages, then rebuilding&remapping the sg list again.

The entire point of using sg lists was exactly to allow this use case of
peer2peer dma (or well in general have special exporters which managed
memory/IO ranges not backed by struct page). So essentially you're having
a "I'm totally not broken flag" here.

I think a better approach would be if we add a requires_struct_page or so,
and annotate the current importers accordingly. Or we just fix them up (it
is all in shared ttm code after all, I think everyone else got this
right).
-Daniel

> ---
>  drivers/dma-buf/dma-buf.c | 1 +
>  include/linux/dma-buf.h   | 4 
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index ffaa2f9a9c2c..f420225f93c6 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -565,6 +565,7 @@ struct dma_buf_attachment *dma_buf_attach(const struct 
> dma_buf_attach_info *info
>  
>   attach->dev = info->dev;
>   attach->dmabuf = dmabuf;
> + attach->peer2peer = info->peer2peer;
>   attach->priv = info->priv;
>   attach->invalidate = info->invalidate;
>  
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index 15dd8598bff1..1ef50bd9bc5b 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -313,6 +313,7 @@ struct dma_buf {
>   * @dmabuf: buffer for this attachment.
>   * @dev: device attached to the buffer.
>   * @node: list of dma_buf_attachment.
> + * @peer2peer: true if the importer can handle peer resources without pages.
>   * @priv: exporter specific attachment data.
>   *
>   * This structure holds the attachment information between the dma_buf buffer
> @@ -328,6 +329,7 @@ struct dma_buf_attachment {
>   struct dma_buf *dmabuf;
>   struct device *dev;
>   struct list_head node;
> + bool peer2peer;
>   void *priv;
>  
>   /**
> @@ -392,6 +394,7 @@ struct dma_buf_export_info {
>   * @dmabuf:  the exported dma_buf
>   * @dev: the device which wants to import the attachment
>   * @priv:private data of importer to this attachment
> + * @peer2peer:   true if the importer can handle peer resources without 
> pages
>   * @invalidate:  callback to use for invalidating mappings
>   *
>   * This structure holds the information required to attach to a buffer. Used
> @@ -401,6 +404,7 @@ struct dma_buf_attach_info {
>   struct dma_buf *dmabuf;
>   struct device *dev;
>   void *priv;
> + bool peer2peer;
>   void (*invalidate)(struct dma_buf_attachment *attach);
>  };
>  
> -- 
> 2.14.1
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


Re: [PATCH v4 09/16] m68k: Use generic free_initrd_mem.

2018-03-28 Thread Geert Uytterhoeven
On Wed, Mar 28, 2018 at 10:36 PM, Shea Levy  wrote:
> Signed-off-by: Shea Levy 

Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v5] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Minchan Kim
binder_update_page_range needs down_write of mmap_sem because
vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
it is set. However, when I profile binder working, it seems
every binder buffers should be mapped in advance by binder_mmap.
It means we could set VM_MIXEDMAP in binder_mmap time which is
already hold a mmap_sem as down_write so binder_update_page_range
doesn't need to hold a mmap_sem as down_write.

Android suffers from mmap_sem contention so let's reduce mmap_sem
down_write.

Cc: Joe Perches 
Cc: Arve Hjønnevåg 
Cc: Todd Kjos 
Cc: Greg Kroah-Hartman 
Reviewed-by: Martijn Coenen 
Signed-off-by: Minchan Kim 
---
>From v4:
  * Fix typo and VM flags clear handling - Joe

>From v3:
  * Fix typo

>From v2:
  * Fix vma->flag setting - Arve

>From v1:
  * remove WARN_ON_ONCE - Greg
  * add reviewed-by - Martijn

Martijn, I took your LGTM of v1 as Reviewed-by. If you don't like it
or want to change it to acked-by, please, tell me.

 drivers/android/binder.c   | 4 +++-
 drivers/android/binder_alloc.c | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 764b63a5aade..bb63e3b54e0c 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4722,7 +4722,9 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
failure_string = "bad vm_flags";
goto err_bad_arg;
}
-   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
+   vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
+   vma->vm_flags &= ~VM_MAYWRITE;
+
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 5a426c877dfb..4f382d51def1 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -219,7 +219,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
mm = alloc->vma_vm_mm;
 
if (mm) {
-   down_write(&mm->mmap_sem);
+   down_read(&mm->mmap_sem);
vma = alloc->vma;
}
 
@@ -288,7 +288,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
/* vm_insert_page does not seem to increment the refcount */
}
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return 0;
@@ -321,7 +321,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
}
 err_no_vma:
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return vma ? -ENOMEM : -ESRCH;
-- 
2.17.0.rc1.321.gba9d0f2565-goog



Re: Regression in 4.16-rc7 - ipsec vpn broken

2018-03-28 Thread Steffen Klassert
Please always make sure to Cc net...@vger.kernel.org
on networking problems.

On Wed, Mar 28, 2018 at 10:21:32PM +, Derek Robson wrote:
> The ipsec VPN is broken in 4.16-rc7 and seem to have been broken in all of
> 4.15
> 
> connecting from an iphone seems to give a timeout.
> 
> 
> A bisect brings me to this commit as the one that is the issue.
> 
> commit: acf568ee859f098279eadf551612f103afdacb4e  (xfrm: Reinject
> transport-mode packets through tasklet)

I have a fix queued for this commit in the ipsec tree.

Can you please try if the patch below fixes your problems?

Thanks!

Subject: [PATCH] xfrm: Fix transport mode skb control buffer usage.

A recent commit introduced a new struct xfrm_trans_cb
that is used with the sk_buff control buffer. Unfortunately
it placed the structure in front of the control buffer and
overlooked that the IPv4/IPv6 control buffer is still needed
for some layer 4 protocols. As a result the IPv4/IPv6 control
buffer is overwritten with this structure. Fix this by setting
a apropriate header in front of the structure.

Fixes acf568ee859f ("xfrm: Reinject transport-mode packets ...")
Signed-off-by: Steffen Klassert 
---
 net/xfrm/xfrm_input.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 1472c0857975..81788105c164 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -26,6 +26,12 @@ struct xfrm_trans_tasklet {
 };
 
 struct xfrm_trans_cb {
+   union {
+   struct inet_skb_parmh4;
+#if IS_ENABLED(CONFIG_IPV6)
+   struct inet6_skb_parm   h6;
+#endif
+   } header;
int (*finish)(struct net *net, struct sock *sk, struct sk_buff *skb);
 };
 
-- 
2.14.1



Re: [PATCH v4] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Joe Perches
On Thu, 2018-03-29 at 15:40 +0900, Minchan Kim wrote:
> binder_update_page_range needs down_write of mmap_sem because
> vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
> it is set. However, when I profile binder working, it seems
> every binder buffers should be mapped in advance by binder_mmap.
> It means we could set VM_MIXEDMAP in bider_mmap time which is

typo trivia: binder_mmap

> already hold a mmap_sem as down_write so binder_update_page_range
> doesn't need to hold a mmap_sem as down_write.

and style trivia:

> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
[]
> @@ -4722,7 +4722,8 @@ static int binder_mmap(struct file *filp, struct 
> vm_area_struct *vma)
>   failure_string = "bad vm_flags";
>   goto err_bad_arg;
>   }
> - vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
> + vma->vm_flags = (vma->vm_flags | VM_DONTCOPY | VM_MIXEDMAP) &
> + ~VM_MAYWRITE;

Perhaps this is clearer as

vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
vma->vm_flags &= ~VM_MAYWRITE;



[PATCH v4] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Minchan Kim
binder_update_page_range needs down_write of mmap_sem because
vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
it is set. However, when I profile binder working, it seems
every binder buffers should be mapped in advance by binder_mmap.
It means we could set VM_MIXEDMAP in bider_mmap time which is
already hold a mmap_sem as down_write so binder_update_page_range
doesn't need to hold a mmap_sem as down_write.

Android suffers from mmap_sem contention so let's reduce mmap_sem
down_write.

Cc: Arve Hjønnevåg 
Cc: Todd Kjos 
Cc: Greg Kroah-Hartman 
Reviewed-by: Martijn Coenen 
Signed-off-by: Minchan Kim 
---
>From v3:
  * Fix typoe

>From v2:
  * Fix vma->flag setting - Arve

>From v1:
  * remove WARN_ON_ONCE - Greg
  * add reviewed-by - Martijn

Martijn, I took your LGTM of v1 as Reviewed-by. If you don't like it
or want to change it to acked-by, please, tell me.

 drivers/android/binder.c   | 3 ++-
 drivers/android/binder_alloc.c | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 764b63a5aade..fe62be7d7113 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4722,7 +4722,8 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
failure_string = "bad vm_flags";
goto err_bad_arg;
}
-   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
+   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY | VM_MIXEDMAP) &
+   ~VM_MAYWRITE;
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 5a426c877dfb..4f382d51def1 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -219,7 +219,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
mm = alloc->vma_vm_mm;
 
if (mm) {
-   down_write(&mm->mmap_sem);
+   down_read(&mm->mmap_sem);
vma = alloc->vma;
}
 
@@ -288,7 +288,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
/* vm_insert_page does not seem to increment the refcount */
}
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return 0;
@@ -321,7 +321,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
}
 err_no_vma:
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return vma ? -ENOMEM : -ESRCH;
-- 
2.17.0.rc1.321.gba9d0f2565-goog



Re: [PATCH for v3.18 00/18] Backport CVE-2017-13166 fixes to Kernel 3.18

2018-03-28 Thread Inki Dae


2018년 03월 29일 13:25에 Greg KH 이(가) 쓴 글:
> On Thu, Mar 29, 2018 at 08:22:08AM +0900, Inki Dae wrote:
>> Really thanks for doing this. :) There would be many users who use
>> Linux-3.18 for their products yet.
> 
> For new products?  They really should not be.  The kernel is officially

Really no. Old products would still be using Linux-3.18 kernel without kernel 
upgrade. For new product, most of SoC vendors will use Linux-4.x including us.
Actually, we are preparing for kernel upgrade for some devices even some old 
devices (to Linux-4.14-LTS) and almost done.

> end-of-life, but I'm keeping it alive for a short while longer just
> because too many people seem to still be using it.  However, they are
> not actually updating the kernel in their devices, so I don't think I
> will be doing many more new 3.18.y releases.
> 
> It's a problem when people ask for support, and then don't use the
> releases given to them :(
> 
> What is keeping you on 3.18.y and not allowing you to move to a newer
> kernel version?

We also want to move to latest kernel version. However, there is a case that we 
cannot upgrade the kernel.
In case that SoC vendor never share firmwares and relevant data sheets, we 
cannot upgrade the kernel. However, we have to resolve the security issues for 
users of this device.

Thanks,
Inki Dae

> 
> thanks,
> 
> greg k-h
> 
> 
> 


[PATCH v1] hwmon, via-cputem: support new centaur CPUs

2018-03-28 Thread David Wang
Newer centaur CPUs(Family == 7) also support this cpu temperature sensor.

Signed-off-by: David Wang 
---
 drivers/hwmon/via-cputemp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 07a0cb0..2f5bd50 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -136,6 +136,11 @@ static int via_cputemp_probe(struct platform_device *pdev)
data->id = pdev->id;
data->name = "via_cputemp";
 
+   if (c->x86 == 7) {
+   data->msr_temp = 0x1423;
+   goto test_access;
+   }
+
switch (c->x86_model) {
case 0xA:
/* C7 A */
@@ -152,6 +157,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+test_access:
/* test if we can access the TEMPERATURE MSR */
err = rdmsr_safe_on_cpu(data->id, data->msr_temp, &eax, &edx);
if (err) {
@@ -283,6 +289,7 @@ static int via_cputemp_down_prep(unsigned int cpu)
{ X86_VENDOR_CENTAUR, 6, 0xa, }, /* C7 A */
{ X86_VENDOR_CENTAUR, 6, 0xd, }, /* C7 D */
{ X86_VENDOR_CENTAUR, 6, 0xf, }, /* Nano */
+   { X86_VENDOR_CENTAUR, 7, X86_MODEL_ANY, },
{}
 };
 MODULE_DEVICE_TABLE(x86cpu, cputemp_ids);
-- 
1.9.1



[PATCH] wcn36xx: Disable 5GHz for wcn3610

2018-03-28 Thread Ramon Fried
wcn3610 can only operate on 2.4GHz band due to RF limitation.
If wcn36xx digital block is associated with an external IRIS
RF module, retrieve the id and disable 5GHz band in case of
wcn3610 id.

Signed-off-by: Ramon Fried 
---
 drivers/net/wireless/ath/wcn36xx/main.c| 4 +++-
 drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/main.c 
b/drivers/net/wireless/ath/wcn36xx/main.c
index ab5be6d2c691..833531a68c95 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1146,7 +1146,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
BIT(NL80211_IFTYPE_MESH_POINT);
 
wcn->hw->wiphy->bands[NL80211_BAND_2GHZ] = &wcn_band_2ghz;
-   if (wcn->rf_id != RF_IRIS_WCN3620)
+   if (wcn->rf_id != RF_IRIS_WCN3610 && wcn->rf_id != RF_IRIS_WCN3620)
wcn->hw->wiphy->bands[NL80211_BAND_5GHZ] = &wcn_band_5ghz;
 
wcn->hw->wiphy->max_scan_ssids = WCN36XX_MAX_SCAN_SSIDS;
@@ -1248,6 +1248,8 @@ static int wcn36xx_platform_get_resources(struct wcn36xx 
*wcn,
if (iris_node) {
if (of_device_is_compatible(iris_node, "qcom,wcn3620"))
wcn->rf_id = RF_IRIS_WCN3620;
+   else if (of_device_is_compatible(iris_node, "qcom,wcn3610"))
+   wcn->rf_id = RF_IRIS_WCN3620;
of_node_put(iris_node);
}
 
diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h 
b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
index 81017e6703b4..bc4d1a10d90e 100644
--- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
+++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h
@@ -95,6 +95,7 @@ enum wcn36xx_ampdu_state {
 #define WCN36XX_MAX_POWER(__wcn) (__wcn->hw->conf.chandef.chan->max_power)
 
 #define RF_UNKNOWN 0x
+#define RF_IRIS_WCN36100x3610
 #define RF_IRIS_WCN36200x3620
 
 static inline void buff_to_be(u32 *buf, size_t len)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 0/2] Add QCOM RPMh Clock driver

2018-03-28 Thread Taniya Das
Hello,

This patch series adds a driver and device tree documentation binding
for the clock control via Resource Power Manager-hardened (RPMh) on some
Qualcomm Technologies, Inc, SoCs such as SDM845. The clock RPMh driver
would send requests for the RPMh managed clock resources.

The RPMh clock driver depends upon the RPMh driver [1] and command DB
driver [2] which are both still undergoing review.

Thanks,
Taniya

[1]: https://lkml.org/lkml/2018/3/9/979
[2]: https://lkml.org/lkml/2018/3/14/787

Amit Nischal (2):
  clk: qcom: clk-rpmh: Add QCOM clock RPMh driver
  dt-bindings: clock: Introduce QCOM RPMh clock bindings

 .../devicetree/bindings/clock/qcom,rpmh.txt|  22 ++
 drivers/clk/qcom/Kconfig   |   9 +
 drivers/clk/qcom/Makefile  |   1 +
 drivers/clk/qcom/clk-rpmh.c| 397 +
 include/dt-bindings/clock/qcom,rpmh.h  |  25 ++
 5 files changed, 454 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,rpmh.txt
 create mode 100644 drivers/clk/qcom/clk-rpmh.c
 create mode 100644 include/dt-bindings/clock/qcom,rpmh.h

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


[PATCH 1/2] clk: qcom: clk-rpmh: Add QCOM RPMh clock driver

2018-03-28 Thread Taniya Das
From: Amit Nischal 

Add the RPMh clock driver to control the RPMh managed clock resources on
some of the Qualcomm Technologies, Inc. SoCs.

Signed-off-by: David Collins 
Signed-off-by: Amit Nischal 
Signed-off-by: Taniya Das 
---
 drivers/clk/qcom/Kconfig  |   9 +
 drivers/clk/qcom/Makefile |   1 +
 drivers/clk/qcom/clk-rpmh.c   | 397 ++
 include/dt-bindings/clock/qcom,rpmh.h |  25 +++
 4 files changed, 432 insertions(+)
 create mode 100644 drivers/clk/qcom/clk-rpmh.c
 create mode 100644 include/dt-bindings/clock/qcom,rpmh.h

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index fbf4532..3697a6a 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -112,6 +112,15 @@ config IPQ_GCC_8074
  i2c, USB, SD/eMMC, etc. Select this for the root clock
  of ipq8074.

+config MSM_CLK_RPMH
+   tristate "RPMh Clock Driver"
+   depends on COMMON_CLK_QCOM && QCOM_RPMH
+   help
+RPMh manages shared resources on some Qualcomm Technologies, Inc.
+SoCs. It accepts requests from other hardware subsystems via RSC.
+Say Y if you want to support the clocks exposed by RPMh on
+platforms such as sdm845.
+
 config MSM_GCC_8660
tristate "MSM8660 Global Clock Controller"
depends on COMMON_CLK_QCOM
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 230332c..b7da05b 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_IPQ_GCC_8074) += gcc-ipq8074.o
 obj-$(CONFIG_IPQ_LCC_806X) += lcc-ipq806x.o
 obj-$(CONFIG_MDM_GCC_9615) += gcc-mdm9615.o
 obj-$(CONFIG_MDM_LCC_9615) += lcc-mdm9615.o
+obj-$(CONFIG_MSM_CLK_RPMH) += clk-rpmh.o
 obj-$(CONFIG_MSM_GCC_8660) += gcc-msm8660.o
 obj-$(CONFIG_MSM_GCC_8916) += gcc-msm8916.o
 obj-$(CONFIG_MSM_GCC_8960) += gcc-msm8960.o
diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
new file mode 100644
index 000..536d102
--- /dev/null
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -0,0 +1,397 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ */
+
+#define pr_fmt(fmt) "%s: " fmt, __func__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "common.h"
+#include "clk-regmap.h"
+
+#define CLK_RPMH_ARC_EN_OFFSET 0
+#define CLK_RPMH_VRM_EN_OFFSET 4
+#define CLK_RPMH_VRM_OFF_VAL 0
+#define CLK_RPMH_VRM_ON_VAL 1
+#define CLK_RPMH_APPS_RSC_AO_STATE_MASK (BIT(RPMH_WAKE_ONLY_STATE) | \
+BIT(RPMH_ACTIVE_ONLY_STATE))
+#define CLK_RPMH_APPS_RSC_STATE_MASK (BIT(RPMH_WAKE_ONLY_STATE) | \
+ BIT(RPMH_ACTIVE_ONLY_STATE) | \
+ BIT(RPMH_SLEEP_STATE))
+struct clk_rpmh {
+   const char *res_name;
+   u32 res_addr;
+   u32 res_en_offset;
+   u32 res_on_val;
+   u32 res_off_val;
+   u32 state;
+   u32 aggr_state;
+   u32 last_sent_aggr_state;
+   u32 valid_state_mask;
+   struct rpmh_client *rpmh_client;
+   unsigned long rate;
+   struct clk_rpmh *peer;
+   struct clk_hw hw;
+};
+
+struct rpmh_cc {
+   struct clk_onecell_data data;
+   struct clk *clks[];
+};
+
+struct clk_rpmh_desc {
+   struct clk_hw **clks;
+   size_t num_clks;
+};
+
+static DEFINE_MUTEX(rpmh_clk_lock);
+
+#define __DEFINE_CLK_RPMH(_platform, _name, _name_active, _res_name, \
+ _res_en_offset, _res_on, _res_off, _rate, \
+ _state_mask, _state_on_mask)\
+   static struct clk_rpmh _platform##_##_name_active;\
+   static struct clk_rpmh _platform##_##_name = {\
+   .res_name = _res_name,\
+   .res_en_offset = _res_en_offset,  \
+   .res_on_val = _res_on,\
+   .res_off_val = _res_off,  \
+   .rate = _rate,\
+   .peer = &_platform##_##_name_active,  \
+   .valid_state_mask = _state_mask,  \
+   .hw.init = &(struct clk_init_data){   \
+   .ops = &clk_rpmh_ops, \
+   .name = #_name,   \
+   },\
+   };\
+   static struct clk_rpmh _platform##_##_name_active = { \
+   .res_name = _res_name,

[PATCH 2/2] dt-bindings: clock: Introduce QCOM RPMh clock bindings

2018-03-28 Thread Taniya Das
From: Amit Nischal 

Add RPMh clock device bindings for Qualcomm Technology Inc's SoCs. These
devices would be used for communicating resource state requests to control
the clocks managed by RPMh.

Signed-off-by: Amit Nischal 
Signed-off-by: Taniya Das 
---
 .../devicetree/bindings/clock/qcom,rpmh.txt| 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,rpmh.txt

diff --git a/Documentation/devicetree/bindings/clock/qcom,rpmh.txt 
b/Documentation/devicetree/bindings/clock/qcom,rpmh.txt
new file mode 100644
index 000..8222c88
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/qcom,rpmh.txt
@@ -0,0 +1,22 @@
+Qualcomm Technologies, Inc. RPMh Clocks
+---
+
+Resource Power Manager Hardened (RPMh) manages shared resources on
+some Qualcomm Technologies Inc. SoCs. It accepts clock requests from
+other hardware subsystems via RSC to control clocks.
+
+Required properties :
+- compatible : shall contain "qcom,rpmh-clk-sdm845"
+
+- #clock-cells : must contain 1
+
+Example :
+
+#include 
+
+   &apps_rsc {
+   clock_rpmh: qcom,rpmhclk {
+   compatible = "qcom,rpmh-clk-sdm845";
+   #clock-cells = <1>;
+   };
+   };
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.



[PATCH] hwmon, via-cputemp: support new centaur CPUs

2018-03-28 Thread David Wang
Signed-off-by: David Wang 
---
 drivers/hwmon/via-cputemp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 07a0cb0..aa0d040 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -136,6 +136,11 @@ static int via_cputemp_probe(struct platform_device *pdev)
data->id = pdev->id;
data->name = "via_cputemp";
 
+   if (c->x86_model == 7) {
+   data->msr_temp = 0x1423;
+   goto test_access;
+   }
+
switch (c->x86_model) {
case 0xA:
/* C7 A */
@@ -152,6 +157,7 @@ static int via_cputemp_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+test_access:
/* test if we can access the TEMPERATURE MSR */
err = rdmsr_safe_on_cpu(data->id, data->msr_temp, &eax, &edx);
if (err) {
@@ -283,6 +289,7 @@ static int via_cputemp_down_prep(unsigned int cpu)
{ X86_VENDOR_CENTAUR, 6, 0xa, }, /* C7 A */
{ X86_VENDOR_CENTAUR, 6, 0xd, }, /* C7 D */
{ X86_VENDOR_CENTAUR, 6, 0xf, }, /* Nano */
+   { X86_VENDOR_CENTAUR, 7, X86_MODEL_ANY, },
{}
 };
 MODULE_DEVICE_TABLE(x86cpu, cputemp_ids);
-- 
1.9.1



Re: [PATCH 9/9] staging: ks7010: Remove extra blank line between functions.

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 22:51 -0700, Quytelda Kahja wrote:
> Remove an extra blank line indicated by checkpatch.

The changelog doesn't match the actual changes made.

> diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
> b/drivers/staging/ks7010/ks7010_sdio.c
[]
> @@ -305,7 +305,8 @@ static void tx_device_task(struct ks_wlan_private *priv)
>   if (priv->dev_state >= DEVICE_STATE_BOOT) {
>   ret = write_to_device(priv, sp->sendp, sp->size);
>   if (ret) {
> - netdev_err(priv->net_dev, "write_to_device error 
> !!(%d)\n", ret);
> + netdev_err(priv->net_dev,
> +"write_to_device() error (%d)!\n", ret);




[PATCH] usb: dwc3: of-simple: use managed and shared reset control

2018-03-28 Thread Masahiro Yamada
This driver handles the reset control in a common manner; deassert
resets before use, assert them after use.  There is no good reason
why it should be exclusive.

Also, use devm_ for clean-up.

Signed-off-by: Masahiro Yamada 
---

CCing Philipp Zabel.
I see his sob in commit 06c47e6286d5.


 drivers/usb/dwc3/dwc3-of-simple.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c 
b/drivers/usb/dwc3/dwc3-of-simple.c
index e54c362..bd6ab65 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -91,7 +91,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, simple);
simple->dev = dev;
 
-   simple->resets = of_reset_control_array_get_optional_exclusive(np);
+   simple->resets = devm_reset_control_array_get_optional_shared(dev);
if (IS_ERR(simple->resets)) {
ret = PTR_ERR(simple->resets);
dev_err(dev, "failed to get device resets, err=%d\n", ret);
@@ -100,7 +100,7 @@ static int dwc3_of_simple_probe(struct platform_device 
*pdev)
 
ret = reset_control_deassert(simple->resets);
if (ret)
-   goto err_resetc_put;
+   return ret;
 
ret = dwc3_of_simple_clk_init(simple, of_count_phandle_with_args(np,
"clocks", "#clock-cells"));
@@ -126,8 +126,6 @@ static int dwc3_of_simple_probe(struct platform_device 
*pdev)
 err_resetc_assert:
reset_control_assert(simple->resets);
 
-err_resetc_put:
-   reset_control_put(simple->resets);
return ret;
 }
 
@@ -146,7 +144,6 @@ static int dwc3_of_simple_remove(struct platform_device 
*pdev)
simple->num_clocks = 0;
 
reset_control_assert(simple->resets);
-   reset_control_put(simple->resets);
 
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
-- 
2.7.4



Re: [PATCH 1/9] staging: ks7010: Replace manual array copy with ether_addr_copy().

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 22:51 -0700, Quytelda Kahja wrote:
> Copying the dummy HW address into the struct net_device doesn't need
> to be done byte by byte; use ether_addr_copy() instead.
> Additionally, dev->dev_addr is not eight bytes long.
> ether_setup() sets the dev->addr_len to ETH_ALEN (defined as 6)
> in the net core code.
[]
> diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
> b/drivers/staging/ks7010/ks_wlan_net.c
[]
> @@ -2900,15 +2900,7 @@ int ks_wlan_net_start(struct net_device *dev)
>   timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
>  
>   /* dummy address set */
> - memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);

why remove the copy of dummy_addr into priv->eth_addr ?

Also, dummy_addr could be removed and eth_zero_addr()
used instead.

> - dev->dev_addr[0] = priv->eth_addr[0];
> - dev->dev_addr[1] = priv->eth_addr[1];
> - dev->dev_addr[2] = priv->eth_addr[2];
> - dev->dev_addr[3] = priv->eth_addr[3];
> - dev->dev_addr[4] = priv->eth_addr[4];
> - dev->dev_addr[5] = priv->eth_addr[5];
> - dev->dev_addr[6] = 0x00;
> - dev->dev_addr[7] = 0x00;
> + ether_addr_copy(dev->dev_addr, priv->eth_addr);

Perhaps

eth_zero_addr(priv->eth_addr);
eth_zero_addr(dev->dev_addr);



RE: [EXT] [PATCH net-next v2 2/2] sfp/phylink: move module EEPROM ethtool access into netdev core ethtool

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Russell King ; Florian Fainelli 
; Thomas Petazzoni ; 
Andrew Lunn ; David S. Miller ; open list 
; Antoine Tenart ; 
Yan Markman ; Stefan Chulski ; 
Maxime Chevallier ; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 2/2] sfp/phylink: move module EEPROM ethtool 
access into netdev core ethtool

External Email

--
From: Russell King 

Provide a pointer to the SFP bus in struct net_device, so that the ethtool 
module EEPROM methods can access the SFP directly, rather than needing every 
user to provide a hook for it.

Reviewed-by: Andrew Lunn 
Signed-off-by: Russell King 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/marvell/mvneta.c | 18 --
 drivers/net/phy/phylink.c | 28 
 drivers/net/phy/sfp-bus.c |  6 ++
 include/linux/netdevice.h |  3 +++
 include/linux/phylink.h   |  3 ---
 net/core/ethtool.c|  7 +++
 6 files changed, 12 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index cd09bde55596..25ced96750bf 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4075,22 +4075,6 @@ static int mvneta_ethtool_set_wol(struct net_device *dev,
return ret;
 }
 
-static int mvneta_ethtool_get_module_info(struct net_device *dev,
- struct ethtool_modinfo *modinfo)
-{
-   struct mvneta_port *pp = netdev_priv(dev);
-
-   return phylink_ethtool_get_module_info(pp->phylink, modinfo);
-}
-
-static int mvneta_ethtool_get_module_eeprom(struct net_device *dev,
-   struct ethtool_eeprom *ee, u8 *buf)
-{
-   struct mvneta_port *pp = netdev_priv(dev);
-
-   return phylink_ethtool_get_module_eeprom(pp->phylink, ee, buf);
-}
-
 static int mvneta_ethtool_get_eee(struct net_device *dev,
  struct ethtool_eee *eee)
 {
@@ -4165,8 +4149,6 @@ static const struct ethtool_ops mvneta_eth_tool_ops = {
.set_link_ksettings = mvneta_ethtool_set_link_ksettings,
.get_wol= mvneta_ethtool_get_wol,
.set_wol= mvneta_ethtool_set_wol,
-   .get_module_info = mvneta_ethtool_get_module_info,
-   .get_module_eeprom = mvneta_ethtool_get_module_eeprom,
.get_eee= mvneta_ethtool_get_eee,
.set_eee= mvneta_ethtool_set_eee,
 };
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 
9b1e4721ea3a..c582b2d7546c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1250,34 +1250,6 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,  
}  EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
 
-int phylink_ethtool_get_module_info(struct phylink *pl,
-   struct ethtool_modinfo *modinfo)
-{
-   int ret = -EOPNOTSUPP;
-
-   WARN_ON(!lockdep_rtnl_is_held());
-
-   if (pl->sfp_bus)
-   ret = sfp_get_module_info(pl->sfp_bus, modinfo);
-
-   return ret;
-}
-EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_info);
-
-int phylink_ethtool_get_module_eeprom(struct phylink *pl,
- struct ethtool_eeprom *ee, u8 *buf)
-{
-   int ret = -EOPNOTSUPP;
-
-   WARN_ON(!lockdep_rtnl_is_held());
-
-   if (pl->sfp_bus)
-   ret = sfp_get_module_eeprom(pl->sfp_bus, ee, buf);
-
-   return ret;
-}
-EXPORT_SYMBOL_GPL(phylink_ethtool_get_module_eeprom);
-
 /**
  * phylink_ethtool_get_eee_err() - read the energy efficient ethernet error
  *   counter
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 
3d4ff5d0d2a6..0381da78d228 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -342,6 +342,7 @@ static int sfp_register_bus(struct sfp_bus *bus)
}
if (bus->started)
bus->socket_ops->start(bus->sfp);
+   bus->netdev->sfp_bus = bus;
bus->registered = true;
return 0;
 }
@@ -356,6 +357,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
if (bus->phydev && ops && ops->disconnect_phy)
ops->disconnect_phy(bus->upstream);
}
+   bus->netdev->sfp_bus = NULL;
bus->registered = false;
 }
 
@@ -371,8 +373,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
  */
 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)  
{
-   if (!bus->registered)
-   return -ENOIOCTLCMD;
return bus->socket_ops->module_info(

RE: [EXT] [PATCH net-next v2 0/2] phylink: API changes

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 0/2] phylink: API changes

External Email

--
Hi all,

This patch series contains two API changes to PHYLINK which will later be used 
by DSA to migrate to PHYLINK. Because these are API changes that impact other 
outstanding work (e.g: MVPP2) I would rather get them included sooner to 
minimize conflicts.

Thank you!

Changes in v2:

- added missing documentation to mac_link_{up,down} that the interface
  must be configured in mac_config()

- added Russell's, Andrew's and my tags

Florian Fainelli (1):
  net: phy: phylink: Provide PHY interface to mac_link_{up,down}

Russell King (1):
  sfp/phylink: move module EEPROM ethtool access into netdev core
ethtool

 drivers/net/ethernet/marvell/mvneta.c | 22 +++---
 drivers/net/phy/phylink.c | 32 +++-
 drivers/net/phy/sfp-bus.c |  6 ++
 include/linux/netdevice.h |  3 +++
 include/linux/phylink.h   | 17 +++--
 net/core/ethtool.c|  7 +++
 6 files changed, 29 insertions(+), 58 deletions(-)

--
2.14.1



RE: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface to mac_link_{up,down}

2018-03-28 Thread Yan Markman
Hi Florian
Please keep CC  Yelena Krivosheev 
for changes withdrivers/net/ethernet/marvell/mvneta.c
Thanks
Yan Markman
Tel. 05-44732819


-Original Message-
From: Florian Fainelli [mailto:f.faine...@gmail.com] 
Sent: Thursday, March 29, 2018 1:44 AM
To: net...@vger.kernel.org
Cc: Florian Fainelli ; Thomas Petazzoni 
; Andrew Lunn ; David S. 
Miller ; Russell King ; open 
list ; Antoine Tenart 
; Yan Markman ; Stefan 
Chulski ; Maxime Chevallier 
; Miquel Raynal 
; Marcin Wojtas 
Subject: [EXT] [PATCH net-next v2 1/2] net: phy: phylink: Provide PHY interface 
to mac_link_{up,down}

External Email

--
In preparation for having DSA transition entirely to PHYLINK, we need to pass a 
PHY interface type to the mac_link_{up,down} callbacks because we may have to 
make decisions on that (e.g: turn on/off RGMII interfaces etc.). We do not pass 
an entire phylink_link_state because not all parameters (pause, duplex etc.) 
are defined when the link is down, only link and interface are.

Update mvneta accordingly since it currently implements phylink_mac_ops.

Acked-by: Russell King 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/marvell/mvneta.c |  4 +++-
 drivers/net/phy/phylink.c |  4 +++-
 include/linux/phylink.h   | 14 +++---
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index eaa4bb80f1c9..cd09bde55596 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3396,7 +3396,8 @@ static void mvneta_set_eee(struct mvneta_port *pp, bool 
enable)
mvreg_write(pp, MVNETA_LPI_CTRL_1, lpi_ctl1);  }
 
-static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
+static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode,
+phy_interface_t interface)
 {
struct mvneta_port *pp = netdev_priv(ndev);
u32 val;
@@ -3415,6 +3416,7 @@ static void mvneta_mac_link_down(struct net_device *ndev, 
unsigned int mode)  }
 
 static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
+  phy_interface_t interface,
   struct phy_device *phy)
 {
struct mvneta_port *pp = netdev_priv(ndev); diff --git 
a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 
51a011a349fe..9b1e4721ea3a 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -470,10 +470,12 @@ static void phylink_resolve(struct work_struct *w)
if (link_state.link != netif_carrier_ok(ndev)) {
if (!link_state.link) {
netif_carrier_off(ndev);
-   pl->ops->mac_link_down(ndev, pl->link_an_mode);
+   pl->ops->mac_link_down(ndev, pl->link_an_mode,
+  pl->phy_state.interface);
netdev_info(ndev, "Link is Down\n");
} else {
pl->ops->mac_link_up(ndev, pl->link_an_mode,
+pl->phy_state.interface,
 pl->phydev);
 
netif_carrier_on(ndev);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 
bd137c273d38..e95cc12030fa 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -73,8 +73,10 @@ struct phylink_mac_ops {
void (*mac_config)(struct net_device *ndev, unsigned int mode,
   const struct phylink_link_state *state);
void (*mac_an_restart)(struct net_device *ndev);
-   void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
+   void (*mac_link_down)(struct net_device *ndev, unsigned int mode,
+ phy_interface_t interface);
void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
+   phy_interface_t interface,
struct phy_device *phy);
 };
 
@@ -161,25 +163,31 @@ void mac_an_restart(struct net_device *ndev);
  * mac_link_down() - take the link down
  * @ndev: a pointer to a &struct net_device for the MAC.
  * @mode: link autonegotiation mode
+ * @interface: link &typedef phy_interface_t mode
  *
  * If @mode is not an in-band negotiation mode (as defined by
  * phylink_autoneg_inband()), force the link down and disable any
- * Energy Efficient Ethernet MAC configuration.
+ * Energy Efficient Ethernet MAC configuration. Interface type
+ * selection must be done in mac_config().
  */
-void mac_link_down(struct net_device *ndev, unsigned int mode);
+void mac_link_down(struct net_device *ndev, unsigned int mode,
+  phy_interface_t interface);
 
 /**
  * mac_link_up() - allow the link to come up
  * @ndev: a pointer to a &struct net_device for th

[PATCH 3/9] staging: ks7010: Reorder ks_wlan_netdev_ops members.

2018-03-28 Thread Quytelda Kahja
Reorder the members of 'ks_wlan_netdev_ops' to reflect the order
of their counterparts in the kernel's 'struct net_device_ops'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 544bfa403d9f..2f84c5dc1324 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -70,14 +70,14 @@ static const struct iw_handler_def ks_wlan_handler_def;
  * function prototypes
  */
 static int ks_wlan_open(struct net_device *dev);
-static void ks_wlan_tx_timeout(struct net_device *dev);
-static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
+static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void ks_wlan_set_multicast_list(struct net_device *dev);
-static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
+static void ks_wlan_tx_timeout(struct net_device *dev);
+static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
 
 static atomic_t update_phyinfo;
 static struct timer_list update_phyinfo_timer;
@@ -2874,14 +2874,14 @@ static const unsigned char dummy_addr[] = {
 };
 
 static const struct net_device_ops ks_wlan_netdev_ops = {
-   .ndo_start_xmit = ks_wlan_start_xmit,
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
-   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
+   .ndo_start_xmit = ks_wlan_start_xmit,
+   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
.ndo_set_mac_address = ks_wlan_set_mac_address,
-   .ndo_get_stats = ks_wlan_get_stats,
+   .ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_get_stats = ks_wlan_get_stats,
 };
 
 int ks_wlan_net_start(struct net_device *dev)
-- 
2.16.3



[PATCH 4/9] staging: ks7010: Rename ks_wlan_set_multicast_list()

2018-03-28 Thread Quytelda Kahja
All of the net_device_ops callbacks are named after their counterparts
in the kernel's 'struct net_device_ops', except
ks_wlan_set_multicast_list().  Rename it to ks_wlan_set_rx_mode() for
greater consistency.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 2f84c5dc1324..41f89f930f50 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -72,7 +72,7 @@ static const struct iw_handler_def ks_wlan_handler_def;
 static int ks_wlan_open(struct net_device *dev);
 static int ks_wlan_close(struct net_device *dev);
 static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static void ks_wlan_set_multicast_list(struct net_device *dev);
+static void ks_wlan_set_rx_mode(struct net_device *dev);
 static int ks_wlan_set_mac_address(struct net_device *dev, void *addr);
 static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
int cmd);
@@ -2833,7 +2833,7 @@ void send_packet_complete(struct ks_wlan_private *priv, 
struct sk_buff *skb)
  * This routine is not state sensitive and need not be SMP locked.
  */
 static
-void ks_wlan_set_multicast_list(struct net_device *dev)
+void ks_wlan_set_rx_mode(struct net_device *dev)
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
@@ -2877,7 +2877,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = {
.ndo_open = ks_wlan_open,
.ndo_stop = ks_wlan_close,
.ndo_start_xmit = ks_wlan_start_xmit,
-   .ndo_set_rx_mode = ks_wlan_set_multicast_list,
+   .ndo_set_rx_mode = ks_wlan_set_rx_mode,
.ndo_set_mac_address = ks_wlan_set_mac_address,
.ndo_do_ioctl = ks_wlan_netdev_ioctl,
.ndo_tx_timeout = ks_wlan_tx_timeout,
-- 
2.16.3



[PATCH 2/9] staging: ks7010: Remove unecessary cast.

2018-03-28 Thread Quytelda Kahja
The driver casts '&ks_wlan_handler_def' to 'struct iw_handler_def *',
but it is already of that type.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index f6e496aa68de..544bfa403d9f 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2904,7 +2904,7 @@ int ks_wlan_net_start(struct net_device *dev)
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = &ks_wlan_netdev_ops;
-   dev->wireless_handlers = (struct iw_handler_def *)&ks_wlan_handler_def;
+   dev->wireless_handlers = &ks_wlan_handler_def;
dev->watchdog_timeo = TX_TIMEOUT;
 
netif_carrier_off(dev);
-- 
2.16.3



Re: [PATCH v3 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans

On 28-03-18 00:50, Florian Fainelli wrote:

On 03/27/2018 02:52 AM, Mike Looijmans wrote:

It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
---
  Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
  drivers/of/of_net.c| 40 ++
  include/linux/of_net.h |  6 
  3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
the boot program; should be used in cases where the MAC address assigned to
the device by the boot program is different from the "local-mac-address"
property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
  - max-speed: number, specifies maximum speed in Mbit/s supported by the 
device;
  - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather 
than
the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..1c5d372 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
   */
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
  }
  EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, &len);
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < 6 || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;


Just one nit here, can you use ETH_ALEN instead of 6? With that fixed:

Reviewed-by: Florian Fainelli 



Ok, implemented and tested it, and v4 is on the way with that change.


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail





[PATCH 1/9] staging: ks7010: Replace manual array copy with ether_addr_copy().

2018-03-28 Thread Quytelda Kahja
Copying the dummy HW address into the struct net_device doesn't need
to be done byte by byte; use ether_addr_copy() instead.
Additionally, dev->dev_addr is not eight bytes long.
ether_setup() sets the dev->addr_len to ETH_ALEN (defined as 6)
in the net core code.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_wlan_net.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 6106e79c5163..f6e496aa68de 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2900,15 +2900,7 @@ int ks_wlan_net_start(struct net_device *dev)
timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
 
/* dummy address set */
-   memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
+   ether_addr_copy(dev->dev_addr, priv->eth_addr);
 
/* The ks_wlan-specific entries in the device structure. */
dev->netdev_ops = &ks_wlan_netdev_ops;
-- 
2.16.3



[PATCH 7/9] staging: ks7010: Remove trailing "_t" from all structure names.

2018-03-28 Thread Quytelda Kahja
The "_t" suffix is not needed for structure names in this driver,
and is a reflection of an older typedef system that is no longer
in place.  Remove the "_t" suffix from every structure defined in this
driver.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c |   2 +-
 drivers/staging/ks7010/ks_hostif.c   |  80 ++--
 drivers/staging/ks7010/ks_hostif.h   | 142 +--
 drivers/staging/ks7010/ks_wlan.h |  68 -
 drivers/staging/ks7010/ks_wlan_net.c |  12 +--
 drivers/staging/ks7010/michael_mic.c |   8 +-
 drivers/staging/ks7010/michael_mic.h |   4 +-
 7 files changed, 158 insertions(+), 158 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a11ee1c..d083bf8d238e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -950,7 +950,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 /* send stop request to MAC */
 static int send_stop_request(struct sdio_func *func)
 {
-   struct hostif_stop_request_t *pp;
+   struct hostif_stop_request *pp;
struct ks_sdio_card *card;
size_t size;
 
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 79d21a64ffa2..a4020eeaac18 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -107,16 +107,16 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv)
 }
 
 static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t 
*ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
 {
-   struct local_ap_t *ap;
+   struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
 
ap = &priv->current_ap;
 
if (is_disconnect_status(priv->connect_status)) {
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
 
@@ -223,13 +223,13 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
 
 
 static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
-  struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+  struct local_ap *ap)
 {
unsigned char *bp;
int bsize, offset;
 
-   memset(ap, 0, sizeof(struct local_ap_t));
+   memset(ap, 0, sizeof(struct local_ap));
 
/* bssid */
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
@@ -314,11 +314,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private 
*priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
-   struct mic_failure_t *mic_failure;
-   struct michael_mic_t michael_mic;
+   struct mic_failure *mic_failure;
+   struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
-   struct wpa_key_t *key = &priv->wpa.key[key_index];
+   struct wpa_key *key = &priv->wpa.key[key_index];
 
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -745,7 +745,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
 
-   get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+   get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -771,10 +771,10 @@ static
 void hostif_scan_indication(struct ks_wlan_private *priv)
 {
int i;
-   struct ap_info_t *ap_info;
+   struct ap_info *ap_info;
 
netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
-   ap_info = (struct ap_info_t *)(priv->rxp);
+   ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
/* bssid check */
@@ -794,7 +794,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: 
aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
-   get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+   get_ap_information(priv, (struct ap_info *)(priv->rxp),
   &(priv->aplist.ap[priv->scan_ind_count - 
1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -863,8 +863,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
 static
 void hostif_associate_indication(struct ks_wlan_private *priv)
 {
-   struct association_request_t *assoc_req;
-   struct association_response_t *assoc_resp;
+   struct association_request *assoc_req;
+   struct a

[PATCH 8/9] staging: ks7010: Remove 'eth_addr' field from 'struct ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
The ethernet address of the network device is already stored in the
'dev_addr' field of 'struct net_device'.  Since 'struct ks_wlan_private'
keeps a pointer to the driver's 'struct net_device', there is no reason
to duplicate this information in 'struct ks_wlan_private'.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 29 +++--
 drivers/staging/ks7010/ks_wlan.h |  2 --
 drivers/staging/ks7010/ks_wlan_net.c |  5 ++---
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a4020eeaac18..7bb0a6dffe61 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -388,6 +388,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
 static
 void hostif_data_indication(struct ks_wlan_private *priv)
 {
+   struct net_device * dev = priv->net_dev;
unsigned int rx_ind_size;   /* indicate data size */
struct sk_buff *skb;
unsigned short auth_type;
@@ -411,9 +412,9 @@ void hostif_data_indication(struct ks_wlan_private *priv)
eth_proto = ntohs(eth_hdr->h_proto);
 
/* source address check */
-   if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
-   netdev_err(priv->net_dev, "invalid : source is own mac address 
!!\n");
-   netdev_err(priv->net_dev,
+   if (memcmp(dev->dev_addr, eth_hdr->h_source, ETH_ALEN) == 0) {
+   netdev_err(dev, "invalid : source is own mac address !!\n");
+   netdev_err(dev,
   
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
   eth_hdr->h_source[0], eth_hdr->h_source[1],
   eth_hdr->h_source[2], eth_hdr->h_source[3],
@@ -443,7 +444,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "SNAP, rx_ind_size = %d\n",
+   netdev_dbg(dev, "SNAP, rx_ind_size = %d\n",
   rx_ind_size);
 
size = ETH_ALEN * 2;
@@ -463,7 +464,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
priv->nstats.rx_dropped++;
return;
}
-   netdev_dbg(priv->net_dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
+   netdev_dbg(dev, "NETBEUI/NetBIOS rx_ind_size=%d\n",
   rx_ind_size);
 
/* 8802/FDDI MAC copy */
@@ -480,7 +481,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14);
break;
default:/* other rx data */
-   netdev_err(priv->net_dev, "invalid data format\n");
+   netdev_err(dev, "invalid data format\n");
priv->nstats.rx_errors++;
return;
}
@@ -522,17 +523,9 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
case DOT11_MAC_ADDRESS:
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
-   memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+   memcpy(dev->dev_addr, priv->rxp, ETH_ALEN);
priv->mac_address_valid = true;
-   dev->dev_addr[0] = priv->eth_addr[0];
-   dev->dev_addr[1] = priv->eth_addr[1];
-   dev->dev_addr[2] = priv->eth_addr[2];
-   dev->dev_addr[3] = priv->eth_addr[3];
-   dev->dev_addr[4] = priv->eth_addr[4];
-   dev->dev_addr[5] = priv->eth_addr[5];
-   dev->dev_addr[6] = 0x00;
-   dev->dev_addr[7] = 0x00;
-   netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
+   netdev_info(dev, "MAC ADDRESS = %pM\n", dev->dev_addr);
break;
case DOT11_PRODUCT_VERSION:
/* firmware version */
@@ -,7 +1104,7 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
 
/* skb check */
eth = (struct ethhdr *)skb->data;
-   if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
+   if (memcmp(priv->net_dev->dev_addr, eth->h_source, ETH_ALEN) != 0) {
netdev_err(priv->net_dev, "invalid mac address !!\n");
netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", 
eth->h_source);
ret = -ENXIO;
@@ -2167,7 +2160,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_MACADDRESS_SET_REQUEST:
hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
   MIB_VALUE_TYPE_OSTRING,
-  &priv->eth_addr[0]);
+  priv->net_dev->dev_addr);
break;
 

[PATCH 6/9] staging: ks7010: Remove unused member 'reg_net' from 'ks_wlan_private'.

2018-03-28 Thread Quytelda Kahja
'reg_net' is never used in this driver.

Signed-off-by: Quytelda Kahja x
---
 drivers/staging/ks7010/ks_wlan.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 846bb1041850..1b7036c32d1c 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -406,7 +406,6 @@ struct ks_wlan_private {
struct tasklet_struct rx_bh_task;
 
struct net_device *net_dev;
-   int reg_net;/* register_netdev */
struct net_device_stats nstats;
struct iw_statistics wstats;
 
-- 
2.16.3



[PATCH 9/9] staging: ks7010: Remove extra blank line between functions.

2018-03-28 Thread Quytelda Kahja
Remove an extra blank line indicated by checkpatch.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks7010_sdio.c | 3 ++-
 drivers/staging/ks7010/ks_hostif.c   | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index d083bf8d238e..930d1f7d7dbf 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -305,7 +305,8 @@ static void tx_device_task(struct ks_wlan_private *priv)
if (priv->dev_state >= DEVICE_STATE_BOOT) {
ret = write_to_device(priv, sp->sendp, sp->size);
if (ret) {
-   netdev_err(priv->net_dev, "write_to_device error 
!!(%d)\n", ret);
+   netdev_err(priv->net_dev,
+  "write_to_device() error (%d)!\n", ret);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return;
}
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 7bb0a6dffe61..de68dbdf7e2d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -221,7 +221,6 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
return size;
 }
 
-
 static
 int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
   struct local_ap *ap)
-- 
2.16.3



[PATCH 5/9] staging: ks7010: Change mac_address_valid to a bool instead of int.

2018-03-28 Thread Quytelda Kahja
'mac_address_valid' is only ever assigned 0 or 1, so it makes more sense
to use a bool type for this variable.

Signed-off-by: Quytelda Kahja 
---
 drivers/staging/ks7010/ks_hostif.c   | 4 ++--
 drivers/staging/ks7010/ks_wlan.h | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a02b73e4e81f..79d21a64ffa2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -523,7 +523,7 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
/* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
dev->dev_addr[0] = priv->eth_addr[0];
dev->dev_addr[1] = priv->eth_addr[1];
dev->dev_addr[2] = priv->eth_addr[2];
@@ -638,7 +638,7 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM);
break;
case LOCAL_CURRENTADDRESS:
-   priv->mac_address_valid = 1;
+   priv->mac_address_valid = true;
break;
case DOT11_RSN_CONFIG_MULTICAST_CIPHER:
hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM);
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index f1f6c88adcca..846bb1041850 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -456,7 +456,7 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
 
-   int mac_address_valid;  /* Mac Address Status */
+   bool mac_address_valid; /* Mac Address Status */
 
int dev_state;
 
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 41f89f930f50..df6192be8a3e 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2767,7 +2767,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void 
*addr)
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
 
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
netdev_info(dev, "ks_wlan:  MAC ADDRESS = %pM\n", priv->eth_addr);
return 0;
@@ -2890,7 +2890,7 @@ int ks_wlan_net_start(struct net_device *dev)
/* int rc; */
 
priv = netdev_priv(dev);
-   priv->mac_address_valid = 0;
+   priv->mac_address_valid = false;
priv->need_commit = 0;
 
priv->device_open_status = 1;
-- 
2.16.3



Re: [PATCH 2/2] rhashtable: improve rhashtable_walk stability when stop/start used.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:10PM +1100, NeilBrown wrote:
> When a walk of an rhashtable is interrupted with rhastable_walk_stop()
> and then rhashtable_walk_start(), the location to restart from is based
> on a 'skip' count in the current hash chain, and this can be incorrect
> if insertions or deletions have happened.  This does not happen when
> the walk is not stopped and started as iter->p is a placeholder which
> is safe to use while holding the RCU read lock.
> 
> In rhashtable_walk_start() we can revalidate that 'p' is still in the
> same hash chain.  If it isn't then the current method is still used.
> 
> With this patch, if a rhashtable walker ensures that the current
> object remains in the table over a stop/start period (possibly by
> elevating the reference count if that is sufficient), it can be sure
> that a walk will not miss objects that were in the hashtable for the
> whole time of the walk.
> 
> rhashtable_walk_start() may not find the object even though it is
> still in the hashtable if a rehash has moved it to a new table.  In
> this case it will (eventually) get -EAGAIN and will need to proceed
> through the whole table again to be sure to see everything at least
> once.
> 
> Signed-off-by: NeilBrown 

Very nice!

Acked-by: Herbert Xu 
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[RFC PATCH] sdhci: arasan: Add runtime PM support

2018-03-28 Thread naranimanish
From: Manish Narani 

This patch adds runtime PM support in Arasan SD driver.

Signed-off-by: Manish Narani 
---
 drivers/mmc/host/sdhci-of-arasan.c | 83 +-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c 
b/drivers/mmc/host/sdhci-of-arasan.c
index c33a5f7..47196b5 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -349,6 +350,75 @@ static const struct sdhci_pltfm_data 
sdhci_arasan_cqe_pdata = {
SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
 };
 
+#ifdef CONFIG_PM
+/**
+ * sdhci_arasan_runtime_suspend - Suspend method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Put the device in a low power state.
+ */
+static int sdhci_arasan_runtime_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = sdhci_runtime_suspend_host(host);
+   if (ret)
+   return ret;
+
+   if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+   mmc_retune_needed(host->mmc);
+
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return 0;
+}
+
+/**
+ * sdhci_arasan_runtime_resume - Resume method for the driver
+ * @dev:   Address of the device structure
+ * Returns 0 on success and error value on error
+ *
+ * Resume operation after suspend
+ */
+static int sdhci_arasan_runtime_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct sdhci_host *host = platform_get_drvdata(pdev);
+   struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+   struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
+   int ret;
+
+   ret = clk_enable(sdhci_arasan->clk_ahb);
+   if (ret) {
+   dev_err(dev, "Cannot enable AHB clock.\n");
+   return ret;
+   }
+
+   ret = clk_enable(pltfm_host->clk);
+   if (ret) {
+   dev_err(dev, "Cannot enable SD clock.\n");
+   return ret;
+   }
+
+   ret = sdhci_runtime_resume_host(host);
+   if (ret)
+   goto out;
+
+   return 0;
+out:
+   clk_disable(pltfm_host->clk);
+   clk_disable(sdhci_arasan->clk_ahb);
+
+   return ret;
+}
+#endif /* ! CONFIG_PM */
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * sdhci_arasan_suspend - Suspend method for the driver
@@ -443,8 +513,11 @@ static int sdhci_arasan_resume(struct device *dev)
 }
 #endif /* ! CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend,
-sdhci_arasan_resume);
+static const struct dev_pm_ops sdhci_arasan_dev_pm_ops = {
+   SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend, sdhci_arasan_resume)
+   SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend,
+  sdhci_arasan_runtime_resume, NULL)
+};
 
 static const struct of_device_id sdhci_arasan_of_match[] = {
/* SoC-specific compatible strings w/ soc_ctl_map */
@@ -806,6 +879,12 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
if (ret)
goto err_add_host;
 
+   pm_runtime_set_active(&pdev->dev);
+   pm_runtime_enable(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
+   pm_runtime_mark_last_busy(&pdev->dev);
+   pm_runtime_use_autosuspend(&pdev->dev);
+
return 0;
 
 err_add_host:
-- 
2.7.4



Re: [PATCH 1/2] rhashtable: fix insertion of in rhltable when duplicate found.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 12:19:09PM +1100, NeilBrown wrote:
> When rhltable_insert() finds an entry with the same key,
> it splices the new entry at the start of a list of entries with the
> same key.
> It stores the address of the new object in *pprev, but in general this
> is *not* the location where the match was found (though in a common
> case where the hash chain has one element, it will be).
> To fix this, pprev should be updated every time we find an object that
> doesn't match.
> 
> This patch changes the behaviour for non-slow insertion in that now
> insertion happens at the end of a chain rather than at the head.
> I don't think this is an important change.
> 
> Signed-off-by: NeilBrown 

Thanks.  But Paul Blakey beat you to it :)

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=d3dcf8eb615537526bd42ff27a081d46d337816e
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[PATCH v2] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto

From: Kuninori Morimoto 

Now we can replace Codec to Component. Let's do it.

Note:
xxx_codec_xxx() ->  xxx_component_xxx()
.idle_bias_off = 0  ->  .idle_bias_on = 1
.ignore_pmdown_time = 0 ->  .use_pmdown_time = 1
-   ->  .endianness = 1
-   ->  .non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto 
---
v1 -> v2

 - fixup .remove return

 drivers/media/i2c/tda1997x.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
index 3021913..2dc4df5 100644
--- a/drivers/media/i2c/tda1997x.c
+++ b/drivers/media/i2c/tda1997x.c
@@ -2444,7 +2444,7 @@ static int tda1997x_pcm_startup(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct tda1997x_state *state = snd_soc_dai_get_drvdata(dai);
-   struct snd_soc_codec *codec = dai->codec;
+   struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *rtd = substream->runtime;
int rate, err;
 
@@ -2452,11 +2452,11 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
err = snd_pcm_hw_constraint_minmax(rtd, SNDRV_PCM_HW_PARAM_RATE,
   rate, rate);
if (err < 0) {
-   dev_err(codec->dev, "failed to constrain samplerate to %dHz\n",
+   dev_err(component->dev, "failed to constrain samplerate to 
%dHz\n",
rate);
return err;
}
-   dev_info(codec->dev, "set samplerate constraint to %dHz\n", rate);
+   dev_info(component->dev, "set samplerate constraint to %dHz\n", rate);
 
return 0;
 }
@@ -2479,20 +2479,22 @@ static int tda1997x_pcm_startup(struct 
snd_pcm_substream *substream,
.ops = &tda1997x_dai_ops,
 };
 
-static int tda1997x_codec_probe(struct snd_soc_codec *codec)
+static int tda1997x_codec_probe(struct snd_soc_component *component)
 {
return 0;
 }
 
-static int tda1997x_codec_remove(struct snd_soc_codec *codec)
+static void tda1997x_codec_remove(struct snd_soc_component *component)
 {
-   return 0;
 }
 
-static struct snd_soc_codec_driver tda1997x_codec_driver = {
+static struct snd_soc_component_driver tda1997x_codec_driver = {
.probe = tda1997x_codec_probe,
.remove = tda1997x_codec_remove,
-   .reg_word_size = sizeof(u16),
+   .idle_bias_on   = 1,
+   .use_pmdown_time= 1,
+   .endianness = 1,
+   .non_legacy_dai_naming  = 1,
 };
 
 static int tda1997x_probe(struct i2c_client *client,
@@ -2737,7 +2739,7 @@ static int tda1997x_probe(struct i2c_client *client,
else
formats = SNDRV_PCM_FMTBIT_S16_LE;
tda1997x_audio_dai.capture.formats = formats;
-   ret = snd_soc_register_codec(&state->client->dev,
+   ret = devm_snd_soc_register_component(&state->client->dev,
 &tda1997x_codec_driver,
 &tda1997x_audio_dai, 1);
if (ret) {
@@ -2782,7 +2784,6 @@ static int tda1997x_remove(struct i2c_client *client)
struct tda1997x_platform_data *pdata = &state->pdata;
 
if (pdata->audout_format) {
-   snd_soc_unregister_codec(&client->dev);
mutex_destroy(&state->audio_lock);
}
 
-- 
1.9.1



Re: [PATCH v2] pcm_native: Remove VLA usage

2018-03-28 Thread Takashi Iwai
On Thu, 29 Mar 2018 00:24:00 +0200,
Kyle Spiers wrote:
> 
> As part of the effort to remove VLAs from the kernel[1], this changes
> the allocation of the rstamps array from being on the stack to being
> kcalloc()ed. This also allows for the removal of the explicit zeroing
> loop.
> 
> Signed-off-by: Kyle Spiers 

It's been already fixed weeks ago...


thanks,

Takashi


Re: [PATCH] media: i2c: wm9090: replace codec to component

2018-03-28 Thread Kuninori Morimoto
Hi

Thank you for this report.
I will post v2 patch, soon

kbuild test robot wrote:
> 
> [1  ]
> Hi Kuninori,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linuxtv-media/master]
> [also build test ERROR on next-20180328]
> [cannot apply to v4.16-rc7]
> [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/Kuninori-Morimoto/media-i2c-wm9090-replace-codec-to-component/20180329-082843
> base:   git://linuxtv.org/media_tree.git master
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
> >> drivers/media/i2c/tda1997x.c:2494:12: error: initialization from 
> >> incompatible pointer type [-Werror=incompatible-pointer-types]
>  .remove = tda1997x_codec_remove,
>^
>drivers/media/i2c/tda1997x.c:2494:12: note: (near initialization for 
> 'tda1997x_codec_driver.remove')
>cc1: some warnings being treated as errors
> 
> vim +2494 drivers/media/i2c/tda1997x.c
> 
> 9ac0038d Tim Harvey2018-02-15  2491  
> b534b135 Kuninori Morimoto 2018-03-28  2492  static struct 
> snd_soc_component_driver tda1997x_codec_driver = {
> 9ac0038d Tim Harvey2018-02-15  2493   .probe = tda1997x_codec_probe,
> 9ac0038d Tim Harvey2018-02-15 @2494   .remove = tda1997x_codec_remove,
> b534b135 Kuninori Morimoto 2018-03-28  2495   .idle_bias_on   = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2496   .use_pmdown_time= 1,
> b534b135 Kuninori Morimoto 2018-03-28  2497   .endianness = 1,
> b534b135 Kuninori Morimoto 2018-03-28  2498   .non_legacy_dai_naming  = 1,
> 9ac0038d Tim Harvey2018-02-15  2499  };
> 9ac0038d Tim Harvey2018-02-15  2500  
> 
> :: The code at line 2494 was first introduced by commit
> :: 9ac0038db9a7e10fc8f425010ec98b7afc2ff621 media: i2c: Add TDA1997x HDMI 
> receiver driver
> 
> :: TO: Tim Harvey 
> :: CC: Mauro Carvalho Chehab 
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> [2 .config.gz ]
> 


Re: [PATCHv2 08/14] mm/page_ext: Drop definition of unused PAGE_EXT_DEBUG_POISON

2018-03-28 Thread Vinayak Menon
On 3/28/2018 10:25 PM, Kirill A. Shutemov wrote:
> After bd33ef368135 ("mm: enable page poisoning early at boot")
> PAGE_EXT_DEBUG_POISON is not longer used. Remove it.
>
> Signed-off-by: Kirill A. Shutemov 
> Cc: Vinayak Menon 
> ---
>  include/linux/page_ext.h | 11 ---
>  1 file changed, 11 deletions(-)
>
> diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
> index ca5461efae2f..bbec618a614b 100644
> --- a/include/linux/page_ext.h
> +++ b/include/linux/page_ext.h
> @@ -16,18 +16,7 @@ struct page_ext_operations {
>  
>  #ifdef CONFIG_PAGE_EXTENSION
>  
> -/*
> - * page_ext->flags bits:
> - *
> - * PAGE_EXT_DEBUG_POISON is set for poisoned pages. This is used to
> - * implement generic debug pagealloc feature. The pages are filled with
> - * poison patterns and set this flag after free_pages(). The poisoned
> - * pages are verified whether the patterns are not corrupted and clear
> - * the flag before alloc_pages().
> - */
> -
>  enum page_ext_flags {
> - PAGE_EXT_DEBUG_POISON,  /* Page is poisoned */
>   PAGE_EXT_DEBUG_GUARD,
>   PAGE_EXT_OWNER,
>  #if defined(CONFIG_IDLE_PAGE_TRACKING) && !defined(CONFIG_64BIT)

Reviewed-by: Vinayak Menon 



Re: [PATCH] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source

2018-03-28 Thread Vignesh R


On Thursday 29 March 2018 04:00 AM, Tony Lindgren wrote:
> * Vignesh R  [180327 12:03]:
>> Enable/Clear module level UART wakeup in UART_OMAP_WER register based on
>> return value of device_may_wakeup() in .suspend(). This allows
>> userspace to use sysfs to control the ability of UART to wakeup the
>> system from deep sleep state. Register is restored back in .startup()
>> call that happens as part of resume sequence.
>> 
>> With this patch, userspace can control UART wakeup capability via sysfs:
>> To enable wakeup capability:
>> echo enabled >  /sys/class/tty/ttyXX/device/power/wakeup
>> For disabling wakeup capability:
>> echo disabled > /sys/class/tty/ttyXX/device/power/wakeup
> 
> To avoid confusion, can you please add this to the description:
> 
> Note that the UART wakeup events configured in the 8250 hardware only
> work for idle modes that do not cut off power for the UART. For deeper
> idle states, dedicated padconf wakeirqs must be used. Or in some cases
> the UART RX pin can be remuxed to GPIO input if the GPIO block stays
> powered.
> 

That makes sense, I will add it to patch description in v2.

> I tested this briefly and the dedicated wakeirqs still work for me,
> so from that point of view:
> 
> Tested-by: Tony Lindgren 

Thanks for testing!

-- 
Regards
Vignesh


[PATCH v4 1/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
It's common practice to store MAC addresses for network interfaces into
nvmem devices. However the code to actually do this in the kernel lacks,
so this patch adds of_get_nvmem_mac_address() for drivers to obtain the
address from an nvmem cell provider.

This is particulary useful on devices where the ethernet interface cannot
be configured by the bootloader, for example because it's in an FPGA.

Signed-off-by: Mike Looijmans 
Reviewed-by: Florian Fainelli 
Reviewed-by: Andrew Lunn 
---
 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 3 files changed, 48 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt 
b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..cfc376b 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
   the boot program; should be used in cases where the MAC address assigned to
   the device by the boot program is different from the "local-mac-address"
   property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address;
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used;
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in the Devicetree
diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..53189d4 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -7,6 +7,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,3 +81,42 @@ const void *of_get_mac_address(struct device_node *np)
return of_get_mac_addr(np, "address");
 }
 EXPORT_SYMBOL(of_get_mac_address);
+
+/**
+ * Obtain the MAC address from an nvmem provider named 'mac-address' through
+ * device tree.
+ * On success, copies the new address into memory pointed to by addr and
+ * returns 0. Returns a negative error code otherwise.
+ * @np:Device tree node containing the nvmem-cells phandle
+ * @addr:  Pointer to receive the MAC address using ether_addr_copy()
+ */
+int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   struct nvmem_cell *cell;
+   const void *mac;
+   size_t len;
+   int ret;
+
+   cell = of_nvmem_cell_get(np, "mac-address");
+   if (IS_ERR(cell))
+   return PTR_ERR(cell);
+
+   mac = nvmem_cell_read(cell, &len);
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(mac))
+   return PTR_ERR(mac);
+
+   if (len < ETH_ALEN || !is_valid_ether_addr(mac)) {
+   ret = -EINVAL;
+   } else {
+   ether_addr_copy(addr, mac);
+   ret = 0;
+   }
+
+   kfree(mac);
+
+   return ret;
+}
+EXPORT_SYMBOL(of_get_nvmem_mac_address);
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 9cd72aa..90d81ee 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -13,6 +13,7 @@
 struct net_device;
 extern int of_get_phy_mode(struct device_node *np);
 extern const void *of_get_mac_address(struct device_node *np);
+extern int of_get_nvmem_mac_address(struct device_node *np, void *addr);
 extern struct net_device *of_find_net_device_by_node(struct device_node *np);
 #else
 static inline int of_get_phy_mode(struct device_node *np)
@@ -25,6 +26,11 @@ static inline const void *of_get_mac_address(struct 
device_node *np)
return NULL;
 }
 
+static inline int of_get_nvmem_mac_address(struct device_node *np, void *addr)
+{
+   return -ENODEV;
+}
+
 static inline struct net_device *of_find_net_device_by_node(struct device_node 
*np)
 {
return NULL;
-- 
1.9.1



[PATCH v4 2/2] net: macb: Try to retrieve MAC addess from nvmem provider

2018-03-28 Thread Mike Looijmans
Call of_get_nvmem_mac_address() to fetch the MAC address from an nvmem
cell, if one is provided in the device tree. This allows the address to
be stored in an I2C EEPROM device for example.

Signed-off-by: Mike Looijmans 
Acked-by: Nicolas Ferre 
---
 drivers/net/ethernet/cadence/macb_main.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index e84afcf..eabe14f 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3950,10 +3950,16 @@ static int macb_probe(struct platform_device *pdev)
dev->max_mtu = ETH_DATA_LEN;
 
mac = of_get_mac_address(np);
-   if (mac)
+   if (mac) {
ether_addr_copy(bp->dev->dev_addr, mac);
-   else
-   macb_get_hwaddr(bp);
+   } else {
+   err = of_get_nvmem_mac_address(np, bp->dev->dev_addr);
+   if (err) {
+   if (err == -EPROBE_DEFER)
+   goto err_out_free_netdev;
+   macb_get_hwaddr(bp);
+   }
+   }
 
err = of_get_phy_mode(np);
if (err < 0) {
-- 
1.9.1



[PATCH v4 0/2] of_net: Implement of_get_nvmem_mac_address helper

2018-03-28 Thread Mike Looijmans
Posted this as a small set now, with an (optional) second patch that shows
how the changes work and what I've used to test the code on a Topic Miami board.
I've taken the liberty to add appropriate "Acked" and "Review" tags.

v4: Replaced "6" with ETH_ALEN

v3: Add patch that implements mac in nvmem for the Cadence MACB controller
Remove the integrated of_get_mac_address call

v2: Use of_nvmem_cell_get to avoid needing the assiciated device
Use void* instead of char*
Add devicetree binding doc


Mike Looijmans (2):
  of_net: Implement of_get_nvmem_mac_address helper
  net: macb: Try to retrieve MAC addess from nvmem provider

 Documentation/devicetree/bindings/net/ethernet.txt |  2 ++
 drivers/net/ethernet/cadence/macb_main.c   | 12 +--
 drivers/of/of_net.c| 40 ++
 include/linux/of_net.h |  6 
 4 files changed, 57 insertions(+), 3 deletions(-)

-- 
1.9.1



Re: [PATCH 5/6] rhashtable: support guaranteed successful insertion.

2018-03-28 Thread Herbert Xu
On Thu, Mar 29, 2018 at 08:26:21AM +1100, NeilBrown wrote:
>
> I say "astronomically unlikely", you say "probability .. is extremely
> low".  I think we are in agreement here.
> 
> The point remains that if an error *can* be returned then I have to
> write code to handle it and test that code.  I'd rather not.

You have be able to handle errors anyway because of memory allocation
failures.  Ultimately if you keep inserting you will eventually
fail with ENOMEM.  So I don't see the issue with an additional
error value.

> > Even if it does happen we won't fail because we will perform
> > an immediate rehash.  We only fail if it happens right away
> > after the rehash (that is, at least another 16 elements have
> > been inserted and you're trying to insert a 17th element, all
> > while the new hash table has not been completely populated),
> > which means that somebody has figured out our hash secret and
> > failing in that case makes sense.

BTW, you didn't acknowledge this bit which I think is crucial to
how likely such an error is.

> I never suggested retrying, but I would have to handle it somehow.  I'd
> rather not.

...

> While I have no doubt that there are hashtables where someone could try
> to attack the hash, I am quite sure there are others where is such an
> attack is meaningless - any code which could generate the required range of
> keys, could do far worse things more easily.

Our network hashtable has to be secure against adversaries.  I
understand that this may not be important to your use-case.  However,
given the fact that the failure would only occur if an adversary
is present and actively attacking your hash table, I don't think
it has that much of a negative effect on your use-case either.

Of course if you can reproduce the EBUSY error without your
disable_count patch or even after you have fixed the issue I
have pointed out in your disable_count patch you can still reproduce
it then that would suggest a real bug and we would need to fix it,
for everyone.

> Yes, storing a sharded count in the spinlock table does seem like an
> appropriate granularity.  However that leads me to ask: why do we have
> the spinlock table?  Why not bit spinlocks in the hashchain head like
> include/linux/list_bl uses?

The spinlock table predates rhashtable.  Perhaps Thomas/Eric/Dave
can elucidate this.

> I don't understand how it can ever be "too late", though I appreciate
> that in some cases "sooner" is better than "later"
> If we give up on the single atomic_t counter, then we must accept that
> the number of elements could exceed any given value.  The only promise
> we can provide is that it wont exceed N% of the table size for more than
> T seconds.

Sure.  However, assuming we use an estimate that is hash-based,
that *should* be fairly accurate assuming that your hash function
is working in the first place.  It's completely different vs.
estimating based on a per-cpu count which could be wildly inaccurate.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: linux-next: manual merge of the kvm-arm tree with the arm64 tree

2018-03-28 Thread Stephen Rothwell
Hi all,

On Wed, 28 Mar 2018 16:05:41 +1100 Stephen Rothwell  
wrote:
>
> Today's linux-next merge of the kvm-arm tree got a conflict in:
> 
>   arch/arm64/kernel/cpufeature.c
> 
> between commits:
> 
>   143ba05d867a ("arm64: capabilities: Prepare for fine grained capabilities")
>   12eb369125ab ("arm64: cpufeature: Avoid warnings due to unused symbols")
> 
> from the arm64 tree and commit:
> 
>   a1efdff442ec ("arm64: cpufeatures: Drop the ARM64_HYP_OFFSET_LOW feature 
> flag")
> 
> from the kvm-arm tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc arch/arm64/kernel/cpufeature.c
> index 96b15d7b10a8,5b25d56bccfd..
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@@ -838,19 -826,11 +838,6 @@@ static bool has_no_hw_prefetch(const st
>   MIDR_CPU_VAR_REV(1, MIDR_REVISION_MASK));
>   }
>   
> - static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry,
> -int __unused)
>  -static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int 
> __unused)
> --{
> - phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
> - 
> - /*
> -  * Activate the lower HYP offset only if:
> -  * - the idmap doesn't clash with it,
> -  * - the kernel is not running at EL2.
> -  */
> - return idmap_addr > GENMASK(VA_BITS - 2, 0) && !is_kernel_in_hyp_mode();
>  -return is_kernel_in_hyp_mode();
> --}
> --
>   static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int 
> __unused)
>   {
>   u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);

This is now a conflict between the kvm tree and the arm64 tree.

-- 
Cheers,
Stephen Rothwell


pgpeAykeHDCCn.pgp
Description: OpenPGP digital signature


Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 05:22, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 9:13 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> On 03/28/2018 06:02 PM, Jens Axboe wrote:
>>> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
 I am not subscribed to any of the lists on the To list here, please CC
 me on any replies.
 
 I am encountering a fairly consistent crash anywhere from 15 minutes to
 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
 The crash looks like:
 
>> 
 
 Looking through the code, I'd guess that this is dying inside
 blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
 is pointing at.
>>> 
>>> Leaving the whole thing here for Paolo - it's crashing off insertion of
>>> a request coming out of SG_IO. Don't think we've seen this BFQ failure
>>> case before.
>>> 
>>> You can mitigate this by switching the scsi-mq devices to mq-deadline
>>> instead.
>>> 
>> 
>> I'm thinking that I should also be able to mitigate it by disabling
>> CONFIG_DEBUG_BLK_CGROUP.
>> 
>> That should remove that entire chunk of code.
>> 
>> Of course, that won't help if this is actually a symptom of a bigger
>> problem.
> 
> Yes, it's not a given that it will fully mask the issue at hand. But
> turning off BFQ has a much higher chance of working for you.
> 
> This time actually CC'ing Paolo.
> 

Hi Zephaniah,
if you are actually interested in the benefits of BFQ (low latency,
high responsiveness, fairness, ...) then it may be worth to try what
you yourself suggest: disabling CONFIG_DEBUG_BLK_CGROUP.  Also because
this option activates the heavy computation of debug cgroup statistics,
which probably you don't use.

In addition, the outcome of your attempt without
CONFIG_DEBUG_BLK_CGROUP would give us useful bisection information:
- if no failure occurs, then the issue is likely to be confined in
that debugging code (which, on the bright side, is likely to be of
occasional interest, for only a handful of developers)
- if the issue still shows up, then we may have new hints on this odd
failure

Finally, consider that this issue has been reported to disappear from
4.16 [1], and, as a plus, that the service quality of BFQ had a
further boost exactly from 4.16.

Looking forward to your feedback, in case you try BFQ without
CONFIG_DEBUG_BLK_CGROUP,
Paolo

[1] https://www.spinics.net/lists/linux-block/msg21422.html

> 
> -- 
> Jens Axboe



linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got a conflict in:

  arch/x86/kvm/vmx.c

between commit:

  9d1887ef3252 ("KVM: nVMX: sync vmcs02 segment regs prior to vmx_set_cr0")

from the kvm-fixes tree and commit:

  2bb8cafea80b ("KVM: vVMX: signal failure for nested VMEntry if 
emulation_required")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kvm/vmx.c
index 92496b9b5f2b,9bc05f5349c8..
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@@ -10952,6 -11081,21 +11092,16 @@@ static int prepare_vmcs02(struct kvm_vc
/* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */
vmx_set_efer(vcpu, vcpu->arch.efer);
  
 -  if (vmx->nested.dirty_vmcs12) {
 -  prepare_vmcs02_full(vcpu, vmcs12, from_vmentry);
 -  vmx->nested.dirty_vmcs12 = false;
 -  }
 -
+   /*
+* Guest state is invalid and unrestricted guest is disabled,
+* which means L1 attempted VMEntry to L2 with invalid state.
+* Fail the VMEntry.
+*/
+   if (vmx->emulation_required) {
+   *entry_failure_code = ENTRY_FAIL_DEFAULT;
+   return 1;
+   }
+ 
/* Shadow page tables on either EPT or shadow page tables. */
if (nested_vmx_load_cr3(vcpu, vmcs12->guest_cr3, 
nested_cpu_has_ept(vmcs12),
entry_failure_code))


pgpyL1d08Z8Ab.pgp
Description: OpenPGP digital signature


Re: kernel BUG at lib/string.c:LINE! (3)

2018-03-28 Thread syzbot

syzbot has found reproducer for the following crash on upstream commit
a2601d78b77aacc5dd790f488188f9556f4a9eb2 (Wed Mar 28 23:54:03 2018 +)
Merge tag 'powerpc-4.16-6' of  
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
syzbot dashboard link:  
https://syzkaller.appspot.com/bug?extid=6800425d54ed3ed8135d


So far this crash happened 3 times on upstream.
C reproducer: https://syzkaller.appspot.com/x/repro.c?id=4970341969428480
syzkaller reproducer:  
https://syzkaller.appspot.com/x/repro.syz?id=5526256363765760
Raw console output:  
https://syzkaller.appspot.com/x/log.txt?id=5692795733934080
Kernel config:  
https://syzkaller.appspot.com/x/.config?id=-8440362230543204781

compiler: gcc (GCC) 7.1.1 20170620

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+6800425d54ed3ed81...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed.

detected buffer overflow in memcpy
[ cut here ]
kernel BUG at lib/string.c:1052!
invalid opcode:  [#1] SMP KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 4420 Comm: syzkaller185831 Not tainted 4.16.0-rc7+ #4
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051
RSP: 0018:8801b02bf940 EFLAGS: 00010282
RAX: 0022 RBX: 110036057f2d RCX: 
RDX: 0022 RSI: 110036057edd RDI: ed0036057f1c
RBP: 8801b02bf940 R08:  R09: 
R10: 0006 R11:  R12: 8801b02bf9e8
R13: 8801b02bf988 R14: 8801b02bfaa8 R15: fa00
FS:  019ff880() GS:8801db30() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2140 CR3: 0001b0f1b005 CR4: 001606e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 memcpy include/linux/string.h:344 [inline]
 ucma_join_ip_multicast+0x37a/0x3c0 drivers/infiniband/core/ucma.c:1434
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1649
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x43fd29
RSP: 002b:7ffed3ea1058 EFLAGS: 0213 ORIG_RAX: 0001
RAX: ffda RBX: 004002c8 RCX: 0043fd29
RDX: 0118 RSI: 2f80 RDI: 0003
RBP: 006ca018 R08: 004002c8 R09: 004002c8
R10: 004002c8 R11: 0213 R12: 00401650
R13: 004016e0 R14:  R15: 
Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 d2 a7 3f fb eb  
de 55 48 89 fe 48 c7 c7 c0 43 44 87 48 89 e5 e8 d5 05 f1 fa <0f> 0b 90 90  
90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56

RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: 8801b02bf940
---[ end trace 71f07011b6e6886b ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..



linux-next: manual merge of the kvm tree with the kvm-fixes tree

2018-03-28 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the kvm tree got conflicts in:

  arch/x86/kernel/kvm.c

between commit:

  17a1079d9c63 ("KVM: x86: Fix pv tlb flush dependencies")

from the kvm-fixes tree and commit:

  6beacf74c257 ("KVM: X86: Don't use PV TLB flush with dedicated physical CPUs")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kernel/kvm.c
index fae86e36e399,4ccbff63cb86..
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@@ -546,7 -546,8 +546,8 @@@ static void __init kvm_guest_init(void
}
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME))
pv_mmu_ops.flush_tlb_others = kvm_flush_tlb_others;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
@@@ -635,7 -641,8 +641,8 @@@ static __init int kvm_setup_pv_tlb_flus
int cpu;
  
if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
+   !kvm_para_has_hint(KVM_HINTS_DEDICATED) &&
 -  !kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
 +  kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
for_each_possible_cpu(cpu) {
zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, 
cpu),
GFP_KERNEL, cpu_to_node(cpu));


pgp6fEKOClamC.pgp
Description: OpenPGP digital signature


Re: [PATCH v4 2/8] openrisc: Set CONFIG_MULTI_IRQ_HANDLER

2018-03-28 Thread Stafford Horne
On Tue, Mar 27, 2018 at 09:19:05AM -0700, Palmer Dabbelt wrote:
> arm has an optional MULTI_IRQ_HANDLER, which openrisc copied but didn't
> make optional.  I'm converting this to generic code, but in order to
> ensure everything stays bisectable I want this defined on openrisc for
> now.  This will go away by the end of the patch set.
> 
> Signed-off-by: Palmer Dabbelt 

Hi Palmer,
Thanks for doing this work, its always nice to see generic code pulled out of
architecture ports.

Acked-by: Stafford Horne 

> ---
>  arch/openrisc/Kconfig | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index 339df7324e9c..9ecad05bfc73 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -27,6 +27,7 @@ config OPENRISC
>   select GENERIC_STRNLEN_USER
>   select GENERIC_SMP_IDLE_THREAD
>   select MODULES_USE_ELF_RELA
> + select MULTI_IRQ_HANDLER
>   select HAVE_DEBUG_STACKOVERFLOW
>   select OR1K_PIC
>   select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1
> @@ -68,6 +69,9 @@ config STACKTRACE_SUPPORT
>  config LOCKDEP_SUPPORT
>   def_bool  y
>  
> +config MULTI_IRQ_HANDLER
> + def_bool y
> +
>  source "init/Kconfig"
>  
>  source "kernel/Kconfig.freezer"
> -- 
> 2.16.1
> 


Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Paolo Valente


> Il giorno 29 mar 2018, alle ore 03:02, Jens Axboe  ha 
> scritto:
> 
> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> I am not subscribed to any of the lists on the To list here, please CC
>> me on any replies.
>> 
>> I am encountering a fairly consistent crash anywhere from 15 minutes to
>> 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
>> The crash looks like:
>> 
>> [ 5466.075993] general protection fault:  [#1] PREEMPT SMP PTI
>> [ 5466.075997] Modules linked in: esp4 xfrm4_mode_tunnel fuse usblp
>> uvcvideo pci_stub vboxpci(O) vboxnetadp(O) vboxnetflt(O) vboxdrv(O)
>> ip6table_filter ip6_tables xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4
>> xt_conntrack nf_conntrack iptable_filter ip_tables x_tables intel_rapl
>> joydev serio_raw wmi_bmof iwldvm iwlwifi shpchp kvm_intel kvm irqbypass
>> autofs4 algif_skcipher nls_iso8859_1 nls_cp437 crc32_pclmul
>> ghash_clmulni_intel
>> [ 5466.076022] CPU: 3 PID: 10573 Comm: pool Tainted: G   O
>> 4.15.13-f1-dirty #148
>> [ 5466.076024] Hardware name: Hewlett-Packard HP EliteBook Folio
>> 9470m/18DF, BIOS 68IBD Ver. F.44 05/22/2013
>> [ 5466.076029] RIP: 0010:percpu_counter_add_batch+0x2b/0xb0
>> [ 5466.076031] RSP: 0018:a556c47afb58 EFLAGS: 00010002
>> [ 5466.076033] RAX: 95cda87ce018 RBX: 95cda87cdb68 RCX:
>> 
>> [ 5466.076034] RDX: 3fff RSI: 896495c4 RDI:
>> 895b2bed
>> [ 5466.076036] RBP: 3fff R08:  R09:
>> 95cb7d5f8148
>> [ 5466.076037] R10: 0200 R11:  R12:
>> 0001
>> [ 5466.076038] R13: 95cda87ce088 R14: 95cda6ebd100 R15:
>> a556c47afc58
>> [ 5466.076040] FS:  7f25f5305700() GS:95cdbeac()
>> knlGS:
>> [ 5466.076042] CS:  0010 DS:  ES:  CR0: 80050033
>> [ 5466.076043] CR2: 7f25e807e0a8 CR3: 0003ed5a6001 CR4:
>> 001606e0
>> [ 5466.076044] Call Trace:
>> [ 5466.076050]  bfqg_stats_update_io_add+0x58/0x100
>> [ 5466.076055]  bfq_insert_requests+0xec/0xd80
>> [ 5466.076059]  ? blk_rq_append_bio+0x8f/0xa0
>> [ 5466.076061]  ? blk_rq_map_user_iov+0xc3/0x1d0
>> [ 5466.076065]  blk_mq_sched_insert_request+0xa3/0x130
>> [ 5466.076068]  blk_execute_rq+0x3a/0x50
>> [ 5466.076070]  sg_io+0x197/0x3e0
>> [ 5466.076073]  ? dput+0xca/0x210
>> [ 5466.076077]  ? mntput_no_expire+0x11/0x1a0
>> [ 5466.076079]  scsi_cmd_ioctl+0x289/0x400
>> [ 5466.076082]  ? filename_lookup+0xe1/0x170
>> [ 5466.076085]  sd_ioctl+0xc7/0x1a0
>> [ 5466.076088]  blkdev_ioctl+0x4d4/0x8c0
>> [ 5466.076091]  block_ioctl+0x39/0x40
>> [ 5466.076094]  do_vfs_ioctl+0x92/0x5e0
>> [ 5466.076097]  ? __fget+0x73/0xc0
>> [ 5466.076099]  SyS_ioctl+0x74/0x80
>> [ 5466.076102]  do_syscall_64+0x60/0x110
>> [ 5466.076106]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
>> [ 5466.076109] RIP: 0033:0x7f25f75fef47
>> [ 5466.076110] RSP: 002b:7f25f53049a8 EFLAGS: 0246 ORIG_RAX:
>> 0010
>> [ 5466.076112] RAX: ffda RBX: 000c RCX:
>> 7f25f75fef47
>> [ 5466.076114] RDX: 7f25f53049b0 RSI: 2285 RDI:
>> 000c
>> [ 5466.076115] RBP: 0010 R08: 7f25e8007818 R09:
>> 0200
>> [ 5466.076116] R10: 0001 R11: 0246 R12:
>> 
>> [ 5466.076118] R13:  R14: 7f25f8a6b5e0 R15:
>> 7f25e80173e0
>> [ 5466.076120] Code: 41 55 49 89 fd bf 01 00 00 00 41 54 49 89 f4 55 89
>> d5 53 e8 18 e1 bb ff 48 c7 c7 c4 95 64 89 e8 dc e9 fb ff 49 8b 45 20 48
>> 63 d5 <65> 8b 18 48 63 db 4c 01 e3 48 39 d3 7d 0a f7 dd 48 63 ed 48 39
>> [ 5466.076147] RIP: percpu_counter_add_batch+0x2b/0xb0 RSP: a556c47afb58
>> [ 5466.076149] ---[ end trace 8d7eb80aafef4494 ]---
>> [ 5466.670153] note: pool[10573] exited with preempt_count 2
>> 
>> (I only have the one instance right this minute as a result of not
>> having remote syslog setup before now.)
>> 
>> This is clearly deep in the blk_mq code, and it goes away when I remove
>> the use_blk_mq kernel command line parameters.
>> 
>> My next obvious step is to try and disable the load of the vbox modules.
>> 
>> I can include the full dmesg output if it would be helpful.
>> 
>> The system is an older HP Ultrabook, and the root partition is, sda1 (a
>> SSD) -> a LUKS encrypted partition -> LVM -> BTRFS.
>> 
>> The kernel is a stock 4.15.11, however I only recently added the blk_mq
>> options, so while I can state that I have seen this on multiple kernels
>> in the 4.15.x series, I have not tested earlier kernels in this
>> configuration.
>> 
>> Looking through the code, I'd guess that this is dying inside
>> blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
>> is pointing at.
> 
> Leaving the whole thing here for Paolo - it's crashing off insertion of
> a request coming out of SG_IO. Don't think we've seen this BFQ failure
> case before.
> 

Actually, we have.  Found and reported by Ming ab

Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 02:04:07PM -0400, Alan Stern wrote:
> On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> 
> > On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > > On Wed, 28 Mar 2018, Paul E. McKenney wrote:
> > > 
> > > > Hello!
> > > > 
> > > > The prototype patch shown below provides files required to allow herd7 
> > > > to
> > > > evaluate C-language litmus tests for the multicopy-atomic TSO ordering
> > > > provided by s390.  This patch should be viewed with great suspicion.
> > > > It does what I expect it to do on SB (with and without barriers),
> > > > IRIW without barriers, and Alan's SB with read-of-write added, but my
> > > > expectations are quite likely faulty, and my test cases are very few
> > > > in number.
> > > > 
> > > > Either way, this is the easy part.  The hard part (which I am happy
> > > > to leave to others) is making litmus7 and klitmus7 able to do tests
> > > > on actual hardware, as well as enabling herd to handle litmus tests
> > > > containing BAL.  ;-)
> > > > 
> > > > Note that CPU architectures already supported by herd might well need
> > > > only a .cfg file that refers to herd's pre-existing support.
> > > > 
> > > > Thoughts?
> > > 
> > > I don't quite see the point of this.  You're not suggesting that we
> > > have one Linux Kernel Memory Consistency Model for s390 and another
> > > one for all the other architectures, are you?
> > 
> > Certainly not for common code!
> > 
> > > If the idea is merely to provide a herd model for s390 then it should 
> > > go into the DIY repository, not into the LKMM repository.
> > 
> > Makes sense.
> > 
> > In the meantime, does the cat file look to you like it correctly
> > models the combination of TSO and multicopy atomicity?  Do the
> > fences really work, or did I just get lucky with my choice of
> > litmus tests?
> 
> You got lucky.  Try creating an SB litmus test where, instead of an
> smp_mb() fence between the write and the read, each thread executes
> some other kind of fence.

Ah, it does indeed get "Never" in that case, which I do not believe
to e correct.

> The acyclicity condition should have been written more like this:
> 
> let po_ghb = ([R] ; po ; [M]) | ([M] ; po ; [W])
> 
> acyclic mfence | po_ghb | rf | fr | co as tso-mca
> 
> I don't know what the fence instruction is on s390; change the "mfence"
> above accordingly.  The main difference between this and the
> corresponding expression in x86tso.cat is that I replaced rfe with rf.

The s390 fence instruction is "bcr 14,0" or "bcr 15,0", depending on
how recent of hardware you are running.  The latter works everywhere,
if I recall correctly.  But I do not believe that herd knows about either
instruction yet.  Ah, and I need to lose the "empty rmw & (fre;coe)".
That appears to be where my spurious ordering was coming from, strange
though that seems to me.

And your use of "rf" instead of "rfe" makes sense, as that is what makes
the read-from-write provide ordering, correct?  And that should also cover
the "Uniproc check" that would otherwise be required, right?

Except that I get "Sometimes" on CoWR+poonceonce+Once.litmus...
Which I can fix by unioning po-loc into po-ghb.  Or is there some
better way to do this?

> This doesn't account for atomic operations properly; see the "implied" 
> term in x86tso.cat.

I will look at this more later, reaching end of both battery and useful
attention span...

Thanx, Paul



Re: [PATCH RFC tools/memory-model] Add s390.{cfg,cat}

2018-03-28 Thread Paul E. McKenney
On Wed, Mar 28, 2018 at 07:51:36PM +0200, Peter Zijlstra wrote:
> On Wed, Mar 28, 2018 at 11:01:25AM -0400, Alan Stern wrote:
> > I don't quite see the point of this.  You're not suggesting that we
> > have one Linux Kernel Memory Consistency Model for s390 and another
> > one for all the other architectures, are you?
> > 
> > If the idea is merely to provide a herd model for s390 then it should 
> > go into the DIY repository, not into the LKMM repository.
> 
> I suspect the use-case was validating s390 arch code which might not
> have followed all the regular linux rules because they know its TSO. But
> yes, I'm tempted to agree that even arch specific code ought to follow
> the regular rules, just to avoid completely messing up the reader.

Another use case is testing an s390 .cat file without having to teach
herd about s390 assembly.  ;-)

Thanx, Paul



Re: [PATCH][next] wil6210: fix potential null dereference of ndev before null check

2018-03-28 Thread Kalle Valo
me...@codeaurora.org writes:

> On 2018-03-28 20:40, Colin King wrote:
>> From: Colin Ian King 
>>
>> The pointer ndev is being dereferenced before it is being null checked,
>> hence there is a potential null pointer deference. Fix this by only
>> dereferencing ndev after it has been null checked
>>
>> Detected by CoverityScan, CID#1467010 ("Dereference before null check")
>>
>> Fixes: e00243fab84b ("wil6210: infrastructure for multiple virtual
>> interfaces")
>> Signed-off-by: Colin Ian King 

[...]

> Reviewed-by: Maya Erez 

Maya, as you are the wil6210 maintainer you can actually use Acked-by
instead of Reviewed-by. Not that it really matters which one you use,
both of them indicate me that you have checked and agree the patch, but
wanted to point out this anyway :)

-- 
Kalle Valo


Re: [PATCH 2/2] usb: dwc3: add clock and resets

2018-03-28 Thread Masahiro Yamada
2018-03-19 7:37 GMT+09:00 Masahiro Yamada :
> Hi Rob,
>
> 2018-03-18 21:52 GMT+09:00 Rob Herring :
>> On Thu, Mar 15, 2018 at 08:39:58PM +0900, Masahiro Yamada wrote:
>>> dwc3-of-simple.c only handles arbitrary number of clocks and resets.
>>> They are both generic enough to be put into the dwc3 core.  For simple
>>> cases, a nested node structure like follows:
>>>
>>>   dwc3-glue {
>>>   compatible = "foo,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>
>>>   dwc3 {
>>>   compatible = "snps,dwc3";
>>>   ...
>>>   };
>>
>> I'm not a fan of how this was done.
>>
>>
>>>   }
>>>
>>> would be turned into a single node:
>>>
>>>   dwc3 {
>>>   compatible = "foo,dwc3", "snps,dwc3";
>>>   clocks = ...;
>>>   resets = ...;
>>>   ...
>>>   }
>>
>> And yes, this is what I'd prefer.
>
>
>
> Not only dwc3-of-simple.c, but all dwc3 nodes are
> written like this.
>
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3";
> reg = <0x4888 0x1>;
> #address-cells = <1>;
> #size-cells = <1>;
> ranges;
> ...
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
> };
>
>
> The glue layer initializes SoC-specific things,
> then populates the child "snps,dwc3".
>
>
> I think the following structure should work
> by handling EPROBE_DEFER properly.
>
> omap_dwc3_1: omap_dwc3_1@4888 {
> compatible = "ti,dwc3"; (should be "ti,dwc3-glue" or something)
> reg = <0x4888 0x1>;
> ...
> };
>
> usb1: usb@4889 {
> compatible = "snps,dwc3";
> reg = <0x4889 0x17000>;
> ...
> };
>
>
>
>>>
>>> I inserted reset_control_deassert() and clk_enable() before the first
>>> register access, i.e. dwc3_cache_hwparams().
>>>
>>> Signed-off-by: Masahiro Yamada 
>>> ---
>>>
>>>  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
>>>  drivers/usb/dwc3/core.c| 127 
>>> -
>>>  drivers/usb/dwc3/core.h|   5 +
>>>  3 files changed, 132 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
>>> b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> index 44e8bab..67e9cfb 100644
>>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>>> @@ -9,12 +9,14 @@ Required properties:
>>>   - interrupts: Interrupts used by the dwc3 controller.
>>>
>>>  Optional properties:
>>> + - clocks: list of phandle and clock specifier pairs
>>
>> However, this should be specific as to how many clocks and their
>> function. This should be readily available to someone with access to
>> Synopsys datasheet. The number of clocks should generally be the same
>> across SoCs, it is just some SoCs either tie clocks together or don't
>> provide s/w control of some of the clocks.
>
>
> Make sense.
> You also implies this property is mandatory.
> The number of clocks should be available in the datasheet
> and no hardware can work with zero clock.
>
> However, making it mandatory breaks the binding
> since the existing DT files do not specify clocks at all
> in the "snps,dwc3" node.
>
>
>
> Anyway, our current situation:
>
> - We have the dwc3-core under the glue layer node
>   despite they are independent in the CPU address view
> - We add all sorts of clocks and resets in the glue layer node,
>   and nothing in the dwc3-core node.
>
> If these are design mistake, what should we do?
>
> Continue development based on it?
> If we fix it, how to change the course?
>

Any insight about this?


I think this is rather a general question.

If somebody upstreams a driver without clocks,
then later it turns out clocks are necessary,
adding required clocks would break existing platforms
since clk_get() fails.


-- 
Best Regards
Masahiro Yamada


[PATCH 0/3] mfd: axp20x: driver cleanup

2018-03-28 Thread Chen-Yu Tsai
Hi Lee,

Here are some cleanup patches for the axp20x mfd driver.

Patch 1 const-ifies all the struct mfd_cell and struct resource
instances found throughout the driver. Not sure why they weren't
set to const before.

Patch 2 replaces all the openly declared interrupt resources with
nice to read one-line DEFINE_RES_IRQ macros.

Patch 3 corrects the prefix for four of the AXP806 interrupt enums.
"POK" was incorrectly expanded to "PWROK".

These are all simple cleanups. No functionality is changed.

Regards
ChenYu

Chen-Yu Tsai (3):
  mfd: axp20x: Const-ify struct mfd_cell and struct resource
  mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells
  mfd: axp20x: Correct AXP806 POK interrupt prefix

 drivers/mfd/axp20x.c   | 239 +++--
 include/linux/mfd/axp20x.h |  10 +-
 2 files changed, 61 insertions(+), 188 deletions(-)

-- 
2.16.3



[PATCH 1/3] mfd: axp20x: Const-ify struct mfd_cell and struct resource

2018-03-28 Thread Chen-Yu Tsai
The axp20x driver has lots of mfd_cell and resource structs.
These can all be const-ified.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 44 ++--
 include/linux/mfd/axp20x.h |  2 +-
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index aaf2acbef701..14be0f658d74 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -169,18 +169,18 @@ static const struct regmap_access_table 
axp806_volatile_table = {
.n_yes_ranges   = ARRAY_SIZE(axp806_volatile_ranges),
 };
 
-static struct resource axp152_pek_resources[] = {
+static const struct resource axp152_pek_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp20x_ac_power_supply_resources[] = {
+static const struct resource axp20x_ac_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
 };
 
-static struct resource axp20x_pek_resources[] = {
+static const struct resource axp20x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP20X_IRQ_PEK_RIS_EDGE,
@@ -194,19 +194,19 @@ static struct resource axp20x_pek_resources[] = {
},
 };
 
-static struct resource axp20x_usb_power_supply_resources[] = {
+static const struct resource axp20x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"),
DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
 };
 
-static struct resource axp22x_usb_power_supply_resources[] = {
+static const struct resource axp22x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
 };
 
-static struct resource axp22x_pek_resources[] = {
+static const struct resource axp22x_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP22X_IRQ_PEK_RIS_EDGE,
@@ -220,7 +220,7 @@ static struct resource axp22x_pek_resources[] = {
},
 };
 
-static struct resource axp288_power_button_resources[] = {
+static const struct resource axp288_power_button_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP288_IRQ_POKP,
@@ -235,7 +235,7 @@ static struct resource axp288_power_button_resources[] = {
},
 };
 
-static struct resource axp288_fuel_gauge_resources[] = {
+static const struct resource axp288_fuel_gauge_resources[] = {
{
.start = AXP288_IRQ_QWBTU,
.end   = AXP288_IRQ_QWBTU,
@@ -268,7 +268,7 @@ static struct resource axp288_fuel_gauge_resources[] = {
},
 };
 
-static struct resource axp803_pek_resources[] = {
+static const struct resource axp803_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP803_IRQ_PEK_RIS_EDGE,
@@ -282,7 +282,7 @@ static struct resource axp803_pek_resources[] = {
},
 };
 
-static struct resource axp809_pek_resources[] = {
+static const struct resource axp809_pek_resources[] = {
{
.name   = "PEK_DBR",
.start  = AXP809_IRQ_PEK_RIS_EDGE,
@@ -648,7 +648,7 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip 
= {
.num_regs   = 5,
 };
 
-static struct mfd_cell axp20x_cells[] = {
+static const struct mfd_cell axp20x_cells[] = {
{
.name   = "axp20x-gpio",
.of_compatible  = "x-powers,axp209-gpio",
@@ -677,7 +677,7 @@ static struct mfd_cell axp20x_cells[] = {
},
 };
 
-static struct mfd_cell axp221_cells[] = {
+static const struct mfd_cell axp221_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -703,7 +703,7 @@ static struct mfd_cell axp221_cells[] = {
},
 };
 
-static struct mfd_cell axp223_cells[] = {
+static const struct mfd_cell axp223_cells[] = {
{
.name   = "axp221-pek",
.num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -729,7 +729,7 @@ static struct mfd_cell axp223_cells[] = {
},
 };
 
-static struct mfd_cell axp152_cells[] = {
+static const struct mfd_cell axp152_cells[] = {
{
.name   = "axp20x-pek",
.num_resources  = ARRAY_SIZE(axp152_pek_resources),
@@ -737,7 +737,7 @@ static struct mfd_cell axp152_cells[] = {
},
 };
 
-static struct resource axp288_adc_resources[] = {
+sta

[PATCH 2/3] mfd: axp20x: Use DEFINE_RES_IRQ to declare resources for mfd_cells

2018-03-28 Thread Chen-Yu Tsai
Previously we were open coding the interrupts for the various mfd
cells. This made the code somewhat long due to pretty-formatting.

This patch convert those into one-line declarations with DEFINE_RES_IRQ,
making the code shorter and easier to read.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c | 187 +--
 1 file changed, 30 insertions(+), 157 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 14be0f658d74..b3051e1c3ddc 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -181,17 +181,8 @@ static const struct resource 
axp20x_ac_power_supply_resources[] = {
 };
 
 static const struct resource axp20x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP20X_IRQ_PEK_RIS_EDGE,
-   .end= AXP20X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP20X_IRQ_PEK_FAL_EDGE,
-   .end= AXP20X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp20x_usb_power_supply_resources[] = {
@@ -207,93 +198,32 @@ static const struct resource 
axp22x_usb_power_supply_resources[] = {
 };
 
 static const struct resource axp22x_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP22X_IRQ_PEK_RIS_EDGE,
-   .end= AXP22X_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP22X_IRQ_PEK_FAL_EDGE,
-   .end= AXP22X_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp288_power_button_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP288_IRQ_POKP,
-   .end= AXP288_IRQ_POKP,
-   .flags  = IORESOURCE_IRQ,
-   },
-   {
-   .name   = "PEK_DBF",
-   .start  = AXP288_IRQ_POKN,
-   .end= AXP288_IRQ_POKN,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"),
 };
 
 static const struct resource axp288_fuel_gauge_resources[] = {
-   {
-   .start = AXP288_IRQ_QWBTU,
-   .end   = AXP288_IRQ_QWBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTU,
-   .end   = AXP288_IRQ_WBTU,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_QWBTO,
-   .end   = AXP288_IRQ_QWBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WBTO,
-   .end   = AXP288_IRQ_WBTO,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL2,
-   .end   = AXP288_IRQ_WL2,
-   .flags = IORESOURCE_IRQ,
-   },
-   {
-   .start = AXP288_IRQ_WL1,
-   .end   = AXP288_IRQ_WL1,
-   .flags = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTU),
+   DEFINE_RES_IRQ(AXP288_IRQ_QWBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WBTO),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL2),
+   DEFINE_RES_IRQ(AXP288_IRQ_WL1),
 };
 
 static const struct resource axp803_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP803_IRQ_PEK_RIS_EDGE,
-   .end= AXP803_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP803_IRQ_PEK_FAL_EDGE,
-   .end= AXP803_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct resource axp809_pek_resources[] = {
-   {
-   .name   = "PEK_DBR",
-   .start  = AXP809_IRQ_PEK_RIS_EDGE,
-   .end= AXP809_IRQ_PEK_RIS_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   }, {
-   .name   = "PEK_DBF",
-   .start  = AXP809_IRQ_PEK_FAL_EDGE,
-   .end= AXP809_IRQ_PEK_FAL_EDGE,
-   .flags  = IORESOURCE_IRQ,
-   },
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+   DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct regmap_config axp152_regmap_co

[PATCH 3/3] mfd: axp20x: Correct AXP806 POK interrupt prefix

2018-03-28 Thread Chen-Yu Tsai
When AXP806 support was added, POK was incorrectly expanded to PWROK.
However, the datasheet lists them as POK[LSNP], which is the same as
on the AXP288. Furthermore, the registers associated with POK functions
are the same as the PEK on the other AXP PMICs. This suggests that
"POK" means "Power On Key", much like "PEK" means "Power Enable Key",
instead of "Power OK".

This patch changes the "PWROK" prefix to "POK" for these interrupts.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/mfd/axp20x.c   | 8 
 include/linux/mfd/axp20x.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index b3051e1c3ddc..9a2ef3d9b8f8 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -450,11 +450,11 @@ static const struct regmap_irq axp806_regmap_irqs[] = {
INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW,0, 5),
INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW,0, 6),
INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW,0, 7),
-   INIT_REGMAP_IRQ(AXP806, PWROK_LONG, 1, 0),
-   INIT_REGMAP_IRQ(AXP806, PWROK_SHORT,1, 1),
+   INIT_REGMAP_IRQ(AXP806, POK_LONG,   1, 0),
+   INIT_REGMAP_IRQ(AXP806, POK_SHORT,  1, 1),
INIT_REGMAP_IRQ(AXP806, WAKEUP, 1, 4),
-   INIT_REGMAP_IRQ(AXP806, PWROK_FALL, 1, 5),
-   INIT_REGMAP_IRQ(AXP806, PWROK_RISE, 1, 6),
+   INIT_REGMAP_IRQ(AXP806, POK_FALL,   1, 5),
+   INIT_REGMAP_IRQ(AXP806, POK_RISE,   1, 6),
 };
 
 static const struct regmap_irq axp809_regmap_irqs[] = {
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index a2489363a998..517e60eecbcb 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -592,11 +592,11 @@ enum axp806_irqs {
AXP806_IRQ_DCDCC_V_LOW,
AXP806_IRQ_DCDCD_V_LOW,
AXP806_IRQ_DCDCE_V_LOW,
-   AXP806_IRQ_PWROK_LONG,
-   AXP806_IRQ_PWROK_SHORT,
+   AXP806_IRQ_POK_LONG,
+   AXP806_IRQ_POK_SHORT,
AXP806_IRQ_WAKEUP,
-   AXP806_IRQ_PWROK_FALL,
-   AXP806_IRQ_PWROK_RISE,
+   AXP806_IRQ_POK_FALL,
+   AXP806_IRQ_POK_RISE,
 };
 
 enum axp809_irqs {
-- 
2.16.3



[PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h

2018-03-28 Thread NeilBrown
These defines are unused or nearly unused, and do not
help at all.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |2 --
 .../lustre/include/linux/libcfs/linux/libcfs.h |   17 -
 drivers/staging/lustre/lnet/libcfs/tracefile.c |2 +-
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h 
b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 4702956805a6..d6e4f47b5daf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -43,8 +43,6 @@
 /*
  * Plus, platform-specific constant
  *
- * CFS_CURPROC_COMM_MAX,
- *
  * and opaque scalar type
  *
  * kernel_cap_t
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index c39c34d74382..0dbd01617865 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -81,8 +81,6 @@
 #include 
 #include "linux-cpu.h"
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE - \
@@ -114,19 +112,4 @@ do {   
\
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include 
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
 #endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c 
b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 129430e74d00..514e1845740e 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data 
*msgdata,
goto console;
}
 
-   depth = __current_nesting_level();
+   depth = 0;
known_size = strlen(file) + 1 + depth;
if (msgdata->msg_fn)
known_size += strlen(msgdata->msg_fn) + 1;




[PATCH 14/17] staging: lustre: discard cfs_duration_sec()

2018-03-28 Thread NeilBrown
cfs_duration_sec() simply divides by HZ.
It is mostly used to report durations in debug messages.
Remove and just use X/HZ.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|2 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |5 ++---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |4 ++--
 drivers/staging/lustre/lnet/libcfs/debug.c |2 +-
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c |6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 9 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ecb2126a9e6f..9a353c6cb85a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,11 +60,6 @@
  * Generic kernel stuff
  */
 
-static inline long cfs_duration_sec(long d)
-{
-   return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index d0ce37d72571..959e119384df 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t 
nid,
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1);
+  last_alive ? (now - last_alive) / HZ : -1);
 }
 
 static void kiblnd_free_pages(struct kib_pages *p)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 563ff5c972bf..b4a182d87ae7 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
-  cfs_duration_sec(jiffies - tx->tx_deadline));
+  (jiffies - tx->tx_deadline) / HZ);
return 1;
}
}
@@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
if (timedout) {
CERROR("Timed out RDMA with %s (%lu): c: %u, 
oc: %u, rc: %u\n",
   libcfs_nid2str(peer->ibp_nid),
-  cfs_duration_sec(jiffies -
-   peer->ibp_last_alive),
+  (jiffies - peer->ibp_last_alive) / HZ,
   conn->ibc_credits,
   conn->ibc_outstanding_credits,
   conn->ibc_reserved_credits);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 16c1ab0b0bd9..79b98cdd0f9d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
   libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
   &conn->ksnc_ipaddr, conn->ksnc_port,
   iov_iter_count(&conn->ksnc_rx_to), 
conn->ksnc_rx_nob_left,
-  cfs_duration_sec(jiffies - last_rcv));
+  (jiffies - last_rcv) / HZ);
lnet_finalize(conn->ksnc_peer->ksnp_ni,
  conn->ksnc_cookie, -EIO);
break;
@@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, 
unsigned long *when)
 
CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
   libcfs_nid2str(nid), peer,
-  last_alive ? cfs_duration_sec(now - last_alive) : -1,
+  last_alive ? (now - last_alive) / HZ : -1,
   connect);
 
if (!connect)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 8ead1e02e854..14450fd5957a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -751,7 +751,7 @@ ksocknal_find_connectable_route_lock

[PATCH 16/17] staging: lustre: discard linux-time.h

2018-03-28 Thread NeilBrown
Very little is left in linux-time.h.
Move CFS_TICK to libcfs.h discard the test.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |5 ++
 .../lustre/include/linux/libcfs/linux/libcfs.h |1 
 .../lustre/include/linux/libcfs/linux/linux-time.h |   66 
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |2 -
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 
drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3d3fa52858e5..f183f31da387 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -52,6 +52,11 @@
 
 #define LOWEST_BIT_SET(x)   ((x) & ~((x) - 1))
 
+/*
+ * One jiffy
+ */
+#define CFS_TICK   (1UL)
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 30e333af8d0d..c39c34d74382 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -80,7 +80,6 @@
 #include 
 #include 
 #include "linux-cpu.h"
-#include "linux-time.h"
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index ecdebccf2b44..
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov 
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include  
instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)10)
-#define ONE_MILLION 100
-
-#include 
-#include 
-#include 
-#include 
-
-/*
- * post 2.5 kernels.
- */
-
-#include 
-
-/*
- * One jiffy
- */
-#define CFS_TICK   (1UL)
-
-#define CFS_DURATION_T   "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c 
b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 3f17c673d1b8..89eef8ec7df4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 * we will SKIP the next ping at next_ping, and the
 * ping will get sent 2 timeouts from now!  Beware.
 */
-   CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+   CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
   time_to_next_wake,
   this_ping + PING_INTERVAL * HZ);
} while (time_to_next_wake <= 0);




[PATCH 15/17] staging: lustre: discard cfs_time_before_64()

2018-03-28 Thread NeilBrown
cfs_time_before_64 is the same as time_before64()
similarly cfs_time_beforeq_64() matsches time_before_eq64()
So just use the standard interfaces.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --
 drivers/staging/lustre/lustre/include/obd_class.h  |4 ++--
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 9a353c6cb85a..ecdebccf2b44 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -56,20 +56,6 @@
 
 #include 
 
-/*
- * Generic kernel stuff
- */
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
-   return (__s64)t2 - (__s64)t1 >= 0;
-}
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index 7cfc3c8d100c..176b63e2c9a7 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
 
CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
   obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
} else {
CDEBUG(D_SUPER,
@@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, 
struct obd_export *exp,
 
CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
   obd->obd_osfs_age, max_age);
-   if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+   if (time_before64(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
if (rc == 0) {
spin_lock(&obd->obd_osfs_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index dd4fd54128dd..537a9e2ed467 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
 * the last successful attempt, go with this one
 */
if ((conn->oic_last_attempt == 0) ||
-   cfs_time_beforeq_64(conn->oic_last_attempt,
+   time_before_eq64(conn->oic_last_attempt,
imp->imp_last_success_conn)) {
imp_conn = conn;
tried_all = 0;
@@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
 */
if (!imp_conn)
imp_conn = conn;
-   else if (cfs_time_before_64(conn->oic_last_attempt,
+   else if (time_before64(conn->oic_last_attempt,
imp_conn->oic_last_attempt))
imp_conn = conn;
}




[PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()

2018-03-28 Thread NeilBrown
This wrapper is only used once, so open-code it as max().

This allows us to remove the libcfs_time.h include file.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |1 
 .../lustre/include/linux/libcfs/libcfs_time.h  |   50 
 .../lustre/include/linux/libcfs/linux/linux-time.h |2 -
 drivers/staging/lustre/lustre/ptlrpc/import.c  |4 +-
 4 files changed, 3 insertions(+), 54 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3b751c436b3d..3d3fa52858e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index 172a8872e3f3..
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
-   if (timeout < CFS_TICK)
-   timeout = CFS_TICK;
-   return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ff3aae2f1231..ecb2126a9e6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK   (1)
+#define CFS_TICK   (1UL)
 
 #define CFS_DURATION_T   "%ld"
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c 
b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 4a9d1f189d01..dd4fd54128dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
}
 
if (ptlrpc_import_in_recovery(imp)) {
-   long timeout;
+   unsigned long timeout;
 
if (AT_OFF) {
if (imp->imp_server_timeout)
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int 
noclose)
 
if (wait_event_idle_timeout(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp),
-   cfs_timeout_cap(timeout)) == 0)
+   max(timeout, CFS_TICK)) == 0)
l_wait_event_abortable(
imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp));




[PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.

2018-03-28 Thread NeilBrown
ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b8fd778d9832..614caa4a9b0e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_CAST(res);
 
lock = ldlm_lock_new(res);
-   if (!lock)
+   if (!lock) {
+   ldlm_resource_putref(res);
return ERR_PTR(-ENOMEM);
+   }
 
lock->l_req_mode = mode;
lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace 
*ns,
return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini




[PATCH 08/17] staging: lustre: add container_of_safe()

2018-03-28 Thread NeilBrown
Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown 
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 ---
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |6 +++---
 drivers/staging/lustre/lustre/llite/llite_nfs.c|2 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |8 
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |2 +-
 .../staging/lustre/lustre/lov/lov_cl_internal.h|   18 +-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |2 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |8 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h|   10 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c |2 +-
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +-
 include/linux/kernel.h |   16 
 15 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..3b751c436b3d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
 int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
-{
-   if (IS_ERR_OR_NULL(ptr))
-   return ptr;
-   return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
-   ((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
 #define _LIBCFS_H
 
 extern struct miscdevice libcfs_dev;
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h 
b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device 
*d)
 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
 {
LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
-   return container_of0(d, struct cl_device, cd_lu_dev);
+   return container_of_safe(d, struct cl_device, cd_lu_dev);
 }
 
 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct 
cl_device *d)
 static inline struct cl_object *lu2cl(const struct lu_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
-   return container_of0(o, struct cl_object, co_lu);
+   return container_of_safe(o, struct cl_object, co_lu);
 }
 
 static inline const struct cl_object_conf *
 lu2cl_conf(const struct lu_object_conf *conf)
 {
-   return container_of0(conf, struct cl_object_conf, coc_lu);
+   return container_of_safe(conf, struct cl_object_conf, coc_lu);
 }
 
 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const 
struct cl_object *obj)
 static inline struct cl_device *cl_object_device(const struct cl_object *o)
 {
LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
-   return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+   return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
 }
 
 static inline struct cl_object_header *luh2coh(const struct lu_object_header 
*h)
 {
-   return container_of0(h, struct cl_object_header, coh_lu);
+   return container_of_safe(h, struct cl_object_header, coh_lu);
 }
 
 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..c3b0ed518819 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -745,15 +745,15 @@ struct lu_object *lu_objec

[PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()

2018-03-28 Thread NeilBrown
1/ the return value of ldlm_resource_putref() is never
  used, so change it to return 'void'.
2/ Move all of the code to run on the last putref to
   __ldlm_resource_putref_final().  This means a lock
   is taken in one function and dropped in another, but
   that isn't too uncommon, and will disappear in a future
   patch.
   Now that the code it together, it becomes apparent that
   we are dropping a ref on the namespace *before* the last
   use.  So keep the ref until after.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h 
b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 5a355fbab401..d668d86423a4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct 
ldlm_namespace *ns,
struct ldlm_resource *parent,
const struct ldlm_res_id *,
enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res,
struct list_head *head,
struct ldlm_lock *lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..8841a1bb2c0a 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
 struct ldlm_resource *res)
 {
struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+   struct ldlm_namespace *ns = nsb->nsb_namespace;
 
if (!list_empty(&res->lr_granted)) {
ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct 
cfs_hash_bd *bd,
LBUG();
}
 
-   cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+   cfs_hash_bd_del_locked(ns->ns_rs_hash,
   bd, &res->lr_hash);
lu_ref_fini(&res->lr_reference);
+   cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+   ns->ns_lvbo->lvbo_free(res);
if (cfs_hash_bd_count_get(bd) == 0)
-   ldlm_namespace_put(nsb->nsb_namespace);
+   ldlm_namespace_put(ns);
+   kmem_cache_free(ldlm_resource_slab, res);
 }
 
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
 {
struct ldlm_namespace *ns = ldlm_res_to_ns(res);
struct cfs_hash_bd   bd;
@@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
   res, atomic_read(&res->lr_refcount) - 1);
 
cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
-   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
+   if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
__ldlm_resource_putref_final(&bd, res);
-   cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
-   if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
-   ns->ns_lvbo->lvbo_free(res);
-   kmem_cache_free(ldlm_resource_slab, res);
-   return 1;
-   }
-   return 0;
 }
 EXPORT_SYMBOL(ldlm_resource_putref);
 




[PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().

2018-03-28 Thread NeilBrown
This function simply multiplies by HZ and adds jiffies.
This is simple enough to be opencoded, and doing so
makes the code easier to read.

Same for cfs_time_shift_64()

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |5 
 .../lustre/include/linux/libcfs/linux/linux-time.h |5 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   12 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +
 drivers/staging/lustre/lnet/lnet/net_fault.c   |   26 ++--
 drivers/staging/lustre/lnet/lnet/router.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 ++-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +
 drivers/staging/lustre/lustre/llite/statahead.c|2 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c|   12 +
 .../staging/lustre/lustre/obdclass/obd_config.c|2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++---
 drivers/staging/lustre/lustre/ptlrpc/service.c |2 +-
 21 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 7b41a129f041..0ebbde4ec8e8 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, 
unsigned long t2)
return time_before_eq(t2, t1);
 }
 
-static inline unsigned long cfs_time_shift(int seconds)
-{
-   return jiffies + seconds * HZ;
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index b3a80531bd71..ff3aae2f1231 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_shift_64(int seconds)
-{
-   return get_jiffies_64() + (u64)seconds * HZ;
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7df07f39b849..276bf486f64b 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset 
*fps,
if (rc)
goto out_fpo;
 
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_owner = fps;
*pp_fpo = fpo;
 
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
spin_lock(&fps->fps_lock);
version = fps->fps_version;
list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
-   fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
fpo->fpo_map_count++;
 
if (fpo->fpo_is_fmr) {
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
fps->fps_version++;
list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
} else {
-   fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+   fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
}
spin_unlock(&fps->fps_lock);
 
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, 
struct kib_pool *pool, int
 
memset(pool, 0, sizeof(*pool));
INIT_LIST_HEAD(&pool->po_free_list);
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+   pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
pool->po_owner= ps;
pool->po_size = size;
 }
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct 
kib_poolset *ps)
continue;
 
pool->po_allocated++;
-   pool->po_deadline = cfs_time_shift(IBLND_POOL_

[PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()

2018-03-28 Thread NeilBrown
cfs_time_after() behaves exactly like time_after()
similarly cfs_time_aftereq() matches time_after_eq()

so discard the cfs versions.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |   14 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|4 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |2 +
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++--
 drivers/staging/lustre/lnet/libcfs/tracefile.c |8 +++--
 drivers/staging/lustre/lnet/lnet/lib-move.c|4 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c   |8 +++--
 drivers/staging/lustre/lnet/lnet/router.c  |6 ++--
 drivers/staging/lustre/lnet/selftest/conrpc.c  |4 +--
 drivers/staging/lustre/lnet/selftest/timer.c   |2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|4 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |4 +--
 drivers/staging/lustre/lustre/osc/osc_object.c |2 +
 drivers/staging/lustre/lustre/osc/osc_request.c|2 +
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |6 ++--
 16 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 0ebbde4ec8e8..172a8872e3f3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -36,20 +36,6 @@
 
 #ifndef __LIBCFS_TIME_H__
 #define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
-   return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
-   return time_before_eq(t2, t1);
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 276bf486f64b..d0ce37d72571 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool 
*fpo, unsigned long now)
return 0;
if (fpo->fpo_failed)
return 1;
-   return cfs_time_aftereq(now, fpo->fpo_deadline);
+   return time_after_eq(now, fpo->fpo_deadline);
 }
 
 static int
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, 
unsigned long now)
return 0;
if (pool->po_failed)
return 1;
-   return cfs_time_aftereq(now, pool->po_deadline);
+   return time_after_eq(now, pool->po_deadline);
 }
 
 void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..ca6e09de0872 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -754,9 +754,9 @@ static inline int
 kiblnd_send_keepalive(struct kib_conn *conn)
 {
return (*kiblnd_tunables.kib_keepalive > 0) &&
-   cfs_time_after(jiffies, conn->ibc_last_send +
-  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
-   MSEC_PER_SEC));
+   time_after(jiffies, conn->ibc_last_send +
+  msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+   MSEC_PER_SEC));
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index f9761d8f2e3e..563ff5c972bf 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct 
list_head *txs)
LASSERT(tx->tx_waiting || tx->tx_sending);
}
 
-   if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+   if (time_after_eq(jiffies, tx->tx_deadline)) {
CERROR("Timed out tx: %s, %lu seconds\n",
   kiblnd_queue2str(conn, txs),
   cfs_duration_sec(jiffies - tx->tx_deadline));
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 1ace54c9b133..8ead1e02e854 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, st

[PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.

2018-03-28 Thread NeilBrown
Discard cfs_time_current() and cfs_time_current64()
and use jiffies and get_jiffies_64() like the rest of the kernel.

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |2 -
 .../lustre/include/linux/libcfs/linux/linux-time.h |9 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   14 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |8 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|9 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++--
 drivers/staging/lustre/lnet/libcfs/tracefile.c |6 +--
 drivers/staging/lustre/lnet/lnet/lib-move.c|4 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c   |6 +--
 drivers/staging/lustre/lnet/lnet/peer.c|2 -
 drivers/staging/lustre/lnet/lnet/router.c  |6 +--
 drivers/staging/lustre/lnet/lnet/router_proc.c |4 +-
 drivers/staging/lustre/lnet/selftest/conrpc.c  |6 +--
 drivers/staging/lustre/lnet/selftest/console.c |4 +-
 drivers/staging/lustre/lnet/selftest/framework.c   |2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |6 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |2 -
 drivers/staging/lustre/lustre/llite/statahead.c|2 -
 drivers/staging/lustre/lustre/lov/lov_request.c|4 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c  |2 -
 drivers/staging/lustre/lustre/osc/osc_object.c |4 +-
 drivers/staging/lustre/lustre/osc/osc_page.c   |4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c|2 -
 drivers/staging/lustre/lustre/ptlrpc/client.c  |4 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c  |2 -
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |4 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c |4 +-
 32 files changed, 88 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index c4f25be78268..df7a3f13f3b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned 
long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-   return cfs_time_add(cfs_time_current(), seconds * HZ);
+   return cfs_time_add(jiffies, seconds * HZ);
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 805cb326af86..ba115e8c820f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,18 +60,11 @@
  * Generic kernel stuff
  */
 
-static inline unsigned long cfs_time_current(void)
-{
-   return jiffies;
-}
-
 static inline long cfs_duration_sec(long d)
 {
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-#define cfs_time_current_64 get_jiffies_64
-
 static inline u64 cfs_time_add_64(u64 t, u64 d)
 {
return t + d;
@@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
 
 static inline u64 cfs_time_shift_64(int seconds)
 {
-   return cfs_time_add_64(cfs_time_current_64(),
+   return cfs_time_add_64(get_jiffies_64(),
   seconds * HZ);
 }
 
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7ae2955c4db6..7df07f39b849 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t 
nid,
 unsigned long *when)
 {
unsigned long last_alive = 0;
-   unsigned long now = cfs_time_current();
+   unsigned long now = jiffies;
rwlock_t *glock = &kiblnd_data.kib_global_lock;
struct kib_peer *peer;
unsigned long flags;
@@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int 
status)
LIST_HEAD(zombies);
struct kib_fmr_pool *fpo = fmr->fmr_pool;
struct kib_fmr_poolset *fps;
-   unsigned long now = cfs_time_current();
+   unsigned long now = jiffies;
struct kib_fmr_pool *tmp;
int rc;
 
@@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, 
struct kib_tx *tx,
goto again;
}
 
-   if (time_before(cfs_time_current(), fps->fps_next_retry)) {
+   if (time_before(jiffies, fps->fps_next_retry)) {
  

[PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub

2018-03-28 Thread NeilBrown
cfs_time_add adds its arguments.
cfs_time_sub subtracts finds the difference.
Discard these and use '+' and '-' directly.

This change highlighted a type error.  The structure field
cr_queued_time was used to store jiffies, but was declared
as time_t (meant for seconds).  So the time is changed to
"unsigned long".

Signed-off-by: NeilBrown 
---
 .../lustre/include/linux/libcfs/libcfs_time.h  |   12 +-
 .../lustre/include/linux/libcfs/linux/linux-time.h |8 +--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|2 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++-
 drivers/staging/lustre/lnet/lnet/lib-move.c|6 ++---
 drivers/staging/lustre/lnet/lnet/router.c  |5 ++--
 drivers/staging/lustre/lnet/lnet/router_proc.c |7 +++---
 drivers/staging/lustre/lnet/selftest/conrpc.c  |4 ++-
 drivers/staging/lustre/lnet/selftest/timer.c   |2 +-
 drivers/staging/lustre/lustre/include/lustre_net.h |5 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|3 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |8 +++
 drivers/staging/lustre/lustre/osc/osc_object.c |3 +--
 drivers/staging/lustre/lustre/ptlrpc/pinger.c  |9 +++-
 drivers/staging/lustre/lustre/ptlrpc/service.c |2 +-
 15 files changed, 32 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index df7a3f13f3b3..7b41a129f041 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -40,16 +40,6 @@
  * generic time manipulation functions.
  */
 
-static inline unsigned long cfs_time_add(unsigned long t, long d)
-{
-   return (unsigned long)(t + d);
-}
-
-static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
-{
-   return (unsigned long)(t1 - t2);
-}
-
 static inline int cfs_time_after(unsigned long t1, unsigned long t2)
 {
return time_before(t2, t1);
@@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned 
long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-   return cfs_time_add(jiffies, seconds * HZ);
+   return jiffies + seconds * HZ;
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h 
b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ba115e8c820f..b3a80531bd71 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_add_64(u64 t, u64 d)
-{
-   return t + d;
-}
-
 static inline u64 cfs_time_shift_64(int seconds)
 {
-   return cfs_time_add_64(get_jiffies_64(),
-  seconds * HZ);
+   return get_jiffies_64() + (u64)seconds * HZ;
 }
 
 static inline int cfs_time_before_64(u64 t1, u64 t2)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 0efde0009a15..4546618c1c12 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
   libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
   &conn->ksnc_ipaddr, conn->ksnc_port,
   iov_iter_count(&conn->ksnc_rx_to), 
conn->ksnc_rx_nob_left,
-  cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
+  cfs_duration_sec(jiffies - last_rcv));
lnet_finalize(conn->ksnc_peer->ksnp_ni,
  conn->ksnc_cookie, -EIO);
break;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index f97da4540b51..5b34c7c030ad 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct 
ksock_tx *tx)
LASSERT(conn->ksnc_tx_scheduled);
list_add_tail(&conn->ksnc_tx_list,
  &ksocknal_data.ksnd_enomem_conns);
-   if (!cfs_time_aftereq(cfs_time_add(jiffies,
-  SOCKNAL_ENOMEM_RETRY),
+   if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
   ksocknal_data.ksnd_reaper_waketime))
wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
@@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
int retry_later = 0;
int rc = 0;
 
-   deadlin

[PATCH 05/17] staging: lustre: remove unneeded include.

2018-03-28 Thread NeilBrown
cfs_hash usage was removed from cl_object.c
some time ago, so remove the #include as well.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/obdclass/cl_object.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 7809f6ae1809..f1641645acae 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -53,7 +53,6 @@
 #include 
 #include 
 #include 
-#include   /* for cfs_hash stuff */
 #include 
 #include 
 #include "cl_internal.h"




[PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async()

2018-03-28 Thread NeilBrown
This function is unused.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   23 
 2 files changed, 24 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h 
b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 239aa2b1268f..7407acf60cf8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1227,7 +1227,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, 
struct ldlm_lock *,
  * processing.
  * @{
  */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
 int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
 /** @} ldlm_local_ast */
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index c3c9186b74ce..be43958e4090 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -191,29 +191,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, 
void *data)
return result;
 }
 
-/**
- * Implementation of ->l_completion_ast() for a client, that doesn't wait
- * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
- * other threads that cannot block for long.
- */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
-{
-   if (flags == LDLM_FL_WAIT_NOREPROC) {
-   LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
-   return 0;
-   }
-
-   if (!(flags & LDLM_FL_BLOCKED_MASK)) {
-   wake_up(&lock->l_waitq);
-   return ldlm_completion_tail(lock, data);
-   }
-
-   LDLM_DEBUG(lock,
-  "client-side enqueue returned a blocked lock, going 
forward");
-   return 0;
-}
-EXPORT_SYMBOL(ldlm_completion_ast_async);
-
 /**
  * Generic LDLM "completion" AST. This is called in several cases:
  *




[PATCH 04/17] staging: lustre: remove unused hash tables.

2018-03-28 Thread NeilBrown
exp_lock_hash and exp_flock_hash are unused in
the client, so remove all references.

Also remove unused hashtable size definitions.

Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   10 ---
 .../staging/lustre/lustre/include/lustre_export.h  |7 -
 .../staging/lustre/lustre/include/obd_support.h|   18 -
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c|   11 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |   14 --
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   27 +---
 drivers/staging/lustre/lustre/obdclass/genops.c|2 -
 7 files changed, 3 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h 
b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 7407acf60cf8..5a355fbab401 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -629,16 +629,6 @@ struct ldlm_lock {
 * Tree node for ldlm_extent.
 */
struct ldlm_interval*l_tree_node;
-   /**
-* Per export hash of locks.
-* Protected by per-bucket exp->exp_lock_hash locks.
-*/
-   struct hlist_node   l_exp_hash;
-   /**
-* Per export hash of flock locks.
-* Protected by per-bucket exp->exp_flock_hash locks.
-*/
-   struct hlist_node   l_exp_flock_hash;
/**
 * Requested mode.
 * Protected by lr_lock.
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h 
b/drivers/staging/lustre/lustre/include/lustre_export.h
index 40cd168ed2ea..19ce13bc8ee6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -102,13 +102,6 @@ struct obd_export {
struct ptlrpc_connection *exp_connection;
/** Connection count value from last successful reconnect rpc */
__u32exp_conn_cnt;
-   /** Hash list of all ldlm locks granted on this export */
-   struct cfs_hash*exp_lock_hash;
-   /**
-* Hash list for Posix lock deadlock detection, added with
-* ldlm_lock::l_exp_flock_hash.
-*/
-   struct cfs_hash*exp_flock_hash;
struct list_headexp_outstanding_replies;
struct list_headexp_uncommitted_replies;
spinlock_texp_uncommitted_replies_lock;
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h 
b/drivers/staging/lustre/lustre/include/obd_support.h
index 8595091b8b86..eb2d6cb6b40b 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -67,27 +67,9 @@ extern char obd_jobid_var[];
 #define HASH_UUID_BKT_BITS 5
 #define HASH_UUID_CUR_BITS 7
 #define HASH_UUID_MAX_BITS 12
-#define HASH_NID_BKT_BITS 5
-#define HASH_NID_CUR_BITS 7
-#define HASH_NID_MAX_BITS 12
-#define HASH_NID_STATS_BKT_BITS 5
-#define HASH_NID_STATS_CUR_BITS 7
-#define HASH_NID_STATS_MAX_BITS 12
-#define HASH_LQE_BKT_BITS 5
-#define HASH_LQE_CUR_BITS 7
-#define HASH_LQE_MAX_BITS 12
 #define HASH_CONN_BKT_BITS 5
 #define HASH_CONN_CUR_BITS 5
 #define HASH_CONN_MAX_BITS 15
-#define HASH_EXP_LOCK_BKT_BITS  5
-#define HASH_EXP_LOCK_CUR_BITS  7
-#define HASH_EXP_LOCK_MAX_BITS  16
-#define HASH_CL_ENV_BKT_BITS5
-#define HASH_CL_ENV_BITS   10
-#define HASH_JOB_STATS_BKT_BITS 5
-#define HASH_JOB_STATS_CUR_BITS 7
-#define HASH_JOB_STATS_MAX_BITS 12
-
 /* Timeout definitions */
 #define OBD_TIMEOUT_DEFAULT 100
 /* Time to wait for all clients to reconnect during recovery (hard limit) */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 411b540b96d9..94f3b1e49896 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode 
mode)
LDLM_DEBUG(lock, "%s(mode: %d)",
   __func__, mode);
 
-   /* Safe to not lock here, since it should be empty anyway */
-   LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
-
list_del_init(&lock->l_res_link);
 
/* client side - set a flag to prevent sending a CANCEL */
@@ -263,15 +260,9 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req)
lock->l_policy_data.l_flock.start =
new->l_policy_data.l_flock.end + 1;
new2->l_conn_export = lock->l_conn_export;
-   if (lock->l_export) {
+   if (lock->l_export)
new2->l_export = class_export_lock_get(lock->l_export,
   new2);
-   if (new2->l_export->exp_lock_hash &&
-   hlist_unhashed(&new2->l_exp_hash))
-   

[PATCH 00/17] staging: Assorted lustre cleanup

2018-03-28 Thread NeilBrown
I'm currently working on converting lustre to use
rhashtables instead of its own resizeable hash tables.
That is progressing well, but I need some changes to
rhashtable first, and that will take a little while.
So here are some other patches.
Some are cleanups related to hashtables,
some are related to measuring time in jiffies
and some are random other things I found as I was looking
at stuff.

James, if this jiffie stuff conflicts with your time-keeping stuff, we
can just drop it.  Last time I cleaned up jiffie-related code you
said it didn't conflict significantly, so I'm hoping this won't
either.

Thanks,
NeilBrown


---

NeilBrown (17):
  staging: lustre: remove invariant in cl_io_read_ahead()
  staging: lustre: remove unused ldlm_completion_ast_async()
  staging: lustre: LNET excludes USERIO
  staging: lustre: remove unused hash tables.
  staging: lustre: remove unneeded include.
  staging: lustre: tidy up ldlm_resource_putref()
  staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
  staging: lustre: add container_of_safe()
  staging: lustre: cfs_time_current() -> jiffies.
  staging: lustre: libcfs: discard cfs_time_add/sub
  staging: lustre: libcfs: discard cfs_time_shift().
  staging: lustre: libcfs: discard cfs_time_after()
  staging: lustre: libcfs: remove cfs_timeout_cap()
  staging: lustre: discard cfs_duration_sec()
  staging: lustre: discard cfs_time_before_64()
  staging: lustre: discard linux-time.h
  staging: lustre: remove cruft from libcfs/linux/libcfs.h


 .../staging/lustre/include/linux/libcfs/curproc.h  |2 
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   17 +--
 .../lustre/include/linux/libcfs/libcfs_time.h  |   79 ---
 .../lustre/include/linux/libcfs/linux/libcfs.h |   18 ---
 .../lustre/include/linux/libcfs/linux/linux-time.h |  103 
 drivers/staging/lustre/lnet/Kconfig|2 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c|   32 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h|6 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   17 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c|   15 +--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   87 -
 drivers/staging/lustre/lnet/libcfs/debug.c |2 
 drivers/staging/lustre/lnet/libcfs/tracefile.c |   12 +-
 drivers/staging/lustre/lnet/lnet/lib-move.c|   14 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c   |   40 
 drivers/staging/lustre/lnet/lnet/peer.c|2 
 drivers/staging/lustre/lnet/lnet/router.c  |   17 ++-
 drivers/staging/lustre/lnet/lnet/router_proc.c |   13 +--
 drivers/staging/lustre/lnet/selftest/conrpc.c  |   14 +--
 drivers/staging/lustre/lnet/selftest/console.c |4 -
 drivers/staging/lustre/lnet/selftest/framework.c   |2 
 drivers/staging/lustre/lnet/selftest/timer.c   |4 -
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |6 +
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   13 ---
 .../staging/lustre/lustre/include/lustre_export.h  |7 -
 drivers/staging/lustre/lustre/include/lustre_net.h |7 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   10 +-
 .../staging/lustre/lustre/include/obd_support.h|   18 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c|   11 --
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |   22 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c|5 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   66 ++---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   25 ++---
 .../staging/lustre/lustre/llite/llite_internal.h   |2 
 drivers/staging/lustre/lustre/llite/llite_lib.c|4 -
 drivers/staging/lustre/lustre/llite/llite_nfs.c|2 
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +-
 drivers/staging/lustre/lustre/llite/statahead.c|4 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |8 +-
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |2 
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|2 
 .../staging/lustre/lustre/lov/lov_cl_internal.h|   18 ++-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |2 
 drivers/staging/lustre/lustre/lov/lov_obd.c|2 
 drivers/staging/lustre/lustre/lov/lov_request.c|4 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c|2 
 drivers/staging/lustre/lustre/obdclass/cl_io.c |1 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |1 
 drivers/staging/lustre/lustre/obdclass/genops.c|2 
 .../lustre/lustre/obdclass/lprocfs_status.c|   12 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |8 +-
 .../staging/lustre/lustre/obdclass/obd_config.c|2 
 .../staging/lustre/lustre/obdecho/echo_client.c|2 
 drivers/staging/lustre/lust

[PATCH 03/17] staging: lustre: LNET excludes USERIO

2018-03-28 Thread NeilBrown
LNET_MINOR and USERIO_MINOR are the same value, so
they cannot both be used in the same kernel.
Until this is resolved, don't allow them to be built
together.  This saves automatic testing from noticing this
known problem.

Reported-by: kernel test robot 
Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lnet/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/Kconfig 
b/drivers/staging/lustre/lnet/Kconfig
index ad049e6f24e4..fe4b24acf075 100644
--- a/drivers/staging/lustre/lnet/Kconfig
+++ b/drivers/staging/lustre/lnet/Kconfig
@@ -1,6 +1,6 @@
 config LNET
tristate "Lustre networking subsystem (LNet)"
-   depends on INET
+   depends on INET && !USERIO
help
  The Lustre network layer, also known as LNet, is a networking 
abstaction
  level API that was initially created to allow Lustre Filesystem to 
utilize




[PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead()

2018-03-28 Thread NeilBrown
This invariant can fail as ci_type is somtimes CIS_INIT.

According to Jinshan Xiong, or of the most recent significant
change to this code, "We should get rid of it."

So do that.

Fixes: 1e1db2a97be5 ("staging: lustre: clio: Revise read ahead implementation")
Cc: Jinshan Xiong 
Signed-off-by: NeilBrown 
---
 drivers/staging/lustre/lustre/obdclass/cl_io.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c 
b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index ab84e011b560..fcdae6029258 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io 
*io,
intresult = 0;
 
LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
-   LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
LINVRNT(cl_io_invariant(io));
 
cl_io_for_each(scan, io) {




Re: [PATCH for v3.18 00/18] Backport CVE-2017-13166 fixes to Kernel 3.18

2018-03-28 Thread Greg KH
On Thu, Mar 29, 2018 at 08:22:08AM +0900, Inki Dae wrote:
> Really thanks for doing this. :) There would be many users who use
> Linux-3.18 for their products yet.

For new products?  They really should not be.  The kernel is officially
end-of-life, but I'm keeping it alive for a short while longer just
because too many people seem to still be using it.  However, they are
not actually updating the kernel in their devices, so I don't think I
will be doing many more new 3.18.y releases.

It's a problem when people ask for support, and then don't use the
releases given to them :(

What is keeping you on 3.18.y and not allowing you to move to a newer
kernel version?

thanks,

greg k-h


Re: [Xen-devel] [PATCH v2 1/1] xen-netback: process malformed sk_buff correctly to avoid BUG_ON()

2018-03-28 Thread Dongli Zhang
Hi Eric,

On 03/29/2018 12:03 PM, Eric Dumazet wrote:
> 
> 
> On 03/28/2018 08:51 PM, Dongli Zhang wrote:
>> The "BUG_ON(!frag_iter)" in function xenvif_rx_next_chunk() is triggered if
>> the received sk_buff is malformed, that is, when the sk_buff has pattern
>> (skb->data_len && !skb_shinfo(skb)->nr_frags). Below is a sample call
>> stack:
>>
>> ...
> 
> 
>>
>> The issue is hit by xen-netback when there is bug with other networking
>> interface (e.g., dom0 physical NIC), who has generated and forwarded
>> malformed sk_buff to dom0 vifX.Y. It is possible to reproduce the issue on
>> purpose with below sample code in a kernel module:
>>
>> skb->dev = dev; // dev of vifX.Y
>> skb->len = 386;
>> skb->data_len = 352;
>> skb->tail = 98;
>> skb->end = 384;
>> skb_shinfo(skb)->nr_frags = 0;
>> dev->netdev_ops->ndo_start_xmit(skb, dev);
>>
> 
> This would be a serious bug in the provider of such skb.

/nods

> 
> Are you sure you do not have instead an skb with a chain of skbs ?
> 
> (skb_shinfo(skb)->frag_list would be not NULL)

I am sure the skb_shinfo(skb)->frag_list is NULL.

> 
> Maybe your driver is wrongly advertising NETIF_F_FRAGLIST
> 
> commit 2167ca029c244901831 would be the bug origin then...

Unlike the new linux version (whose BUG_ON() does not panic the server), the
BUG_ON() in prior old kernel version would panic xen dom0 server and then people
would always blame xen paravirtual driver.

Indeed, xen-netback did not process the malformed sk_buff appropriately on rx
path. The issue is not hit with old dom0 kernel, when I am running the debug
module (as shown in below link) to generate a malformed sk_buff on purpose.

https://lists.xenproject.org/archives/html/xen-devel/2018-03/msg03176.html

Dongli Zhang


Re: [PATCH net V2] vhost: correctly remove wait queue during poll failure

2018-03-28 Thread Michael S. Tsirkin
On Tue, Mar 27, 2018 at 08:50:52PM +0800, Jason Wang wrote:
> We tried to remove vq poll from wait queue, but do not check whether
> or not it was in a list before. This will lead double free. Fixing
> this by switching to use vhost_poll_stop() which zeros poll->wqh after
> removing poll from waitqueue to make sure it won't be freed twice.
> 
> Cc: Darren Kenny 
> Reported-by: syzbot+c0272972b01b872e6...@syzkaller.appspotmail.com
> Fixes: 2b8b328b61c79 ("vhost_net: handle polling errors when setting backend")
> Signed-off-by: Jason Wang 

OK with this the only bug we have is where get user pages returns 0
(Reported-by: syzbot+6304bf97ef436580f...@syzkaller.appspotmail.com)



> ---
> Changes from V1:
> - tweak the commit log for to match the code
> ---
>  drivers/vhost/vhost.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 1b3e8d2d..5d5a9d9 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -212,8 +212,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file 
> *file)
>   if (mask)
>   vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
>   if (mask & EPOLLERR) {
> - if (poll->wqh)
> - remove_wait_queue(poll->wqh, &poll->wait);
> + vhost_poll_stop(poll);
>   ret = -EINVAL;
>   }
>  
> -- 
> 2.7.4


[PATCH 1/1] hugetlbfs: fix bug in pgoff overflow checking

2018-03-28 Thread Mike Kravetz
This is a fix for a regression in 32 bit kernels caused by an
invalid check for pgoff overflow in hugetlbfs mmap setup.  The
check incorrectly specified that the size of a loff_t was the
same as the size of a long.  The regression prevents mapping
hugetlbfs files at offset greater than 4GB on 32 bit kernels.

Fix the check by using sizeof(loff_t) to get size.  In addition,
make sure pgoff + length can be represented by a signed long
huge page offset.  This check is only necessary on 32 bit kernels.

Fixes: 63489f8e8211 ("hugetlbfs: check for pgoff value overflow")
Cc: 
Reported-by: Dan Rue 
Signed-off-by: Mike Kravetz 
---
 fs/hugetlbfs/inode.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index b9a254dcc0e7..8450a1d75dfa 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -116,7 +116,8 @@ static void huge_pagevec_release(struct pagevec *pvec)
  * bit into account.
  */
 #define PGOFF_LOFFT_MAX \
-   (((1UL << (PAGE_SHIFT + 1)) - 1) <<  (BITS_PER_LONG - (PAGE_SHIFT + 1)))
+   (((1UL << (PAGE_SHIFT + 1)) - 1) << \
+((sizeof(loff_t) * BITS_PER_BYTE) - (PAGE_SHIFT + 1)))
 
 static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
@@ -138,21 +139,32 @@ static int hugetlbfs_file_mmap(struct file *file, struct 
vm_area_struct *vma)
 
/*
 * page based offset in vm_pgoff could be sufficiently large to
-* overflow a (l)off_t when converted to byte offset.
+* overflow a loff_t when converted to byte offset.
 */
-   if (vma->vm_pgoff & PGOFF_LOFFT_MAX)
+   if ((loff_t)vma->vm_pgoff & (loff_t)PGOFF_LOFFT_MAX)
return -EINVAL;
 
-   /* must be huge page aligned */
+   /* vm_pgoff must be huge page aligned */
if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT))
return -EINVAL;
 
+   /*
+* Compute file offset of the end of this mapping
+*/
vma_len = (loff_t)(vma->vm_end - vma->vm_start);
len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
-   /* check for overflow */
+
+   /* Check to ensure this did not overflow loff_t */
if (len < vma_len)
return -EINVAL;
 
+   /*
+* On 32 bit systems, this check is necessary to ensure the last page
+* of mapping can be represented as a signed long huge page index.
+*/
+   if ((len >> huge_page_shift(h)) > LONG_MAX)
+   return -EINVAL;
+
inode_lock(inode);
file_accessed(file);
 
-- 
2.13.6



[PATCH 0/1] fix regression in hugetlbfs overflow checking

2018-03-28 Thread Mike Kravetz
Commit 63489f8e8211 ("hugetlbfs: check for pgoff value overflow")
introduced a regression in 32 bit kernels.  When creating the mask
to check vm_pgoff, it incorrectly specified that the size of a loff_t
was the size of a long.  This prevents mapping hugetlbfs files at
offsets greater than 4GB on 32 bit kernels.

The above is in the commit message.  63489f8e8211 has been sent upstream
and to stable, so cc'ing stable here as well.

I would appreciate some more eyes on this code.  There have been several
fixes and we keep running into issues.

Mike Kravetz (1):
  hugetlbfs: fix bug in pgoff overflow checking

 fs/hugetlbfs/inode.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

-- 
2.13.6



Re: [PATCH v3] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Greg Kroah-Hartman
On Thu, Mar 29, 2018 at 11:42:04AM +0900, Minchan Kim wrote:
> 
> On Thu, Mar 29, 2018 at 11:37:12AM +0900, Minchan Kim wrote:
> > binder_update_page_range needs down_write of mmap_sem because
> > vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
> > it is set. However, when I profile binder working, it seems
> > every binder buffers should be mapped in advance by binder_mmap.
> > It means we could set VM_MIXEDMAP in bider_mmap time which is
> > already hold a mmap_sem as down_write so binder_update_page_range
> > doesn't need to hold a mmap_sem as down_write.
> > 
> > Android suffers from mmap_sem contention so let's reduce mmap_sem
> > down_write.
> > 
> > Cc: Todd Kjos 
> > Cc: Greg Kroah-Hartman 
> > Cc: Arve Hjønnevåg 
> > Reviewed-by: Martijn Coenen 
> > Signed-off-by: Minchan Kim 
> 
> Sent wrong version. Sorry for that. Please ignore this and take it.
> 
> >From 480e992d4a650fb98e1397114d75dea7af8e6d0c Mon Sep 17 00:00:00 2001
> From: Minchan Kim 
> Date: Wed, 28 Mar 2018 11:32:42 +0900
> Subject: [PATCH v3] ANDROID: binder: change down_write to down_read
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit



I really don't want to hand-edit patches, please just send v4.

thanks,

greg k-h


Re: [PATCH v2 1/1] xen-netback: process malformed sk_buff correctly to avoid BUG_ON()

2018-03-28 Thread Eric Dumazet


On 03/28/2018 08:51 PM, Dongli Zhang wrote:
> The "BUG_ON(!frag_iter)" in function xenvif_rx_next_chunk() is triggered if
> the received sk_buff is malformed, that is, when the sk_buff has pattern
> (skb->data_len && !skb_shinfo(skb)->nr_frags). Below is a sample call
> stack:
> 
>...


> 
> The issue is hit by xen-netback when there is bug with other networking
> interface (e.g., dom0 physical NIC), who has generated and forwarded
> malformed sk_buff to dom0 vifX.Y. It is possible to reproduce the issue on
> purpose with below sample code in a kernel module:
> 
> skb->dev = dev; // dev of vifX.Y
> skb->len = 386;
> skb->data_len = 352;
> skb->tail = 98;
> skb->end = 384;
> skb_shinfo(skb)->nr_frags = 0;
> dev->netdev_ops->ndo_start_xmit(skb, dev);
>

This would be a serious bug in the provider of such skb.

Are you sure you do not have instead an skb with a chain of skbs ?

(skb_shinfo(skb)->frag_list would be not NULL)

Maybe your driver is wrongly advertising NETIF_F_FRAGLIST

commit 2167ca029c244901831 would be the bug origin then...





[PATCH 3/5] powerpc/cache: add cache flush operation for various e500

2018-03-28 Thread Ran Wang
Various e500 core have different cache architecture, so they
need different cache flush operations. Therefore, add a callback
function cpu_flush_caches to the struct cpu_spec. The cache flush
operation for the specific kind of e500 is selected at init time.
The callback function will flush all caches in the current cpu.

Signed-off-by: Chenhui Zhao 
Reviewed-by: Yang Li 
Reviewed-by: Jose Rivera 
Signed-off-by: Ran Wang 
---
 arch/powerpc/include/asm/cputable.h   |   12 
 arch/powerpc/kernel/asm-offsets.c |3 +
 arch/powerpc/kernel/cpu_setup_fsl_booke.S |   81 +
 arch/powerpc/kernel/cputable.c|4 ++
 4 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/cputable.h 
b/arch/powerpc/include/asm/cputable.h
index a2c5c95..364e6cf 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -44,6 +44,14 @@ enum powerpc_pmc_type {
 extern int machine_check_e500(struct pt_regs *regs);
 extern int machine_check_e200(struct pt_regs *regs);
 extern int machine_check_47x(struct pt_regs *regs);
+
+#if defined(CONFIG_E500) || defined(CONFIG_PPC_E500MC)
+extern void __flush_caches_e500v2(void);
+extern void __flush_caches_e500mc(void);
+extern void __flush_caches_e5500(void);
+extern void __flush_caches_e6500(void);
+#endif
+
 int machine_check_8xx(struct pt_regs *regs);
 
 extern void cpu_down_flush_e500v2(void);
@@ -70,6 +78,10 @@ struct cpu_spec {
/* flush caches inside the current cpu */
void (*cpu_down_flush)(void);
 
+#if defined(CONFIG_E500) || defined(CONFIG_PPC_E500MC)
+   /* flush caches of the cpu which is running the function */
+   void (*cpu_flush_caches)(void);
+#endif
/* number of performance monitor counters */
unsigned intnum_pmcs;
enum powerpc_pmc_type pmc_type;
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index ea5eb91..cb4b869 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -351,6 +351,9 @@ int main(void)
OFFSET(CPU_SPEC_FEATURES, cpu_spec, cpu_features);
OFFSET(CPU_SPEC_SETUP, cpu_spec, cpu_setup);
OFFSET(CPU_SPEC_RESTORE, cpu_spec, cpu_restore);
+#if defined(CONFIG_E500) || defined(CONFIG_PPC_E500MC)
+   OFFSET(CPU_FLUSH_CACHES, cpu_spec, cpu_flush_caches);
+#endif
 
OFFSET(pbe_address, pbe, address);
OFFSET(pbe_orig_address, pbe, orig_address);
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S 
b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 462aed9..e94eb41 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -345,3 +345,84 @@ _GLOBAL(cpu_down_flush_e5500)
 /* L1 Data Cache of e6500 contains no modified data, no flush is required */
 _GLOBAL(cpu_down_flush_e6500)
blr
+
+_GLOBAL(__flush_caches_e500v2)
+   mflr r0
+   bl  flush_dcache_L1
+   mtlr r0
+   blr
+
+_GLOBAL(__flush_caches_e500mc)
+_GLOBAL(__flush_caches_e5500)
+   mflr r0
+   bl  flush_dcache_L1
+   bl  flush_backside_L2_cache
+   mtlr r0
+   blr
+
+/* L1 Data Cache of e6500 contains no modified data, no flush is required */
+_GLOBAL(__flush_caches_e6500)
+   blr
+
+   /* r3 = virtual address of L2 controller, WIMG = 01xx */
+_GLOBAL(flush_disable_L2)
+   /* It's a write-through cache, so only invalidation is needed. */
+   mbar
+   isync
+   lwz r4, 0(r3)
+   li  r5, 1
+   rlwimi  r4, r5, 30, 0xc000
+   stw r4, 0(r3)
+
+   /* Wait for the invalidate to finish */
+1: lwz r4, 0(r3)
+   andis.  r4, r4, 0x4000
+   bne 1b
+   mbar
+
+   blr
+
+   /* r3 = virtual address of L2 controller, WIMG = 01xx */
+_GLOBAL(invalidate_enable_L2)
+   mbar
+   isync
+   lwz r4, 0(r3)
+   li  r5, 3
+   rlwimi  r4, r5, 30, 0xc000
+   stw r4, 0(r3)
+
+   /* Wait for the invalidate to finish */
+1: lwz r4, 0(r3)
+   andis.  r4, r4, 0x4000
+   bne 1b
+   mbar
+
+   blr
+
+/* Flush L1 d-cache, invalidate and disable d-cache and i-cache */
+_GLOBAL(__flush_disable_L1)
+   mflrr10
+   bl  flush_dcache_L1 /* Flush L1 d-cache */
+   mtlrr10
+
+   mfspr   r4, SPRN_L1CSR0 /* Invalidate and disable d-cache */
+   li  r5, 2
+   rlwimi  r4, r5, 0, 3
+
+   msync
+   isync
+   mtspr   SPRN_L1CSR0, r4
+   isync
+
+1: mfspr   r4, SPRN_L1CSR0 /* Wait for the invalidate to finish */
+   andi.   r4, r4, 2
+   bne 1b
+
+   mfspr   r4, SPRN_L1CSR1 /* Invalidate and disable i-cache */
+   li  r5, 2
+   rlwimi  r4, r5, 0, 3
+
+   mtspr   SPRN_L1CSR1, r4
+   isync
+
+   blr
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index c40a9fc..eec3ca7 100644
--- a/arch/powerpc/kernel/cputabl

[PATCH 1/5] powerpc/pm: Fix suspend=n in menuconfig for e500mc platforms.

2018-03-28 Thread Ran Wang
Also, unselect FSL_PMC which is for older platfroms instead.

Signed-off-by: Ran Wang 
---
 arch/powerpc/Kconfig |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 73ce5dd..ed60c83 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -316,7 +316,7 @@ config ARCH_HIBERNATION_POSSIBLE
 config ARCH_SUSPEND_POSSIBLE
def_bool y
depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_83xx || \
-  (PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \
+  FSL_SOC_BOOKE || PPC_86xx || PPC_PSERIES \
   || 44x || 40x
 
 config PPC_DCR_NATIVE
@@ -940,8 +940,6 @@ config FSL_PCI
 
 config FSL_PMC
bool
-   default y
-   depends on SUSPEND && (PPC_85xx || PPC_86xx)
help
  Freescale MPC85xx/MPC86xx power management controller support
  (suspend/resume). For MPC83xx see platforms/83xx/suspend.c
-- 
1.7.1



[PATCH 4/5] powerpc/pm: add sleep and deep sleep on QorIQ SoCs

2018-03-28 Thread Ran Wang
In sleep mode, the clocks of CPU core and unused IP blocks are turned
off (IP blocks allowed to wake up system will running).

Some QorIQ SoCs like MPC8536, P1022 and T104x, have deep sleep PM mode
in addtion to the sleep PM mode. While in deep sleep mode,
additionally, the power supply is removed from CPU core and most IP
blocks. Only the blocks needed to wake up the chip out of deep sleep
are ON.

This feature supports 32-bit and 36-bit address space.

The sleep mode is equal to the Standby state in Linux. The deep sleep
mode is equal to the Suspend-to-RAM state of Linux Power Management.
Command to enter sleep mode.
echo standby > /sys/power/state
Command to enter deep sleep mode.
echo mem > /sys/power/state

Signed-off-by: Dave Liu 
Signed-off-by: Li Yang 
Signed-off-by: Jin Qing 
Signed-off-by: Jerry Huang 
Signed-off-by: Ramneek Mehresh 
Signed-off-by: Zhao Chenhui 
Signed-off-by: Wang Dongsheng 
Signed-off-by: Tang Yuantian 
Signed-off-by: Xie Xiaobo 
Signed-off-by: Zhao Qiang 
Signed-off-by: Shengzhou Liu 
Signed-off-by: Ran Wang 
---
 arch/powerpc/include/asm/cacheflush.h |7 +
 arch/powerpc/include/asm/fsl_pm.h |   31 +
 arch/powerpc/kernel/Makefile  |1 +
 arch/powerpc/kernel/fsl_booke_entry_mapping.S |   10 +
 arch/powerpc/kernel/fsl_pm.c  |   49 +
 arch/powerpc/kernel/head_64.S |2 +-
 arch/powerpc/platforms/85xx/Kconfig   |6 +
 arch/powerpc/platforms/85xx/Makefile  |2 +
 arch/powerpc/platforms/85xx/deepsleep.c   |  349 
 arch/powerpc/platforms/85xx/qoriq_pm.c|  223 +
 arch/powerpc/platforms/85xx/sleep.S   | 1192 +
 arch/powerpc/platforms/86xx/Kconfig   |1 +
 arch/powerpc/sysdev/fsl_pmc.c |  176 -
 arch/powerpc/sysdev/fsl_soc.c |   31 +
 arch/powerpc/sysdev/fsl_soc.h |   18 +
 15 files changed, 2078 insertions(+), 20 deletions(-)
 create mode 100644 arch/powerpc/kernel/fsl_pm.c
 create mode 100644 arch/powerpc/platforms/85xx/deepsleep.c
 create mode 100644 arch/powerpc/platforms/85xx/qoriq_pm.c
 create mode 100644 arch/powerpc/platforms/85xx/sleep.S

diff --git a/arch/powerpc/include/asm/cacheflush.h 
b/arch/powerpc/include/asm/cacheflush.h
index b77f036..a5411af 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -31,6 +31,13 @@
 #define flush_dcache_mmap_lock(mapping)do { } while (0)
 #define flush_dcache_mmap_unlock(mapping)  do { } while (0)
 
+extern void __flush_disable_L1(void);
+#ifdef CONFIG_FSL_SOC_BOOKE
+extern void flush_dcache_L1(void);
+#else
+#define flush_dcache_L1()  do { } while (0)
+#endif
+
 extern void flush_icache_range(unsigned long, unsigned long);
 extern void flush_icache_user_range(struct vm_area_struct *vma,
struct page *page, unsigned long addr,
diff --git a/arch/powerpc/include/asm/fsl_pm.h 
b/arch/powerpc/include/asm/fsl_pm.h
index 47df55e..510e5d2 100644
--- a/arch/powerpc/include/asm/fsl_pm.h
+++ b/arch/powerpc/include/asm/fsl_pm.h
@@ -11,6 +11,9 @@
 #ifndef __PPC_FSL_PM_H
 #define __PPC_FSL_PM_H
 
+#ifndef __ASSEMBLY__
+#include 
+
 #define E500_PM_PH10   1
 #define E500_PM_PH15   2
 #define E500_PM_PH20   3
@@ -46,6 +49,34 @@ struct fsl_pm_ops {
 
 extern const struct fsl_pm_ops *qoriq_pm_ops;
 
+struct fsm_reg_vals {
+   u32 offset;
+   u32 value;
+};
+
+void fsl_fsm_setup(void __iomem *base, struct fsm_reg_vals *val);
+void fsl_epu_setup_default(void __iomem *epu_base);
+void fsl_npc_setup_default(void __iomem *npc_base);
+void fsl_fsm_clean(void __iomem *base, struct fsm_reg_vals *val);
+void fsl_epu_clean_default(void __iomem *epu_base);
+
+extern int fsl_dp_iomap(void);
+extern void fsl_dp_iounmap(void);
+
+extern int fsl_enter_epu_deepsleep(void);
+extern void fsl_dp_enter_low(void __iomem *ccsr_base, void __iomem *dcsr_base,
+void __iomem *pld_base, int pld_flag);
+extern void fsl_booke_deep_sleep_resume(void);
+
 int __init fsl_rcpm_init(void);
 
+void set_pm_suspend_state(suspend_state_t state);
+suspend_state_t pm_suspend_state(void);
+
+void fsl_set_power_except(struct device *dev, int on);
+#endif /* __ASSEMBLY__ */
+
+#define T1040QDS_TETRA_FLAG1
+#define T104xRDB_CPLD_FLAG 2
+
 #endif /* __PPC_FSL_PM_H */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 1b6bc7f..f191269 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_EEH)  += eeh.o eeh_pe.o eeh_dev.o 
eeh_cache.o \
 obj-$(CONFIG_GENERIC_TBSYNC)   += smp-tbsync.o
 obj-$(CONFIG_CRASH_DUMP)   += crash_dump.o
 obj-$(CONFIG_FA_DUMP)  += fadump.o
+obj-$(CONFIG_FSL_SOC)  += fsl_pm.o
 ifeq ($(CONFIG_PPC32),y)
 obj-$(CONFIG_E500) += idle_e500.o
 endif
diff --git a/arch/

[PATCH 5/5] powerpc:dts:pm: add power management node

2018-03-28 Thread Ran Wang
Enable Power Management feature on device tree, including MPC8536,
MPC8544, MPC8548, MPC8572, P1010, P1020, P1021, P1022, P2020, P2041,
P3041, T104X, T1024.

Signed-off-by: Zhao Chenhui 
Signed-off-by: Ran Wang 
---
 arch/powerpc/boot/dts/fsl/mpc8536si-post.dtsi |   14 ++-
 arch/powerpc/boot/dts/fsl/mpc8544si-post.dtsi |2 +
 arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi |2 +
 arch/powerpc/boot/dts/fsl/mpc8572si-post.dtsi |2 +
 arch/powerpc/boot/dts/fsl/p1010si-post.dtsi   |8 
 arch/powerpc/boot/dts/fsl/p1020si-post.dtsi   |5 +++
 arch/powerpc/boot/dts/fsl/p1021si-post.dtsi   |5 +++
 arch/powerpc/boot/dts/fsl/p1022si-post.dtsi   |9 +++--
 arch/powerpc/boot/dts/fsl/p2020si-post.dtsi   |   14 +++
 arch/powerpc/boot/dts/fsl/pq3-power.dtsi  |   48 +
 arch/powerpc/boot/dts/fsl/t1024rdb.dts|2 +-
 arch/powerpc/boot/dts/fsl/t1040rdb.dts|2 +-
 arch/powerpc/boot/dts/fsl/t1042rdb.dts|2 +-
 arch/powerpc/boot/dts/fsl/t1042rdb_pi.dts |2 +-
 14 files changed, 108 insertions(+), 9 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/fsl/pq3-power.dtsi

diff --git a/arch/powerpc/boot/dts/fsl/mpc8536si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/mpc8536si-post.dtsi
index 4193570..fba40a1 100644
--- a/arch/powerpc/boot/dts/fsl/mpc8536si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/mpc8536si-post.dtsi
@@ -199,6 +199,10 @@
 
 /include/ "pq3-dma-0.dtsi"
 /include/ "pq3-etsec1-0.dtsi"
+   enet0: ethernet@24000 {
+   fsl,wake-on-filer;
+   fsl,pmc-handle = <&etsec1_clk>;
+   };
 /include/ "pq3-etsec1-timer-0.dtsi"
 
usb@22000 {
@@ -222,9 +226,10 @@
};
 
 /include/ "pq3-etsec1-2.dtsi"
-
-   ethernet@26000 {
+   enet2: ethernet@26000 {
cell-index = <1>;
+   fsl,wake-on-filer;
+   fsl,pmc-handle = <&etsec3_clk>;
};
 
usb@2b000 {
@@ -249,4 +254,9 @@
reg = <0xe 0x1000>;
fsl,has-rstcr;
};
+
+/include/ "pq3-power.dtsi"
+   power@e0070 {
+   compatible = "fsl,mpc8536-pmc", "fsl,mpc8548-pmc";
+   };
 };
diff --git a/arch/powerpc/boot/dts/fsl/mpc8544si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/mpc8544si-post.dtsi
index b68eb11..ea7416a 100644
--- a/arch/powerpc/boot/dts/fsl/mpc8544si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/mpc8544si-post.dtsi
@@ -188,4 +188,6 @@
reg = <0xe 0x1000>;
fsl,has-rstcr;
};
+
+/include/ "pq3-power.dtsi"
 };
diff --git a/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi
index 579d76c..dddb737 100644
--- a/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi
@@ -156,4 +156,6 @@
reg = <0xe 0x1000>;
fsl,has-rstcr;
};
+
+/include/ "pq3-power.dtsi"
 };
diff --git a/arch/powerpc/boot/dts/fsl/mpc8572si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/mpc8572si-post.dtsi
index 49294cf..40a6cff 100644
--- a/arch/powerpc/boot/dts/fsl/mpc8572si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/mpc8572si-post.dtsi
@@ -193,4 +193,6 @@
reg = <0xe 0x1000>;
fsl,has-rstcr;
};
+
+/include/ "pq3-power.dtsi"
 };
diff --git a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
index 1b4aafc..47b62a8 100644
--- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi
@@ -173,6 +173,8 @@
 
 /include/ "pq3-etsec2-0.dtsi"
enet0: ethernet@b {
+   fsl,pmc-handle = <&etsec1_clk>;
+
queue-group@b {
fsl,rx-bit-map = <0xff>;
fsl,tx-bit-map = <0xff>;
@@ -181,6 +183,8 @@
 
 /include/ "pq3-etsec2-1.dtsi"
enet1: ethernet@b1000 {
+   fsl,pmc-handle = <&etsec2_clk>;
+
queue-group@b1000 {
fsl,rx-bit-map = <0xff>;
fsl,tx-bit-map = <0xff>;
@@ -189,6 +193,8 @@
 
 /include/ "pq3-etsec2-2.dtsi"
enet2: ethernet@b2000 {
+   fsl,pmc-handle = <&etsec3_clk>;
+
queue-group@b2000 {
fsl,rx-bit-map = <0xff>;
fsl,tx-bit-map = <0xff>;
@@ -201,4 +207,6 @@
reg = <0xe 0x1000>;
fsl,has-rstcr;
};
+
+/include/ "pq3-power.dtsi"
 };
diff --git a/arch/powerpc/boot/dts/fsl/p1020si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p1020si-post.dtsi
index 642dc3a..cc4c746 100644
--- a/arch/powerpc/boot/dts/fsl/p1020si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p1020si-post.dtsi
@@ -163,14 +163,17 @@
 
 /include/ "pq3-etsec2-0.dtsi"
enet0: enet0_grp2: ethernet@b {
+   fsl,pmc-handle = <&etsec1_clk>;
};
 
 /include/ "pq3-etsec2-1.dtsi"
enet1: enet1_grp2: ethernet@b1000 {
+   fsl,pmc-handle = <

[PATCH 2/5] drivers/soc/fsl: add EPU FSM configuration for deep sleep

2018-03-28 Thread Ran Wang
In the last stage of deep sleep, software will trigger a Finite
State Machine (FSM) to control the hardware procedure, such a
board isolation, killing PLLs, removing power, and so on.

When the system is waked up by an interrupt, the FSM controls
the hardware to complete the early resume procedure.

This patch configure the EPU FSM preparing for deep sleep.

Signed-off-by: Hongbo Zhang 
Signed-off-by: Chenhui Zhao 
Signed-off-by: Ran Wang 
---
 drivers/soc/fsl/Kconfig |7 +
 drivers/soc/fsl/Makefile|1 +
 drivers/soc/fsl/sleep_fsm.c |  279 +++
 drivers/soc/fsl/sleep_fsm.h |  130 
 4 files changed, 417 insertions(+), 0 deletions(-)
 create mode 100644 drivers/soc/fsl/sleep_fsm.c
 create mode 100644 drivers/soc/fsl/sleep_fsm.h

diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
index 7a9fb9b..4222bd5 100644
--- a/drivers/soc/fsl/Kconfig
+++ b/drivers/soc/fsl/Kconfig
@@ -16,3 +16,10 @@ config FSL_GUTS
  Initially only reading SVR and registering soc device are supported.
  Other guts accesses, such as reading RCW, should eventually be moved
  into this driver as well.
+
+config FSL_SLEEP_FSM
+   bool
+   help
+ This driver configures a hardware FSM (Finite State Machine) for deep 
sleep.
+ The FSM is used to finish clean-ups at the last stage of system 
entering deep
+ sleep, and also wakes up system when a wake up event happens.
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
index 44b3beb..28c38c3 100644
--- a/drivers/soc/fsl/Makefile
+++ b/drivers/soc/fsl/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA) += qbman/
 obj-$(CONFIG_QUICC_ENGINE) += qe/
 obj-$(CONFIG_CPM)  += qe/
 obj-$(CONFIG_FSL_GUTS) += guts.o
+obj-$(CONFIG_FSL_SLEEP_FSM)+= sleep_fsm.o
diff --git a/drivers/soc/fsl/sleep_fsm.c b/drivers/soc/fsl/sleep_fsm.c
new file mode 100644
index 000..378857f
--- /dev/null
+++ b/drivers/soc/fsl/sleep_fsm.c
@@ -0,0 +1,279 @@
+/*
+ * deep sleep FSM (finite-state machine) configuration
+ *
+ * Copyright 2018 NXP
+ *
+ * Author: Hongbo Zhang 
+ * Chenhui Zhao 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ *  names of any contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include "sleep_fsm.h"
+/*
+ * These values are from chip's reference manual. For example,
+ * the values for T1040 can be found in "8.4.3.8 Programming
+ * supporting deep sleep mode" of Chapter 8 "Run Control and
+ * Power Management (RCPM)".
+ * The default value can be applied to T104x, LS1021.
+ */
+struct fsm_reg_vals epu_default_val[] = {
+   /* EPGCR (Event Processor Global Control Register) */
+   {EPGCR, 0},
+   /* EPECR (Event Processor Event Control Registers) */
+   {EPECR0 + EPECR_STRIDE * 0, 0},
+   {EPECR0 + EPECR_STRIDE * 1, 0},
+   {EPECR0 + EPECR_STRIDE * 2, 0xF0004004},
+   {EPECR0 + EPECR_STRIDE * 3, 0x8084},
+   {EPECR0 + EPECR_STRIDE * 4, 0x2084},
+   {EPECR0 + EPECR_STRIDE * 5, 0x0804},
+   {EPECR0 + EPECR_STRIDE * 6, 0x8084},
+   {EPECR0 + EPECR_STRIDE * 7, 0x8084},
+   {EPECR0 + EPECR_STRIDE * 8, 0x6084},
+   

[PATCH v2 1/1] xen-netback: process malformed sk_buff correctly to avoid BUG_ON()

2018-03-28 Thread Dongli Zhang
The "BUG_ON(!frag_iter)" in function xenvif_rx_next_chunk() is triggered if
the received sk_buff is malformed, that is, when the sk_buff has pattern
(skb->data_len && !skb_shinfo(skb)->nr_frags). Below is a sample call
stack:

[  438.652658] [ cut here ]
[  438.652660] kernel BUG at drivers/net/xen-netback/rx.c:325!
[  438.652714] invalid opcode:  [#1] SMP NOPTI
[  438.652813] CPU: 0 PID: 2492 Comm: vif1.0-q0-guest Tainted: G   O
 4.16.0-rc6+ #1
[  438.652896] RIP: e030:xenvif_rx_skb+0x3c2/0x5e0 [xen_netback]
[  438.652926] RSP: e02b:c90040877dc8 EFLAGS: 00010246
[  438.652956] RAX: 0160 RBX: 0022 RCX: 0001
[  438.652993] RDX: c900402890d0 RSI:  RDI: c90040889000
[  438.653029] RBP: 88002b460040 R08: c90040877de0 R09: 0100
[  438.653065] R10: 7ff0 R11: 0002 R12: c90040889000
[  438.653100] R13: 8000 R14: 0022 R15: 8000
[  438.653149] FS:  7f15603778c0() GS:88003040() 
knlGS:
[  438.653188] CS:  e033 DS:  ES:  CR0: 80050033
[  438.653219] CR2: 01832a08 CR3: 29c12000 CR4: 00042660
[  438.653262] Call Trace:
[  438.653284]  ? xen_hypercall_event_channel_op+0xa/0x20
[  438.653313]  xenvif_rx_action+0x41/0x80 [xen_netback]
[  438.653341]  xenvif_kthread_guest_rx+0xb2/0x2a8 [xen_netback]
[  438.653374]  ? __schedule+0x352/0x700
[  438.653398]  ? wait_woken+0x80/0x80
[  438.653421]  kthread+0xf3/0x130
[  438.653442]  ? xenvif_rx_action+0x80/0x80 [xen_netback]
[  438.653470]  ? kthread_destroy_worker+0x40/0x40
[  438.653497]  ret_from_fork+0x35/0x40

The issue is hit by xen-netback when there is bug with other networking
interface (e.g., dom0 physical NIC), who has generated and forwarded
malformed sk_buff to dom0 vifX.Y. It is possible to reproduce the issue on
purpose with below sample code in a kernel module:

skb->dev = dev; // dev of vifX.Y
skb->len = 386;
skb->data_len = 352;
skb->tail = 98;
skb->end = 384;
skb_shinfo(skb)->nr_frags = 0;
dev->netdev_ops->ndo_start_xmit(skb, dev);

This patch stops processing sk_buff immediately if it is detected as
malformed, that is, pkt->frag_iter is NULL but there is still remaining
pkt->remaining_len.

Signed-off-by: Dongli Zhang 

---
Changed since v1:
  * return XEN_NETIF_RSP_ERROR in response to netfront

 drivers/net/xen-netback/rx.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c
index b1cf7c6..a3d8ee9 100644
--- a/drivers/net/xen-netback/rx.c
+++ b/drivers/net/xen-netback/rx.c
@@ -358,6 +358,7 @@ static void xenvif_rx_data_slot(struct xenvif_queue *queue,
 {
unsigned int offset = 0;
unsigned int flags;
+   bool err = false;
 
do {
size_t len;
@@ -369,6 +370,15 @@ static void xenvif_rx_data_slot(struct xenvif_queue *queue,
offset += len;
pkt->remaining_len -= len;
 
+   if (unlikely(!pkt->frag_iter && pkt->remaining_len)) {
+   pkt->remaining_len = 0;
+   pkt->extra_count = 0;
+   err = true;
+   pr_err_ratelimited("malformed sk_buff at %s\n",
+  queue->name);
+   break;
+   }
+
} while (offset < XEN_PAGE_SIZE && pkt->remaining_len > 0);
 
if (pkt->remaining_len > 0)
@@ -392,7 +402,7 @@ static void xenvif_rx_data_slot(struct xenvif_queue *queue,
rsp->offset = 0;
rsp->flags = flags;
rsp->id = req->id;
-   rsp->status = (s16)offset;
+   rsp->status = likely(!err) ? (s16)offset : XEN_NETIF_RSP_ERROR;
 }
 
 static void xenvif_rx_extra_slot(struct xenvif_queue *queue,
-- 
2.7.4



Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Jens Axboe
On 3/28/18 9:13 PM, Zephaniah E. Loss-Cutler-Hull wrote:
> On 03/28/2018 06:02 PM, Jens Axboe wrote:
>> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>>> I am not subscribed to any of the lists on the To list here, please CC
>>> me on any replies.
>>>
>>> I am encountering a fairly consistent crash anywhere from 15 minutes to
>>> 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
>>> The crash looks like:
>>>
> 
>>>
>>> Looking through the code, I'd guess that this is dying inside
>>> blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
>>> is pointing at.
>>
>> Leaving the whole thing here for Paolo - it's crashing off insertion of
>> a request coming out of SG_IO. Don't think we've seen this BFQ failure
>> case before.
>>
>> You can mitigate this by switching the scsi-mq devices to mq-deadline
>> instead.
>>
> 
> I'm thinking that I should also be able to mitigate it by disabling
> CONFIG_DEBUG_BLK_CGROUP.
> 
> That should remove that entire chunk of code.
> 
> Of course, that won't help if this is actually a symptom of a bigger
> problem.

Yes, it's not a given that it will fully mask the issue at hand. But
turning off BFQ has a much higher chance of working for you.

This time actually CC'ing Paolo.


-- 
Jens Axboe



Re: General protection fault with use_blk_mq=1.

2018-03-28 Thread Zephaniah E. Loss-Cutler-Hull
On 03/28/2018 06:02 PM, Jens Axboe wrote:
> On 3/28/18 5:03 PM, Zephaniah E. Loss-Cutler-Hull wrote:
>> I am not subscribed to any of the lists on the To list here, please CC
>> me on any replies.
>>
>> I am encountering a fairly consistent crash anywhere from 15 minutes to
>> 12 hours after boot with scsi_mod.use_blk_mq=1 dm_mod.use_blk_mq=1> 
>> The crash looks like:
>>

>>
>> Looking through the code, I'd guess that this is dying inside
>> blkg_rwstat_add, which calls percpu_counter_add_batch, which is what RIP
>> is pointing at.
> 
> Leaving the whole thing here for Paolo - it's crashing off insertion of
> a request coming out of SG_IO. Don't think we've seen this BFQ failure
> case before.
> 
> You can mitigate this by switching the scsi-mq devices to mq-deadline
> instead.
> 

I'm thinking that I should also be able to mitigate it by disabling
CONFIG_DEBUG_BLK_CGROUP.

That should remove that entire chunk of code.

Of course, that won't help if this is actually a symptom of a bigger
problem.

Regards,
Zephaniah E. Loss-Cutler-Hull.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4 2/2] dt-bindings: usb: rt1711h device tree binding document

2018-03-28 Thread Rob Herring
On Tue, Mar 27, 2018 at 9:30 AM, 李書帆  wrote:
> Hi Rob,
>
> 2018-03-27 6:23 GMT+08:00 Rob Herring :
>> On Tue, Mar 20, 2018 at 05:15:04PM +0800, ShuFan Lee wrote:
>>> From: ShuFan Lee 
>>>
>>> Add device tree binding document for Richtek RT1711H Type-C chip driver
>>>
>>> Signed-off-by: ShuFan Lee 
>>> ---
>>>  .../devicetree/bindings/usb/richtek,rt1711h.txt| 30 
>>> ++
>>>  1 file changed, 30 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/usb/richtek,rt1711h.txt
>>>
>>>  changelogs between v2 & v3
>>>  - add dt-bindings for rt1711h typec driver
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt 
>>> b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt
>>> new file mode 100644
>>> index ..7da4dac78ea7
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/usb/richtek,rt1711h.txt
>>> @@ -0,0 +1,30 @@
>>> +Richtek RT1711H TypeC PD Controller.
>>> +
>>> +Required properties:
>>> + - compatible : Must be "richtek,rt1711h".
>>> + - reg : Must be 0x4e, it's slave address of RT1711H.
>>> +
>>> +Recommended properties :
>>> + - interrupt-parent : the phandle for the interrupt controller that
>>> +   provides interrupts for this device.
>>> + - interrupts :  where a is the interrupt number and b represents an
>>> +   encoding of the sense and level information for the interrupt.
>>> +
>>> +Optional properties :
>>> + - rt,intr-gpios : IRQ GPIO pin that's connected to RT1711H interrupt.
>>> +   if interrupt-parent & interrupts are not defined, use this property 
>>> instead.
>>
>> Drop this. You should simply always have interrupts property.
> Does this also imply that we could always assume client->irq is ready
> for request?

No idea.

> Therefore, there's no need to check client->irq and get gpio through
> rt,intr-gpios.

Looked to me like the gpio is just converted to an irq and used for
nothing else in the driver. If that's the case, then there's no point
in it being a gpio.

Rob


Re: [PATCH v8 22/24] mm: Speculative page fault handler return VMA

2018-03-28 Thread Ganesh Mahendran
2018-03-29 10:26 GMT+08:00 Ganesh Mahendran :
> Hi, Laurent
>
> 2018-02-16 23:25 GMT+08:00 Laurent Dufour :
>> When the speculative page fault handler is returning VM_RETRY, there is a
>> chance that VMA fetched without grabbing the mmap_sem can be reused by the
>> legacy page fault handler.  By reusing it, we avoid calling find_vma()
>> again. To achieve, that we must ensure that the VMA structure will not be
>> freed in our back. This is done by getting the reference on it (get_vma())
>> and by assuming that the caller will call the new service
>> can_reuse_spf_vma() once it has grabbed the mmap_sem.
>>
>> can_reuse_spf_vma() is first checking that the VMA is still in the RB tree
>> , and then that the VMA's boundaries matched the passed address and release
>> the reference on the VMA so that it can be freed if needed.
>>
>> In the case the VMA is freed, can_reuse_spf_vma() will have returned false
>> as the VMA is no more in the RB tree.
>
> when I applied this patch to arm64, I got a crash:
>
> [6.088296] Unable to handle kernel NULL pointer dereference at
> virtual address 
> [6.088307] pgd = ff9d67735000
> [6.088313] [] *pgd=0001795e3003,
> *pud=0001795e3003, *pmd=
> [6.088372] [ cut here ]
> [6.088377] Kernel BUG at ff9d64f65960 [verbose debug info unavailable]
> [6.088384] Internal error: Oops - BUG: 9645 [#1] PREEMPT SMP
> [6.088389] BUG: Bad rss-counter state mm:ffe8f3861040 idx:0 val:90
> [6.088393] BUG: Bad rss-counter state mm:ffe8f3861040 idx:1 val:58
> [6.088398] Modules linked in:
> [6.088408] CPU: 1 PID: 621 Comm: qseecomd Not tainted 4.4.78-perf+ #88
> [6.088413] Hardware name: Qualcomm Technologies, Inc. SDM 636
> PM660 + PM660L MTP E7S (DT)
> [6.088419] task: ffe8f6208000 ti: ffe872a8c000 task.ti:
> ffe872a8c000
> [6.088432] PC is at __rb_erase_color+0x108/0x240
> [6.088441] LR is at vma_interval_tree_remove+0x244/0x24c
> [6.088447] pc : [] lr : []
> pstate: 604001c5
> [6.088451] sp : ffe872a8fa50
> [6.088455] x29: ffe872a8fa50 x28: 0008
> [6.088462] x27: 0009 x26: 
> [6.088470] x25: ffe8f458fb80 x24: 00768ff87000
> [6.088477] x23:  x22: 
> [6.088484] x21: ff9d64d9be7c x20: ffe8f3ff0680
> [6.088492] x19: ffe8f212e9b0 x18: 0074
> [6.088499] x17: 0007 x16: 000e
> [6.088507] x15: ff9d65c88000 x14: 0001
> [6.088514] x13: 00192d76 x12: 00989680
> [6.088521] x11: 001f x10: ff9d661ded1b
> [6.088528] x9 : 007691759000 x8 : 07691759
> [6.088535] x7 :  x6 : ffe871ebada8
> [6.088541] x5 : 00e1 x4 : ffe8f212e958
> [6.088548] x3 : 00e9 x2 : 
> [6.088555] x1 : ffe8f212f110 x0 : ffe8f212e9b1
> [6.088564]
> [6.088564] PC: 0xff9d64f65920:
> [6.088568] 5920  f902 aa0103e0 aa1603e1 d63f02a0 aa1603e1
> f9400822 f9000662 f9000833
> [6.088590] 5940  143b f9400a61 f9400020 370002c0 f9400436
> b2400260 f9000a76 f9000433
> [6.088610] 5960  f90002c0 f9400260 f920 f9000261 f27ef400
> 54000100 f9400802 eb13005f
> [6.088630] 5980  5461 f9000801 1404 f9000401 1402
> f9000281 aa1303e0 d63f02a0
> [6.088652]
> [6.088652] LR: 0xff9d64d9c298:
> [6.088656] c298  f9403083 b483 f9400c63 eb03005f 9a832042
> f9403883 eb02007f 54a0
> [6.088676] c2b8  f9003882 f9402c82 927ef442 b5fffd22 b480
> f0e2 9139f042 94072561
> [6.088695] c2d8  a8c17bfd d65f03c0 a9bf7bfd 910003fd f943
> d280 b4e3 f9400c65
> [6.088715] c2f8  d1016063 eb0100bf 5463 aa0303e0 97fffef2
> a8c17bfd d65f03c0 a9bf7bfd
> [6.088735]
> [6.088735] SP: 0xffe872a8fa10:
> [6.088740] fa10  64d9c2d8 ff9d 72a8fa50 ffe8 64f65960
> ff9d 604001c5 
> [6.088759] fa30  71d67d70 ffe8 71c281e8 ffe8 
> 0080 64daa90c ff9d
> [6.088779] fa50  72a8fa90 ffe8 64d9c2d8 ff9d 71ebada8
> ffe8 f3ff0678 ffe8
> [6.088799] fa70  72a8fb80 ffe8   
>  0001 
> [6.088818]
> [6.088823] Process qseecomd (pid: 621, stack limit = 0xffe872a8c028)
> [6.088828] Call trace:
> [6.088834] Exception stack(0xffe872a8f860 to 0xffe872a8f990)
> [6.088841] f860: ffe8f212e9b0 0080
> 82b37000 ff9d64f65960
> [6.088848] f880: 604001c5 ff9d672c8680
> ff9d672c9c00 ff9d672d3ab7
> [6.088855] f8a0: ffe872a8f8f0 ff9d64db9bfc
>  ffe8f9402c00
> [6.088861] f8c0: ffe872a8c000 
> ffe872a8f920 ff9d64db9bfc
> [6.088867] f8e0:  ffe8f9402b00
> 

Re: [PATCH v2 04/21] kconfig: reference environments directly and remove 'option env=' syntax

2018-03-28 Thread Ulf Magnusson
On Thu, Mar 29, 2018 at 4:19 AM, Ulf Magnusson  wrote:
> I've been kinda busy lately, so that's why I disappeared.
>
> I'll try to go over this patchset in more detail over the weekend.
>
> On Tue, Mar 27, 2018 at 7:29 AM, Masahiro Yamada
>  wrote:
>> To get an environment value, Kconfig needs to define a symbol using
>> "option env=" syntax.  It is tedious to add a config entry for each
>> environment given that we need more environments such as 'CC', 'AS',
>> 'srctree' etc. to evaluate the compiler capability in Kconfig.
>>
>> Adding '$' to symbols is weird.  Kconfig can reference symbols directly
>> like this:
>>
>>   config FOO
>>   string
>>   default BAR
>>
>> So, I want to use the following syntax to get environment 'BAR' from
>> the system:
>>
>>   config FOO
>>   string
>>   default $BAR
>>
>> Looking at the code, the symbols prefixed with 'S' are expanded by:
>>  - conf_expand_value()
>>This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
>>  - expand_string_value()
>>This is used to expand strings in 'source' and 'mainmenu'
>>
>> All of them are fixed values independent of user configuration.  So,
>> this kind of syntax should be moved to simply take the environment.
>>
>> This change makes the code much cleaner.  The bounce symbols 'SRCARCH',
>> 'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.
>>
>> sym_init() hard-coding 'UNAME_RELEASE' is also gone.  'UNAME_RELEASE'
>> should be be given from the environment.
>>
>> ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
>> by 'default ARCH_DEFCONFIG'.
>>
>> The environments are expanding in the lexer; when '$' is encountered,
>> it is expanded, and resulted strings are pushed back to the input
>> stream.  This makes the implementation simpler.
>>
>> For example, the following code works.
>>
>> [Example code]
>>
>>   config TOOLCHAIN_LIST
>>   string
>>   default "My tools: CC=$CC, AS=$AS, CPP=$CPP"
>>
>> [Result]
>>
>>   $ make -s alldefconfig && tail -n 1 .config
>>   CONFIG_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"
>>
>> Signed-off-by: Masahiro Yamada 
>> ---
>>
>> I tested all 'make *config' for arch architectures.
>> I confirmed this commit still produced the same result
>> (by my kconfig test tool).
>>
>>
>> Changes in v2:
>>   - Move the string expansion to the lexer phase.
>>   - Split environment helpers to env.c
>>
>>  Documentation/kbuild/kconfig-language.txt |  8 ---
>>  Kconfig   |  4 --
>>  Makefile  |  3 +-
>>  arch/sh/Kconfig   |  4 +-
>>  arch/sparc/Kconfig|  4 +-
>>  arch/tile/Kconfig |  2 +-
>>  arch/um/Kconfig.common|  4 --
>>  arch/x86/Kconfig  |  4 +-
>>  arch/x86/um/Kconfig   |  4 +-
>>  init/Kconfig  | 10 +---
>>  scripts/kconfig/confdata.c| 31 +-
>>  scripts/kconfig/env.c | 95 
>> +++
>>  scripts/kconfig/kconf_id.c|  1 -
>>  scripts/kconfig/lkc.h |  8 +--
>>  scripts/kconfig/menu.c|  3 -
>>  scripts/kconfig/symbol.c  | 56 --
>>  scripts/kconfig/util.c| 75 
>>  scripts/kconfig/zconf.l   | 20 ++-
>>  scripts/kconfig/zconf.y   |  2 +-
>>  19 files changed, 158 insertions(+), 180 deletions(-)
>>  create mode 100644 scripts/kconfig/env.c
>>
>> diff --git a/Documentation/kbuild/kconfig-language.txt 
>> b/Documentation/kbuild/kconfig-language.txt
>> index f5b9493..0e966e8 100644
>> --- a/Documentation/kbuild/kconfig-language.txt
>> +++ b/Documentation/kbuild/kconfig-language.txt
>> @@ -198,14 +198,6 @@ applicable everywhere (see syntax).
>>  enables the third modular state for all config symbols.
>>  At most one symbol may have the "modules" option set.
>>
>> -  - "env"=
>> -This imports the environment variable into Kconfig. It behaves like
>> -a default, except that the value comes from the environment, this
>> -also means that the behaviour when mixing it with normal defaults is
>> -undefined at this point. The symbol is currently not exported back
>> -to the build environment (if this is desired, it can be done via
>> -another symbol).
>> -
>>- "allnoconfig_y"
>>  This declares the symbol as one that should have the value y when
>>  using "allnoconfig". Used for symbols that hide other symbols.
>> diff --git a/Kconfig b/Kconfig
>> index 8c4c1cb..e6ece5b 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -5,8 +5,4 @@
>>  #
>>  mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration"
>>
>> -config SRCARCH
>> -   string
>> -   option env="SRCARCH"
>> -
>>  source "arch/$SRCARCH/Kconfig"
>> diff --git a/Makefile b/Makefile
>> ind

Re: [PATCH v2 07/21] kconfig: add function support and implement 'shell' function

2018-03-28 Thread Ulf Magnusson
On Tue, Mar 27, 2018 at 7:29 AM, Masahiro Yamada
 wrote:
> This commit adds a new concept 'function' to do more text processing
> in Kconfig.
>
> A function call looks like this:
>
>   $(function arg1, arg2, arg3, ...)
>
> (Actually, this syntax was inspired by make.)
>
> Real examples will look like this:
>
>   $(shell echo hello world)
>   $(cc-option -fstackprotector)
>
> This commit adds the basic infrastructure to add, delete, evaluate
> functions, and also the first built-in function $(shell ...).  This
> accepts a single command to execute.  It returns the standard output
> from it.
>
> [Example code]
>
>   config HELLO
>   string
>   default "$(shell echo hello world)"
>
>   config Y
>   def_bool $(shell echo y)
>
> [Result]
>
>   $ make -s alldefconfig && tail -n 2 .config
>   CONFIG_HELLO="hello world"
>   CONFIG_Y=y
>
> Caveat:
> Like environments, functions are expanded in the lexer.  You cannot
> pass symbols to function arguments.  This is a limitation to simplify
> the implementation.  I want to avoid the dynamic function evaluation,
> which would introduce much more complexity.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
> Reminder for myself:
> Update Documentation/kbuild/kconfig-language.txt
>
>
> Changes in v2:
>   - Use 'shell' for getting stdout from the comment.
> It was 'shell-stdout' in the previous version.
>   - Symplify the implementation since the expansion has been moved to
> lexer.
>
>  scripts/kconfig/function.c  | 170 
> 
>  scripts/kconfig/lkc_proto.h |   5 ++
>  scripts/kconfig/util.c  |  46 +---
>  scripts/kconfig/zconf.y |   9 +++
>  4 files changed, 222 insertions(+), 8 deletions(-)
>  create mode 100644 scripts/kconfig/function.c
>

The gotcha from 04/21 ("kconfig: reference environments directly and
remove 'option env=' syntax") applies here too. For example, the
following will work:

config A
bool "A"
default $(shell echo "B && C")

Some people might argue that that's a feature (I sense a mess down the
road if people start depending on it), but just in case you hadn't
thought of it.

Similarly, the following will only work as expected if 'cmd' outputs
the name of an undefined Kconfig symbol:

config A
string
default $(shell cmd)

You could argue that people should add quotes there though (though
that's broken at the moment if the output from 'cmd' includes a
quote).

Quotes in Kconfig speak just mean "constant value". Problem is it's
undocumented, and no one would intuitively expect it.

Cheers,
Ulf


Re: [PATCH v3] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Minchan Kim

On Thu, Mar 29, 2018 at 11:37:12AM +0900, Minchan Kim wrote:
> binder_update_page_range needs down_write of mmap_sem because
> vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
> it is set. However, when I profile binder working, it seems
> every binder buffers should be mapped in advance by binder_mmap.
> It means we could set VM_MIXEDMAP in bider_mmap time which is
> already hold a mmap_sem as down_write so binder_update_page_range
> doesn't need to hold a mmap_sem as down_write.
> 
> Android suffers from mmap_sem contention so let's reduce mmap_sem
> down_write.
> 
> Cc: Todd Kjos 
> Cc: Greg Kroah-Hartman 
> Cc: Arve Hjønnevåg 
> Reviewed-by: Martijn Coenen 
> Signed-off-by: Minchan Kim 

Sent wrong version. Sorry for that. Please ignore this and take it.

>From 480e992d4a650fb98e1397114d75dea7af8e6d0c Mon Sep 17 00:00:00 2001
From: Minchan Kim 
Date: Wed, 28 Mar 2018 11:32:42 +0900
Subject: [PATCH v3] ANDROID: binder: change down_write to down_read
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

binder_update_page_range needs down_write of mmap_sem because
vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
it is set. However, when I profile binder working, it seems
every binder buffers should be mapped in advance by binder_mmap.
It means we could set VM_MIXEDMAP in bider_mmap time which is
already hold a mmap_sem as down_write so binder_update_page_range
doesn't need to hold a mmap_sem as down_write.

Android suffers from mmap_sem contention so let's reduce mmap_sem
down_write.

Cc: Arve Hjønnevåg 
Cc: Todd Kjos 
Cc: Greg Kroah-Hartman 
Reviewed-by: Martijn Coenen 
Signed-off-by: Minchan Kim 
---

>From v2:
  * Fix vma->flag setting - Arve

>From v1:
  * remove WARN_ON_ONCE - Greg
  * add reviewed-by - Martijn

Martijn, I took your LGTM of v1 as Reviewed-by. If you don't like it
or want to change it to acked-by, please, tell me.

 drivers/android/binder.c   | 3 ++-
 drivers/android/binder_alloc.c | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 764b63a5aade..fe62be7d7113 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4722,7 +4722,8 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
failure_string = "bad vm_flags";
goto err_bad_arg;
}
-   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
+   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY | VM_MIXEDMAP) &
+   ~VM_MAYWRITE;
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 5a426c877dfb..4f382d51def1 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -219,7 +219,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
mm = alloc->vma_vm_mm;
 
if (mm) {
-   down_write(&mm->mmap_sem);
+   down_read(&mm->mmap_sem);
vma = alloc->vma;
}
 
@@ -288,7 +288,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
/* vm_insert_page does not seem to increment the refcount */
}
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return 0;
@@ -321,7 +321,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
}
 err_no_vma:
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return vma ? -ENOMEM : -ESRCH;
-- 
2.17.0.rc1.321.gba9d0f2565-goog



[PATCH v3] ANDROID: binder: change down_write to down_read

2018-03-28 Thread Minchan Kim
binder_update_page_range needs down_write of mmap_sem because
vm_insert_page need to change vma->vm_flags to VM_MIXEDMAP unless
it is set. However, when I profile binder working, it seems
every binder buffers should be mapped in advance by binder_mmap.
It means we could set VM_MIXEDMAP in bider_mmap time which is
already hold a mmap_sem as down_write so binder_update_page_range
doesn't need to hold a mmap_sem as down_write.

Android suffers from mmap_sem contention so let's reduce mmap_sem
down_write.

Cc: Todd Kjos 
Cc: Greg Kroah-Hartman 
Cc: Arve Hjønnevåg 
Reviewed-by: Martijn Coenen 
Signed-off-by: Minchan Kim 
---
>From v2:
  * Fix vma->flag setting - Arve

>From v1:
  * remove WARN_ON_ONCE - Greg
  * add reviewed-by - Martijn

Martijn, I took your LGTM of v1 as Reviewed-by. If you don't like it
or want to change it to acked-by, please, tell me.

 drivers/android/binder.c   | 3 ++-
 drivers/android/binder_alloc.c | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 764b63a5aade..875ab21fa2e0 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4722,7 +4722,8 @@ static int binder_mmap(struct file *filp, struct 
vm_area_struct *vma)
failure_string = "bad vm_flags";
goto err_bad_arg;
}
-   vma->vm_flags = (vma->vm_flags | VM_DONTCOPY) & ~VM_MAYWRITE;
+   vma->vm_flags = (vma->flags | VM_DONTCOPY | VM_MIXEDMAP) &
+   ~VM_MAYWRITE;
vma->vm_ops = &binder_vm_ops;
vma->vm_private_data = proc;
 
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 5a426c877dfb..4f382d51def1 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -219,7 +219,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
mm = alloc->vma_vm_mm;
 
if (mm) {
-   down_write(&mm->mmap_sem);
+   down_read(&mm->mmap_sem);
vma = alloc->vma;
}
 
@@ -288,7 +288,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
/* vm_insert_page does not seem to increment the refcount */
}
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return 0;
@@ -321,7 +321,7 @@ static int binder_update_page_range(struct binder_alloc 
*alloc, int allocate,
}
 err_no_vma:
if (mm) {
-   up_write(&mm->mmap_sem);
+   up_read(&mm->mmap_sem);
mmput(mm);
}
return vma ? -ENOMEM : -ESRCH;
-- 
2.17.0.rc1.321.gba9d0f2565-goog



Re: [PATCH] media: i2c: wm9090: replace codec to component

2018-03-28 Thread kbuild test robot
Hi Kuninori,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20180328]
[cannot apply to v4.16-rc7]
[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/Kuninori-Morimoto/media-i2c-wm9090-replace-codec-to-component/20180329-082843
base:   git://linuxtv.org/media_tree.git master
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/media/i2c/tda1997x.c:2494:12: error: initialization from 
>> incompatible pointer type [-Werror=incompatible-pointer-types]
 .remove = tda1997x_codec_remove,
   ^
   drivers/media/i2c/tda1997x.c:2494:12: note: (near initialization for 
'tda1997x_codec_driver.remove')
   cc1: some warnings being treated as errors

vim +2494 drivers/media/i2c/tda1997x.c

9ac0038d Tim Harvey2018-02-15  2491  
b534b135 Kuninori Morimoto 2018-03-28  2492  static struct 
snd_soc_component_driver tda1997x_codec_driver = {
9ac0038d Tim Harvey2018-02-15  2493 .probe = tda1997x_codec_probe,
9ac0038d Tim Harvey2018-02-15 @2494 .remove = tda1997x_codec_remove,
b534b135 Kuninori Morimoto 2018-03-28  2495 .idle_bias_on   = 1,
b534b135 Kuninori Morimoto 2018-03-28  2496 .use_pmdown_time= 1,
b534b135 Kuninori Morimoto 2018-03-28  2497 .endianness = 1,
b534b135 Kuninori Morimoto 2018-03-28  2498 .non_legacy_dai_naming  = 1,
9ac0038d Tim Harvey2018-02-15  2499  };
9ac0038d Tim Harvey2018-02-15  2500  

:: The code at line 2494 was first introduced by commit
:: 9ac0038db9a7e10fc8f425010ec98b7afc2ff621 media: i2c: Add TDA1997x HDMI 
receiver driver

:: TO: Tim Harvey 
:: CC: Mauro Carvalho Chehab 

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


.config.gz
Description: application/gzip


Re: [PATCH v6 0/6] Add MediaTek PMIC keys support

2018-03-28 Thread Chen Zhong
On Wed, 2018-03-28 at 11:26 +0100, Lee Jones wrote:
> On Tue, 27 Mar 2018, Matthias Brugger wrote:
> 
> > 
> > 
> > On 03/27/2018 10:05 AM, Lee Jones wrote:
> > > On Fri, 23 Mar 2018, Dmitry Torokhov wrote:
> > >> On Thu, Mar 22, 2018 at 10:17:53AM +0800, Sean Wang wrote:
> > >>> Hi, Dmitry and Lee
> > >>>
> > >>> The series seems not being got merged. Are they good enough to be ready
> > >>> into the your tree?
> > >>>
> > >>> Recently I've tested the series with focusing on pwrkey event generated
> > >>> through interrupt when push and release the key on bpi-r2 board and then
> > >>> finally it's working fine. but for homekey it cannot be found on the
> > >>> board and thus I cannot have more tests more about it.
> > >>>
> > >>> Tested-by: Sean Wang 
> > >>
> > >> You have my Ack on the input patch; I expect it go through Lee's tree as
> > >> there are some dependencies on mfd core piece.
> > > 
> > > Are you happy for me to merge the Input dt-bindings without your Ack?
> > > 
> > 
> > They got both Acked in v5, but the commit message was not updated:
> > https://patchwork.kernel.org/patch/9973721/
> > https://patchwork.kernel.org/patch/9973723/
> 
> Thanks Matthias.
> 
> Chen, can you collect all the Acks and repost as a RESEND please?
> 

Thanks Matthias, Lee, Dmitry and Sean for your comments.

Hi Lee,

I have collected the Acks by Rob and sent the v6:
https://patchwork.kernel.org/patch/10026705
https://patchwork.kernel.org/patch/10026707

Are they enough to be merged?

Thank you.




Re: [PATCH 1/2] perf: riscv: preliminary RISC-V support

2018-03-28 Thread Alan Kao
Hi Alex,

I'm appreciated for your reply and tests.

On Wed, Mar 28, 2018 at 03:58:41PM -0700, Alex Solomatnikov wrote:
> Did you test this code?

I did test this patch on QEMU's virt model with multi-hart, which is the only
RISC-V machine I have for now.  But as I mentioned in 
https://github.com/riscv/riscv-qemu/pull/115 , the hardware counter support
in QEMU is not fully conformed to the 1.10 Priv-Spec, so I had to slightly
tweak the code to make reading work.

Specifically, the read to cycle and instret in QEMU looks like this:
...
case CSR_INSTRET:
case CSR_CYCLE:
//  if (ctr_ok) {
return cpu_get_host_ticks();
//  }
break;
...
and the two lines of comment was the tweak.

On such environment, I did not get anything unexpected.  No matter which of them
is requested, QEMU returns the host's tick.

> 
> I got funny numbers when I tried to run it on HiFive Unleashed:
> 
> perf stat mem-latency
> ...
> 
>  Performance counter stats for 'mem-latency':
> 
> 157.907000  task-clock (msec) #0.940 CPUs utilized
> 
>  1  context-switches  #0.006 K/sec
> 
>  1  cpu-migrations#0.006 K/sec
> 
>   4102  page-faults   #0.026 M/sec
> 
>  157923752  cycles#1.000 GHz
> 
> 9223372034948899840  instructions  # 58403957087.78  insn
> per cycle
>  branches
> 
>  branch-misses
> 
> 
>0.168046000 seconds time elapsed
> 
> 
> Tracing read_counter(), I see this:
> 
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.058809] CPU 3:
> read_counter  idx=0 val=2528358954912
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.063339] CPU 3:
> read_counter  idx=1 val=53892244920
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.118160] CPU 3:
> read_counter  idx=0 val=2528418303035
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.122694] CPU 3:
> read_counter  idx=1 val=53906699665
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.216736] CPU 1:
> read_counter  idx=0 val=2528516878664
> Jan  1 00:41:50 buildroot user.info kernel: [ 2510.221270] CPU 1:
> read_counter  idx=1 val=51986369142
> 
> It looks like the counter values from different cores are subtracted and
> wraparound occurs.
> 

Thanks for the hint.  It makes sense.  9223372034948899840 is 7fff8e66a400,
which should be a wraparound with the mask I set (63-bit) in the code.

I will try this direction.  Ideally, we can solve it by explicitly syncing the
hwc->prev_count when a cpu migration event happens.

> 
> Also, core IDs and socket IDs are wrong in perf report:
> 

As Palmer has replied to this, I have no comment here.

> perf report --header -I
> Error:
> The perf.data file has no samples!
> # 
> # captured on: Thu Jan  1 02:52:07 1970
> # hostname : buildroot
> # os release : 4.15.0-00045-g0d7c030-dirty
> # perf version : 4.15.0
> # arch : riscv64
> # nrcpus online : 4
> # nrcpus avail : 5
> # total memory : 8188340 kB
> # cmdline : /usr/bin/perf record -F 1000 lat_mem_rd -P 1 -W 1 -N 1 -t 10
> # event : name = cycles:ppp, , size = 112, { sample_period, sample_freq } =
> 1000, sample_type = IP|TID|TIME|PERIOD, disabled = 1, inherit = 1, mmap =
> 1, comm = 1, freq = 1, enable_on_exec = 1, task = 1, precise_ip = 3,
> sample_id_all = 1, exclude_guest = 1, mmap2 = 1, comm_exec = 1
> # sibling cores   : 1
> # sibling cores   : 2
> # sibling cores   : 3
> # sibling cores   : 4
> # sibling threads : 1
> # sibling threads : 2
> # sibling threads : 3
> # sibling threads : 4
> # CPU 0: Core ID -1, Socket ID -1
> # CPU 1: Core ID 0, Socket ID -1
> # CPU 2: Core ID 0, Socket ID -1
> # CPU 3: Core ID 0, Socket ID -1
> # CPU 4: Core ID 0, Socket ID -1
> # pmu mappings: cpu = 4, software = 1
> # CPU cache info:
> #  L1 Instruction  32K [1]
> #  L1 Data 32K [1]
> #  L1 Instruction  32K [2]
> #  L1 Data 32K [2]
> #  L1 Instruction  32K [3]
> #  L1 Data 32K [3]
> # missing features: TRACING_DATA BUILD_ID CPUDESC CPUID NUMA_TOPOLOGY
> BRANCH_STACK GROUP_DESC AUXTRACE STAT
> # 
> 
> 
> Alex
>

Many thanks,
Alan

> On Mon, Mar 26, 2018 at 12:57 AM, Alan Kao  wrote:
> 
> > This patch provide a basic PMU, riscv_base_pmu, which supports two
> > general hardware event, instructions and cycles.  Furthermore, this
> > PMU serves as a reference implementation to ease the portings in
> > the future.
> >
> > riscv_base_pmu should be able to run on any RISC-V machine that
> > conforms to the Priv-Spec.  Note that the latest qemu model hasn't
> > fully support a proper behavior of Priv-Spec 1.10 yet, but work
> > around should be easy with very small fixes.  Please check
> > https://github.com/riscv/riscv-qemu/pull/115 for future updates.
> >
> > Cc: Nick Hu 
> > Cc: Greentime Hu 
> > Signed-off-by: Alan Kao 
> > ---
> >  arch/riscv/Kconfig  |  12 +
> >  arch/riscv/include/asm

  1   2   3   4   5   6   7   8   9   10   >