[PATCH for v4.9 LTS 54/86] net: phy: marvell: fix Marvell 88E1512 used in SGMII mode

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Russell King 

[ Upstream commit a13c06525ab9ff442924e67df9393a5efa914c56 ]

When an Marvell 88E1512 PHY is connected to a nic in SGMII mode, the
fiber page is used for the SGMII host-side connection.  The PHY driver
notices that SUPPORTED_FIBRE is set, so it tries reading the fiber page
for the link status, and ends up reading the MAC-side status instead of
the outgoing (copper) link.  This leads to incorrect results reported
via ethtool.

If the PHY is connected via SGMII to the host, ignore the fiber page.
However, continue to allow the existing power management code to
suspend and resume the fiber page.

Fixes: 6cfb3bcc0641 ("Marvell phy: check link status in case of fiber link.")
Signed-off-by: Russell King 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/phy/marvell.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index d6a541bde331..d17173214a70 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1202,7 +1202,8 @@ static int marvell_read_status(struct phy_device *phydev)
int err;
 
/* Check the fiber mode first */
-   if (phydev->supported & SUPPORTED_FIBRE) {
+   if (phydev->supported & SUPPORTED_FIBRE &&
+   phydev->interface != PHY_INTERFACE_MODE_SGMII) {
err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M_FIBER);
if (err < 0)
goto error;
-- 
2.11.0


[PATCH for v4.9 LTS 61/86] spi: davinci: use dma_mapping_error()

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Kevin Hilman 

[ Upstream commit c5a2a394835f473ae23931eda5066d3771d7b2f8 ]

The correct error checking for dma_map_single() is to use
dma_mapping_error().

Signed-off-by: Kevin Hilman 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-davinci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index d36c11b73a35..02fb96797ac8 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -646,7 +646,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct 
spi_transfer *t)
buf = t->rx_buf;
t->rx_dma = dma_map_single(>dev, buf,
t->len, DMA_FROM_DEVICE);
-   if (!t->rx_dma) {
+   if (dma_mapping_error(>dev, !t->rx_dma)) {
ret = -EFAULT;
goto err_rx_map;
}
@@ -660,7 +660,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct 
spi_transfer *t)
buf = (void *)t->tx_buf;
t->tx_dma = dma_map_single(>dev, buf,
t->len, DMA_TO_DEVICE);
-   if (!t->tx_dma) {
+   if (dma_mapping_error(>dev, t->tx_dma)) {
ret = -EFAULT;
goto err_tx_map;
}
-- 
2.11.0


[PATCH for v4.9 LTS 84/86] tipc: allocate user memory with GFP_KERNEL flag

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Parthasarathy Bhuvaragan 

[ Upstream commit 57d5f64d83ab5b5a5118b1597386dd76eaf4340d ]

Until now, we allocate memory always with GFP_ATOMIC flag.
When the system is under memory pressure and a user tries to send,
the send fails due to low memory. However, the user application
can wait for free memory if we allocate it using GFP_KERNEL flag.

In this commit, we use allocate memory with GFP_KERNEL for all user
allocation.

Reported-by: Rune Torgersen 
Acked-by: Jon Maloy 
Signed-off-by: Parthasarathy Bhuvaragan 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/tipc/discover.c   |  4 ++--
 net/tipc/link.c   |  2 +-
 net/tipc/msg.c| 16 
 net/tipc/msg.h|  2 +-
 net/tipc/name_distr.c |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 6b109a808d4c..02462d67d191 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -169,7 +169,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
 
/* Send response, if necessary */
if (respond && (mtyp == DSC_REQ_MSG)) {
-   rskb = tipc_buf_acquire(MAX_H_SIZE);
+   rskb = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
if (!rskb)
return;
tipc_disc_init_msg(net, rskb, DSC_RESP_MSG, bearer);
@@ -278,7 +278,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,
req = kmalloc(sizeof(*req), GFP_ATOMIC);
if (!req)
return -ENOMEM;
-   req->buf = tipc_buf_acquire(MAX_H_SIZE);
+   req->buf = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
if (!req->buf) {
kfree(req);
return -ENOMEM;
diff --git a/net/tipc/link.c b/net/tipc/link.c
index bda89bf9f4ff..4e8647aef01c 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1395,7 +1395,7 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct 
tipc_link *tnl,
msg_set_seqno(hdr, seqno++);
pktlen = msg_size(hdr);
msg_set_size(, pktlen + INT_H_SIZE);
-   tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE);
+   tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE, GFP_ATOMIC);
if (!tnlskb) {
pr_warn("%sunable to send packet\n", link_co_err);
return;
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 17201aa8423d..a53fbe120f35 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -58,12 +58,12 @@ static unsigned int align(unsigned int i)
  * NOTE: Headroom is reserved to allow prepending of a data link header.
  *   There may also be unrequested tailroom present at the buffer's end.
  */
-struct sk_buff *tipc_buf_acquire(u32 size)
+struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp)
 {
struct sk_buff *skb;
unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
 
-   skb = alloc_skb_fclone(buf_size, GFP_ATOMIC);
+   skb = alloc_skb_fclone(buf_size, gfp);
if (skb) {
skb_reserve(skb, BUF_HEADROOM);
skb_put(skb, size);
@@ -95,7 +95,7 @@ struct sk_buff *tipc_msg_create(uint user, uint type,
struct tipc_msg *msg;
struct sk_buff *buf;
 
-   buf = tipc_buf_acquire(hdr_sz + data_sz);
+   buf = tipc_buf_acquire(hdr_sz + data_sz, GFP_ATOMIC);
if (unlikely(!buf))
return NULL;
 
@@ -261,7 +261,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
 
/* No fragmentation needed? */
if (likely(msz <= pktmax)) {
-   skb = tipc_buf_acquire(msz);
+   skb = tipc_buf_acquire(msz, GFP_KERNEL);
if (unlikely(!skb))
return -ENOMEM;
skb_orphan(skb);
@@ -282,7 +282,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
msg_set_importance(, msg_importance(mhdr));
 
/* Prepare first fragment */
-   skb = tipc_buf_acquire(pktmax);
+   skb = tipc_buf_acquire(pktmax, GFP_KERNEL);
if (!skb)
return -ENOMEM;
skb_orphan(skb);
@@ -313,7 +313,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
pktsz = drem + INT_H_SIZE;
else
pktsz = pktmax;
-   skb = tipc_buf_acquire(pktsz);
+   skb = tipc_buf_acquire(pktsz, GFP_KERNEL);
if (!skb) {
rc = -ENOMEM;
goto error;
@@ -448,7 +448,7 @@ bool tipc_msg_make_bundle(struct sk_buff **skb,  struct 
tipc_msg *msg,
if (msz > (max / 2))
return false;
 
-   _skb = tipc_buf_acquire(max);
+   _skb = tipc_buf_acquire(max, GFP_ATOMIC);
if (!_skb)
  

[PATCH for v4.9 LTS 81/86] be2net: fix MAC addr setting on privileged BE3 VFs

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Ivan Vecera 

[ Upstream commit 34393529163af7163ef8459808e3cf2af7db7f16 ]

During interface opening MAC address stored in netdev->dev_addr is
programmed in the HW with exception of BE3 VFs where the initial
MAC is programmed by parent PF. This is OK when MAC address is not
changed when an interfaces is down. In this case the requested MAC is
stored to netdev->dev_addr and later is stored into HW during opening.
But this is not done for all BE3 VFs so the NIC HW does not know
anything about this change and all traffic is filtered.

This is the case of bonding if fail_over_mac == 0 where the MACs of
the slaves are changed while they are down.

The be2net behavior is too restrictive because if a BE3 VF has
the FILTMGMT privilege then it is able to modify its MAC without
any restriction.

To solve the described problem the driver should take care about these
privileged BE3 VFs so the MAC is programmed during opening. And by
contrast unpriviled BE3 VFs should not be allowed to change its MAC
in any case.

Cc: Sathya Perla 
Cc: Ajit Khaparde 
Cc: Sriharsha Basavapatna 
Cc: Somnath Kotur 
Signed-off-by: Ivan Vecera 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index a25d35a1b03d..b3c9cbef766e 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -319,6 +319,13 @@ static int be_mac_addr_set(struct net_device *netdev, void 
*p)
if (ether_addr_equal(addr->sa_data, adapter->dev_mac))
return 0;
 
+   /* BE3 VFs without FILTMGMT privilege are not allowed to set its MAC
+* address
+*/
+   if (BEx_chip(adapter) && be_virtfn(adapter) &&
+   !check_privilege(adapter, BE_PRIV_FILTMGMT))
+   return -EPERM;
+
/* if device is not running, copy MAC to netdev->dev_addr */
if (!netif_running(netdev))
goto done;
@@ -3787,8 +3794,9 @@ static int be_enable_if_filters(struct be_adapter 
*adapter)
if (status)
return status;
 
-   /* For BE3 VFs, the PF programs the initial MAC address */
-   if (!(BEx_chip(adapter) && be_virtfn(adapter))) {
+   /* Don't add MAC on BE3 VFs without FILTMGMT privilege */
+   if (!BEx_chip(adapter) || !be_virtfn(adapter) ||
+   check_privilege(adapter, BE_PRIV_FILTMGMT)) {
status = be_dev_mac_add(adapter, adapter->netdev->dev_addr);
if (status)
return status;
-- 
2.11.0


[PATCH for v4.9 LTS 59/86] usb: gadget: composite: Fix function used to free memory

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Christophe JAILLET 

[ Upstream commit 990758c53eafe5a220a780ed12e7b4d51b3df032 ]

'cdev->os_desc_req' has been allocated with 'usb_ep_alloc_request()' so
'usb_ep_free_request()' should be used to free it.

Signed-off-by: Christophe JAILLET 
Signed-off-by: Felipe Balbi 
Signed-off-by: Sasha Levin 
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index c3c5b87b35b3..baa7cdcc0ebc 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2147,7 +2147,7 @@ int composite_os_desc_req_prepare(struct 
usb_composite_dev *cdev,
cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
if (!cdev->os_desc_req->buf) {
ret = -ENOMEM;
-   kfree(cdev->os_desc_req);
+   usb_ep_free_request(ep0, cdev->os_desc_req);
goto end;
}
cdev->os_desc_req->context = cdev;
-- 
2.11.0


[PATCH for v4.9 LTS 80/86] be2net: don't delete MAC on close on unprivileged BE3 VFs

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Ivan Vecera 

[ Upstream commit 6d928ae590c8d58cfd5cca997d54394de139cbb7 ]

BE3 VFs without FILTMGMT privilege are not allowed to modify its MAC,
VLAN table and UC/MC lists. So don't try to delete MAC on such VFs.

Cc: Sathya Perla 
Cc: Ajit Khaparde 
Cc: Sriharsha Basavapatna 
Cc: Somnath Kotur 
Signed-off-by: Ivan Vecera 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 9711ca4510fa..a25d35a1b03d 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3630,7 +3630,11 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
 
 static void be_disable_if_filters(struct be_adapter *adapter)
 {
-   be_dev_mac_del(adapter, adapter->pmac_id[0]);
+   /* Don't delete MAC on BE3 VFs without FILTMGMT privilege  */
+   if (!BEx_chip(adapter) || !be_virtfn(adapter) ||
+   check_privilege(adapter, BE_PRIV_FILTMGMT))
+   be_dev_mac_del(adapter, adapter->pmac_id[0]);
+
be_clear_uc_list(adapter);
be_clear_mc_list(adapter);
 
-- 
2.11.0


[PATCH for v4.9 LTS 72/86] perf/core: Fix sys_perf_event_open() vs. hotplug

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Peter Zijlstra 

[ Upstream commit 63cae12bce9861cec309798d34701cf3da20bc71 ]

There is problem with installing an event in a task that is 'stuck' on
an offline CPU.

Blocked tasks are not dis-assosciated from offlined CPUs, after all, a
blocked task doesn't run and doesn't require a CPU etc.. Only on
wakeup do we ammend the situation and place the task on a available
CPU.

If we hit such a task with perf_install_in_context() we'll loop until
either that task wakes up or the CPU comes back online, if the task
waking depends on the event being installed, we're stuck.

While looking into this issue, I also spotted another problem, if we
hit a task with perf_install_in_context() that is in the middle of
being migrated, that is we observe the old CPU before sending the IPI,
but run the IPI (on the old CPU) while the task is already running on
the new CPU, things also go sideways.

Rework things to rely on task_curr() -- outside of rq->lock -- which
is rather tricky. Imagine the following scenario where we're trying to
install the first event into our task 't':

CPU0CPU1CPU2

(current == t)

t->perf_event_ctxp[] = ctx;
smp_mb();
cpu = task_cpu(t);

switch(t, n);
migrate(t, 2);
switch(p, t);

ctx = t->perf_event_ctxp[]; // must not be NULL

smp_function_call(cpu, ..);

generic_exec_single()
  func();
spin_lock(ctx->lock);
if (task_curr(t)) // false

add_event_to_ctx();
spin_unlock(ctx->lock);

perf_event_context_sched_in();
  spin_lock(ctx->lock);
  // sees event

So its CPU0's store of t->perf_event_ctxp[] that must not go 'missing'.
Because if CPU2's load of that variable were to observe NULL, it would
not try to schedule the ctx and we'd have a task running without its
counter, which would be 'bad'.

As long as we observe !NULL, we'll acquire ctx->lock. If we acquire it
first and not see the event yet, then CPU0 must observe task_curr()
and retry. If the install happens first, then we must see the event on
sched-in and all is well.

I think we can translate the first part (until the 'must not be NULL')
of the scenario to a litmus test like:

  C C-peterz

  {
  }

  P0(int *x, int *y)
  {
  int r1;

  WRITE_ONCE(*x, 1);
  smp_mb();
  r1 = READ_ONCE(*y);
  }

  P1(int *y, int *z)
  {
  WRITE_ONCE(*y, 1);
  smp_store_release(z, 1);
  }

  P2(int *x, int *z)
  {
  int r1;
  int r2;

  r1 = smp_load_acquire(z);
  smp_mb();
  r2 = READ_ONCE(*x);
  }

  exists
  (0:r1=0 /\ 2:r1=1 /\ 2:r2=0)

Where:
  x is perf_event_ctxp[],
  y is our tasks's CPU, and
  z is our task being placed on the rq of CPU2.

The P0 smp_mb() is the one added by this patch, ordering the store to
perf_event_ctxp[] from find_get_context() and the load of task_cpu()
in task_function_call().

The smp_store_release/smp_load_acquire model the RCpc locking of the
rq->lock and the smp_mb() of P2 is the context switch switching from
whatever CPU2 was running to our task 't'.

This litmus test evaluates into:

  Test C-peterz Allowed
  States 7
  0:r1=0; 2:r1=0; 2:r2=0;
  0:r1=0; 2:r1=0; 2:r2=1;
  0:r1=0; 2:r1=1; 2:r2=1;
  0:r1=1; 2:r1=0; 2:r2=0;
  0:r1=1; 2:r1=0; 2:r2=1;
  0:r1=1; 2:r1=1; 2:r2=0;
  0:r1=1; 2:r1=1; 2:r2=1;
  No
  Witnesses
  Positive: 0 Negative: 7
  Condition exists (0:r1=0 /\ 2:r1=1 /\ 2:r2=0)
  Observation C-peterz Never 0 7
  Hash=e427f41d9146b2a5445101d3e2fcaa34

And the strong and weak model agree.

Reported-by: Mark Rutland 
Tested-by: Mark Rutland 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Sebastian Andrzej Siewior 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Cc: Will Deacon 
Cc: jeremy.lin...@arm.com
Link: 
http://lkml.kernel.org/r/20161209135900.gu3...@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c | 70 +++-
 1 file changed, 48 insertions(+), 22 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 11cc1d83c770..30ccc7029d18 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2272,7 +2272,7 @@ 

[PATCH for v4.9 LTS 77/86] s390/ctl_reg: make __ctl_load a full memory barrier

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Heiko Carstens 

[ Upstream commit e991c24d68b8c0ba297eeb7af80b1e398e98c33f ]

We have quite a lot of code that depends on the order of the
__ctl_load inline assemby and subsequent memory accesses, like
e.g. disabling lowcore protection and the writing to lowcore.

Since the __ctl_load macro does not have memory barrier semantics, nor
any other dependencies the compiler is, theoretically, free to shuffle
code around. Or in other words: storing to lowcore could happen before
lowcore protection is disabled.

In order to avoid this class of potential bugs simply add a full
memory barrier to the __ctl_load macro.

Signed-off-by: Heiko Carstens 
Signed-off-by: Martin Schwidefsky 
Signed-off-by: Sasha Levin 
---
 arch/s390/include/asm/ctl_reg.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/s390/include/asm/ctl_reg.h b/arch/s390/include/asm/ctl_reg.h
index d7697ab802f6..8e136b88cdf4 100644
--- a/arch/s390/include/asm/ctl_reg.h
+++ b/arch/s390/include/asm/ctl_reg.h
@@ -15,7 +15,9 @@
BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
asm volatile(   \
"   lctlg   %1,%2,%0\n" \
-   : : "Q" (*(addrtype *)()), "i" (low), "i" (high));\
+   :   \
+   : "Q" (*(addrtype *)()), "i" (low), "i" (high)\
+   : "memory");\
 }
 
 #define __ctl_store(array, low, high) {
\
-- 
2.11.0


[PATCH for v4.9 LTS 83/86] net: phy: dp83867: allow RGMII_TXID/RGMII_RXID interface types

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: "Karicheri, Muralidharan" 

[ Upstream commit 34c55cf2fc75f8bf6ba87df321038c064cf2d426 ]

Currently dp83867 driver returns error if phy interface type
PHY_INTERFACE_MODE_RGMII_RXID is used to set the rx only internal
delay. Similarly issue happens for PHY_INTERFACE_MODE_RGMII_TXID.
Fix this by checking also the interface type if a particular delay
value is missing in the phy dt bindings. Also update the DT document
accordingly.

Signed-off-by: Murali Karicheri 
Signed-off-by: Sekhar Nori 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 Documentation/devicetree/bindings/net/ti,dp83867.txt | 6 --
 drivers/net/phy/dp83867.c| 8 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.txt 
b/Documentation/devicetree/bindings/net/ti,dp83867.txt
index 5d21141a68b5..75bcaa355880 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.txt
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.txt
@@ -3,9 +3,11 @@
 Required properties:
- reg - The ID number for the phy, usually a small integer
- ti,rx-internal-delay - RGMII Receive Clock Delay - see 
dt-bindings/net/ti-dp83867.h
-   for applicable values
+   for applicable values. Required only if interface type is
+   PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_RXID
- ti,tx-internal-delay - RGMII Transmit Clock Delay - see 
dt-bindings/net/ti-dp83867.h
-   for applicable values
+   for applicable values. Required only if interface type is
+   PHY_INTERFACE_MODE_RGMII_ID or PHY_INTERFACE_MODE_RGMII_TXID
- ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h
for applicable values
 
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 91177a4a32ad..4cad95552cf1 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -113,12 +113,16 @@ static int dp83867_of_init(struct phy_device *phydev)
 
ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
   >rx_id_delay);
-   if (ret)
+   if (ret &&
+   (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID))
return ret;
 
ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
   >tx_id_delay);
-   if (ret)
+   if (ret &&
+   (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID))
return ret;
 
return of_property_read_u32(of_node, "ti,fifo-depth",
-- 
2.11.0


[PATCH for v4.9 LTS 85/86] perf probe: Fix to probe on gcc generated functions in modules

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Masami Hiramatsu 

[ Upstream commit 613f050d68a8ed3c0b18b9568698908ef7bbc1f7 ]

Fix to probe on gcc generated functions on modules. Since
probing on a module is based on its symbol name, it should
be adjusted on actual symbols.

E.g. without this fix, perf probe shows probe definition
on non-exist symbol as below.

  $ perf probe -m build-x86_64/net/netfilter/nf_nat.ko -F in_range*
  in_range.isra.12
  $ perf probe -m build-x86_64/net/netfilter/nf_nat.ko -D in_range
  p:probe/in_range nf_nat:in_range+0

With this fix, perf probe correctly shows a probe on
gcc-generated symbol.

  $ perf probe -m build-x86_64/net/netfilter/nf_nat.ko -D in_range
  p:probe/in_range nf_nat:in_range.isra.12+0

This also fixes same problem on online module as below.

  $ perf probe -m i915 -D assert_plane
  p:probe/assert_plane i915:assert_plane.constprop.134+0

Signed-off-by: Masami Hiramatsu 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/148411450673.9978.14905987549651656075.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/probe-event.c  | 45 +++---
 tools/perf/util/probe-finder.c |  7 +--
 tools/perf/util/probe-finder.h |  3 +++
 3 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d281ae2b54e8..1d9c02bc00f1 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -645,18 +645,31 @@ static int add_exec_to_probe_trace_events(struct 
probe_trace_event *tevs,
return ret;
 }
 
-static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
-   int ntevs, const char *module)
+static int
+post_process_module_probe_trace_events(struct probe_trace_event *tevs,
+  int ntevs, const char *module,
+  struct debuginfo *dinfo)
 {
+   Dwarf_Addr text_offs = 0;
int i, ret = 0;
char *mod_name = NULL;
+   struct map *map;
 
if (!module)
return 0;
 
-   mod_name = find_module_name(module);
+   map = get_target_map(module, false);
+   if (!map || debuginfo__get_text_offset(dinfo, _offs, true) < 0) {
+   pr_warning("Failed to get ELF symbols for %s\n", module);
+   return -EINVAL;
+   }
 
+   mod_name = find_module_name(module);
for (i = 0; i < ntevs; i++) {
+   ret = post_process_probe_trace_point([i].point,
+   map, (unsigned long)text_offs);
+   if (ret < 0)
+   break;
tevs[i].point.module =
strdup(mod_name ? mod_name : module);
if (!tevs[i].point.module) {
@@ -666,6 +679,8 @@ static int add_module_to_probe_trace_events(struct 
probe_trace_event *tevs,
}
 
free(mod_name);
+   map__put(map);
+
return ret;
 }
 
@@ -722,7 +737,7 @@ arch__post_process_probe_trace_events(struct 
perf_probe_event *pev __maybe_unuse
 static int post_process_probe_trace_events(struct perf_probe_event *pev,
   struct probe_trace_event *tevs,
   int ntevs, const char *module,
-  bool uprobe)
+  bool uprobe, struct debuginfo *dinfo)
 {
int ret;
 
@@ -730,7 +745,8 @@ static int post_process_probe_trace_events(struct 
perf_probe_event *pev,
ret = add_exec_to_probe_trace_events(tevs, ntevs, module);
else if (module)
/* Currently ref_reloc_sym based probe is not for drivers */
-   ret = add_module_to_probe_trace_events(tevs, ntevs, module);
+   ret = post_process_module_probe_trace_events(tevs, ntevs,
+module, dinfo);
else
ret = post_process_kernel_probe_trace_events(tevs, ntevs);
 
@@ -774,30 +790,27 @@ static int try_to_find_probe_trace_events(struct 
perf_probe_event *pev,
}
}
 
-   debuginfo__delete(dinfo);
-
if (ntevs > 0) {/* Succeeded to find trace events */
pr_debug("Found %d probe_trace_events.\n", ntevs);
ret = post_process_probe_trace_events(pev, *tevs, ntevs,
-   pev->target, pev->uprobes);
+   pev->target, pev->uprobes, dinfo);
if (ret < 0 || ret == ntevs) {
+   pr_debug("Post processing failed or all events are 
skipped. 

[PATCH for v4.9 LTS 76/86] swiotlb: ensure that page-sized mappings are page-aligned

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Nikita Yushchenko 

[ Upstream commit 602d9858f07c72eab64f5f00e2fae55f9902cfbe ]

Some drivers do depend on page mappings to be page aligned.

Swiotlb already enforces such alignment for mappings greater than page,
extend that to page-sized mappings as well.

Without this fix, nvme hits BUG() in nvme_setup_prps(), because that routine
assumes page-aligned mappings.

Signed-off-by: Nikita Yushchenko 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Sagi Grimberg 
Signed-off-by: Konrad Rzeszutek Wilk 
Signed-off-by: Sasha Levin 
---
 lib/swiotlb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index ad1d2962d129..b7812df04437 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -456,11 +456,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
: 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
 
/*
-* For mappings greater than a page, we limit the stride (and
-* hence alignment) to a page size.
+* For mappings greater than or equal to a page, we limit the stride
+* (and hence alignment) to a page size.
 */
nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
-   if (size > PAGE_SIZE)
+   if (size >= PAGE_SIZE)
stride = (1 << (PAGE_SHIFT - IO_TLB_SHIFT));
else
stride = 1;
-- 
2.11.0


[PATCH for v4.9 LTS 75/86] coredump: Ensure proper size of sparse core files

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Dave Kleikamp 

[ Upstream commit 4d22c75d4c7b5c5f4bd31054f09103ee490878fd ]

If the last section of a core file ends with an unmapped or zero page,
the size of the file does not correspond with the last dump_skip() call.
gdb complains that the file is truncated and can be confusing to users.

After all of the vma sections are written, make sure that the file size
is no smaller than the current file position.

This problem can be demonstrated with gdb's bigcore testcase on the
sparc architecture.

Signed-off-by: Dave Kleikamp 
Cc: Alexander Viro 
Cc: linux-fsde...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Al Viro 
Signed-off-by: Sasha Levin 
---
 fs/binfmt_elf.c  |  1 +
 fs/coredump.c| 18 ++
 include/linux/coredump.h |  1 +
 3 files changed, 20 insertions(+)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 2472af2798c7..cfd724f98332 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -2296,6 +2296,7 @@ static int elf_core_dump(struct coredump_params *cprm)
goto end_coredump;
}
}
+   dump_truncate(cprm);
 
if (!elf_core_write_extra_data(cprm))
goto end_coredump;
diff --git a/fs/coredump.c b/fs/coredump.c
index eb9c92c9b20f..4407e27beca9 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -833,3 +833,21 @@ int dump_align(struct coredump_params *cprm, int align)
return mod ? dump_skip(cprm, align - mod) : 1;
 }
 EXPORT_SYMBOL(dump_align);
+
+/*
+ * Ensures that file size is big enough to contain the current file
+ * postion. This prevents gdb from complaining about a truncated file
+ * if the last "write" to the file was dump_skip.
+ */
+void dump_truncate(struct coredump_params *cprm)
+{
+   struct file *file = cprm->file;
+   loff_t offset;
+
+   if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
+   offset = file->f_op->llseek(file, 0, SEEK_CUR);
+   if (i_size_read(file->f_mapping->host) < offset)
+   do_truncate(file->f_path.dentry, offset, 0, file);
+   }
+}
+EXPORT_SYMBOL(dump_truncate);
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index d016a121a8c4..28ffa94aed6b 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -14,6 +14,7 @@ struct coredump_params;
 extern int dump_skip(struct coredump_params *cprm, size_t nr);
 extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
 extern int dump_align(struct coredump_params *cprm, int align);
+extern void dump_truncate(struct coredump_params *cprm);
 #ifdef CONFIG_COREDUMP
 extern void do_coredump(const siginfo_t *siginfo);
 #else
-- 
2.11.0


[PATCH for v4.9 LTS 79/86] be2net: fix status check in be_cmd_pmac_add()

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Ivan Vecera 

[ Upstream commit fe68d8bfe59c561664aa87d827aa4b320eb08895 ]

Return value from be_mcc_notify_wait() contains a base completion status
together with an additional status. The base_status() macro need to be
used to access base status.

Fixes: e3a7ae2 be2net: Changing MAC Address of a VF was broken
Cc: Sathya Perla 
Cc: Ajit Khaparde 
Cc: Sriharsha Basavapatna 
Cc: Somnath Kotur 
Signed-off-by: Ivan Vecera 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 0e74529a4209..30e855004c57 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1118,7 +1118,7 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 
*mac_addr,
 err:
mutex_unlock(>mcc_lock);
 
-if (status == MCC_STATUS_UNAUTHORIZED_REQUEST)
+if (base_status(status) == MCC_STATUS_UNAUTHORIZED_REQUEST)
status = -EPERM;
 
return status;
-- 
2.11.0


[PATCH for v4.9 LTS 67/86] pmem: return EIO on read_pmem() failure

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Stefan Hajnoczi 

[ Upstream commit d47d1d27fd6206c18806440f6ebddf51a806be4f ]

The read_pmem() function uses memcpy_mcsafe() on x86 where an EFAULT
error code indicates a failed read.  Block I/O should use EIO to
indicate failure.  Other pmem code paths (like bad blocks) already use
EIO so let's be consistent.

This fixes compatibility with consumers like btrfs that try to parse the
specific error code rather than treat all errors the same.

Reviewed-by: Jeff Moyer 
Signed-off-by: Stefan Hajnoczi 
Signed-off-by: Dan Williams 
Signed-off-by: Sasha Levin 
---
 drivers/nvdimm/pmem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index b4808590870c..3456f532077c 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -87,7 +87,9 @@ static int read_pmem(struct page *page, unsigned int off,
 
rc = memcpy_from_pmem(mem + off, pmem_addr, len);
kunmap_atomic(mem);
-   return rc;
+   if (rc)
+   return -EIO;
+   return 0;
 }
 
 static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
-- 
2.11.0


[PATCH for v4.9 LTS 69/86] KVM: arm64: Access CNTHCTL_EL2 bit fields correctly on VHE systems

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Jintack Lim 

[ Upstream commit 488f94d7212b00a2ec72fb886b155f1b04c5aa98 ]

Current KVM world switch code is unintentionally setting wrong bits to
CNTHCTL_EL2 when E2H == 1, which may allow guest OS to access physical
timer.  Bit positions of CNTHCTL_EL2 are changing depending on
HCR_EL2.E2H bit.  EL1PCEN and EL1PCTEN are 1st and 0th bits when E2H is
not set, but they are 11th and 10th bits respectively when E2H is set.

In fact, on VHE we only need to set those bits once, not for every world
switch. This is because the host kernel runs in EL2 with HCR_EL2.TGE ==
1, which makes those bits have no effect for the host kernel execution.
So we just set those bits once for guests, and that's it.

Signed-off-by: Jintack Lim 
Reviewed-by: Marc Zyngier 
Signed-off-by: Marc Zyngier 
Signed-off-by: Sasha Levin 
---
 arch/arm/include/asm/virt.h   |  5 +
 arch/arm/kvm/arm.c|  3 +++
 arch/arm64/include/asm/virt.h |  9 +
 include/kvm/arm_arch_timer.h  |  1 +
 virt/kvm/arm/arch_timer.c | 23 +++
 virt/kvm/arm/hyp/timer-sr.c   | 33 +
 6 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/virt.h b/arch/arm/include/asm/virt.h
index a2e75b84e2ae..6dae1956c74d 100644
--- a/arch/arm/include/asm/virt.h
+++ b/arch/arm/include/asm/virt.h
@@ -80,6 +80,11 @@ static inline bool is_kernel_in_hyp_mode(void)
return false;
 }
 
+static inline bool has_vhe(void)
+{
+   return false;
+}
+
 /* The section containing the hypervisor idmap text */
 extern char __hyp_idmap_text_start[];
 extern char __hyp_idmap_text_end[];
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 19b5f5c1c0ff..60d031642798 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -1093,6 +1093,9 @@ static void cpu_init_hyp_mode(void *dummy)
__cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr);
__cpu_init_stage2();
 
+   if (is_kernel_in_hyp_mode())
+   kvm_timer_init_vhe();
+
kvm_arm_init_debug();
 }
 
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index fea10736b11f..439f6b5d31f6 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * __boot_cpu_mode records what mode CPUs were booted in.
@@ -80,6 +81,14 @@ static inline bool is_kernel_in_hyp_mode(void)
return read_sysreg(CurrentEL) == CurrentEL_EL2;
 }
 
+static inline bool has_vhe(void)
+{
+   if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN))
+   return true;
+
+   return false;
+}
+
 #ifdef CONFIG_ARM64_VHE
 extern void verify_cpu_run_el(void);
 #else
diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h
index dda39d8fa189..2d5490375e0d 100644
--- a/include/kvm/arm_arch_timer.h
+++ b/include/kvm/arm_arch_timer.h
@@ -76,4 +76,5 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu);
 
 void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu);
 
+void kvm_timer_init_vhe(void);
 #endif
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 27a1f6341d41..0ebd0dc39cd4 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -24,6 +24,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -517,3 +518,25 @@ void kvm_timer_init(struct kvm *kvm)
 {
kvm->arch.timer.cntvoff = kvm_phys_timer_read();
 }
+
+/*
+ * On VHE system, we only need to configure trap on physical timer and counter
+ * accesses in EL0 and EL1 once, not for every world switch.
+ * The host kernel runs at EL2 with HCR_EL2.TGE == 1,
+ * and this makes those bits have no effect for the host kernel execution.
+ */
+void kvm_timer_init_vhe(void)
+{
+   /* When HCR_EL2.E2H ==1, EL1PCEN and EL1PCTEN are shifted by 10 */
+   u32 cnthctl_shift = 10;
+   u64 val;
+
+   /*
+* Disallow physical timer access for the guest.
+* Physical counter access is allowed.
+*/
+   val = read_sysreg(cnthctl_el2);
+   val &= ~(CNTHCTL_EL1PCEN << cnthctl_shift);
+   val |= (CNTHCTL_EL1PCTEN << cnthctl_shift);
+   write_sysreg(val, cnthctl_el2);
+}
diff --git a/virt/kvm/arm/hyp/timer-sr.c b/virt/kvm/arm/hyp/timer-sr.c
index 798866a8d875..63e28dd18bb0 100644
--- a/virt/kvm/arm/hyp/timer-sr.c
+++ b/virt/kvm/arm/hyp/timer-sr.c
@@ -35,10 +35,16 @@ void __hyp_text __timer_save_state(struct kvm_vcpu *vcpu)
/* Disable the virtual timer */
write_sysreg_el0(0, cntv_ctl);
 
-   /* Allow physical timer/counter access for the host */
-   val = read_sysreg(cnthctl_el2);
-   val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN;
-   write_sysreg(val, cnthctl_el2);
+   /*
+* We don't need to do this for VHE since the host kernel runs in EL2
+* with HCR_EL2.TGE ==1, which makes those bits have 

[PATCH for v4.9 LTS 47/86] vxlan: do not age static remote mac entries

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Balakrishnan Raman 

[ Upstream commit efb5f68f32995c146944a9d4257c3cf8eae2c4a1 ]

Mac aging is applicable only for dynamically learnt remote mac
entries. Check for user configured static remote mac entries
and skip aging.

Signed-off-by: Balakrishnan Raman 
Signed-off-by: Roopa Prabhu 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 55c4408892be..963e5339a4d7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2285,7 +2285,7 @@ static void vxlan_cleanup(unsigned long arg)
= container_of(p, struct vxlan_fdb, hlist);
unsigned long timeout;
 
-   if (f->state & NUD_PERMANENT)
+   if (f->state & (NUD_PERMANENT | NUD_NOARP))
continue;
 
timeout = f->used + vxlan->cfg.age_interval * HZ;
-- 
2.11.0


[PATCH for v4.9 LTS 63/86] net: thunderx: acpi: fix LMAC initialization

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Vadim Lomovtsev 

[ Upstream commit 7aa4865506a26c607e00bd9794a85785b55ebca7 ]

While probing BGX we requesting appropriate QLM for it's configuration
and get LMAC count by that request. Then, while reading configured
MAC values from SSDT table we need to save them in proper mapping:
  BGX[i]->lmac[j].mac = 
to later provide for initialization stuff. In order to fill
such mapping properly we need to add lmac index to be used while
acpi initialization since at this moment bgx->lmac_count already contains
actual value.

Signed-off-by: Vadim Lomovtsev 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c 
b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 679679a4ccb2..e858b1af788d 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -48,8 +48,9 @@ struct lmac {
 struct bgx {
u8  bgx_id;
struct  lmaclmac[MAX_LMAC_PER_BGX];
-   int lmac_count;
+   u8  lmac_count;
u8  max_lmac;
+   u8  acpi_lmac_idx;
void __iomem*reg_base;
struct pci_dev  *pdev;
boolis_dlm;
@@ -1159,13 +1160,13 @@ static acpi_status bgx_acpi_register_phy(acpi_handle 
handle,
if (acpi_bus_get_device(handle, ))
goto out;
 
-   acpi_get_mac_address(dev, adev, bgx->lmac[bgx->lmac_count].mac);
+   acpi_get_mac_address(dev, adev, bgx->lmac[bgx->acpi_lmac_idx].mac);
 
-   SET_NETDEV_DEV(>lmac[bgx->lmac_count].netdev, dev);
+   SET_NETDEV_DEV(>lmac[bgx->acpi_lmac_idx].netdev, dev);
 
-   bgx->lmac[bgx->lmac_count].lmacid = bgx->lmac_count;
+   bgx->lmac[bgx->acpi_lmac_idx].lmacid = bgx->acpi_lmac_idx;
+   bgx->acpi_lmac_idx++; /* move to next LMAC */
 out:
-   bgx->lmac_count++;
return AE_OK;
 }
 
-- 
2.11.0


[PATCH for v4.9 LTS 46/86] ip6_tunnel: must reload ipv6h in ip6ip6_tnl_xmit()

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Eric Dumazet 

[ Upstream commit 21b995a9cb093fff33ec91d7cb3822b882a90a1e ]

Since ip6_tnl_parse_tlv_enc_lim() can call pskb_may_pull(),
we must reload any pointer that was related to skb->head
(or skb->data), or risk use after free.

Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Eric Dumazet 
Cc: Dmitry Kozlov 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/ipv6/ip6_gre.c| 3 +++
 net/ipv6/ip6_tunnel.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 0a5922055da2..a5fdc1aa7a9a 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -582,6 +582,9 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, 
struct net_device *dev)
return -1;
 
offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb));
+   /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */
+   ipv6h = ipv6_hdr(skb);
+
if (offset > 0) {
struct ipv6_tlv_tnl_enc_lim *tel;
tel = (struct ipv6_tlv_tnl_enc_lim 
*)_network_header(skb)[offset];
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 116b4da06820..63fad2467a7e 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1313,6 +1313,8 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device 
*dev)
fl6.flowlabel = key->label;
} else {
offset = ip6_tnl_parse_tlv_enc_lim(skb, 
skb_network_header(skb));
+   /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head 
*/
+   ipv6h = ipv6_hdr(skb);
if (offset > 0) {
struct ipv6_tlv_tnl_enc_lim *tel;
 
-- 
2.11.0


[PATCH for v4.9 LTS 48/86] ibmveth: Add a proper check for the availability of the checksum features

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Thomas Huth 

[ Upstream commit 23d28a859fb847fd7fcfbd31acb3b160abb5d6ae ]

When using the ibmveth driver in a KVM/QEMU based VM, it currently
always prints out a scary error message like this when it is started:

 ibmveth 7103 (unregistered net_device): unable to change
 checksum offload settings. 1 rc=-2 ret_attr=7103

This happens because the driver always tries to enable the checksum
offloading without checking for the availability of this feature first.
QEMU does not support checksum offloading for the spapr-vlan device,
thus we always get the error message here.
According to the LoPAPR specification, the "ibm,illan-options" property
of the corresponding device tree node should be checked first to see
whether the H_ILLAN_ATTRIUBTES hypercall and thus the checksum offloading
feature is available. Thus let's do this in the ibmveth driver, too, so
that the error message is really only limited to cases where something
goes wrong, and does not occur if the feature is just missing.

Signed-off-by: Thomas Huth 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/ibm/ibmveth.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index 03dca732e4c6..b375ae9f98ef 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1604,8 +1604,11 @@ static int ibmveth_probe(struct vio_dev *dev, const 
struct vio_device_id *id)
netdev->netdev_ops = _netdev_ops;
netdev->ethtool_ops = _ethtool_ops;
SET_NETDEV_DEV(netdev, >dev);
-   netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
-   NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+   netdev->hw_features = NETIF_F_SG;
+   if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) {
+   netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+  NETIF_F_RXCSUM;
+   }
 
netdev->features |= netdev->hw_features;
 
-- 
2.11.0


[PATCH for v4.9 LTS 44/86] mlxsw: spectrum_router: Correctly reallocate adjacency entries

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Ido Schimmel 

[ Upstream commit a59b7e0246774e28193126fe7fdbbd0ae9c67dcc ]

mlxsw_sp_nexthop_group_mac_update() is called in one of two cases:

1) When the MAC of a nexthop needs to be updated
2) When the size of a nexthop group has changed

In the second case the adjacency entries for the nexthop group need to
be reallocated from the adjacency table. In this case we must write to
the entries the MAC addresses of all the nexthops that should be
offloaded and not only those whose MAC changed. Otherwise, these entries
would be filled with garbage data, resulting in packet loss.

Fixes: a7ff87acd995 ("mlxsw: spectrum_router: Implement next-hop routing")
Signed-off-by: Ido Schimmel 
Signed-off-by: Jiri Pirko 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 690563099313..9e31a3390154 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1178,7 +1178,8 @@ static int mlxsw_sp_nexthop_mac_update(struct mlxsw_sp 
*mlxsw_sp, u32 adj_index,
 
 static int
 mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp *mlxsw_sp,
- struct mlxsw_sp_nexthop_group *nh_grp)
+ struct mlxsw_sp_nexthop_group *nh_grp,
+ bool reallocate)
 {
u32 adj_index = nh_grp->adj_index; /* base */
struct mlxsw_sp_nexthop *nh;
@@ -1193,7 +1194,7 @@ mlxsw_sp_nexthop_group_mac_update(struct mlxsw_sp 
*mlxsw_sp,
continue;
}
 
-   if (nh->update) {
+   if (nh->update || reallocate) {
err = mlxsw_sp_nexthop_mac_update(mlxsw_sp,
  adj_index, nh);
if (err)
@@ -1254,7 +1255,8 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
/* Nothing was added or removed, so no need to reallocate. Just
 * update MAC on existing adjacency indexes.
 */
-   err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp);
+   err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp,
+   false);
if (err) {
dev_warn(mlxsw_sp->bus_info->dev, "Failed to update 
neigh MAC in adjacency table.\n");
goto set_trap;
@@ -1282,7 +1284,7 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
nh_grp->adj_index_valid = 1;
nh_grp->adj_index = adj_index;
nh_grp->ecmp_size = ecmp_size;
-   err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp);
+   err = mlxsw_sp_nexthop_group_mac_update(mlxsw_sp, nh_grp, true);
if (err) {
dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC 
in adjacency table.\n");
goto set_trap;
-- 
2.11.0


[PATCH for v4.9 LTS 64/86] drm/radeon/si: load special ucode for certain MC configs

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Alex Deucher 

[ Upstream commit ef736d394e85b1bf1fd65ba5e5257b85f6c82325 ]

Special MC ucode is required for these memory configurations.

Acked-by: Edward O'Callaghan 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/radeon/si.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index e8a45933..b75d809c292e 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -115,6 +115,8 @@ MODULE_FIRMWARE("radeon/hainan_rlc.bin");
 MODULE_FIRMWARE("radeon/hainan_smc.bin");
 MODULE_FIRMWARE("radeon/hainan_k_smc.bin");
 
+MODULE_FIRMWARE("radeon/si58_mc.bin");
+
 static u32 si_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh);
 static void si_pcie_gen3_enable(struct radeon_device *rdev);
 static void si_program_aspm(struct radeon_device *rdev);
@@ -1650,6 +1652,7 @@ static int si_init_microcode(struct radeon_device *rdev)
int err;
int new_fw = 0;
bool new_smc = false;
+   bool si58_fw = false;
 
DRM_DEBUG("\n");
 
@@ -1742,6 +1745,10 @@ static int si_init_microcode(struct radeon_device *rdev)
default: BUG();
}
 
+   /* this memory configuration requires special firmware */
+   if (((RREG32(MC_SEQ_MISC0) & 0xff00) >> 24) == 0x58)
+   si58_fw = true;
+
DRM_INFO("Loading %s Microcode\n", new_chip_name);
 
snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", new_chip_name);
@@ -1845,7 +1852,10 @@ static int si_init_microcode(struct radeon_device *rdev)
}
}
 
-   snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", new_chip_name);
+   if (si58_fw)
+   snprintf(fw_name, sizeof(fw_name), "radeon/si58_mc.bin");
+   else
+   snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", 
new_chip_name);
err = request_firmware(>mc_fw, fw_name, rdev->dev);
if (err) {
snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc2.bin", 
chip_name);
-- 
2.11.0


[PATCH for v4.9 LTS 21/86] drm/amdgpu: add support for new hainan variants

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Alex Deucher 

[ Upstream commit 17324b6add82d6c0bf119f1d1944baef392a4e39 ]

New hainan parts require updated smc firmware.

Cc: Sonny Jiang 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/si_dpm.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c 
b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
index 6f3c89178b6a..4cb347e88cf0 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
@@ -64,6 +64,7 @@ MODULE_FIRMWARE("radeon/oland_smc.bin");
 MODULE_FIRMWARE("radeon/oland_k_smc.bin");
 MODULE_FIRMWARE("radeon/hainan_smc.bin");
 MODULE_FIRMWARE("radeon/hainan_k_smc.bin");
+MODULE_FIRMWARE("radeon/banks_k_2_smc.bin");
 
 union power_info {
struct _ATOM_POWERPLAY_INFO info;
@@ -7721,10 +7722,11 @@ static int si_dpm_init_microcode(struct amdgpu_device 
*adev)
((adev->pdev->device == 0x6660) ||
(adev->pdev->device == 0x6663) ||
(adev->pdev->device == 0x6665) ||
-   (adev->pdev->device == 0x6667))) ||
-   ((adev->pdev->revision == 0xc3) &&
-   (adev->pdev->device == 0x6665)))
+(adev->pdev->device == 0x6667
chip_name = "hainan_k";
+   else if ((adev->pdev->revision == 0xc3) &&
+(adev->pdev->device == 0x6665))
+   chip_name = "banks_k_2";
else
chip_name = "hainan";
break;
-- 
2.11.0


[PATCH for v4.9 LTS 33/86] virtio_console: fix a crash in config_work_handler

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: "G. Campana" 

[ Upstream commit 8379cadf71c3ee8173a1c6fc1ea7762a9638c047 ]

Using control_work instead of config_work as the 3rd argument to
container_of results in an invalid portdev pointer. Indeed, the work
structure is initialized as below:

INIT_WORK(>config_work, _work_handler);

It leads to a crash when portdev->vdev is dereferenced later. This
bug
is triggered when the guest uses a virtio-console without multiport
feature and receives a config_changed virtio interrupt.

Signed-off-by: G. Campana 
Reviewed-by: Amit Shah 
Signed-off-by: Michael S. Tsirkin 
Signed-off-by: Sasha Levin 
---
 drivers/char/virtio_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 471a301d63e3..8f890c1aca57 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1870,7 +1870,7 @@ static void config_work_handler(struct work_struct *work)
 {
struct ports_device *portdev;
 
-   portdev = container_of(work, struct ports_device, control_work);
+   portdev = container_of(work, struct ports_device, config_work);
if (!use_multiport(portdev)) {
struct virtio_device *vdev;
struct port *port;
-- 
2.11.0


[PATCH for v4.9 LTS 37/86] scsi: virtio_scsi: Reject commands when virtqueue is broken

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Eric Farman 

[ Upstream commit 773c7220e22d193e5667c352fcbf8d47eefc817f ]

In the case of a graceful set of detaches, where the virtio-scsi-ccw
disk is removed from the guest prior to the controller, the guest
behaves quite normally.  Specifically, the detach gets us into
sd_sync_cache to issue a Synchronize Cache(10) command, which
immediately fails (and is retried a couple of times) because the device
has been removed.  Later, the removal of the controller sees two CRWs
presented, but there's no further indication of the removal from the
guest viewpoint.

 [   17.217458] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   17.219257] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: 
hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
 [   21.449400] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, 
erc=4, rsid=2
 [   21.449406] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, 
erc=4, rsid=0

However, on s390, the SCSI disks can be removed "by surprise" when an
entire controller (host) is removed and all associated disks are removed
via the loop in scsi_forget_host.  The same call to sd_sync_cache is
made, but because the controller has already been removed, the
Synchronize Cache(10) command is neither issued (and then failed) nor
rejected.

That the I/O isn't returned means the guest cannot have other devices
added nor removed, and other tasks (such as shutdown or reboot) issued
by the guest will not complete either.  The virtio ring has already been
marked as broken (via virtio_break_device in virtio_ccw_remove), but we
still attempt to queue the command only to have it remain there.  The
calling sequence provides a bit of distinction for us:

  virtscsi_queuecommand()
   -> virtscsi_kick_cmd()
-> virtscsi_add_cmd()
 -> virtqueue_add_sgs()
  -> virtqueue_add()
 if success
   return 0
 elseif vq->broken or vring_mapping_error()
   return -EIO
 else
   return -ENOSPC

A return of ENOSPC is generally a temporary condition, so returning
"host busy" from virtscsi_queuecommand makes sense here, to have it
redriven in a moment or two.  But the EIO return code is more of a
permanent error and so it would be wise to return the I/O itself and
allow the calling thread to finish gracefully.  The result is these four
kernel messages in the guest (the fourth one does not occur prior to
this patch):

 [   22.921562] crw_info : CRW reports slct=0, oflw=0, chn=1, rsc=3, anc=0, 
erc=4, rsid=2
 [   22.921580] crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=0, 
erc=4, rsid=0
 [   22.921978] sd 0:0:0:0: [sda] Synchronizing SCSI cache
 [   22.921993] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: 
hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK

I opted to fill in the same response data that is returned from the more
graceful device detach, where the disk device is removed prior to the
controller device.

Signed-off-by: Eric Farman 
Reviewed-by: Fam Zheng 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/virtio_scsi.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index ec91bd07f00a..c680d7641311 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -534,7 +534,9 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
 {
struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
struct virtio_scsi_cmd *cmd = scsi_cmd_priv(sc);
+   unsigned long flags;
int req_size;
+   int ret;
 
BUG_ON(scsi_sg_count(sc) > shost->sg_tablesize);
 
@@ -562,8 +564,15 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
req_size = sizeof(cmd->req.cmd);
}
 
-   if (virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd)) != 
0)
+   ret = virtscsi_kick_cmd(req_vq, cmd, req_size, sizeof(cmd->resp.cmd));
+   if (ret == -EIO) {
+   cmd->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
+   spin_lock_irqsave(_vq->vq_lock, flags);
+   virtscsi_complete_cmd(vscsi, cmd);
+   spin_unlock_irqrestore(_vq->vq_lock, flags);
+   } else if (ret != 0) {
return SCSI_MLQUEUE_HOST_BUSY;
+   }
return 0;
 }
 
-- 
2.11.0


[PATCH for v4.9 LTS 43/86] vfio/spapr: fail tce_iommu_attach_group() when iommu_data is null

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Greg Kurz 

[ Upstream commit bd00fdf198e2da475a2f4265a83686ab42d998a8 ]

The recently added mediated VFIO driver doesn't know about powerpc iommu.
It thus doesn't register a struct iommu_table_group in the iommu group
upon device creation. The iommu_data pointer hence remains null.

This causes a kernel oops when userspace tries to set the iommu type of a
container associated with a mediated device to VFIO_SPAPR_TCE_v2_IOMMU.

[   82.585440] mtty mtty: MDEV: Registered
[   87.655522] iommu: Adding device 83b8f4f2-509f-382f-3c1e-e6bfe0fa1001 to 
group 10
[   87.655527] vfio_mdev 83b8f4f2-509f-382f-3c1e-e6bfe0fa1001: MDEV: group_id = 
10
[  116.297184] Unable to handle kernel paging request for data at address 
0x0030
[  116.297389] Faulting instruction address: 0xd7870524
[  116.297465] Oops: Kernel access of bad area, sig: 11 [#1]
[  116.297611] SMP NR_CPUS=2048
[  116.297611] NUMA
[  116.297627] PowerNV
...
[  116.297954] CPU: 33 PID: 7067 Comm: qemu-system-ppc Not tainted 
4.10.0-rc5-mdev-test #8
[  116.297993] task: c00e7718b680 task.stack: c00e77214000
[  116.298025] NIP: d7870524 LR: d7870518 CTR: 
[  116.298064] REGS: c00e77217990 TRAP: 0300   Not tainted  
(4.10.0-rc5-mdev-test)
[  116.298103] MSR: 90009033 
[  116.298107]   CR: 8400  XER: 
[  116.298154] CFAR: c000888c DAR: 0030 DSISR: 4000 
SOFTE: 1
   GPR00: d7870518 c00e77217c10 d787b0ed 
c00eed2103c0
   GPR04:   c00eed2103e0 
000f2432
   GPR08: 0104 0001  
d78729b0
   GPR12: c025b7e0 cfe08400 0001 
01002d31d100
   GPR16: 01002c22c850 3315c750 43145680 
43141bc0
   GPR20: ffed f000 20003b65 
d7706018
   GPR24: c00f16cf0d98 d7706000 c3f42980 
c3f42980
   GPR28: c00f1575ac00 c3f429c8  
c00eed2103c0
[  116.298504] NIP [d7870524] tce_iommu_attach_group+0x10c/0x360 
[vfio_iommu_spapr_tce]
[  116.298555] LR [d7870518] tce_iommu_attach_group+0x100/0x360 
[vfio_iommu_spapr_tce]
[  116.298601] Call Trace:
[  116.298610] [c00e77217c10] [d7870518] 
tce_iommu_attach_group+0x100/0x360 [vfio_iommu_spapr_tce] (unreliable)
[  116.298671] [c00e77217cb0] [d77033a0] 
vfio_fops_unl_ioctl+0x278/0x3e0 [vfio]
[  116.298713] [c00e77217d40] [c02a3ebc] do_vfs_ioctl+0xcc/0x8b0
[  116.298745] [c00e77217de0] [c02a4700] SyS_ioctl+0x60/0xc0
[  116.298782] [c00e77217e30] [c000b220] system_call+0x38/0xfc
[  116.298812] Instruction dump:
[  116.298828] 7d3f4b78 409effc8 3d22 e9298020 3c800140 38a00018 608480c0 
e8690028
[  116.298869] 4800249d e8410018 7c7f1b79 41820230  2fa9 419e0114 
e9090020
[  116.298914] ---[ end trace 1e10b0ced08b9120 ]---

This patch fixes the oops.

Reported-by: Vaibhav Jain 
Signed-off-by: Greg Kurz 
Signed-off-by: Alex Williamson 
Signed-off-by: Sasha Levin 
---
 drivers/vfio/vfio_iommu_spapr_tce.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
b/drivers/vfio/vfio_iommu_spapr_tce.c
index 79ddcb05d126..85d3e648bdea 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -1292,6 +1292,10 @@ static int tce_iommu_attach_group(void *iommu_data,
/* pr_debug("tce_vfio: Attaching group #%u to iommu %p\n",
iommu_group_id(iommu_group), iommu_group); */
table_group = iommu_group_get_iommudata(iommu_group);
+   if (!table_group) {
+   ret = -ENODEV;
+   goto unlock_exit;
+   }
 
if (tce_groups_attached(container) && (!table_group->ops ||
!table_group->ops->take_ownership ||
-- 
2.11.0


[PATCH for v4.9 LTS 35/86] net: sctp: fix array overrun read on sctp_timer_tbl

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Colin Ian King 

[ Upstream commit 0e73fc9a56f22f2eec4d2b2910c649f7af67b74d ]

The comparison on the timeout can lead to an array overrun
read on sctp_timer_tbl because of an off-by-one error. Fix
this by using < instead of <= and also compare to the array
size rather than SCTP_EVENT_TIMEOUT_MAX.

Fixes CoverityScan CID#1397639 ("Out-of-bounds read")

Signed-off-by: Colin Ian King 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/sctp/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sctp/debug.c b/net/sctp/debug.c
index 95d7b15dad21..e371a0d90068 100644
--- a/net/sctp/debug.c
+++ b/net/sctp/debug.c
@@ -166,7 +166,7 @@ static const char *const sctp_timer_tbl[] = {
 /* Lookup timer debug name. */
 const char *sctp_tname(const sctp_subtype_t id)
 {
-   if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
+   if (id.timeout < ARRAY_SIZE(sctp_timer_tbl))
return sctp_timer_tbl[id.timeout];
return "unknown_timer";
 }
-- 
2.11.0


[PATCH for v4.9 LTS 42/86] drm/amdgpu: check ring being ready before using

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Ding Pixel 

[ Upstream commit c5f21c9f878b8dcd54d0b9739c025ca73cb4c091 ]

Return success when the ring is properly initialized, otherwise return
failure.

Tonga SRIOV VF doesn't have UVD and VCE engines, the initialization of
these IPs is bypassed. The system crashes if application submit IB to
their rings which are not ready to use. It could be a common issue if
IP having ring buffer is disabled for some reason on specific ASIC, so
it should check the ring being ready to use.

Bug: amdgpu_test crashes system on Tonga VF.

Signed-off-by: Ding Pixel 
Reviewed-by: Christian König 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 82dc8d20e28a..bfb4b91869e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -83,6 +83,13 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 
ip_type,
}
break;
}
+
+   if (!(*out_ring && (*out_ring)->adev)) {
+   DRM_ERROR("Ring %d is not initialized on IP %d\n",
+ ring, ip_type);
+   return -EINVAL;
+   }
+
return 0;
 }
 
-- 
2.11.0


[PATCH for v4.9 LTS 36/86] xen-netfront: Fix Rx stall during network stress and OOM

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Vineeth Remanan Pillai 

[ Upstream commit 90c311b0eeead647b708a723dbdde1eda3dcad05 ]

During an OOM scenario, request slots could not be created as skb
allocation fails. So the netback cannot pass in packets and netfront
wrongly assumes that there is no more work to be done and it disables
polling. This causes Rx to stall.

The issue is with the retry logic which schedules the timer if the
created slots are less than NET_RX_SLOTS_MIN. The count of new request
slots to be pushed are calculated as a difference between new req_prod
and rsp_cons which could be more than the actual slots, if there are
unconsumed responses.

The fix is to calculate the count of newly created slots as the
difference between new req_prod and old req_prod.

Signed-off-by: Vineeth Remanan Pillai 
Reviewed-by: Juergen Gross 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/xen-netfront.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 0cdcb2169083..599cf5090030 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -321,7 +321,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue 
*queue)
queue->rx.req_prod_pvt = req_prod;
 
/* Not enough requests? Try again later. */
-   if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN) {
+   if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) {
mod_timer(>rx_refill_timer, jiffies + (HZ/10));
return;
}
-- 
2.11.0


[PATCH for v4.9 LTS 41/86] net: dsa: Check return value of phy_connect_direct()

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Florian Fainelli 

[ Upstream commit 4078b76cac68e50ccf1f76a74e7d3d5788aec3fe ]

We need to check the return value of phy_connect_direct() in
dsa_slave_phy_connect() otherwise we may be continuing the
initialization of a slave network device with a PHY that already
attached somewhere else and which will soon be in error because the PHY
device is in error.

The conditions for such an error to occur are that we have a port of our
switch that is not disabled, and has the same port number as a PHY
address (say both 5) that can be probed using the DSA slave MII bus. We
end-up having this slave network device find a PHY at the same address
as our port number, and we try to attach to it.

A slave network (e.g: port 0) has already attached to our PHY device,
and we try to re-attach it with a different network device, but since we
ignore the error we would end-up initializating incorrect device
references by the time the slave network interface is opened.

The code has been (re)organized several times, making it hard to provide
an exact Fixes tag, this is a bugfix nonetheless.

Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/dsa/slave.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 3ff9d97cf56b..079d76bc204c 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1103,10 +1103,8 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv 
*p,
/* Use already configured phy mode */
if (p->phy_interface == PHY_INTERFACE_MODE_NA)
p->phy_interface = p->phy->interface;
-   phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
-  p->phy_interface);
-
-   return 0;
+   return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
+ p->phy_interface);
 }
 
 static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
-- 
2.11.0


[PATCH for v4.9 LTS 34/86] swiotlb-xen: update dev_addr after swapping pages

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Stefano Stabellini 

[ Upstream commit f1225ee4c8fcf09afaa199b8b1f0450f38b8cd11 ]

In xen_swiotlb_map_page and xen_swiotlb_map_sg_attrs, if the original
page is not suitable, we swap it for another page from the swiotlb
pool.

In these cases, we don't update the previously calculated dma address
for the page before calling xen_dma_map_page. Thus, we end up calling
xen_dma_map_page passing the wrong dev_addr, resulting in
xen_dma_map_page mistakenly assuming that the page is foreign when it is
local.

Fix the bug by updating dev_addr appropriately.

This change has no effect on x86, because xen_dma_map_page is a stub
there.

Signed-off-by: Stefano Stabellini 
Signed-off-by: Pooya Keshavarzi 
Tested-by: Pooya Keshavarzi 
Reviewed-by: Boris Ostrovsky 
Signed-off-by: Konrad Rzeszutek Wilk 
Signed-off-by: Sasha Levin 
---
 drivers/xen/swiotlb-xen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 8e7a3d646531..679f79f68182 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -409,9 +409,9 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct 
page *page,
if (map == SWIOTLB_MAP_ERROR)
return DMA_ERROR_CODE;
 
+   dev_addr = xen_phys_to_bus(map);
xen_dma_map_page(dev, pfn_to_page(map >> PAGE_SHIFT),
dev_addr, map & ~PAGE_MASK, size, dir, 
attrs);
-   dev_addr = xen_phys_to_bus(map);
 
/*
 * Ensure that the address returned is DMA'ble
@@ -567,13 +567,14 @@ xen_swiotlb_map_sg_attrs(struct device *hwdev, struct 
scatterlist *sgl,
sg_dma_len(sgl) = 0;
return 0;
}
+   dev_addr = xen_phys_to_bus(map);
xen_dma_map_page(hwdev, pfn_to_page(map >> PAGE_SHIFT),
dev_addr,
map & ~PAGE_MASK,
sg->length,
dir,
attrs);
-   sg->dma_address = xen_phys_to_bus(map);
+   sg->dma_address = dev_addr;
} else {
/* we are not interested in the dma_addr returned by
 * xen_dma_map_page, only in the potential cache 
flushes executed
-- 
2.11.0


[PATCH for v4.9 LTS 38/86] iwlwifi: fix kernel crash when unregistering thermal zone

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Jens Axboe 

[ Upstream commit 92549cdc288f47f3a98cf80ac5890c91f5876a06 ]

A recent firmware change seems to have enabled thermal zones on the
iwlwifi driver. Unfortunately, my device fails when registering the
thermal zone. This doesn't stop the driver from attempting to unregister
the thermal zone at unload time, triggering a NULL pointer deference in
strlen() off the thermal_zone_device_unregister() path.

Don't unregister if name is NULL, for that case we failed registering.
Do the same for the cooling zone.

Signed-off-by: Jens Axboe 
Signed-off-by: Kalle Valo 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 63a051be832e..bec7d9c46087 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -843,8 +843,10 @@ static void iwl_mvm_thermal_zone_unregister(struct iwl_mvm 
*mvm)
return;
 
IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n");
-   thermal_zone_device_unregister(mvm->tz_device.tzone);
-   mvm->tz_device.tzone = NULL;
+   if (mvm->tz_device.tzone) {
+   thermal_zone_device_unregister(mvm->tz_device.tzone);
+   mvm->tz_device.tzone = NULL;
+   }
 }
 
 static void iwl_mvm_cooling_device_unregister(struct iwl_mvm *mvm)
@@ -853,8 +855,10 @@ static void iwl_mvm_cooling_device_unregister(struct 
iwl_mvm *mvm)
return;
 
IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n");
-   thermal_cooling_device_unregister(mvm->cooling_dev.cdev);
-   mvm->cooling_dev.cdev = NULL;
+   if (mvm->cooling_dev.cdev) {
+   thermal_cooling_device_unregister(mvm->cooling_dev.cdev);
+   mvm->cooling_dev.cdev = NULL;
+   }
 }
 #endif /* CONFIG_THERMAL */
 
-- 
2.11.0


[PATCH for v4.9 LTS 32/86] Btrfs: fix truncate down when no_holes feature is enabled

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Liu Bo 

[ Upstream commit 91298eec05cd8d4e828cf7ee5d4a6334f70cf69a ]

For such a file mapping,

[0-4k][hole][8k-12k]

In NO_HOLES mode, we don't have the [hole] extent any more.
Commit c1aa45759e90 ("Btrfs: fix shrinking truncate when the no_holes feature 
is enabled")
 fixed disk isize not being updated in NO_HOLES mode when data is not flushed.

However, even if data has been flushed, we can still have trouble
in updating disk isize since we updated disk isize to 'start' of
the last evicted extent.

Reviewed-by: Chris Mason 
Signed-off-by: Liu Bo 
Signed-off-by: David Sterba 
Signed-off-by: Sasha Levin 
---
 fs/btrfs/inode.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cada3f977baf..a2a014b19f18 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4480,8 +4480,19 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle 
*trans,
if (found_type > min_type) {
del_item = 1;
} else {
-   if (item_end < new_size)
+   if (item_end < new_size) {
+   /*
+* With NO_HOLES mode, for the following mapping
+*
+* [0-4k][hole][8k-12k]
+*
+* if truncating isize down to 6k, it ends up
+* isize being 8k.
+*/
+   if (btrfs_fs_incompat(root->fs_info, NO_HOLES))
+   last_size = new_size;
break;
+   }
if (found_key.offset >= new_size)
del_item = 1;
else
-- 
2.11.0


[PATCH for v4.9 LTS 12/86] perf/x86/intel: Handle exclusive threadid correctly on CPU hotplug

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: Zhou Chengming 

[ Upstream commit 4e71de7986386d5fd3765458f27d612931f27f5e ]

The CPU hotplug function intel_pmu_cpu_starting() sets
cpu_hw_events.excl_thread_id unconditionally to 1 when the shared exclusive
counters data structure is already availabe for the sibling thread.

This works during the boot process because the first sibling gets threadid
0 assigned and the second sibling which shares the data structure gets 1.

But when the first thread of the core is offlined and onlined again it
shares the data structure with the second thread and gets exclusive thread
id 1 assigned as well.

Prevent this by checking the threadid of the already online thread.

[ tglx: Rewrote changelog ]

Signed-off-by: Zhou Chengming 
Cc: NuoHan Qiao 
Cc: a...@linux.intel.com
Cc: pet...@infradead.org
Cc: kan.li...@intel.com
Cc: dave.han...@linux.intel.com
Cc: eran...@google.com
Cc: qiaonuo...@huawei.com
Cc: davi...@google.com
Cc: guohan...@huawei.com
Link: 
http://lkml.kernel.org/r/1484536871-3131-1-git-send-email-zhouchengmi...@huawei.com
Signed-off-by: Thomas Gleixner 
--- ---
 arch/x86/events/intel/core.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/core.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index cb8522290e6a..8d7a6a0f7d2f 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3164,13 +3164,16 @@ static void intel_pmu_cpu_starting(int cpu)
 
if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
for_each_cpu(i, topology_sibling_cpumask(cpu)) {
+   struct cpu_hw_events *sibling;
struct intel_excl_cntrs *c;
 
-   c = per_cpu(cpu_hw_events, i).excl_cntrs;
+   sibling = _cpu(cpu_hw_events, i);
+   c = sibling->excl_cntrs;
if (c && c->core_id == core_id) {
cpuc->kfree_on_online[1] = cpuc->excl_cntrs;
cpuc->excl_cntrs = c;
-   cpuc->excl_thread_id = 1;
+   if (!sibling->excl_thread_id)
+   cpuc->excl_thread_id = 1;
break;
}
}
-- 
2.11.0


[PATCH for v4.9 LTS 08/86] dt: bindings: net: use boolean dt properties for eee broken modes

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: jbrunet 

[ Upstream commit 308d3165d8b2b98d3dc3d97d6662062735daea67 ]

The patches regarding eee-broken-modes was merged before all people
involved could find an agreement on the best way to move forward.

While we agreed on having a DT property to mark particular modes as broken,
the value used for eee-broken-modes mapped the phy register in very direct
way. Because of this, the concern is that it could be used to implement
configuration policies instead of describing a broken HW.

In the end, having a boolean property for each mode seems to be preferred
over one bit field value mapping the register (too) directly.

Cc: Florian Fainelli 
Signed-off-by: Jerome Brunet 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 Documentation/devicetree/bindings/net/phy.txt |  9 +
 include/dt-bindings/net/mdio.h| 19 ---
 2 files changed, 9 insertions(+), 19 deletions(-)
 delete mode 100644 include/dt-bindings/net/mdio.h

diff --git a/Documentation/devicetree/bindings/net/phy.txt 
b/Documentation/devicetree/bindings/net/phy.txt
index bc1c3c8bf8fa..62bdc5f2bf16 100644
--- a/Documentation/devicetree/bindings/net/phy.txt
+++ b/Documentation/devicetree/bindings/net/phy.txt
@@ -35,6 +35,15 @@ Optional Properties:
 - broken-turn-around: If set, indicates the PHY device does not correctly
   release the turn around line low at the end of a MDIO transaction.
 
+- eee-broken-100tx:
+- eee-broken-1000t:
+- eee-broken-10gt:
+- eee-broken-1000kx:
+- eee-broken-10gkx4:
+- eee-broken-10gkr:
+  Mark the corresponding energy efficient ethernet mode as broken and
+  request the ethernet to stop advertising it.
+
 Example:
 
 ethernet-phy@0 {
diff --git a/include/dt-bindings/net/mdio.h b/include/dt-bindings/net/mdio.h
deleted file mode 100644
index 99c6d903d439..
--- a/include/dt-bindings/net/mdio.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * This header provides generic constants for ethernet MDIO bindings
- */
-
-#ifndef _DT_BINDINGS_NET_MDIO_H
-#define _DT_BINDINGS_NET_MDIO_H
-
-/*
- * EEE capability Advertisement
- */
-
-#define MDIO_EEE_100TX 0x0002  /* 100TX EEE cap */
-#define MDIO_EEE_1000T 0x0004  /* 1000T EEE cap */
-#define MDIO_EEE_10GT  0x0008  /* 10GT EEE cap */
-#define MDIO_EEE_1000KX0x0010  /* 1000KX EEE cap */
-#define MDIO_EEE_10GKX40x0020  /* 10G KX4 EEE cap */
-#define MDIO_EEE_10GKR 0x0040  /* 10G KR EEE cap */
-
-#endif
-- 
2.11.0


[PATCH for v4.9 LTS 04/86] net: phy: add an option to disable EEE advertisement

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: jbrunet 

[ Upstream commit d853d145ea3e63387a2ac759aa41d5e43876e561 ]

This patch adds an option to disable EEE advertisement in the generic PHY
by providing a mask of prohibited modes corresponding to the value found in
the MDIO_AN_EEE_ADV register.

On some platforms, PHY Low power idle seems to be causing issues, even
breaking the link some cases. The patch provides a convenient way for these
platforms to disable EEE advertisement and work around the issue.

Signed-off-by: Jerome Brunet 
Tested-by: Yegor Yefremov 
Tested-by: Andreas Färber 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/phy/phy.c|  3 ++
 drivers/net/phy/phy_device.c | 80 +++-
 include/linux/phy.h  |  3 ++
 3 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a9be26f1f677..edd30ebbf275 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1384,6 +1384,9 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct 
ethtool_eee *data)
 {
int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
 
+   /* Mask prohibited EEE modes */
+   val &= ~phydev->eee_broken_modes;
+
phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, val);
 
return 0;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 14d57d0d1c04..b14fcf6e11f6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1146,6 +1146,43 @@ static int genphy_config_advert(struct phy_device 
*phydev)
 }
 
 /**
+ * genphy_config_eee_advert - disable unwanted eee mode advertisement
+ * @phydev: target phy_device struct
+ *
+ * Description: Writes MDIO_AN_EEE_ADV after disabling unsupported energy
+ *   efficent ethernet modes. Returns 0 if the PHY's advertisement hasn't
+ *   changed, and 1 if it has changed.
+ */
+static int genphy_config_eee_advert(struct phy_device *phydev)
+{
+   u32 broken = phydev->eee_broken_modes;
+   u32 old_adv, adv;
+
+   /* Nothing to disable */
+   if (!broken)
+   return 0;
+
+   /* If the following call fails, we assume that EEE is not
+* supported by the phy. If we read 0, EEE is not advertised
+* In both case, we don't need to continue
+*/
+   adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN);
+   if (adv <= 0)
+   return 0;
+
+   old_adv = adv;
+   adv &= ~broken;
+
+   /* Advertising remains unchanged with the broken mask */
+   if (old_adv == adv)
+   return 0;
+
+   phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, adv);
+
+   return 1;
+}
+
+/**
  * genphy_setup_forced - configures/forces speed/duplex from @phydev
  * @phydev: target phy_device struct
  *
@@ -1203,15 +1240,20 @@ EXPORT_SYMBOL(genphy_restart_aneg);
  */
 int genphy_config_aneg(struct phy_device *phydev)
 {
-   int result;
+   int err, changed;
+
+   changed = genphy_config_eee_advert(phydev);
 
if (AUTONEG_ENABLE != phydev->autoneg)
return genphy_setup_forced(phydev);
 
-   result = genphy_config_advert(phydev);
-   if (result < 0) /* error */
-   return result;
-   if (result == 0) {
+   err = genphy_config_advert(phydev);
+   if (err < 0) /* error */
+   return err;
+
+   changed |= err;
+
+   if (changed == 0) {
/* Advertisement hasn't changed, but maybe aneg was never on to
 * begin with?  Or maybe phy was isolated?
 */
@@ -1221,16 +1263,16 @@ int genphy_config_aneg(struct phy_device *phydev)
return ctl;
 
if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
-   result = 1; /* do restart aneg */
+   changed = 1; /* do restart aneg */
}
 
/* Only restart aneg if we are advertising something different
 * than we were before.
 */
-   if (result > 0)
-   result = genphy_restart_aneg(phydev);
+   if (changed > 0)
+   return genphy_restart_aneg(phydev);
 
-   return result;
+   return 0;
 }
 EXPORT_SYMBOL(genphy_config_aneg);
 
@@ -1588,6 +1630,21 @@ static void of_set_phy_supported(struct phy_device 
*phydev)
__set_phy_supported(phydev, max_speed);
 }
 
+static void of_set_phy_eee_broken(struct phy_device *phydev)
+{
+   struct device_node *node = phydev->mdio.dev.of_node;
+   u32 broken;
+
+   if (!IS_ENABLED(CONFIG_OF_MDIO))
+   return;
+
+   if (!node)
+   return;
+
+   if (!of_property_read_u32(node, "eee-broken-modes", ))
+   phydev->eee_broken_modes = broken;
+}
+
 /**
  * phy_probe - probe and init 

[PATCH for v4.9 LTS 05/86] dt-bindings: net: add EEE capability constants

2017-06-17 Thread Levin, Alexander (Sasha Levin)
From: jbrunet 

[ Upstream commit 1fc31357ad194fb98691f3d122bcd47e59239e83 ]

Signed-off-by: Jerome Brunet 
Tested-by: Yegor Yefremov 
Tested-by: Andreas Färber 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 include/dt-bindings/net/mdio.h | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 include/dt-bindings/net/mdio.h

diff --git a/include/dt-bindings/net/mdio.h b/include/dt-bindings/net/mdio.h
new file mode 100644
index ..99c6d903d439
--- /dev/null
+++ b/include/dt-bindings/net/mdio.h
@@ -0,0 +1,19 @@
+/*
+ * This header provides generic constants for ethernet MDIO bindings
+ */
+
+#ifndef _DT_BINDINGS_NET_MDIO_H
+#define _DT_BINDINGS_NET_MDIO_H
+
+/*
+ * EEE capability Advertisement
+ */
+
+#define MDIO_EEE_100TX 0x0002  /* 100TX EEE cap */
+#define MDIO_EEE_1000T 0x0004  /* 1000T EEE cap */
+#define MDIO_EEE_10GT  0x0008  /* 10GT EEE cap */
+#define MDIO_EEE_1000KX0x0010  /* 1000KX EEE cap */
+#define MDIO_EEE_10GKX40x0020  /* 10G KX4 EEE cap */
+#define MDIO_EEE_10GKR 0x0040  /* 10G KR EEE cap */
+
+#endif
-- 
2.11.0


[PATCH] rt_mutex: correctly initialize lockdep in rt_mutex_init_proxy_locked

2017-06-09 Thread Levin, Alexander (Sasha Levin)
lockdep can't deal with NULL name or key, and doesn't do anything
with the lock when that happens.

Make rt_mutex_init_proxy_locked pass a name and a key for the lock.

Fixes: f5694788ad8d ("rt_mutex: Add lockdep annotations")
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sasha Levin 
---
 kernel/locking/rtmutex.c|  6 --
 kernel/locking/rtmutex_common.h | 12 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 43123533e9b1..f540961cec30 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1679,10 +1679,12 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init);
  * possible at this point because the pi_state which contains the rtmutex
  * is not yet visible to other tasks.
  */
-void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
+void __rt_mutex_init_proxy_locked(struct rt_mutex *lock,
+   const char *name,
+   struct lock_class_key *key,
struct task_struct *proxy_owner)
 {
-   __rt_mutex_init(lock, NULL, NULL);
+   __rt_mutex_init(lock, name, key);
debug_rt_mutex_proxy_lock(lock, proxy_owner);
rt_mutex_set_owner(lock, proxy_owner);
 }
diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h
index 72ad45a9a794..110dc1ed1e89 100644
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -100,8 +100,16 @@ enum rtmutex_chainwalk {
  * PI-futex support (proxy locking functions, etc.):
  */
 extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
-extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
-  struct task_struct *proxy_owner);
+extern void __rt_mutex_init_proxy_locked(struct rt_mutex *lock,
+const char *name,
+struct lock_class_key *key,
+struct task_struct *proxy_owner);
+#define rt_mutex_init_proxy_locked(lock, proxy_owner) \
+do { \
+   static struct lock_class_key __key; \
+   __rt_mutex_init_proxy_locked(lock, #lock, &__key, proxy_owner); \
+} while (0)
+
 extern void rt_mutex_proxy_unlock(struct rt_mutex *lock,
  struct task_struct *proxy_owner);
 extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter);
-- 
2.11.0


Re: [PATCH] nohz: Fix spurious warning when hrtimer and clockevent get out of sync

2017-06-09 Thread Levin, Alexander (Sasha Levin)
On Fri, Jun 09, 2017 at 02:48:57AM +0200, Frederic Weisbecker wrote:
> On Thu, Jun 08, 2017 at 10:13:38PM +0000, Levin, Alexander (Sasha Levin) 
> wrote:
> > On Thu, Jun 08, 2017 at 09:07:05PM +0200, Frederic Weisbecker wrote:
> > > Awesome, these traces have been very helpful! So now I think I get what's 
> > > going on.
> > > Can you please test the following fix?
> > 
> > With the patch, I hit the warning early on boot:
> > 
> > [1.423727] clocksource: Switched to clocksource kvm-clock
> > [1.429326] [ cut here ]
> > [1.430234] WARNING: CPU: 1 PID: 0 at kernel/time/tick-sched.c:792 
> > __tick_nohz_idle_enter+0xe1c/0x15c0
> 
> Oh sorry, I inverted some conditional. It warns as soon as the tick is 
> completely stopped
> and not just deferred, which seldom happen on my testbox.
> 
> I need to learn programming again.
> 
> Here is the fixed version:

These warnings seem to have gone away, but I've started seeing a new one:

[ cut here ]
WARNING: CPU: 0 PID: 12525 at kernel/time/hrtimer.c:805 
hrtimer_forward+0x222/0x3e0 kernel/time/hrtimer.c:805
Kernel panic - not syncing: panic_on_warn set ...

CPU: 0 PID: 12525 Comm: syz-executor7 Not tainted 4.12.0-rc4-next-20170608+ #87
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 
04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x100/0x189 lib/dump_stack.c:52
 panic+0x1dd/0x489 kernel/panic.c:180
 __warn+0x1d3/0x220 kernel/panic.c:541
 report_bug+0x1fa/0x2b0 lib/bug.c:183
 fixup_bug arch/x86/kernel/traps.c:190 [inline]
 do_trap_no_signal arch/x86/kernel/traps.c:224 [inline]
 do_trap+0x3c4/0x500 arch/x86/kernel/traps.c:273
 do_error_trap+0x12f/0x240 arch/x86/kernel/traps.c:310
 do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:323
 invalid_op+0x1e/0x30 arch/x86/entry/entry_64.S:844
RIP: 0010:hrtimer_forward+0x222/0x3e0 kernel/time/hrtimer.c:805
RSP: 0018:880064a77b58 EFLAGS: 00010086
RAX: 0001 RBX: 88003b35d4b8 RCX: 0017
RDX: 11000766ba9e RSI: 14c6502d37db1b49 RDI: 88003b35d4f0
RBP: 880064a77ba8 R08: 14c6502d37db1b49 R09: 88007ffd7008
R10: 88007ffd7010 R11: 0001 R12: 001f39eeff61
R13: 14c6502d37db1b49 R14: 14c6500dfdec1be8 R15: 
 common_hrtimer_forward+0x50/0x70 kernel/time/posix-timers.c:621
 common_timer_get+0x25a/0x690 kernel/time/posix-timers.c:674
 common_timer_set+0x63/0x580 kernel/time/posix-timers.c:779
 SYSC_timer_settime+0x1e4/0x370 kernel/time/posix-timers.c:840
 SyS_timer_settime+0x2c/0x40 kernel/time/posix-timers.c:809
 do_syscall_64+0x1c1/0x5c0 arch/x86/entry/common.c:284
 entry_SYSCALL64_slow_path+0x25/0x25
RIP: 0033:0x451429
RSP: 002b:7f8ab906cc08 EFLAGS: 0216 ORIG_RAX: 00df
RAX: ffda RBX:  RCX: 00451429
RDX: 20002000 RSI:  RDI: 
RBP: 007180a8 R08:  R09: 
R10: 2fe0 R11: 0216 R12: 
R13:  R14: 05b9 R15: 7f8ab906d700
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: 0x1de0 from 0x8100 (relocation range: 
0x8000-0xbfff)
Rebooting in 86400 seconds..

I'm not 100% sure it's related, but that WARN isn't in any new code.

-- 

Thanks,
Sasha

Re: [PATCH v2 00/10] PCID and improved laziness

2017-06-18 Thread Levin, Alexander (Sasha Levin)
On Tue, Jun 13, 2017 at 09:56:18PM -0700, Andy Lutomirski wrote:
>There are three performance benefits here:
>
>1. TLB flushing is slow.  (I.e. the flush itself takes a while.)
>   This avoids many of them when switching tasks by using PCID.  In
>   a stupid little benchmark I did, it saves about 100ns on my laptop
>   per context switch.  I'll try to improve that benchmark.
>
>2. Mms that have been used recently on a given CPU might get to keep
>   their TLB entries alive across process switches with this patch
>   set.  TLB fills are pretty fast on modern CPUs, but they're even
>   faster when they don't happen.
>
>3. Lazy TLB is way better.  We used to do two stupid things when we
>   ran kernel threads: we'd send IPIs to flush user contexts on their
>   CPUs and then we'd write to CR3 for no particular reason as an excuse
>   to stop further IPIs.  With this patch, we do neither.
>
>This will, in general, perform suboptimally if paravirt TLB flushing
>is in use (currently just Xen, I think, but Hyper-V is in the works).
>The code is structured so we could fix it in one of two ways: we
>could take a spinlock when touching the percpu state so we can update
>it remotely after a paravirt flush, or we could be more careful about
>our exactly how we access the state and use cmpxchg16b to do atomic
>remote updates.  (On SMP systems without cmpxchg16b, we'd just skip
>the optimization entirely.)

Hey Andy,

I've started seeing the following in -next:

[ cut here ]
kernel BUG at arch/x86/mm/tlb.c:47!
invalid opcode:  [#1] PREEMPT SMP DEBUG_PAGEALLOC KASAN
Dumping ftrace buffer:
   (ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 5302 Comm: kworker/u9:1 Not tainted 4.12.0-rc5+ #142
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 
04/01/2014
Workqueue: writeback wb_workfn (flush-259:0)
task: 880030ad0040 task.stack: 880036e78000
RIP: 0010:leave_mm+0x33/0x40 arch/x86/mm/tlb.c:50
RSP: 0018:880036e7d4c8 EFLAGS: 00010246
RAX: 0001 RBX: 88006a65e240 RCX: dc00
RDX:  RSI: b1475fa0 RDI: 
RBP: 880036e7d638 R08: 110006dcfad1 R09: 880030ad0040
R10: 880036e7d3b8 R11:  R12: 110006dcfa9e
R13: 880036e7d6c0 R14: 880036e7d680 R15: 
FS:  () GS:88003ea0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 00c420019318 CR3: 47a28000 CR4: 000406f0
Call Trace:
 flush_tlb_func_local arch/x86/mm/tlb.c:239 [inline]
 flush_tlb_mm_range+0x26d/0x370 arch/x86/mm/tlb.c:317
 flush_tlb_page arch/x86/include/asm/tlbflush.h:253 [inline]
 ptep_clear_flush+0xd5/0x110 mm/pgtable-generic.c:86
 page_mkclean_one+0x242/0x540 mm/rmap.c:867
 rmap_walk_file+0x5e3/0xd20 mm/rmap.c:1681
 rmap_walk+0x1cd/0x2f0 mm/rmap.c:1699
 page_mkclean+0x2a0/0x380 mm/rmap.c:928
 clear_page_dirty_for_io+0x37e/0x9d0 mm/page-writeback.c:2703
 mpage_submit_page+0x77/0x230 fs/ext4/inode.c:2131
 mpage_process_page_bufs+0x427/0x500 fs/ext4/inode.c:2261
 mpage_prepare_extent_to_map+0x78d/0xcf0 fs/ext4/inode.c:2638
 ext4_writepages+0x13be/0x3dd0 fs/ext4/inode.c:2784
 do_writepages+0xff/0x170 mm/page-writeback.c:2357
 __writeback_single_inode+0x1d9/0x1480 fs/fs-writeback.c:1319
 writeback_sb_inodes+0x6e2/0x1260 fs/fs-writeback.c:1583
 wb_writeback+0x45d/0xed0 fs/fs-writeback.c:1759
 wb_do_writeback fs/fs-writeback.c:1891 [inline]
 wb_workfn+0x2b5/0x1460 fs/fs-writeback.c:1927
 process_one_work+0xbfa/0x1d30 kernel/workqueue.c:2097
 worker_thread+0x221/0x1860 kernel/workqueue.c:2231
 kthread+0x35f/0x430 kernel/kthread.c:231
 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:425
Code: 48 3d 80 96 f8 b1 74 22 65 8b 05 f1 42 8c 53 83 f8 01 74 17 55 31 d2 48 
c7 c6 80 96 f8 b1 31 ff 48 89 e5 e8 60 ff ff ff 5d c3 c3 <0f> 0b 90 66 2e 0f 1f 
84 00 00 00 00 00 48 c7 c0 b4 10 73 b2 55 
RIP: leave_mm+0x33/0x40 arch/x86/mm/tlb.c:50 RSP: 880036e7d4c8
---[ end trace 3b5d5a6fb6e394f8 ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
   (ftrace buffer empty)
Kernel Offset: 0x2b80 from 0x8100 (relocation range: 
0x8000-0xbfff)
Rebooting in 86400 seconds..

Don't really have an easy way to reproduce it...

-- 

Thanks,
Sasha

Re: [PATCH] rt_mutex: correctly initialize lockdep in rt_mutex_init_proxy_locked

2017-06-11 Thread Levin, Alexander (Sasha Levin)
On Sat, Jun 10, 2017 at 04:02:12PM +0200, Peter Zijlstra wrote:
> On Sat, Jun 10, 2017 at 02:48:04AM +0000, Levin, Alexander (Sasha Levin) 
> wrote:
> > lockdep can't deal with NULL name or key, and doesn't do anything
> > with the lock when that happens.
> 
> Not doing anything is 'right', the proxy stuff won't be lockdep tracked
> anyway. But yeah, the first thing is a wee bit of a problem, for it will
> trigger DEBUG_LOCKS_WARN_ON() and fully kill lockdep.

But don't we want pi_state->pi_mutex tracked by lockdep?

> Yeah, no need to do that; all we really need here is something like:
> 
> ---
>  kernel/locking/rtmutex-debug.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/locking/rtmutex-debug.c b/kernel/locking/rtmutex-debug.c
> index ac35e648b0e5..8dc647dc4b4b 100644
> --- a/kernel/locking/rtmutex-debug.c
> +++ b/kernel/locking/rtmutex-debug.c
> @@ -175,7 +175,8 @@ void debug_rt_mutex_init(struct rt_mutex *lock, const 
> char *name, struct lock_cl
>   lock->name = name;
>  
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
> - lockdep_init_map(>dep_map, name, key, 0);
> + if (name && key)
> + lockdep_init_map(>dep_map, name, key, 0);
>  #endif
>  }

I didn't want to do that because in later calls on that mutex we
will end up going into lockdep code, and I didn't think that doing
that without calling lockdep_init_map() initially was safe.

-- 

Thanks,
Sasha

[PATCH] rt_mutex: don't initialize lockdep when not required

2017-06-18 Thread Levin, Alexander (Sasha Levin)
pi_mutex isn't supposed to be tracked by lockdep, but just
passing NULLs for name and key will cause lockdep to spew a
warning and die, which is not what we want it to do.

Skip lockdep initialization if the caller passed NULLs for
name and key, suggesting such initialization isn't desired.

Fixes: f5694788ad8d ("rt_mutex: Add lockdep annotations")
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sasha Levin 
---
 kernel/locking/rtmutex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 43123533e9b1..78069895032a 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1661,7 +1661,8 @@ void __rt_mutex_init(struct rt_mutex *lock, const char 
*name,
lock->waiters = RB_ROOT;
lock->waiters_leftmost = NULL;
 
-   debug_rt_mutex_init(lock, name, key);
+   if (name && key)
+   debug_rt_mutex_init(lock, name, key);
 }
 EXPORT_SYMBOL_GPL(__rt_mutex_init);
 
-- 
2.11.0


[PATCH for 4.9 44/59] pinctrl: mvebu: Use seq_puts() in mvebu_pinconf_group_dbg_show()

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Markus Elfring 

[ Upstream commit 420dc61642920849d824a0de2aa853db59f5244f ]

Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
Signed-off-by: Linus Walleij 
Signed-off-by: Sasha Levin 
---
 drivers/pinctrl/mvebu/pinctrl-mvebu.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c 
b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index b6ec6db78351..ac8a2ab9b35e 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -195,11 +195,12 @@ static void mvebu_pinconf_group_dbg_show(struct 
pinctrl_dev *pctldev,
seq_printf(s, "o");
seq_printf(s, ")");
}
-   } else
-   seq_printf(s, "current: UNKNOWN");
+   } else {
+   seq_puts(s, "current: UNKNOWN");
+   }
 
if (grp->num_settings > 1) {
-   seq_printf(s, ", available = [");
+   seq_puts(s, ", available = [");
for (n = 0; n < grp->num_settings; n++) {
if (curr == >settings[n])
continue;
@@ -222,7 +223,7 @@ static void mvebu_pinconf_group_dbg_show(struct pinctrl_dev 
*pctldev,
seq_printf(s, ")");
}
}
-   seq_printf(s, " ]");
+   seq_puts(s, " ]");
}
return;
 }
-- 
2.11.0


[PATCH for 4.9 29/59] IB/rxe: Add a runtime check in alloc_index()

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Bart Van Assche 

[ Upstream commit 642c7cbcaf2ffc1e27f67eda3dc47347ac5aff37 ]

Since index values equal to or above 'range' can trigger memory
corruption, complain if index >= range.

Signed-off-by: Bart Van Assche 
Reviewed-by: Andrew Boyer 
Cc: Moni Shoua 
Signed-off-by: Doug Ledford 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c 
b/drivers/infiniband/sw/rxe/rxe_pool.c
index 6bac0717c540..ee26a1b1b4ed 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -274,6 +274,7 @@ static u32 alloc_index(struct rxe_pool *pool)
if (index >= range)
index = find_first_zero_bit(pool->table, range);
 
+   WARN_ON_ONCE(index >= range);
set_bit(index, pool->table);
pool->last = index;
return index + pool->min_index;
-- 
2.11.0


[PATCH for 4.9 50/59] iommu/arm-smmu: Set privileged attribute to 'default' instead of 'unprivileged'

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Sricharan R 

[ Upstream commit e19898077cfb642fe151ba22981e795c74d9e114 ]

Currently the driver sets all the device transactions privileges
to UNPRIVILEGED, but there are cases where the iommu masters wants
to isolate privileged supervisor and unprivileged user.
So don't override the privileged setting to unprivileged, instead
set it to default as incoming and let it be controlled by the pagetable
settings.

Acked-by: Will Deacon 
Signed-off-by: Sricharan R 
Signed-off-by: Will Deacon 
Signed-off-by: Sasha Levin 
---
 drivers/iommu/arm-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 8f7281444551..5a9a4416f467 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1211,7 +1211,7 @@ static int arm_smmu_domain_add_master(struct 
arm_smmu_domain *smmu_domain,
continue;
 
s2cr[idx].type = type;
-   s2cr[idx].privcfg = S2CR_PRIVCFG_UNPRIV;
+   s2cr[idx].privcfg = S2CR_PRIVCFG_DEFAULT;
s2cr[idx].cbndx = cbndx;
arm_smmu_write_s2cr(smmu, idx);
}
-- 
2.11.0


[PATCH for 4.9 52/59] rtl8xxxu: Add additional USB IDs for rtl8192eu devices

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Axel Köllhofer 

[ Upstream commit 5407fd7de69f3352aed659244d4bef18e3cabf5c ]

These IDs originate from the vendor driver

Signed-off-by: Axel Köllhofer 
Signed-off-by: Jes Sorensen 
Signed-off-by: Kalle Valo 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 82d949ede294..4e725d165aa6 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6316,6 +6316,13 @@ static struct usb_device_id dev_table[] = {
.driver_info = (unsigned long)_fops},
 {USB_DEVICE_AND_INTERFACE_INFO(0x7392, 0x7822, 0xff, 0xff, 0xff),
.driver_info = (unsigned long)_fops},
+/* found in rtl8192eu vendor driver */
+{USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0107, 0xff, 0xff, 0xff),
+   .driver_info = (unsigned long)_fops},
+{USB_DEVICE_AND_INTERFACE_INFO(0x2019, 0xab33, 0xff, 0xff, 0xff),
+   .driver_info = (unsigned long)_fops},
+{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x818c, 0xff, 0xff, 
0xff),
+   .driver_info = (unsigned long)_fops},
 #endif
 { }
 };
-- 
2.11.0


[PATCH for 4.9 32/59] drm/i915/psr: disable psr2 for resolution greater than 32X20

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: "Nagaraju, Vathsala" 

[ Upstream commit acf45d11050abd751dcec986ab121cb2367dcbba ]

PSR2 is restricted to work with panel resolutions upto 3200x2000,
move the check to intel_psr_match_conditions and fully block psr.

Cc: Rodrigo Vivi 
Cc: Jim Bride 
Suggested-by: Rodrigo Vivi 
Signed-off-by: Vathsala Nagaraju 
Reviewed-by: Rodrigo Vivi 
Signed-off-by: Rodrigo Vivi 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1484031746-20874-1-git-send-email-vathsala.nagar...@intel.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/i915/intel_psr.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c
index 9b307cee3008..dff478498f05 100644
--- a/drivers/gpu/drm/i915/intel_psr.c
+++ b/drivers/gpu/drm/i915/intel_psr.c
@@ -387,6 +387,13 @@ static bool intel_psr_match_conditions(struct intel_dp 
*intel_dp)
return false;
}
 
+   /* PSR2 is restricted to work with panel resolutions upto 3200x2000 */
+   if (intel_crtc->config->pipe_src_w > 3200 ||
+   intel_crtc->config->pipe_src_h > 2000) {
+   dev_priv->psr.psr2_support = false;
+   return false;
+   }
+
dev_priv->psr.source_ok = true;
return true;
 }
@@ -425,7 +432,6 @@ void intel_psr_enable(struct intel_dp *intel_dp)
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
struct drm_device *dev = intel_dig_port->base.base.dev;
struct drm_i915_private *dev_priv = to_i915(dev);
-   struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
 
if (!HAS_PSR(dev)) {
DRM_DEBUG_KMS("PSR not supported on this platform\n");
@@ -452,12 +458,7 @@ void intel_psr_enable(struct intel_dp *intel_dp)
hsw_psr_setup_vsc(intel_dp);
 
if (dev_priv->psr.psr2_support) {
-   /* PSR2 is restricted to work with panel resolutions 
upto 3200x2000 */
-   if (crtc->config->pipe_src_w > 3200 ||
-   crtc->config->pipe_src_h > 2000)
-   dev_priv->psr.psr2_support = false;
-   else
-   skl_psr_setup_su_vsc(intel_dp);
+   skl_psr_setup_su_vsc(intel_dp);
}
 
/*
-- 
2.11.0


[PATCH for 4.9 30/59] IB/rxe: Fix a MR reference leak in check_rkey()

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Bart Van Assche 

[ Upstream commit b3a459961014b14c267544c327db033669493295 ]

Avoid that calling check_rkey() for mem->state == RXE_MEM_STATE_FREE
triggers an MR reference leak.

Signed-off-by: Bart Van Assche 
Reviewed-by: Andrew Boyer 
Cc: Moni Shoua 
Signed-off-by: Doug Ledford 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/sw/rxe/rxe_resp.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c 
b/drivers/infiniband/sw/rxe/rxe_resp.c
index ccf624763565..69ed4e0d7a0d 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -418,7 +418,7 @@ static enum resp_states check_length(struct rxe_qp *qp,
 static enum resp_states check_rkey(struct rxe_qp *qp,
   struct rxe_pkt_info *pkt)
 {
-   struct rxe_mem *mem;
+   struct rxe_mem *mem = NULL;
u64 va;
u32 rkey;
u32 resid;
@@ -452,38 +452,38 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
mem = lookup_mem(qp->pd, access, rkey, lookup_remote);
if (!mem) {
state = RESPST_ERR_RKEY_VIOLATION;
-   goto err1;
+   goto err;
}
 
if (unlikely(mem->state == RXE_MEM_STATE_FREE)) {
state = RESPST_ERR_RKEY_VIOLATION;
-   goto err1;
+   goto err;
}
 
if (mem_check_range(mem, va, resid)) {
state = RESPST_ERR_RKEY_VIOLATION;
-   goto err2;
+   goto err;
}
 
if (pkt->mask & RXE_WRITE_MASK)  {
if (resid > mtu) {
if (pktlen != mtu || bth_pad(pkt)) {
state = RESPST_ERR_LENGTH;
-   goto err2;
+   goto err;
}
 
qp->resp.resid = mtu;
} else {
if (pktlen != resid) {
state = RESPST_ERR_LENGTH;
-   goto err2;
+   goto err;
}
if ((bth_pad(pkt) != (0x3 & (-resid {
/* This case may not be exactly that
 * but nothing else fits.
 */
state = RESPST_ERR_LENGTH;
-   goto err2;
+   goto err;
}
}
}
@@ -493,9 +493,9 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
qp->resp.mr = mem;
return RESPST_EXECUTE;
 
-err2:
-   rxe_drop_ref(mem);
-err1:
+err:
+   if (mem)
+   rxe_drop_ref(mem);
return state;
 }
 
-- 
2.11.0


[PATCH for 4.9 54/59] drm: mali-dp: Fix destination size handling when rotating

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Brian Starkey 

[ Upstream commit edabb3c4cd2d035bc93a3d67b25a304ea6217301 ]

The destination rectangle provided by userspace in the CRTC_X/Y/W/H
properties is already expressed as the dimensions after rotation.
This means we shouldn't swap the width and height ourselves when a
90/270 degree rotation is requested, so remove the code doing the swap.

Fixes: ad49f8602fe8 ("drm/arm: Add support for Mali Display Processors")

Signed-off-by: Brian Starkey 
Signed-off-by: Liviu Dudau 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/arm/malidp_planes.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 82c193e5e0d6..a6bdd91d6c9e 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -150,13 +150,8 @@ static void malidp_de_plane_update(struct drm_plane *plane,
/* convert src values from Q16 fixed point to integer */
src_w = plane->state->src_w >> 16;
src_h = plane->state->src_h >> 16;
-   if (plane->state->rotation & MALIDP_ROTATED_MASK) {
-   dest_w = plane->state->crtc_h;
-   dest_h = plane->state->crtc_w;
-   } else {
-   dest_w = plane->state->crtc_w;
-   dest_h = plane->state->crtc_h;
-   }
+   dest_w = plane->state->crtc_w;
+   dest_h = plane->state->crtc_h;
 
malidp_hw_write(mp->hwdev, format_id, mp->layer->base);
 
-- 
2.11.0


[PATCH for 4.9 58/59] mips: ath79: clock:- Unmap region obtained by of_iomap

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Arvind Yadav 

[ Upstream commit b3d91db3f71d5f70ea60d900425a3f96aeb3d065 ]

Free memory mapping, if ath79_clocks_init_dt_ng is not successful.

Signed-off-by: Arvind Yadav 
Fixes: 3bdf1071ba7d ("MIPS: ath79: update devicetree clock support for AR9132")
Cc: antonynpav...@gmail.com
Cc: al...@free.fr
Cc: hackpas...@gmail.com
Cc: sb...@codeaurora.org
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14915/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/ath79/clock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c
index cc3a1e33a600..7e2bb12b64ea 100644
--- a/arch/mips/ath79/clock.c
+++ b/arch/mips/ath79/clock.c
@@ -508,16 +508,19 @@ static void __init ath79_clocks_init_dt_ng(struct 
device_node *np)
ar9330_clk_init(ref_clk, pll_base);
else {
pr_err("%s: could not find any appropriate clk_init()\n", dnfn);
-   goto err_clk;
+   goto err_iounmap;
}
 
if (of_clk_add_provider(np, of_clk_src_onecell_get, _data)) {
pr_err("%s: could not register clk provider\n", dnfn);
-   goto err_clk;
+   goto err_iounmap;
}
 
return;
 
+err_iounmap:
+   iounmap(pll_base);
+
 err_clk:
clk_put(ref_clk);
 
-- 
2.11.0


[PATCH for 4.9 47/59] audit: log 32-bit socketcalls

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Richard Guy Briggs 

[ Upstream commit 62bc306e2083436675e33b5bdeb6a77907d35971 ]

32-bit socketcalls were not being logged by audit on x86_64 systems.
Log them.  This is basically a duplicate of the call from
net/socket.c:sys_socketcall(), but it addresses the impedance mismatch
between 32-bit userspace process and 64-bit kernel audit.

See: https://github.com/linux-audit/audit-kernel/issues/14

Signed-off-by: Richard Guy Briggs 
Acked-by: David S. Miller 
Signed-off-by: Paul Moore 
Signed-off-by: Sasha Levin 
---
 include/linux/audit.h | 20 
 net/compat.c  | 17 ++---
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 9d4443f93db6..2be99b276d29 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -387,6 +387,20 @@ static inline int audit_socketcall(int nargs, unsigned 
long *args)
return __audit_socketcall(nargs, args);
return 0;
 }
+
+static inline int audit_socketcall_compat(int nargs, u32 *args)
+{
+   unsigned long a[AUDITSC_ARGS];
+   int i;
+
+   if (audit_dummy_context())
+   return 0;
+
+   for (i = 0; i < nargs; i++)
+   a[i] = (unsigned long)args[i];
+   return __audit_socketcall(nargs, a);
+}
+
 static inline int audit_sockaddr(int len, void *addr)
 {
if (unlikely(!audit_dummy_context()))
@@ -513,6 +527,12 @@ static inline int audit_socketcall(int nargs, unsigned 
long *args)
 {
return 0;
 }
+
+static inline int audit_socketcall_compat(int nargs, u32 *args)
+{
+   return 0;
+}
+
 static inline void audit_fd_pair(int fd1, int fd2)
 { }
 static inline int audit_sockaddr(int len, void *addr)
diff --git a/net/compat.c b/net/compat.c
index 1cd2ec046164..a96fd2f3507b 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -781,14 +782,24 @@ COMPAT_SYSCALL_DEFINE5(recvmmsg, int, fd, struct 
compat_mmsghdr __user *, mmsg,
 
 COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
 {
-   int ret;
-   u32 a[6];
+   u32 a[AUDITSC_ARGS];
+   unsigned int len;
u32 a0, a1;
+   int ret;
 
if (call < SYS_SOCKET || call > SYS_SENDMMSG)
return -EINVAL;
-   if (copy_from_user(a, args, nas[call]))
+   len = nas[call];
+   if (len > sizeof(a))
+   return -EINVAL;
+
+   if (copy_from_user(a, args, len))
return -EFAULT;
+
+   ret = audit_socketcall_compat(len / sizeof(a[0]), a);
+   if (ret)
+   return ret;
+
a0 = a[0];
a1 = a[1];
 
-- 
2.11.0


[PATCH for 4.9 42/59] USB: serial: mos7840: fix control-message error handling

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Johan Hovold 

[ Upstream commit cd8db057e93ddaacbec025b567490555d2bca280 ]

Make sure to detect short transfers when reading a device register.

The modem-status handling had sufficient error checks in place, but move
handling of short transfers into the register accessor function itself
for consistency.

Reviewed-by: Greg Kroah-Hartman 
Signed-off-by: Johan Hovold 
Signed-off-by: Sasha Levin 
---
 drivers/usb/serial/mos7840.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 5c4fc3abf6a7..6baacf64b21e 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -285,9 +285,15 @@ static int mos7840_get_reg_sync(struct usb_serial_port 
*port, __u16 reg,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
  MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
  MOS_WDR_TIMEOUT);
+   if (ret < VENDOR_READ_LENGTH) {
+   if (ret >= 0)
+   ret = -EIO;
+   goto out;
+   }
+
*val = buf[0];
dev_dbg(>dev, "%s offset is %x, return val %x\n", __func__, reg, 
*val);
-
+out:
kfree(buf);
return ret;
 }
@@ -353,8 +359,13 @@ static int mos7840_get_uart_reg(struct usb_serial_port 
*port, __u16 reg,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
  MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
  MOS_WDR_TIMEOUT);
+   if (ret < VENDOR_READ_LENGTH) {
+   if (ret >= 0)
+   ret = -EIO;
+   goto out;
+   }
*val = buf[0];
-
+out:
kfree(buf);
return ret;
 }
@@ -1490,10 +1501,10 @@ static int mos7840_tiocmget(struct tty_struct *tty)
return -ENODEV;
 
status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, );
-   if (status != 1)
+   if (status < 0)
return -EIO;
status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, );
-   if (status != 1)
+   if (status < 0)
return -EIO;
result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
| ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
-- 
2.11.0


[PATCH for 4.9 46/59] ASoC: dapm: handle probe deferrals

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Linus Walleij 

[ Upstream commit 37e1df8c95e2c8a57c77eafc097648f6e40a60ff ]

This starts to handle probe deferrals on regulators and clocks
on the ASoC DAPM.

I came to this patch after audio stopped working on Ux500 ages
ago and I finally looked into it to see what is wrong. I had
messages like this in the console since a while back:

ab8500-codec.0: ASoC: Failed to request audioclk: -517
ab8500-codec.0: ASoC: Failed to create DAPM control audioclk
ab8500-codec.0: Failed to create new controls -12
snd-soc-mop500.0: ASoC: failed to instantiate card -12
snd-soc-mop500.0: Error: snd_soc_register_card failed (-12)!
snd-soc-mop500: probe of snd-soc-mop500.0 failed with error -12

Apparently because the widget table for the codec looks like
this (sound/soc/codecs/ab8500-codec.c):

static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {

/* Clocks */
SND_SOC_DAPM_CLOCK_SUPPLY("audioclk"),

/* Regulators */
SND_SOC_DAPM_REGULATOR_SUPPLY("V-AUD", 0, 0),
SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC1", 0, 0),
SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC2", 0, 0),
SND_SOC_DAPM_REGULATOR_SUPPLY("V-DMIC", 0, 0),

So when we call snd_soc_register_codec() and any of these widgets
get a deferred probe we do not get an -EPROBE_DEFER (-517) back as
we should and instead we just fail. Apparently the code assumes
that clocks and regulators must be available at this point and
not defer.

After this patch it rather looks like this:

ab8500-codec.0: Failed to create new controls -517
snd-soc-mop500.0: ASoC: failed to instantiate card -517
snd-soc-mop500.0: Error: snd_soc_register_card failed (-517)!
(...)
abx500-clk.0: registered clocks for ab850x
snd-soc-mop500.0: ab8500-codec-dai.0 <-> ux500-msp-i2s.1 mapping ok
snd-soc-mop500.0: ab8500-codec-dai.1 <-> ux500-msp-i2s.3 mapping ok

I'm pretty happy about the patch as it it, but I'm a bit
uncertain on how to proceed: there are a lot of users of the
external functions snd_soc_dapm_new_control() (111 sites)
and that will now return an occassional error pointer, which
is not handled in the calling sites.

I want an indication from the maintainers whether I should just
go in and augment all these call sites, or if deferred probe
is frowned upon when it leads to this much overhead.

Signed-off-by: Linus Walleij 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-dapm.c | 42 ++
 sound/soc/soc-topology.c |  9 +
 2 files changed, 51 insertions(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 3bbe32ee4630..411f7574dd0b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -358,6 +358,10 @@ static int dapm_kcontrol_data_alloc(struct 
snd_soc_dapm_widget *widget,
snd_soc_dapm_new_control_unlocked(widget->dapm,
);
kfree(name);
+   if (IS_ERR(data->widget)) {
+   ret = PTR_ERR(data->widget);
+   goto err_data;
+   }
if (!data->widget) {
ret = -ENOMEM;
goto err_data;
@@ -392,6 +396,10 @@ static int dapm_kcontrol_data_alloc(struct 
snd_soc_dapm_widget *widget,
data->widget = snd_soc_dapm_new_control_unlocked(
widget->dapm, );
kfree(name);
+   if (IS_ERR(data->widget)) {
+   ret = PTR_ERR(data->widget);
+   goto err_data;
+   }
if (!data->widget) {
ret = -ENOMEM;
goto err_data;
@@ -3311,11 +3319,22 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context 
*dapm,
 
mutex_lock_nested(>card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
w = snd_soc_dapm_new_control_unlocked(dapm, widget);
+   /* Do not nag about probe deferrals */
+   if (IS_ERR(w)) {
+   int ret = PTR_ERR(w);
+
+   if (ret != -EPROBE_DEFER)
+   dev_err(dapm->dev,
+   "ASoC: Failed to create DAPM control %s (%d)\n",
+   widget->name, ret);
+   goto out_unlock;
+   }
if (!w)
dev_err(dapm->dev,
"ASoC: Failed to create DAPM control %s\n",
widget->name);
 
+out_unlock:
mutex_unlock(>card->dapm_mutex);
return w;
 }
@@ -3338,6 +3357,8 @@ snd_soc_dapm_new_control_unlocked(struct 
snd_soc_dapm_context *dapm,
w->regulator = devm_regulator_get(dapm->dev, w->name);
if (IS_ERR(w->regulator)) {
 

[PATCH for 4.9 51/59] usb: chipidea: vbus event may exist before starting gadget

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Peter Chen 

[ Upstream commit c3b674a04b8ab62a1d35e86714d466af0a0ecc18 ]

At some situations, the vbus may already be there before starting
gadget. So we need to check vbus event after switching to gadget in
order to handle missing vbus event. The typical use cases are plugging
vbus cable before driver load or the vbus has already been there
after stopping host but before starting gadget.

Signed-off-by: Peter Chen 
Tested-by: Stephen Boyd 
Reported-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/usb/chipidea/otg.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 0cf149e8..f36a1ac3bfbd 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -134,9 +134,9 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
if (!ci->is_otg)
return;
 
-   if (hw_read_otgsc(ci, OTGSC_BSV))
+   if (hw_read_otgsc(ci, OTGSC_BSV) && !ci->vbus_active)
usb_gadget_vbus_connect(>gadget);
-   else
+   else if (!hw_read_otgsc(ci, OTGSC_BSV) && ci->vbus_active)
usb_gadget_vbus_disconnect(>gadget);
 }
 
@@ -175,14 +175,21 @@ static void ci_handle_id_switch(struct ci_hdrc *ci)
 
ci_role_stop(ci);
 
-   if (role == CI_ROLE_GADGET)
+   if (role == CI_ROLE_GADGET &&
+   IS_ERR(ci->platdata->vbus_extcon.edev))
/*
-* wait vbus lower than OTGSC_BSV before connecting
-* to host
+* Wait vbus lower than OTGSC_BSV before connecting
+* to host. If connecting status is from an external
+* connector instead of register, we don't need to
+* care vbus on the board, since it will not affect
+* external connector status.
 */
hw_wait_vbus_lower_bsv(ci);
 
ci_role_start(ci, role);
+   /* vbus change may have already occurred */
+   if (role == CI_ROLE_GADGET)
+   ci_handle_vbus_change(ci);
}
 }
 /**
-- 
2.11.0


[PATCH for 4.9 13/59] MIPS: ralink: Fix a typo in the pinmux setup.

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: John Crispin 

[ Upstream commit 58181a117d353427127a2e7afc7cf1ab44759828 ]

There is a typo inside the pinmux setup code. The function is really
called utif and not util. This was recently discovered when people were
trying to make the UTIF interface work.

Signed-off-by: John Crispin 
Cc: linux-m...@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14899/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/ralink/mt7620.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c
index 3c7c9bf57bf3..6f892c1f3ad7 100644
--- a/arch/mips/ralink/mt7620.c
+++ b/arch/mips/ralink/mt7620.c
@@ -176,7 +176,7 @@ static struct rt2880_pmx_func spi_cs1_grp_mt7628[] = {
 
 static struct rt2880_pmx_func spis_grp_mt7628[] = {
FUNC("pwm_uart2", 3, 14, 4),
-   FUNC("util", 2, 14, 4),
+   FUNC("utif", 2, 14, 4),
FUNC("gpio", 1, 14, 4),
FUNC("spis", 0, 14, 4),
 };
@@ -190,28 +190,28 @@ static struct rt2880_pmx_func gpio_grp_mt7628[] = {
 
 static struct rt2880_pmx_func p4led_kn_grp_mt7628[] = {
FUNC("jtag", 3, 30, 1),
-   FUNC("util", 2, 30, 1),
+   FUNC("utif", 2, 30, 1),
FUNC("gpio", 1, 30, 1),
FUNC("p4led_kn", 0, 30, 1),
 };
 
 static struct rt2880_pmx_func p3led_kn_grp_mt7628[] = {
FUNC("jtag", 3, 31, 1),
-   FUNC("util", 2, 31, 1),
+   FUNC("utif", 2, 31, 1),
FUNC("gpio", 1, 31, 1),
FUNC("p3led_kn", 0, 31, 1),
 };
 
 static struct rt2880_pmx_func p2led_kn_grp_mt7628[] = {
FUNC("jtag", 3, 32, 1),
-   FUNC("util", 2, 32, 1),
+   FUNC("utif", 2, 32, 1),
FUNC("gpio", 1, 32, 1),
FUNC("p2led_kn", 0, 32, 1),
 };
 
 static struct rt2880_pmx_func p1led_kn_grp_mt7628[] = {
FUNC("jtag", 3, 33, 1),
-   FUNC("util", 2, 33, 1),
+   FUNC("utif", 2, 33, 1),
FUNC("gpio", 1, 33, 1),
FUNC("p1led_kn", 0, 33, 1),
 };
@@ -232,28 +232,28 @@ static struct rt2880_pmx_func wled_kn_grp_mt7628[] = {
 
 static struct rt2880_pmx_func p4led_an_grp_mt7628[] = {
FUNC("jtag", 3, 39, 1),
-   FUNC("util", 2, 39, 1),
+   FUNC("utif", 2, 39, 1),
FUNC("gpio", 1, 39, 1),
FUNC("p4led_an", 0, 39, 1),
 };
 
 static struct rt2880_pmx_func p3led_an_grp_mt7628[] = {
FUNC("jtag", 3, 40, 1),
-   FUNC("util", 2, 40, 1),
+   FUNC("utif", 2, 40, 1),
FUNC("gpio", 1, 40, 1),
FUNC("p3led_an", 0, 40, 1),
 };
 
 static struct rt2880_pmx_func p2led_an_grp_mt7628[] = {
FUNC("jtag", 3, 41, 1),
-   FUNC("util", 2, 41, 1),
+   FUNC("utif", 2, 41, 1),
FUNC("gpio", 1, 41, 1),
FUNC("p2led_an", 0, 41, 1),
 };
 
 static struct rt2880_pmx_func p1led_an_grp_mt7628[] = {
FUNC("jtag", 3, 42, 1),
-   FUNC("util", 2, 42, 1),
+   FUNC("utif", 2, 42, 1),
FUNC("gpio", 1, 42, 1),
FUNC("p1led_an", 0, 42, 1),
 };
-- 
2.11.0


[PATCH for 4.9 22/59] clk/axs10x: Clear init field in driver probe

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Jose Abreu 

[ Upstream commit 6205406cf6f282d622f31de25036e6d1ab3a2ff5 ]

Init field must be cleared in driver probe as this structure is not
dinamically allocated. If not, wrong flags can be passed to core.

Signed-off-by: Jose Abreu 
Cc: Carlos Palminha 
Cc: Stephen Boyd 
Cc: Michael Turquette 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 923587aafc2c ("clk/axs10x: Add I2S PLL clock driver")
Signed-off-by: Michael Turquette 
Link: 
lkml.kernel.org/r/040cc9afdfa0e95ce7a01c406ff427ef7dc0c0fd.1481540717.git.joab...@synopsys.com
Signed-off-by: Sasha Levin 
---
 drivers/clk/axs10x/i2s_pll_clock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/axs10x/i2s_pll_clock.c 
b/drivers/clk/axs10x/i2s_pll_clock.c
index 411310d29581..02d3bcd6216c 100644
--- a/drivers/clk/axs10x/i2s_pll_clock.c
+++ b/drivers/clk/axs10x/i2s_pll_clock.c
@@ -182,6 +182,7 @@ static int i2s_pll_clk_probe(struct platform_device *pdev)
if (IS_ERR(pll_clk->base))
return PTR_ERR(pll_clk->base);
 
+   memset(, 0, sizeof(init));
clk_name = node->name;
init.name = clk_name;
init.ops = _pll_ops;
-- 
2.11.0


[PATCH for 4.9 17/59] ARM: dts: am335x-chilisom: Wakeup from RTC-only state by power on event

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Marcin Niestroj 

[ Upstream commit ca244a83ecc7f0a9242ee2116e622cb6d7ec2a90 ]

On chiliSOM TPS65217 nWAKEUP pin is connected to AM335x internal RTC
EXT_WAKEUP input. In RTC-only state TPS65217 is notifying about power on
events (such as power buton presses) by setting nWAKEUP output
low. After that it waits 5s for proper device boot. Currently it doesn't
happen, as the processor doesn't listen for such events. Consequently
TPS65217 changes state from SLEEP (RTC-only state) to OFF.

Enable EXT_WAKEUP input of AM335x's RTC, so the processor can properly
detect power on events and recover immediately from RTC-only states,
without powering off RTC and losing time.

Signed-off-by: Marcin Niestroj 
Signed-off-by: Tony Lindgren 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/am335x-chilisom.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-chilisom.dtsi 
b/arch/arm/boot/dts/am335x-chilisom.dtsi
index f9ee5859c154..1b43ebd08b38 100644
--- a/arch/arm/boot/dts/am335x-chilisom.dtsi
+++ b/arch/arm/boot/dts/am335x-chilisom.dtsi
@@ -124,6 +124,14 @@
 
  {
system-power-controller;
+
+   pinctrl-0 = <_wakeup>;
+   pinctrl-names = "default";
+
+   ext_wakeup: ext-wakeup {
+   pins = "ext_wakeup0";
+   input-enable;
+   };
 };
 
 /* NAND Flash */
-- 
2.11.0


[PATCH for 4.9 19/59] extcon: axp288: Use vbus-valid instead of -present to determine cable presence

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Hans de Goede 

[ Upstream commit 5757aca10146061befd168dab37fb0db1ccd8f73 ]

The vbus-present bit in the power status register also gets set to 1
when a usb-host cable (id-pin shorted to ground) is plugged in and a 5v
boost converter is supplying 5v to the otg usb bus.

This causes a "disconnect or unknown or ID event" warning in dmesg as
well as the extcon device to report the last detected charger cable
type as being connected even though none is connected.

This commit switches to checking the vbus-valid bit instead, which is
only 1 when both vbus is present and the vbus-path is enabled in the
vbus-path control register (the vbus-path gets disabled when a usb-host
cable is detected, to avoid the pmic drawing power from the 5v boost
converter).

Signed-off-by: Hans de Goede 
Acked-by: Chanwoo Choi 
Signed-off-by: Chanwoo Choi 
Signed-off-by: Sasha Levin 
---
 drivers/extcon/extcon-axp288.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 42f41e808292..27f67c28e700 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -168,7 +168,7 @@ static int axp288_handle_chrg_det_event(struct 
axp288_extcon_info *info)
return ret;
}
 
-   vbus_attach = (pwr_stat & PS_STAT_VBUS_PRESENT);
+   vbus_attach = (pwr_stat & PS_STAT_VBUS_VALID);
if (!vbus_attach)
goto notify_otg;
 
-- 
2.11.0


[PATCH for 4.9 01/59] drm_fourcc: Fix DRM_FORMAT_MOD_LINEAR #define

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: "Kristian H. Kristensen" 

[ Upstream commit af913418261d6d3e7a29f06cf35f04610ead667c ]

We need to define DRM_FORMAT_MOD_VENDOR_NONE for the fourcc_mod_code()
macro to work correctly.

Signed-off-by: Kristian H. Kristensen 
Signed-off-by: Daniel Vetter 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1481657272-25975-1-git-send-email-hoegsb...@google.com
Signed-off-by: Sasha Levin 
---
 include/uapi/drm/drm_fourcc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index a5890bf44c0a..d1601a621929 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -154,6 +154,7 @@ extern "C" {
 
 /* Vendor Ids: */
 #define DRM_FORMAT_MOD_NONE   0
+#define DRM_FORMAT_MOD_VENDOR_NONE0
 #define DRM_FORMAT_MOD_VENDOR_INTEL   0x01
 #define DRM_FORMAT_MOD_VENDOR_AMD 0x02
 #define DRM_FORMAT_MOD_VENDOR_NV  0x03
-- 
2.11.0


[PATCH for 4.9 18/59] igb: re-assign hw address pointer on reset after PCI error

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Guilherme G Piccoli 

[ Upstream commit 69b97cf6dbce7403845a28bbc75d57f5be7b12ac ]

Whenever the igb driver detects the result of a read operation returns
a value composed only by F's (like 0x), it will detach the
net_device, clear the hw_addr pointer and warn to the user that adapter's
link is lost - those steps happen on igb_rd32().

In case a PCI error happens on Power architecture, there's a recovery
mechanism called EEH, that will reset the PCI slot and call driver's
handlers to reset the adapter and network functionality as well.

We observed that once hw_addr is NULL after the error is detected on
igb_rd32(), it's never assigned back, so in the process of resetting
the network functionality we got a NULL pointer dereference in both
igb_configure_tx_ring() and igb_configure_rx_ring(). In order to avoid
such bug, this patch re-assigns the hw_addr value in the slot_reset
handler.

Reported-by: Anthony H Thai 
Reported-by: Harsha Thyagaraja 
Signed-off-by: Guilherme G Piccoli 
Tested-by: Aaron Brown 
Signed-off-by: Jeff Kirsher 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/igb/igb_main.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 9affd7c198bd..6a62447fe377 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7882,6 +7882,11 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev 
*pdev)
pci_enable_wake(pdev, PCI_D3hot, 0);
pci_enable_wake(pdev, PCI_D3cold, 0);
 
+   /* In case of PCI error, adapter lose its HW address
+* so we should re-assign it here.
+*/
+   hw->hw_addr = adapter->io_addr;
+
igb_reset(adapter);
wr32(E1000_WUS, ~0);
result = PCI_ERS_RESULT_RECOVERED;
-- 
2.11.0


[PATCH for 4.9 40/59] drm/amdkfd: fix improper return value on error

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Pan Bian 

[ Upstream commit 8bf793883da213864efc50c274d2b38ec0ca58b2 ]

In function kfd_wait_on_events(), when the call to copy_from_user()
fails, the value of return variable ret is 0. 0 indicates success, which
is inconsistent with the execution status. This patch fixes the bug by
assigning "-EFAULT" to ret when copy_from_user() returns an unexpected
value.

Signed-off-by: Pan Bian 
Signed-off-by: Oded Gabbay 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
index a6a4b2b1c0d9..6a3470f84998 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
@@ -739,8 +739,10 @@ int kfd_wait_on_events(struct kfd_process *p,
struct kfd_event_data event_data;
 
if (copy_from_user(_data, [i],
-   sizeof(struct kfd_event_data)))
+   sizeof(struct kfd_event_data))) {
+   ret = -EFAULT;
goto fail;
+   }
 
ret = init_event_waiter(p, _waiters[i],
event_data.event_id, i);
-- 
2.11.0


[PATCH for 4.9 34/59] tty: goldfish: Fix a parameter of a call to free_irq

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Christophe JAILLET 

[ Upstream commit 1a5c2d1de7d35f5eb9793266237903348989502b ]

'request_irq()' and 'free_irq()' should be called with the same dev_id.

Signed-off-by: Christophe JAILLET 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/tty/goldfish.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 3fc912373adf..996bd473dd03 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -300,7 +300,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
return 0;
 
 err_tty_register_device_failed:
-   free_irq(irq, pdev);
+   free_irq(irq, qtty);
 err_request_irq_failed:
goldfish_tty_current_line_count--;
if (goldfish_tty_current_line_count == 0)
-- 
2.11.0


[PATCH for 4.9 33/59] serial: 8250: moxa: Store num_ports in brd

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: "Matwey V. Kornilov" 

[ Upstream commit 9c4b60fe5313c125b1bf68ef04b0010512c27f2d ]

When struct moxa8250_board is allocated, then num_ports should
be initialized in order to use it later in moxa8250_remove.

Signed-off-by: Matwey V. Kornilov 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/tty/serial/8250/8250_moxa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/8250/8250_moxa.c 
b/drivers/tty/serial/8250/8250_moxa.c
index 26eb5393a263..d5069b2d4d79 100644
--- a/drivers/tty/serial/8250/8250_moxa.c
+++ b/drivers/tty/serial/8250/8250_moxa.c
@@ -68,6 +68,7 @@ static int moxa8250_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
   sizeof(unsigned int) * nr_ports, GFP_KERNEL);
if (!brd)
return -ENOMEM;
+   brd->num_ports = nr_ports;
 
memset(, 0, sizeof(struct uart_8250_port));
 
-- 
2.11.0


[PATCH for 4.9 39/59] arm: dts: mt2701: Add subsystem clock controller device nodes

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: James Liao 

[ Upstream commit f235c7e7a75325f28a33559a71f25a0eca6112db ]

Add MT2701 subsystem clock controllers, inlcude mmsys, imgsys,
vdecsys, hifsys, ethsys and bdpsys.

Signed-off-by: James Liao 
Signed-off-by: Matthias Brugger 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/mt2701.dtsi | 36 
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index 18596a2c58a1..77c6b931dc24 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -174,4 +174,40 @@
clocks = <_clk>;
status = "disabled";
};
+
+   mmsys: syscon@1400 {
+   compatible = "mediatek,mt2701-mmsys", "syscon";
+   reg = <0 0x1400 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   imgsys: syscon@1500 {
+   compatible = "mediatek,mt2701-imgsys", "syscon";
+   reg = <0 0x1500 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   vdecsys: syscon@1600 {
+   compatible = "mediatek,mt2701-vdecsys", "syscon";
+   reg = <0 0x1600 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   hifsys: syscon@1a00 {
+   compatible = "mediatek,mt2701-hifsys", "syscon";
+   reg = <0 0x1a00 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   ethsys: syscon@1b00 {
+   compatible = "mediatek,mt2701-ethsys", "syscon";
+   reg = <0 0x1b00 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   bdpsys: syscon@1c00 {
+   compatible = "mediatek,mt2701-bdpsys", "syscon";
+   reg = <0 0x1c00 0 0x1000>;
+   #clock-cells = <1>;
+   };
 };
-- 
2.11.0


[PATCH for 4.9 36/59] IB/ipoib: Fix deadlock over vlan_mutex

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Feras Daoud 

[ Upstream commit 1c3098cdb05207e740715857df7b0998e372f527 ]

This patch fixes Deadlock while executing ipoib_vlan_delete.

The function takes the vlan_rwsem semaphore and calls
unregister_netdevice. The later function calls
ipoib_mcast_stop_thread that cause workqueue flush.

When the queue has one of the ipoib_ib_dev_flush_xxx events,
a deadlock occur because these events also tries to catch the
same vlan_rwsem semaphore.

To fix, unregister_netdevice should be called after releasing
the semaphore.

Fixes: cbbe1efa4972 ("IPoIB: Fix deadlock between ipoib_open() and child 
interface create")
Signed-off-by: Feras Daoud 
Signed-off-by: Erez Shitrit 
Reviewed-by: Alex Vesker 
Signed-off-by: Leon Romanovsky 
Signed-off-by: Doug Ledford 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c 
b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 57eadd2b7a71..8151d1a6acb1 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -193,7 +193,6 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned 
short pkey)
list_for_each_entry_safe(priv, tpriv, >child_intfs, list) {
if (priv->pkey == pkey &&
priv->child_type == IPOIB_LEGACY_CHILD) {
-   unregister_netdevice(priv->dev);
list_del(>list);
dev = priv->dev;
break;
@@ -201,6 +200,11 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned 
short pkey)
}
up_write(>vlan_rwsem);
 
+   if (dev) {
+   ipoib_dbg(ppriv, "delete child vlan %s\n", dev->name);
+   unregister_netdevice(dev);
+   }
+
rtnl_unlock();
 
if (dev) {
-- 
2.11.0


[PATCH for 4.9 38/59] IB/ipoib: Replace list_del of the neigh->list with list_del_init

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Feras Daoud 

[ Upstream commit c586071d1dc8227a7182179b8e50ee92cc43f6d2 ]

In order to resolve a situation where a few process delete
the same list element in sequence and cause panic, list_del
is replaced with list_del_init. In this case if the first
process that calls list_del releases the lock before acquiring
it again, other processes who can acquire the lock will call
list_del_init.

Fixes: b63b70d87741 ("IPoIB: Use a private hash table for path lookup")
Signed-off-by: Feras Daoud 
Signed-off-by: Erez Shitrit 
Reviewed-by: Alex Vesker 
Signed-off-by: Leon Romanovsky 
Reviewed-by: Yuval Shaia 
Signed-off-by: Doug Ledford 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c 
b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 08c4b0287304..183db0cd849e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1302,7 +1302,7 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv 
*priv)
   
rcu_dereference_protected(neigh->hnext,
 
lockdep_is_held(>lock)));
/* remove from path/mc list */
-   list_del(>list);
+   list_del_init(>list);
call_rcu(>rcu, ipoib_neigh_reclaim);
} else {
np = >hnext;
@@ -1466,7 +1466,7 @@ void ipoib_neigh_free(struct ipoib_neigh *neigh)
   
rcu_dereference_protected(neigh->hnext,
 
lockdep_is_held(>lock)));
/* remove from parent list */
-   list_del(>list);
+   list_del_init(>list);
call_rcu(>rcu, ipoib_neigh_reclaim);
return;
} else {
@@ -1551,7 +1551,7 @@ void ipoib_del_neighs_by_gid(struct net_device *dev, u8 
*gid)
   
rcu_dereference_protected(neigh->hnext,
 
lockdep_is_held(>lock)));
/* remove from parent list */
-   list_del(>list);
+   list_del_init(>list);
call_rcu(>rcu, ipoib_neigh_reclaim);
} else {
np = >hnext;
@@ -1593,7 +1593,7 @@ static void ipoib_flush_neighs(struct ipoib_dev_priv 
*priv)
   
rcu_dereference_protected(neigh->hnext,
 
lockdep_is_held(>lock)));
/* remove from path/mc list */
-   list_del(>list);
+   list_del_init(>list);
call_rcu(>rcu, ipoib_neigh_reclaim);
}
}
-- 
2.11.0


[PATCH for 4.9 49/59] spi: pxa2xx: Add support for Intel Gemini Lake

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: "David E. Box" 

[ Upstream commit e18a80acd1365e91e3efcd69942d9073936cf851 ]

Gemini Lake reuses the same LPSS SPI configuration as Broxton

Signed-off-by: David E. Box 
Signed-off-by: Jarkko Nikula 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 drivers/spi/spi-pxa2xx.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index d6239fa718be..3f3751e2b521 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1458,6 +1458,10 @@ static const struct pci_device_id 
pxa2xx_spi_pci_compound_match[] = {
{ PCI_VDEVICE(INTEL, 0x1ac2), LPSS_BXT_SSP },
{ PCI_VDEVICE(INTEL, 0x1ac4), LPSS_BXT_SSP },
{ PCI_VDEVICE(INTEL, 0x1ac6), LPSS_BXT_SSP },
+   /* GLK */
+   { PCI_VDEVICE(INTEL, 0x31c2), LPSS_BXT_SSP },
+   { PCI_VDEVICE(INTEL, 0x31c4), LPSS_BXT_SSP },
+   { PCI_VDEVICE(INTEL, 0x31c6), LPSS_BXT_SSP },
/* APL */
{ PCI_VDEVICE(INTEL, 0x5ac2), LPSS_BXT_SSP },
{ PCI_VDEVICE(INTEL, 0x5ac4), LPSS_BXT_SSP },
-- 
2.11.0


[PATCH for 4.9 41/59] USB: serial: mos7720: fix control-message error handling

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Johan Hovold 

[ Upstream commit 0d130367abf582e7cbf60075c2a7ab53817b1d14 ]

Make sure to log an error on short transfers when reading a device
register.

Also clear the provided buffer (which if often an uninitialised
automatic variable) on errors as the driver currently does not bother to
check for errors.

Reviewed-by: Greg Kroah-Hartman 
Signed-off-by: Johan Hovold 
Signed-off-by: Sasha Levin 
---
 drivers/usb/serial/mos7720.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 136ff5e1b7c1..135eb04368f9 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -234,11 +234,16 @@ static int read_mos_reg(struct usb_serial *serial, 
unsigned int serial_portnum,
 
status = usb_control_msg(usbdev, pipe, request, requesttype, value,
 index, buf, 1, MOS_WDR_TIMEOUT);
-   if (status == 1)
+   if (status == 1) {
*data = *buf;
-   else if (status < 0)
+   } else {
dev_err(>dev,
"mos7720: usb_control_msg() failed: %d\n", status);
+   if (status >= 0)
+   status = -EIO;
+   *data = 0;
+   }
+
kfree(buf);
 
return status;
-- 
2.11.0


[PATCH for 4.9 53/59] ASoC: dapm: fix some pointer error handling

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Linus Walleij 

[ Upstream commit 639467c8f26d834c934215e8b59129ce442475fe ]

commit 66feeec9322132689d42723df2537d60f96f8e44
"RFC: ASoC: dapm: handle probe deferrals"
forgot a to update some two sites where the call
was used. The static codechecks quickly found them.

Reported-by: Dan Carpenter 
Fixes: 66feeec93221 ("RFC: ASoC: dapm: handle probe deferrals")
Signed-off-by: Linus Walleij 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-dapm.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 411f7574dd0b..6780eba55ec2 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3843,6 +3843,16 @@ int snd_soc_dapm_new_dai_widgets(struct 
snd_soc_dapm_context *dapm,
template.name);
 
w = snd_soc_dapm_new_control_unlocked(dapm, );
+   if (IS_ERR(w)) {
+   int ret = PTR_ERR(w);
+
+   /* Do not nag about probe deferrals */
+   if (ret != -EPROBE_DEFER)
+   dev_err(dapm->dev,
+   "ASoC: Failed to create %s widget (%d)\n",
+   dai->driver->playback.stream_name, ret);
+   return ret;
+   }
if (!w) {
dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
dai->driver->playback.stream_name);
@@ -3862,6 +3872,16 @@ int snd_soc_dapm_new_dai_widgets(struct 
snd_soc_dapm_context *dapm,
template.name);
 
w = snd_soc_dapm_new_control_unlocked(dapm, );
+   if (IS_ERR(w)) {
+   int ret = PTR_ERR(w);
+
+   /* Do not nag about probe deferrals */
+   if (ret != -EPROBE_DEFER)
+   dev_err(dapm->dev,
+   "ASoC: Failed to create %s widget (%d)\n",
+   dai->driver->playback.stream_name, ret);
+   return ret;
+   }
if (!w) {
dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
dai->driver->capture.stream_name);
-- 
2.11.0


[PATCH for 4.9 59/59] lkdtm: Fix Oops when unloading the module

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Juerg Haefliger 

[ Upstream commit 9ba60573638e2006170ebcc5489fb1e068afbc8f ]

No jprobe is registered when the module is loaded without specifying a
crashpoint that uses a jprobe. At the moment, we unconditionally try to
unregister the jprobe on module unload which results in an Oops. Add a
check to fix this.

Signed-off-by: Juerg Haefliger 
Acked-by: Kees Cook 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/misc/lkdtm_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/lkdtm_core.c b/drivers/misc/lkdtm_core.c
index f9154b8d67f6..b2989f2d3126 100644
--- a/drivers/misc/lkdtm_core.c
+++ b/drivers/misc/lkdtm_core.c
@@ -533,7 +533,9 @@ static void __exit lkdtm_module_exit(void)
/* Handle test-specific clean-up. */
lkdtm_usercopy_exit();
 
-   unregister_jprobe(lkdtm_jprobe);
+   if (lkdtm_jprobe != NULL)
+   unregister_jprobe(lkdtm_jprobe);
+
pr_info("Crash point unregistered\n");
 }
 
-- 
2.11.0


[PATCH for 4.9 45/59] partitions/efi: Fix integer overflow in GPT size calculation

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Alden Tondettar 

[ Upstream commit c5082b70adfe8e1ea1cf4a8eff92c9f260e364d2 ]

If a GUID Partition Table claims to have more than 2**25 entries, the
calculation of the partition table size in alloc_read_gpt_entries() will
overflow a 32-bit integer and not enough space will be allocated for the
table.

Nothing seems to get written out of bounds, but later efi_partition() will
read up to 32768 bytes from a 128 byte buffer, possibly OOPSing or exposing
information to /proc/partitions and uevents.

The problem exists on both 64-bit and 32-bit platforms.

Fix the overflow and also print a meaningful debug message if the table
size is too large.

Signed-off-by: Alden Tondettar 
Acked-by: Ard Biesheuvel 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 block/partitions/efi.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index bcd86e5cd546..39f70d968754 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -293,7 +293,7 @@ static gpt_entry *alloc_read_gpt_entries(struct 
parsed_partitions *state,
if (!gpt)
return NULL;
 
-   count = le32_to_cpu(gpt->num_partition_entries) *
+   count = (size_t)le32_to_cpu(gpt->num_partition_entries) *
 le32_to_cpu(gpt->sizeof_partition_entry);
if (!count)
return NULL;
@@ -352,7 +352,7 @@ static int is_gpt_valid(struct parsed_partitions *state, 
u64 lba,
gpt_header **gpt, gpt_entry **ptes)
 {
u32 crc, origcrc;
-   u64 lastlba;
+   u64 lastlba, pt_size;
 
if (!ptes)
return 0;
@@ -434,13 +434,20 @@ static int is_gpt_valid(struct parsed_partitions *state, 
u64 lba,
goto fail;
}
 
+   /* Sanity check partition table size */
+   pt_size = (u64)le32_to_cpu((*gpt)->num_partition_entries) *
+   le32_to_cpu((*gpt)->sizeof_partition_entry);
+   if (pt_size > KMALLOC_MAX_SIZE) {
+   pr_debug("GUID Partition Table is too large: %llu > %lu 
bytes\n",
+(unsigned long long)pt_size, KMALLOC_MAX_SIZE);
+   goto fail;
+   }
+
if (!(*ptes = alloc_read_gpt_entries(state, *gpt)))
goto fail;
 
/* Check the GUID Partition Entry Array CRC */
-   crc = efi_crc32((const unsigned char *) (*ptes),
-   le32_to_cpu((*gpt)->num_partition_entries) *
-   le32_to_cpu((*gpt)->sizeof_partition_entry));
+   crc = efi_crc32((const unsigned char *) (*ptes), pt_size);
 
if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
pr_debug("GUID Partition Entry Array CRC check failed.\n");
-- 
2.11.0


[PATCH for 4.9 10/59] MIPS: Ensure bss section ends on a long-aligned address

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Paul Burton 

[ Upstream commit 3f00f4d8f083bc61005d0a1ef592b149f5c88bbd ]

When clearing the .bss section in kernel_entry we do so using LONG_S
instructions, and branch whilst the current write address doesn't equal
the end of the .bss section minus the size of a long integer. The .bss
section always begins at a long-aligned address and we always increment
the write pointer by the size of a long integer - we therefore rely upon
the .bss section ending at a long-aligned address. If this is not the
case then the long-aligned write address can never be equal to the
non-long-aligned end address & we will continue to increment past the
end of the .bss section, attempting to zero the rest of memory.

Despite this requirement that .bss end at a long-aligned address we pass
0 as the end alignment requirement to the BSS_SECTION macro and thus
don't guarantee any particular alignment, allowing us to hit the error
condition described above.

Fix this by instead passing 8 bytes as the end alignment argument to
the BSS_SECTION macro, ensuring that the end of the .bss section is
always at least long-aligned.

Signed-off-by: Paul Burton 
Cc: linux-m...@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14526/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index d5de67591735..f0a0e6d62be3 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -182,7 +182,7 @@ SECTIONS
 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
 * gets that alignment.  .sbss should be empty, so there will be
 * no holes after __init_end. */
-   BSS_SECTION(0, 0x1, 0)
+   BSS_SECTION(0, 0x1, 8)
 
_end = . ;
 
-- 
2.11.0


[PATCH for 4.9 07/59] clk: sunxi-ng: set the parent rate when adjustin CPUX clock on A33

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Icenowy Zheng 

[ Upstream commit bb021cda2ccf45ee9470bf0f8c55323ad1c761ae ]

The CPUX clock on A33, which is for the Cortex-A7 cores, is designed to
be changeable by changing the rate of PLL_CPUX.

Add CLK_SET_RATE_PARENT flag to this clock.

Signed-off-by: Icenowy Zheng 
Signed-off-by: Maxime Ripard 
Signed-off-by: Sasha Levin 
---
 drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c 
b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
index 9bd1f78a0547..d54e5db3959a 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
@@ -170,7 +170,7 @@ static SUNXI_CCU_N_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1",
 static const char * const cpux_parents[] = { "osc32k", "osc24M",
 "pll-cpux" , "pll-cpux" };
 static SUNXI_CCU_MUX(cpux_clk, "cpux", cpux_parents,
-0x050, 16, 2, CLK_IS_CRITICAL);
+0x050, 16, 2, CLK_IS_CRITICAL | CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_M(axi_clk, "axi", "cpux", 0x050, 0, 2, 0);
 
-- 
2.11.0


[PATCH for 4.9 24/59] usb: make the MTK XHCI driver compile for older MIPS SoCs

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: John Crispin 

[ Upstream commit 808cf33d4817c730008de9b2736b357708a3d7f6 ]

The MIPS based MT7621 shares the same XHCI core as the newer generation of
ARM based SoCs. The driver works out of the box and we only need to make it
buildable in Kconfig.

Signed-off-by: John Crispin 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/usb/host/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 0b80cee30da4..eb121b2a55d4 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -45,9 +45,9 @@ config USB_XHCI_PLATFORM
  If unsure, say N.
 
 config USB_XHCI_MTK
-   tristate "xHCI support for Mediatek MT65xx"
+   tristate "xHCI support for Mediatek MT65xx/MT7621"
select MFD_SYSCON
-   depends on ARCH_MEDIATEK || COMPILE_TEST
+   depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || COMPILE_TEST
---help---
  Say 'Y' to enable the support for the xHCI host controller
  found in Mediatek MT65xx SoCs.
-- 
2.11.0


[PATCH for 4.9 25/59] hwmon: (gl520sm) Fix overflows and crash seen when writing into limit attributes

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Guenter Roeck 

[ Upstream commit 87cdfa9d60f4f40e6d71b04b10b36d9df3c89282 ]

Writes into limit attributes can overflow due to multplications and
additions with unbound input values. Writing into fan limit attributes
can result in a crash with a division by zero if very large values are
written and the fan divider is larger than 1.

Signed-off-by: Guenter Roeck 
Signed-off-by: Sasha Levin 
---
 drivers/hwmon/gl520sm.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index dee93ec87d02..84e0994aafdd 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -208,11 +208,13 @@ static ssize_t get_cpu_vid(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR(cpu0_vid, S_IRUGO, get_cpu_vid, NULL);
 
-#define VDD_FROM_REG(val) (((val) * 95 + 2) / 4)
-#define VDD_TO_REG(val) clamp_valval) * 4 + 47) / 95), 0, 255)
+#define VDD_FROM_REG(val)  DIV_ROUND_CLOSEST((val) * 95, 4)
+#define VDD_CLAMP(val) clamp_val(val, 0, 255 * 95 / 4)
+#define VDD_TO_REG(val)DIV_ROUND_CLOSEST(VDD_CLAMP(val) * 4, 
95)
 
-#define IN_FROM_REG(val) ((val) * 19)
-#define IN_TO_REG(val) clamp_valval) + 9) / 19), 0, 255)
+#define IN_FROM_REG(val)   ((val) * 19)
+#define IN_CLAMP(val)  clamp_val(val, 0, 255 * 19)
+#define IN_TO_REG(val) DIV_ROUND_CLOSEST(IN_CLAMP(val), 19)
 
 static ssize_t get_in_input(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -349,8 +351,13 @@ static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR,
 
 #define DIV_FROM_REG(val) (1 << (val))
 #define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (48 / ((val) << (div
-#define FAN_TO_REG(val, div) ((val) <= 0 ? 0 : \
-   clamp_val((48 + ((val) << ((div)-1))) / ((val) << (div)), 1, 255))
+
+#define FAN_BASE(div)  (48 >> (div))
+#define FAN_CLAMP(val, div)clamp_val(val, FAN_BASE(div) / 255, \
+ FAN_BASE(div))
+#define FAN_TO_REG(val, div)   ((val) == 0 ? 0 : \
+DIV_ROUND_CLOSEST(48, \
+   FAN_CLAMP(val, div) << (div)))
 
 static ssize_t get_fan_input(struct device *dev, struct device_attribute *attr,
 char *buf)
@@ -513,9 +520,9 @@ static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
 static DEVICE_ATTR(fan1_off, S_IRUGO | S_IWUSR,
get_fan_off, set_fan_off);
 
-#define TEMP_FROM_REG(val) (((val) - 130) * 1000)
-#define TEMP_TO_REG(val) clamp_val(val) < 0 ? \
-   (val) - 500 : (val) + 500) / 1000) + 130), 0, 255)
+#define TEMP_FROM_REG(val) (((val) - 130) * 1000)
+#define TEMP_CLAMP(val)clamp_val(val, -13, 125000)
+#define TEMP_TO_REG(val)   (DIV_ROUND_CLOSEST(TEMP_CLAMP(val), 1000) + 130)
 
 static ssize_t get_temp_input(struct device *dev, struct device_attribute 
*attr,
  char *buf)
-- 
2.11.0


[PATCH for 4.9 02/59] drm: bridge: add DT bindings for TI ths8135

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Bartosz Golaszewski 

[ Upstream commit 2e644be30fcc08c736f66b60f4898d274d4873ab ]

THS8135 is a configurable video DAC. Add DT bindings for this chip.

Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Laurent Pinchart 
Acked-by: Rob Herring 
Signed-off-by: Archit Taneja 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1481623759-12786-3-git-send-email-bgolaszew...@baylibre.com
Signed-off-by: Sasha Levin 
---
 .../bindings/display/bridge/ti,ths8135.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt

diff --git a/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt 
b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
new file mode 100644
index ..6ec1a880ac18
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/ti,ths8135.txt
@@ -0,0 +1,46 @@
+THS8135 Video DAC
+-
+
+This is the binding for Texas Instruments THS8135 Video DAC bridge.
+
+Required properties:
+
+- compatible: Must be "ti,ths8135"
+
+Required nodes:
+
+This device has two video ports. Their connections are modelled using the OF
+graph bindings specified in Documentation/devicetree/bindings/graph.txt.
+
+- Video port 0 for RGB input
+- Video port 1 for VGA output
+
+Example
+---
+
+vga-bridge {
+   compatible = "ti,ths8135";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   vga_bridge_in: endpoint {
+   remote-endpoint = <_out_vga>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   vga_bridge_out: endpoint {
+   remote-endpoint = <_con_in>;
+   };
+   };
+   };
+};
-- 
2.11.0


[PATCH for 4.9 09/59] ARM: dts: r8a7790: Use R-Car Gen 2 fallback binding for msiof nodes

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Simon Horman 

[ Upstream commit 654450baf2afba86cf328e1849ccac61ec4630af ]

Use recently added R-Car Gen 2 fallback binding for msiof nodes in
DT for r8a7790 SoC.

This has no run-time effect for the current driver as the initialisation
sequence is the same for the SoC-specific binding for r8a7790 and the
fallback binding for R-Car Gen 2.

Signed-off-by: Simon Horman 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/r8a7790.dtsi | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 351fcc2f87df..b6c6410ca384 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -1493,7 +1493,8 @@
};
 
msiof0: spi@e6e2 {
-   compatible = "renesas,msiof-r8a7790";
+   compatible = "renesas,msiof-r8a7790",
+"renesas,rcar-gen2-msiof";
reg = <0 0xe6e2 0 0x0064>;
interrupts = ;
clocks = <_clks R8A7790_CLK_MSIOF0>;
@@ -1507,7 +1508,8 @@
};
 
msiof1: spi@e6e1 {
-   compatible = "renesas,msiof-r8a7790";
+   compatible = "renesas,msiof-r8a7790",
+"renesas,rcar-gen2-msiof";
reg = <0 0xe6e1 0 0x0064>;
interrupts = ;
clocks = <_clks R8A7790_CLK_MSIOF1>;
@@ -1521,7 +1523,8 @@
};
 
msiof2: spi@e6e0 {
-   compatible = "renesas,msiof-r8a7790";
+   compatible = "renesas,msiof-r8a7790",
+"renesas,rcar-gen2-msiof";
reg = <0 0xe6e0 0 0x0064>;
interrupts = ;
clocks = <_clks R8A7790_CLK_MSIOF2>;
@@ -1535,7 +1538,8 @@
};
 
msiof3: spi@e6c9 {
-   compatible = "renesas,msiof-r8a7790";
+   compatible = "renesas,msiof-r8a7790",
+"renesas,rcar-gen2-msiof";
reg = <0 0xe6c9 0 0x0064>;
interrupts = ;
clocks = <_clks R8A7790_CLK_MSIOF3>;
-- 
2.11.0


[PATCH for 4.9 57/59] MIPS: Lantiq: Fix another request_mem_region() return code check

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Arnd Bergmann 

[ Upstream commit 98ea51cb0c8ce009d9da1fd7b48f0ff1d7a9bbb0 ]

Hauke already fixed a couple of them, but one instance remains
that checks for a negative integer when it should check
for a NULL pointer:

arch/mips/lantiq/xway/sysctrl.c: In function 'ltq_soc_init':
arch/mips/lantiq/xway/sysctrl.c:473:19: error: ordered comparison of pointer 
with integer zero [-Werror=extra]

Fixes: 6e807852676a ("MIPS: Lantiq: Fix check for return value of 
request_mem_region()")
Signed-off-by: Arnd Bergmann 
Cc: John Crispin 
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/15043/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/lantiq/xway/sysctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
index 90565477dfbd..95bec460b651 100644
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -469,8 +469,8 @@ void __init ltq_soc_init(void)
panic("Failed to load xbar nodes from devicetree");
if (of_address_to_resource(np_xbar, 0, _xbar))
panic("Failed to get xbar resources");
-   if (request_mem_region(res_xbar.start, resource_size(_xbar),
-   res_xbar.name) < 0)
+   if (!request_mem_region(res_xbar.start, 
resource_size(_xbar),
+   res_xbar.name))
panic("Failed to get xbar resources");
 
ltq_xbar_membase = ioremap_nocache(res_xbar.start,
-- 
2.11.0


[PATCH for 4.9 35/59] serial: 8250_port: Remove dangerous pr_debug()

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Alexey Brodkin 

[ Upstream commit 699a11ba7ec869b006623182881f2f1f5b4aea53 ]

With CONFIG_DYNAMIC_DEBUG if dyndbg enables debug output in
8250_port.c deadlock happens inevitably on UART IRQ handling.

That's the problematic execution path:
>8
UART IRQ:
  serial8250_interrupt() ->
serial8250_handle_irq(): lock "port->lock" ->
  pr_debug() ->
serial8250_console_write(): bump in locked "port->lock".

  OR (if above pr_debug() gets removed):
  serial8250_tx_chars() ->
pr_debug() ->
  serial8250_console_write(): bump in locked "port->lock".
>8

So let's get rid of those not that much useful debug entries.

Discussed problem could be easily reproduced with QEMU for x86_64.
As well as this fix could be mimicked with muting of dynamic debug for
the problematic lines as simple as:
>8
dyndbg="+p; file 8250_port.c line 1756 -p; file 8250_port.c line 1822 -p"
>8

Signed-off-by: Alexey Brodkin 
Cc: Jiri Slaby 
Cc: Peter Hurley 
Cc: Phillip Raffeck 
Cc: Anton Wuerfel 
Cc: "Matwey V. Kornilov" 
Cc: Yegor Yefremov 
Cc: Thor Thayer 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/tty/serial/8250/8250_port.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index f24d3030b98c..1ef31e3ee4a1 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1751,8 +1751,6 @@ void serial8250_tx_chars(struct uart_8250_port *up)
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(port);
 
-   pr_debug("%s: THRE\n", __func__);
-
/*
 * With RPM enabled, we have to wait until the FIFO is empty before the
 * HW can go idle. So we get here once again with empty FIFO and disable
@@ -1817,8 +1815,6 @@ int serial8250_handle_irq(struct uart_port *port, 
unsigned int iir)
 
status = serial_port_in(port, UART_LSR);
 
-   pr_debug("%s: status = %x\n", __func__, status);
-
if (status & (UART_LSR_DR | UART_LSR_BI)) {
if (!up->dma || handle_rx_dma(up, iir))
status = serial8250_rx_chars(up, status);
-- 
2.11.0


[PATCH for 4.9 37/59] IB/ipoib: rtnl_unlock can not come after free_netdev

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Feras Daoud 

[ Upstream commit 89a3987ab7a923c047c6dec008e60ad6f41fac22 ]

The ipoib_vlan_add function calls rtnl_unlock after free_netdev,
rtnl_unlock not only releases the lock, but also calls netdev_run_todo.
The latter function browses the net_todo_list array and completes the
unregistration of all its net_device instances. If we call free_netdev
before rtnl_unlock, then netdev_run_todo call over the freed device causes
panic.
To fix, move rtnl_unlock call before free_netdev call.

Fixes: 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support")
Cc: Or Gerlitz 
Signed-off-by: Feras Daoud 
Signed-off-by: Erez Shitrit 
Reviewed-by: Yuval Shaia 
Signed-off-by: Leon Romanovsky 
Signed-off-by: Doug Ledford 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c 
b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 8151d1a6acb1..93b50be14438 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -165,11 +165,11 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned 
short pkey)
 out:
up_write(>vlan_rwsem);
 
+   rtnl_unlock();
+
if (result)
free_netdev(priv->dev);
 
-   rtnl_unlock();
-
return result;
 }
 
-- 
2.11.0


[PATCH for 4.9 55/59] drm: mali-dp: Fix transposed horizontal/vertical flip

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Brian Starkey 

[ Upstream commit 7916efe5b57505080b3cebf5bdb228b4eda008ea ]

The horizontal and vertical flip flags were the wrong way around,
causing reflect-x to result in reflect-y being applied and vice-versa.
Fix them.

Fixes: ad49f8602fe8 ("drm/arm: Add support for Mali Display Processors")

Signed-off-by: Brian Starkey 
Signed-off-by: Liviu Dudau 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/arm/malidp_planes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index a6bdd91d6c9e..afe0480d95c9 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -184,9 +184,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
if (plane->state->rotation & DRM_ROTATE_MASK)
val = ilog2(plane->state->rotation & DRM_ROTATE_MASK) << 
LAYER_ROT_OFFSET;
if (plane->state->rotation & DRM_REFLECT_X)
-   val |= LAYER_V_FLIP;
-   if (plane->state->rotation & DRM_REFLECT_Y)
val |= LAYER_H_FLIP;
+   if (plane->state->rotation & DRM_REFLECT_Y)
+   val |= LAYER_V_FLIP;
 
/* set the 'enable layer' bit */
val |= LAYER_ENABLE;
-- 
2.11.0


[PATCH for 4.9 31/59] ARM: 8635/1: nommu: allow enabling REMAP_VECTORS_TO_RAM

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Afzal Mohammed 

[ Upstream commit 8a792e9afbce84a0fdaf213fe42bb97382487094 ]

REMAP_VECTORS_TO_RAM depends on DRAM_BASE, but since DRAM_BASE is a
hex, REMAP_VECTORS_TO_RAM could never get enabled. Also depending on
DRAM_BASE is redundant as whenever REMAP_VECTORS_TO_RAM makes itself
available to Kconfig, DRAM_BASE also is available as the Kconfig
gets sourced on !MMU.

Signed-off-by: Afzal Mohammed 
Reviewed-by: Vladimir Murzin 
Signed-off-by: Russell King 
Signed-off-by: Sasha Levin 
---
 arch/arm/Kconfig-nommu | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig-nommu b/arch/arm/Kconfig-nommu
index aed66d5df7f1..b7576349528c 100644
--- a/arch/arm/Kconfig-nommu
+++ b/arch/arm/Kconfig-nommu
@@ -34,8 +34,7 @@ config PROCESSOR_ID
  used instead of the auto-probing which utilizes the register.
 
 config REMAP_VECTORS_TO_RAM
-   bool 'Install vectors to the beginning of RAM' if DRAM_BASE
-   depends on DRAM_BASE
+   bool 'Install vectors to the beginning of RAM'
help
  The kernel needs to change the hardware exception vectors.
  In nommu mode, the hardware exception vectors are normally
-- 
2.11.0


[PATCH for 4.9 14/59] MIPS: ralink: Fix incorrect assignment on ralink_soc

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Colin Ian King 

[ Upstream commit 08d90c81b714482dceb5323d14f6617bcf55ee61 ]

ralink_soc sould be assigned to RT3883_SOC, replace incorrect
comparision with assignment.

Signed-off-by: Colin Ian King 
Fixes: 418d29c87061 ("MIPS: ralink: Unify SoC id handling")
Cc: John Crispin 
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14903/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/ralink/rt3883.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c
index 9e4631acfcb5..3e68e35daf21 100644
--- a/arch/mips/ralink/rt3883.c
+++ b/arch/mips/ralink/rt3883.c
@@ -145,5 +145,5 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
 
rt2880_pinmux_data = rt3883_pinmux_data;
 
-   ralink_soc == RT3883_SOC;
+   ralink_soc = RT3883_SOC;
 }
-- 
2.11.0


[PATCH for 4.9 06/59] clk: sunxi-ng: fix PLL_CPUX adjusting on H3

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Ondrej Jirman 

[ Upstream commit a43c96427e713bea94e9ef50e8be1f493afc0691 ]

When adjusting PLL_CPUX on H3, the PLL is temporarily driven
too high, and the system becomes unstable (oopses or hangs).

Add a notifier to avoid this situation by temporarily switching
to a known stable 24 MHz oscillator.

Signed-off-by: Ondrej Jirman 
Tested-by: Lutz Sammer 
Acked-by: Chen-Yu Tsai 
Signed-off-by: Maxime Ripard 
Signed-off-by: Sasha Levin 
---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c 
b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
index 21c427d86f28..a26c8a19fe93 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
@@ -803,6 +803,13 @@ static const struct sunxi_ccu_desc sun8i_h3_ccu_desc = {
.num_resets = ARRAY_SIZE(sun8i_h3_ccu_resets),
 };
 
+static struct ccu_mux_nb sun8i_h3_cpu_nb = {
+   .common = _clk.common,
+   .cm = _clk.mux,
+   .delay_us   = 1, /* > 8 clock cycles at 24 MHz */
+   .bypass_index   = 1, /* index of 24 MHz oscillator */
+};
+
 static void __init sun8i_h3_ccu_setup(struct device_node *node)
 {
void __iomem *reg;
@@ -821,6 +828,9 @@ static void __init sun8i_h3_ccu_setup(struct device_node 
*node)
writel(val | (3 << 16), reg + SUN8I_H3_PLL_AUDIO_REG);
 
sunxi_ccu_probe(node, reg, _h3_ccu_desc);
+
+   ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
+ _h3_cpu_nb);
 }
 CLK_OF_DECLARE(sun8i_h3_ccu, "allwinner,sun8i-h3-ccu",
   sun8i_h3_ccu_setup);
-- 
2.11.0


[PATCH for 4.9 03/59] GFS2: Fix reference to ERR_PTR in gfs2_glock_iter_next

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Dan Carpenter 

[ Upstream commit 14d37564fa3dc4e5d4c6828afcd26ac14e6796c5 ]

This patch fixes a place where function gfs2_glock_iter_next can
reference an invalid error pointer.

Signed-off-by: Dan Carpenter 
Signed-off-by: Bob Peterson 
Signed-off-by: Sasha Levin 
---
 fs/gfs2/glock.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7bff6f46f5da..95bc0ae71d81 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1820,16 +1820,18 @@ void gfs2_glock_exit(void)
 
 static void gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
 {
-   do {
-   gi->gl = rhashtable_walk_next(>hti);
+   while ((gi->gl = rhashtable_walk_next(>hti))) {
if (IS_ERR(gi->gl)) {
if (PTR_ERR(gi->gl) == -EAGAIN)
continue;
gi->gl = NULL;
+   return;
}
-   /* Skip entries for other sb and dead entries */
-   } while ((gi->gl) && ((gi->sdp != gi->gl->gl_name.ln_sbd) ||
- __lockref_is_dead(>gl->gl_lockref)));
+   /* Skip entries for other sb and dead entries */
+   if (gi->sdp == gi->gl->gl_name.ln_sbd &&
+   !__lockref_is_dead(>gl->gl_lockref))
+   return;
+   }
 }
 
 static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
-- 
2.11.0


[PATCH for 4.9 05/59] ARM: dts: exynos: Add CPU OPPs for Exynos4412 Prime

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Bartlomiej Zolnierkiewicz 

[ Upstream commit 80b7a2e2498bcffb1a79980dfbeb7a1275577b28 ]

Add CPU operating points for Exynos4412 Prime (it supports
additional 1704MHz & 1600MHz OPPs and 1500MHz OPP is just
a regular non-turbo OPP on this SoC).  Also update relevant
cooling maps to account for new OPPs.

ODROID-X2/U2/U3 boards use Exynos4412 Prime SoC version so
update their board files accordingly.

Based on Hardkernel's kernel for ODROID-X2/U2/U3 boards.

Cc: Doug Anderson 
Cc: Andreas Faerber 
Cc: Thomas Abraham 
Cc: Tobias Jakobi 
Cc: Ben Gamari 
Signed-off-by: Bartlomiej Zolnierkiewicz 
Signed-off-by: Krzysztof Kozlowski 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/exynos4412-odroid-common.dtsi |  4 +--
 arch/arm/boot/dts/exynos4412-odroidu3.dts   |  5 +--
 arch/arm/boot/dts/exynos4412-odroidx2.dts   |  1 +
 arch/arm/boot/dts/exynos4412-prime.dtsi | 41 +
 arch/arm/boot/dts/exynos4412.dtsi   |  2 +-
 5 files changed, 48 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4412-prime.dtsi

diff --git a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi 
b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
index 8aa19ba14436..5282d69e55bd 100644
--- a/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
+++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi
@@ -97,11 +97,11 @@
thermal-zones {
cpu_thermal: cpu-thermal {
cooling-maps {
-   map0 {
+   cooling_map0: map0 {
 /* Corresponds to 800MHz at freq_table */
 cooling-device = < 7 7>;
};
-   map1 {
+   cooling_map1: map1 {
 /* Corresponds to 200MHz at freq_table */
 cooling-device = < 13 13>;
   };
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts 
b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 99634c54dca9..7504a5aa538e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -13,6 +13,7 @@
 
 /dts-v1/;
 #include "exynos4412-odroid-common.dtsi"
+#include "exynos4412-prime.dtsi"
 
 / {
model = "Hardkernel ODROID-U3 board based on Exynos4412";
@@ -47,11 +48,11 @@
cooling-maps {
map0 {
 trip = <_alert1>;
-cooling-device = < 7 7>;
+cooling-device = < 9 9>;
};
map1 {
 trip = <_alert2>;
-cooling-device = < 13 13>;
+cooling-device = < 15 15>;
};
map2 {
 trip = <_alert0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidx2.dts 
b/arch/arm/boot/dts/exynos4412-odroidx2.dts
index 4d228858f172..d6e92ebc3874 100644
--- a/arch/arm/boot/dts/exynos4412-odroidx2.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidx2.dts
@@ -12,6 +12,7 @@
 */
 
 #include "exynos4412-odroidx.dts"
+#include "exynos4412-prime.dtsi"
 
 / {
model = "Hardkernel ODROID-X2 board based on Exynos4412";
diff --git a/arch/arm/boot/dts/exynos4412-prime.dtsi 
b/arch/arm/boot/dts/exynos4412-prime.dtsi
new file mode 100644
index ..e75bc170c89c
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4412-prime.dtsi
@@ -0,0 +1,41 @@
+/*
+ * Samsung's Exynos4412 Prime SoC device tree source
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * Exynos4412 Prime SoC revision supports higher CPU frequencies than
+ * non-Prime version.  Therefore we need to update OPPs table and
+ * thermal maps accordingly.
+ */
+
+_opp_1500 {
+   /delete-property/turbo-mode;
+};
+
+_opp_table {
+   opp@16 {
+   opp-hz = /bits/ 64 <16>;
+   opp-microvolt = <135>;
+   clock-latency-ns = <20>;
+   };
+   opp@170400 {
+   opp-hz = /bits/ 64 <170400>;
+   opp-microvolt = <135>;
+   clock-latency-ns = <20>;
+   };
+};
+
+_map0 {
+   cooling-device = < 9 9>;
+};
+
+_map1 {
+   cooling-device = < 15 15>;
+};
diff 

[PATCH for 4.9 15/59] power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Hans de Goede 

[ Upstream commit 6f074bc878dc9b00c0df0bf3a8cb1d9e294cd881 ]

If reading the register fails, return the actual error code, instead
of the uninitialized val variable;

Signed-off-by: Hans de Goede 
Signed-off-by: Sebastian Reichel 
Signed-off-by: Sasha Levin 
---
 drivers/power/supply/axp288_fuel_gauge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/axp288_fuel_gauge.c 
b/drivers/power/supply/axp288_fuel_gauge.c
index 5bdde692f724..f62f9dfea984 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -169,8 +169,10 @@ static int fuel_gauge_reg_readb(struct axp288_fg_info 
*info, int reg)
break;
}
 
-   if (ret < 0)
+   if (ret < 0) {
dev_err(>pdev->dev, "axp288 reg read err:%d\n", ret);
+   return ret;
+   }
 
return val;
 }
-- 
2.11.0


[PATCH for 4.9 04/59] drm/i915: Fix the overlay frontbuffer tracking

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Ville Syrjälä 

[ Upstream commit 58d09ebdb4edf5d3ab3a2aee851ab0168bc83ec6 ]

Do the overlay frontbuffer tracking properly so that it matches
the state of the overlay on/off/continue requests.

One slight problem is that intel_frontbuffer_flip_complete()
may get delayed by an arbitrarily liong time due to the fact that
the overlay code likes to bail out when a signal occurs. So the
flip may not get completed until the ioctl is restarted. But fixing
that would require bigger surgery, so I decided to ignore it for now.

Signed-off-by: Ville Syrjälä 
Link: 
http://patchwork.freedesktop.org/patch/msgid/1481131693-27993-5-git-send-email-ville.syrj...@linux.intel.com
Reviewed-by: Chris Wilson 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/i915/intel_overlay.c | 64 +++-
 1 file changed, 41 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_overlay.c 
b/drivers/gpu/drm/i915/intel_overlay.c
index a2655cd5a84e..8ab6f30dc23c 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -272,8 +272,30 @@ static int intel_overlay_on(struct intel_overlay *overlay)
return intel_overlay_do_wait_request(overlay, req, NULL);
 }
 
+static void intel_overlay_flip_prepare(struct intel_overlay *overlay,
+  struct i915_vma *vma)
+{
+   enum pipe pipe = overlay->crtc->pipe;
+
+   WARN_ON(overlay->old_vma);
+
+   i915_gem_track_fb(overlay->vma ? overlay->vma->obj : NULL,
+ vma ? vma->obj : NULL,
+ INTEL_FRONTBUFFER_OVERLAY(pipe));
+
+   intel_frontbuffer_flip_prepare(overlay->i915,
+  INTEL_FRONTBUFFER_OVERLAY(pipe));
+
+   overlay->old_vma = overlay->vma;
+   if (vma)
+   overlay->vma = i915_vma_get(vma);
+   else
+   overlay->vma = NULL;
+}
+
 /* overlay needs to be enabled in OCMD reg */
 static int intel_overlay_continue(struct intel_overlay *overlay,
+ struct i915_vma *vma,
  bool load_polyphase_filter)
 {
struct drm_i915_private *dev_priv = overlay->i915;
@@ -308,43 +330,44 @@ static int intel_overlay_continue(struct intel_overlay 
*overlay,
intel_ring_emit(ring, flip_addr);
intel_ring_advance(ring);
 
+   intel_overlay_flip_prepare(overlay, vma);
+
intel_overlay_submit_request(overlay, req, NULL);
 
return 0;
 }
 
-static void intel_overlay_release_old_vid_tail(struct i915_gem_active *active,
-  struct drm_i915_gem_request *req)
+static void intel_overlay_release_old_vma(struct intel_overlay *overlay)
 {
-   struct intel_overlay *overlay =
-   container_of(active, typeof(*overlay), last_flip);
struct i915_vma *vma;
 
vma = fetch_and_zero(>old_vma);
if (WARN_ON(!vma))
return;
 
-   i915_gem_track_fb(vma->obj, NULL,
- INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe));
+   intel_frontbuffer_flip_complete(overlay->i915,
+   
INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe));
 
i915_gem_object_unpin_from_display_plane(vma);
i915_vma_put(vma);
 }
 
+static void intel_overlay_release_old_vid_tail(struct i915_gem_active *active,
+  struct drm_i915_gem_request *req)
+{
+   struct intel_overlay *overlay =
+   container_of(active, typeof(*overlay), last_flip);
+
+   intel_overlay_release_old_vma(overlay);
+}
+
 static void intel_overlay_off_tail(struct i915_gem_active *active,
   struct drm_i915_gem_request *req)
 {
struct intel_overlay *overlay =
container_of(active, typeof(*overlay), last_flip);
-   struct i915_vma *vma;
-
-   /* never have the overlay hw on without showing a frame */
-   vma = fetch_and_zero(>vma);
-   if (WARN_ON(!vma))
-   return;
 
-   i915_gem_object_unpin_from_display_plane(vma);
-   i915_vma_put(vma);
+   intel_overlay_release_old_vma(overlay);
 
overlay->crtc->overlay = NULL;
overlay->crtc = NULL;
@@ -398,6 +421,8 @@ static int intel_overlay_off(struct intel_overlay *overlay)
}
intel_ring_advance(ring);
 
+   intel_overlay_flip_prepare(overlay, NULL);
+
return intel_overlay_do_wait_request(overlay, req,
 intel_overlay_off_tail);
 }
@@ -836,18 +861,10 @@ static int intel_overlay_do_put_image(struct 
intel_overlay *overlay,
 
intel_overlay_unmap_regs(overlay, regs);
 
-   ret = intel_overlay_continue(overlay, scale_changed);
+   ret = intel_overlay_continue(overlay, vma, 

[PATCH for 4.9 12/59] MIPS: kexec: Do not reserve invalid crashkernel memory on boot

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Marcin Nowakowski 

[ Upstream commit a8f108d70c74d83574c157648383eb2e4285a190 ]

Do not reserve memory for the crashkernel if the commandline argument
points to a wrong location. This can happen if the location is specified
wrong or if the same commandline is reused when starting the crashkernel
- in the latter case the reserved memory would point to the location
from which the crashkernel is executing.

Signed-off-by: Marcin Nowakowski 
Cc: linux-m...@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14612/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/kernel/setup.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 38697f25d168..d64ee5d3cc89 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -668,6 +668,11 @@ static void __init mips_parse_crashkernel(void)
if (ret != 0 || crash_size <= 0)
return;
 
+   if (!memory_region_available(crash_base, crash_size)) {
+   pr_warn("Invalid memory region reserved for crash kernel\n");
+   return;
+   }
+
crashk_res.start = crash_base;
crashk_res.end   = crash_base + crash_size - 1;
 }
-- 
2.11.0


[PATCH for 4.9 23/59] clk: wm831x: fix usleep_range with bad range

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Nicholas Mc Guire 

[ Upstream commit ed784c532a3d0959db488f40a96c5127f63d42dc ]

The delay here is not in atomic context and does not seem critical with
respect to precision, but usleep_range(min,max) with min==max results in
giving the timer subsystem no room to optimize uncritical delays. Fix
this by setting the range to 2000,3000 us.

Fixes: commit f05259a6ffa4 ("clk: wm831x: Add initial WM831x clock driver")
Signed-off-by: Nicholas Mc Guire 
Acked-by: Charles Keepax 
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/clk/clk-wm831x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-wm831x.c b/drivers/clk/clk-wm831x.c
index 0621fbfb4beb..a47960aacfa5 100644
--- a/drivers/clk/clk-wm831x.c
+++ b/drivers/clk/clk-wm831x.c
@@ -97,7 +97,8 @@ static int wm831x_fll_prepare(struct clk_hw *hw)
if (ret != 0)
dev_crit(wm831x->dev, "Failed to enable FLL: %d\n", ret);
 
-   usleep_range(2000, 2000);
+   /* wait 2-3 ms for new frequency taking effect */
+   usleep_range(2000, 3000);
 
return ret;
 }
-- 
2.11.0


[PATCH for 4.9 28/59] iio: adc: hx711: Add DT binding for avia,hx711

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Andreas Klinger 

[ Upstream commit ff1293f67734da68e23fecb6ecdae7112b8c43f9 ]

Add DT bindings for avia,hx711
Add vendor avia to vendor list

Signed-off-by: Andreas Klinger 
Acked-by: Rob Herring 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 .../devicetree/bindings/iio/adc/avia-hx711.txt | 18 ++
 Documentation/devicetree/bindings/vendor-prefixes.txt  |  1 +
 2 files changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/avia-hx711.txt

diff --git a/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt 
b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt
new file mode 100644
index ..b3629405f568
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/avia-hx711.txt
@@ -0,0 +1,18 @@
+* AVIA HX711 ADC chip for weight cells
+  Bit-banging driver
+
+Required properties:
+ - compatible: Should be "avia,hx711"
+ - sck-gpios:  Definition of the GPIO for the clock
+ - dout-gpios: Definition of the GPIO for data-out
+   See Documentation/devicetree/bindings/gpio/gpio.txt
+ - avdd-supply:Definition of the regulator used as analog supply
+
+Example:
+weight@0 {
+   compatible = "avia,hx711";
+   sck-gpios = < 10 GPIO_ACTIVE_HIGH>;
+   dout-gpios = < 7 GPIO_ACTIVE_HIGH>;
+   avdd-suppy = <>;
+};
+
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index f0a48ea78659..bceb7502 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -38,6 +38,7 @@ atmel Atmel Corporation
 auoAU Optronics Corporation
 auvidea Auvidea GmbH
 avago  Avago Technologies
+avia   avia semiconductor
 avic   Shanghai AVIC Optoelectronics Co., Ltd.
 axis   Axis Communications AB
 boeBOE Technology Group Co., Ltd.
-- 
2.11.0


[PATCH for 4.9 21/59] sh_eth: use correct name for ECMR_MPDE bit

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Niklas Söderlund 

[ Upstream commit 6dcf45e514974a1ff10755015b5e06746a033e5f ]

This bit was wrongly named due to a typo, Sergei checked the SH7734/63
manuals and this bit should be named MPDE.

Suggested-by: Sergei Shtylyov 
Signed-off-by: Niklas Söderlund 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/renesas/sh_eth.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.h 
b/drivers/net/ethernet/renesas/sh_eth.h
index d050f37f3e0f..5024280f5af2 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -339,7 +339,7 @@ enum FELIC_MODE_BIT {
ECMR_DPAD = 0x0020, ECMR_RZPF = 0x0010,
ECMR_ZPF = 0x0008, ECMR_PFR = 0x0004, ECMR_RXF = 0x0002,
ECMR_TXF = 0x0001, ECMR_MCT = 0x2000, ECMR_PRCEF = 0x1000,
-   ECMR_PMDE = 0x0200, ECMR_RE = 0x0040, ECMR_TE = 0x0020,
+   ECMR_MPDE = 0x0200, ECMR_RE = 0x0040, ECMR_TE = 0x0020,
ECMR_RTM = 0x0010, ECMR_ILB = 0x0008, ECMR_ELB = 0x0004,
ECMR_DM = 0x0002, ECMR_PRM = 0x0001,
 };
-- 
2.11.0


[PATCH for 4.9 27/59] iio: adc: axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Hans de Goede 

[ Upstream commit fa2849e9649b5180ffc4cb3c3b005261c403093a ]

For some reason the axp288_adc driver was modifying the
AXP288_ADC_TS_PIN_CTRL register, changing bits 0-1 depending on
whether the GP_ADC channel or another channel was written.

These bits control when a bias current is send to the TS_PIN, the
GP_ADC has its own pin and a separate bit in another register to
control the bias current.

Not only does changing when to enable the TS_PIN bias current
(always or only when sampling) when reading the GP_ADC make no sense
at all, the code is modifying these bits is writing the entire register,
assuming that all the other bits have their default value.

So if the firmware has configured a different bias-current for either
pin, then that change gets clobbered by the write, likewise if the
firmware has set bit 2 to indicate that the battery has no thermal sensor,
this will get clobbered by the write.

This commit fixes all this, by simply removing all writes to the
AXP288_ADC_TS_PIN_CTRL register, they are not needed to read the
GP_ADC pin, and can actually be harmful.

Signed-off-by: Hans de Goede 
Acked-by: Chen-Yu Tsai 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/iio/adc/axp288_adc.c | 32 +---
 1 file changed, 1 insertion(+), 31 deletions(-)

diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 7fd24949c0c1..64799ad7ebad 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -28,8 +28,6 @@
 #include 
 
 #define AXP288_ADC_EN_MASK 0xF1
-#define AXP288_ADC_TS_PIN_GPADC0xF2
-#define AXP288_ADC_TS_PIN_ON   0xF3
 
 enum axp288_adc_id {
AXP288_ADC_TS,
@@ -123,16 +121,6 @@ static int axp288_adc_read_channel(int *val, unsigned long 
address,
return IIO_VAL_INT;
 }
 
-static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode,
-   unsigned long address)
-{
-   /* channels other than GPADC do not need to switch TS pin */
-   if (address != AXP288_GP_ADC_H)
-   return 0;
-
-   return regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode);
-}
-
 static int axp288_adc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
@@ -143,16 +131,7 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
mutex_lock(_dev->mlock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
-   if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC,
-   chan->address)) {
-   dev_err(_dev->dev, "GPADC mode\n");
-   ret = -EINVAL;
-   break;
-   }
ret = axp288_adc_read_channel(val, chan->address, info->regmap);
-   if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON,
-   chan->address))
-   dev_err(_dev->dev, "TS pin restore\n");
break;
default:
ret = -EINVAL;
@@ -162,15 +141,6 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
return ret;
 }
 
-static int axp288_adc_set_state(struct regmap *regmap)
-{
-   /* ADC should be always enabled for internal FG to function */
-   if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON))
-   return -EIO;
-
-   return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
-}
-
 static const struct iio_info axp288_adc_iio_info = {
.read_raw = _adc_read_raw,
.driver_module = THIS_MODULE,
@@ -199,7 +169,7 @@ static int axp288_adc_probe(struct platform_device *pdev)
 * Set ADC to enabled state at all time, including system suspend.
 * otherwise internal fuel gauge functionality may be affected.
 */
-   ret = axp288_adc_set_state(axp20x->regmap);
+   ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
if (ret) {
dev_err(>dev, "unable to enable ADC device\n");
return ret;
-- 
2.11.0


[PATCH for 4.9 48/59] ath10k: prevent sta pointer rcu violation

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Michal Kazior 

[ Upstream commit 0a744d927406389e00687560d9ce3c5ab0e58db9 ]

Station pointers are RCU protected so driver must
be extra careful if it tries to store them
internally for later use outside of the RCU
section it obtained it in.

It was possible for station teardown to race with
some htt events. The possible outcome could be a
use-after-free and a crash.

Only peer-flow-control capable firmware was
affected (so hardware-wise qca99x0 and qca4019).

This could be done in sta_state() itself via
explicit synchronize_net() call but there's
already a convenient sta_pre_rcu_remove() op that
can be hooked up to avoid extra rcu stall.

The peer->sta pointer itself can't be set to
NULL/ERR_PTR because it is later used in
sta_state() for extra sanity checks.

Signed-off-by: Michal Kazior 
Signed-off-by: Kalle Valo 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/mac.c  | 18 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index be5b527472f9..90c0c4a7175d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -314,6 +314,7 @@ struct ath10k_peer {
struct ieee80211_vif *vif;
struct ieee80211_sta *sta;
 
+   bool removed;
int vdev_id;
u8 addr[ETH_ALEN];
DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index f2e85eb22afe..30e98afa2e68 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3738,6 +3738,9 @@ struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k 
*ar,
if (!peer)
return NULL;
 
+   if (peer->removed)
+   return NULL;
+
if (peer->sta)
return peer->sta->txq[tid];
else if (peer->vif)
@@ -7422,6 +7425,20 @@ ath10k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,
return 0;
 }
 
+static void ath10k_mac_op_sta_pre_rcu_remove(struct ieee80211_hw *hw,
+struct ieee80211_vif *vif,
+struct ieee80211_sta *sta)
+{
+   struct ath10k *ar;
+   struct ath10k_peer *peer;
+
+   ar = hw->priv;
+
+   list_for_each_entry(peer, >peers, list)
+   if (peer->sta == sta)
+   peer->removed = true;
+}
+
 static const struct ieee80211_ops ath10k_ops = {
.tx = ath10k_mac_op_tx,
.wake_tx_queue  = ath10k_mac_op_wake_tx_queue,
@@ -7462,6 +7479,7 @@ static const struct ieee80211_ops ath10k_ops = {
.assign_vif_chanctx = ath10k_mac_op_assign_vif_chanctx,
.unassign_vif_chanctx   = ath10k_mac_op_unassign_vif_chanctx,
.switch_vif_chanctx = ath10k_mac_op_switch_vif_chanctx,
+   .sta_pre_rcu_remove = ath10k_mac_op_sta_pre_rcu_remove,
 
CFG80211_TESTMODE_CMD(ath10k_tm_cmd)
 
-- 
2.11.0


[PATCH for 4.9 56/59] HID: wacom: release the resources before leaving despite devm

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Benjamin Tissoires 

[ Upstream commit 5b779fc52020ac6f5beea31c5eafc3d25cf70dc1 ]

In the general case, the resources are properly released by devm without
needing to do anything. However, when unplugging the wireless receiver,
the kernel segfaults from time to time while calling devres_release_all().

I think in that case the resources attempt to access hid_get_drvdata(hdev)
which has been set to null while leaving wacom_remove().

Signed-off-by: Benjamin Tissoires 
Acked-by: Jason Gerecke 
Signed-off-by: Jiri Kosina 
Signed-off-by: Sasha Levin 
---
 drivers/hid/wacom_sys.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 0c535d0f3b95..53ac19b3727a 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -2433,6 +2433,8 @@ static void wacom_remove(struct hid_device *hdev)
if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(>dev, _attr_speed);
 
+   wacom_release_resources(wacom);
+
hid_set_drvdata(hdev, NULL);
 }
 
-- 
2.11.0


[PATCH for 4.9 16/59] scsi: be2iscsi: Add checks to validate CID alloc/free

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Jitendra Bhivare 

[ Upstream commit 413f365657a8b9669bd0ba3628e9fde9ce63604e ]

Set CID slot to 0x to indicate empty.
Check if connection already exists in conn_table before binding.
Check if endpoint already NULL before putting back CID.
Break ep->conn link in free_ep to ignore completions after freeing.

Signed-off-by: Jitendra Bhivare 
Reviewed-by: Hannes Reinecke 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 163 ---
 drivers/scsi/be2iscsi/be_main.c  |   7 +-
 drivers/scsi/be2iscsi/be_main.h  |   1 +
 3 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index ba258217614e..963c732a3d24 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -166,33 +166,6 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, 
u32 cid)
 }
 
 /**
- * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table
- * @beiscsi_conn: The pointer to  beiscsi_conn structure
- * @phba: The phba instance
- * @cid: The cid to free
- */
-static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
-   struct beiscsi_conn *beiscsi_conn,
-   unsigned int cid)
-{
-   uint16_t cri_index = BE_GET_CRI_FROM_CID(cid);
-
-   if (phba->conn_table[cri_index]) {
-   beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
-   "BS_%d : Connection table already occupied. 
Detected clash\n");
-
-   return -EINVAL;
-   } else {
-   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
-   cri_index, beiscsi_conn);
-
-   phba->conn_table[cri_index] = beiscsi_conn;
-   }
-   return 0;
-}
-
-/**
  * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection
  * @cls_session: pointer to iscsi cls session
  * @cls_conn: pointer to iscsi cls conn
@@ -212,6 +185,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
struct hwi_wrb_context *pwrb_context;
struct beiscsi_endpoint *beiscsi_ep;
struct iscsi_endpoint *ep;
+   uint16_t cri_index;
 
ep = iscsi_lookup_endpoint(transport_fd);
if (!ep)
@@ -229,20 +203,34 @@ int beiscsi_conn_bind(struct iscsi_cls_session 
*cls_session,
 
return -EEXIST;
}
-
-   pwrb_context = _ctrlr->wrb_context[BE_GET_CRI_FROM_CID(
-   beiscsi_ep->ep_cid)];
+   cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid);
+   if (phba->conn_table[cri_index]) {
+   if (beiscsi_conn != phba->conn_table[cri_index] ||
+   beiscsi_ep != phba->conn_table[cri_index]->ep) {
+   __beiscsi_log(phba, KERN_ERR,
+ "BS_%d : conn_table not empty at %u: cid 
%u conn %p:%p\n",
+ cri_index,
+ beiscsi_ep->ep_cid,
+ beiscsi_conn,
+ phba->conn_table[cri_index]);
+   return -EINVAL;
+   }
+   }
 
beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid;
beiscsi_conn->ep = beiscsi_ep;
beiscsi_ep->conn = beiscsi_conn;
+   /**
+* Each connection is associated with a WRBQ kept in wrb_context.
+* Store doorbell offset for transmit path.
+*/
+   pwrb_context = _ctrlr->wrb_context[cri_index];
beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset;
-
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
-   "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
-   beiscsi_conn, conn, beiscsi_ep->ep_cid);
-
-   return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
+   "BS_%d : cid %d phba->conn_table[%u]=%p\n",
+   beiscsi_ep->ep_cid, cri_index, beiscsi_conn);
+   phba->conn_table[cri_index] = beiscsi_conn;
+   return 0;
 }
 
 static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba)
@@ -973,9 +961,9 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn)
  */
 static int beiscsi_get_cid(struct beiscsi_hba *phba)
 {
-   unsigned short cid = 0x, cid_from_ulp;
-   struct ulp_cid_info *cid_info = NULL;
uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1;
+   unsigned short cid, cid_from_ulp;
+   struct ulp_cid_info *cid_info;
 
/* Find the ULP which has more CID available */
cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ?
@@ -984,20 +972,27 @@ static int beiscsi_get_cid(struct 

[PATCH for 4.9 08/59] RDS: RDMA: Fix the composite message user notification

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Santosh Shilimkar 

[ Upstream commit 941f8d55f6d613a460a5e080d25a38509f45eb75 ]

When application sends an RDS RDMA composite message consist of
RDMA transfer to be followed up by non RDMA payload, it expect to
be notified *only* when the full message gets delivered. RDS RDMA
notification doesn't behave this way though.

Thanks to Venkat for debug and root casuing the issue
where only first part of the message(RDMA) was
successfully delivered but remainder payload delivery failed.
In that case, application should not be notified with
a false positive of message delivery success.

Fix this case by making sure the user gets notified only after
the full message delivery.

Reviewed-by: Venkat Venkatsubra 
Signed-off-by: Santosh Shilimkar 
Signed-off-by: Sasha Levin 
---
 net/rds/ib_send.c | 25 +++--
 net/rds/rdma.c| 10 ++
 net/rds/rds.h |  1 +
 net/rds/send.c|  4 +++-
 4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index 84d90c97332f..191098173018 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -69,16 +69,6 @@ static void rds_ib_send_complete(struct rds_message *rm,
complete(rm, notify_status);
 }
 
-static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
-  struct rm_data_op *op,
-  int wc_status)
-{
-   if (op->op_nents)
-   ib_dma_unmap_sg(ic->i_cm_id->device,
-   op->op_sg, op->op_nents,
-   DMA_TO_DEVICE);
-}
-
 static void rds_ib_send_unmap_rdma(struct rds_ib_connection *ic,
   struct rm_rdma_op *op,
   int wc_status)
@@ -139,6 +129,21 @@ static void rds_ib_send_unmap_atomic(struct 
rds_ib_connection *ic,
rds_ib_stats_inc(s_ib_atomic_fadd);
 }
 
+static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
+  struct rm_data_op *op,
+  int wc_status)
+{
+   struct rds_message *rm = container_of(op, struct rds_message, data);
+
+   if (op->op_nents)
+   ib_dma_unmap_sg(ic->i_cm_id->device,
+   op->op_sg, op->op_nents,
+   DMA_TO_DEVICE);
+
+   if (rm->rdma.op_active && rm->data.op_notify)
+   rds_ib_send_unmap_rdma(ic, >rdma, wc_status);
+}
+
 /*
  * Unmap the resources associated with a struct send_work.
  *
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 4c93badeabf2..8d3a851a3476 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -626,6 +626,16 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct 
rds_message *rm,
}
op->op_notifier->n_user_token = args->user_token;
op->op_notifier->n_status = RDS_RDMA_SUCCESS;
+
+   /* Enable rmda notification on data operation for composite
+* rds messages and make sure notification is enabled only
+* for the data operation which follows it so that application
+* gets notified only after full message gets delivered.
+*/
+   if (rm->data.op_sg) {
+   rm->rdma.op_notify = 0;
+   rm->data.op_notify = !!(args->flags & 
RDS_RDMA_NOTIFY_ME);
+   }
}
 
/* The cookie contains the R_Key of the remote memory region, and
diff --git a/net/rds/rds.h b/net/rds/rds.h
index 67ba67c058b1..f107a968ddff 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -414,6 +414,7 @@ struct rds_message {
} rdma;
struct rm_data_op {
unsigned intop_active:1;
+   unsigned intop_notify:1;
unsigned intop_nents;
unsigned intop_count;
unsigned intop_dmasg;
diff --git a/net/rds/send.c b/net/rds/send.c
index 896626b9a0ef..f28651b6ae83 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -475,12 +475,14 @@ void rds_rdma_send_complete(struct rds_message *rm, int 
status)
struct rm_rdma_op *ro;
struct rds_notifier *notifier;
unsigned long flags;
+   unsigned int notify = 0;
 
spin_lock_irqsave(>m_rs_lock, flags);
 
+   notify =  rm->rdma.op_notify | rm->data.op_notify;
ro = >rdma;
if (test_bit(RDS_MSG_ON_SOCK, >m_flags) &&
-   ro->op_active && ro->op_notify && ro->op_notifier) {
+   ro->op_active && notify && ro->op_notifier) {
notifier = ro->op_notifier;
rs = rm->m_rs;
sock_hold(rds_rs_to_sk(rs));
-- 
2.11.0


[PATCH for 4.9 20/59] reset: ti_syscon: fix a ti_syscon_reset_status issue

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Jiancheng Xue 

[ Upstream commit 5987b4bf512101137fa60c5c0ccac3db51541221 ]

If STATUS_SET was not set, ti_syscon_reset_status would always return 0
no matter whether the status_bit was set or not.

Signed-off-by: Jiancheng Xue 
Fixes: cc7c2bb1493c ("reset: add TI SYSCON based reset driver")
Signed-off-by: Philipp Zabel 
Signed-off-by: Sasha Levin 
---
 drivers/reset/reset-ti-syscon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
index 47f0ffd3b013..1799fd423901 100644
--- a/drivers/reset/reset-ti-syscon.c
+++ b/drivers/reset/reset-ti-syscon.c
@@ -154,8 +154,8 @@ static int ti_syscon_reset_status(struct 
reset_controller_dev *rcdev,
if (ret)
return ret;
 
-   return (reset_state & BIT(control->status_bit)) &&
-   (control->flags & STATUS_SET);
+   return !(reset_state & BIT(control->status_bit)) ==
+   !(control->flags & STATUS_SET);
 }
 
 static struct reset_control_ops ti_syscon_reset_ops = {
-- 
2.11.0


[PATCH for 4.9 11/59] MIPS: fix mem=X@Y commandline processing

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Marcin Nowakowski 

[ Upstream commit 73fbc1eba7ffa3bf0ad12486232a8a1edb4e4411 ]

When a memory offset is specified through the commandline, add the
memory in range PHYS_OFFSET:Y as reserved memory area.
Otherwise the bootmem allocator is initialised with low page equal to
min_low_pfn = PHYS_OFFSET, and in free_all_bootmem will process pages
starting from min_low_pfn instead of PFN(Y).

Signed-off-by: Marcin Nowakowski 
Cc: linux-m...@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14613/
Signed-off-by: Ralf Baechle 
Signed-off-by: Sasha Levin 
---
 arch/mips/kernel/setup.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index f66e5ce505b2..38697f25d168 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -589,6 +589,10 @@ static int __init early_parse_mem(char *p)
start = memparse(p + 1, );
 
add_memory_region(start, size, BOOT_MEM_RAM);
+
+   if (start && start > PHYS_OFFSET)
+   add_memory_region(PHYS_OFFSET, start - PHYS_OFFSET,
+   BOOT_MEM_RESERVED);
return 0;
 }
 early_param("mem", early_parse_mem);
-- 
2.11.0


[PATCH for 4.9 26/59] iio: adc: imx25-gcq: Fix module autoload

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Javier Martinez Canillas 

[ Upstream commit 8f0d7daf53972da0004f7a5a4d938c85333db300 ]

If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.

Export the module alias information using the MODULE_DEVICE_TABLE() macro.

Before this patch:

$ modinfo drivers/iio/adc/fsl-imx25-gcq.ko | grep alias
$

After this patch:

$ modinfo drivers/iio/adc/fsl-imx25-gcq.ko | grep alias
alias:  of:N*T*Cfsl,imx25-gcqC*
alias:  of:N*T*Cfsl,imx25-gcq

Signed-off-by: Javier Martinez Canillas 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Sasha Levin 
---
 drivers/iio/adc/fsl-imx25-gcq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
index 72b32c1ab257..ea264fa9e567 100644
--- a/drivers/iio/adc/fsl-imx25-gcq.c
+++ b/drivers/iio/adc/fsl-imx25-gcq.c
@@ -401,6 +401,7 @@ static const struct of_device_id mx25_gcq_ids[] = {
{ .compatible = "fsl,imx25-gcq", },
{ /* Sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, mx25_gcq_ids);
 
 static struct platform_driver mx25_gcq_driver = {
.driver = {
-- 
2.11.0


[PATCH for 4.9 43/59] sfc: get PIO buffer size from the NIC

2017-09-14 Thread Levin, Alexander (Sasha Levin)
From: Edward Cree 

[ Upstream commit c634700f7eec3c0da46e299cd0a0ae8b594f9b55 ]

The 8000 series SFC NICs have 4K PIO buffers, rather than the 2K of
 the 7000 series.  Rather than having a hard-coded PIO buffer size
 (ER_DZ_TX_PIOBUF_SIZE), read it from the GET_CAPABILITIES_V2 MCDI
 response.

Signed-off-by: Edward Cree 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/sfc/ef10.c | 16 ++--
 drivers/net/ethernet/sfc/nic.h  |  2 ++
 drivers/net/ethernet/sfc/tx.c   |  1 -
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index c4ada7227f40..1d85109cb8ed 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -197,11 +197,15 @@ static int efx_ef10_init_datapath_caps(struct efx_nic 
*efx)
nic_data->datapath_caps =
MCDI_DWORD(outbuf, GET_CAPABILITIES_OUT_FLAGS1);
 
-   if (outlen >= MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)
+   if (outlen >= MC_CMD_GET_CAPABILITIES_V2_OUT_LEN) {
nic_data->datapath_caps2 = MCDI_DWORD(outbuf,
GET_CAPABILITIES_V2_OUT_FLAGS2);
-   else
+   nic_data->piobuf_size = MCDI_WORD(outbuf,
+   GET_CAPABILITIES_V2_OUT_SIZE_PIO_BUFF);
+   } else {
nic_data->datapath_caps2 = 0;
+   nic_data->piobuf_size = ER_DZ_TX_PIOBUF_SIZE;
+   }
 
/* record the DPCPU firmware IDs to determine VEB vswitching support.
 */
@@ -825,8 +829,8 @@ static int efx_ef10_link_piobufs(struct efx_nic *efx)
offset = ((efx->tx_channel_offset + efx->n_tx_channels -
   tx_queue->channel->channel - 1) *
  efx_piobuf_size);
-   index = offset / ER_DZ_TX_PIOBUF_SIZE;
-   offset = offset % ER_DZ_TX_PIOBUF_SIZE;
+   index = offset / nic_data->piobuf_size;
+   offset = offset % nic_data->piobuf_size;
 
/* When the host page size is 4K, the first
 * host page in the WC mapping may be within
@@ -1161,11 +1165,11 @@ static int efx_ef10_dimension_resources(struct efx_nic 
*efx)
 * functions of the controller.
 */
if (efx_piobuf_size != 0 &&
-   ER_DZ_TX_PIOBUF_SIZE / efx_piobuf_size * EF10_TX_PIOBUF_COUNT >=
+   nic_data->piobuf_size / efx_piobuf_size * EF10_TX_PIOBUF_COUNT >=
efx->n_tx_channels) {
unsigned int n_piobufs =
DIV_ROUND_UP(efx->n_tx_channels,
-ER_DZ_TX_PIOBUF_SIZE / efx_piobuf_size);
+nic_data->piobuf_size / efx_piobuf_size);
 
rc = efx_ef10_alloc_piobufs(efx, n_piobufs);
if (rc)
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index 73bee7ea332a..73028f21a2d7 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -500,6 +500,7 @@ enum {
  * @pio_write_base: Base address for writing PIO buffers
  * @pio_write_vi_base: Relative VI number for @pio_write_base
  * @piobuf_handle: Handle of each PIO buffer allocated
+ * @piobuf_size: size of a single PIO buffer
  * @must_restore_piobufs: Flag: PIO buffers have yet to be restored after MC
  * reboot
  * @rx_rss_context: Firmware handle for our RSS context
@@ -537,6 +538,7 @@ struct efx_ef10_nic_data {
void __iomem *wc_membase, *pio_write_base;
unsigned int pio_write_vi_base;
unsigned int piobuf_handle[EF10_TX_PIOBUF_COUNT];
+   u16 piobuf_size;
bool must_restore_piobufs;
u32 rx_rss_context;
bool rx_rss_context_exclusive;
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index 233778911557..6f26acd0aa61 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -27,7 +27,6 @@
 
 #ifdef EFX_USE_PIO
 
-#define EFX_PIOBUF_SIZE_MAX ER_DZ_TX_PIOBUF_SIZE
 #define EFX_PIOBUF_SIZE_DEF ALIGN(256, L1_CACHE_BYTES)
 unsigned int efx_piobuf_size __read_mostly = EFX_PIOBUF_SIZE_DEF;
 
-- 
2.11.0


<    1   2   3   4   5   6   7   8   9   10   >