All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output
@ 2017-06-04  8:11 Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 002/111] ibmvnic: Fix endian error when requesting device capabilities Levin, Alexander (Sasha Levin)
                   ` (69 more replies)
  0 siblings, 70 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Thomas Falcon, David S . Miller, Levin, Alexander (Sasha Levin)

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

[ Upstream commit 75224c93fa985f4a6fb983f53208f5c5aa555fbf ]

Error reports received from firmware were not being converted from
big endian values, leading to bogus error codes reported on little
endian systems.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 0fbf686f5e7c..207cc562f803 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2197,12 +2197,12 @@ static void handle_error_info_rsp(union ibmvnic_crq *crq,
 
 	if (!found) {
 		dev_err(dev, "Couldn't find error id %x\n",
-			crq->request_error_rsp.error_id);
+			be32_to_cpu(crq->request_error_rsp.error_id));
 		return;
 	}
 
 	dev_err(dev, "Detailed info for error id %x:",
-		crq->request_error_rsp.error_id);
+		be32_to_cpu(crq->request_error_rsp.error_id));
 
 	for (i = 0; i < error_buff->len; i++) {
 		pr_cont("%02x", (int)error_buff->buff[i]);
@@ -2281,8 +2281,8 @@ static void handle_error_indication(union ibmvnic_crq *crq,
 	dev_err(dev, "Firmware reports %serror id %x, cause %d\n",
 		crq->error_indication.
 		    flags & IBMVNIC_FATAL_ERROR ? "FATAL " : "",
-		crq->error_indication.error_id,
-		crq->error_indication.error_cause);
+		be32_to_cpu(crq->error_indication.error_id),
+		be16_to_cpu(crq->error_indication.error_cause));
 
 	error_buff = kmalloc(sizeof(*error_buff), GFP_ATOMIC);
 	if (!error_buff)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 002/111] ibmvnic: Fix endian error when requesting device capabilities
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 003/111] net: xilinx_emaclite: fix freezes due to unordered I/O Levin, Alexander (Sasha Levin)
                   ` (68 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Thomas Falcon, David S . Miller, Levin, Alexander (Sasha Levin)

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

[ Upstream commit 28f4d16570dcf440e54a4d72666d5be452f27d0e ]

When a vNIC client driver requests a faulty device setting, the
server returns an acceptable value for the client to request.
This 64 bit value was incorrectly being swapped as a 32 bit value,
resulting in loss of data. This patch corrects that by using
the 64 bit swap function.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 207cc562f803..d1cf37dc3aa2 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2400,10 +2400,10 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
 	case PARTIALSUCCESS:
 		dev_info(dev, "req=%lld, rsp=%ld in %s queue, retrying.\n",
 			 *req_value,
-			 (long int)be32_to_cpu(crq->request_capability_rsp.
+			 (long int)be64_to_cpu(crq->request_capability_rsp.
 					       number), name);
 		release_sub_crqs_no_irqs(adapter);
-		*req_value = be32_to_cpu(crq->request_capability_rsp.number);
+		*req_value = be64_to_cpu(crq->request_capability_rsp.number);
 		init_sub_crqs(adapter, 1);
 		return;
 	default:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 003/111] net: xilinx_emaclite: fix freezes due to unordered I/O
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 002/111] ibmvnic: Fix endian error when requesting device capabilities Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 004/111] net: xilinx_emaclite: fix receive buffer overflow Levin, Alexander (Sasha Levin)
                   ` (67 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Anssi Hannula, David S . Miller, Levin, Alexander (Sasha Levin)

From: Anssi Hannula <anssi.hannula@bitwise.fi>

[ Upstream commit acf138f1b00bdd1b7cd9894562ed0c2a1670888e ]

The xilinx_emaclite uses __raw_writel and __raw_readl for register
accesses. Those functions do not imply any kind of memory barriers and
they may be reordered.

The driver does not seem to take that into account, though, and the
driver does not satisfy the ordering requirements of the hardware.
For clear examples, see xemaclite_mdio_write() and xemaclite_mdio_read()
which try to set MDIO address before initiating the transaction.

I'm seeing system freezes with the driver with GCC 5.4 and current
Linux kernels on Zynq-7000 SoC immediately when trying to use the
interface.

In commit 123c1407af87 ("net: emaclite: Do not use microblaze and ppc
IO functions") the driver was switched from non-generic
in_be32/out_be32 (memory barriers, big endian) to
__raw_readl/__raw_writel (no memory barriers, native endian), so
apparently the device follows system endianness and the driver was
originally written with the assumption of memory barriers.

Rather than try to hunt for each case of missing barrier, just switch
the driver to use iowrite32/ioread32/iowrite32be/ioread32be depending
on endianness instead.

Tested on little-endian Zynq-7000 ARM SoC FPGA.

Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Fixes: 123c1407af87 ("net: emaclite: Do not use microblaze and ppc IO
functions")
Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 116 ++++++++++++++------------
 1 file changed, 62 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 93dc10b10c09..dfdb78cc13ad 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -100,6 +100,14 @@
 /* BUFFER_ALIGN(adr) calculates the number of bytes to the next alignment. */
 #define BUFFER_ALIGN(adr) ((ALIGNMENT - ((u32) adr)) % ALIGNMENT)
 
+#ifdef __BIG_ENDIAN
+#define xemaclite_readl		ioread32be
+#define xemaclite_writel	iowrite32be
+#else
+#define xemaclite_readl		ioread32
+#define xemaclite_writel	iowrite32
+#endif
+
 /**
  * struct net_local - Our private per device data
  * @ndev:		instance of the network device
@@ -156,15 +164,15 @@ static void xemaclite_enable_interrupts(struct net_local *drvdata)
 	u32 reg_data;
 
 	/* Enable the Tx interrupts for the first Buffer */
-	reg_data = __raw_readl(drvdata->base_addr + XEL_TSR_OFFSET);
-	__raw_writel(reg_data | XEL_TSR_XMIT_IE_MASK,
-		     drvdata->base_addr + XEL_TSR_OFFSET);
+	reg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET);
+	xemaclite_writel(reg_data | XEL_TSR_XMIT_IE_MASK,
+			 drvdata->base_addr + XEL_TSR_OFFSET);
 
 	/* Enable the Rx interrupts for the first buffer */
-	__raw_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr + XEL_RSR_OFFSET);
+	xemaclite_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr + XEL_RSR_OFFSET);
 
 	/* Enable the Global Interrupt Enable */
-	__raw_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);
+	xemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);
 }
 
 /**
@@ -179,17 +187,17 @@ static void xemaclite_disable_interrupts(struct net_local *drvdata)
 	u32 reg_data;
 
 	/* Disable the Global Interrupt Enable */
-	__raw_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);
+	xemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);
 
 	/* Disable the Tx interrupts for the first buffer */
-	reg_data = __raw_readl(drvdata->base_addr + XEL_TSR_OFFSET);
-	__raw_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK),
-		     drvdata->base_addr + XEL_TSR_OFFSET);
+	reg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET);
+	xemaclite_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK),
+			 drvdata->base_addr + XEL_TSR_OFFSET);
 
 	/* Disable the Rx interrupts for the first buffer */
-	reg_data = __raw_readl(drvdata->base_addr + XEL_RSR_OFFSET);
-	__raw_writel(reg_data & (~XEL_RSR_RECV_IE_MASK),
-		     drvdata->base_addr + XEL_RSR_OFFSET);
+	reg_data = xemaclite_readl(drvdata->base_addr + XEL_RSR_OFFSET);
+	xemaclite_writel(reg_data & (~XEL_RSR_RECV_IE_MASK),
+			 drvdata->base_addr + XEL_RSR_OFFSET);
 }
 
 /**
@@ -321,7 +329,7 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
 		byte_count = ETH_FRAME_LEN;
 
 	/* Check if the expected buffer is available */
-	reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
+	reg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);
 	if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
 	     XEL_TSR_XMIT_ACTIVE_MASK)) == 0) {
 
@@ -334,7 +342,7 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
 
 		addr = (void __iomem __force *)((u32 __force)addr ^
 						 XEL_BUFFER_OFFSET);
-		reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
+		reg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);
 
 		if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
 		     XEL_TSR_XMIT_ACTIVE_MASK)) != 0)
@@ -345,16 +353,16 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
 	/* Write the frame to the buffer */
 	xemaclite_aligned_write(data, (u32 __force *) addr, byte_count);
 
-	__raw_writel((byte_count & XEL_TPLR_LENGTH_MASK),
-		     addr + XEL_TPLR_OFFSET);
+	xemaclite_writel((byte_count & XEL_TPLR_LENGTH_MASK),
+			 addr + XEL_TPLR_OFFSET);
 
 	/* Update the Tx Status Register to indicate that there is a
 	 * frame to send. Set the XEL_TSR_XMIT_ACTIVE_MASK flag which
 	 * is used by the interrupt handler to check whether a frame
 	 * has been transmitted */
-	reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
+	reg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);
 	reg_data |= (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_XMIT_ACTIVE_MASK);
-	__raw_writel(reg_data, addr + XEL_TSR_OFFSET);
+	xemaclite_writel(reg_data, addr + XEL_TSR_OFFSET);
 
 	return 0;
 }
@@ -379,7 +387,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 	addr = (drvdata->base_addr + drvdata->next_rx_buf_to_use);
 
 	/* Verify which buffer has valid data */
-	reg_data = __raw_readl(addr + XEL_RSR_OFFSET);
+	reg_data = xemaclite_readl(addr + XEL_RSR_OFFSET);
 
 	if ((reg_data & XEL_RSR_RECV_DONE_MASK) == XEL_RSR_RECV_DONE_MASK) {
 		if (drvdata->rx_ping_pong != 0)
@@ -396,14 +404,14 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 			return 0;	/* No data was available */
 
 		/* Verify that buffer has valid data */
-		reg_data = __raw_readl(addr + XEL_RSR_OFFSET);
+		reg_data = xemaclite_readl(addr + XEL_RSR_OFFSET);
 		if ((reg_data & XEL_RSR_RECV_DONE_MASK) !=
 		     XEL_RSR_RECV_DONE_MASK)
 			return 0;	/* No data was available */
 	}
 
 	/* Get the protocol type of the ethernet frame that arrived */
-	proto_type = ((ntohl(__raw_readl(addr + XEL_HEADER_OFFSET +
+	proto_type = ((ntohl(xemaclite_readl(addr + XEL_HEADER_OFFSET +
 			XEL_RXBUFF_OFFSET)) >> XEL_HEADER_SHIFT) &
 			XEL_RPLR_LENGTH_MASK);
 
@@ -412,7 +420,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 	if (proto_type > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
 
 		if (proto_type == ETH_P_IP) {
-			length = ((ntohl(__raw_readl(addr +
+			length = ((ntohl(xemaclite_readl(addr +
 					XEL_HEADER_IP_LENGTH_OFFSET +
 					XEL_RXBUFF_OFFSET)) >>
 					XEL_HEADER_SHIFT) &
@@ -434,9 +442,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 				data, length);
 
 	/* Acknowledge the frame */
-	reg_data = __raw_readl(addr + XEL_RSR_OFFSET);
+	reg_data = xemaclite_readl(addr + XEL_RSR_OFFSET);
 	reg_data &= ~XEL_RSR_RECV_DONE_MASK;
-	__raw_writel(reg_data, addr + XEL_RSR_OFFSET);
+	xemaclite_writel(reg_data, addr + XEL_RSR_OFFSET);
 
 	return length;
 }
@@ -463,14 +471,14 @@ static void xemaclite_update_address(struct net_local *drvdata,
 
 	xemaclite_aligned_write(address_ptr, (u32 __force *) addr, ETH_ALEN);
 
-	__raw_writel(ETH_ALEN, addr + XEL_TPLR_OFFSET);
+	xemaclite_writel(ETH_ALEN, addr + XEL_TPLR_OFFSET);
 
 	/* Update the MAC address in the EmacLite */
-	reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
-	__raw_writel(reg_data | XEL_TSR_PROG_MAC_ADDR, addr + XEL_TSR_OFFSET);
+	reg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);
+	xemaclite_writel(reg_data | XEL_TSR_PROG_MAC_ADDR, addr + XEL_TSR_OFFSET);
 
 	/* Wait for EmacLite to finish with the MAC address update */
-	while ((__raw_readl(addr + XEL_TSR_OFFSET) &
+	while ((xemaclite_readl(addr + XEL_TSR_OFFSET) &
 		XEL_TSR_PROG_MAC_ADDR) != 0)
 		;
 }
@@ -640,32 +648,32 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
 	u32 tx_status;
 
 	/* Check if there is Rx Data available */
-	if ((__raw_readl(base_addr + XEL_RSR_OFFSET) &
+	if ((xemaclite_readl(base_addr + XEL_RSR_OFFSET) &
 			 XEL_RSR_RECV_DONE_MASK) ||
-	    (__raw_readl(base_addr + XEL_BUFFER_OFFSET + XEL_RSR_OFFSET)
+	    (xemaclite_readl(base_addr + XEL_BUFFER_OFFSET + XEL_RSR_OFFSET)
 			 & XEL_RSR_RECV_DONE_MASK))
 
 		xemaclite_rx_handler(dev);
 
 	/* Check if the Transmission for the first buffer is completed */
-	tx_status = __raw_readl(base_addr + XEL_TSR_OFFSET);
+	tx_status = xemaclite_readl(base_addr + XEL_TSR_OFFSET);
 	if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
 		(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
 
 		tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
-		__raw_writel(tx_status, base_addr + XEL_TSR_OFFSET);
+		xemaclite_writel(tx_status, base_addr + XEL_TSR_OFFSET);
 
 		tx_complete = true;
 	}
 
 	/* Check if the Transmission for the second buffer is completed */
-	tx_status = __raw_readl(base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
+	tx_status = xemaclite_readl(base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
 	if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
 		(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
 
 		tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
-		__raw_writel(tx_status, base_addr + XEL_BUFFER_OFFSET +
-			     XEL_TSR_OFFSET);
+		xemaclite_writel(tx_status, base_addr + XEL_BUFFER_OFFSET +
+				 XEL_TSR_OFFSET);
 
 		tx_complete = true;
 	}
@@ -698,7 +706,7 @@ static int xemaclite_mdio_wait(struct net_local *lp)
 	/* wait for the MDIO interface to not be busy or timeout
 	   after some time.
 	*/
-	while (__raw_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET) &
+	while (xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET) &
 			XEL_MDIOCTRL_MDIOSTS_MASK) {
 		if (time_before_eq(end, jiffies)) {
 			WARN_ON(1);
@@ -734,17 +742,17 @@ static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg)
 	 * MDIO Address register. Set the Status bit in the MDIO Control
 	 * register to start a MDIO read transaction.
 	 */
-	ctrl_reg = __raw_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);
-	__raw_writel(XEL_MDIOADDR_OP_MASK |
-		     ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),
-		     lp->base_addr + XEL_MDIOADDR_OFFSET);
-	__raw_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,
-		     lp->base_addr + XEL_MDIOCTRL_OFFSET);
+	ctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);
+	xemaclite_writel(XEL_MDIOADDR_OP_MASK |
+			 ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),
+			 lp->base_addr + XEL_MDIOADDR_OFFSET);
+	xemaclite_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,
+			 lp->base_addr + XEL_MDIOCTRL_OFFSET);
 
 	if (xemaclite_mdio_wait(lp))
 		return -ETIMEDOUT;
 
-	rc = __raw_readl(lp->base_addr + XEL_MDIORD_OFFSET);
+	rc = xemaclite_readl(lp->base_addr + XEL_MDIORD_OFFSET);
 
 	dev_dbg(&lp->ndev->dev,
 		"xemaclite_mdio_read(phy_id=%i, reg=%x) == %x\n",
@@ -781,13 +789,13 @@ static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 	 * Data register. Finally, set the Status bit in the MDIO Control
 	 * register to start a MDIO write transaction.
 	 */
-	ctrl_reg = __raw_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);
-	__raw_writel(~XEL_MDIOADDR_OP_MASK &
-		     ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),
-		     lp->base_addr + XEL_MDIOADDR_OFFSET);
-	__raw_writel(val, lp->base_addr + XEL_MDIOWR_OFFSET);
-	__raw_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,
-		     lp->base_addr + XEL_MDIOCTRL_OFFSET);
+	ctrl_reg = xemaclite_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET);
+	xemaclite_writel(~XEL_MDIOADDR_OP_MASK &
+			 ((phy_id << XEL_MDIOADDR_PHYADR_SHIFT) | reg),
+			 lp->base_addr + XEL_MDIOADDR_OFFSET);
+	xemaclite_writel(val, lp->base_addr + XEL_MDIOWR_OFFSET);
+	xemaclite_writel(ctrl_reg | XEL_MDIOCTRL_MDIOSTS_MASK,
+			 lp->base_addr + XEL_MDIOCTRL_OFFSET);
 
 	return 0;
 }
@@ -834,8 +842,8 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
 	/* Enable the MDIO bus by asserting the enable bit in MDIO Control
 	 * register.
 	 */
-	__raw_writel(XEL_MDIOCTRL_MDIOEN_MASK,
-		     lp->base_addr + XEL_MDIOCTRL_OFFSET);
+	xemaclite_writel(XEL_MDIOCTRL_MDIOEN_MASK,
+			 lp->base_addr + XEL_MDIOCTRL_OFFSET);
 
 	bus = mdiobus_alloc();
 	if (!bus) {
@@ -1140,8 +1148,8 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
 	}
 
 	/* Clear the Tx CSR's in case this is a restart */
-	__raw_writel(0, lp->base_addr + XEL_TSR_OFFSET);
-	__raw_writel(0, lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
+	xemaclite_writel(0, lp->base_addr + XEL_TSR_OFFSET);
+	xemaclite_writel(0, lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
 
 	/* Set the MAC address in the EmacLite device */
 	xemaclite_update_address(lp, ndev->dev_addr);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 004/111] net: xilinx_emaclite: fix receive buffer overflow
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 002/111] ibmvnic: Fix endian error when requesting device capabilities Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 003/111] net: xilinx_emaclite: fix freezes due to unordered I/O Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 005/111] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h Levin, Alexander (Sasha Levin)
                   ` (66 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Anssi Hannula, David S . Miller, Levin, Alexander (Sasha Levin)

From: Anssi Hannula <anssi.hannula@bitwise.fi>

[ Upstream commit cd224553641848dd17800fe559e4ff5d208553e8 ]

xilinx_emaclite looks at the received data to try to determine the
Ethernet packet length but does not properly clamp it if
proto_type == ETH_P_IP or 1500 < proto_type <= 1518, causing a buffer
overflow and a panic via skb_panic() as the length exceeds the allocated
skb size.

Fix those cases.

Also add an additional unconditional check with WARN_ON() at the end.

Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Fixes: bb81b2ddfa19 ("net: add Xilinx emac lite device driver")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index dfdb78cc13ad..aa02a03a6d8d 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -377,7 +377,7 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
  *
  * Return:	Total number of bytes received
  */
-static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
+static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data, int maxlen)
 {
 	void __iomem *addr;
 	u16 length, proto_type;
@@ -417,7 +417,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 
 	/* Check if received ethernet frame is a raw ethernet frame
 	 * or an IP packet or an ARP packet */
-	if (proto_type > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
+	if (proto_type > ETH_DATA_LEN) {
 
 		if (proto_type == ETH_P_IP) {
 			length = ((ntohl(xemaclite_readl(addr +
@@ -425,6 +425,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 					XEL_RXBUFF_OFFSET)) >>
 					XEL_HEADER_SHIFT) &
 					XEL_RPLR_LENGTH_MASK);
+			length = min_t(u16, length, ETH_DATA_LEN);
 			length += ETH_HLEN + ETH_FCS_LEN;
 
 		} else if (proto_type == ETH_P_ARP)
@@ -437,6 +438,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
 		/* Use the length in the frame, plus the header and trailer */
 		length = proto_type + ETH_HLEN + ETH_FCS_LEN;
 
+	if (WARN_ON(length > maxlen))
+		length = maxlen;
+
 	/* Read from the EmacLite device */
 	xemaclite_aligned_read((u32 __force *) (addr + XEL_RXBUFF_OFFSET),
 				data, length);
@@ -611,7 +615,7 @@ static void xemaclite_rx_handler(struct net_device *dev)
 
 	skb_reserve(skb, 2);
 
-	len = xemaclite_recv_data(lp, (u8 *) skb->data);
+	len = xemaclite_recv_data(lp, (u8 *) skb->data, len);
 
 	if (!len) {
 		dev->stats.rx_errors++;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 005/111] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (2 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 004/111] net: xilinx_emaclite: fix receive buffer overflow Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 006/111] bpf: kernel header files need to be copied into the tools directory Levin, Alexander (Sasha Levin)
                   ` (65 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Joe Stringer, Alexei Starovoitov, Daniel Borkmann,
	Arnaldo Carvalho de Melo, Levin, Alexander (Sasha Levin)

From: Joe Stringer <joe@ovn.org>

[ Upstream commit 0cb34dc2a37290f4069c5b01735c9725dc0a1b5c ]

The tools version of this header is out of date; update it to the latest
version from the kernel headers.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Link: http://lkml.kernel.org/r/20161209024620.31660-2-joe@ovn.org
[ Sync it harder, after merging with what was in net-next via perf/urgent via torvalds/master to get BPG_PROG_(AT|DE)TACH, etc ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/include/uapi/linux/bpf.h | 593 +++++++++++++++++++++++++----------------
 1 file changed, 364 insertions(+), 229 deletions(-)

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 9e5fc168c8a3..0eb0e87dbe9f 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -73,6 +73,8 @@ enum bpf_cmd {
 	BPF_PROG_LOAD,
 	BPF_OBJ_PIN,
 	BPF_OBJ_GET,
+	BPF_PROG_ATTACH,
+	BPF_PROG_DETACH,
 };
 
 enum bpf_map_type {
@@ -85,6 +87,8 @@ enum bpf_map_type {
 	BPF_MAP_TYPE_PERCPU_ARRAY,
 	BPF_MAP_TYPE_STACK_TRACE,
 	BPF_MAP_TYPE_CGROUP_ARRAY,
+	BPF_MAP_TYPE_LRU_HASH,
+	BPF_MAP_TYPE_LRU_PERCPU_HASH,
 };
 
 enum bpf_prog_type {
@@ -95,8 +99,23 @@ enum bpf_prog_type {
 	BPF_PROG_TYPE_SCHED_ACT,
 	BPF_PROG_TYPE_TRACEPOINT,
 	BPF_PROG_TYPE_XDP,
+	BPF_PROG_TYPE_PERF_EVENT,
+	BPF_PROG_TYPE_CGROUP_SKB,
+	BPF_PROG_TYPE_CGROUP_SOCK,
+	BPF_PROG_TYPE_LWT_IN,
+	BPF_PROG_TYPE_LWT_OUT,
+	BPF_PROG_TYPE_LWT_XMIT,
 };
 
+enum bpf_attach_type {
+	BPF_CGROUP_INET_INGRESS,
+	BPF_CGROUP_INET_EGRESS,
+	BPF_CGROUP_INET_SOCK_CREATE,
+	__MAX_BPF_ATTACH_TYPE
+};
+
+#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
+
 #define BPF_PSEUDO_MAP_FD	1
 
 /* flags for BPF_MAP_UPDATE_ELEM command */
@@ -105,6 +124,13 @@ enum bpf_prog_type {
 #define BPF_EXIST	2 /* update existing element */
 
 #define BPF_F_NO_PREALLOC	(1U << 0)
+/* Instead of having one common LRU list in the
+ * BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list
+ * which can scale and perform better.
+ * Note, the LRU nodes (including free nodes) cannot be moved
+ * across different LRU lists.
+ */
+#define BPF_F_NO_COMMON_LRU	(1U << 1)
 
 union bpf_attr {
 	struct { /* anonymous struct used by BPF_MAP_CREATE command */
@@ -140,243 +166,327 @@ union bpf_attr {
 		__aligned_u64	pathname;
 		__u32		bpf_fd;
 	};
+
+	struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */
+		__u32		target_fd;	/* container object to attach to */
+		__u32		attach_bpf_fd;	/* eBPF program to attach */
+		__u32		attach_type;
+	};
 } __attribute__((aligned(8)));
 
+/* BPF helper function descriptions:
+ *
+ * void *bpf_map_lookup_elem(&map, &key)
+ *     Return: Map value or NULL
+ *
+ * int bpf_map_update_elem(&map, &key, &value, flags)
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_map_delete_elem(&map, &key)
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_probe_read(void *dst, int size, void *src)
+ *     Return: 0 on success or negative error
+ *
+ * u64 bpf_ktime_get_ns(void)
+ *     Return: current ktime
+ *
+ * int bpf_trace_printk(const char *fmt, int fmt_size, ...)
+ *     Return: length of buffer written or negative error
+ *
+ * u32 bpf_prandom_u32(void)
+ *     Return: random value
+ *
+ * u32 bpf_raw_smp_processor_id(void)
+ *     Return: SMP processor ID
+ *
+ * int bpf_skb_store_bytes(skb, offset, from, len, flags)
+ *     store bytes into packet
+ *     @skb: pointer to skb
+ *     @offset: offset within packet from skb->mac_header
+ *     @from: pointer where to copy bytes from
+ *     @len: number of bytes to store into packet
+ *     @flags: bit 0 - if true, recompute skb->csum
+ *             other bits - reserved
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_l3_csum_replace(skb, offset, from, to, flags)
+ *     recompute IP checksum
+ *     @skb: pointer to skb
+ *     @offset: offset within packet where IP checksum is located
+ *     @from: old value of header field
+ *     @to: new value of header field
+ *     @flags: bits 0-3 - size of header field
+ *             other bits - reserved
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_l4_csum_replace(skb, offset, from, to, flags)
+ *     recompute TCP/UDP checksum
+ *     @skb: pointer to skb
+ *     @offset: offset within packet where TCP/UDP checksum is located
+ *     @from: old value of header field
+ *     @to: new value of header field
+ *     @flags: bits 0-3 - size of header field
+ *             bit 4 - is pseudo header
+ *             other bits - reserved
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_tail_call(ctx, prog_array_map, index)
+ *     jump into another BPF program
+ *     @ctx: context pointer passed to next program
+ *     @prog_array_map: pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY
+ *     @index: index inside array that selects specific program to run
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_clone_redirect(skb, ifindex, flags)
+ *     redirect to another netdev
+ *     @skb: pointer to skb
+ *     @ifindex: ifindex of the net device
+ *     @flags: bit 0 - if set, redirect to ingress instead of egress
+ *             other bits - reserved
+ *     Return: 0 on success or negative error
+ *
+ * u64 bpf_get_current_pid_tgid(void)
+ *     Return: current->tgid << 32 | current->pid
+ *
+ * u64 bpf_get_current_uid_gid(void)
+ *     Return: current_gid << 32 | current_uid
+ *
+ * int bpf_get_current_comm(char *buf, int size_of_buf)
+ *     stores current->comm into buf
+ *     Return: 0 on success or negative error
+ *
+ * u32 bpf_get_cgroup_classid(skb)
+ *     retrieve a proc's classid
+ *     @skb: pointer to skb
+ *     Return: classid if != 0
+ *
+ * int bpf_skb_vlan_push(skb, vlan_proto, vlan_tci)
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_vlan_pop(skb)
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_get_tunnel_key(skb, key, size, flags)
+ * int bpf_skb_set_tunnel_key(skb, key, size, flags)
+ *     retrieve or populate tunnel metadata
+ *     @skb: pointer to skb
+ *     @key: pointer to 'struct bpf_tunnel_key'
+ *     @size: size of 'struct bpf_tunnel_key'
+ *     @flags: room for future extensions
+ *     Return: 0 on success or negative error
+ *
+ * u64 bpf_perf_event_read(&map, index)
+ *     Return: Number events read or error code
+ *
+ * int bpf_redirect(ifindex, flags)
+ *     redirect to another netdev
+ *     @ifindex: ifindex of the net device
+ *     @flags: bit 0 - if set, redirect to ingress instead of egress
+ *             other bits - reserved
+ *     Return: TC_ACT_REDIRECT
+ *
+ * u32 bpf_get_route_realm(skb)
+ *     retrieve a dst's tclassid
+ *     @skb: pointer to skb
+ *     Return: realm if != 0
+ *
+ * int bpf_perf_event_output(ctx, map, index, data, size)
+ *     output perf raw sample
+ *     @ctx: struct pt_regs*
+ *     @map: pointer to perf_event_array map
+ *     @index: index of event in the map
+ *     @data: data on stack to be output as raw data
+ *     @size: size of data
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_get_stackid(ctx, map, flags)
+ *     walk user or kernel stack and return id
+ *     @ctx: struct pt_regs*
+ *     @map: pointer to stack_trace map
+ *     @flags: bits 0-7 - numer of stack frames to skip
+ *             bit 8 - collect user stack instead of kernel
+ *             bit 9 - compare stacks by hash only
+ *             bit 10 - if two different stacks hash into the same stackid
+ *                      discard old
+ *             other bits - reserved
+ *     Return: >= 0 stackid on success or negative error
+ *
+ * s64 bpf_csum_diff(from, from_size, to, to_size, seed)
+ *     calculate csum diff
+ *     @from: raw from buffer
+ *     @from_size: length of from buffer
+ *     @to: raw to buffer
+ *     @to_size: length of to buffer
+ *     @seed: optional seed
+ *     Return: csum result or negative error code
+ *
+ * int bpf_skb_get_tunnel_opt(skb, opt, size)
+ *     retrieve tunnel options metadata
+ *     @skb: pointer to skb
+ *     @opt: pointer to raw tunnel option data
+ *     @size: size of @opt
+ *     Return: option size
+ *
+ * int bpf_skb_set_tunnel_opt(skb, opt, size)
+ *     populate tunnel options metadata
+ *     @skb: pointer to skb
+ *     @opt: pointer to raw tunnel option data
+ *     @size: size of @opt
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_change_proto(skb, proto, flags)
+ *     Change protocol of the skb. Currently supported is v4 -> v6,
+ *     v6 -> v4 transitions. The helper will also resize the skb. eBPF
+ *     program is expected to fill the new headers via skb_store_bytes
+ *     and lX_csum_replace.
+ *     @skb: pointer to skb
+ *     @proto: new skb->protocol type
+ *     @flags: reserved
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_change_type(skb, type)
+ *     Change packet type of skb.
+ *     @skb: pointer to skb
+ *     @type: new skb->pkt_type type
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_under_cgroup(skb, map, index)
+ *     Check cgroup2 membership of skb
+ *     @skb: pointer to skb
+ *     @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
+ *     @index: index of the cgroup in the bpf_map
+ *     Return:
+ *       == 0 skb failed the cgroup2 descendant test
+ *       == 1 skb succeeded the cgroup2 descendant test
+ *        < 0 error
+ *
+ * u32 bpf_get_hash_recalc(skb)
+ *     Retrieve and possibly recalculate skb->hash.
+ *     @skb: pointer to skb
+ *     Return: hash
+ *
+ * u64 bpf_get_current_task(void)
+ *     Returns current task_struct
+ *     Return: current
+ *
+ * int bpf_probe_write_user(void *dst, void *src, int len)
+ *     safely attempt to write to a location
+ *     @dst: destination address in userspace
+ *     @src: source address on stack
+ *     @len: number of bytes to copy
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_current_task_under_cgroup(map, index)
+ *     Check cgroup2 membership of current task
+ *     @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
+ *     @index: index of the cgroup in the bpf_map
+ *     Return:
+ *       == 0 current failed the cgroup2 descendant test
+ *       == 1 current succeeded the cgroup2 descendant test
+ *        < 0 error
+ *
+ * int bpf_skb_change_tail(skb, len, flags)
+ *     The helper will resize the skb to the given new size, to be used f.e.
+ *     with control messages.
+ *     @skb: pointer to skb
+ *     @len: new skb length
+ *     @flags: reserved
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_skb_pull_data(skb, len)
+ *     The helper will pull in non-linear data in case the skb is non-linear
+ *     and not all of len are part of the linear section. Only needed for
+ *     read/write with direct packet access.
+ *     @skb: pointer to skb
+ *     @len: len to make read/writeable
+ *     Return: 0 on success or negative error
+ *
+ * s64 bpf_csum_update(skb, csum)
+ *     Adds csum into skb->csum in case of CHECKSUM_COMPLETE.
+ *     @skb: pointer to skb
+ *     @csum: csum to add
+ *     Return: csum on success or negative error
+ *
+ * void bpf_set_hash_invalid(skb)
+ *     Invalidate current skb->hash.
+ *     @skb: pointer to skb
+ *
+ * int bpf_get_numa_node_id()
+ *     Return: Id of current NUMA node.
+ *
+ * int bpf_skb_change_head()
+ *     Grows headroom of skb and adjusts MAC header offset accordingly.
+ *     Will extends/reallocae as required automatically.
+ *     May change skb data pointer and will thus invalidate any check
+ *     performed for direct packet access.
+ *     @skb: pointer to skb
+ *     @len: length of header to be pushed in front
+ *     @flags: Flags (unused for now)
+ *     Return: 0 on success or negative error
+ *
+ * int bpf_xdp_adjust_head(xdp_md, delta)
+ *     Adjust the xdp_md.data by delta
+ *     @xdp_md: pointer to xdp_md
+ *     @delta: An positive/negative integer to be added to xdp_md.data
+ *     Return: 0 on success or negative on error
+ */
+#define __BPF_FUNC_MAPPER(FN)		\
+	FN(unspec),			\
+	FN(map_lookup_elem),		\
+	FN(map_update_elem),		\
+	FN(map_delete_elem),		\
+	FN(probe_read),			\
+	FN(ktime_get_ns),		\
+	FN(trace_printk),		\
+	FN(get_prandom_u32),		\
+	FN(get_smp_processor_id),	\
+	FN(skb_store_bytes),		\
+	FN(l3_csum_replace),		\
+	FN(l4_csum_replace),		\
+	FN(tail_call),			\
+	FN(clone_redirect),		\
+	FN(get_current_pid_tgid),	\
+	FN(get_current_uid_gid),	\
+	FN(get_current_comm),		\
+	FN(get_cgroup_classid),		\
+	FN(skb_vlan_push),		\
+	FN(skb_vlan_pop),		\
+	FN(skb_get_tunnel_key),		\
+	FN(skb_set_tunnel_key),		\
+	FN(perf_event_read),		\
+	FN(redirect),			\
+	FN(get_route_realm),		\
+	FN(perf_event_output),		\
+	FN(skb_load_bytes),		\
+	FN(get_stackid),		\
+	FN(csum_diff),			\
+	FN(skb_get_tunnel_opt),		\
+	FN(skb_set_tunnel_opt),		\
+	FN(skb_change_proto),		\
+	FN(skb_change_type),		\
+	FN(skb_under_cgroup),		\
+	FN(get_hash_recalc),		\
+	FN(get_current_task),		\
+	FN(probe_write_user),		\
+	FN(current_task_under_cgroup),	\
+	FN(skb_change_tail),		\
+	FN(skb_pull_data),		\
+	FN(csum_update),		\
+	FN(set_hash_invalid),		\
+	FN(get_numa_node_id),		\
+	FN(skb_change_head),		\
+	FN(xdp_adjust_head),
+
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
  */
+#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x
 enum bpf_func_id {
-	BPF_FUNC_unspec,
-	BPF_FUNC_map_lookup_elem, /* void *map_lookup_elem(&map, &key) */
-	BPF_FUNC_map_update_elem, /* int map_update_elem(&map, &key, &value, flags) */
-	BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */
-	BPF_FUNC_probe_read,      /* int bpf_probe_read(void *dst, int size, void *src) */
-	BPF_FUNC_ktime_get_ns,    /* u64 bpf_ktime_get_ns(void) */
-	BPF_FUNC_trace_printk,    /* int bpf_trace_printk(const char *fmt, int fmt_size, ...) */
-	BPF_FUNC_get_prandom_u32, /* u32 prandom_u32(void) */
-	BPF_FUNC_get_smp_processor_id, /* u32 raw_smp_processor_id(void) */
-
-	/**
-	 * skb_store_bytes(skb, offset, from, len, flags) - store bytes into packet
-	 * @skb: pointer to skb
-	 * @offset: offset within packet from skb->mac_header
-	 * @from: pointer where to copy bytes from
-	 * @len: number of bytes to store into packet
-	 * @flags: bit 0 - if true, recompute skb->csum
-	 *         other bits - reserved
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_skb_store_bytes,
-
-	/**
-	 * l3_csum_replace(skb, offset, from, to, flags) - recompute IP checksum
-	 * @skb: pointer to skb
-	 * @offset: offset within packet where IP checksum is located
-	 * @from: old value of header field
-	 * @to: new value of header field
-	 * @flags: bits 0-3 - size of header field
-	 *         other bits - reserved
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_l3_csum_replace,
-
-	/**
-	 * l4_csum_replace(skb, offset, from, to, flags) - recompute TCP/UDP checksum
-	 * @skb: pointer to skb
-	 * @offset: offset within packet where TCP/UDP checksum is located
-	 * @from: old value of header field
-	 * @to: new value of header field
-	 * @flags: bits 0-3 - size of header field
-	 *         bit 4 - is pseudo header
-	 *         other bits - reserved
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_l4_csum_replace,
-
-	/**
-	 * bpf_tail_call(ctx, prog_array_map, index) - jump into another BPF program
-	 * @ctx: context pointer passed to next program
-	 * @prog_array_map: pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY
-	 * @index: index inside array that selects specific program to run
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_tail_call,
-
-	/**
-	 * bpf_clone_redirect(skb, ifindex, flags) - redirect to another netdev
-	 * @skb: pointer to skb
-	 * @ifindex: ifindex of the net device
-	 * @flags: bit 0 - if set, redirect to ingress instead of egress
-	 *         other bits - reserved
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_clone_redirect,
-
-	/**
-	 * u64 bpf_get_current_pid_tgid(void)
-	 * Return: current->tgid << 32 | current->pid
-	 */
-	BPF_FUNC_get_current_pid_tgid,
-
-	/**
-	 * u64 bpf_get_current_uid_gid(void)
-	 * Return: current_gid << 32 | current_uid
-	 */
-	BPF_FUNC_get_current_uid_gid,
-
-	/**
-	 * bpf_get_current_comm(char *buf, int size_of_buf)
-	 * stores current->comm into buf
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_get_current_comm,
-
-	/**
-	 * bpf_get_cgroup_classid(skb) - retrieve a proc's classid
-	 * @skb: pointer to skb
-	 * Return: classid if != 0
-	 */
-	BPF_FUNC_get_cgroup_classid,
-	BPF_FUNC_skb_vlan_push, /* bpf_skb_vlan_push(skb, vlan_proto, vlan_tci) */
-	BPF_FUNC_skb_vlan_pop,  /* bpf_skb_vlan_pop(skb) */
-
-	/**
-	 * bpf_skb_[gs]et_tunnel_key(skb, key, size, flags)
-	 * retrieve or populate tunnel metadata
-	 * @skb: pointer to skb
-	 * @key: pointer to 'struct bpf_tunnel_key'
-	 * @size: size of 'struct bpf_tunnel_key'
-	 * @flags: room for future extensions
-	 * Retrun: 0 on success
-	 */
-	BPF_FUNC_skb_get_tunnel_key,
-	BPF_FUNC_skb_set_tunnel_key,
-	BPF_FUNC_perf_event_read,	/* u64 bpf_perf_event_read(&map, index) */
-	/**
-	 * bpf_redirect(ifindex, flags) - redirect to another netdev
-	 * @ifindex: ifindex of the net device
-	 * @flags: bit 0 - if set, redirect to ingress instead of egress
-	 *         other bits - reserved
-	 * Return: TC_ACT_REDIRECT
-	 */
-	BPF_FUNC_redirect,
-
-	/**
-	 * bpf_get_route_realm(skb) - retrieve a dst's tclassid
-	 * @skb: pointer to skb
-	 * Return: realm if != 0
-	 */
-	BPF_FUNC_get_route_realm,
-
-	/**
-	 * bpf_perf_event_output(ctx, map, index, data, size) - output perf raw sample
-	 * @ctx: struct pt_regs*
-	 * @map: pointer to perf_event_array map
-	 * @index: index of event in the map
-	 * @data: data on stack to be output as raw data
-	 * @size: size of data
-	 * Return: 0 on success
-	 */
-	BPF_FUNC_perf_event_output,
-	BPF_FUNC_skb_load_bytes,
-
-	/**
-	 * bpf_get_stackid(ctx, map, flags) - walk user or kernel stack and return id
-	 * @ctx: struct pt_regs*
-	 * @map: pointer to stack_trace map
-	 * @flags: bits 0-7 - numer of stack frames to skip
-	 *         bit 8 - collect user stack instead of kernel
-	 *         bit 9 - compare stacks by hash only
-	 *         bit 10 - if two different stacks hash into the same stackid
-	 *                  discard old
-	 *         other bits - reserved
-	 * Return: >= 0 stackid on success or negative error
-	 */
-	BPF_FUNC_get_stackid,
-
-	/**
-	 * bpf_csum_diff(from, from_size, to, to_size, seed) - calculate csum diff
-	 * @from: raw from buffer
-	 * @from_size: length of from buffer
-	 * @to: raw to buffer
-	 * @to_size: length of to buffer
-	 * @seed: optional seed
-	 * Return: csum result
-	 */
-	BPF_FUNC_csum_diff,
-
-	/**
-	 * bpf_skb_[gs]et_tunnel_opt(skb, opt, size)
-	 * retrieve or populate tunnel options metadata
-	 * @skb: pointer to skb
-	 * @opt: pointer to raw tunnel option data
-	 * @size: size of @opt
-	 * Return: 0 on success for set, option size for get
-	 */
-	BPF_FUNC_skb_get_tunnel_opt,
-	BPF_FUNC_skb_set_tunnel_opt,
-
-	/**
-	 * bpf_skb_change_proto(skb, proto, flags)
-	 * Change protocol of the skb. Currently supported is
-	 * v4 -> v6, v6 -> v4 transitions. The helper will also
-	 * resize the skb. eBPF program is expected to fill the
-	 * new headers via skb_store_bytes and lX_csum_replace.
-	 * @skb: pointer to skb
-	 * @proto: new skb->protocol type
-	 * @flags: reserved
-	 * Return: 0 on success or negative error
-	 */
-	BPF_FUNC_skb_change_proto,
-
-	/**
-	 * bpf_skb_change_type(skb, type)
-	 * Change packet type of skb.
-	 * @skb: pointer to skb
-	 * @type: new skb->pkt_type type
-	 * Return: 0 on success or negative error
-	 */
-	BPF_FUNC_skb_change_type,
-
-	/**
-	 * bpf_skb_under_cgroup(skb, map, index) - Check cgroup2 membership of skb
-	 * @skb: pointer to skb
-	 * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
-	 * @index: index of the cgroup in the bpf_map
-	 * Return:
-	 *   == 0 skb failed the cgroup2 descendant test
-	 *   == 1 skb succeeded the cgroup2 descendant test
-	 *    < 0 error
-	 */
-	BPF_FUNC_skb_under_cgroup,
-
-	/**
-	 * bpf_get_hash_recalc(skb)
-	 * Retrieve and possibly recalculate skb->hash.
-	 * @skb: pointer to skb
-	 * Return: hash
-	 */
-	BPF_FUNC_get_hash_recalc,
-
-	/**
-	 * u64 bpf_get_current_task(void)
-	 * Returns current task_struct
-	 * Return: current
-	 */
-	BPF_FUNC_get_current_task,
-
-	/**
-	 * bpf_probe_write_user(void *dst, void *src, int len)
-	 * safely attempt to write to a location
-	 * @dst: destination address in userspace
-	 * @src: source address on stack
-	 * @len: number of bytes to copy
-	 * Return: 0 on success or negative error
-	 */
-	BPF_FUNC_probe_write_user,
-
+	__BPF_FUNC_MAPPER(__BPF_ENUM_FN)
 	__BPF_FUNC_MAX_ID,
 };
+#undef __BPF_ENUM_FN
 
 /* All flags used by eBPF helper functions, placed here. */
 
@@ -450,6 +560,31 @@ struct bpf_tunnel_key {
 	__u32 tunnel_label;
 };
 
+/* Generic BPF return codes which all BPF program types may support.
+ * The values are binary compatible with their TC_ACT_* counter-part to
+ * provide backwards compatibility with existing SCHED_CLS and SCHED_ACT
+ * programs.
+ *
+ * XDP is handled seprately, see XDP_*.
+ */
+enum bpf_ret_code {
+	BPF_OK = 0,
+	/* 1 reserved */
+	BPF_DROP = 2,
+	/* 3-6 reserved */
+	BPF_REDIRECT = 7,
+	/* >127 are reserved for prog type specific return codes */
+};
+
+struct bpf_sock {
+	__u32 bound_dev_if;
+	__u32 family;
+	__u32 type;
+	__u32 protocol;
+};
+
+#define XDP_PACKET_HEADROOM 256
+
 /* User return codes for XDP prog type.
  * A valid XDP program must return one of these defined values. All other
  * return codes are reserved for future use. Unknown return codes will result
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 006/111] bpf: kernel header files need to be copied into the tools directory
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (3 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 005/111] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 007/111] tcp: tcp_probe: use spin_lock_bh() Levin, Alexander (Sasha Levin)
                   ` (64 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Stephen Rothwell, David S . Miller, Levin, Alexander (Sasha Levin)

From: Stephen Rothwell <sfr@canb.auug.org.au>

[ Upstream commit 5463b3d043826ff8ef487edbd1ef1bfffb677437 ]

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 tools/include/uapi/linux/bpf.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 0eb0e87dbe9f..d2b0ac799d03 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -116,6 +116,12 @@ enum bpf_attach_type {
 
 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
 
+/* If BPF_F_ALLOW_OVERRIDE flag is used in BPF_PROG_ATTACH command
+ * to the given target_fd cgroup the descendent cgroup will be able to
+ * override effective bpf program that was inherited from this cgroup
+ */
+#define BPF_F_ALLOW_OVERRIDE	(1U << 0)
+
 #define BPF_PSEUDO_MAP_FD	1
 
 /* flags for BPF_MAP_UPDATE_ELEM command */
@@ -171,6 +177,7 @@ union bpf_attr {
 		__u32		target_fd;	/* container object to attach to */
 		__u32		attach_bpf_fd;	/* eBPF program to attach */
 		__u32		attach_type;
+		__u32		attach_flags;
 	};
 } __attribute__((aligned(8)));
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 007/111] tcp: tcp_probe: use spin_lock_bh()
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (4 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 006/111] bpf: kernel header files need to be copied into the tools directory Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 008/111] ipv6: Handle IPv4-mapped src to in6addr_any dst Levin, Alexander (Sasha Levin)
                   ` (63 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Eric Dumazet, David S . Miller, Levin, Alexander (Sasha Levin)

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit e70ac171658679ecf6bea4bbd9e9325cd6079d2b ]

tcp_rcv_established() can now run in process context.

We need to disable BH while acquiring tcp probe spinlock,
or risk a deadlock.

Fixes: 5413d1babe8f ("net: do not block BH while processing socket backlog")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Ricardo Nabinger Sanchez <rnsanchez@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv4/tcp_probe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index f6c50af24a64..3d063eb37848 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -117,7 +117,7 @@ static void jtcp_rcv_established(struct sock *sk, struct sk_buff *skb,
 	     (fwmark > 0 && skb->mark == fwmark)) &&
 	    (full || tp->snd_cwnd != tcp_probe.lastcwnd)) {
 
-		spin_lock(&tcp_probe.lock);
+		spin_lock_bh(&tcp_probe.lock);
 		/* If log fills, just silently drop */
 		if (tcp_probe_avail() > 1) {
 			struct tcp_log *p = tcp_probe.log + tcp_probe.head;
@@ -157,7 +157,7 @@ static void jtcp_rcv_established(struct sock *sk, struct sk_buff *skb,
 			tcp_probe.head = (tcp_probe.head + 1) & (bufsize - 1);
 		}
 		tcp_probe.lastcwnd = tp->snd_cwnd;
-		spin_unlock(&tcp_probe.lock);
+		spin_unlock_bh(&tcp_probe.lock);
 
 		wake_up(&tcp_probe.wait);
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 009/111] ipv6: Inhibit IPv4-mapped src address on the wire.
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (6 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 008/111] ipv6: Handle IPv4-mapped src to in6addr_any dst Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 010/111] tipc: Fix tipc_sk_reinit race conditions Levin, Alexander (Sasha Levin)
                   ` (61 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Jonathan T. Leighton, David S . Miller, Levin, Alexander (Sasha Levin)

From: "Jonathan T. Leighton" <jtleight@udel.edu>

[ Upstream commit ec5e3b0a1d41fbda0cc33a45bc9e54e91d9d12c7 ]

This patch adds a check for the problematic case of an IPv4-mapped IPv6
source address and a destination address that is neither an IPv4-mapped
IPv6 address nor in6addr_any, and returns an appropriate error. The
check in done before returning from looking up the route.

Signed-off-by: Jonathan T. Leighton <jtleight@udel.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv6/ip6_output.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e27b8fdba5d2..2f495063e4cc 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1016,6 +1016,9 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
 		}
 	}
 #endif
+	if (ipv6_addr_v4mapped(&fl6->saddr) &&
+	    !(ipv6_addr_v4mapped(&fl6->daddr) || ipv6_addr_any(&fl6->daddr)))
+		return -EAFNOSUPPORT;
 
 	return 0;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 008/111] ipv6: Handle IPv4-mapped src to in6addr_any dst.
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (5 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 007/111] tcp: tcp_probe: use spin_lock_bh() Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 009/111] ipv6: Inhibit IPv4-mapped src address on the wire Levin, Alexander (Sasha Levin)
                   ` (62 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Jonathan T. Leighton, David S . Miller, Levin, Alexander (Sasha Levin)

From: "Jonathan T. Leighton" <jtleight@udel.edu>

[ Upstream commit 052d2369d1b479cdbbe020fdd6d057d3c342db74 ]

This patch adds a check on the type of the source address for the case
where the destination address is in6addr_any. If the source is an
IPv4-mapped IPv6 source address, the destination is changed to
::ffff:127.0.0.1, and otherwise the destination is changed to ::1. This
is done in three locations to handle UDP calls to either connect() or
sendmsg() and TCP calls to connect(). Note that udpv6_sendmsg() delays
handling an in6addr_any destination until very late, so the patch only
needs to handle the case where the source is an IPv4-mapped IPv6
address.

Signed-off-by: Jonathan T. Leighton <jtleight@udel.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv6/datagram.c | 14 +++++++++-----
 net/ipv6/tcp_ipv6.c | 11 ++++++++---
 net/ipv6/udp.c      |  4 ++++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 442ec1f39ed1..38062f403ceb 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -166,18 +166,22 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
 	if (np->sndflow)
 		fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
 
-	addr_type = ipv6_addr_type(&usin->sin6_addr);
-
-	if (addr_type == IPV6_ADDR_ANY) {
+	if (ipv6_addr_any(&usin->sin6_addr)) {
 		/*
 		 *	connect to self
 		 */
-		usin->sin6_addr.s6_addr[15] = 0x01;
+		if (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
+			ipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),
+					       &usin->sin6_addr);
+		else
+			usin->sin6_addr = in6addr_loopback;
 	}
 
+	addr_type = ipv6_addr_type(&usin->sin6_addr);
+
 	daddr = &usin->sin6_addr;
 
-	if (addr_type == IPV6_ADDR_MAPPED) {
+	if (addr_type & IPV6_ADDR_MAPPED) {
 		struct sockaddr_in sin;
 
 		if (__ipv6_only_sock(sk)) {
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index b2e61a0e8d0a..f39e6dec9800 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -148,8 +148,13 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
 	 *	connect() to INADDR_ANY means loopback (BSD'ism).
 	 */
 
-	if (ipv6_addr_any(&usin->sin6_addr))
-		usin->sin6_addr.s6_addr[15] = 0x1;
+	if (ipv6_addr_any(&usin->sin6_addr)) {
+		if (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
+			ipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),
+					       &usin->sin6_addr);
+		else
+			usin->sin6_addr = in6addr_loopback;
+	}
 
 	addr_type = ipv6_addr_type(&usin->sin6_addr);
 
@@ -188,7 +193,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
 	 *	TCP over IPv4
 	 */
 
-	if (addr_type == IPV6_ADDR_MAPPED) {
+	if (addr_type & IPV6_ADDR_MAPPED) {
 		u32 exthdrlen = icsk->icsk_ext_hdr_len;
 		struct sockaddr_in sin;
 
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 40a289f78d77..2497f62fa4c2 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1049,6 +1049,10 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 			if (addr_len < SIN6_LEN_RFC2133)
 				return -EINVAL;
 			daddr = &sin6->sin6_addr;
+			if (ipv6_addr_any(daddr) &&
+			    ipv6_addr_v4mapped(&np->saddr))
+				ipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),
+						       daddr);
 			break;
 		case AF_INET:
 			goto do_udp_sendmsg;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 010/111] tipc: Fix tipc_sk_reinit race conditions
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (7 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 009/111] ipv6: Inhibit IPv4-mapped src address on the wire Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 011/111] gfs2: Use rhashtable walk interface in glock_hash_walk Levin, Alexander (Sasha Levin)
                   ` (60 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Herbert Xu, David S . Miller, Levin, Alexander (Sasha Levin)

From: Herbert Xu <herbert@gondor.apana.org.au>

[ Upstream commit 9dbbfb0ab6680c6a85609041011484e6658e7d3c ]

There are two problems with the function tipc_sk_reinit.  Firstly
it's doing a manual walk over an rhashtable.  This is broken as
an rhashtable can be resized and if you manually walk over it
during a resize then you may miss entries.

Secondly it's missing memory barriers as previously the code used
spinlocks which provide the barriers implicitly.

This patch fixes both problems.

Fixes: 07f6c4bc048a ("tipc: convert tipc reference table to...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/tipc/net.c    |  4 ++++
 net/tipc/socket.c | 30 +++++++++++++++++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/net/tipc/net.c b/net/tipc/net.c
index 28bf4feeb81c..ab8a2d5d1e32 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -110,6 +110,10 @@ int tipc_net_start(struct net *net, u32 addr)
 	char addr_string[16];
 
 	tn->own_addr = addr;
+
+	/* Ensure that the new address is visible before we reinit. */
+	smp_mb();
+
 	tipc_named_reinit(net);
 	tipc_sk_reinit(net);
 
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 41f013888f07..25bc5c30d7fb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -335,8 +335,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
 	INIT_LIST_HEAD(&tsk->publications);
 	msg = &tsk->phdr;
 	tn = net_generic(sock_net(sk), tipc_net_id);
-	tipc_msg_init(tn->own_addr, msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG,
-		      NAMED_H_SIZE, 0);
 
 	/* Finish initializing socket data structures */
 	sock->ops = ops;
@@ -346,6 +344,13 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
 		pr_warn("Socket create failed; port number exhausted\n");
 		return -EINVAL;
 	}
+
+	/* Ensure tsk is visible before we read own_addr. */
+	smp_mb();
+
+	tipc_msg_init(tn->own_addr, msg, TIPC_LOW_IMPORTANCE, TIPC_NAMED_MSG,
+		      NAMED_H_SIZE, 0);
+
 	msg_set_origport(msg, tsk->portid);
 	setup_timer(&sk->sk_timer, tipc_sk_timeout, (unsigned long)tsk);
 	sk->sk_backlog_rcv = tipc_backlog_rcv;
@@ -2264,24 +2269,27 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
 void tipc_sk_reinit(struct net *net)
 {
 	struct tipc_net *tn = net_generic(net, tipc_net_id);
-	const struct bucket_table *tbl;
-	struct rhash_head *pos;
+	struct rhashtable_iter iter;
 	struct tipc_sock *tsk;
 	struct tipc_msg *msg;
-	int i;
 
-	rcu_read_lock();
-	tbl = rht_dereference_rcu((&tn->sk_rht)->tbl, &tn->sk_rht);
-	for (i = 0; i < tbl->size; i++) {
-		rht_for_each_entry_rcu(tsk, pos, tbl, i, node) {
+	rhashtable_walk_enter(&tn->sk_rht, &iter);
+
+	do {
+		tsk = ERR_PTR(rhashtable_walk_start(&iter));
+		if (tsk)
+			continue;
+
+		while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) {
 			spin_lock_bh(&tsk->sk.sk_lock.slock);
 			msg = &tsk->phdr;
 			msg_set_prevnode(msg, tn->own_addr);
 			msg_set_orignode(msg, tn->own_addr);
 			spin_unlock_bh(&tsk->sk.sk_lock.slock);
 		}
-	}
-	rcu_read_unlock();
+
+		rhashtable_walk_stop(&iter);
+	} while (tsk == ERR_PTR(-EAGAIN));
 }
 
 static struct tipc_sock *tipc_sk_lookup(struct net *net, u32 portid)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 011/111] gfs2: Use rhashtable walk interface in glock_hash_walk
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (8 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 010/111] tipc: Fix tipc_sk_reinit race conditions Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 012/111] NET: Fix /proc/net/arp for AX.25 Levin, Alexander (Sasha Levin)
                   ` (59 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Herbert Xu, David S . Miller, Levin, Alexander (Sasha Levin)

From: Herbert Xu <herbert@gondor.apana.org.au>

[ Upstream commit 6a25478077d987edc5e2f880590a2bc5fcab4441 ]

The function glock_hash_walk walks the rhashtable by hand.  This
is broken because if it catches the hash table in the middle of
a rehash, then it will miss entries.

This patch replaces the manual walk by using the rhashtable walk
interface.

Fixes: 88ffbf3e037e ("GFS2: Use resizable hash table for glocks")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/gfs2/glock.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 133f322573b5..6528724ad6e5 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1425,26 +1425,32 @@ static struct shrinker glock_shrinker = {
  * @sdp: the filesystem
  * @bucket: the bucket
  *
+ * Note that the function can be called multiple times on the same
+ * object.  So the user must ensure that the function can cope with
+ * that.
  */
 
 static void glock_hash_walk(glock_examiner examiner, const struct gfs2_sbd *sdp)
 {
 	struct gfs2_glock *gl;
-	struct rhash_head *pos;
-	const struct bucket_table *tbl;
-	int i;
+	struct rhashtable_iter iter;
 
-	rcu_read_lock();
-	tbl = rht_dereference_rcu(gl_hash_table.tbl, &gl_hash_table);
-	for (i = 0; i < tbl->size; i++) {
-		rht_for_each_entry_rcu(gl, pos, tbl, i, gl_node) {
+	rhashtable_walk_enter(&gl_hash_table, &iter);
+
+	do {
+		gl = ERR_PTR(rhashtable_walk_start(&iter));
+		if (gl)
+			continue;
+
+		while ((gl = rhashtable_walk_next(&iter)) && !IS_ERR(gl))
 			if ((gl->gl_name.ln_sbd == sdp) &&
 			    lockref_get_not_dead(&gl->gl_lockref))
 				examiner(gl);
-		}
-	}
-	rcu_read_unlock();
-	cond_resched();
+
+		rhashtable_walk_stop(&iter);
+	} while (cond_resched(), gl == ERR_PTR(-EAGAIN));
+
+	rhashtable_walk_exit(&iter);
 }
 
 /**
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 013/111] ibmvnic: Call napi_disable instead of napi_enable in failure path
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (10 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 012/111] NET: Fix /proc/net/arp for AX.25 Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 014/111] ibmvnic: Initialize completion variables before starting work Levin, Alexander (Sasha Levin)
                   ` (57 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Nathan Fontenot, David S . Miller, Levin, Alexander (Sasha Levin)

From: Nathan Fontenot <nfont@linux.vnet.ibm.com>

[ Upstream commit e722af6391949e8851310441bb0cec157d25611d ]

The failure path in ibmvnic_open() mistakenly makes a second call
to napi_enable instead of calling napi_disable. This can result
in a BUG_ON for any queues that were enabled in the previous call
to napi_enable.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index d1cf37dc3aa2..38314244f000 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -505,7 +505,7 @@ static int ibmvnic_open(struct net_device *netdev)
 	adapter->rx_pool = NULL;
 rx_pool_arr_alloc_failed:
 	for (i = 0; i < adapter->req_rx_queues; i++)
-		napi_enable(&adapter->napi[i]);
+		napi_disable(&adapter->napi[i]);
 alloc_napi_failed:
 	return -ENOMEM;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 012/111] NET: Fix /proc/net/arp for AX.25
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (9 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 011/111] gfs2: Use rhashtable walk interface in glock_hash_walk Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 013/111] ibmvnic: Call napi_disable instead of napi_enable in failure path Levin, Alexander (Sasha Levin)
                   ` (58 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Ralf Baechle, David S . Miller, Levin, Alexander (Sasha Levin)

From: Ralf Baechle <ralf@linux-mips.org>

[ Upstream commit 4872e57c812dd312bf8193b5933fa60585cda42f ]

When sending ARP requests over AX.25 links the hwaddress in the neighbour
cache are not getting initialized.  For such an incomplete arp entry
ax2asc2 will generate an empty string resulting in /proc/net/arp output
like the following:

$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
192.168.122.1    0x1         0x2         52:54:00:00:5d:5f     *        ens3
172.20.1.99      0x3         0x0              *        bpq0

The missing field will confuse the procfs parsing of arp(8) resulting in
incorrect output for the device such as the following:

$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
gateway                  ether   52:54:00:00:5d:5f   C                     ens3
172.20.1.99                      (incomplete)                              ens3

This changes the content of /proc/net/arp to:

$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
172.20.1.99      0x3         0x0         *                     *        bpq0
192.168.122.1    0x1         0x2         52:54:00:00:5d:5f     *        ens3

To do so it change ax2asc to put the string "*" in buf for a NULL address
argument.  Finally the HW address field is left aligned in a 17 character
field (the length of an ethernet HW address in the usual hex notation) for
readability.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv4/arp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 89a8cac4726a..51b27ae09fbd 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1263,7 +1263,7 @@ void __init arp_init(void)
 /*
  *	ax25 -> ASCII conversion
  */
-static char *ax2asc2(ax25_address *a, char *buf)
+static void ax2asc2(ax25_address *a, char *buf)
 {
 	char c, *s;
 	int n;
@@ -1285,10 +1285,10 @@ static char *ax2asc2(ax25_address *a, char *buf)
 	*s++ = n + '0';
 	*s++ = '\0';
 
-	if (*buf == '\0' || *buf == '-')
-		return "*";
-
-	return buf;
+	if (*buf == '\0' || *buf == '-') {
+		buf[0] = '*';
+		buf[1] = '\0';
+	}
 }
 #endif /* CONFIG_AX25 */
 
@@ -1322,7 +1322,7 @@ static void arp_format_neigh_entry(struct seq_file *seq,
 	}
 #endif
 	sprintf(tbuf, "%pI4", n->primary_key);
-	seq_printf(seq, "%-16s 0x%-10x0x%-10x%s     *        %s\n",
+	seq_printf(seq, "%-16s 0x%-10x0x%-10x%-17s     *        %s\n",
 		   tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
 	read_unlock(&n->lock);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 014/111] ibmvnic: Initialize completion variables before starting work
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (11 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 013/111] ibmvnic: Call napi_disable instead of napi_enable in failure path Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 015/111] NET: mkiss: Fix panic Levin, Alexander (Sasha Levin)
                   ` (56 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable; +Cc: Nathan Fontenot, David S . Miller, Levin, Alexander (Sasha Levin)

From: Nathan Fontenot <nfont@linux.vnet.ibm.com>

[ Upstream commit db5d0b597bc27bbddf40f2f8359a73be4eb77104 ]

Initialize condition variables prior to invoking any work that can
mark them complete. This resolves a race in the ibmvnic driver where
the driver faults trying to complete an uninitialized condition
variable.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 38314244f000..9f2184be55dc 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -189,9 +189,10 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter,
 	}
 	ltb->map_id = adapter->map_id;
 	adapter->map_id++;
+
+	init_completion(&adapter->fw_done);
 	send_request_map(adapter, ltb->addr,
 			 ltb->size, ltb->map_id);
-	init_completion(&adapter->fw_done);
 	wait_for_completion(&adapter->fw_done);
 	return 0;
 }
@@ -1133,10 +1134,10 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
 	crq.request_statistics.ioba = cpu_to_be32(adapter->stats_token);
 	crq.request_statistics.len =
 	    cpu_to_be32(sizeof(struct ibmvnic_statistics));
-	ibmvnic_send_crq(adapter, &crq);
 
 	/* Wait for data to be written */
 	init_completion(&adapter->stats_done);
+	ibmvnic_send_crq(adapter, &crq);
 	wait_for_completion(&adapter->stats_done);
 
 	for (i = 0; i < ARRAY_SIZE(ibmvnic_stats); i++)
@@ -2809,9 +2810,9 @@ static ssize_t trace_read(struct file *file, char __user *user_buf, size_t len,
 	crq.collect_fw_trace.correlator = adapter->ras_comps[num].correlator;
 	crq.collect_fw_trace.ioba = cpu_to_be32(trace_tok);
 	crq.collect_fw_trace.len = adapter->ras_comps[num].trace_buff_size;
-	ibmvnic_send_crq(adapter, &crq);
 
 	init_completion(&adapter->fw_done);
+	ibmvnic_send_crq(adapter, &crq);
 	wait_for_completion(&adapter->fw_done);
 
 	if (*ppos + len > be32_to_cpu(adapter->ras_comps[num].trace_buff_size))
@@ -3591,9 +3592,9 @@ static int ibmvnic_dump_show(struct seq_file *seq, void *v)
 	memset(&crq, 0, sizeof(crq));
 	crq.request_dump_size.first = IBMVNIC_CRQ_CMD;
 	crq.request_dump_size.cmd = REQUEST_DUMP_SIZE;
-	ibmvnic_send_crq(adapter, &crq);
 
 	init_completion(&adapter->fw_done);
+	ibmvnic_send_crq(adapter, &crq);
 	wait_for_completion(&adapter->fw_done);
 
 	seq_write(seq, adapter->dump_data, adapter->dump_data_size);
@@ -3639,8 +3640,8 @@ static void handle_crq_init_rsp(struct work_struct *work)
 		}
 	}
 
-	send_version_xchg(adapter);
 	reinit_completion(&adapter->init_done);
+	send_version_xchg(adapter);
 	if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
 		dev_err(dev, "Passive init timeout\n");
 		goto task_failed;
@@ -3650,9 +3651,9 @@ static void handle_crq_init_rsp(struct work_struct *work)
 		if (adapter->renegotiate) {
 			adapter->renegotiate = false;
 			release_sub_crqs_no_irqs(adapter);
-			send_cap_queries(adapter);
 
 			reinit_completion(&adapter->init_done);
+			send_cap_queries(adapter);
 			if (!wait_for_completion_timeout(&adapter->init_done,
 							 timeout)) {
 				dev_err(dev, "Passive init timeout\n");
@@ -3780,9 +3781,9 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 			adapter->debugfs_dump = ent;
 		}
 	}
-	ibmvnic_send_crq_init(adapter);
 
 	init_completion(&adapter->init_done);
+	ibmvnic_send_crq_init(adapter);
 	if (!wait_for_completion_timeout(&adapter->init_done, timeout))
 		return 0;
 
@@ -3790,9 +3791,9 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 		if (adapter->renegotiate) {
 			adapter->renegotiate = false;
 			release_sub_crqs_no_irqs(adapter);
-			send_cap_queries(adapter);
 
 			reinit_completion(&adapter->init_done);
+			send_cap_queries(adapter);
 			if (!wait_for_completion_timeout(&adapter->init_done,
 							 timeout))
 				return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 015/111] NET: mkiss: Fix panic
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (12 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 014/111] ibmvnic: Initialize completion variables before starting work Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 016/111] net: hns: Fix the device being used for dma mapping during TX Levin, Alexander (Sasha Levin)
                   ` (55 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Ralf Baechle, Thomas Osterried, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Ralf Baechle <ralf@linux-mips.org>

[ Upstream commit 7ba1b689038726d34e3244c1ac9e2e18c2ea4787 ]

If a USB-to-serial adapter is unplugged, the driver re-initializes, with
dev->hard_header_len and dev->addr_len set to zero, instead of the correct
values.  If then a packet is sent through the half-dead interface, the
kernel will panic due to running out of headroom in the skb when pushing
for the AX.25 headers resulting in this panic:

[<c0595468>] (skb_panic) from [<c0401f70>] (skb_push+0x4c/0x50)
[<c0401f70>] (skb_push) from [<bf0bdad4>] (ax25_hard_header+0x34/0xf4 [ax25])
[<bf0bdad4>] (ax25_hard_header [ax25]) from [<bf0d05d4>] (ax_header+0x38/0x40 [mkiss])
[<bf0d05d4>] (ax_header [mkiss]) from [<c041b584>] (neigh_compat_output+0x8c/0xd8)
[<c041b584>] (neigh_compat_output) from [<c043e7a8>] (ip_finish_output+0x2a0/0x914)
[<c043e7a8>] (ip_finish_output) from [<c043f948>] (ip_output+0xd8/0xf0)
[<c043f948>] (ip_output) from [<c043f04c>] (ip_local_out_sk+0x44/0x48)

This patch makes mkiss behave like the 6pack driver. 6pack does not
panic.  In 6pack.c sp_setup() (same function name here) the values for
dev->hard_header_len and dev->addr_len are set to the same values as in
my mkiss patch.

[ralf@linux-mips.org: Massages original submission to conform to the usual
standards for patch submissions.]

Signed-off-by: Thomas Osterried <thomas@osterried.de>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/hamradio/mkiss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 1dfe2304daa7..e0a6b1a0ca88 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -648,8 +648,8 @@ static void ax_setup(struct net_device *dev)
 {
 	/* Finish setting up the DEVICE info. */
 	dev->mtu             = AX_MTU;
-	dev->hard_header_len = 0;
-	dev->addr_len        = 0;
+	dev->hard_header_len = AX25_MAX_HEADER_LEN;
+	dev->addr_len        = AX25_ADDR_LEN;
 	dev->type            = ARPHRD_AX25;
 	dev->tx_queue_len    = 10;
 	dev->header_ops      = &ax25_header_ops;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 016/111] net: hns: Fix the device being used for dma mapping during TX
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (13 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 015/111] NET: mkiss: Fix panic Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 017/111] sierra_net: Skip validating irrelevant fields for IDLE LSIs Levin, Alexander (Sasha Levin)
                   ` (54 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Kejian Yan, Salil Mehta, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Kejian Yan <yankejian@huawei.com>

[ Upstream commit b85ea006b6bebb692628f11882af41c3e12e1e09 ]

This patch fixes the device being used to DMA map skb->data.
Erroneous device assignment causes the crash when SMMU is enabled.
This happens during TX since buffer gets DMA mapped with device
correspondign to net_device and gets unmapped using the device
related to DSAF.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index dff7b60345d8..c06845b7b666 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -304,8 +304,8 @@ int hns_nic_net_xmit_hw(struct net_device *ndev,
 			struct hns_nic_ring_data *ring_data)
 {
 	struct hns_nic_priv *priv = netdev_priv(ndev);
-	struct device *dev = priv->dev;
 	struct hnae_ring *ring = ring_data->ring;
+	struct device *dev = ring_to_dev(ring);
 	struct netdev_queue *dev_queue;
 	struct skb_frag_struct *frag;
 	int buf_num;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 017/111] sierra_net: Skip validating irrelevant fields for IDLE LSIs
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (14 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 016/111] net: hns: Fix the device being used for dma mapping during TX Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 018/111] sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications Levin, Alexander (Sasha Levin)
                   ` (53 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Stefan Brüns, David S . Miller, Levin, Alexander (Sasha Levin)

From: Stefan Brüns <stefan.bruens@rwth-aachen.de>

[ Upstream commit 764895d3039e903dac3a70f219949efe43d036a0 ]

When the context is deactivated, the link_type is set to 0xff, which
triggers a warning message, and results in a wrong link status, as
the LSI is ignored.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/usb/sierra_net.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index a251588762ec..d997d24798f0 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -365,6 +365,13 @@ static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
 		return -1;
 	}
 
+	/* Validate the session state */
+	if (lsi->session_state == SIERRA_NET_SESSION_IDLE) {
+		netdev_err(dev->net, "Session idle, 0x%02x\n",
+			   lsi->session_state);
+		return 0;
+	}
+
 	/* Validate the protocol  - only support UMTS for now */
 	if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) {
 		netdev_err(dev->net, "Protocol unsupported, 0x%02x\n",
@@ -386,13 +393,6 @@ static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
 		return 0;
 	}
 
-	/* Validate the session state */
-	if (lsi->session_state == SIERRA_NET_SESSION_IDLE) {
-		netdev_err(dev->net, "Session idle, 0x%02x\n",
-			lsi->session_state);
-		return 0;
-	}
-
 	/* Set link_sense true */
 	return 1;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 018/111] sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (15 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 017/111] sierra_net: Skip validating irrelevant fields for IDLE LSIs Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 020/111] i2c: piix4: Fix request_region size Levin, Alexander (Sasha Levin)
                   ` (52 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Stefan Brüns, David S . Miller, Levin, Alexander (Sasha Levin)

From: Stefan Brüns <stefan.bruens@rwth-aachen.de>

[ Upstream commit 5a70348e1187c5bf1cbd0ec51843f36befed1c2d ]

If a context is configured as dualstack ("IPv4v6"), the modem indicates
the context activation with a slightly different indication message.
The dual-stack indication omits the link_type (IPv4/v6) and adds
additional address fields.
IPv6 LSIs are identical to IPv4 LSIs, but have a different link type.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/usb/sierra_net.c | 101 ++++++++++++++++++++++++++++---------------
 1 file changed, 66 insertions(+), 35 deletions(-)

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index d997d24798f0..0b5a84c9022c 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -73,8 +73,6 @@ static	atomic_t iface_counter = ATOMIC_INIT(0);
 /* Private data structure */
 struct sierra_net_data {
 
-	u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */
-
 	u16 link_up;		/* air link up or down */
 	u8 tx_hdr_template[4];	/* part of HIP hdr for tx'd packets */
 
@@ -122,6 +120,7 @@ struct param {
 
 /* LSI Protocol types */
 #define SIERRA_NET_PROTOCOL_UMTS      0x01
+#define SIERRA_NET_PROTOCOL_UMTS_DS   0x04
 /* LSI Coverage */
 #define SIERRA_NET_COVERAGE_NONE      0x00
 #define SIERRA_NET_COVERAGE_NOPACKET  0x01
@@ -129,7 +128,8 @@ struct param {
 /* LSI Session */
 #define SIERRA_NET_SESSION_IDLE       0x00
 /* LSI Link types */
-#define SIERRA_NET_AS_LINK_TYPE_IPv4  0x00
+#define SIERRA_NET_AS_LINK_TYPE_IPV4  0x00
+#define SIERRA_NET_AS_LINK_TYPE_IPV6  0x02
 
 struct lsi_umts {
 	u8 protocol;
@@ -137,9 +137,14 @@ struct lsi_umts {
 	__be16 length;
 	/* eventually use a union for the rest - assume umts for now */
 	u8 coverage;
-	u8 unused2[41];
+	u8 network_len; /* network name len */
+	u8 network[40]; /* network name (UCS2, bigendian) */
 	u8 session_state;
 	u8 unused3[33];
+} __packed;
+
+struct lsi_umts_single {
+	struct lsi_umts lsi;
 	u8 link_type;
 	u8 pdp_addr_len; /* NW-supplied PDP address len */
 	u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */
@@ -158,10 +163,31 @@ struct lsi_umts {
 	u8 reserved[8];
 } __packed;
 
+struct lsi_umts_dual {
+	struct lsi_umts lsi;
+	u8 pdp_addr4_len; /* NW-supplied PDP IPv4 address len */
+	u8 pdp_addr4[4];  /* NW-supplied PDP IPv4 address (bigendian)) */
+	u8 pdp_addr6_len; /* NW-supplied PDP IPv6 address len */
+	u8 pdp_addr6[16]; /* NW-supplied PDP IPv6 address (bigendian)) */
+	u8 unused4[23];
+	u8 dns1_addr4_len; /* NW-supplied 1st DNS v4 address len (bigendian) */
+	u8 dns1_addr4[4];  /* NW-supplied 1st DNS v4 address */
+	u8 dns1_addr6_len; /* NW-supplied 1st DNS v6 address len */
+	u8 dns1_addr6[16]; /* NW-supplied 1st DNS v6 address (bigendian)*/
+	u8 dns2_addr4_len; /* NW-supplied 2nd DNS v4 address len (bigendian) */
+	u8 dns2_addr4[4];  /* NW-supplied 2nd DNS v4 address */
+	u8 dns2_addr6_len; /* NW-supplied 2nd DNS v6 address len */
+	u8 dns2_addr6[16]; /* NW-supplied 2nd DNS v6 address (bigendian)*/
+	u8 unused5[68];
+} __packed;
+
 #define SIERRA_NET_LSI_COMMON_LEN      4
-#define SIERRA_NET_LSI_UMTS_LEN        (sizeof(struct lsi_umts))
+#define SIERRA_NET_LSI_UMTS_LEN        (sizeof(struct lsi_umts_single))
 #define SIERRA_NET_LSI_UMTS_STATUS_LEN \
 	(SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN)
+#define SIERRA_NET_LSI_UMTS_DS_LEN     (sizeof(struct lsi_umts_dual))
+#define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN \
+	(SIERRA_NET_LSI_UMTS_DS_LEN - SIERRA_NET_LSI_COMMON_LEN)
 
 /* Forward definitions */
 static void sierra_sync_timer(unsigned long syncdata);
@@ -191,10 +217,11 @@ static inline void sierra_net_set_private(struct usbnet *dev,
 	dev->data[0] = (unsigned long)priv;
 }
 
-/* is packet IPv4 */
+/* is packet IPv4/IPv6 */
 static inline int is_ip(struct sk_buff *skb)
 {
-	return skb->protocol == cpu_to_be16(ETH_P_IP);
+	return skb->protocol == cpu_to_be16(ETH_P_IP) ||
+	       skb->protocol == cpu_to_be16(ETH_P_IPV6);
 }
 
 /*
@@ -350,18 +377,11 @@ static inline int sierra_net_is_valid_addrlen(u8 len)
 static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
 {
 	struct lsi_umts *lsi = (struct lsi_umts *)data;
+	u32 expected_length;
 
-	if (datalen < sizeof(struct lsi_umts)) {
-		netdev_err(dev->net, "%s: Data length %d, exp %Zu\n",
-				__func__, datalen,
-				sizeof(struct lsi_umts));
-		return -1;
-	}
-
-	if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) {
-		netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n",
-				__func__, be16_to_cpu(lsi->length),
-				(u32)SIERRA_NET_LSI_UMTS_STATUS_LEN);
+	if (datalen < sizeof(struct lsi_umts_single)) {
+		netdev_err(dev->net, "%s: Data length %d, exp >= %Zu\n",
+			   __func__, datalen, sizeof(struct lsi_umts_single));
 		return -1;
 	}
 
@@ -373,22 +393,34 @@ static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
 	}
 
 	/* Validate the protocol  - only support UMTS for now */
-	if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) {
+	if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS) {
+		struct lsi_umts_single *single = (struct lsi_umts_single *)lsi;
+
+		/* Validate the link type */
+		if (single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV4 &&
+		    single->link_type != SIERRA_NET_AS_LINK_TYPE_IPV6) {
+			netdev_err(dev->net, "Link type unsupported: 0x%02x\n",
+				   single->link_type);
+			return -1;
+		}
+		expected_length = SIERRA_NET_LSI_UMTS_STATUS_LEN;
+	} else if (lsi->protocol == SIERRA_NET_PROTOCOL_UMTS_DS) {
+		expected_length = SIERRA_NET_LSI_UMTS_DS_STATUS_LEN;
+	} else {
 		netdev_err(dev->net, "Protocol unsupported, 0x%02x\n",
-			lsi->protocol);
+			   lsi->protocol);
 		return -1;
 	}
 
-	/* Validate the link type */
-	if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) {
-		netdev_err(dev->net, "Link type unsupported: 0x%02x\n",
-			lsi->link_type);
+	if (be16_to_cpu(lsi->length) != expected_length) {
+		netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n",
+			   __func__, be16_to_cpu(lsi->length), expected_length);
 		return -1;
 	}
 
 	/* Validate the coverage */
-	if (lsi->coverage == SIERRA_NET_COVERAGE_NONE
-	   || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) {
+	if (lsi->coverage == SIERRA_NET_COVERAGE_NONE ||
+	    lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) {
 		netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage);
 		return 0;
 	}
@@ -662,7 +694,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	u8	numendpoints;
 	u16	fwattr = 0;
 	int	status;
-	struct ethhdr *eth;
 	struct sierra_net_data *priv;
 	static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
 		0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
@@ -700,11 +731,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
 	dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
 
-	/* we will have to manufacture ethernet headers, prepare template */
-	eth = (struct ethhdr *)priv->ethr_hdr_tmpl;
-	memcpy(&eth->h_dest, dev->net->dev_addr, ETH_ALEN);
-	eth->h_proto = cpu_to_be16(ETH_P_IP);
-
 	/* prepare shutdown message template */
 	memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg));
 	/* set context index initially to 0 - prepares tx hdr template */
@@ -833,9 +859,14 @@ static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 
 		skb_pull(skb, hh.hdrlen);
 
-		/* We are going to accept this packet, prepare it */
-		memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl,
-			ETH_HLEN);
+		/* We are going to accept this packet, prepare it.
+		 * In case protocol is IPv6, keep it, otherwise force IPv4.
+		 */
+		skb_reset_mac_header(skb);
+		if (eth_hdr(skb)->h_proto != cpu_to_be16(ETH_P_IPV6))
+			eth_hdr(skb)->h_proto = cpu_to_be16(ETH_P_IP);
+		eth_zero_addr(eth_hdr(skb)->h_source);
+		memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
 
 		/* Last packet in batch handled by usbnet */
 		if (hh.payload_len.word == skb->len)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 019/111] i2c: piix4: Request the SMBUS semaphore inside the mutex
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (17 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 020/111] i2c: piix4: Fix request_region size Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 021/111] powerpc/powernv: Properly set "host-ipi" on IPIs Levin, Alexander (Sasha Levin)
                   ` (50 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Ricardo Ribalda, Jean Delvare, Wolfram Sang, Levin,
	Alexander (Sasha Levin)

From: Ricardo Ribalda <ricardo.ribalda@gmail.com>

[ Upstream commit bbb27fc33d44e7b8d96369810654df4ee1837566 ]

SMBSLVCNT must be protected with the piix4_mutex_sb800 in order to avoid
multiple buses accessing to the semaphore at the same time.

Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
Reported-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/i2c/busses/i2c-piix4.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index e34d82e79b98..1250e5bc46b7 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -592,6 +592,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
 	u8 port;
 	int retval;
 
+	mutex_lock(&piix4_mutex_sb800);
+
 	/* Request the SMBUS semaphore, avoid conflicts with the IMC */
 	smbslvcnt  = inb_p(SMBSLVCNT);
 	do {
@@ -605,10 +607,10 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
 		usleep_range(1000, 2000);
 	} while (--retries);
 	/* SMBus is still owned by the IMC, we give up */
-	if (!retries)
+	if (!retries) {
+		mutex_unlock(&piix4_mutex_sb800);
 		return -EBUSY;
-
-	mutex_lock(&piix4_mutex_sb800);
+	}
 
 	outb_p(piix4_port_sel_sb800, SB800_PIIX4_SMB_IDX);
 	smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
@@ -623,11 +625,11 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
 
 	outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1);
 
-	mutex_unlock(&piix4_mutex_sb800);
-
 	/* Release the semaphore */
 	outb_p(smbslvcnt | 0x20, SMBSLVCNT);
 
+	mutex_unlock(&piix4_mutex_sb800);
+
 	return retval;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 020/111] i2c: piix4: Fix request_region size
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (16 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 018/111] sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 019/111] i2c: piix4: Request the SMBUS semaphore inside the mutex Levin, Alexander (Sasha Levin)
                   ` (51 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Ricardo Ribalda, Jean Delvare, Wolfram Sang, Levin,
	Alexander (Sasha Levin)

From: Ricardo Ribalda <ricardo.ribalda@gmail.com>

[ Upstream commit f43128c75202f29ee71aa83e6c320a911137c189 ]

Since '701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")' we
are using the SMBSLVCNT register at offset 0x8. We need to request it.

Fixes: 701dc207bf55 ("i2c: piix4: Avoid race conditions with IMC")
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/i2c/busses/i2c-piix4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 1250e5bc46b7..c21ca7bf2efe 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -58,7 +58,7 @@
 #define SMBSLVDAT	(0xC + piix4_smba)
 
 /* count for request_region */
-#define SMBIOSIZE	8
+#define SMBIOSIZE	9
 
 /* PCI Address Constants */
 #define SMBBA		0x090
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 021/111] powerpc/powernv: Properly set "host-ipi" on IPIs
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (18 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 019/111] i2c: piix4: Request the SMBUS semaphore inside the mutex Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 022/111] kernel/ucount.c: mark user_header with kmemleak_ignore() Levin, Alexander (Sasha Levin)
                   ` (49 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Levin, Alexander (Sasha Levin)

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

[ Upstream commit f83e6862047e1e371bdc5d512dd6cabe8a3965b8 ]

Otherwise KVM will fail to pass them through to the host

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/powerpc/sysdev/xics/icp-opal.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
index 32c46b424dd0..b53f80f0b4d8 100644
--- a/arch/powerpc/sysdev/xics/icp-opal.c
+++ b/arch/powerpc/sysdev/xics/icp-opal.c
@@ -130,14 +130,16 @@ static void icp_opal_cause_ipi(int cpu, unsigned long data)
 {
 	int hw_cpu = get_hard_smp_processor_id(cpu);
 
+	kvmppc_set_host_ipi(cpu, 1);
 	opal_int_set_mfrr(hw_cpu, IPI_PRIORITY);
 }
 
 static irqreturn_t icp_opal_ipi_action(int irq, void *dev_id)
 {
-	int hw_cpu = hard_smp_processor_id();
+	int cpu = smp_processor_id();
 
-	opal_int_set_mfrr(hw_cpu, 0xff);
+	kvmppc_set_host_ipi(cpu, 0);
+	opal_int_set_mfrr(get_hard_smp_processor_id(cpu), 0xff);
 
 	return smp_ipi_demux();
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 022/111] kernel/ucount.c: mark user_header with kmemleak_ignore()
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (19 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 021/111] powerpc/powernv: Properly set "host-ipi" on IPIs Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:11 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 023/111] net: thunderx: Fix PHY autoneg for SGMII QLM mode Levin, Alexander (Sasha Levin)
                   ` (48 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:11 UTC (permalink / raw)
  To: stable
  Cc: Luis R. Rodriguez, Eric W . Biederman, Kees Cook,
	Nikolay Borisov, Serge Hallyn, Jan Kara, Andrew Morton,
	Linus Torvalds, Levin, Alexander (Sasha Levin)

From: "Luis R. Rodriguez" <mcgrof@kernel.org>

[ Upstream commit ed5bd7dc88edf4a4a9c67130742b1b59aa017a5f ]

The user_header gets caught by kmemleak with the following splat as
missing a free:

  unreferenced object 0xffff99667a733d80 (size 96):
  comm "swapper/0", pid 1, jiffies 4294892317 (age 62191.468s)
  hex dump (first 32 bytes):
    a0 b6 92 b4 ff ff ff ff 00 00 00 00 01 00 00 00  ................
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
     kmemleak_alloc+0x4a/0xa0
     __kmalloc+0x144/0x260
     __register_sysctl_table+0x54/0x5e0
     register_sysctl+0x1b/0x20
     user_namespace_sysctl_init+0x17/0x34
     do_one_initcall+0x52/0x1a0
     kernel_init_freeable+0x173/0x200
     kernel_init+0xe/0x100
     ret_from_fork+0x2c/0x40

The BUG_ON()s are intended to crash so no need to clean up after
ourselves on error there.  This is also a kernel/ subsys_init() we don't
need a respective exit call here as this is never modular, so just white
list it.

Link: http://lkml.kernel.org/r/20170203211404.31458-1-mcgrof@kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 kernel/ucount.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/ucount.c b/kernel/ucount.c
index f4ac18509ecf..c761cdba2a2d 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -231,11 +231,10 @@ static __init int user_namespace_sysctl_init(void)
 	 * properly.
 	 */
 	user_header = register_sysctl("user", empty);
+	kmemleak_ignore(user_header);
 	BUG_ON(!user_header);
 	BUG_ON(!setup_userns_sysctls(&init_user_ns));
 #endif
 	return 0;
 }
 subsys_initcall(user_namespace_sysctl_init);
-
-
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 024/111] ipv6: addrconf: fix generation of new temporary addresses
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (21 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 023/111] net: thunderx: Fix PHY autoneg for SGMII QLM mode Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags Levin, Alexander (Sasha Levin)
                   ` (46 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Marcus Huewe, David S . Miller, Levin, Alexander (Sasha Levin)

From: Marcus Huewe <suse-tux@gmx.de>

[ Upstream commit a11a7f71cac209c7c9cca66eb506e1ebb033a3b3 ]

Under some circumstances it is possible that no new temporary addresses
will be generated.

For instance, addrconf_prefix_rcv_add_addr() indirectly calls
ipv6_create_tempaddr(), which creates a tentative temporary address and
starts dad. Next, addrconf_prefix_rcv_add_addr() indirectly calls
addrconf_verify_rtnl(). Now, assume that the previously created temporary
address has the least preferred lifetime among all existing addresses and
is still tentative (that is, dad is still running). Hence, the next run of
addrconf_verify_rtnl() is performed when the preferred lifetime of the
temporary address ends. If dad succeeds before the next run, the temporary
address becomes deprecated during the next run, but no new temporary
address is generated.

In order to fix this, schedule the next addrconf_verify_rtnl() run slightly
before the temporary address becomes deprecated, if dad succeeded.

Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv6/addrconf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f088a1d9a618..9ed836aa1903 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4004,6 +4004,12 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
 
 	if (bump_id)
 		rt_genid_bump_ipv6(dev_net(dev));
+
+	/* Make sure that a new temporary address will be created
+	 * before this temporary address becomes deprecated.
+	 */
+	if (ifp->flags & IFA_F_TEMPORARY)
+		addrconf_verify_rtnl();
 }
 
 static void addrconf_dad_run(struct inet6_dev *idev)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 023/111] net: thunderx: Fix PHY autoneg for SGMII QLM mode
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (20 preceding siblings ...)
  2017-06-04  8:11 ` [PATCH for v4.9 LTS 022/111] kernel/ucount.c: mark user_header with kmemleak_ignore() Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 024/111] ipv6: addrconf: fix generation of new temporary addresses Levin, Alexander (Sasha Levin)
                   ` (47 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Thanneeru Srinivasulu, Sunil Goutham, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Thanneeru Srinivasulu <tsrinivasulu@cavium.com>

[ Upstream commit 075ad765ef7541b2860de8408c165a92b78aefa3 ]

This patch fixes the case where there is no phydev attached
to a LMAC in DT due to non-existance of a PHY driver or due
to usage of non-stanadard PHY which doesn't support autoneg.
Changes dependeds on firmware to send correct info w.r.t
PHY and autoneg capability.

This patch also covers a case where a 10G/40G interface is used
as a 1G with convertors with Cortina PHY in between.

Signed-off-by: Thanneeru Srinivasulu <tsrinivasulu@cavium.com>
Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 108 +++++++++++++++++++---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.h |   5 +
 2 files changed, 101 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 050e21fbb147..679679a4ccb2 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -31,6 +31,7 @@ struct lmac {
 	u8                      lmac_type;
 	u8                      lane_to_sds;
 	bool                    use_training;
+	bool                    autoneg;
 	bool			link_up;
 	int			lmacid; /* ID within BGX */
 	int			lmacid_bd; /* ID on board */
@@ -418,7 +419,17 @@ static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac)
 	/* power down, reset autoneg, autoneg enable */
 	cfg = bgx_reg_read(bgx, lmacid, BGX_GMP_PCS_MRX_CTL);
 	cfg &= ~PCS_MRX_CTL_PWR_DN;
-	cfg |= (PCS_MRX_CTL_RST_AN | PCS_MRX_CTL_AN_EN);
+	cfg |= PCS_MRX_CTL_RST_AN;
+	if (lmac->phydev) {
+		cfg |= PCS_MRX_CTL_AN_EN;
+	} else {
+		/* In scenarios where PHY driver is not present or it's a
+		 * non-standard PHY, FW sets AN_EN to inform Linux driver
+		 * to do auto-neg and link polling or not.
+		 */
+		if (cfg & PCS_MRX_CTL_AN_EN)
+			lmac->autoneg = true;
+	}
 	bgx_reg_write(bgx, lmacid, BGX_GMP_PCS_MRX_CTL, cfg);
 
 	if (lmac->lmac_type == BGX_MODE_QSGMII) {
@@ -429,7 +440,7 @@ static int bgx_lmac_sgmii_init(struct bgx *bgx, struct lmac *lmac)
 		return 0;
 	}
 
-	if (lmac->lmac_type == BGX_MODE_SGMII) {
+	if ((lmac->lmac_type == BGX_MODE_SGMII) && lmac->phydev) {
 		if (bgx_poll_reg(bgx, lmacid, BGX_GMP_PCS_MRX_STATUS,
 				 PCS_MRX_STATUS_AN_CPT, false)) {
 			dev_err(&bgx->pdev->dev, "BGX AN_CPT not completed\n");
@@ -623,12 +634,71 @@ static int bgx_xaui_check_link(struct lmac *lmac)
 	return -1;
 }
 
+static void bgx_poll_for_sgmii_link(struct lmac *lmac)
+{
+	u64 pcs_link, an_result;
+	u8 speed;
+
+	pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid,
+				BGX_GMP_PCS_MRX_STATUS);
+
+	/*Link state bit is sticky, read it again*/
+	if (!(pcs_link & PCS_MRX_STATUS_LINK))
+		pcs_link = bgx_reg_read(lmac->bgx, lmac->lmacid,
+					BGX_GMP_PCS_MRX_STATUS);
+
+	if (bgx_poll_reg(lmac->bgx, lmac->lmacid, BGX_GMP_PCS_MRX_STATUS,
+			 PCS_MRX_STATUS_AN_CPT, false)) {
+		lmac->link_up = false;
+		lmac->last_speed = SPEED_UNKNOWN;
+		lmac->last_duplex = DUPLEX_UNKNOWN;
+		goto next_poll;
+	}
+
+	lmac->link_up = ((pcs_link & PCS_MRX_STATUS_LINK) != 0) ? true : false;
+	an_result = bgx_reg_read(lmac->bgx, lmac->lmacid,
+				 BGX_GMP_PCS_ANX_AN_RESULTS);
+
+	speed = (an_result >> 3) & 0x3;
+	lmac->last_duplex = (an_result >> 1) & 0x1;
+	switch (speed) {
+	case 0:
+		lmac->last_speed = 10;
+		break;
+	case 1:
+		lmac->last_speed = 100;
+		break;
+	case 2:
+		lmac->last_speed = 1000;
+		break;
+	default:
+		lmac->link_up = false;
+		lmac->last_speed = SPEED_UNKNOWN;
+		lmac->last_duplex = DUPLEX_UNKNOWN;
+		break;
+	}
+
+next_poll:
+
+	if (lmac->last_link != lmac->link_up) {
+		if (lmac->link_up)
+			bgx_sgmii_change_link_state(lmac);
+		lmac->last_link = lmac->link_up;
+	}
+
+	queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 3);
+}
+
 static void bgx_poll_for_link(struct work_struct *work)
 {
 	struct lmac *lmac;
 	u64 spu_link, smu_link;
 
 	lmac = container_of(work, struct lmac, dwork.work);
+	if (lmac->is_sgmii) {
+		bgx_poll_for_sgmii_link(lmac);
+		return;
+	}
 
 	/* Receive link is latching low. Force it high and verify it */
 	bgx_reg_modify(lmac->bgx, lmac->lmacid,
@@ -720,9 +790,21 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
 	    (lmac->lmac_type != BGX_MODE_XLAUI) &&
 	    (lmac->lmac_type != BGX_MODE_40G_KR) &&
 	    (lmac->lmac_type != BGX_MODE_10G_KR)) {
-		if (!lmac->phydev)
-			return -ENODEV;
-
+		if (!lmac->phydev) {
+			if (lmac->autoneg) {
+				bgx_reg_write(bgx, lmacid,
+					      BGX_GMP_PCS_LINKX_TIMER,
+					      PCS_LINKX_TIMER_COUNT);
+				goto poll;
+			} else {
+				/* Default to below link speed and duplex */
+				lmac->link_up = true;
+				lmac->last_speed = 1000;
+				lmac->last_duplex = 1;
+				bgx_sgmii_change_link_state(lmac);
+				return 0;
+			}
+		}
 		lmac->phydev->dev_flags = 0;
 
 		if (phy_connect_direct(&lmac->netdev, lmac->phydev,
@@ -731,15 +813,17 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
 			return -ENODEV;
 
 		phy_start_aneg(lmac->phydev);
-	} else {
-		lmac->check_link = alloc_workqueue("check_link", WQ_UNBOUND |
-						   WQ_MEM_RECLAIM, 1);
-		if (!lmac->check_link)
-			return -ENOMEM;
-		INIT_DELAYED_WORK(&lmac->dwork, bgx_poll_for_link);
-		queue_delayed_work(lmac->check_link, &lmac->dwork, 0);
+		return 0;
 	}
 
+poll:
+	lmac->check_link = alloc_workqueue("check_link", WQ_UNBOUND |
+					   WQ_MEM_RECLAIM, 1);
+	if (!lmac->check_link)
+		return -ENOMEM;
+	INIT_DELAYED_WORK(&lmac->dwork, bgx_poll_for_link);
+	queue_delayed_work(lmac->check_link, &lmac->dwork, 0);
+
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index 01cc7c859131..1143e9575e53 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -144,10 +144,15 @@
 #define	 PCS_MRX_CTL_LOOPBACK1			BIT_ULL(14)
 #define	 PCS_MRX_CTL_RESET			BIT_ULL(15)
 #define BGX_GMP_PCS_MRX_STATUS		0x30008
+#define	 PCS_MRX_STATUS_LINK			BIT_ULL(2)
 #define	 PCS_MRX_STATUS_AN_CPT			BIT_ULL(5)
+#define BGX_GMP_PCS_ANX_ADV		0x30010
 #define BGX_GMP_PCS_ANX_AN_RESULTS	0x30020
+#define BGX_GMP_PCS_LINKX_TIMER		0x30040
+#define PCS_LINKX_TIMER_COUNT			0x1E84
 #define BGX_GMP_PCS_SGM_AN_ADV		0x30068
 #define BGX_GMP_PCS_MISCX_CTL		0x30078
+#define  PCS_MISC_CTL_MODE			BIT_ULL(8)
 #define  PCS_MISC_CTL_DISP_EN			BIT_ULL(13)
 #define  PCS_MISC_CTL_GMX_ENO			BIT_ULL(11)
 #define  PCS_MISC_CTL_SAMP_PT_MASK	0x7Full
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (22 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 024/111] ipv6: addrconf: fix generation of new temporary addresses Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04 22:42   ` Hugh Dickins
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 027/111] ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches Levin, Alexander (Sasha Levin)
                   ` (45 subsequent siblings)
  69 siblings, 1 reply; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Hugh Dickins, Andrew Morton, Nicholas Piggin, Wu Fengguang,
	Linus Torvalds, Levin, Alexander (Sasha Levin)

From: Hugh Dickins <hughd@google.com>

[ Upstream commit b6789123bccba8b5feb9901ed2e8c3c39181979d ]

Commit 6326fec1122c ("mm: Use owner_priv bit for PageSwapCache, valid
when PageSwapBacked") aliased PG_swapcache to PG_owner_priv_1 (and
depending on PageSwapBacked being true).

As a result, the KPF_SWAPCACHE bit in '/proc/kpageflags' should now be
synthesized, instead of being shown on unrelated pages which just happen
to have PG_owner_priv_1 set.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/proc/page.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/proc/page.c b/fs/proc/page.c
index 3ecd445e830d..8ffd43709634 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -173,7 +173,8 @@ u64 stable_page_flags(struct page *page)
 	u |= kpf_copy_bit(k, KPF_ACTIVE,	PG_active);
 	u |= kpf_copy_bit(k, KPF_RECLAIM,	PG_reclaim);
 
-	u |= kpf_copy_bit(k, KPF_SWAPCACHE,	PG_swapcache);
+	if (PageSwapCache(page))
+		u |= 1 << KPF_SWAPCACHE;
 	u |= kpf_copy_bit(k, KPF_SWAPBACKED,	PG_swapbacked);
 
 	u |= kpf_copy_bit(k, KPF_UNEVICTABLE,	PG_unevictable);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 027/111] ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (23 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 026/111] vfio/spapr_tce: Set window when adding additional groups to container Levin, Alexander (Sasha Levin)
                   ` (44 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Linus Lüssing, David S . Miller, Levin, Alexander (Sasha Levin)

From: Linus Lüssing <linus.luessing@c0d3.blue>

[ Upstream commit a088d1d73a4bcfd7bc482f8d08375b9b665dc3e5 ]

When for instance a mobile Linux device roams from one access point to
another with both APs sharing the same broadcast domain and a
multicast snooping switch in between:

1)    (c) <~~~> (AP1) <--[SSW]--> (AP2)

2)              (AP1) <--[SSW]--> (AP2) <~~~> (c)

Then currently IPv6 multicast packets will get lost for (c) until an
MLD Querier sends its next query message. The packet loss occurs
because upon roaming the Linux host so far stayed silent regarding
MLD and the snooping switch will therefore be unaware of the
multicast topology change for a while.

This patch fixes this by always resending MLD reports when an interface
change happens, for instance from NO-CARRIER to CARRIER state.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/ipv6/addrconf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9ed836aa1903..045738319e8b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3387,9 +3387,15 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
 			}
 
 			if (idev) {
-				if (idev->if_flags & IF_READY)
-					/* device is already configured. */
+				if (idev->if_flags & IF_READY) {
+					/* device is already configured -
+					 * but resend MLD reports, we might
+					 * have roamed and need to update
+					 * multicast snooping switches
+					 */
+					ipv6_mc_up(idev);
 					break;
+				}
 				idev->if_flags |= IF_READY;
 			}
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 026/111] vfio/spapr_tce: Set window when adding additional groups to container
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (24 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 027/111] ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 028/111] ARM: defconfigs: make NF_CT_PROTO_SCTP and NF_CT_PROTO_UDPLITE built-in Levin, Alexander (Sasha Levin)
                   ` (43 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Alexey Kardashevskiy, Alex Williamson, Levin, Alexander (Sasha Levin)

From: Alexey Kardashevskiy <aik@ozlabs.ru>

[ Upstream commit 930a42ded3fede7ca3acafc9153f4f2d0f56a92c ]

If a container already has a group attached, attaching a new group
should just program already created IOMMU tables to the hardware via
the iommu_table_group_ops::set_window() callback.

However commit 6f01cc692a16 ("vfio/spapr: Add a helper to create
default DMA window") did not just simplify the code but also removed
the set_window() calls in the case of attaching groups to a container
which already has tables so it broke VFIO PCI hotplug.

This reverts set_window() bits in tce_iommu_take_ownership_ddw().

Fixes: 6f01cc692a16 ("vfio/spapr: Add a helper to create default DMA window")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/vfio/vfio_iommu_spapr_tce.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index c8823578a1b2..79ddcb05d126 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -1246,6 +1246,8 @@ static void tce_iommu_release_ownership_ddw(struct tce_container *container,
 static long tce_iommu_take_ownership_ddw(struct tce_container *container,
 		struct iommu_table_group *table_group)
 {
+	long i, ret = 0;
+
 	if (!table_group->ops->create_table || !table_group->ops->set_window ||
 			!table_group->ops->release_ownership) {
 		WARN_ON_ONCE(1);
@@ -1254,7 +1256,27 @@ static long tce_iommu_take_ownership_ddw(struct tce_container *container,
 
 	table_group->ops->take_ownership(table_group);
 
+	/* Set all windows to the new group */
+	for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
+		struct iommu_table *tbl = container->tables[i];
+
+		if (!tbl)
+			continue;
+
+		ret = table_group->ops->set_window(table_group, i, tbl);
+		if (ret)
+			goto release_exit;
+	}
+
 	return 0;
+
+release_exit:
+	for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
+		table_group->ops->unset_window(table_group, i);
+
+	table_group->ops->release_ownership(table_group);
+
+	return ret;
 }
 
 static int tce_iommu_attach_group(void *iommu_data,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 028/111] ARM: defconfigs: make NF_CT_PROTO_SCTP and NF_CT_PROTO_UDPLITE built-in
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (25 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 026/111] vfio/spapr_tce: Set window when adding additional groups to container Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 029/111] PM / runtime: Avoid false-positive warnings from might_sleep_if() Levin, Alexander (Sasha Levin)
                   ` (42 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Arnd Bergmann, Levin, Alexander (Sasha Levin)

From: Arnd Bergmann <arnd@arndb.de>

[ Upstream commit 5aff1d245e8cc1ab5c4517d916edaed9e3f7f973 ]

The symbols can no longer be used as loadable modules, leading to a harmless Kconfig
warning:

arch/arm/configs/imote2_defconfig:60:warning: symbol value 'm' invalid for NF_CT_PROTO_UDPLITE
arch/arm/configs/imote2_defconfig:59:warning: symbol value 'm' invalid for NF_CT_PROTO_SCTP
arch/arm/configs/ezx_defconfig:68:warning: symbol value 'm' invalid for NF_CT_PROTO_UDPLITE
arch/arm/configs/ezx_defconfig:67:warning: symbol value 'm' invalid for NF_CT_PROTO_SCTP

Let's make them built-in.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm/configs/ezx_defconfig    | 4 ++--
 arch/arm/configs/imote2_defconfig | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/configs/ezx_defconfig b/arch/arm/configs/ezx_defconfig
index ea316c4b890e..d3f1768840e2 100644
--- a/arch/arm/configs/ezx_defconfig
+++ b/arch/arm/configs/ezx_defconfig
@@ -64,8 +64,8 @@ CONFIG_NETFILTER=y
 CONFIG_NETFILTER_NETLINK_QUEUE=m
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_EVENTS=y
-CONFIG_NF_CT_PROTO_SCTP=m
-CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
 CONFIG_NF_CONNTRACK_AMANDA=m
 CONFIG_NF_CONNTRACK_FTP=m
 CONFIG_NF_CONNTRACK_H323=m
diff --git a/arch/arm/configs/imote2_defconfig b/arch/arm/configs/imote2_defconfig
index 18e59feaa307..7f479cdb3479 100644
--- a/arch/arm/configs/imote2_defconfig
+++ b/arch/arm/configs/imote2_defconfig
@@ -56,8 +56,8 @@ CONFIG_NETFILTER=y
 CONFIG_NETFILTER_NETLINK_QUEUE=m
 CONFIG_NF_CONNTRACK=m
 CONFIG_NF_CONNTRACK_EVENTS=y
-CONFIG_NF_CT_PROTO_SCTP=m
-CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CT_PROTO_SCTP=y
+CONFIG_NF_CT_PROTO_UDPLITE=y
 CONFIG_NF_CONNTRACK_AMANDA=m
 CONFIG_NF_CONNTRACK_FTP=m
 CONFIG_NF_CONNTRACK_H323=m
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 029/111] PM / runtime: Avoid false-positive warnings from might_sleep_if()
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (26 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 028/111] ARM: defconfigs: make NF_CT_PROTO_SCTP and NF_CT_PROTO_UDPLITE built-in Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 030/111] jump label: pass kbuild_cflags when checking for asm goto support Levin, Alexander (Sasha Levin)
                   ` (41 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Rafael J. Wysocki, Levin, Alexander (Sasha Levin)

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

[ Upstream commit a9306a63631493afc75893a4ac405d4e1cbae6aa ]

The might_sleep_if() assertions in __pm_runtime_idle(),
__pm_runtime_suspend() and __pm_runtime_resume() may generate
false-positive warnings in some situations.  For example, that
happens if a nested pm_runtime_get_sync()/pm_runtime_put() pair
is executed with disabled interrupts within an outer
pm_runtime_get_sync()/pm_runtime_put() section for the same device.
[Generally, pm_runtime_get_sync() may sleep, so it should not be
called with disabled interrupts, but in this particular case the
previous pm_runtime_get_sync() guarantees that the device will not
be suspended, so the inner pm_runtime_get_sync() will return
immediately after incrementing the device's usage counter.]

That started to happen in the i915 driver in 4.10-rc, leading to
the following splat:

 BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:1032
 in_atomic(): 1, irqs_disabled(): 0, pid: 1500, name: Xorg
 1 lock held by Xorg/1500:
  #0:  (&dev->struct_mutex){+.+.+.}, at:
  [<ffffffffa0680c13>] i915_mutex_lock_interruptible+0x43/0x140 [i915]
 CPU: 0 PID: 1500 Comm: Xorg Not tainted
 Call Trace:
  dump_stack+0x85/0xc2
  ___might_sleep+0x196/0x260
  __might_sleep+0x53/0xb0
  __pm_runtime_resume+0x7a/0x90
  intel_runtime_pm_get+0x25/0x90 [i915]
  aliasing_gtt_bind_vma+0xaa/0xf0 [i915]
  i915_vma_bind+0xaf/0x1e0 [i915]
  i915_gem_execbuffer_relocate_entry+0x513/0x6f0 [i915]
  i915_gem_execbuffer_relocate_vma.isra.34+0x188/0x250 [i915]
  ? trace_hardirqs_on+0xd/0x10
  ? i915_gem_execbuffer_reserve_vma.isra.31+0x152/0x1f0 [i915]
  ? i915_gem_execbuffer_reserve.isra.32+0x372/0x3a0 [i915]
  i915_gem_do_execbuffer.isra.38+0xa70/0x1a40 [i915]
  ? __might_fault+0x4e/0xb0
  i915_gem_execbuffer2+0xc5/0x260 [i915]
  ? __might_fault+0x4e/0xb0
  drm_ioctl+0x206/0x450 [drm]
  ? i915_gem_execbuffer+0x340/0x340 [i915]
  ? __fget+0x5/0x200
  do_vfs_ioctl+0x91/0x6f0
  ? __fget+0x111/0x200
  ? __fget+0x5/0x200
  SyS_ioctl+0x79/0x90
  entry_SYSCALL_64_fastpath+0x23/0xc6

even though the code triggering it is correct.

Unfortunately, the might_sleep_if() assertions in question are
too coarse-grained to cover such cases correctly, so make them
a bit less sensitive in order to avoid the false-positives.

Reported-and-tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/base/power/runtime.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 23f3b95a1158..147d2e3678aa 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -889,13 +889,13 @@ int __pm_runtime_idle(struct device *dev, int rpmflags)
 	unsigned long flags;
 	int retval;
 
-	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
-
 	if (rpmflags & RPM_GET_PUT) {
 		if (!atomic_dec_and_test(&dev->power.usage_count))
 			return 0;
 	}
 
+	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
+
 	spin_lock_irqsave(&dev->power.lock, flags);
 	retval = rpm_idle(dev, rpmflags);
 	spin_unlock_irqrestore(&dev->power.lock, flags);
@@ -921,13 +921,13 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags)
 	unsigned long flags;
 	int retval;
 
-	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
-
 	if (rpmflags & RPM_GET_PUT) {
 		if (!atomic_dec_and_test(&dev->power.usage_count))
 			return 0;
 	}
 
+	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
+
 	spin_lock_irqsave(&dev->power.lock, flags);
 	retval = rpm_suspend(dev, rpmflags);
 	spin_unlock_irqrestore(&dev->power.lock, flags);
@@ -952,7 +952,8 @@ int __pm_runtime_resume(struct device *dev, int rpmflags)
 	unsigned long flags;
 	int retval;
 
-	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe);
+	might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe &&
+			dev->power.runtime_status != RPM_ACTIVE);
 
 	if (rpmflags & RPM_GET_PUT)
 		atomic_inc(&dev->power.usage_count);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 030/111] jump label: pass kbuild_cflags when checking for asm goto support
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (27 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 029/111] PM / runtime: Avoid false-positive warnings from might_sleep_if() Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 031/111] shmem: fix sleeping from atomic context Levin, Alexander (Sasha Levin)
                   ` (40 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: David Lin, Michal Marek, Andrew Morton, Linus Torvalds, Levin,
	Alexander (Sasha Levin)

From: David Lin <dtwlin@google.com>

[ Upstream commit 35f860f9ba6aac56cc38e8b18916d833a83f1157 ]

Some versions of ARM GCC compiler such as Android toolchain throws in a
'-fpic' flag by default.  This causes the gcc-goto check script to fail
although some config would have '-fno-pic' flag in the KBUILD_CFLAGS.

This patch passes the KBUILD_CFLAGS to the check script so that the
script does not rely on the default config from different compilers.

Link: http://lkml.kernel.org/r/20170120234329.78868-1-dtwlin@google.com
Signed-off-by: David Lin <dtwlin@google.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Michal Marek <mmarek@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index b78a45bcf9b1..09ccce2383db 100644
--- a/Makefile
+++ b/Makefile
@@ -797,7 +797,7 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
 KBUILD_ARFLAGS := $(call ar-option,D)
 
 # check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
 	KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
 	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
 endif
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 031/111] shmem: fix sleeping from atomic context
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (28 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 030/111] jump label: pass kbuild_cflags when checking for asm goto support Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 032/111] kasan: respect /proc/sys/kernel/traceoff_on_warning Levin, Alexander (Sasha Levin)
                   ` (39 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Kirill A. Shutemov, Andrew Morton, Linus Torvalds, Levin,
	Alexander (Sasha Levin)

From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>

[ Upstream commit 253fd0f02040a19c6fe80e4171659fa3482a422d ]

Syzkaller fuzzer managed to trigger this:

    BUG: sleeping function called from invalid context at mm/shmem.c:852
    in_atomic(): 1, irqs_disabled(): 0, pid: 529, name: khugepaged
    3 locks held by khugepaged/529:
     #0:  (shrinker_rwsem){++++..}, at: [<ffffffff818d7ef1>] shrink_slab.part.59+0x121/0xd30 mm/vmscan.c:451
     #1:  (&type->s_umount_key#29){++++..}, at: [<ffffffff81a63630>] trylock_super+0x20/0x100 fs/super.c:392
     #2:  (&(&sbinfo->shrinklist_lock)->rlock){+.+.-.}, at: [<ffffffff818fd83e>] spin_lock include/linux/spinlock.h:302 [inline]
     #2:  (&(&sbinfo->shrinklist_lock)->rlock){+.+.-.}, at: [<ffffffff818fd83e>] shmem_unused_huge_shrink+0x28e/0x1490 mm/shmem.c:427
    CPU: 2 PID: 529 Comm: khugepaged Not tainted 4.10.0-rc5+ #201
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    Call Trace:
       shmem_undo_range+0xb20/0x2710 mm/shmem.c:852
       shmem_truncate_range+0x27/0xa0 mm/shmem.c:939
       shmem_evict_inode+0x35f/0xca0 mm/shmem.c:1030
       evict+0x46e/0x980 fs/inode.c:553
       iput_final fs/inode.c:1515 [inline]
       iput+0x589/0xb20 fs/inode.c:1542
       shmem_unused_huge_shrink+0xbad/0x1490 mm/shmem.c:446
       shmem_unused_huge_scan+0x10c/0x170 mm/shmem.c:512
       super_cache_scan+0x376/0x450 fs/super.c:106
       do_shrink_slab mm/vmscan.c:378 [inline]
       shrink_slab.part.59+0x543/0xd30 mm/vmscan.c:481
       shrink_slab mm/vmscan.c:2592 [inline]
       shrink_node+0x2c7/0x870 mm/vmscan.c:2592
       shrink_zones mm/vmscan.c:2734 [inline]
       do_try_to_free_pages+0x369/0xc80 mm/vmscan.c:2776
       try_to_free_pages+0x3c6/0x900 mm/vmscan.c:2982
       __perform_reclaim mm/page_alloc.c:3301 [inline]
       __alloc_pages_direct_reclaim mm/page_alloc.c:3322 [inline]
       __alloc_pages_slowpath+0xa24/0x1c30 mm/page_alloc.c:3683
       __alloc_pages_nodemask+0x544/0xae0 mm/page_alloc.c:3848
       __alloc_pages include/linux/gfp.h:426 [inline]
       __alloc_pages_node include/linux/gfp.h:439 [inline]
       khugepaged_alloc_page+0xc2/0x1b0 mm/khugepaged.c:750
       collapse_huge_page+0x182/0x1fe0 mm/khugepaged.c:955
       khugepaged_scan_pmd+0xfdf/0x12a0 mm/khugepaged.c:1208
       khugepaged_scan_mm_slot mm/khugepaged.c:1727 [inline]
       khugepaged_do_scan mm/khugepaged.c:1808 [inline]
       khugepaged+0xe9b/0x1590 mm/khugepaged.c:1853
       kthread+0x326/0x3f0 kernel/kthread.c:227
       ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430

The iput() from atomic context was a bad idea: if after igrab() somebody
else calls iput() and we left with the last inode reference, our iput()
would lead to inode eviction and therefore sleeping.

This patch should fix the situation.

Link: http://lkml.kernel.org/r/20170131093141.GA15899@node.shutemov.name
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 mm/shmem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 9d32e1cb9f38..d99cfb6eb03a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -412,6 +412,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		struct shrink_control *sc, unsigned long nr_to_split)
 {
 	LIST_HEAD(list), *pos, *next;
+	LIST_HEAD(to_remove);
 	struct inode *inode;
 	struct shmem_inode_info *info;
 	struct page *page;
@@ -438,9 +439,8 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 		/* Check if there's anything to gain */
 		if (round_up(inode->i_size, PAGE_SIZE) ==
 				round_up(inode->i_size, HPAGE_PMD_SIZE)) {
-			list_del_init(&info->shrinklist);
+			list_move(&info->shrinklist, &to_remove);
 			removed++;
-			iput(inode);
 			goto next;
 		}
 
@@ -451,6 +451,13 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
 	}
 	spin_unlock(&sbinfo->shrinklist_lock);
 
+	list_for_each_safe(pos, next, &to_remove) {
+		info = list_entry(pos, struct shmem_inode_info, shrinklist);
+		inode = &info->vfs_inode;
+		list_del_init(&info->shrinklist);
+		iput(inode);
+	}
+
 	list_for_each_safe(pos, next, &list) {
 		int ret;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 032/111] kasan: respect /proc/sys/kernel/traceoff_on_warning
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (29 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 031/111] shmem: fix sleeping from atomic context Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero Levin, Alexander (Sasha Levin)
                   ` (38 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Peter Zijlstra, Andrey Ryabinin, Dmitry Vyukov, Steven Rostedt,
	Andrew Morton, Linus Torvalds, Levin, Alexander (Sasha Levin)

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit 4f40c6e5627ea73b4e7c615c59631f38cc880885 ]

After much waiting I finally reproduced a KASAN issue, only to find my
trace-buffer empty of useful information because it got spooled out :/

Make kasan_report honour the /proc/sys/kernel/traceoff_on_warning
interface.

Link: http://lkml.kernel.org/r/20170125164106.3514-1-aryabinin@virtuozzo.com
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 mm/kasan/report.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 073325aedc68..8ca412aebcf1 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -13,6 +13,7 @@
  *
  */
 
+#include <linux/ftrace.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/printk.h>
@@ -298,6 +299,8 @@ void kasan_report(unsigned long addr, size_t size,
 	if (likely(!kasan_report_enabled()))
 		return;
 
+	disable_trace_on_warning();
+
 	info.access_addr = (void *)addr;
 	info.access_size = size;
 	info.is_write = is_write;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (30 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 032/111] kasan: respect /proc/sys/kernel/traceoff_on_warning Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 034/111] ethtool: do not vzalloc(0) on registers dump Levin, Alexander (Sasha Levin)
                   ` (37 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Ard Biesheuvel, Linus Torvalds, Levin, Alexander (Sasha Levin)

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

[ Upstream commit 29905b52fad0854351f57bab867647e4982285bf ]

The function order_base_2() is defined (according to the comment block)
as returning zero on input zero, but subsequently passes the input into
roundup_pow_of_two(), which is explicitly undefined for input zero.

This has gone unnoticed until now, but optimization passes in GCC 7 may
produce constant folded function instances where a constant value of
zero is passed into order_base_2(), resulting in link errors against the
deliberately undefined '____ilog2_NaN'.

So update order_base_2() to adhere to its own documented interface.

[ See

     http://marc.info/?l=linux-kernel&m=147672952517795&w=2

  and follow-up discussion for more background. The gcc "optimization
  pass" is really just broken, but now the GCC trunk problem seems to
  have escaped out of just specially built daily images, so we need to
  work around it in mainline.    - Linus ]

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 include/linux/log2.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/log2.h b/include/linux/log2.h
index f38fae23bdac..c373295f359f 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -194,6 +194,17 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
  *  ... and so on.
  */
 
-#define order_base_2(n) ilog2(roundup_pow_of_two(n))
+static inline __attribute_const__
+int __order_base_2(unsigned long n)
+{
+	return n > 1 ? ilog2(n - 1) + 1 : 0;
+}
 
+#define order_base_2(n)				\
+(						\
+	__builtin_constant_p(n) ? (		\
+		((n) == 0 || (n) == 1) ? 0 :	\
+		ilog2((n) - 1) + 1) :		\
+	__order_base_2(n)			\
+)
 #endif /* _LINUX_LOG2_H */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 034/111] ethtool: do not vzalloc(0) on registers dump
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (31 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver Levin, Alexander (Sasha Levin)
                   ` (36 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Stanislaw Gruszka, David S . Miller, Levin, Alexander (Sasha Levin)

From: Stanislaw Gruszka <sgruszka@redhat.com>

[ Upstream commit 3808d34838184fd29088d6b3a364ba2f1c018fb6 ]

If ->get_regs_len() callback return 0, we allocate 0 bytes of memory,
what print ugly warning in dmesg, which can be found further below.

This happen on mac80211 devices where ieee80211_get_regs_len() just
return 0 and driver only fills ethtool_regs structure and actually
do not provide any dump. However I assume this can happen on other
drivers i.e. when for some devices driver provide regs dump and for
others do not. Hence preventing to to print warning in ethtool code
seems to be reasonable.

ethtool: vmalloc: allocation failure: 0 bytes, mode:0x24080c2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO)
<snip>
Call Trace:
[<ffffffff813bde47>] dump_stack+0x63/0x8c
[<ffffffff811b0a1f>] warn_alloc+0x13f/0x170
[<ffffffff811f0476>] __vmalloc_node_range+0x1e6/0x2c0
[<ffffffff811f0874>] vzalloc+0x54/0x60
[<ffffffff8169986c>] dev_ethtool+0xb4c/0x1b30
[<ffffffff816adbb1>] dev_ioctl+0x181/0x520
[<ffffffff816714d2>] sock_do_ioctl+0x42/0x50
<snip>
Mem-Info:
active_anon:435809 inactive_anon:173951 isolated_anon:0
 active_file:835822 inactive_file:196932 isolated_file:0
 unevictable:0 dirty:8 writeback:0 unstable:0
 slab_reclaimable:157732 slab_unreclaimable:10022
 mapped:83042 shmem:306356 pagetables:9507 bounce:0
 free:130041 free_pcp:1080 free_cma:0
Node 0 active_anon:1743236kB inactive_anon:695804kB active_file:3343288kB inactive_file:787728kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:332168kB dirty:32kB writeback:0kB shmem:0kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 1225424kB writeback_tmp:0kB unstable:0kB pages_scanned:0 all_unreclaimable? no
Node 0 DMA free:15900kB min:136kB low:168kB high:200kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15984kB managed:15900kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 3187 7643 7643
Node 0 DMA32 free:419732kB min:28124kB low:35152kB high:42180kB active_anon:541180kB inactive_anon:248988kB active_file:1466388kB inactive_file:389632kB unevictable:0kB writepending:0kB present:3370280kB managed:3290932kB mlocked:0kB slab_reclaimable:217184kB slab_unreclaimable:4180kB kernel_stack:160kB pagetables:984kB bounce:0kB free_pcp:2236kB local_pcp:660kB free_cma:0kB
lowmem_reserve[]: 0 0 4456 4456

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 net/core/ethtool.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 047a1752ece1..072c1f4998c9 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1394,9 +1394,12 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
 	if (regs.len > reglen)
 		regs.len = reglen;
 
-	regbuf = vzalloc(reglen);
-	if (reglen && !regbuf)
-		return -ENOMEM;
+	regbuf = NULL;
+	if (reglen) {
+		regbuf = vzalloc(reglen);
+		if (!regbuf)
+			return -ENOMEM;
+	}
 
 	ops->get_regs(dev, &regs, regbuf);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (32 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 034/111] ethtool: do not vzalloc(0) on registers dump Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04 17:17   ` Florian Fainelli
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 036/111] drm/radeon: Fix vram_size/visible values in DRM_RADEON_GEM_INFO ioctl Levin, Alexander (Sasha Levin)
                   ` (35 subsequent siblings)
  69 siblings, 1 reply; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Mao Wenan, Florian Fainelli, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Mao Wenan <maowenan@huawei.com>

[ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]

There is currently no reference count being held on the PHY driver,
which makes it possible to remove the PHY driver module while the PHY
state machine is running and polling the PHY. This could cause crashes
similar to this one to show up:

[   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
[   43.361162] IP: phy_state_machine+0x32/0x490
[   43.361162] PGD 59dc067
[   43.361162] PUD 0
[   43.361162]
[   43.361162] Oops: 0000 [#1] SMP
[   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
[   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
[   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
[   43.361162] Workqueue: events_power_efficient phy_state_machine
[   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
[   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
[   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
[   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
ffff880006a15c60
[   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
ffff8800059e5428
[   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
0000000000000000
[   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
ffff8800059e5428
[   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
ffff880006a15c40
[   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
knlGS:0000000000000000
[   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
00000000000006f0
[   43.361162] Call Trace:
[   43.361162]  process_one_work+0x1b4/0x3e0
[   43.361162]  worker_thread+0x43/0x4d0
[   43.361162]  ? __schedule+0x17f/0x4e0
[   43.361162]  kthread+0xf7/0x130
[   43.361162]  ? process_one_work+0x3e0/0x3e0
[   43.361162]  ? kthread_create_on_node+0x40/0x40
[   43.361162]  ret_from_fork+0x29/0x40
[   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b

Keep references on the PHY driver module right before we are going to
utilize it in phy_attach_direct(), and conversely when we don't use it
anymore in phy_detach().

Signed-off-by: Mao Wenan <maowenan@huawei.com>
[florian: rebase, rework commit message]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/phy/phy_device.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c4ceb082e970..67571f9627e5 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -872,6 +872,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 		return -EIO;
 	}
 
+	if (!try_module_get(d->driver->owner)) {
+		dev_err(&dev->dev, "failed to get the device driver module\n");
+		return -EIO;
+	}
+
 	get_device(d);
 
 	/* Assume that if there is no driver, that it doesn't
@@ -927,6 +932,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 
 error:
 	put_device(d);
+	module_put(d->driver->owner);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 	return err;
@@ -1007,6 +1013,7 @@ void phy_detach(struct phy_device *phydev)
 	bus = phydev->mdio.bus;
 
 	put_device(&phydev->mdio.dev);
+	module_put(phydev->mdio.dev.driver->owner);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 036/111] drm/radeon: Fix vram_size/visible values in DRM_RADEON_GEM_INFO ioctl
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (33 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 037/111] net: fix ndo_features_check/ndo_fix_features comment ordering Levin, Alexander (Sasha Levin)
                   ` (34 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Michel Dänzer, Alex Deucher, Levin, Alexander (Sasha Levin)

From: Michel Dänzer <michel.daenzer@amd.com>

[ Upstream commit 51964e9e12d0a054002a1a0d1dec4f661c7aaf28 ]

vram_size is supposed to be the total amount of VRAM that can be used by
userspace, which corresponds to the TTM VRAM manager size (which is
normally the full amount of VRAM, but can be just the visible VRAM when
DMA can't be used for BO migration for some reason).

The above was incorrectly used for vram_visible before, resulting in
generally too large values being reported.

Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/radeon/radeon_drv.c | 3 ++-
 drivers/gpu/drm/radeon/radeon_gem.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e0c143b865f3..30bd4a6a9d46 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -97,9 +97,10 @@
  *   2.46.0 - Add PFP_SYNC_ME support on evergreen
  *   2.47.0 - Add UVD_NO_OP register support
  *   2.48.0 - TA_CS_BC_BASE_ADDR allowed on SI
+ *   2.49.0 - DRM_RADEON_GEM_INFO ioctl returns correct vram_size/visible values
  */
 #define KMS_DRIVER_MAJOR	2
-#define KMS_DRIVER_MINOR	48
+#define KMS_DRIVER_MINOR	49
 #define KMS_DRIVER_PATCHLEVEL	0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index deb9511725c9..316856715878 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -220,8 +220,8 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
 
 	man = &rdev->mman.bdev.man[TTM_PL_VRAM];
 
-	args->vram_size = rdev->mc.real_vram_size;
-	args->vram_visible = (u64)man->size << PAGE_SHIFT;
+	args->vram_size = (u64)man->size << PAGE_SHIFT;
+	args->vram_visible = rdev->mc.visible_vram_size;
 	args->vram_visible -= rdev->vram_pin_size;
 	args->gart_size = rdev->mc.gtt_size;
 	args->gart_size -= rdev->gart_pin_size;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 037/111] net: fix ndo_features_check/ndo_fix_features comment ordering
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (34 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 036/111] drm/radeon: Fix vram_size/visible values in DRM_RADEON_GEM_INFO ioctl Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 039/111] fscache: Fix dead object requeue Levin, Alexander (Sasha Levin)
                   ` (33 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Dimitris Michailidis, David S . Miller, Levin, Alexander (Sasha Levin)

From: Dimitris Michailidis <dmichail@google.com>

[ Upstream commit 1a2a14444d32b89b28116daea86f63ced1716668 ]

Commit cdba756f5803a2 ("net: move ndo_features_check() close to
ndo_start_xmit()") inadvertently moved the doc comment for
.ndo_fix_features instead of .ndo_features_check. Fix the comment
ordering.

Fixes: cdba756f5803a2 ("net: move ndo_features_check() close to ndo_start_xmit()")
Signed-off-by: Dimitris Michailidis <dmichail@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 include/linux/netdevice.h | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bb9b102c15cd..780e7171f548 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -865,11 +865,15 @@ struct netdev_xdp {
  *	of useless work if you return NETDEV_TX_BUSY.
  *	Required; cannot be NULL.
  *
- * netdev_features_t (*ndo_fix_features)(struct net_device *dev,
- *		netdev_features_t features);
- *	Adjusts the requested feature flags according to device-specific
- *	constraints, and returns the resulting flags. Must not modify
- *	the device state.
+ * netdev_features_t (*ndo_features_check)(struct sk_buff *skb,
+ *					   struct net_device *dev
+ *					   netdev_features_t features);
+ *	Called by core transmit path to determine if device is capable of
+ *	performing offload operations on a given packet. This is to give
+ *	the device an opportunity to implement any restrictions that cannot
+ *	be otherwise expressed by feature flags. The check is called with
+ *	the set of features that the stack has calculated and it returns
+ *	those the driver believes to be appropriate.
  *
  * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
  *                         void *accel_priv, select_queue_fallback_t fallback);
@@ -1027,6 +1031,12 @@ struct netdev_xdp {
  *	Called to release previously enslaved netdev.
  *
  *      Feature/offload setting functions.
+ * netdev_features_t (*ndo_fix_features)(struct net_device *dev,
+ *		netdev_features_t features);
+ *	Adjusts the requested feature flags according to device-specific
+ *	constraints, and returns the resulting flags. Must not modify
+ *	the device state.
+ *
  * int (*ndo_set_features)(struct net_device *dev, netdev_features_t features);
  *	Called to update device configuration to new features. Passed
  *	feature set might be less than what was returned by ndo_fix_features()).
@@ -1099,15 +1109,6 @@ struct netdev_xdp {
  *	Callback to use for xmit over the accelerated station. This
  *	is used in place of ndo_start_xmit on accelerated net
  *	devices.
- * netdev_features_t (*ndo_features_check)(struct sk_buff *skb,
- *					   struct net_device *dev
- *					   netdev_features_t features);
- *	Called by core transmit path to determine if device is capable of
- *	performing offload operations on a given packet. This is to give
- *	the device an opportunity to implement any restrictions that cannot
- *	be otherwise expressed by feature flags. The check is called with
- *	the set of features that the stack has calculated and it returns
- *	those the driver believes to be appropriate.
  * int (*ndo_set_tx_maxrate)(struct net_device *dev,
  *			     int queue_index, u32 maxrate);
  *	Called when a user wants to set a max-rate limitation of specific
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 039/111] fscache: Fix dead object requeue
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (35 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 037/111] net: fix ndo_features_check/ndo_fix_features comment ordering Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 038/111] scsi: mpt3sas: Force request partial completion alignment Levin, Alexander (Sasha Levin)
                   ` (32 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: David Howells, Al Viro, Levin, Alexander (Sasha Levin)

From: David Howells <dhowells@redhat.com>

[ Upstream commit e26bfebdfc0d212d366de9990a096665d5c0209a ]

Under some circumstances, an fscache object can become queued such that it
fscache_object_work_func() can be called once the object is in the
OBJECT_DEAD state.  This results in the kernel oopsing when it tries to
invoke the handler for the state (which is hard coded to 0x2).

The way this comes about is something like the following:

 (1) The object dispatcher is processing a work state for an object.  This
     is done in workqueue context.

 (2) An out-of-band event comes in that isn't masked, causing the object to
     be queued, say EV_KILL.

 (3) The object dispatcher finishes processing the current work state on
     that object and then sees there's another event to process, so,
     without returning to the workqueue core, it processes that event too.
     It then follows the chain of events that initiates until we reach
     OBJECT_DEAD without going through a wait state (such as
     WAIT_FOR_CLEARANCE).

     At this point, object->events may be 0, object->event_mask will be 0
     and oob_event_mask will be 0.

 (4) The object dispatcher returns to the workqueue processor, and in due
     course, this sees that the object's work item is still queued and
     invokes it again.

 (5) The current state is a work state (OBJECT_DEAD), so the dispatcher
     jumps to it - resulting in an OOPS.

When I'm seeing this, the work state in (1) appears to have been either
LOOK_UP_OBJECT or CREATE_OBJECT (object->oob_table is
fscache_osm_lookup_oob).

The window for (2) is very small:

 (A) object->event_mask is cleared whilst the event dispatch process is
     underway - though there's no memory barrier to force this to the top
     of the function.

     The window, therefore is from the time the object was selected by the
     workqueue processor and made requeueable to the time the mask was
     cleared.

 (B) fscache_raise_event() will only queue the object if it manages to set
     the event bit and the corresponding event_mask bit was set.

     The enqueuement is then deferred slightly whilst we get a ref on the
     object and get the per-CPU variable for workqueue congestion.  This
     slight deferral slightly increases the probability by allowing extra
     time for the workqueue to make the item requeueable.

Handle this by giving the dead state a processor function and checking the
for the dead state address rather than seeing if the processor function is
address 0x2.  The dead state processor function can then set a flag to
indicate that it's occurred and give a warning if it occurs more than once
per object.

If this race occurs, an oops similar to the following is seen (note the RIP
value):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000002
IP: [<0000000000000002>] 0x1
PGD 0
Oops: 0010 [#1] SMP
Modules linked in: ...
CPU: 17 PID: 16077 Comm: kworker/u48:9 Not tainted 3.10.0-327.18.2.el7.x86_64 #1
Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 12/27/2015
Workqueue: fscache_object fscache_object_work_func [fscache]
task: ffff880302b63980 ti: ffff880717544000 task.ti: ffff880717544000
RIP: 0010:[<0000000000000002>]  [<0000000000000002>] 0x1
RSP: 0018:ffff880717547df8  EFLAGS: 00010202
RAX: ffffffffa0368640 RBX: ffff880edf7a4480 RCX: dead000000200200
RDX: 0000000000000002 RSI: 00000000ffffffff RDI: ffff880edf7a4480
RBP: ffff880717547e18 R08: 0000000000000000 R09: dfc40a25cb3a4510
R10: dfc40a25cb3a4510 R11: 0000000000000400 R12: 0000000000000000
R13: ffff880edf7a4510 R14: ffff8817f6153400 R15: 0000000000000600
FS:  0000000000000000(0000) GS:ffff88181f420000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000002 CR3: 000000000194a000 CR4: 00000000001407e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
 ffffffffa0363695 ffff880edf7a4510 ffff88093f16f900 ffff8817faa4ec00
 ffff880717547e60 ffffffff8109d5db 00000000faa4ec18 0000000000000000
 ffff8817faa4ec18 ffff88093f16f930 ffff880302b63980 ffff88093f16f900
Call Trace:
 [<ffffffffa0363695>] ? fscache_object_work_func+0xa5/0x200 [fscache]
 [<ffffffff8109d5db>] process_one_work+0x17b/0x470
 [<ffffffff8109e4ac>] worker_thread+0x21c/0x400
 [<ffffffff8109e290>] ? rescuer_thread+0x400/0x400
 [<ffffffff810a5acf>] kthread+0xcf/0xe0
 [<ffffffff810a5a00>] ? kthread_create_on_node+0x140/0x140
 [<ffffffff816460d8>] ret_from_fork+0x58/0x90
 [<ffffffff810a5a00>] ? kthread_create_on_node+0x140/0x140

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Jeremy McNicoll <jeremymc@redhat.com>
Tested-by: Frank Sorenson <sorenson@redhat.com>
Tested-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/fscache/object.c           | 26 ++++++++++++++++++++++++--
 include/linux/fscache-cache.h |  1 +
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 9e792e30f4db..f3a024fcff81 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -30,6 +30,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
 static const struct fscache_state *fscache_object_available(struct fscache_object *, int);
 static const struct fscache_state *fscache_parent_ready(struct fscache_object *, int);
 static const struct fscache_state *fscache_update_object(struct fscache_object *, int);
+static const struct fscache_state *fscache_object_dead(struct fscache_object *, int);
 
 #define __STATE_NAME(n) fscache_osm_##n
 #define STATE(n) (&__STATE_NAME(n))
@@ -91,7 +92,7 @@ static WORK_STATE(LOOKUP_FAILURE,	"LCFL", fscache_lookup_failure);
 static WORK_STATE(KILL_OBJECT,		"KILL", fscache_kill_object);
 static WORK_STATE(KILL_DEPENDENTS,	"KDEP", fscache_kill_dependents);
 static WORK_STATE(DROP_OBJECT,		"DROP", fscache_drop_object);
-static WORK_STATE(OBJECT_DEAD,		"DEAD", (void*)2UL);
+static WORK_STATE(OBJECT_DEAD,		"DEAD", fscache_object_dead);
 
 static WAIT_STATE(WAIT_FOR_INIT,	"?INI",
 		  TRANSIT_TO(INIT_OBJECT,	1 << FSCACHE_OBJECT_EV_NEW_CHILD));
@@ -229,6 +230,10 @@ static void fscache_object_sm_dispatcher(struct fscache_object *object)
 	event = -1;
 	if (new_state == NO_TRANSIT) {
 		_debug("{OBJ%x} %s notrans", object->debug_id, state->name);
+		if (unlikely(state == STATE(OBJECT_DEAD))) {
+			_leave(" [dead]");
+			return;
+		}
 		fscache_enqueue_object(object);
 		event_mask = object->oob_event_mask;
 		goto unmask_events;
@@ -239,7 +244,7 @@ static void fscache_object_sm_dispatcher(struct fscache_object *object)
 	object->state = state = new_state;
 
 	if (state->work) {
-		if (unlikely(state->work == ((void *)2UL))) {
+		if (unlikely(state == STATE(OBJECT_DEAD))) {
 			_leave(" [dead]");
 			return;
 		}
@@ -1077,3 +1082,20 @@ void fscache_object_mark_killed(struct fscache_object *object,
 	}
 }
 EXPORT_SYMBOL(fscache_object_mark_killed);
+
+/*
+ * The object is dead.  We can get here if an object gets queued by an event
+ * that would lead to its death (such as EV_KILL) when the dispatcher is
+ * already running (and so can be requeued) but hasn't yet cleared the event
+ * mask.
+ */
+static const struct fscache_state *fscache_object_dead(struct fscache_object *object,
+						       int event)
+{
+	if (!test_and_set_bit(FSCACHE_OBJECT_RUN_AFTER_DEAD,
+			      &object->flags))
+		return NO_TRANSIT;
+
+	WARN(true, "FS-Cache object redispatched after death");
+	return NO_TRANSIT;
+}
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index 13ba552e6c09..4c467ef50159 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -360,6 +360,7 @@ struct fscache_object {
 #define FSCACHE_OBJECT_IS_AVAILABLE	5	/* T if object has become active */
 #define FSCACHE_OBJECT_RETIRED		6	/* T if object was retired on relinquishment */
 #define FSCACHE_OBJECT_KILLED_BY_CACHE	7	/* T if object was killed by the cache */
+#define FSCACHE_OBJECT_RUN_AFTER_DEAD	8	/* T if object has been dispatched after death */
 
 	struct list_head	cache_link;	/* link in cache->object_list */
 	struct hlist_node	cookie_link;	/* link in cookie->backing_objects */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 038/111] scsi: mpt3sas: Force request partial completion alignment
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (36 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 039/111] fscache: Fix dead object requeue Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 041/111] FS-Cache: Initialise stores_lock in netfs cookie Levin, Alexander (Sasha Levin)
                   ` (31 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Ram Pai, Guilherme G . Piccoli, Martin K . Petersen, Levin,
	Alexander (Sasha Levin)

From: Ram Pai <linuxram@us.ibm.com>

[ Upstream commit f2e767bb5d6ee0d988cb7d4e54b0b21175802b6b ]

The firmware or device, possibly under a heavy I/O load, can return on a
partial unaligned boundary. Scsi-ml expects these requests to be
completed on an alignment boundary. Scsi-ml blindly requeues the I/O
without checking the alignment boundary of the I/O request for the
remaining bytes. This leads to errors, since devices cannot perform
non-aligned read/write operations.

This patch fixes the issue in the driver. It aligns unaligned
completions of FS requests, by truncating them to the nearest alignment
boundary.

[mkp: simplified if statement]

Reported-by: Mauricio Faria De Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 8a7941b8189f..289374cbcb47 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -4634,6 +4634,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 	struct MPT3SAS_DEVICE *sas_device_priv_data;
 	u32 response_code = 0;
 	unsigned long flags;
+	unsigned int sector_sz;
 
 	mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
 	scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
@@ -4692,6 +4693,20 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 	}
 
 	xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
+
+	/* In case of bogus fw or device, we could end up having
+	 * unaligned partial completion. We can force alignment here,
+	 * then scsi-ml does not need to handle this misbehavior.
+	 */
+	sector_sz = scmd->device->sector_size;
+	if (unlikely(scmd->request->cmd_type == REQ_TYPE_FS && sector_sz &&
+		     xfer_cnt % sector_sz)) {
+		sdev_printk(KERN_INFO, scmd->device,
+		    "unaligned partial completion avoided (xfer_cnt=%u, sector_sz=%u)\n",
+			    xfer_cnt, sector_sz);
+		xfer_cnt = round_down(xfer_cnt, sector_sz);
+	}
+
 	scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
 	if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
 		log_info =  le32_to_cpu(mpi_reply->IOCLogInfo);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 040/111] fscache: Clear outstanding writes when disabling a cookie
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (38 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 041/111] FS-Cache: Initialise stores_lock in netfs cookie Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 042/111] ipv6: fix flow labels when the traffic class is non-0 Levin, Alexander (Sasha Levin)
                   ` (29 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: David Howells, Al Viro, Levin, Alexander (Sasha Levin)

From: David Howells <dhowells@redhat.com>

[ Upstream commit 6bdded59c8933940ac7e5b416448276ac89d1144 ]

fscache_disable_cookie() needs to clear the outstanding writes on the
cookie it's disabling because they cannot be completed after.

Without this, fscache_nfs_open_file() gets stuck because it disables the
cookie when the file is opened for writing but can't uncache the pages till
afterwards - otherwise there's a race between the open routine and anyone
who already has it open R/O and is still reading from it.

Looking in /proc/pid/stack of the offending process shows:

[<ffffffffa0142883>] __fscache_wait_on_page_write+0x82/0x9b [fscache]
[<ffffffffa014336e>] __fscache_uncache_all_inode_pages+0x91/0xe1 [fscache]
[<ffffffffa01740fa>] nfs_fscache_open_file+0x59/0x9e [nfs]
[<ffffffffa01ccf41>] nfs4_file_open+0x17f/0x1b8 [nfsv4]
[<ffffffff8117350e>] do_dentry_open+0x16d/0x2b7
[<ffffffff811743ac>] vfs_open+0x5c/0x65
[<ffffffff81184185>] path_openat+0x785/0x8fb
[<ffffffff81184343>] do_filp_open+0x48/0x9e
[<ffffffff81174710>] do_sys_open+0x13b/0x1cb
[<ffffffff811747b9>] SyS_open+0x19/0x1b
[<ffffffff81001c44>] do_syscall_64+0x80/0x17a
[<ffffffff8165c2da>] return_from_SYSCALL_64+0x0/0x7a
[<ffffffffffffffff>] 0xffffffffffffffff

Reported-by: Jianhong Yin <jiyin@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/fscache/cookie.c | 5 +++++
 fs/fscache/object.c | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 4304072161aa..40d61077bead 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -542,6 +542,7 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
 		hlist_for_each_entry(object, &cookie->backing_objects, cookie_link) {
 			if (invalidate)
 				set_bit(FSCACHE_OBJECT_RETIRED, &object->flags);
+			clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
 			fscache_raise_event(object, FSCACHE_OBJECT_EV_KILL);
 		}
 	} else {
@@ -560,6 +561,10 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
 		wait_on_atomic_t(&cookie->n_active, fscache_wait_atomic_t,
 				 TASK_UNINTERRUPTIBLE);
 
+	/* Make sure any pending writes are cancelled. */
+	if (cookie->def->type != FSCACHE_COOKIE_TYPE_INDEX)
+		fscache_invalidate_writes(cookie);
+
 	/* Reset the cookie state if it wasn't relinquished */
 	if (!test_bit(FSCACHE_COOKIE_RELINQUISHED, &cookie->flags)) {
 		atomic_inc(&cookie->n_active);
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index f3a024fcff81..7a182c87f378 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -650,6 +650,12 @@ static const struct fscache_state *fscache_kill_object(struct fscache_object *ob
 	fscache_mark_object_dead(object);
 	object->oob_event_mask = 0;
 
+	if (test_bit(FSCACHE_OBJECT_RETIRED, &object->flags)) {
+		/* Reject any new read/write ops and abort any that are pending. */
+		clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags);
+		fscache_cancel_all_ops(object);
+	}
+
 	if (list_empty(&object->dependents) &&
 	    object->n_ops == 0 &&
 	    object->n_children == 0)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 041/111] FS-Cache: Initialise stores_lock in netfs cookie
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (37 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 038/111] scsi: mpt3sas: Force request partial completion alignment Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 040/111] fscache: Clear outstanding writes when disabling a cookie Levin, Alexander (Sasha Levin)
                   ` (30 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: David Howells, Al Viro, Levin, Alexander (Sasha Levin)

From: David Howells <dhowells@redhat.com>

[ Upstream commit 62deb8187d116581c88c69a2dd9b5c16588545d4 ]

Initialise the stores_lock in fscache netfs cookies.  Technically, it
shouldn't be necessary, since the netfs cookie is an index and stores no
data, but initialising it anyway adds insignificant overhead.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 fs/fscache/netfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 9b28649df3a1..a8aa00be4444 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -48,6 +48,7 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
 	cookie->flags		= 1 << FSCACHE_COOKIE_ENABLED;
 
 	spin_lock_init(&cookie->lock);
+	spin_lock_init(&cookie->stores_lock);
 	INIT_HLIST_HEAD(&cookie->backing_objects);
 
 	/* check the netfs type is not already present */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 042/111] ipv6: fix flow labels when the traffic class is non-0
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (39 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 040/111] fscache: Clear outstanding writes when disabling a cookie Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 043/111] drm/nouveau: prevent userspace from deleting client object Levin, Alexander (Sasha Levin)
                   ` (28 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Dimitris Michailidis, David S . Miller, Levin, Alexander (Sasha Levin)

From: Dimitris Michailidis <dmichail@google.com>

[ Upstream commit 90427ef5d2a4b9a24079889bf16afdcdaebc4240 ]

ip6_make_flowlabel() determines the flow label for IPv6 packets. It's
supposed to be passed a flow label, which it returns as is if non-0 and
in some other cases, otherwise it calculates a new value.

The problem is callers often pass a flowi6.flowlabel, which may also
contain traffic class bits. If the traffic class is non-0
ip6_make_flowlabel() mistakes the non-0 it gets as a flow label and
returns the whole thing. Thus it can return a 'flow label' longer than
20b and the low 20b of that is typically 0 resulting in packets with 0
label. Moreover, different packets of a flow may be labeled differently.
For a TCP flow with ECN non-payload and payload packets get different
labels as exemplified by this pair of consecutive packets:

(pure ACK)
Internet Protocol Version 6, Src: 2002:af5:11a3::, Dst: 2002:af5:11a2::
    0110 .... = Version: 6
    .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    .... .... .... 0001 1100 1110 0100 1001 = Flow Label: 0x1ce49
    Payload Length: 32
    Next Header: TCP (6)

(payload)
Internet Protocol Version 6, Src: 2002:af5:11a3::, Dst: 2002:af5:11a2::
    0110 .... = Version: 6
    .... 0000 0010 .... .... .... .... .... = Traffic Class: 0x02 (DSCP: CS0, ECN: ECT(0))
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..10 .... .... .... .... .... = Explicit Congestion Notification: ECN-Capable Transport codepoint '10' (2)
    .... .... .... 0000 0000 0000 0000 0000 = Flow Label: 0x00000
    Payload Length: 688
    Next Header: TCP (6)

This patch allows ip6_make_flowlabel() to be passed more than just a
flow label and has it extract the part it really wants. This was simpler
than modifying the callers. With this patch packets like the above become

Internet Protocol Version 6, Src: 2002:af5:11a3::, Dst: 2002:af5:11a2::
    0110 .... = Version: 6
    .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    .... .... .... 1010 1111 1010 0101 1110 = Flow Label: 0xafa5e
    Payload Length: 32
    Next Header: TCP (6)

Internet Protocol Version 6, Src: 2002:af5:11a3::, Dst: 2002:af5:11a2::
    0110 .... = Version: 6
    .... 0000 0010 .... .... .... .... .... = Traffic Class: 0x02 (DSCP: CS0, ECN: ECT(0))
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..10 .... .... .... .... .... = Explicit Congestion Notification: ECN-Capable Transport codepoint '10' (2)
    .... .... .... 1010 1111 1010 0101 1110 = Flow Label: 0xafa5e
    Payload Length: 688
    Next Header: TCP (6)

Signed-off-by: Dimitris Michailidis <dmichail@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 include/net/ipv6.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 7f15f95625e7..3fe4d7452bb3 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -776,6 +776,11 @@ static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
 {
 	u32 hash;
 
+	/* @flowlabel may include more than a flow label, eg, the traffic class.
+	 * Here we want only the flow label value.
+	 */
+	flowlabel &= IPV6_FLOWLABEL_MASK;
+
 	if (flowlabel ||
 	    net->ipv6.sysctl.auto_flowlabels == IP6_AUTO_FLOW_LABEL_OFF ||
 	    (!autolabel &&
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 043/111] drm/nouveau: prevent userspace from deleting client object
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (40 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 042/111] ipv6: fix flow labels when the traffic class is non-0 Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 044/111] drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers Levin, Alexander (Sasha Levin)
                   ` (27 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Ben Skeggs, Levin, Alexander (Sasha Levin)

From: Ben Skeggs <bskeggs@redhat.com>

[ Upstream commit c966b6279f610a24ac1d42dcbe30e10fa61220b2 ]

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_usif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 08f9c6fa0f7f..1fba38622744 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -313,7 +313,8 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 argc)
 	if (!(ret = nvif_unpack(-ENOSYS, &data, &size, argv->v0, 0, 0, true))) {
 		/* block access to objects not created via this interface */
 		owner = argv->v0.owner;
-		if (argv->v0.object == 0ULL)
+		if (argv->v0.object == 0ULL &&
+		    argv->v0.type != NVIF_IOCTL_V0_DEL)
 			argv->v0.owner = NVDRM_OBJECT_ANY; /* except client */
 		else
 			argv->v0.owner = NVDRM_OBJECT_USIF;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 044/111] drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (41 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 043/111] drm/nouveau: prevent userspace from deleting client object Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 045/111] sparc64: Handle PIO & MEM non-resumable errors Levin, Alexander (Sasha Levin)
                   ` (26 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Ben Skeggs, Levin, Alexander (Sasha Levin)

From: Ben Skeggs <bskeggs@redhat.com>

[ Upstream commit 96692b097ba76d0c637ae8af47b29c73da33c9d0 ]

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_fence.h | 1 +
 drivers/gpu/drm/nouveau/nv84_fence.c    | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
index 64c4ce7115ad..75e1f09484ff 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
@@ -100,6 +100,7 @@ struct nv84_fence_priv {
 	struct nouveau_bo *bo;
 	struct nouveau_bo *bo_gart;
 	u32 *suspend;
+	struct mutex mutex;
 };
 
 u64  nv84_fence_crtc(struct nouveau_channel *, int);
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 18bde9d8e6d6..90a5dd6311c6 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -121,8 +121,10 @@ nv84_fence_context_del(struct nouveau_channel *chan)
 	}
 
 	nouveau_bo_wr32(priv->bo, chan->chid * 16 / 4, fctx->base.sequence);
+	mutex_lock(&priv->mutex);
 	nouveau_bo_vma_del(priv->bo, &fctx->vma_gart);
 	nouveau_bo_vma_del(priv->bo, &fctx->vma);
+	mutex_unlock(&priv->mutex);
 	nouveau_fence_context_del(&fctx->base);
 	chan->fence = NULL;
 	nouveau_fence_context_free(&fctx->base);
@@ -148,11 +150,13 @@ nv84_fence_context_new(struct nouveau_channel *chan)
 	fctx->base.sync32 = nv84_fence_sync32;
 	fctx->base.sequence = nv84_fence_read(chan);
 
+	mutex_lock(&priv->mutex);
 	ret = nouveau_bo_vma_add(priv->bo, cli->vm, &fctx->vma);
 	if (ret == 0) {
 		ret = nouveau_bo_vma_add(priv->bo_gart, cli->vm,
 					&fctx->vma_gart);
 	}
+	mutex_unlock(&priv->mutex);
 
 	/* map display semaphore buffers into channel's vm */
 	for (i = 0; !ret && i < chan->drm->dev->mode_config.num_crtc; i++) {
@@ -232,6 +236,8 @@ nv84_fence_create(struct nouveau_drm *drm)
 	priv->base.context_base = fence_context_alloc(priv->base.contexts);
 	priv->base.uevent = true;
 
+	mutex_init(&priv->mutex);
+
 	/* Use VRAM if there is any ; otherwise fallback to system memory */
 	domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
 			 /*
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 045/111] sparc64: Handle PIO & MEM non-resumable errors.
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (42 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 044/111] drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 046/111] sparc64: Zero pages on allocation for mondo and error queues Levin, Alexander (Sasha Levin)
                   ` (25 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Liam R. Howlett, David S . Miller, Levin, Alexander (Sasha Levin)

From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

[ Upstream commit 047487241ff59374fded8c477f21453681f5995c ]

User processes trying to access an invalid memory address via PIO will
receive a SIGBUS signal instead of causing a panic.  Memory errors will
receive a SIGKILL since a SIGBUS may result in a coredump which may
attempt to repeat the faulting access.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/sparc/kernel/traps_64.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index 4094a51b1970..2eeef6ab676c 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -2051,6 +2051,73 @@ void sun4v_resum_overflow(struct pt_regs *regs)
 	atomic_inc(&sun4v_resum_oflow_cnt);
 }
 
+/* Given a set of registers, get the virtual addressi that was being accessed
+ * by the faulting instructions at tpc.
+ */
+static unsigned long sun4v_get_vaddr(struct pt_regs *regs)
+{
+	unsigned int insn;
+
+	if (!copy_from_user(&insn, (void __user *)regs->tpc, 4)) {
+		return compute_effective_address(regs, insn,
+						 (insn >> 25) & 0x1f);
+	}
+	return 0;
+}
+
+/* Attempt to handle non-resumable errors generated from userspace.
+ * Returns true if the signal was handled, false otherwise.
+ */
+bool sun4v_nonresum_error_user_handled(struct pt_regs *regs,
+				  struct sun4v_error_entry *ent) {
+
+	unsigned int attrs = ent->err_attrs;
+
+	if (attrs & SUN4V_ERR_ATTRS_MEMORY) {
+		unsigned long addr = ent->err_raddr;
+		siginfo_t info;
+
+		if (addr == ~(u64)0) {
+			/* This seems highly unlikely to ever occur */
+			pr_emerg("SUN4V NON-RECOVERABLE ERROR: Memory error detected in unknown location!\n");
+		} else {
+			unsigned long page_cnt = DIV_ROUND_UP(ent->err_size,
+							      PAGE_SIZE);
+
+			/* Break the unfortunate news. */
+			pr_emerg("SUN4V NON-RECOVERABLE ERROR: Memory failed at %016lX\n",
+				 addr);
+			pr_emerg("SUN4V NON-RECOVERABLE ERROR:   Claiming %lu ages.\n",
+				 page_cnt);
+
+			while (page_cnt-- > 0) {
+				if (pfn_valid(addr >> PAGE_SHIFT))
+					get_page(pfn_to_page(addr >> PAGE_SHIFT));
+				addr += PAGE_SIZE;
+			}
+		}
+		info.si_signo = SIGKILL;
+		info.si_errno = 0;
+		info.si_trapno = 0;
+		force_sig_info(info.si_signo, &info, current);
+
+		return true;
+	}
+	if (attrs & SUN4V_ERR_ATTRS_PIO) {
+		siginfo_t info;
+
+		info.si_signo = SIGBUS;
+		info.si_code = BUS_ADRERR;
+		info.si_addr = (void __user *)sun4v_get_vaddr(regs);
+		force_sig_info(info.si_signo, &info, current);
+
+		return true;
+	}
+
+	/* Default to doing nothing */
+	return false;
+}
+
 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
  * Log the event, clear the first word of the entry, and die.
  */
@@ -2075,6 +2142,12 @@ void sun4v_nonresum_error(struct pt_regs *regs, unsigned long offset)
 
 	put_cpu();
 
+	if (!(regs->tstate & TSTATE_PRIV) &&
+	    sun4v_nonresum_error_user_handled(regs, &local_copy)) {
+		/* DON'T PANIC: This userspace error was handled. */
+		return;
+	}
+
 #ifdef CONFIG_PCI
 	/* Check for the special PCI poke sequence. */
 	if (pci_poke_in_progress && pci_poke_cpu == cpu) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 046/111] sparc64: Zero pages on allocation for mondo and error queues.
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (43 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 045/111] sparc64: Handle PIO & MEM non-resumable errors Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 047/111] net/mlx4_core: Avoid command timeouts during VF driver device shutdown Levin, Alexander (Sasha Levin)
                   ` (24 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Liam R. Howlett, David S . Miller, Levin, Alexander (Sasha Levin)

From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

[ Upstream commit 7a7dc961a28b965a0d0303c2e989df17b411708b ]

Error queues use a non-zero first word to detect if the queues are full.
Using pages that have not been zeroed may result in false positive
overflow events.  These queues are set up once during boot so zeroing
all mondo and error queue pages is safe.

Note that the false positive overflow does not always occur because the
page allocation for these queues is so early in the boot cycle that
higher number CPUs get fresh pages.  It is only when traps are serviced
with lower number CPUs who were given already used pages that this issue
is exposed.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/sparc/kernel/irq_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index 34a7930b76ef..baed4cdeda75 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -1021,7 +1021,7 @@ static void __init alloc_one_queue(unsigned long *pa_ptr, unsigned long qmask)
 	unsigned long order = get_order(size);
 	unsigned long p;
 
-	p = __get_free_pages(GFP_KERNEL, order);
+	p = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 	if (!p) {
 		prom_printf("SUN4V: Error, cannot allocate queue.\n");
 		prom_halt();
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 047/111] net/mlx4_core: Avoid command timeouts during VF driver device shutdown
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (44 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 046/111] sparc64: Zero pages on allocation for mondo and error queues Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 048/111] gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page Levin, Alexander (Sasha Levin)
                   ` (23 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Jack Morgenstein, Tariq Toukan, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

[ Upstream commit d585df1c5ccf995fcee910705ad7a9cdd11d4152 ]

Some Hypervisors detach VFs from VMs by instantly causing an FLR event
to be generated for a VF.

In the mlx4 case, this will cause that VF's comm channel to be disabled
before the VM has an opportunity to invoke the VF device's "shutdown"
method.

The result is that the VF driver on the VM will experience a command
timeout during the shutdown process when the Hypervisor does not deliver
a command-completion event to the VM.

To avoid FW command timeouts on the VM when the driver's shutdown method
is invoked, we detect the absence of the VF's comm channel at the very
start of the shutdown process. If the comm-channel has already been
disabled, we cause all FW commands during the device shutdown process to
immediately return success (and thus avoid all command timeouts).

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/mellanox/mlx4/catas.c |  2 +-
 drivers/net/ethernet/mellanox/mlx4/intf.c  | 12 ++++++++++++
 drivers/net/ethernet/mellanox/mlx4/mlx4.h  |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/catas.c b/drivers/net/ethernet/mellanox/mlx4/catas.c
index c7e939945259..53daa6ca5d83 100644
--- a/drivers/net/ethernet/mellanox/mlx4/catas.c
+++ b/drivers/net/ethernet/mellanox/mlx4/catas.c
@@ -158,7 +158,7 @@ static int mlx4_reset_slave(struct mlx4_dev *dev)
 	return -ETIMEDOUT;
 }
 
-static int mlx4_comm_internal_err(u32 slave_read)
+int mlx4_comm_internal_err(u32 slave_read)
 {
 	return (u32)COMM_CHAN_EVENT_INTERNAL_ERR ==
 		(slave_read & (u32)COMM_CHAN_EVENT_INTERNAL_ERR) ? 1 : 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/intf.c b/drivers/net/ethernet/mellanox/mlx4/intf.c
index 0e8b7c44931f..8258d08acd8c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/intf.c
+++ b/drivers/net/ethernet/mellanox/mlx4/intf.c
@@ -222,6 +222,18 @@ void mlx4_unregister_device(struct mlx4_dev *dev)
 		return;
 
 	mlx4_stop_catas_poll(dev);
+	if (dev->persist->interface_state & MLX4_INTERFACE_STATE_DELETION &&
+	    mlx4_is_slave(dev)) {
+		/* In mlx4_remove_one on a VF */
+		u32 slave_read =
+			swab32(readl(&mlx4_priv(dev)->mfunc.comm->slave_read));
+
+		if (mlx4_comm_internal_err(slave_read)) {
+			mlx4_dbg(dev, "%s: comm channel is down, entering error state.\n",
+				 __func__);
+			mlx4_enter_error_state(dev->persist);
+		}
+	}
 	mutex_lock(&intf_mutex);
 
 	list_for_each_entry(intf, &intf_list, list)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 88ee7d8a5923..086920b615af 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -1220,6 +1220,7 @@ void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
 void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
 
 void mlx4_enter_error_state(struct mlx4_dev_persistent *persist);
+int mlx4_comm_internal_err(u32 slave_read);
 
 int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
 		    enum mlx4_port_type *type);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 048/111] gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (45 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 047/111] net/mlx4_core: Avoid command timeouts during VF driver device shutdown Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 049/111] net: ethtool: add support for 2500BaseT and 5000BaseT link modes Levin, Alexander (Sasha Levin)
                   ` (22 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Arseny Solokha, David S . Miller, Levin, Alexander (Sasha Levin)

From: Arseny Solokha <asolokha@kb.kras.ru>

[ Upstream commit 4af0e5bb95ee3ba5ea4bd7dbb94e1648a5279cc9 ]

In spite of switching to paged allocation of Rx buffers, the driver still
called dma_unmap_single() in the Rx queues tear-down path.

The DMA region unmapping code in free_skb_rx_queue() basically predates
the introduction of paged allocation to the driver. While being refactored,
it apparently hasn't reflected the change in the DMA API usage by its
counterpart gfar_new_page().

As a result, setting an interface to the DOWN state now yields the following:

  # ip link set eth2 down
  fsl-gianfar ffe24000.ethernet: DMA-API: device driver frees DMA memory with wrong function [device address=0x000000001ecd0000] [size=40]
  ------------[ cut here ]------------
  WARNING: CPU: 1 PID: 189 at lib/dma-debug.c:1123 check_unmap+0x8e0/0xa28
  CPU: 1 PID: 189 Comm: ip Tainted: G           O    4.9.5 #1
  task: dee73400 task.stack: dede2000
  NIP: c02101e8 LR: c02101e8 CTR: c0260d74
  REGS: dede3bb0 TRAP: 0700   Tainted: G           O     (4.9.5)
  MSR: 00021000 <CE,ME>  CR: 28002222  XER: 00000000

  GPR00: c02101e8 dede3c60 dee73400 000000b6 dfbd033c dfbd36c4 1f622000 dede2000
  GPR08: 00000007 c05b1634 1f622000 00000000 22002484 100a9904 00000000 00000000
  GPR16: 00000000 db4c849c 00000002 db4c8480 00000001 df142240 db4c84bc 00000000
  GPR24: c0706148 c0700000 00029000 c07552e8 c07323b4 dede3cb8 c07605e0 db535540
  NIP [c02101e8] check_unmap+0x8e0/0xa28
  LR [c02101e8] check_unmap+0x8e0/0xa28
  Call Trace:
  [dede3c60] [c02101e8] check_unmap+0x8e0/0xa28 (unreliable)
  [dede3cb0] [c02103b8] debug_dma_unmap_page+0x88/0x9c
  [dede3d30] [c02dffbc] free_skb_resources+0x2c4/0x404
  [dede3d80] [c02e39b4] gfar_close+0x24/0xc8
  [dede3da0] [c0361550] __dev_close_many+0xa0/0xf8
  [dede3dd0] [c03616f0] __dev_close+0x2c/0x4c
  [dede3df0] [c036b1b8] __dev_change_flags+0xa0/0x174
  [dede3e10] [c036b2ac] dev_change_flags+0x20/0x60
  [dede3e30] [c03e130c] devinet_ioctl+0x540/0x824
  [dede3e90] [c0347dcc] sock_ioctl+0x134/0x298
  [dede3eb0] [c0111814] do_vfs_ioctl+0xac/0x854
  [dede3f20] [c0111ffc] SyS_ioctl+0x40/0x74
  [dede3f40] [c000f290] ret_from_syscall+0x0/0x3c
  --- interrupt: c01 at 0xff45da0
      LR = 0xff45cd0
  Instruction dump:
  811d001c 7c66482e 813d0020 9061000c 807f000c 5463103a 7cc6182e 3c60c052
  386309ac 90c10008 4cc63182 4826b845 <0fe00000> 4bfffa60 3c80c052 388402c4
  ---[ end trace 695ae6d7ac1d0c47 ]---
  Mapped at:
   [<c02e22a8>] gfar_alloc_rx_buffs+0x178/0x248
   [<c02e3ef0>] startup_gfar+0x368/0x570
   [<c036aeb4>] __dev_open+0xdc/0x150
   [<c036b1b8>] __dev_change_flags+0xa0/0x174
   [<c036b2ac>] dev_change_flags+0x20/0x60

Even though the issue was discovered in 4.9 kernel, the code in question
is identical in the current net and net-next trees.

Fixes: 75354148ce69 ("gianfar: Add paged allocation and Rx S/G")
Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Acked-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 9061c2f82b9c..d391beebe591 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2007,8 +2007,8 @@ static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue)
 		if (!rxb->page)
 			continue;
 
-		dma_unmap_single(rx_queue->dev, rxb->dma,
-				 PAGE_SIZE, DMA_FROM_DEVICE);
+		dma_unmap_page(rx_queue->dev, rxb->dma,
+			       PAGE_SIZE, DMA_FROM_DEVICE);
 		__free_page(rxb->page);
 
 		rxb->page = NULL;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 050/111] pinctrl: baytrail: Rectify debounce support (part 2)
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (47 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 049/111] net: ethtool: add support for 2500BaseT and 5000BaseT link modes Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 051/111] [media] cec: fix wrong last_la determination Levin, Alexander (Sasha Levin)
                   ` (20 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Andy Shevchenko, Linus Walleij, Levin, Alexander (Sasha Levin)

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[ Upstream commit 827e1579e1d5cb66e340e7be1944b825b542bbdf ]

The commit 04ff5a095d66 ("pinctrl: baytrail: Rectify debounce support")
almost fixes the logic of debuonce but missed couple of things, i.e.
typo in mask when disabling debounce and lack of enabling it back.

This patch addresses above issues.

Reported-by: Jean Delvare <jdelvare@suse.de>
Fixes: 04ff5a095d66 ("pinctrl: baytrail: Rectify debounce support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 583ae3f38fc0..5419de8e20b1 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1250,10 +1250,12 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
 			debounce = readl(db_reg);
 			debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
 
+			if (arg)
+				conf |= BYT_DEBOUNCE_EN;
+			else
+				conf &= ~BYT_DEBOUNCE_EN;
+
 			switch (arg) {
-			case 0:
-				conf &= BYT_DEBOUNCE_EN;
-				break;
 			case 375:
 				debounce |= BYT_DEBOUNCE_PULSE_375US;
 				break;
@@ -1276,7 +1278,9 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
 				debounce |= BYT_DEBOUNCE_PULSE_24MS;
 				break;
 			default:
-				ret = -EINVAL;
+				if (arg)
+					ret = -EINVAL;
+				break;
 			}
 
 			if (!ret)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 049/111] net: ethtool: add support for 2500BaseT and 5000BaseT link modes
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (46 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 048/111] gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 050/111] pinctrl: baytrail: Rectify debounce support (part 2) Levin, Alexander (Sasha Levin)
                   ` (21 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Pavel Belous, David S . Miller, Levin, Alexander (Sasha Levin)

From: Pavel Belous <pavel.s.belous@gmail.com>

[ Upstream commit 94842b4fc4d6b1691cfc86c6f5251f299d27f4ba ]

This patch introduce support for 2500BaseT and 5000BaseT link modes.
These modes are included in the new IEEE 802.3bz standard.

Signed-off-by: Pavel Belous <pavel.s.belous@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 include/uapi/linux/ethtool.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 8e547231c1b7..5c22e8cab24b 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1368,6 +1368,8 @@ enum ethtool_link_mode_bit_indices {
 	ETHTOOL_LINK_MODE_10000baseLR_Full_BIT	= 44,
 	ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT	= 45,
 	ETHTOOL_LINK_MODE_10000baseER_Full_BIT	= 46,
+	ETHTOOL_LINK_MODE_2500baseT_Full_BIT	= 47,
+	ETHTOOL_LINK_MODE_5000baseT_Full_BIT	= 48,
 
 
 	/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
@@ -1377,7 +1379,7 @@ enum ethtool_link_mode_bit_indices {
 	 */
 
 	__ETHTOOL_LINK_MODE_LAST
-	  = ETHTOOL_LINK_MODE_10000baseER_Full_BIT,
+	  = ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
 };
 
 #define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name)	\
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 051/111] [media] cec: fix wrong last_la determination
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (48 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 050/111] pinctrl: baytrail: Rectify debounce support (part 2) Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 052/111] drm: Add fake controlD* symlinks for backwards compat Levin, Alexander (Sasha Levin)
                   ` (19 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Hans Verkuil, Hans Verkuil, Mauro Carvalho Chehab, Levin,
	Alexander (Sasha Levin)

From: Hans Verkuil <hverkuil@xs4all.nl>

[ Upstream commit f9f96fc10c09ca16e336854c08bc1563eed97985 ]

Due to an incorrect condition the last_la used for the initial attempt at
claiming a logical address could be wrong.

The last_la wasn't converted to a mask when ANDing with type2mask, so that
test was broken.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/staging/media/cec/cec-adap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/staging/media/cec/cec-adap.c
index 611e07b78bfe..057c9b5ab1e5 100644
--- a/drivers/staging/media/cec/cec-adap.c
+++ b/drivers/staging/media/cec/cec-adap.c
@@ -1017,7 +1017,7 @@ static int cec_config_thread_func(void *arg)
 		las->log_addr[i] = CEC_LOG_ADDR_INVALID;
 		if (last_la == CEC_LOG_ADDR_INVALID ||
 		    last_la == CEC_LOG_ADDR_UNREGISTERED ||
-		    !(last_la & type2mask[type]))
+		    !((1 << last_la) & type2mask[type]))
 			last_la = la_list[0];
 
 		err = cec_config_log_addr(adap, i, last_la);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 052/111] drm: Add fake controlD* symlinks for backwards compat
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (49 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 051/111] [media] cec: fix wrong last_la determination Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 053/111] drm: prevent double-(un)registration for connectors Levin, Alexander (Sasha Levin)
                   ` (18 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Daniel Vetter, Dave Airlie, Alex Deucher, David Herrmann,
	Greg Kroah-Hartman, Daniel Vetter, Levin, Alexander (Sasha Levin)

From: Daniel Vetter <daniel.vetter@ffwll.ch>

[ Upstream commit 6449b088dd51dd5aa6b38455888bbf538d21f2fc ]

We thought that no userspace is using them, but oops libdrm is using
them to figure out whether a driver supports modesetting. Check out
drmCheckModesettingSupported but maybe don't because it's horrible and
totally runs counter to where we want to go with libdrm device
handling. The function looks in the device hierarchy for whether
controlD* exist using the following format string:

/sys/bus/pci/devices/%04x:%02x:%02x.%d/drm/controlD%d

The "/drm" subdirectory is the glue directory from the sysfs class
stuff, and the only way to get at it seems to through
kdev->kobj.parent (when kdev is represents e.g. the card0 chardev
instance in sysfs). Git grep says we're not the only ones touching
that, so I hope it's ok we dig into such internals - I couldn't find a
proper interface for getting at the glue directory.

Quick git grep shows that at least -amdgpu, -ati are using this.
-modesetting do not, and on -intel it's only about the 4th fallback
path for device lookup, which is why this didn't blow up earlier.

Oh well, we need to keep it working, and the simplest way is to add a
symlink at the right place in sysfs from controlD* to card*.

v2:
- Fix error path handling by adding if (!minor) return checks (David)
- Fix the controlD* numbers to match what's been there (David)
- Add a comment what exactly userspace minimally needs.
- Correct the analysis for -intel (Chris).

Fixes: 8a357d10043c ("drm: Nerf DRM_CONTROL nodes")
Cc: Dave Airlie <airlied@gmail.com>
Reported-and-tested-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161209135656.14881-1-daniel.vetter@ffwll.ch
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/drm_drv.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 6efdba4993fc..d6e03f8f5358 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -667,6 +667,62 @@ void drm_dev_unref(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_dev_unref);
 
+static int create_compat_control_link(struct drm_device *dev)
+{
+	struct drm_minor *minor;
+	char *name;
+	int ret;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return 0;
+
+	minor = *drm_minor_get_slot(dev, DRM_MINOR_PRIMARY);
+	if (!minor)
+		return 0;
+
+	/*
+	 * Some existing userspace out there uses the existing of the controlD*
+	 * sysfs files to figure out whether it's a modeset driver. It only does
+	 * readdir, hence a symlink is sufficient (and the least confusing
+	 * option). Otherwise controlD* is entirely unused.
+	 *
+	 * Old controlD chardev have been allocated in the range
+	 * 64-127.
+	 */
+	name = kasprintf(GFP_KERNEL, "controlD%d", minor->index + 64);
+	if (!name)
+		return -ENOMEM;
+
+	ret = sysfs_create_link(minor->kdev->kobj.parent,
+				&minor->kdev->kobj,
+				name);
+
+	kfree(name);
+
+	return ret;
+}
+
+static void remove_compat_control_link(struct drm_device *dev)
+{
+	struct drm_minor *minor;
+	char *name;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return;
+
+	minor = *drm_minor_get_slot(dev, DRM_MINOR_PRIMARY);
+	if (!minor)
+		return;
+
+	name = kasprintf(GFP_KERNEL, "controlD%d", minor->index);
+	if (!name)
+		return;
+
+	sysfs_remove_link(minor->kdev->kobj.parent, name);
+
+	kfree(name);
+}
+
 /**
  * drm_dev_register - Register DRM device
  * @dev: Device to register
@@ -705,6 +761,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
+	ret = create_compat_control_link(dev);
+	if (ret)
+		goto err_minors;
+
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, flags);
 		if (ret)
@@ -718,6 +778,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	goto out_unlock;
 
 err_minors:
+	remove_compat_control_link(dev);
 	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
@@ -758,6 +819,7 @@ void drm_dev_unregister(struct drm_device *dev)
 	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
 		drm_legacy_rmmap(dev, r_list->map);
 
+	remove_compat_control_link(dev);
 	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 053/111] drm: prevent double-(un)registration for connectors
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (50 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 052/111] drm: Add fake controlD* symlinks for backwards compat Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 054/111] drm: Don't race connector registration Levin, Alexander (Sasha Levin)
                   ` (17 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Daniel Vetter, Chris Wilson, Daniel Vetter, Levin,
	Alexander (Sasha Levin)

From: Daniel Vetter <daniel.vetter@ffwll.ch>

[ Upstream commit e73ab00e9a0f1731f34d0620a9c55f5c30c4ad4e ]

If we're unlucky then the registration from a hotplugged connector
might race with the final registration step on driver load. And since
MST topology discover is asynchronous that's even somewhat likely.

v2: Also update the kerneldoc for @registered!

v3: Review from Chris:
- Improve kerneldoc for late_register/early_unregister callbacks.
- Use mutex_destroy.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161218133545.2106-1-daniel.vetter@ffwll.ch
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/drm_connector.c | 20 +++++++++++++++-----
 include/drm/drm_connector.h     | 16 +++++++++++++++-
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 2db7fb510b6c..a103f1fcbdbf 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -225,6 +225,7 @@ int drm_connector_init(struct drm_device *dev,
 
 	INIT_LIST_HEAD(&connector->probed_modes);
 	INIT_LIST_HEAD(&connector->modes);
+	mutex_init(&connector->mutex);
 	connector->edid_blob_ptr = NULL;
 	connector->status = connector_status_unknown;
 
@@ -359,6 +360,8 @@ void drm_connector_cleanup(struct drm_connector *connector)
 		connector->funcs->atomic_destroy_state(connector,
 						       connector->state);
 
+	mutex_destroy(&connector->mutex);
+
 	memset(connector, 0, sizeof(*connector));
 }
 EXPORT_SYMBOL(drm_connector_cleanup);
@@ -374,14 +377,15 @@ EXPORT_SYMBOL(drm_connector_cleanup);
  */
 int drm_connector_register(struct drm_connector *connector)
 {
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&connector->mutex);
 	if (connector->registered)
-		return 0;
+		goto unlock;
 
 	ret = drm_sysfs_connector_add(connector);
 	if (ret)
-		return ret;
+		goto unlock;
 
 	ret = drm_debugfs_connector_add(connector);
 	if (ret) {
@@ -397,12 +401,14 @@ int drm_connector_register(struct drm_connector *connector)
 	drm_mode_object_register(connector->dev, &connector->base);
 
 	connector->registered = true;
-	return 0;
+	goto unlock;
 
 err_debugfs:
 	drm_debugfs_connector_remove(connector);
 err_sysfs:
 	drm_sysfs_connector_remove(connector);
+unlock:
+	mutex_unlock(&connector->mutex);
 	return ret;
 }
 EXPORT_SYMBOL(drm_connector_register);
@@ -415,8 +421,11 @@ EXPORT_SYMBOL(drm_connector_register);
  */
 void drm_connector_unregister(struct drm_connector *connector)
 {
-	if (!connector->registered)
+	mutex_lock(&connector->mutex);
+	if (!connector->registered) {
+		mutex_unlock(&connector->mutex);
 		return;
+	}
 
 	if (connector->funcs->early_unregister)
 		connector->funcs->early_unregister(connector);
@@ -425,6 +434,7 @@ void drm_connector_unregister(struct drm_connector *connector)
 	drm_debugfs_connector_remove(connector);
 
 	connector->registered = false;
+	mutex_unlock(&connector->mutex);
 }
 EXPORT_SYMBOL(drm_connector_unregister);
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index ac9d7d8e0e43..d8bb8d151825 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -345,6 +345,8 @@ struct drm_connector_funcs {
 	 * core drm connector interfaces. Everything added from this callback
 	 * should be unregistered in the early_unregister callback.
 	 *
+	 * This is called while holding drm_connector->mutex.
+	 *
 	 * Returns:
 	 *
 	 * 0 on success, or a negative error code on failure.
@@ -359,6 +361,8 @@ struct drm_connector_funcs {
 	 * late_register(). It is called from drm_connector_unregister(),
 	 * early in the driver unload sequence to disable userspace access
 	 * before data structures are torndown.
+	 *
+	 * This is called while holding drm_connector->mutex.
 	 */
 	void (*early_unregister)(struct drm_connector *connector);
 
@@ -511,7 +515,6 @@ struct drm_cmdline_mode {
  * @interlace_allowed: can this connector handle interlaced modes?
  * @doublescan_allowed: can this connector handle doublescan?
  * @stereo_allowed: can this connector handle stereo modes?
- * @registered: is this connector exposed (registered) with userspace?
  * @modes: modes available on this connector (from fill_modes() + user)
  * @status: one of the drm_connector_status enums (connected, not, or unknown)
  * @probed_modes: list of modes derived directly from the display
@@ -560,6 +563,13 @@ struct drm_connector {
 	char *name;
 
 	/**
+	 * @mutex: Lock for general connector state, but currently only protects
+	 * @registered. Most of the connector state is still protected by the
+	 * mutex in &drm_mode_config.
+	 */
+	struct mutex mutex;
+
+	/**
 	 * @index: Compacted connector index, which matches the position inside
 	 * the mode_config.list for drivers not supporting hot-add/removing. Can
 	 * be used as an array index. It is invariant over the lifetime of the
@@ -572,6 +582,10 @@ struct drm_connector {
 	bool interlace_allowed;
 	bool doublescan_allowed;
 	bool stereo_allowed;
+	/**
+	 * @registered: Is this connector exposed (registered) with userspace?
+	 * Protected by @mutex.
+	 */
 	bool registered;
 	struct list_head modes; /* list of modes on this connector */
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 054/111] drm: Don't race connector registration
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (51 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 053/111] drm: prevent double-(un)registration for connectors Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 055/111] pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES Levin, Alexander (Sasha Levin)
                   ` (16 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Daniel Vetter, Dave Hansen, Chris Wilson, Daniel Vetter, Levin,
	Alexander (Sasha Levin)

From: Daniel Vetter <daniel.vetter@ffwll.ch>

[ Upstream commit e6e7b48b295afa5a5ab440de0a94d9ad8b3ce2d0 ]

I was under the misconception that the sysfs dev stuff can be fully
set up, and then registered all in one step with device_add. That's
true for properties and property groups, but not for parents and child
devices. Those must be fully registered before you can register a
child.

Add a bit of tracking to make sure that asynchronous mst connector
hotplugging gets this right. For consistency we rely upon the implicit
barriers of the connector->mutex, which is taken anyway, to ensure
that at least either the connector or device registration call will
work out.

Mildly tested since I can't reliably reproduce this on my mst box
here.

Reported-by: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1484237756-2720-1-git-send-email-daniel.vetter@ffwll.ch
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_drv.c       | 4 ++++
 include/drm/drmP.h              | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index a103f1fcbdbf..0e934a9ac63c 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -379,6 +379,9 @@ int drm_connector_register(struct drm_connector *connector)
 {
 	int ret = 0;
 
+	if (!connector->dev->registered)
+		return 0;
+
 	mutex_lock(&connector->mutex);
 	if (connector->registered)
 		goto unlock;
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index d6e03f8f5358..12b9782f1297 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -765,6 +765,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
+	dev->registered = true;
+
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, flags);
 		if (ret)
@@ -805,6 +807,8 @@ void drm_dev_unregister(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
+	dev->registered = false;
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_modeset_unregister_all(dev);
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e9fb2e802feb..0c4f9c67c221 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -776,6 +776,7 @@ struct drm_device {
 	struct drm_minor *control;		/**< Control node */
 	struct drm_minor *primary;		/**< Primary node */
 	struct drm_minor *render;		/**< Render node */
+	bool registered;
 
 	/* currently active master for this device. Protected by master_mutex */
 	struct drm_master *master;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 055/111] pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (52 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 054/111] drm: Don't race connector registration Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 056/111] net: adaptec: starfire: add checks for dma mapping errors Levin, Alexander (Sasha Levin)
                   ` (15 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Jisheng Zhang, Linus Walleij, Levin, Alexander (Sasha Levin)

From: Jisheng Zhang <jszhang@marvell.com>

[ Upstream commit e82d02580af45663fad6d3596e4344c606e81e10 ]

This should be a typo.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/pinctrl/berlin/berlin-bg4ct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/berlin/berlin-bg4ct.c b/drivers/pinctrl/berlin/berlin-bg4ct.c
index 09172043d589..c617ec49e9ed 100644
--- a/drivers/pinctrl/berlin/berlin-bg4ct.c
+++ b/drivers/pinctrl/berlin/berlin-bg4ct.c
@@ -217,7 +217,7 @@ static const struct berlin_desc_group berlin4ct_soc_pinctrl_groups[] = {
 	BERLIN_PINCTRL_GROUP("SCRD0_CRD_PRES", 0xc, 0x3, 0x15,
 			BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO20 */
 			BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* crd pres */
-			BERLIN_PINCTRL_FUNCTION(0x1, "sd1a")), /* DAT3 */
+			BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT3 */
 	BERLIN_PINCTRL_GROUP("SPI1_SS0n", 0xc, 0x3, 0x18,
 			BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */
 			BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO37 */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 056/111] net: adaptec: starfire: add checks for dma mapping errors
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (53 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 055/111] pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 057/111] drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj() Levin, Alexander (Sasha Levin)
                   ` (14 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Alexey Khoroshilov, David S . Miller, Levin, Alexander (Sasha Levin)

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

[ Upstream commit d1156b489fa734d1af763d6a07b1637c01bb0aed ]

init_ring(), refill_rx_ring() and start_tx() don't check
if mapping dma memory succeed.
The patch adds the checks and failure handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/adaptec/starfire.c | 45 +++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c
index 8af2c88d5b33..45bb0fe50917 100644
--- a/drivers/net/ethernet/adaptec/starfire.c
+++ b/drivers/net/ethernet/adaptec/starfire.c
@@ -1153,6 +1153,12 @@ static void init_ring(struct net_device *dev)
 		if (skb == NULL)
 			break;
 		np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
+		if (pci_dma_mapping_error(np->pci_dev,
+					  np->rx_info[i].mapping)) {
+			dev_kfree_skb(skb);
+			np->rx_info[i].skb = NULL;
+			break;
+		}
 		/* Grrr, we cannot offset to correctly align the IP header. */
 		np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid);
 	}
@@ -1183,8 +1189,9 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
 	unsigned int entry;
+	unsigned int prev_tx;
 	u32 status;
-	int i;
+	int i, j;
 
 	/*
 	 * be cautious here, wrapping the queue has weird semantics
@@ -1202,6 +1209,7 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
 	}
 #endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */
 
+	prev_tx = np->cur_tx;
 	entry = np->cur_tx % TX_RING_SIZE;
 	for (i = 0; i < skb_num_frags(skb); i++) {
 		int wrap_ring = 0;
@@ -1235,6 +1243,11 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
 					       skb_frag_size(this_frag),
 					       PCI_DMA_TODEVICE);
 		}
+		if (pci_dma_mapping_error(np->pci_dev,
+					  np->tx_info[entry].mapping)) {
+			dev->stats.tx_dropped++;
+			goto err_out;
+		}
 
 		np->tx_ring[entry].addr = cpu_to_dma(np->tx_info[entry].mapping);
 		np->tx_ring[entry].status = cpu_to_le32(status);
@@ -1269,8 +1282,30 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
 		netif_stop_queue(dev);
 
 	return NETDEV_TX_OK;
-}
 
+err_out:
+	entry = prev_tx % TX_RING_SIZE;
+	np->tx_info[entry].skb = NULL;
+	if (i > 0) {
+		pci_unmap_single(np->pci_dev,
+				 np->tx_info[entry].mapping,
+				 skb_first_frag_len(skb),
+				 PCI_DMA_TODEVICE);
+		np->tx_info[entry].mapping = 0;
+		entry = (entry + np->tx_info[entry].used_slots) % TX_RING_SIZE;
+		for (j = 1; j < i; j++) {
+			pci_unmap_single(np->pci_dev,
+					 np->tx_info[entry].mapping,
+					 skb_frag_size(
+						&skb_shinfo(skb)->frags[j-1]),
+					 PCI_DMA_TODEVICE);
+			entry++;
+		}
+	}
+	dev_kfree_skb_any(skb);
+	np->cur_tx = prev_tx;
+	return NETDEV_TX_OK;
+}
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
@@ -1570,6 +1605,12 @@ static void refill_rx_ring(struct net_device *dev)
 				break;	/* Better luck next round. */
 			np->rx_info[entry].mapping =
 				pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
+			if (pci_dma_mapping_error(np->pci_dev,
+						np->rx_info[entry].mapping)) {
+				dev_kfree_skb(skb);
+				np->rx_info[entry].skb = NULL;
+				break;
+			}
 			np->rx_ring[entry].rxaddr =
 				cpu_to_dma(np->rx_info[entry].mapping | RxDescValid);
 		}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 057/111] drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj()
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (54 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 056/111] net: adaptec: starfire: add checks for dma mapping errors Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 059/111] net/mlx5: Return EOPNOTSUPP when failing to get steering name-space Levin, Alexander (Sasha Levin)
                   ` (13 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Linus Torvalds, Daniel Vetter, Jani Nikula,
	Ville Syrjälä,
	Chris Wilson, Maarten Lankhorst, Tvrtko Ursulin, Imre Deak,
	Levin, Alexander (Sasha Levin)

From: Linus Torvalds <torvalds@linux-foundation.org>

[ Upstream commit 39cb2c9a316e77f6dfba96c543e55b6672d5a37e ]

I've seen this trigger twice now, where the i915_gem_object_to_ggtt()
call in intel_unpin_fb_obj() returns NULL, resulting in an oops
immediately afterwards as the (inlined) call to i915_vma_unpin_fence()
tries to dereference it.

It seems to be some race condition where the object is going away at
shutdown time, since both times happened when shutting down the X
server.  The call chains were different:

 - VT ioctl(KDSETMODE, KD_TEXT):

    intel_cleanup_plane_fb+0x5b/0xa0 [i915]
    drm_atomic_helper_cleanup_planes+0x6f/0x90 [drm_kms_helper]
    intel_atomic_commit_tail+0x749/0xfe0 [i915]
    intel_atomic_commit+0x3cb/0x4f0 [i915]
    drm_atomic_commit+0x4b/0x50 [drm]
    restore_fbdev_mode+0x14c/0x2a0 [drm_kms_helper]
    drm_fb_helper_restore_fbdev_mode_unlocked+0x34/0x80 [drm_kms_helper]
    drm_fb_helper_set_par+0x2d/0x60 [drm_kms_helper]
    intel_fbdev_set_par+0x18/0x70 [i915]
    fb_set_var+0x236/0x460
    fbcon_blank+0x30f/0x350
    do_unblank_screen+0xd2/0x1a0
    vt_ioctl+0x507/0x12a0
    tty_ioctl+0x355/0xc30
    do_vfs_ioctl+0xa3/0x5e0
    SyS_ioctl+0x79/0x90
    entry_SYSCALL_64_fastpath+0x13/0x94

 - i915 unpin_work workqueue:

    intel_unpin_work_fn+0x58/0x140 [i915]
    process_one_work+0x1f1/0x480
    worker_thread+0x48/0x4d0
    kthread+0x101/0x140

and this patch purely papers over the issue by adding a NULL pointer
check and a WARN_ON_ONCE() to avoid the oops that would then generally
make the machine unresponsive.

Other callers of i915_gem_object_to_ggtt() seem to also check for the
returned pointer being NULL and warn about it, so this clearly has
happened before in other places.

[ Reported it originally to the i915 developers on Jan 8, applying the
  ugly workaround on my own now after triggering the problem for the
  second time with no feedback.

  This is likely to be the same bug reported as

     https://bugs.freedesktop.org/show_bug.cgi?id=98829
     https://bugs.freedesktop.org/show_bug.cgi?id=99134

  which has a patch for the underlying problem, but it hasn't gotten to
  me, so I'm applying the workaround. ]

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/i915/intel_display.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5dc6082639db..3673ab3aa991 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2253,6 +2253,9 @@ void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)
 	intel_fill_fb_ggtt_view(&view, fb, rotation);
 	vma = i915_gem_object_to_ggtt(obj, &view);
 
+	if (WARN_ON_ONCE(!vma))
+		return;
+
 	i915_vma_unpin_fence(vma);
 	i915_gem_object_unpin_from_display_plane(vma);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 059/111] net/mlx5: Return EOPNOTSUPP when failing to get steering name-space
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (55 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 057/111] drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj() Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 058/111] net/mlx5: E-Switch, Err when retrieving steering name-space fails Levin, Alexander (Sasha Levin)
                   ` (12 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Or Gerlitz, Saeed Mahameed, Levin, Alexander (Sasha Levin)

From: Or Gerlitz <ogerlitz@mellanox.com>

[ Upstream commit eff596da48784316ccb83bef82bc1213b512d5e0 ]

When we fail to retrieve a hardware steering name-space, the returned error
code should say that this operation is not supported. Align the various
places in the driver where this call is made to this convention.

Also, make sure to warn when we fail to retrieve a SW (ANCHOR) name-space.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_fs.c            | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c          | 6 +++---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c          | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index 36fbc6b21a33..8cd7227fbdfc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -1081,7 +1081,7 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
 					       MLX5_FLOW_NAMESPACE_KERNEL);
 
 	if (!priv->fs.ns)
-		return -EINVAL;
+		return -EOPNOTSUPP;
 
 	err = mlx5e_arfs_create_tables(priv);
 	if (err) {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index c7011ef4e351..a8966e6dbe1b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -352,7 +352,7 @@ static int esw_create_legacy_fdb_table(struct mlx5_eswitch *esw, int nvports)
 	root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_FDB);
 	if (!root_ns) {
 		esw_warn(dev, "Failed to get FDB flow namespace\n");
-		return -ENOMEM;
+		return -EOPNOTSUPP;
 	}
 
 	flow_group_in = mlx5_vzalloc(inlen);
@@ -961,7 +961,7 @@ static int esw_vport_enable_egress_acl(struct mlx5_eswitch *esw,
 	root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_EGRESS);
 	if (!root_ns) {
 		esw_warn(dev, "Failed to get E-Switch egress flow namespace\n");
-		return -EIO;
+		return -EOPNOTSUPP;
 	}
 
 	flow_group_in = mlx5_vzalloc(inlen);
@@ -1078,7 +1078,7 @@ static int esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw,
 	root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS);
 	if (!root_ns) {
 		esw_warn(dev, "Failed to get E-Switch ingress flow namespace\n");
-		return -EIO;
+		return -EOPNOTSUPP;
 	}
 
 	flow_group_in = mlx5_vzalloc(inlen);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index d3f8840f10fe..b08b9e2c6a76 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -521,7 +521,7 @@ static int esw_create_offloads_table(struct mlx5_eswitch *esw)
 	ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_OFFLOADS);
 	if (!ns) {
 		esw_warn(esw->dev, "Failed to get offloads flow namespace\n");
-		return -ENOMEM;
+		return -EOPNOTSUPP;
 	}
 
 	ft_offloads = mlx5_create_flow_table(ns, 0, dev->priv.sriov.num_vfs + 2, 0);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 7e20e4bc4cc7..4de3c28b0547 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1678,7 +1678,7 @@ static int create_anchor_flow_table(struct mlx5_flow_steering *steering)
 	struct mlx5_flow_table *ft;
 
 	ns = mlx5_get_flow_namespace(steering->dev, MLX5_FLOW_NAMESPACE_ANCHOR);
-	if (!ns)
+	if (WARN_ON(!ns))
 		return -EINVAL;
 	ft = mlx5_create_flow_table(ns, ANCHOR_PRIO, ANCHOR_SIZE, ANCHOR_LEVEL);
 	if (IS_ERR(ft)) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 058/111] net/mlx5: E-Switch, Err when retrieving steering name-space fails
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (56 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 059/111] net/mlx5: Return EOPNOTSUPP when failing to get steering name-space Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 060/111] parisc, parport_gsc: Fixes for printk continuation lines Levin, Alexander (Sasha Levin)
                   ` (11 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Or Gerlitz, Saeed Mahameed, Levin, Alexander (Sasha Levin)

From: Or Gerlitz <ogerlitz@mellanox.com>

[ Upstream commit 5403dc703ff277f8a2a12a83ac820750485f13b3 ]

Make sure to return error when we failed retrieving the FDB steering
name space. Also, while around, correctly print the error when mode
change revert fails in the warning message.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index d239f5d0ea36..d3f8840f10fe 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -414,6 +414,7 @@ static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)
 	root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_FDB);
 	if (!root_ns) {
 		esw_warn(dev, "Failed to get FDB flow namespace\n");
+		err = -EOPNOTSUPP;
 		goto ns_err;
 	}
 
@@ -639,7 +640,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw)
 		esw_warn(esw->dev, "Failed setting eswitch to offloads, err %d\n", err);
 		err1 = mlx5_eswitch_enable_sriov(esw, num_vfs, SRIOV_LEGACY);
 		if (err1)
-			esw_warn(esw->dev, "Failed setting eswitch back to legacy, err %d\n", err);
+			esw_warn(esw->dev, "Failed setting eswitch back to legacy, err %d\n", err1);
 	}
 	return err;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 060/111] parisc, parport_gsc: Fixes for printk continuation lines
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (57 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 058/111] net/mlx5: E-Switch, Err when retrieving steering name-space fails Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 061/111] net: phy: micrel: add support for KSZ8795 Levin, Alexander (Sasha Levin)
                   ` (10 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Helge Deller, Levin, Alexander (Sasha Levin)

From: Helge Deller <deller@gmx.de>

[ Upstream commit 83b5d1e3d3013dbf90645a5d07179d018c8243fa ]

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/parport/parport_gsc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
index 6e3a60c78873..50f3bb0dd1f1 100644
--- a/drivers/parport/parport_gsc.c
+++ b/drivers/parport/parport_gsc.c
@@ -293,7 +293,7 @@ struct parport *parport_gsc_probe_port(unsigned long base,
 		p->irq = PARPORT_IRQ_NONE;
 	}
 	if (p->irq != PARPORT_IRQ_NONE) {
-		printk(", irq %d", p->irq);
+		pr_cont(", irq %d", p->irq);
 
 		if (p->dma == PARPORT_DMA_AUTO) {
 			p->dma = PARPORT_DMA_NONE;
@@ -303,8 +303,8 @@ struct parport *parport_gsc_probe_port(unsigned long base,
                                            is mandatory (see above) */
 		p->dma = PARPORT_DMA_NONE;
 
-	printk(" [");
-#define printmode(x) {if(p->modes&PARPORT_MODE_##x){printk("%s%s",f?",":"",#x);f++;}}
+	pr_cont(" [");
+#define printmode(x) {if(p->modes&PARPORT_MODE_##x){pr_cont("%s%s",f?",":"",#x);f++;}}
 	{
 		int f = 0;
 		printmode(PCSPP);
@@ -315,7 +315,7 @@ struct parport *parport_gsc_probe_port(unsigned long base,
 //		printmode(DMA);
 	}
 #undef printmode
-	printk("]\n");
+	pr_cont("]\n");
 
 	if (p->irq != PARPORT_IRQ_NONE) {
 		if (request_irq (p->irq, parport_irq_handler,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 062/111] ARM64: dts: amlogic: Add Meson GX dtsi from GXBB
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (59 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 061/111] net: phy: micrel: add support for KSZ8795 Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage Levin, Alexander (Sasha Levin)
                   ` (8 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Neil Armstrong, Kevin Hilman, Levin, Alexander (Sasha Levin)

From: Neil Armstrong <narmstrong@baylibre.com>

[ Upstream commit c328666d58aac4880bf0934eb915f9c5d1801360 ]

Move all non-gxbb specific nodes to a common GX dtsi.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm64/boot/dts/amlogic/meson-gx.dtsi   | 200 +++++++
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 895 ++++++++++++----------------
 2 files changed, 579 insertions(+), 516 deletions(-)
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-gx.dtsi

diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
new file mode 100644
index 000000000000..0737056b369f
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2016 BayLibre, SAS.
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ *
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <carlo@endlessm.com>
+ *
+ * Copyright (c) 2016 Andreas Färber
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+	interrupt-parent = <&gic>;
+	#address-cells = <2>;
+	#size-cells = <2>;
+
+	cpus {
+		#address-cells = <0x2>;
+		#size-cells = <0x0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x0>;
+			enable-method = "psci";
+		};
+
+		cpu1: cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x1>;
+			enable-method = "psci";
+		};
+
+		cpu2: cpu@2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x2>;
+			enable-method = "psci";
+		};
+
+		cpu3: cpu@3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x3>;
+			enable-method = "psci";
+		};
+	};
+
+	arm-pmu {
+		compatible = "arm,cortex-a53-pmu";
+		interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+	};
+
+	psci {
+		compatible = "arm,psci-0.2";
+		method = "smc";
+	};
+
+	timer {
+		compatible = "arm,armv8-timer";
+		interrupts = <GIC_PPI 13
+			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 14
+			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 11
+			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
+			     <GIC_PPI 10
+			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>;
+	};
+
+	xtal: xtal-clk {
+		compatible = "fixed-clock";
+		clock-frequency = <24000000>;
+		clock-output-names = "xtal";
+		#clock-cells = <0>;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		cbus: cbus@c1100000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xc1100000 0x0 0x100000>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xc1100000 0x0 0x100000>;
+
+			uart_A: serial@84c0 {
+				compatible = "amlogic,meson-uart";
+				reg = <0x0 0x84c0 0x0 0x14>;
+				interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
+				clocks = <&xtal>;
+				status = "disabled";
+			};
+		};
+
+		gic: interrupt-controller@c4301000 {
+			compatible = "arm,gic-400";
+			reg = <0x0 0xc4301000 0 0x1000>,
+			      <0x0 0xc4302000 0 0x2000>,
+			      <0x0 0xc4304000 0 0x2000>,
+			      <0x0 0xc4306000 0 0x2000>;
+			interrupt-controller;
+			interrupts = <GIC_PPI 9
+				(GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
+			#interrupt-cells = <3>;
+			#address-cells = <0>;
+		};
+
+		aobus: aobus@c8100000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xc8100000 0x0 0x100000>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xc8100000 0x0 0x100000>;
+
+			uart_AO: serial@4c0 {
+				compatible = "amlogic,meson-uart";
+				reg = <0x0 0x004c0 0x0 0x14>;
+				interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
+				clocks = <&xtal>;
+				status = "disabled";
+			};
+		};
+
+		periphs: periphs@c8834000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xc8834000 0x0 0x2000>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xc8834000 0x0 0x2000>;
+		};
+
+
+		hiubus: hiubus@c883c000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xc883c000 0x0 0x2000>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xc883c000 0x0 0x2000>;
+		};
+
+		apb: apb@d0000000 {
+			compatible = "simple-bus";
+			reg = <0x0 0xd0000000 0x0 0x200000>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges = <0x0 0x0 0x0 0xd0000000 0x0 0x200000>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index 610e0e1c3cee..443811b497de 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -40,9 +40,7 @@
  *     OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/interrupt-controller/irq.h>
-#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "meson-gx.dtsi"
 #include <dt-bindings/gpio/meson-gxbb-gpio.h>
 #include <dt-bindings/reset/amlogic,meson-gxbb-reset.h>
 #include <dt-bindings/clock/gxbb-clkc.h>
@@ -51,56 +49,6 @@
 
 / {
 	compatible = "amlogic,meson-gxbb";
-	interrupt-parent = <&gic>;
-	#address-cells = <2>;
-	#size-cells = <2>;
-
-	cpus {
-		#address-cells = <0x2>;
-		#size-cells = <0x0>;
-
-		cpu0: cpu@0 {
-			device_type = "cpu";
-			compatible = "arm,cortex-a53", "arm,armv8";
-			reg = <0x0 0x0>;
-			enable-method = "psci";
-		};
-
-		cpu1: cpu@1 {
-			device_type = "cpu";
-			compatible = "arm,cortex-a53", "arm,armv8";
-			reg = <0x0 0x1>;
-			enable-method = "psci";
-		};
-
-		cpu2: cpu@2 {
-			device_type = "cpu";
-			compatible = "arm,cortex-a53", "arm,armv8";
-			reg = <0x0 0x2>;
-			enable-method = "psci";
-		};
-
-		cpu3: cpu@3 {
-			device_type = "cpu";
-			compatible = "arm,cortex-a53", "arm,armv8";
-			reg = <0x0 0x3>;
-			enable-method = "psci";
-		};
-	};
-
-	arm-pmu {
-		compatible = "arm,cortex-a53-pmu";
-		interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
-			     <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
-			     <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
-			     <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
-		interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
-	};
-
-	psci {
-		compatible = "arm,psci-0.2";
-		method = "smc";
-	};
 
 	firmware {
 		sm: secure-monitor {
@@ -126,31 +74,7 @@
 		};
 	};
 
-	timer {
-		compatible = "arm,armv8-timer";
-		interrupts = <GIC_PPI 13
-			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
-			     <GIC_PPI 14
-			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
-			     <GIC_PPI 11
-			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>,
-			     <GIC_PPI 10
-			(GIC_CPU_MASK_RAW(0xff) | IRQ_TYPE_LEVEL_LOW)>;
-	};
-
-	xtal: xtal-clk {
-		compatible = "fixed-clock";
-		clock-frequency = <24000000>;
-		clock-output-names = "xtal";
-		#clock-cells = <0>;
-	};
-
 	soc {
-		compatible = "simple-bus";
-		#address-cells = <2>;
-		#size-cells = <2>;
-		ranges;
-
 		usb0_phy: phy@c0000000 {
 			compatible = "amlogic,meson-gxbb-usb2-phy";
 			#phy-cells = <0>;
@@ -170,500 +94,439 @@
 			status = "disabled";
 		};
 
-		cbus: cbus@c1100000 {
-			compatible = "simple-bus";
-			reg = <0x0 0xc1100000 0x0 0x100000>;
-			#address-cells = <2>;
-			#size-cells = <2>;
-			ranges = <0x0 0x0 0x0 0xc1100000 0x0 0x100000>;
+		usb0: usb@c9000000 {
+			compatible = "amlogic,meson-gxbb-usb", "snps,dwc2";
+			reg = <0x0 0xc9000000 0x0 0x40000>;
+			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clkc CLKID_USB0_DDR_BRIDGE>;
+			clock-names = "otg";
+			phys = <&usb0_phy>;
+			phy-names = "usb2-phy";
+			dr_mode = "host";
+			status = "disabled";
+		};
 
-			reset: reset-controller@4404 {
-				compatible = "amlogic,meson-gxbb-reset";
-				reg = <0x0 0x04404 0x0 0x20>;
-				#reset-cells = <1>;
-			};
+		usb1: usb@c9100000 {
+			compatible = "amlogic,meson-gxbb-usb", "snps,dwc2";
+			reg = <0x0 0xc9100000 0x0 0x40000>;
+			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clkc CLKID_USB1_DDR_BRIDGE>;
+			clock-names = "otg";
+			phys = <&usb1_phy>;
+			phy-names = "usb2-phy";
+			dr_mode = "host";
+			status = "disabled";
+		};
 
-			uart_A: serial@84c0 {
-				compatible = "amlogic,meson-uart";
-				reg = <0x0 0x84c0 0x0 0x14>;
-				interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&xtal>;
-				status = "disabled";
-			};
+		ethmac: ethernet@c9410000 {
+			compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac";
+			reg = <0x0 0xc9410000 0x0 0x10000
+			       0x0 0xc8834540 0x0 0x4>;
+			interrupts = <0 8 1>;
+			interrupt-names = "macirq";
+			clocks = <&clkc CLKID_ETH>,
+				 <&clkc CLKID_FCLK_DIV2>,
+				 <&clkc CLKID_MPLL2>;
+			clock-names = "stmmaceth", "clkin0", "clkin1";
+			phy-mode = "rgmii";
+			status = "disabled";
+		};
+	};
+};
+
+&cbus {
+	reset: reset-controller@4404 {
+		compatible = "amlogic,meson-gxbb-reset";
+		reg = <0x0 0x04404 0x0 0x20>;
+		#reset-cells = <1>;
+	};
+
+	uart_B: serial@84dc {
+		compatible = "amlogic,meson-uart";
+		reg = <0x0 0x84dc 0x0 0x14>;
+		interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&xtal>;
+		status = "disabled";
+	};
+
+	pwm_ab: pwm@8550 {
+		compatible = "amlogic,meson-gxbb-pwm";
+		reg = <0x0 0x08550 0x0 0x10>;
+		#pwm-cells = <3>;
+		status = "disabled";
+	};
+
+	pwm_cd: pwm@8650 {
+		compatible = "amlogic,meson-gxbb-pwm";
+		reg = <0x0 0x08650 0x0 0x10>;
+		#pwm-cells = <3>;
+		status = "disabled";
+	};
+
+	pwm_ef: pwm@86c0 {
+		compatible = "amlogic,meson-gxbb-pwm";
+		reg = <0x0 0x086c0 0x0 0x10>;
+		#pwm-cells = <3>;
+		status = "disabled";
+	};
+
+	uart_C: serial@8700 {
+		compatible = "amlogic,meson-uart";
+		reg = <0x0 0x8700 0x0 0x14>;
+		interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&xtal>;
+		status = "disabled";
+	};
+
+	watchdog@98d0 {
+		compatible = "amlogic,meson-gxbb-wdt";
+		reg = <0x0 0x098d0 0x0 0x10>;
+		clocks = <&xtal>;
+	};
+
+	spifc: spi@8c80 {
+		compatible = "amlogic,meson-gxbb-spifc";
+		reg = <0x0 0x08c80 0x0 0x80>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clocks = <&clkc CLKID_SPI>;
+		status = "disabled";
+	};
+
+	i2c_A: i2c@8500 {
+		compatible = "amlogic,meson-gxbb-i2c";
+		reg = <0x0 0x08500 0x0 0x20>;
+		interrupts = <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&clkc CLKID_I2C>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+
+	i2c_B: i2c@87c0 {
+		compatible = "amlogic,meson-gxbb-i2c";
+		reg = <0x0 0x087c0 0x0 0x20>;
+		interrupts = <GIC_SPI 214 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&clkc CLKID_I2C>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+
+	i2c_C: i2c@87e0 {
+		compatible = "amlogic,meson-gxbb-i2c";
+		reg = <0x0 0x087e0 0x0 0x20>;
+		interrupts = <GIC_SPI 215 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&clkc CLKID_I2C>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+};
+
+&aobus {
+	pinctrl_aobus: pinctrl@14 {
+		compatible = "amlogic,meson-gxbb-aobus-pinctrl";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
 
-			uart_B: serial@84dc {
-				compatible = "amlogic,meson-uart";
-				reg = <0x0 0x84dc 0x0 0x14>;
-				interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&xtal>;
-				status = "disabled";
+		gpio_ao: bank@14 {
+			reg = <0x0 0x00014 0x0 0x8>,
+			      <0x0 0x0002c 0x0 0x4>,
+			      <0x0 0x00024 0x0 0x8>;
+			reg-names = "mux", "pull", "gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		uart_ao_a_pins: uart_ao_a {
+			mux {
+				groups = "uart_tx_ao_a", "uart_rx_ao_a";
+				function = "uart_ao";
 			};
+		};
 
-			pwm_ab: pwm@8550 {
-				compatible = "amlogic,meson-gxbb-pwm";
-				reg = <0x0 0x08550 0x0 0x10>;
-				#pwm-cells = <3>;
-				status = "disabled";
+		remote_input_ao_pins: remote_input_ao {
+			mux {
+				groups = "remote_input_ao";
+				function = "remote_input_ao";
 			};
+		};
 
-			pwm_cd: pwm@8650 {
-				compatible = "amlogic,meson-gxbb-pwm";
-				reg = <0x0 0x08650 0x0 0x10>;
-				#pwm-cells = <3>;
-				status = "disabled";
+		i2c_ao_pins: i2c_ao {
+			mux {
+				groups = "i2c_sck_ao",
+				       "i2c_sda_ao";
+				function = "i2c_ao";
 			};
+		};
 
-			pwm_ef: pwm@86c0 {
-				compatible = "amlogic,meson-gxbb-pwm";
-				reg = <0x0 0x086c0 0x0 0x10>;
-				#pwm-cells = <3>;
-				status = "disabled";
+		pwm_ao_a_3_pins: pwm_ao_a_3 {
+			mux {
+				groups = "pwm_ao_a_3";
+				function = "pwm_ao_a_3";
 			};
+		};
 
-			uart_C: serial@8700 {
-				compatible = "amlogic,meson-uart";
-				reg = <0x0 0x8700 0x0 0x14>;
-				interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&xtal>;
-				status = "disabled";
+		pwm_ao_a_6_pins: pwm_ao_a_6 {
+			mux {
+				groups = "pwm_ao_a_6";
+				function = "pwm_ao_a_6";
 			};
+		};
 
-			watchdog@98d0 {
-				compatible = "amlogic,meson-gxbb-wdt";
-				reg = <0x0 0x098d0 0x0 0x10>;
-				clocks = <&xtal>;
+		pwm_ao_a_12_pins: pwm_ao_a_12 {
+			mux {
+				groups = "pwm_ao_a_12";
+				function = "pwm_ao_a_12";
 			};
+		};
 
-			spifc: spi@8c80 {
-				compatible = "amlogic,meson-gxbb-spifc";
-				reg = <0x0 0x08c80 0x0 0x80>;
-				#address-cells = <1>;
-				#size-cells = <0>;
-				clocks = <&clkc CLKID_SPI>;
-				status = "disabled";
+		pwm_ao_b_pins: pwm_ao_b {
+			mux {
+				groups = "pwm_ao_b";
+				function = "pwm_ao_b";
 			};
+		};
+	};
+
+	clkc_AO: clock-controller@040 {
+		compatible = "amlogic,gxbb-aoclkc";
+		reg = <0x0 0x00040 0x0 0x4>;
+		#clock-cells = <1>;
+		#reset-cells = <1>;
+	};
+
+	ir: ir@580 {
+		compatible = "amlogic,meson-gxbb-ir";
+		reg = <0x0 0x00580 0x0 0x40>;
+		interrupts = <GIC_SPI 196 IRQ_TYPE_EDGE_RISING>;
+		status = "disabled";
+	};
+
+	pwm_ab_AO: pwm@550 {
+		compatible = "amlogic,meson-gxbb-pwm";
+		reg = <0x0 0x0550 0x0 0x10>;
+		#pwm-cells = <3>;
+		status = "disabled";
+	};
+
+	i2c_AO: i2c@500 {
+		compatible = "amlogic,meson-gxbb-i2c";
+		reg = <0x0 0x500 0x0 0x20>;
+		interrupts = <GIC_SPI 195 IRQ_TYPE_EDGE_RISING>;
+		clocks = <&clkc CLKID_AO_I2C>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+};
+
+&periphs {
+	rng {
+		compatible = "amlogic,meson-rng";
+		reg = <0x0 0x0 0x0 0x4>;
+	};
+
+	pinctrl_periphs: pinctrl@4b0 {
+		compatible = "amlogic,meson-gxbb-periphs-pinctrl";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		gpio: bank@4b0 {
+			reg = <0x0 0x004b0 0x0 0x28>,
+			      <0x0 0x004e8 0x0 0x14>,
+			      <0x0 0x00120 0x0 0x14>,
+			      <0x0 0x00430 0x0 0x40>;
+			reg-names = "mux", "pull", "pull-enable", "gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
 
-			i2c_A: i2c@8500 {
-				compatible = "amlogic,meson-gxbb-i2c";
-				reg = <0x0 0x08500 0x0 0x20>;
-				interrupts = <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&clkc CLKID_I2C>;
-				#address-cells = <1>;
-				#size-cells = <0>;
-				status = "disabled";
+		emmc_pins: emmc {
+			mux {
+				groups = "emmc_nand_d07",
+				       "emmc_cmd",
+				       "emmc_clk";
+				function = "emmc";
 			};
+		};
 
-			i2c_B: i2c@87c0 {
-				compatible = "amlogic,meson-gxbb-i2c";
-				reg = <0x0 0x087c0 0x0 0x20>;
-				interrupts = <GIC_SPI 214 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&clkc CLKID_I2C>;
-				#address-cells = <1>;
-				#size-cells = <0>;
-				status = "disabled";
+		nor_pins: nor {
+			mux {
+				groups = "nor_d",
+				       "nor_q",
+				       "nor_c",
+				       "nor_cs";
+				function = "nor";
 			};
+		};
 
-			i2c_C: i2c@87e0 {
-				compatible = "amlogic,meson-gxbb-i2c";
-				reg = <0x0 0x087e0 0x0 0x20>;
-				interrupts = <GIC_SPI 215 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&clkc CLKID_I2C>;
-				#address-cells = <1>;
-				#size-cells = <0>;
-				status = "disabled";
+		sdcard_pins: sdcard {
+			mux {
+				groups = "sdcard_d0",
+				       "sdcard_d1",
+				       "sdcard_d2",
+				       "sdcard_d3",
+				       "sdcard_cmd",
+				       "sdcard_clk";
+				function = "sdcard";
 			};
 		};
 
-		gic: interrupt-controller@c4301000 {
-			compatible = "arm,gic-400";
-			reg = <0x0 0xc4301000 0 0x1000>,
-			      <0x0 0xc4302000 0 0x2000>,
-			      <0x0 0xc4304000 0 0x2000>,
-			      <0x0 0xc4306000 0 0x2000>;
-			interrupt-controller;
-			interrupts = <GIC_PPI 9
-				(GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
-			#interrupt-cells = <3>;
-			#address-cells = <0>;
-		};
-
-		aobus: aobus@c8100000 {
-			compatible = "simple-bus";
-			reg = <0x0 0xc8100000 0x0 0x100000>;
-			#address-cells = <2>;
-			#size-cells = <2>;
-			ranges = <0x0 0x0 0x0 0xc8100000 0x0 0x100000>;
-
-			pinctrl_aobus: pinctrl@14 {
-				compatible = "amlogic,meson-gxbb-aobus-pinctrl";
-				#address-cells = <2>;
-				#size-cells = <2>;
-				ranges;
-
-				gpio_ao: bank@14 {
-					reg = <0x0 0x00014 0x0 0x8>,
-					      <0x0 0x0002c 0x0 0x4>,
-					      <0x0 0x00024 0x0 0x8>;
-					reg-names = "mux", "pull", "gpio";
-					gpio-controller;
-					#gpio-cells = <2>;
-				};
-
-				uart_ao_a_pins: uart_ao_a {
-					mux {
-						groups = "uart_tx_ao_a", "uart_rx_ao_a";
-						function = "uart_ao";
-					};
-				};
-
-				remote_input_ao_pins: remote_input_ao {
-					mux {
-						groups = "remote_input_ao";
-						function = "remote_input_ao";
-					};
-				};
-
-				i2c_ao_pins: i2c_ao {
-					mux {
-						groups = "i2c_sck_ao",
-						       "i2c_sda_ao";
-						function = "i2c_ao";
-					};
-				};
-
-				pwm_ao_a_3_pins: pwm_ao_a_3 {
-					mux {
-						groups = "pwm_ao_a_3";
-						function = "pwm_ao_a_3";
-					};
-				};
-
-				pwm_ao_a_6_pins: pwm_ao_a_6 {
-					mux {
-						groups = "pwm_ao_a_6";
-						function = "pwm_ao_a_6";
-					};
-				};
-
-				pwm_ao_a_12_pins: pwm_ao_a_12 {
-					mux {
-						groups = "pwm_ao_a_12";
-						function = "pwm_ao_a_12";
-					};
-				};
-
-				pwm_ao_b_pins: pwm_ao_b {
-					mux {
-						groups = "pwm_ao_b";
-						function = "pwm_ao_b";
-					};
-				};
+		sdio_pins: sdio {
+			mux {
+				groups = "sdio_d0",
+				       "sdio_d1",
+				       "sdio_d2",
+				       "sdio_d3",
+				       "sdio_cmd",
+				       "sdio_clk";
+				function = "sdio";
 			};
+		};
 
-			clkc_AO: clock-controller@040 {
-				compatible = "amlogic,gxbb-aoclkc";
-				reg = <0x0 0x00040 0x0 0x4>;
-				#clock-cells = <1>;
-				#reset-cells = <1>;
+		sdio_irq_pins: sdio_irq {
+			mux {
+				groups = "sdio_irq";
+				function = "sdio";
 			};
+		};
 
-			uart_AO: serial@4c0 {
-				compatible = "amlogic,meson-uart";
-				reg = <0x0 0x004c0 0x0 0x14>;
-				interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&xtal>;
-				status = "disabled";
+		uart_a_pins: uart_a {
+			mux {
+				groups = "uart_tx_a",
+				       "uart_rx_a";
+				function = "uart_a";
 			};
+		};
 
-			ir: ir@580 {
-				compatible = "amlogic,meson-gxbb-ir";
-				reg = <0x0 0x00580 0x0 0x40>;
-				interrupts = <GIC_SPI 196 IRQ_TYPE_EDGE_RISING>;
-				status = "disabled";
+		uart_b_pins: uart_b {
+			mux {
+				groups = "uart_tx_b",
+				       "uart_rx_b";
+				function = "uart_b";
 			};
+		};
 
-			pwm_ab_AO: pwm@550 {
-				compatible = "amlogic,meson-gxbb-pwm";
-				reg = <0x0 0x0550 0x0 0x10>;
-				#pwm-cells = <3>;
-				status = "disabled";
+		uart_c_pins: uart_c {
+			mux {
+				groups = "uart_tx_c",
+				       "uart_rx_c";
+				function = "uart_c";
 			};
+		};
 
-			i2c_AO: i2c@500 {
-				compatible = "amlogic,meson-gxbb-i2c";
-				reg = <0x0 0x500 0x0 0x20>;
-				interrupts = <GIC_SPI 195 IRQ_TYPE_EDGE_RISING>;
-				clocks = <&clkc CLKID_AO_I2C>;
-				#address-cells = <1>;
-				#size-cells = <0>;
-				status = "disabled";
+		i2c_a_pins: i2c_a {
+			mux {
+				groups = "i2c_sck_a",
+				       "i2c_sda_a";
+				function = "i2c_a";
 			};
 		};
 
-		periphs: periphs@c8834000 {
-			compatible = "simple-bus";
-			reg = <0x0 0xc8834000 0x0 0x2000>;
-			#address-cells = <2>;
-			#size-cells = <2>;
-			ranges = <0x0 0x0 0x0 0xc8834000 0x0 0x2000>;
+		i2c_b_pins: i2c_b {
+			mux {
+				groups = "i2c_sck_b",
+				       "i2c_sda_b";
+				function = "i2c_b";
+			};
+		};
 
-			rng {
-				compatible = "amlogic,meson-rng";
-				reg = <0x0 0x0 0x0 0x4>;
+		i2c_c_pins: i2c_c {
+			mux {
+				groups = "i2c_sck_c",
+				       "i2c_sda_c";
+				function = "i2c_c";
 			};
+		};
 
-			pinctrl_periphs: pinctrl@4b0 {
-				compatible = "amlogic,meson-gxbb-periphs-pinctrl";
-				#address-cells = <2>;
-				#size-cells = <2>;
-				ranges;
-
-				gpio: bank@4b0 {
-					reg = <0x0 0x004b0 0x0 0x28>,
-					      <0x0 0x004e8 0x0 0x14>,
-					      <0x0 0x00120 0x0 0x14>,
-					      <0x0 0x00430 0x0 0x40>;
-					reg-names = "mux", "pull", "pull-enable", "gpio";
-					gpio-controller;
-					#gpio-cells = <2>;
-				};
-
-				emmc_pins: emmc {
-					mux {
-						groups = "emmc_nand_d07",
-						       "emmc_cmd",
-						       "emmc_clk";
-						function = "emmc";
-					};
-				};
-
-				nor_pins: nor {
-					mux {
-						groups = "nor_d",
-						       "nor_q",
-						       "nor_c",
-						       "nor_cs";
-						function = "nor";
-					};
-				};
-
-				sdcard_pins: sdcard {
-					mux {
-						groups = "sdcard_d0",
-						       "sdcard_d1",
-						       "sdcard_d2",
-						       "sdcard_d3",
-						       "sdcard_cmd",
-						       "sdcard_clk";
-						function = "sdcard";
-					};
-				};
-
-				sdio_pins: sdio {
-					mux {
-						groups = "sdio_d0",
-						       "sdio_d1",
-						       "sdio_d2",
-						       "sdio_d3",
-						       "sdio_cmd",
-						       "sdio_clk";
-						function = "sdio";
-					};
-				};
-
-				sdio_irq_pins: sdio_irq {
-					mux {
-						groups = "sdio_irq";
-						function = "sdio";
-					};
-				};
-
-				uart_a_pins: uart_a {
-					mux {
-						groups = "uart_tx_a",
-						       "uart_rx_a";
-						function = "uart_a";
-					};
-				};
-
-				uart_b_pins: uart_b {
-					mux {
-						groups = "uart_tx_b",
-						       "uart_rx_b";
-						function = "uart_b";
-					};
-				};
-
-				uart_c_pins: uart_c {
-					mux {
-						groups = "uart_tx_c",
-						       "uart_rx_c";
-						function = "uart_c";
-					};
-				};
-
-				i2c_a_pins: i2c_a {
-					mux {
-						groups = "i2c_sck_a",
-						       "i2c_sda_a";
-						function = "i2c_a";
-					};
-				};
-
-				i2c_b_pins: i2c_b {
-					mux {
-						groups = "i2c_sck_b",
-						       "i2c_sda_b";
-						function = "i2c_b";
-					};
-				};
-
-				i2c_c_pins: i2c_c {
-					mux {
-						groups = "i2c_sck_c",
-						       "i2c_sda_c";
-						function = "i2c_c";
-					};
-				};
-
-				eth_pins: eth_c {
-					mux {
-						groups = "eth_mdio",
-						       "eth_mdc",
-						       "eth_clk_rx_clk",
-						       "eth_rx_dv",
-						       "eth_rxd0",
-						       "eth_rxd1",
-						       "eth_rxd2",
-						       "eth_rxd3",
-						       "eth_rgmii_tx_clk",
-						       "eth_tx_en",
-						       "eth_txd0",
-						       "eth_txd1",
-						       "eth_txd2",
-						       "eth_txd3";
-						function = "eth";
-					};
-				};
-
-				pwm_a_x_pins: pwm_a_x {
-					mux {
-						groups = "pwm_a_x";
-						function = "pwm_a_x";
-					};
-				};
-
-				pwm_a_y_pins: pwm_a_y {
-					mux {
-						groups = "pwm_a_y";
-						function = "pwm_a_y";
-					};
-				};
-
-				pwm_b_pins: pwm_b {
-					mux {
-						groups = "pwm_b";
-						function = "pwm_b";
-					};
-				};
-
-				pwm_d_pins: pwm_d {
-					mux {
-						groups = "pwm_d";
-						function = "pwm_d";
-					};
-				};
-
-				pwm_e_pins: pwm_e {
-					mux {
-						groups = "pwm_e";
-						function = "pwm_e";
-					};
-				};
-
-				pwm_f_x_pins: pwm_f_x {
-					mux {
-						groups = "pwm_f_x";
-						function = "pwm_f_x";
-					};
-				};
-
-				pwm_f_y_pins: pwm_f_y {
-					mux {
-						groups = "pwm_f_y";
-						function = "pwm_f_y";
-					};
-				};
+		eth_pins: eth_c {
+			mux {
+				groups = "eth_mdio",
+				       "eth_mdc",
+				       "eth_clk_rx_clk",
+				       "eth_rx_dv",
+				       "eth_rxd0",
+				       "eth_rxd1",
+				       "eth_rxd2",
+				       "eth_rxd3",
+				       "eth_rgmii_tx_clk",
+				       "eth_tx_en",
+				       "eth_txd0",
+				       "eth_txd1",
+				       "eth_txd2",
+				       "eth_txd3";
+				function = "eth";
 			};
 		};
 
-		hiubus: hiubus@c883c000 {
-			compatible = "simple-bus";
-			reg = <0x0 0xc883c000 0x0 0x2000>;
-			#address-cells = <2>;
-			#size-cells = <2>;
-			ranges = <0x0 0x0 0x0 0xc883c000 0x0 0x2000>;
+		pwm_a_x_pins: pwm_a_x {
+			mux {
+				groups = "pwm_a_x";
+				function = "pwm_a_x";
+			};
+		};
 
-			clkc: clock-controller@0 {
-				compatible = "amlogic,gxbb-clkc";
-				#clock-cells = <1>;
-				reg = <0x0 0x0 0x0 0x3db>;
+		pwm_a_y_pins: pwm_a_y {
+			mux {
+				groups = "pwm_a_y";
+				function = "pwm_a_y";
 			};
+		};
 
-			mailbox: mailbox@404 {
-				compatible = "amlogic,meson-gxbb-mhu";
-				reg = <0 0x404 0 0x4c>;
-				interrupts = <0 208 IRQ_TYPE_EDGE_RISING>,
-					     <0 209 IRQ_TYPE_EDGE_RISING>,
-					     <0 210 IRQ_TYPE_EDGE_RISING>;
-				#mbox-cells = <1>;
+		pwm_b_pins: pwm_b {
+			mux {
+				groups = "pwm_b";
+				function = "pwm_b";
 			};
 		};
 
-		apb: apb@d0000000 {
-			compatible = "simple-bus";
-			reg = <0x0 0xd0000000 0x0 0x200000>;
-			#address-cells = <2>;
-			#size-cells = <2>;
-			ranges = <0x0 0x0 0x0 0xd0000000 0x0 0x200000>;
+		pwm_d_pins: pwm_d {
+			mux {
+				groups = "pwm_d";
+				function = "pwm_d";
+			};
 		};
 
-		usb0: usb@c9000000 {
-			compatible = "amlogic,meson-gxbb-usb", "snps,dwc2";
-			reg = <0x0 0xc9000000 0x0 0x40000>;
-			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clkc CLKID_USB0_DDR_BRIDGE>;
-			clock-names = "otg";
-			phys = <&usb0_phy>;
-			phy-names = "usb2-phy";
-			dr_mode = "host";
-			status = "disabled";
+		pwm_e_pins: pwm_e {
+			mux {
+				groups = "pwm_e";
+				function = "pwm_e";
+			};
 		};
 
-		usb1: usb@c9100000 {
-			compatible = "amlogic,meson-gxbb-usb", "snps,dwc2";
-			reg = <0x0 0xc9100000 0x0 0x40000>;
-			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clkc CLKID_USB1_DDR_BRIDGE>;
-			clock-names = "otg";
-			phys = <&usb1_phy>;
-			phy-names = "usb2-phy";
-			dr_mode = "host";
-			status = "disabled";
+		pwm_f_x_pins: pwm_f_x {
+			mux {
+				groups = "pwm_f_x";
+				function = "pwm_f_x";
+			};
 		};
 
-		ethmac: ethernet@c9410000 {
-			compatible = "amlogic,meson-gxbb-dwmac", "snps,dwmac";
-			reg = <0x0 0xc9410000 0x0 0x10000
-			       0x0 0xc8834540 0x0 0x4>;
-			interrupts = <0 8 1>;
-			interrupt-names = "macirq";
-			clocks = <&clkc CLKID_ETH>,
-				 <&clkc CLKID_FCLK_DIV2>,
-				 <&clkc CLKID_MPLL2>;
-			clock-names = "stmmaceth", "clkin0", "clkin1";
-			phy-mode = "rgmii";
-			status = "disabled";
+		pwm_f_y_pins: pwm_f_y {
+			mux {
+				groups = "pwm_f_y";
+				function = "pwm_f_y";
+			};
 		};
 	};
 };
+
+&hiubus {
+	clkc: clock-controller@0 {
+		compatible = "amlogic,gxbb-clkc";
+		#clock-cells = <1>;
+		reg = <0x0 0x0 0x0 0x3db>;
+	};
+
+	mailbox: mailbox@404 {
+		compatible = "amlogic,meson-gxbb-mhu";
+		reg = <0 0x404 0 0x4c>;
+		interrupts = <0 208 IRQ_TYPE_EDGE_RISING>,
+			     <0 209 IRQ_TYPE_EDGE_RISING>,
+			     <0 210 IRQ_TYPE_EDGE_RISING>;
+		#mbox-cells = <1>;
+	};
+};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 061/111] net: phy: micrel: add support for KSZ8795
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (58 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 060/111] parisc, parport_gsc: Fixes for printk continuation lines Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 062/111] ARM64: dts: amlogic: Add Meson GX dtsi from GXBB Levin, Alexander (Sasha Levin)
                   ` (9 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Sean Nyekjaer, David S . Miller, Levin, Alexander (Sasha Levin)

From: Sean Nyekjaer <sean.nyekjaer@prevas.dk>

[ Upstream commit 9d162ed69f51cbd9ee5a0c7e82aba7acc96362ff ]

This is adds support for the PHYs in the KSZ8795 5port managed switch.

It will allow to detect the link between the switch and the soc
and uses the same read_status functions as the KSZ8873MLL switch.

Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/phy/micrel.c   | 14 ++++++++++++++
 include/linux/micrel_phy.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index ea92d524d5a8..fab56c9350cf 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1014,6 +1014,20 @@ static struct phy_driver ksphy_driver[] = {
 	.get_stats	= kszphy_get_stats,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
+}, {
+	.phy_id		= PHY_ID_KSZ8795,
+	.phy_id_mask	= MICREL_PHY_ID_MASK,
+	.name		= "Micrel KSZ8795",
+	.features	= (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
+	.flags		= PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
+	.config_init	= kszphy_config_init,
+	.config_aneg	= ksz8873mll_config_aneg,
+	.read_status	= ksz8873mll_read_status,
+	.get_sset_count = kszphy_get_sset_count,
+	.get_strings	= kszphy_get_strings,
+	.get_stats	= kszphy_get_stats,
+	.suspend	= genphy_suspend,
+	.resume		= genphy_resume,
 } };
 
 module_phy_driver(ksphy_driver);
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 257173e0095e..f541da68d1e7 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -35,6 +35,8 @@
 #define PHY_ID_KSZ886X		0x00221430
 #define PHY_ID_KSZ8863		0x00221435
 
+#define PHY_ID_KSZ8795		0x00221550
+
 /* struct phy_device dev_flags definitions */
 #define MICREL_PHY_50MHZ_CLK	0x00000001
 #define MICREL_PHY_FXEN		0x00000002
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (60 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 062/111] ARM64: dts: amlogic: Add Meson GX dtsi from GXBB Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04 20:45   ` Jerome Brunet
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 063/111] ARM64: dts: meson-gx: Add firmware reserved memory zones Levin, Alexander (Sasha Levin)
                   ` (7 subsequent siblings)
  69 siblings, 1 reply; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Jerome Brunet, Kevin Hilman, Arnd Bergmann, Levin,
	Alexander (Sasha Levin)

From: Jerome Brunet <jbrunet@baylibre.com>

[ Upstream commit feb3cbea0946c67060e2d5bcb7499b0a6f6700fe ]

OdroidC2 GbE link breaks under heavy tx transfer. This happens even if the
MAC does not enable Energy Efficient Ethernet (No Low Power state Idle on
the Tx path). The problem seems to come from the phy Rx path, entering the
LPI state.

Disabling EEE advertisement on the phy prevent this feature to be
negociated with the link partner and solve the issue.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index e6e3491d48a5..f150a4c63efe 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -85,6 +85,18 @@
 	status = "okay";
 	pinctrl-0 = <&eth_pins>;
 	pinctrl-names = "default";
+	phy-handle = <&eth_phy0>;
+
+	mdio {
+		compatible = "snps,dwmac-mdio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		eth_phy0: ethernet-phy@0 {
+			reg = <0>;
+			eee-broken-1000t;
+		};
+	};
 };
 
 &ir {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 063/111] ARM64: dts: meson-gx: Add firmware reserved memory zones
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (61 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 065/111] gtp: add genl family modules alias Levin, Alexander (Sasha Levin)
                   ` (6 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Neil Armstrong, Kevin Hilman, Arnd Bergmann, Levin,
	Alexander (Sasha Levin)

From: Neil Armstrong <narmstrong@baylibre.com>

[ Upstream commit bba8e3f42736cf7f974968a818e53b128286ad1d ]

The Amlogic Meson GXBB/GXL/GXM secure monitor uses part of the memory space,
this patch adds these reserved zones.

Without such reserved memory zones, running the following stress command :
$ stress-ng --vm 16 --vm-bytes 128M --timeout 10s
multiple times:

Could lead to the following kernel crashes :
[   46.937975] Bad mode in Error handler detected on CPU1, code 0xbf000000 -- SError
...
[   47.058536] Internal error: Attempting to execute userspace memory: 8600000f [#3] PREEMPT SMP
...
Instead of the OOM killer.

Fixes: 4f24eda8401f ("ARM64: dts: Prepare configs for Amlogic Meson GXBaby")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
[khilman: added Fixes tag, added _reserved and unit addresses]
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
index 0737056b369f..88849fe7aa66 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -55,6 +55,24 @@
 	#address-cells = <2>;
 	#size-cells = <2>;
 
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		/* 16 MiB reserved for Hardware ROM Firmware */
+		hwrom_reserved: hwrom@0 {
+			reg = <0x0 0x0 0x0 0x1000000>;
+			no-map;
+		};
+
+		/* 2 MiB reserved for ARM Trusted Firmware (BL31) */
+		secmon_reserved: secmon@10000000 {
+			reg = <0x0 0x10000000 0x0 0x200000>;
+			no-map;
+		};
+	};
+
 	cpus {
 		#address-cells = <0x2>;
 		#size-cells = <0x0>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 065/111] gtp: add genl family modules alias
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (62 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 063/111] ARM64: dts: meson-gx: Add firmware reserved memory zones Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 067/111] drm/nouveau: Rename acpi_work to hpd_work Levin, Alexander (Sasha Levin)
                   ` (5 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Andreas Schultz, David S . Miller, Levin, Alexander (Sasha Levin)

From: Andreas Schultz <aschultz@tpip.net>

[ Upstream commit ab729823ec16aef384f09fd2cffe0b3d3f6e6cba ]

Auto-load the module when userspace asks for the gtp netlink
family.

Signed-off-by: Andreas Schultz <aschultz@tpip.net>
Acked-by: Harald Welte <laforge@netfilter.org>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/gtp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 97e0cbca0a08..cebde074d196 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1372,3 +1372,4 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <hwelte@sysmocom.de>");
 MODULE_DESCRIPTION("Interface driver for GTP encapsulated traffic");
 MODULE_ALIAS_RTNL_LINK("gtp");
+MODULE_ALIAS_GENL_FAMILY("gtp");
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 067/111] drm/nouveau: Rename acpi_work to hpd_work
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (63 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 065/111] gtp: add genl family modules alias Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 066/111] drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE Levin, Alexander (Sasha Levin)
                   ` (4 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Hans de Goede, Ben Skeggs, Levin, Alexander (Sasha Levin)

From: Hans de Goede <hdegoede@redhat.com>

[ Upstream commit 81280d0e24e76c35f40f997af26c779bcb10b04d ]

We need to call drm_helper_hpd_irq_event() on resume to properly detect
monitor connection / disconnection on some laptops. For runtime-resume
(which gets called on resume from normal suspend too) we must call
drm_helper_hpd_irq_event() from a workqueue to avoid a deadlock.

Rename acpi_work to hpd_work, and move it out of the #ifdef CONFIG_ACPI
blocks to make it suitable for generic work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 32 +++++++++++++++----------------
 drivers/gpu/drm/nouveau/nouveau_drv.h     |  2 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index a0be029886d0..3cd2b8a7e530 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -359,21 +359,10 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {
 	}                                                                      \
 } while(0)
 
-#ifdef CONFIG_ACPI
-
-/*
- * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch
- * to the acpi subsys to move it there from drivers/acpi/acpi_video.c .
- * This should be dropped once that is merged.
- */
-#ifndef ACPI_VIDEO_NOTIFY_PROBE
-#define ACPI_VIDEO_NOTIFY_PROBE			0x81
-#endif
-
 static void
-nouveau_display_acpi_work(struct work_struct *work)
+nouveau_display_hpd_work(struct work_struct *work)
 {
-	struct nouveau_drm *drm = container_of(work, typeof(*drm), acpi_work);
+	struct nouveau_drm *drm = container_of(work, typeof(*drm), hpd_work);
 
 	pm_runtime_get_sync(drm->dev->dev);
 
@@ -383,6 +372,17 @@ nouveau_display_acpi_work(struct work_struct *work)
 	pm_runtime_put_sync(drm->dev->dev);
 }
 
+#ifdef CONFIG_ACPI
+
+/*
+ * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch
+ * to the acpi subsys to move it there from drivers/acpi/acpi_video.c .
+ * This should be dropped once that is merged.
+ */
+#ifndef ACPI_VIDEO_NOTIFY_PROBE
+#define ACPI_VIDEO_NOTIFY_PROBE			0x81
+#endif
+
 static int
 nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,
 			  void *data)
@@ -395,9 +395,9 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,
 			/*
 			 * This may be the only indication we receive of a
 			 * connector hotplug on a runtime suspended GPU,
-			 * schedule acpi_work to check.
+			 * schedule hpd_work to check.
 			 */
-			schedule_work(&drm->acpi_work);
+			schedule_work(&drm->hpd_work);
 
 			/* acpi-video should not generate keypresses for this */
 			return NOTIFY_BAD;
@@ -587,8 +587,8 @@ nouveau_display_create(struct drm_device *dev)
 	}
 
 	nouveau_backlight_init(dev);
+	INIT_WORK(&drm->hpd_work, nouveau_display_hpd_work);
 #ifdef CONFIG_ACPI
-	INIT_WORK(&drm->acpi_work, nouveau_display_acpi_work);
 	drm->acpi_nb.notifier_call = nouveau_display_acpi_ntfy;
 	register_acpi_notifier(&drm->acpi_nb);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 71d45324bd78..0c17ca1f5757 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -163,9 +163,9 @@ struct nouveau_drm {
 	struct nvbios vbios;
 	struct nouveau_display *display;
 	struct backlight_device *backlight;
+	struct work_struct hpd_work;
 #ifdef CONFIG_ACPI
 	struct notifier_block acpi_nb;
-	struct work_struct acpi_work;
 #endif
 
 	/* power management */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 066/111] drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (64 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 067/111] drm/nouveau: Rename acpi_work to hpd_work Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume Levin, Alexander (Sasha Levin)
                   ` (3 subsequent siblings)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Hans de Goede, Levin, Alexander (Sasha Levin)

From: Hans de Goede <hdegoede@redhat.com>

[ Upstream commit 3a6536c51d5db3adf58dcd466a3aee6233b58544 ]

Various notebooks with nvidia GPUs generate an ACPI_VIDEO_NOTIFY_PROBE
acpi-video event when an external device gets plugged in (and again on
modesets on that connector), the default behavior in the acpi-video
driver for this is to send a KEY_SWITCHVIDEOMODE evdev event, which
causes e.g. gnome-settings-daemon to ask us to rescan the connectors
(good), but also causes g-s-d to switch to mirror mode on a newly plugged
monitor rather then using the monitor to extend the desktop (bad)
as KEY_SWITCHVIDEOMODE is supposed to switch between extend the desktop
vs mirror mode.

More troublesome are the repeated ACPI_VIDEO_NOTIFY_PROBE events on
changing the mode on the connector, which cause g-s-d to switch
between mirror/extend mode, which causes a new ACPI_VIDEO_NOTIFY_PROBE
event and we end up with an endless loop.

This commit fixes this by adding an acpi notifier block handler to
nouveau_display.c to intercept ACPI_VIDEO_NOTIFY_PROBE and:

1) Wake-up runtime suspended GPUs and call drm_helper_hpd_irq_event()
   on them, this is necessary in some cases for the GPU to detect connector
   hotplug events while runtime suspended
2) Return NOTIFY_BAD to stop acpi-video from emitting a bogus
   KEY_SWITCHVIDEOMODE key-press event

There already is another acpi notifier block handler registered in
drivers/gpu/drm/nouveau/nvkm/engine/device/acpi.c, but that is not
suitable since that one gets unregistered on runtime suspend, and
we also want to intercept ACPI_VIDEO_NOTIFY_PROBE when runtime suspended.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 59 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/nouveau/nouveau_drv.h     |  6 ++++
 2 files changed, 65 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index afbf557b23d4..a0be029886d0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -24,6 +24,7 @@
  *
  */
 
+#include <acpi/video.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 
@@ -358,6 +359,55 @@ static struct nouveau_drm_prop_enum_list dither_depth[] = {
 	}                                                                      \
 } while(0)
 
+#ifdef CONFIG_ACPI
+
+/*
+ * Hans de Goede: This define belongs in acpi/video.h, I've submitted a patch
+ * to the acpi subsys to move it there from drivers/acpi/acpi_video.c .
+ * This should be dropped once that is merged.
+ */
+#ifndef ACPI_VIDEO_NOTIFY_PROBE
+#define ACPI_VIDEO_NOTIFY_PROBE			0x81
+#endif
+
+static void
+nouveau_display_acpi_work(struct work_struct *work)
+{
+	struct nouveau_drm *drm = container_of(work, typeof(*drm), acpi_work);
+
+	pm_runtime_get_sync(drm->dev->dev);
+
+	drm_helper_hpd_irq_event(drm->dev);
+
+	pm_runtime_mark_last_busy(drm->dev->dev);
+	pm_runtime_put_sync(drm->dev->dev);
+}
+
+static int
+nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val,
+			  void *data)
+{
+	struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb);
+	struct acpi_bus_event *info = data;
+
+	if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) {
+		if (info->type == ACPI_VIDEO_NOTIFY_PROBE) {
+			/*
+			 * This may be the only indication we receive of a
+			 * connector hotplug on a runtime suspended GPU,
+			 * schedule acpi_work to check.
+			 */
+			schedule_work(&drm->acpi_work);
+
+			/* acpi-video should not generate keypresses for this */
+			return NOTIFY_BAD;
+		}
+	}
+
+	return NOTIFY_DONE;
+}
+#endif
+
 int
 nouveau_display_init(struct drm_device *dev)
 {
@@ -537,6 +587,12 @@ nouveau_display_create(struct drm_device *dev)
 	}
 
 	nouveau_backlight_init(dev);
+#ifdef CONFIG_ACPI
+	INIT_WORK(&drm->acpi_work, nouveau_display_acpi_work);
+	drm->acpi_nb.notifier_call = nouveau_display_acpi_ntfy;
+	register_acpi_notifier(&drm->acpi_nb);
+#endif
+
 	return 0;
 
 vblank_err:
@@ -552,6 +608,9 @@ nouveau_display_destroy(struct drm_device *dev)
 {
 	struct nouveau_display *disp = nouveau_display(dev);
 
+#ifdef CONFIG_ACPI
+	unregister_acpi_notifier(&nouveau_drm(dev)->acpi_nb);
+#endif
 	nouveau_backlight_exit(dev);
 	nouveau_display_vblank_fini(dev);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 822a0212cd48..71d45324bd78 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -37,6 +37,8 @@
  *      - implemented limited ABI16/NVIF interop
  */
 
+#include <linux/notifier.h>
+
 #include <nvif/client.h>
 #include <nvif/device.h>
 #include <nvif/ioctl.h>
@@ -161,6 +163,10 @@ struct nouveau_drm {
 	struct nvbios vbios;
 	struct nouveau_display *display;
 	struct backlight_device *backlight;
+#ifdef CONFIG_ACPI
+	struct notifier_block acpi_nb;
+	struct work_struct acpi_work;
+#endif
 
 	/* power management */
 	struct nouveau_hwmon *hwmon;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (65 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 066/111] drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:57   ` Lukas Wunner
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 068/111] drm/nouveau: Handle fbcon suspend/resume in seperate worker Levin, Alexander (Sasha Levin)
                   ` (2 subsequent siblings)
  69 siblings, 1 reply; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Lyude Paul, Hans de Goede, Kilian Singer, Lukas Wunner,
	David Airlie, Levin, Alexander (Sasha Levin)

From: Lyude Paul <lyude@redhat.com>

[ Upstream commit cae9ff036eea577856d5b12860b4c79c5e71db4a ]

As it turns out, on cards that actually have CRTCs on them we're already
calling drm_kms_helper_poll_enable(drm_dev) from
nouveau_display_resume() before we call it in
nouveau_pmops_runtime_resume(). This leads us to accidentally trying to
enable polling twice, which results in a potential deadlock between the
RPM locks and drm_dev->mode_config.mutex if we end up trying to enable
polling the second time while output_poll_execute is running and holding
the mode_config lock. As such, make sure we only enable polling in
nouveau_pmops_runtime_resume() if we need to.

This fixes hangs observed on the ThinkPad W541

Signed-off-by: Lyude <lyude@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Kilian Singer <kilian.singer@quantumtechnology.info>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: David Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 3 ++-
 drivers/gpu/drm/nouveau/nouveau_drm.c     | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 3cd2b8a7e530..73c8c57b04c9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -421,7 +421,8 @@ nouveau_display_init(struct drm_device *dev)
 		return ret;
 
 	/* enable polling for external displays */
-	drm_kms_helper_poll_enable(dev);
+	if (!dev->mode_config.poll_enabled)
+		drm_kms_helper_poll_enable(dev);
 
 	/* enable hotplug interrupts */
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 3100fd88a015..8b5068ca3329 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -761,7 +761,10 @@ nouveau_pmops_runtime_resume(struct device *dev)
 	pci_set_master(pdev);
 
 	ret = nouveau_do_resume(drm_dev, true);
-	drm_kms_helper_poll_enable(drm_dev);
+
+	if (!drm_dev->mode_config.poll_enabled)
+		drm_kms_helper_poll_enable(drm_dev);
+
 	/* do magic */
 	nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 068/111] drm/nouveau: Handle fbcon suspend/resume in seperate worker
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (66 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 070/111] drm/ast: Fixed system hanged if disable P2A Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 071/111] ravb: unmap descriptors when freeing rings Levin, Alexander (Sasha Levin)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Lyude Paul, Hans de Goede, Kilian Singer, Lukas Wunner,
	David Airlie, Levin, Alexander (Sasha Levin)

From: Lyude Paul <lyude@redhat.com>

[ Upstream commit 15266ae38fe09dae07bd8812cb7a7717b1e1d992 ]

Resuming from RPM can happen while already holding
dev->mode_config.mutex. This means we can't actually handle fbcon in
any RPM resume workers, since restoring fbcon requires grabbing
dev->mode_config.mutex again. So move the fbcon suspend/resume code into
it's own worker, and rely on that instead to avoid deadlocking.

This fixes more deadlocks for runtime suspending the GPU on the ThinkPad
W541. Reproduction recipe:

 - Get a machine with both optimus and a nvidia card with connectors
   attached to it
 - Wait for the nvidia GPU to suspend
 - Attempt to manually reprobe any of the connectors on the nvidia GPU
   using sysfs
 - *deadlock*

[airlied: use READ_ONCE to address Hans's comment]

Signed-off-by: Lyude <lyude@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Kilian Singer <kilian.singer@quantumtechnology.info>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: David Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/nouveau/nouveau_drv.h   |  2 ++
 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 43 ++++++++++++++++++++++++++-------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 0c17ca1f5757..1e7f1e326b3c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -164,6 +164,8 @@ struct nouveau_drm {
 	struct nouveau_display *display;
 	struct backlight_device *backlight;
 	struct work_struct hpd_work;
+	struct work_struct fbcon_work;
+	int fbcon_new_state;
 #ifdef CONFIG_ACPI
 	struct notifier_block acpi_nb;
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 9f5692726c16..2b79e27dd89c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -491,19 +491,43 @@ static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
 	.fb_probe = nouveau_fbcon_create,
 };
 
+static void
+nouveau_fbcon_set_suspend_work(struct work_struct *work)
+{
+	struct nouveau_drm *drm = container_of(work, typeof(*drm), fbcon_work);
+	int state = READ_ONCE(drm->fbcon_new_state);
+
+	if (state == FBINFO_STATE_RUNNING)
+		pm_runtime_get_sync(drm->dev->dev);
+
+	console_lock();
+	if (state == FBINFO_STATE_RUNNING)
+		nouveau_fbcon_accel_restore(drm->dev);
+	drm_fb_helper_set_suspend(&drm->fbcon->helper, state);
+	if (state != FBINFO_STATE_RUNNING)
+		nouveau_fbcon_accel_save_disable(drm->dev);
+	console_unlock();
+
+	if (state == FBINFO_STATE_RUNNING) {
+		pm_runtime_mark_last_busy(drm->dev->dev);
+		pm_runtime_put_sync(drm->dev->dev);
+	}
+}
+
 void
 nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
 {
 	struct nouveau_drm *drm = nouveau_drm(dev);
-	if (drm->fbcon) {
-		console_lock();
-		if (state == FBINFO_STATE_RUNNING)
-			nouveau_fbcon_accel_restore(dev);
-		drm_fb_helper_set_suspend(&drm->fbcon->helper, state);
-		if (state != FBINFO_STATE_RUNNING)
-			nouveau_fbcon_accel_save_disable(dev);
-		console_unlock();
-	}
+
+	if (!drm->fbcon)
+		return;
+
+	drm->fbcon_new_state = state;
+	/* Since runtime resume can happen as a result of a sysfs operation,
+	 * it's possible we already have the console locked. So handle fbcon
+	 * init/deinit from a seperate work thread
+	 */
+	schedule_work(&drm->fbcon_work);
 }
 
 int
@@ -524,6 +548,7 @@ nouveau_fbcon_init(struct drm_device *dev)
 
 	fbcon->dev = dev;
 	drm->fbcon = fbcon;
+	INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work);
 
 	drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 070/111] drm/ast: Fixed system hanged if disable P2A
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (67 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 068/111] drm/nouveau: Handle fbcon suspend/resume in seperate worker Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 071/111] ravb: unmap descriptors when freeing rings Levin, Alexander (Sasha Levin)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable; +Cc: Y.C. Chen, Dave Airlie, Levin, Alexander (Sasha Levin)

From: "Y.C. Chen" <yc_chen@aspeedtech.com>

[ Upstream commit 6c971c09f38704513c426ba6515f22fb3d6c87d5 ]

The original ast driver will access some BMC configuration through P2A bridge
that can be disabled since AST2300 and after.
It will cause system hanged if P2A bridge is disabled.
Here is the update to fix it.

Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/gpu/drm/ast/ast_drv.h  |   1 +
 drivers/gpu/drm/ast/ast_main.c | 157 ++++++++++++++++++++++-------------------
 drivers/gpu/drm/ast/ast_post.c |  18 +++--
 3 files changed, 97 insertions(+), 79 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 908011d2c8f5..7abda94fc2cf 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -113,6 +113,7 @@ struct ast_private {
 	struct ttm_bo_kmap_obj cache_kmap;
 	int next_cursor;
 	bool support_wide_screen;
+	bool DisableP2A;
 
 	enum ast_tx_chip tx_chip_type;
 	u8 dp501_maxclk;
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index f75c6421db62..533e762d036d 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
 	} else
 		*need_post = false;
 
+	/* Check P2A Access */
+	ast->DisableP2A = true;
+	data = ast_read32(ast, 0xf004);
+	if (data != 0xFFFFFFFF)
+		ast->DisableP2A = false;
+
 	/* Check if we support wide screen */
 	switch (ast->chip) {
 	case AST1180:
@@ -140,15 +146,17 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
 			ast->support_wide_screen = true;
 		else {
 			ast->support_wide_screen = false;
-			/* Read SCU7c (silicon revision register) */
-			ast_write32(ast, 0xf004, 0x1e6e0000);
-			ast_write32(ast, 0xf000, 0x1);
-			data = ast_read32(ast, 0x1207c);
-			data &= 0x300;
-			if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
-				ast->support_wide_screen = true;
-			if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
-				ast->support_wide_screen = true;
+			if (ast->DisableP2A == false) {
+				/* Read SCU7c (silicon revision register) */
+				ast_write32(ast, 0xf004, 0x1e6e0000);
+				ast_write32(ast, 0xf000, 0x1);
+				data = ast_read32(ast, 0x1207c);
+				data &= 0x300;
+				if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
+					ast->support_wide_screen = true;
+				if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
+					ast->support_wide_screen = true;
+			}
 		}
 		break;
 	}
@@ -216,80 +224,81 @@ static int ast_get_dram_info(struct drm_device *dev)
 	uint32_t data, data2;
 	uint32_t denum, num, div, ref_pll;
 
-	ast_write32(ast, 0xf004, 0x1e6e0000);
-	ast_write32(ast, 0xf000, 0x1);
-
-
-	ast_write32(ast, 0x10000, 0xfc600309);
-
-	do {
-		if (pci_channel_offline(dev->pdev))
-			return -EIO;
-	} while (ast_read32(ast, 0x10000) != 0x01);
-	data = ast_read32(ast, 0x10004);
-
-	if (data & 0x40)
+	if (ast->DisableP2A)
+	{
 		ast->dram_bus_width = 16;
+		ast->dram_type = AST_DRAM_1Gx16;
+		ast->mclk = 396;
+	}
 	else
-		ast->dram_bus_width = 32;
+	{
+		ast_write32(ast, 0xf004, 0x1e6e0000);
+		ast_write32(ast, 0xf000, 0x1);
+		data = ast_read32(ast, 0x10004);
+
+		if (data & 0x40)
+			ast->dram_bus_width = 16;
+		else
+			ast->dram_bus_width = 32;
+
+		if (ast->chip == AST2300 || ast->chip == AST2400) {
+			switch (data & 0x03) {
+			case 0:
+				ast->dram_type = AST_DRAM_512Mx16;
+				break;
+			default:
+			case 1:
+				ast->dram_type = AST_DRAM_1Gx16;
+				break;
+			case 2:
+				ast->dram_type = AST_DRAM_2Gx16;
+				break;
+			case 3:
+				ast->dram_type = AST_DRAM_4Gx16;
+				break;
+			}
+		} else {
+			switch (data & 0x0c) {
+			case 0:
+			case 4:
+				ast->dram_type = AST_DRAM_512Mx16;
+				break;
+			case 8:
+				if (data & 0x40)
+					ast->dram_type = AST_DRAM_1Gx16;
+				else
+					ast->dram_type = AST_DRAM_512Mx32;
+				break;
+			case 0xc:
+				ast->dram_type = AST_DRAM_1Gx32;
+				break;
+			}
+		}
 
-	if (ast->chip == AST2300 || ast->chip == AST2400) {
-		switch (data & 0x03) {
-		case 0:
-			ast->dram_type = AST_DRAM_512Mx16;
-			break;
-		default:
-		case 1:
-			ast->dram_type = AST_DRAM_1Gx16;
-			break;
-		case 2:
-			ast->dram_type = AST_DRAM_2Gx16;
-			break;
+		data = ast_read32(ast, 0x10120);
+		data2 = ast_read32(ast, 0x10170);
+		if (data2 & 0x2000)
+			ref_pll = 14318;
+		else
+			ref_pll = 12000;
+
+		denum = data & 0x1f;
+		num = (data & 0x3fe0) >> 5;
+		data = (data & 0xc000) >> 14;
+		switch (data) {
 		case 3:
-			ast->dram_type = AST_DRAM_4Gx16;
-			break;
-		}
-	} else {
-		switch (data & 0x0c) {
-		case 0:
-		case 4:
-			ast->dram_type = AST_DRAM_512Mx16;
+			div = 0x4;
 			break;
-		case 8:
-			if (data & 0x40)
-				ast->dram_type = AST_DRAM_1Gx16;
-			else
-				ast->dram_type = AST_DRAM_512Mx32;
+		case 2:
+		case 1:
+			div = 0x2;
 			break;
-		case 0xc:
-			ast->dram_type = AST_DRAM_1Gx32;
+		default:
+			div = 0x1;
 			break;
 		}
+		ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
 	}
-
-	data = ast_read32(ast, 0x10120);
-	data2 = ast_read32(ast, 0x10170);
-	if (data2 & 0x2000)
-		ref_pll = 14318;
-	else
-		ref_pll = 12000;
-
-	denum = data & 0x1f;
-	num = (data & 0x3fe0) >> 5;
-	data = (data & 0xc000) >> 14;
-	switch (data) {
-	case 3:
-		div = 0x4;
-		break;
-	case 2:
-	case 1:
-		div = 0x2;
-		break;
-	default:
-		div = 0x1;
-		break;
-	}
-	ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 30672a3df8a9..270e8fb2803f 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -375,12 +375,20 @@ void ast_post_gpu(struct drm_device *dev)
 	ast_enable_mmio(dev);
 	ast_set_def_ext_reg(dev);
 
-	if (ast->chip == AST2300 || ast->chip == AST2400)
-		ast_init_dram_2300(dev);
-	else
-		ast_init_dram_reg(dev);
+	if (ast->DisableP2A == false)
+	{
+		if (ast->chip == AST2300 || ast->chip == AST2400)
+			ast_init_dram_2300(dev);
+		else
+			ast_init_dram_reg(dev);
 
-	ast_init_3rdtx(dev);
+		ast_init_3rdtx(dev);
+	}
+	else
+	{
+		if (ast->tx_chip_type != AST_TX_NONE)
+			ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x80);	/* Enable DVO */
+	}
 }
 
 /* AST 2300 DRAM settings */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH for v4.9 LTS 071/111] ravb: unmap descriptors when freeing rings
  2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
                   ` (68 preceding siblings ...)
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 070/111] drm/ast: Fixed system hanged if disable P2A Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:12 ` Levin, Alexander (Sasha Levin)
  69 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-04  8:12 UTC (permalink / raw)
  To: stable
  Cc: Kazuya Mizuguchi, Simon Horman, David S . Miller, Levin,
	Alexander (Sasha Levin)

From: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>

[ Upstream commit a47b70ea86bdeb3091341f5ae3ef580f1a1ad822 ]

"swiotlb buffer is full" errors occur after repeated initialisation of a
device - f.e. suspend/resume or ip link set up/down. This is because memory
mapped using dma_map_single() in ravb_ring_format() and ravb_start_xmit()
is not released.  Resolve this problem by unmapping descriptors when
freeing rings.

Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
[simon: reworked]
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 112 ++++++++++++++++++-------------
 1 file changed, 64 insertions(+), 48 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 862f18ed6022..510ff62584d6 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -179,6 +179,49 @@ static struct mdiobb_ops bb_ops = {
 	.get_mdio_data = ravb_get_mdio_data,
 };
 
+/* Free TX skb function for AVB-IP */
+static int ravb_tx_free(struct net_device *ndev, int q, bool free_txed_only)
+{
+	struct ravb_private *priv = netdev_priv(ndev);
+	struct net_device_stats *stats = &priv->stats[q];
+	struct ravb_tx_desc *desc;
+	int free_num = 0;
+	int entry;
+	u32 size;
+
+	for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
+		bool txed;
+
+		entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] *
+					     NUM_TX_DESC);
+		desc = &priv->tx_ring[q][entry];
+		txed = desc->die_dt == DT_FEMPTY;
+		if (free_txed_only && !txed)
+			break;
+		/* Descriptor type must be checked before all other reads */
+		dma_rmb();
+		size = le16_to_cpu(desc->ds_tagl) & TX_DS;
+		/* Free the original skb. */
+		if (priv->tx_skb[q][entry / NUM_TX_DESC]) {
+			dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
+					 size, DMA_TO_DEVICE);
+			/* Last packet descriptor? */
+			if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) {
+				entry /= NUM_TX_DESC;
+				dev_kfree_skb_any(priv->tx_skb[q][entry]);
+				priv->tx_skb[q][entry] = NULL;
+				if (txed)
+					stats->tx_packets++;
+			}
+			free_num++;
+		}
+		if (txed)
+			stats->tx_bytes += size;
+		desc->die_dt = DT_EEMPTY;
+	}
+	return free_num;
+}
+
 /* Free skb's and DMA buffers for Ethernet AVB */
 static void ravb_ring_free(struct net_device *ndev, int q)
 {
@@ -194,19 +237,21 @@ static void ravb_ring_free(struct net_device *ndev, int q)
 	kfree(priv->rx_skb[q]);
 	priv->rx_skb[q] = NULL;
 
-	/* Free TX skb ringbuffer */
-	if (priv->tx_skb[q]) {
-		for (i = 0; i < priv->num_tx_ring[q]; i++)
-			dev_kfree_skb(priv->tx_skb[q][i]);
-	}
-	kfree(priv->tx_skb[q]);
-	priv->tx_skb[q] = NULL;
-
 	/* Free aligned TX buffers */
 	kfree(priv->tx_align[q]);
 	priv->tx_align[q] = NULL;
 
 	if (priv->rx_ring[q]) {
+		for (i = 0; i < priv->num_rx_ring[q]; i++) {
+			struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
+
+			if (!dma_mapping_error(ndev->dev.parent,
+					       le32_to_cpu(desc->dptr)))
+				dma_unmap_single(ndev->dev.parent,
+						 le32_to_cpu(desc->dptr),
+						 PKT_BUF_SZ,
+						 DMA_FROM_DEVICE);
+		}
 		ring_size = sizeof(struct ravb_ex_rx_desc) *
 			    (priv->num_rx_ring[q] + 1);
 		dma_free_coherent(ndev->dev.parent, ring_size, priv->rx_ring[q],
@@ -215,12 +260,20 @@ static void ravb_ring_free(struct net_device *ndev, int q)
 	}
 
 	if (priv->tx_ring[q]) {
+		ravb_tx_free(ndev, q, false);
+
 		ring_size = sizeof(struct ravb_tx_desc) *
 			    (priv->num_tx_ring[q] * NUM_TX_DESC + 1);
 		dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q],
 				  priv->tx_desc_dma[q]);
 		priv->tx_ring[q] = NULL;
 	}
+
+	/* Free TX skb ringbuffer.
+	 * SKBs are freed by ravb_tx_free() call above.
+	 */
+	kfree(priv->tx_skb[q]);
+	priv->tx_skb[q] = NULL;
 }
 
 /* Format skb and descriptor buffer for Ethernet AVB */
@@ -431,44 +484,6 @@ static int ravb_dmac_init(struct net_device *ndev)
 	return 0;
 }
 
-/* Free TX skb function for AVB-IP */
-static int ravb_tx_free(struct net_device *ndev, int q)
-{
-	struct ravb_private *priv = netdev_priv(ndev);
-	struct net_device_stats *stats = &priv->stats[q];
-	struct ravb_tx_desc *desc;
-	int free_num = 0;
-	int entry;
-	u32 size;
-
-	for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
-		entry = priv->dirty_tx[q] % (priv->num_tx_ring[q] *
-					     NUM_TX_DESC);
-		desc = &priv->tx_ring[q][entry];
-		if (desc->die_dt != DT_FEMPTY)
-			break;
-		/* Descriptor type must be checked before all other reads */
-		dma_rmb();
-		size = le16_to_cpu(desc->ds_tagl) & TX_DS;
-		/* Free the original skb. */
-		if (priv->tx_skb[q][entry / NUM_TX_DESC]) {
-			dma_unmap_single(ndev->dev.parent, le32_to_cpu(desc->dptr),
-					 size, DMA_TO_DEVICE);
-			/* Last packet descriptor? */
-			if (entry % NUM_TX_DESC == NUM_TX_DESC - 1) {
-				entry /= NUM_TX_DESC;
-				dev_kfree_skb_any(priv->tx_skb[q][entry]);
-				priv->tx_skb[q][entry] = NULL;
-				stats->tx_packets++;
-			}
-			free_num++;
-		}
-		stats->tx_bytes += size;
-		desc->die_dt = DT_EEMPTY;
-	}
-	return free_num;
-}
-
 static void ravb_get_tx_tstamp(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
@@ -902,7 +917,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
 			spin_lock_irqsave(&priv->lock, flags);
 			/* Clear TX interrupt */
 			ravb_write(ndev, ~mask, TIS);
-			ravb_tx_free(ndev, q);
+			ravb_tx_free(ndev, q, true);
 			netif_wake_subqueue(ndev, q);
 			mmiowb();
 			spin_unlock_irqrestore(&priv->lock, flags);
@@ -1571,7 +1586,8 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 
 	priv->cur_tx[q] += NUM_TX_DESC;
 	if (priv->cur_tx[q] - priv->dirty_tx[q] >
-	    (priv->num_tx_ring[q] - 1) * NUM_TX_DESC && !ravb_tx_free(ndev, q))
+	    (priv->num_tx_ring[q] - 1) * NUM_TX_DESC &&
+	    !ravb_tx_free(ndev, q, true))
 		netif_stop_subqueue(ndev, q);
 
 exit:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume Levin, Alexander (Sasha Levin)
@ 2017-06-04  8:57   ` Lukas Wunner
  2017-06-05 12:23     ` Levin, Alexander (Sasha Levin)
  2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  0 siblings, 2 replies; 86+ messages in thread
From: Lukas Wunner @ 2017-06-04  8:57 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin)
  Cc: stable, Lyude Paul, Hans de Goede, Kilian Singer, David Airlie,
	Peter Ujfalusi

[cc += Peter Ujfalusi]

On Sun, Jun 04, 2017 at 08:12:31AM +0000, Levin, Alexander (Sasha Levin) wrote:
> From: Lyude Paul <lyude@redhat.com>
> 
> [ Upstream commit cae9ff036eea577856d5b12860b4c79c5e71db4a ]

There's a fix for the above-quoted commit which landed in v4.12-rc2
and may be worth applying on top:

    commit 9a2eba337cacefc95b97c2726e3efdd435b3460e
    Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
    Date:   Mon May 15 12:04:31 2017 +0300

    drm/nouveau: Fix drm poll_helper handling

Thanks,

Lukas

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver Levin, Alexander (Sasha Levin)
@ 2017-06-04 17:17   ` Florian Fainelli
  2017-06-05 12:15     ` Levin, Alexander (Sasha Levin)
  0 siblings, 1 reply; 86+ messages in thread
From: Florian Fainelli @ 2017-06-04 17:17 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin), stable; +Cc: Mao Wenan, David S . Miller

Hi Alex,

On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
> From: Mao Wenan <maowenan@huawei.com>
> 
> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
> 
> There is currently no reference count being held on the PHY driver,
> which makes it possible to remove the PHY driver module while the PHY
> state machine is running and polling the PHY. This could cause crashes
> similar to this one to show up:
> 
> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
> [   43.361162] IP: phy_state_machine+0x32/0x490
> [   43.361162] PGD 59dc067
> [   43.361162] PUD 0
> [   43.361162]
> [   43.361162] Oops: 0000 [#1] SMP
> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
> [   43.361162] Workqueue: events_power_efficient phy_state_machine
> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
> ffff880006a15c60
> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
> ffff8800059e5428
> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
> 0000000000000000
> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
> ffff8800059e5428
> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
> ffff880006a15c40
> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
> knlGS:0000000000000000
> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
> 00000000000006f0
> [   43.361162] Call Trace:
> [   43.361162]  process_one_work+0x1b4/0x3e0
> [   43.361162]  worker_thread+0x43/0x4d0
> [   43.361162]  ? __schedule+0x17f/0x4e0
> [   43.361162]  kthread+0xf7/0x130
> [   43.361162]  ? process_one_work+0x3e0/0x3e0
> [   43.361162]  ? kthread_create_on_node+0x40/0x40
> [   43.361162]  ret_from_fork+0x29/0x40
> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
> 
> Keep references on the PHY driver module right before we are going to
> utilize it in phy_attach_direct(), and conversely when we don't use it
> anymore in phy_detach().
> 
> Signed-off-by: Mao Wenan <maowenan@huawei.com>
> [florian: rebase, rework commit message]
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>

This commit alone will cause problems, you will also need to pick this
one on top of it:

6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
checks and NULL deref in phy_attach_direct()")

Thanks!

> ---
>  drivers/net/phy/phy_device.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index c4ceb082e970..67571f9627e5 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -872,6 +872,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  		return -EIO;
>  	}
>  
> +	if (!try_module_get(d->driver->owner)) {
> +		dev_err(&dev->dev, "failed to get the device driver module\n");
> +		return -EIO;
> +	}
> +
>  	get_device(d);
>  
>  	/* Assume that if there is no driver, that it doesn't
> @@ -927,6 +932,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  
>  error:
>  	put_device(d);
> +	module_put(d->driver->owner);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  	return err;
> @@ -1007,6 +1013,7 @@ void phy_detach(struct phy_device *phydev)
>  	bus = phydev->mdio.bus;
>  
>  	put_device(&phydev->mdio.dev);
> +	module_put(phydev->mdio.dev.driver->owner);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  }
> 

-- 
Florian

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage Levin, Alexander (Sasha Levin)
@ 2017-06-04 20:45   ` Jerome Brunet
  2017-06-05 12:20     ` Levin, Alexander (Sasha Levin)
  2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  0 siblings, 2 replies; 86+ messages in thread
From: Jerome Brunet @ 2017-06-04 20:45 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin), stable; +Cc: Kevin Hilman, Arnd Bergmann

On Sun, 2017-06-04 at 08:12 +0000, Levin, Alexander (Sasha Levin) wrote:
> From: Jerome Brunet <jbrunet@baylibre.com>
> 
> [ Upstream commit feb3cbea0946c67060e2d5bcb7499b0a6f6700fe ]
> 
> OdroidC2 GbE link breaks under heavy tx transfer. This happens even if the
> MAC does not enable Energy Efficient Ethernet (No Low Power state Idle on
> the Tx path). The problem seems to come from the phy Rx path, entering the
> LPI state.
> 
> Disabling EEE advertisement on the phy prevent this feature to be
> negociated with the link partner and solve the issue.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>

Alexander,

unfortunately, this dt change alone won't fix the problem. The code related to
eee-broken-**** has been merged into mainline around the same time as this
particular change.

For this flag to actually do something you'll need the following commits:

d853d145ea3e63387a2ac759aa41d5e43876e561
1fc31357ad194fb98691f3d122bcd47e59239e83
3bb9ab63276696988d8224f52db20e87194deb4b
57f3986231bb2c69a55ccab1d2b30a00818027ac
308d3165d8b2b98d3dc3d97d6662062735daea67

Cheers

Jerome

> ---
>  arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
> b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
> index e6e3491d48a5..f150a4c63efe 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
> +++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
> @@ -85,6 +85,18 @@
>  	status = "okay";
>  	pinctrl-0 = <&eth_pins>;
>  	pinctrl-names = "default";
> +	phy-handle = <&eth_phy0>;
> +
> +	mdio {
> +		compatible = "snps,dwmac-mdio";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		eth_phy0: ethernet-phy@0 {
> +			reg = <0>;
> +			eee-broken-1000t;
> +		};
> +	};
>  };
>  
>  &ir {

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags
  2017-06-04  8:12 ` [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags Levin, Alexander (Sasha Levin)
@ 2017-06-04 22:42   ` Hugh Dickins
  2017-06-05 12:00     ` Levin, Alexander (Sasha Levin)
  0 siblings, 1 reply; 86+ messages in thread
From: Hugh Dickins @ 2017-06-04 22:42 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin)
  Cc: stable, Hugh Dickins, Andrew Morton, Nicholas Piggin,
	Wu Fengguang, Linus Torvalds

On Sun, 4 Jun 2017, Levin, Alexander (Sasha Levin) wrote:

> From: Hugh Dickins <hughd@google.com>
> 
> [ Upstream commit b6789123bccba8b5feb9901ed2e8c3c39181979d ]
> 
> Commit 6326fec1122c ("mm: Use owner_priv bit for PageSwapCache, valid
> when PageSwapBacked") aliased PG_swapcache to PG_owner_priv_1 (and
> depending on PageSwapBacked being true).
> 
> As a result, the KPF_SWAPCACHE bit in '/proc/kpageflags' should now be
> synthesized, instead of being shown on unrelated pages which just happen
> to have PG_owner_priv_1 set.

I think this does not belong in v4.9 LTS - though it would only be
puzzling, not harmful there.  It's a fix to an earlier v4.10 commit,
and I wouldn't expect that earlier v4.10 commit to be added to v4.9 LTS
(but perhaps my expectation is wrong - I'm not in stable@vger.kernel.org,
so wouldn't see all 111 of these mails).

Hugh

> 
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Wu Fengguang <fengguang.wu@intel.com>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> ---
>  fs/proc/page.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/proc/page.c b/fs/proc/page.c
> index 3ecd445e830d..8ffd43709634 100644
> --- a/fs/proc/page.c
> +++ b/fs/proc/page.c
> @@ -173,7 +173,8 @@ u64 stable_page_flags(struct page *page)
>  	u |= kpf_copy_bit(k, KPF_ACTIVE,	PG_active);
>  	u |= kpf_copy_bit(k, KPF_RECLAIM,	PG_reclaim);
>  
> -	u |= kpf_copy_bit(k, KPF_SWAPCACHE,	PG_swapcache);
> +	if (PageSwapCache(page))
> +		u |= 1 << KPF_SWAPCACHE;
>  	u |= kpf_copy_bit(k, KPF_SWAPBACKED,	PG_swapbacked);
>  
>  	u |= kpf_copy_bit(k, KPF_UNEVICTABLE,	PG_unevictable);
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags
  2017-06-04 22:42   ` Hugh Dickins
@ 2017-06-05 12:00     ` Levin, Alexander (Sasha Levin)
  0 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-05 12:00 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: stable, Andrew Morton, Nicholas Piggin, Wu Fengguang, Linus Torvalds

On Sun, Jun 04, 2017 at 03:42:35PM -0700, Hugh Dickins wrote:
> On Sun, 4 Jun 2017, Levin, Alexander (Sasha Levin) wrote:
> 
> > From: Hugh Dickins <hughd@google.com>
> > 
> > [ Upstream commit b6789123bccba8b5feb9901ed2e8c3c39181979d ]
> > 
> > Commit 6326fec1122c ("mm: Use owner_priv bit for PageSwapCache, valid
> > when PageSwapBacked") aliased PG_swapcache to PG_owner_priv_1 (and
> > depending on PageSwapBacked being true).
> > 
> > As a result, the KPF_SWAPCACHE bit in '/proc/kpageflags' should now be
> > synthesized, instead of being shown on unrelated pages which just happen
> > to have PG_owner_priv_1 set.
> 
> I think this does not belong in v4.9 LTS - though it would only be
> puzzling, not harmful there.  It's a fix to an earlier v4.10 commit,
> and I wouldn't expect that earlier v4.10 commit to be added to v4.9 LTS
> (but perhaps my expectation is wrong - I'm not in stable@vger.kernel.org,
> so wouldn't see all 111 of these mails).

Nope, it's actually not. I'll pull this commit out, thanks!

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-04 17:17   ` Florian Fainelli
@ 2017-06-05 12:15     ` Levin, Alexander (Sasha Levin)
  2017-06-05 16:56       ` Florian Fainelli
  0 siblings, 1 reply; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-05 12:15 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: stable, Mao Wenan, David S . Miller

On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
> Hi Alex,
> 
> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
> > From: Mao Wenan <maowenan@huawei.com>
> > 
> > [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
> > 
> > There is currently no reference count being held on the PHY driver,
> > which makes it possible to remove the PHY driver module while the PHY
> > state machine is running and polling the PHY. This could cause crashes
> > similar to this one to show up:
> > 
> > [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
> > [   43.361162] IP: phy_state_machine+0x32/0x490
> > [   43.361162] PGD 59dc067
> > [   43.361162] PUD 0
> > [   43.361162]
> > [   43.361162] Oops: 0000 [#1] SMP
> > [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
> > [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
> > [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> > BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
> > [   43.361162] Workqueue: events_power_efficient phy_state_machine
> > [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
> > [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
> > [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
> > [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
> > ffff880006a15c60
> > [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
> > ffff8800059e5428
> > [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
> > 0000000000000000
> > [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
> > ffff8800059e5428
> > [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
> > ffff880006a15c40
> > [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
> > knlGS:0000000000000000
> > [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
> > 00000000000006f0
> > [   43.361162] Call Trace:
> > [   43.361162]  process_one_work+0x1b4/0x3e0
> > [   43.361162]  worker_thread+0x43/0x4d0
> > [   43.361162]  ? __schedule+0x17f/0x4e0
> > [   43.361162]  kthread+0xf7/0x130
> > [   43.361162]  ? process_one_work+0x3e0/0x3e0
> > [   43.361162]  ? kthread_create_on_node+0x40/0x40
> > [   43.361162]  ret_from_fork+0x29/0x40
> > [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
> > 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
> > 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
> > 
> > Keep references on the PHY driver module right before we are going to
> > utilize it in phy_attach_direct(), and conversely when we don't use it
> > anymore in phy_detach().
> > 
> > Signed-off-by: Mao Wenan <maowenan@huawei.com>
> > [florian: rebase, rework commit message]
> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> > Signed-off-by: David S. Miller <davem@davemloft.net>
> > 
> > Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> 
> This commit alone will cause problems, you will also need to pick this
> one on top of it:
> 
> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
> checks and NULL deref in phy_attach_direct()")

Should I also be grabbing a7dac9f9c1
("phy: fix error case of phy_led_triggers_(un)register")?

It says it fixes a commit that's not in -stable, but it looks like it's
still relevant even without that commit.

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage
  2017-06-04 20:45   ` Jerome Brunet
@ 2017-06-05 12:20     ` Levin, Alexander (Sasha Levin)
  2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  1 sibling, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-05 12:20 UTC (permalink / raw)
  To: Jerome Brunet; +Cc: stable, Kevin Hilman, Arnd Bergmann

On Sun, Jun 04, 2017 at 10:45:49PM +0200, Jerome Brunet wrote:
> On Sun, 2017-06-04 at 08:12 +0000, Levin, Alexander (Sasha Levin) wrote:
> > From: Jerome Brunet <jbrunet@baylibre.com>
> > 
> > [ Upstream commit feb3cbea0946c67060e2d5bcb7499b0a6f6700fe ]
> > 
> > OdroidC2 GbE link breaks under heavy tx transfer. This happens even if the
> > MAC does not enable Energy Efficient Ethernet (No Low Power state Idle on
> > the Tx path). The problem seems to come from the phy Rx path, entering the
> > LPI state.
> > 
> > Disabling EEE advertisement on the phy prevent this feature to be
> > negociated with the link partner and solve the issue.
> > 
> > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> > Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> 
> Alexander,
> 
> unfortunately, this dt change alone won't fix the problem. The code related to
> eee-broken-**** has been merged into mainline around the same time as this
> particular change.
> 
> For this flag to actually do something you'll need the following commits:
> 
> d853d145ea3e63387a2ac759aa41d5e43876e561
> 1fc31357ad194fb98691f3d122bcd47e59239e83
> 3bb9ab63276696988d8224f52db20e87194deb4b
> 57f3986231bb2c69a55ccab1d2b30a00818027ac
> 308d3165d8b2b98d3dc3d97d6662062735daea67

Added these too, thanks Jerome!

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume
  2017-06-04  8:57   ` Lukas Wunner
@ 2017-06-05 12:23     ` Levin, Alexander (Sasha Levin)
  2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  1 sibling, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-05 12:23 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: stable, Lyude Paul, Hans de Goede, Kilian Singer, David Airlie,
	Peter Ujfalusi

On Sun, Jun 04, 2017 at 10:57:44AM +0200, Lukas Wunner wrote:
> [cc += Peter Ujfalusi]
> 
> On Sun, Jun 04, 2017 at 08:12:31AM +0000, Levin, Alexander (Sasha Levin) wrote:
> > From: Lyude Paul <lyude@redhat.com>
> > 
> > [ Upstream commit cae9ff036eea577856d5b12860b4c79c5e71db4a ]
> 
> There's a fix for the above-quoted commit which landed in v4.12-rc2
> and may be worth applying on top:
> 
>     commit 9a2eba337cacefc95b97c2726e3efdd435b3460e
>     Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
>     Date:   Mon May 15 12:04:31 2017 +0300
> 
>     drm/nouveau: Fix drm poll_helper handling

Added it too, thanks Lukas!

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-05 12:15     ` Levin, Alexander (Sasha Levin)
@ 2017-06-05 16:56       ` Florian Fainelli
  2017-06-05 19:58         ` Levin, Alexander (Sasha Levin)
  0 siblings, 1 reply; 86+ messages in thread
From: Florian Fainelli @ 2017-06-05 16:56 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin); +Cc: stable, Mao Wenan, David S . Miller

On 06/05/2017 05:15 AM, Levin, Alexander (Sasha Levin) wrote:
> On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
>> Hi Alex,
>>
>> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
>>> From: Mao Wenan <maowenan@huawei.com>
>>>
>>> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
>>>
>>> There is currently no reference count being held on the PHY driver,
>>> which makes it possible to remove the PHY driver module while the PHY
>>> state machine is running and polling the PHY. This could cause crashes
>>> similar to this one to show up:
>>>
>>> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
>>> [   43.361162] IP: phy_state_machine+0x32/0x490
>>> [   43.361162] PGD 59dc067
>>> [   43.361162] PUD 0
>>> [   43.361162]
>>> [   43.361162] Oops: 0000 [#1] SMP
>>> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
>>> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
>>> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
>>> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
>>> [   43.361162] Workqueue: events_power_efficient phy_state_machine
>>> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
>>> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
>>> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
>>> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
>>> ffff880006a15c60
>>> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
>>> ffff8800059e5428
>>> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
>>> 0000000000000000
>>> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
>>> ffff8800059e5428
>>> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
>>> ffff880006a15c40
>>> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
>>> knlGS:0000000000000000
>>> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
>>> 00000000000006f0
>>> [   43.361162] Call Trace:
>>> [   43.361162]  process_one_work+0x1b4/0x3e0
>>> [   43.361162]  worker_thread+0x43/0x4d0
>>> [   43.361162]  ? __schedule+0x17f/0x4e0
>>> [   43.361162]  kthread+0xf7/0x130
>>> [   43.361162]  ? process_one_work+0x3e0/0x3e0
>>> [   43.361162]  ? kthread_create_on_node+0x40/0x40
>>> [   43.361162]  ret_from_fork+0x29/0x40
>>> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
>>> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
>>> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
>>>
>>> Keep references on the PHY driver module right before we are going to
>>> utilize it in phy_attach_direct(), and conversely when we don't use it
>>> anymore in phy_detach().
>>>
>>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
>>> [florian: rebase, rework commit message]
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>>
>>> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
>>
>> This commit alone will cause problems, you will also need to pick this
>> one on top of it:
>>
>> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
>> checks and NULL deref in phy_attach_direct()")
> 
> Should I also be grabbing a7dac9f9c1
> ("phy: fix error case of phy_led_triggers_(un)register")?
> 
> It says it fixes a commit that's not in -stable, but it looks like it's
> still relevant even without that commit.

No, you don't have to pick this one, it does indeed fix something that
was only introduced in 4.10 and newer.

Thanks!
-- 
Florian

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-05 16:56       ` Florian Fainelli
@ 2017-06-05 19:58         ` Levin, Alexander (Sasha Levin)
  2017-06-05 22:21           ` Florian Fainelli
  2017-06-06  0:33           ` Florian Fainelli
  0 siblings, 2 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-05 19:58 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: stable, Mao Wenan, David S . Miller

On Mon, Jun 05, 2017 at 09:56:18AM -0700, Florian Fainelli wrote:
> On 06/05/2017 05:15 AM, Levin, Alexander (Sasha Levin) wrote:
> > On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
> >> Hi Alex,
> >>
> >> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
> >>> From: Mao Wenan <maowenan@huawei.com>
> >>>
> >>> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
> >>>
> >>> There is currently no reference count being held on the PHY driver,
> >>> which makes it possible to remove the PHY driver module while the PHY
> >>> state machine is running and polling the PHY. This could cause crashes
> >>> similar to this one to show up:
> >>>
> >>> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
> >>> [   43.361162] IP: phy_state_machine+0x32/0x490
> >>> [   43.361162] PGD 59dc067
> >>> [   43.361162] PUD 0
> >>> [   43.361162]
> >>> [   43.361162] Oops: 0000 [#1] SMP
> >>> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
> >>> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
> >>> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> >>> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
> >>> [   43.361162] Workqueue: events_power_efficient phy_state_machine
> >>> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
> >>> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
> >>> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
> >>> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
> >>> ffff880006a15c60
> >>> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
> >>> ffff8800059e5428
> >>> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
> >>> 0000000000000000
> >>> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
> >>> ffff8800059e5428
> >>> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
> >>> ffff880006a15c40
> >>> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
> >>> knlGS:0000000000000000
> >>> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> >>> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
> >>> 00000000000006f0
> >>> [   43.361162] Call Trace:
> >>> [   43.361162]  process_one_work+0x1b4/0x3e0
> >>> [   43.361162]  worker_thread+0x43/0x4d0
> >>> [   43.361162]  ? __schedule+0x17f/0x4e0
> >>> [   43.361162]  kthread+0xf7/0x130
> >>> [   43.361162]  ? process_one_work+0x3e0/0x3e0
> >>> [   43.361162]  ? kthread_create_on_node+0x40/0x40
> >>> [   43.361162]  ret_from_fork+0x29/0x40
> >>> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
> >>> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
> >>> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
> >>>
> >>> Keep references on the PHY driver module right before we are going to
> >>> utilize it in phy_attach_direct(), and conversely when we don't use it
> >>> anymore in phy_detach().
> >>>
> >>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
> >>> [florian: rebase, rework commit message]
> >>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> >>> Signed-off-by: David S. Miller <davem@davemloft.net>
> >>>
> >>> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> >>
> >> This commit alone will cause problems, you will also need to pick this
> >> one on top of it:
> >>
> >> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
> >> checks and NULL deref in phy_attach_direct()")
> > 
> > Should I also be grabbing a7dac9f9c1
> > ("phy: fix error case of phy_led_triggers_(un)register")?
> > 
> > It says it fixes a commit that's not in -stable, but it looks like it's
> > still relevant even without that commit.
> 
> No, you don't have to pick this one, it does indeed fix something that
> was only introduced in 4.10 and newer.

Hm, can you ack this conflict resolution of applying 6d9f66ac7fe on top
of 4.9.30 (in particular, the code in phy_attach_direct()):

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 686bca0ba820..a8082d3d70e3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -860,6 +860,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	struct module *ndev_owner = dev->dev.parent->driver->owner;
 	struct mii_bus *bus = phydev->mdio.bus;
 	struct device *d = &phydev->mdio.dev;
+	bool using_genphy = false;
 	int err;
 
 	/* For Ethernet device drivers that register their own MDIO bus, we
@@ -872,11 +873,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 		return -EIO;
 	}
 
-	if (!try_module_get(d->driver->owner)) {
-		dev_err(&dev->dev, "failed to get the device driver module\n");
-		return -EIO;
-	}
-
 	get_device(d);
 
 	/* Assume that if there is no driver, that it doesn't
@@ -890,12 +886,22 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 			d->driver =
 				&genphy_driver[GENPHY_DRV_1G].mdiodrv.driver;
 
+		using_genphy = true;
+	}
+
+	if (!try_module_get(d->driver->owner)) {
+		dev_err(&dev->dev, "failed to get the device driver module\n");
+		err = -EIO;
+		goto error_put_device;
+	}
+
+	if (using_genphy) {
 		err = d->driver->probe(d);
 		if (err >= 0)
 			err = device_bind_driver(d);
 
 		if (err)
-			goto error;
+			goto error_module_put;
 	}
 
 	if (phydev->attached_dev) {
@@ -931,8 +937,12 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	return err;
 
 error:
-	put_device(d);
+	return err;
+
+error_module_put:
 	module_put(d->driver->owner);
+error_put_device:
+	put_device(d);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 	return err;
@@ -993,6 +1003,8 @@ void phy_detach(struct phy_device *phydev)
 	phydev->attached_dev = NULL;
 	phy_suspend(phydev);
 
+	module_put(phydev->mdio.dev.driver->owner);
+
 	/* If the device had no specific driver before (i.e. - it
 	 * was using the generic driver), we unbind the device
 	 * from the generic driver so that there's a chance a
@@ -1013,7 +1025,6 @@ void phy_detach(struct phy_device *phydev)
 	bus = phydev->mdio.bus;
 
 	put_device(&phydev->mdio.dev);
-	module_put(phydev->mdio.dev.driver->owner);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 }

--

Thanks,
Sasha

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-05 19:58         ` Levin, Alexander (Sasha Levin)
@ 2017-06-05 22:21           ` Florian Fainelli
  2017-06-06  0:33           ` Florian Fainelli
  1 sibling, 0 replies; 86+ messages in thread
From: Florian Fainelli @ 2017-06-05 22:21 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin); +Cc: stable, Mao Wenan, David S . Miller

On 06/05/2017 12:58 PM, Levin, Alexander (Sasha Levin) wrote:
> On Mon, Jun 05, 2017 at 09:56:18AM -0700, Florian Fainelli wrote:
>> On 06/05/2017 05:15 AM, Levin, Alexander (Sasha Levin) wrote:
>>> On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
>>>> Hi Alex,
>>>>
>>>> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
>>>>> From: Mao Wenan <maowenan@huawei.com>
>>>>>
>>>>> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
>>>>>
>>>>> There is currently no reference count being held on the PHY driver,
>>>>> which makes it possible to remove the PHY driver module while the PHY
>>>>> state machine is running and polling the PHY. This could cause crashes
>>>>> similar to this one to show up:
>>>>>
>>>>> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
>>>>> [   43.361162] IP: phy_state_machine+0x32/0x490
>>>>> [   43.361162] PGD 59dc067
>>>>> [   43.361162] PUD 0
>>>>> [   43.361162]
>>>>> [   43.361162] Oops: 0000 [#1] SMP
>>>>> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
>>>>> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
>>>>> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
>>>>> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
>>>>> [   43.361162] Workqueue: events_power_efficient phy_state_machine
>>>>> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
>>>>> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
>>>>> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
>>>>> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
>>>>> ffff880006a15c60
>>>>> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
>>>>> ffff8800059e5428
>>>>> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
>>>>> 0000000000000000
>>>>> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
>>>>> ffff8800059e5428
>>>>> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
>>>>> ffff880006a15c40
>>>>> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
>>>>> knlGS:0000000000000000
>>>>> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>>>> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
>>>>> 00000000000006f0
>>>>> [   43.361162] Call Trace:
>>>>> [   43.361162]  process_one_work+0x1b4/0x3e0
>>>>> [   43.361162]  worker_thread+0x43/0x4d0
>>>>> [   43.361162]  ? __schedule+0x17f/0x4e0
>>>>> [   43.361162]  kthread+0xf7/0x130
>>>>> [   43.361162]  ? process_one_work+0x3e0/0x3e0
>>>>> [   43.361162]  ? kthread_create_on_node+0x40/0x40
>>>>> [   43.361162]  ret_from_fork+0x29/0x40
>>>>> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
>>>>> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
>>>>> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
>>>>>
>>>>> Keep references on the PHY driver module right before we are going to
>>>>> utilize it in phy_attach_direct(), and conversely when we don't use it
>>>>> anymore in phy_detach().
>>>>>
>>>>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
>>>>> [florian: rebase, rework commit message]
>>>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>>>>
>>>>> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
>>>>
>>>> This commit alone will cause problems, you will also need to pick this
>>>> one on top of it:
>>>>
>>>> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
>>>> checks and NULL deref in phy_attach_direct()")
>>>
>>> Should I also be grabbing a7dac9f9c1
>>> ("phy: fix error case of phy_led_triggers_(un)register")?
>>>
>>> It says it fixes a commit that's not in -stable, but it looks like it's
>>> still relevant even without that commit.
>>
>> No, you don't have to pick this one, it does indeed fix something that
>> was only introduced in 4.10 and newer.
> 
> Hm, can you ack this conflict resolution of applying 6d9f66ac7fe on top
> of 4.9.30 (in particular, the code in phy_attach_direct()):

The resolution looks good at first glance, but I will run this through
the tests that required the cooking of these patches in the first place.
Will respond in a few hours, thanks!

> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 686bca0ba820..a8082d3d70e3 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -860,6 +860,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  	struct module *ndev_owner = dev->dev.parent->driver->owner;
>  	struct mii_bus *bus = phydev->mdio.bus;
>  	struct device *d = &phydev->mdio.dev;
> +	bool using_genphy = false;
>  	int err;
>  
>  	/* For Ethernet device drivers that register their own MDIO bus, we
> @@ -872,11 +873,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  		return -EIO;
>  	}
>  
> -	if (!try_module_get(d->driver->owner)) {
> -		dev_err(&dev->dev, "failed to get the device driver module\n");
> -		return -EIO;
> -	}
> -
>  	get_device(d);
>  
>  	/* Assume that if there is no driver, that it doesn't
> @@ -890,12 +886,22 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  			d->driver =
>  				&genphy_driver[GENPHY_DRV_1G].mdiodrv.driver;
>  
> +		using_genphy = true;
> +	}
> +
> +	if (!try_module_get(d->driver->owner)) {
> +		dev_err(&dev->dev, "failed to get the device driver module\n");
> +		err = -EIO;
> +		goto error_put_device;
> +	}
> +
> +	if (using_genphy) {
>  		err = d->driver->probe(d);
>  		if (err >= 0)
>  			err = device_bind_driver(d);
>  
>  		if (err)
> -			goto error;
> +			goto error_module_put;
>  	}
>  
>  	if (phydev->attached_dev) {
> @@ -931,8 +937,12 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  	return err;
>  
>  error:
> -	put_device(d);
> +	return err;
> +
> +error_module_put:
>  	module_put(d->driver->owner);
> +error_put_device:
> +	put_device(d);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  	return err;
> @@ -993,6 +1003,8 @@ void phy_detach(struct phy_device *phydev)
>  	phydev->attached_dev = NULL;
>  	phy_suspend(phydev);
>  
> +	module_put(phydev->mdio.dev.driver->owner);
> +
>  	/* If the device had no specific driver before (i.e. - it
>  	 * was using the generic driver), we unbind the device
>  	 * from the generic driver so that there's a chance a
> @@ -1013,7 +1025,6 @@ void phy_detach(struct phy_device *phydev)
>  	bus = phydev->mdio.bus;
>  
>  	put_device(&phydev->mdio.dev);
> -	module_put(phydev->mdio.dev.driver->owner);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  }
> 
> --
> 
> Thanks,
> Sasha
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-05 19:58         ` Levin, Alexander (Sasha Levin)
  2017-06-05 22:21           ` Florian Fainelli
@ 2017-06-06  0:33           ` Florian Fainelli
  2017-06-06  1:16             ` Levin, Alexander (Sasha Levin)
  1 sibling, 1 reply; 86+ messages in thread
From: Florian Fainelli @ 2017-06-06  0:33 UTC (permalink / raw)
  To: Levin, Alexander (Sasha Levin); +Cc: stable, Mao Wenan, David S . Miller

[-- Attachment #1: Type: text/plain, Size: 4346 bytes --]

On 06/05/2017 12:58 PM, Levin, Alexander (Sasha Levin) wrote:
> On Mon, Jun 05, 2017 at 09:56:18AM -0700, Florian Fainelli wrote:
>> On 06/05/2017 05:15 AM, Levin, Alexander (Sasha Levin) wrote:
>>> On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
>>>> Hi Alex,
>>>>
>>>> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
>>>>> From: Mao Wenan <maowenan@huawei.com>
>>>>>
>>>>> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
>>>>>
>>>>> There is currently no reference count being held on the PHY driver,
>>>>> which makes it possible to remove the PHY driver module while the PHY
>>>>> state machine is running and polling the PHY. This could cause crashes
>>>>> similar to this one to show up:
>>>>>
>>>>> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
>>>>> [   43.361162] IP: phy_state_machine+0x32/0x490
>>>>> [   43.361162] PGD 59dc067
>>>>> [   43.361162] PUD 0
>>>>> [   43.361162]
>>>>> [   43.361162] Oops: 0000 [#1] SMP
>>>>> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
>>>>> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
>>>>> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
>>>>> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
>>>>> [   43.361162] Workqueue: events_power_efficient phy_state_machine
>>>>> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
>>>>> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
>>>>> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
>>>>> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
>>>>> ffff880006a15c60
>>>>> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
>>>>> ffff8800059e5428
>>>>> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
>>>>> 0000000000000000
>>>>> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
>>>>> ffff8800059e5428
>>>>> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
>>>>> ffff880006a15c40
>>>>> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
>>>>> knlGS:0000000000000000
>>>>> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>>>> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
>>>>> 00000000000006f0
>>>>> [   43.361162] Call Trace:
>>>>> [   43.361162]  process_one_work+0x1b4/0x3e0
>>>>> [   43.361162]  worker_thread+0x43/0x4d0
>>>>> [   43.361162]  ? __schedule+0x17f/0x4e0
>>>>> [   43.361162]  kthread+0xf7/0x130
>>>>> [   43.361162]  ? process_one_work+0x3e0/0x3e0
>>>>> [   43.361162]  ? kthread_create_on_node+0x40/0x40
>>>>> [   43.361162]  ret_from_fork+0x29/0x40
>>>>> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
>>>>> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
>>>>> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
>>>>>
>>>>> Keep references on the PHY driver module right before we are going to
>>>>> utilize it in phy_attach_direct(), and conversely when we don't use it
>>>>> anymore in phy_detach().
>>>>>
>>>>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
>>>>> [florian: rebase, rework commit message]
>>>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>>>>
>>>>> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
>>>>
>>>> This commit alone will cause problems, you will also need to pick this
>>>> one on top of it:
>>>>
>>>> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
>>>> checks and NULL deref in phy_attach_direct()")
>>>
>>> Should I also be grabbing a7dac9f9c1
>>> ("phy: fix error case of phy_led_triggers_(un)register")?
>>>
>>> It says it fixes a commit that's not in -stable, but it looks like it's
>>> still relevant even without that commit.
>>
>> No, you don't have to pick this one, it does indeed fix something that
>> was only introduced in 4.10 and newer.
> 
> Hm, can you ack this conflict resolution of applying 6d9f66ac7fe on top
> of 4.9.30 (in particular, the code in phy_attach_direct()):

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Sorry it took a bit of time for testing because I also exercised the
error paths to make sure it was not blowing up on us, FWIW, attached was
the patch that I used.
-- 
Florian

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-net-phy-Fix-PHY-module-checks-and-NULL-deref-in-phy_.patch --]
[-- Type: text/x-patch; name="0001-net-phy-Fix-PHY-module-checks-and-NULL-deref-in-phy_.patch", Size: 3850 bytes --]

From 2a33694744e3ed2d33c4a530118ab46d20fbe6fc Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 8 Feb 2017 19:05:26 -0800
Subject: [PATCH] net: phy: Fix PHY module checks and NULL deref in
 phy_attach_direct()

The Generic PHY drivers gets assigned after we checked that the current
PHY driver is NULL, so we need to check a few things before we can
safely dereference d->driver. This would be causing a NULL deference to
occur when a system binds to the Generic PHY driver. Update
phy_attach_direct() to do the following:

- grab the driver module reference after we have assigned the Generic
  PHY drivers accordingly, and remember we came from the generic PHY
  path

- update the error path to clean up the module reference in case the
  Generic PHY probe function fails

- split the error path involving phy_detacht() to avoid double free/put
  since phy_detach() does all the clean up

- finally, have phy_detach() drop the module reference count before we
  call device_release_driver() for the Generic PHY driver case

Fixes: cafe8df8b9bc ("net: phy: Fix lack of reference count on PHY driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/phy/phy_device.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 67571f9627e5..14d57d0d1c04 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -860,6 +860,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	struct module *ndev_owner = dev->dev.parent->driver->owner;
 	struct mii_bus *bus = phydev->mdio.bus;
 	struct device *d = &phydev->mdio.dev;
+	bool using_genphy = false;
 	int err;
 
 	/* For Ethernet device drivers that register their own MDIO bus, we
@@ -872,11 +873,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 		return -EIO;
 	}
 
-	if (!try_module_get(d->driver->owner)) {
-		dev_err(&dev->dev, "failed to get the device driver module\n");
-		return -EIO;
-	}
-
 	get_device(d);
 
 	/* Assume that if there is no driver, that it doesn't
@@ -890,12 +886,22 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 			d->driver =
 				&genphy_driver[GENPHY_DRV_1G].mdiodrv.driver;
 
+		using_genphy = true;
+	}
+
+	if (!try_module_get(d->driver->owner)) {
+		dev_err(&dev->dev, "failed to get the device driver module\n");
+		err = -EIO;
+		goto error_put_device;
+	}
+
+	if (using_genphy) {
 		err = d->driver->probe(d);
 		if (err >= 0)
 			err = device_bind_driver(d);
 
 		if (err)
-			goto error;
+			goto error_module_put;
 	}
 
 	if (phydev->attached_dev) {
@@ -931,8 +937,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	return err;
 
 error:
-	put_device(d);
+	/* phy_detach() does all of the cleanup below */
+	phy_detach(phydev);
+	return err;
+
+error_module_put:
 	module_put(d->driver->owner);
+error_put_device:
+	put_device(d);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 	return err;
@@ -993,6 +1005,8 @@ void phy_detach(struct phy_device *phydev)
 	phydev->attached_dev = NULL;
 	phy_suspend(phydev);
 
+	module_put(phydev->mdio.dev.driver->owner);
+
 	/* If the device had no specific driver before (i.e. - it
 	 * was using the generic driver), we unbind the device
 	 * from the generic driver so that there's a chance a
@@ -1013,7 +1027,6 @@ void phy_detach(struct phy_device *phydev)
 	bus = phydev->mdio.bus;
 
 	put_device(&phydev->mdio.dev);
-	module_put(phydev->mdio.dev.driver->owner);
 	if (ndev_owner != bus->owner)
 		module_put(bus->owner);
 }
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver
  2017-06-06  0:33           ` Florian Fainelli
@ 2017-06-06  1:16             ` Levin, Alexander (Sasha Levin)
  0 siblings, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-06  1:16 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: stable, Mao Wenan, David S . Miller

On Mon, Jun 05, 2017 at 05:33:08PM -0700, Florian Fainelli wrote:
> On 06/05/2017 12:58 PM, Levin, Alexander (Sasha Levin) wrote:
> > On Mon, Jun 05, 2017 at 09:56:18AM -0700, Florian Fainelli wrote:
> >> On 06/05/2017 05:15 AM, Levin, Alexander (Sasha Levin) wrote:
> >>> On Sun, Jun 04, 2017 at 10:17:49AM -0700, Florian Fainelli wrote:
> >>>> Hi Alex,
> >>>>
> >>>> On 06/04/2017 01:12 AM, Levin, Alexander (Sasha Levin) wrote:
> >>>>> From: Mao Wenan <maowenan@huawei.com>
> >>>>>
> >>>>> [ Upstream commit cafe8df8b9bc9aa3dffa827c1a6757c6cd36f657 ]
> >>>>>
> >>>>> There is currently no reference count being held on the PHY driver,
> >>>>> which makes it possible to remove the PHY driver module while the PHY
> >>>>> state machine is running and polling the PHY. This could cause crashes
> >>>>> similar to this one to show up:
> >>>>>
> >>>>> [   43.361162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
> >>>>> [   43.361162] IP: phy_state_machine+0x32/0x490
> >>>>> [   43.361162] PGD 59dc067
> >>>>> [   43.361162] PUD 0
> >>>>> [   43.361162]
> >>>>> [   43.361162] Oops: 0000 [#1] SMP
> >>>>> [   43.361162] Modules linked in: dsa_loop [last unloaded: broadcom]
> >>>>> [   43.361162] CPU: 0 PID: 1299 Comm: kworker/0:3 Not tainted 4.10.0-rc5+ #415
> >>>>> [   43.361162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> >>>>> BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
> >>>>> [   43.361162] Workqueue: events_power_efficient phy_state_machine
> >>>>> [   43.361162] task: ffff880006782b80 task.stack: ffffc90000184000
> >>>>> [   43.361162] RIP: 0010:phy_state_machine+0x32/0x490
> >>>>> [   43.361162] RSP: 0018:ffffc90000187e18 EFLAGS: 00000246
> >>>>> [   43.361162] RAX: 0000000000000000 RBX: ffff8800059e53c0 RCX:
> >>>>> ffff880006a15c60
> >>>>> [   43.361162] RDX: ffff880006782b80 RSI: 0000000000000000 RDI:
> >>>>> ffff8800059e5428
> >>>>> [   43.361162] RBP: ffffc90000187e48 R08: ffff880006a15c40 R09:
> >>>>> 0000000000000000
> >>>>> [   43.361162] R10: 0000000000000000 R11: 0000000000000000 R12:
> >>>>> ffff8800059e5428
> >>>>> [   43.361162] R13: ffff8800059e5000 R14: 0000000000000000 R15:
> >>>>> ffff880006a15c40
> >>>>> [   43.361162] FS:  0000000000000000(0000) GS:ffff880006a00000(0000)
> >>>>> knlGS:0000000000000000
> >>>>> [   43.361162] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> >>>>> [   43.361162] CR2: 0000000000000140 CR3: 0000000005979000 CR4:
> >>>>> 00000000000006f0
> >>>>> [   43.361162] Call Trace:
> >>>>> [   43.361162]  process_one_work+0x1b4/0x3e0
> >>>>> [   43.361162]  worker_thread+0x43/0x4d0
> >>>>> [   43.361162]  ? __schedule+0x17f/0x4e0
> >>>>> [   43.361162]  kthread+0xf7/0x130
> >>>>> [   43.361162]  ? process_one_work+0x3e0/0x3e0
> >>>>> [   43.361162]  ? kthread_create_on_node+0x40/0x40
> >>>>> [   43.361162]  ret_from_fork+0x29/0x40
> >>>>> [   43.361162] Code: 56 41 55 41 54 4c 8d 67 68 53 4c 8d af 40 fc ff ff
> >>>>> 48 89 fb 4c 89 e7 48 83 ec 08 e8 c9 9d 27 00 48 8b 83 60 ff ff ff 44 8b
> >>>>> 73 98 <48> 8b 90 40 01 00 00 44 89 f0 48 85 d2 74 08 4c 89 ef ff d2 8b
> >>>>>
> >>>>> Keep references on the PHY driver module right before we are going to
> >>>>> utilize it in phy_attach_direct(), and conversely when we don't use it
> >>>>> anymore in phy_detach().
> >>>>>
> >>>>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
> >>>>> [florian: rebase, rework commit message]
> >>>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> >>>>> Signed-off-by: David S. Miller <davem@davemloft.net>
> >>>>>
> >>>>> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> >>>>
> >>>> This commit alone will cause problems, you will also need to pick this
> >>>> one on top of it:
> >>>>
> >>>> 6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25 ("net: phy: Fix PHY module
> >>>> checks and NULL deref in phy_attach_direct()")
> >>>
> >>> Should I also be grabbing a7dac9f9c1
> >>> ("phy: fix error case of phy_led_triggers_(un)register")?
> >>>
> >>> It says it fixes a commit that's not in -stable, but it looks like it's
> >>> still relevant even without that commit.
> >>
> >> No, you don't have to pick this one, it does indeed fix something that
> >> was only introduced in 4.10 and newer.
> > 
> > Hm, can you ack this conflict resolution of applying 6d9f66ac7fe on top
> > of 4.9.30 (in particular, the code in phy_attach_direct()):
> 
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> 
> Sorry it took a bit of time for testing because I also exercised the
> error paths to make sure it was not blowing up on us, FWIW, attached was
> the patch that I used.
> -- 
> Florian

I'll take your patch below. Thanks Florian!

> From 2a33694744e3ed2d33c4a530118ab46d20fbe6fc Mon Sep 17 00:00:00 2001
> From: Florian Fainelli <f.fainelli@gmail.com>
> Date: Wed, 8 Feb 2017 19:05:26 -0800
> Subject: [PATCH] net: phy: Fix PHY module checks and NULL deref in
>  phy_attach_direct()
> 
> The Generic PHY drivers gets assigned after we checked that the current
> PHY driver is NULL, so we need to check a few things before we can
> safely dereference d->driver. This would be causing a NULL deference to
> occur when a system binds to the Generic PHY driver. Update
> phy_attach_direct() to do the following:
> 
> - grab the driver module reference after we have assigned the Generic
>   PHY drivers accordingly, and remember we came from the generic PHY
>   path
> 
> - update the error path to clean up the module reference in case the
>   Generic PHY probe function fails
> 
> - split the error path involving phy_detacht() to avoid double free/put
>   since phy_detach() does all the clean up
> 
> - finally, have phy_detach() drop the module reference count before we
>   call device_release_driver() for the Generic PHY driver case
> 
> Fixes: cafe8df8b9bc ("net: phy: Fix lack of reference count on PHY driver")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  drivers/net/phy/phy_device.c | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 67571f9627e5..14d57d0d1c04 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -860,6 +860,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  	struct module *ndev_owner = dev->dev.parent->driver->owner;
>  	struct mii_bus *bus = phydev->mdio.bus;
>  	struct device *d = &phydev->mdio.dev;
> +	bool using_genphy = false;
>  	int err;
>  
>  	/* For Ethernet device drivers that register their own MDIO bus, we
> @@ -872,11 +873,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  		return -EIO;
>  	}
>  
> -	if (!try_module_get(d->driver->owner)) {
> -		dev_err(&dev->dev, "failed to get the device driver module\n");
> -		return -EIO;
> -	}
> -
>  	get_device(d);
>  
>  	/* Assume that if there is no driver, that it doesn't
> @@ -890,12 +886,22 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  			d->driver =
>  				&genphy_driver[GENPHY_DRV_1G].mdiodrv.driver;
>  
> +		using_genphy = true;
> +	}
> +
> +	if (!try_module_get(d->driver->owner)) {
> +		dev_err(&dev->dev, "failed to get the device driver module\n");
> +		err = -EIO;
> +		goto error_put_device;
> +	}
> +
> +	if (using_genphy) {
>  		err = d->driver->probe(d);
>  		if (err >= 0)
>  			err = device_bind_driver(d);
>  
>  		if (err)
> -			goto error;
> +			goto error_module_put;
>  	}
>  
>  	if (phydev->attached_dev) {
> @@ -931,8 +937,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  	return err;
>  
>  error:
> -	put_device(d);
> +	/* phy_detach() does all of the cleanup below */
> +	phy_detach(phydev);
> +	return err;
> +
> +error_module_put:
>  	module_put(d->driver->owner);
> +error_put_device:
> +	put_device(d);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  	return err;
> @@ -993,6 +1005,8 @@ void phy_detach(struct phy_device *phydev)
>  	phydev->attached_dev = NULL;
>  	phy_suspend(phydev);
>  
> +	module_put(phydev->mdio.dev.driver->owner);
> +
>  	/* If the device had no specific driver before (i.e. - it
>  	 * was using the generic driver), we unbind the device
>  	 * from the generic driver so that there's a chance a
> @@ -1013,7 +1027,6 @@ void phy_detach(struct phy_device *phydev)
>  	bus = phydev->mdio.bus;
>  
>  	put_device(&phydev->mdio.dev);
> -	module_put(phydev->mdio.dev.driver->owner);
>  	if (ndev_owner != bus->owner)
>  		module_put(bus->owner);
>  }
> -- 
> 2.9.3
> 


-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage
  2017-06-04 20:45   ` Jerome Brunet
  2017-06-05 12:20     ` Levin, Alexander (Sasha Levin)
@ 2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  1 sibling, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-11 14:31 UTC (permalink / raw)
  To: Jerome Brunet; +Cc: stable, Kevin Hilman, Arnd Bergmann

On Sun, Jun 04, 2017 at 10:45:49PM +0200, Jerome Brunet wrote:
> On Sun, 2017-06-04 at 08:12 +0000, Levin, Alexander (Sasha Levin) wrote:
> > From: Jerome Brunet <jbrunet@baylibre.com>
> > 
> > [ Upstream commit feb3cbea0946c67060e2d5bcb7499b0a6f6700fe ]
> > 
> > OdroidC2 GbE link breaks under heavy tx transfer. This happens even if the
> > MAC does not enable Energy Efficient Ethernet (No Low Power state Idle on
> > the Tx path). The problem seems to come from the phy Rx path, entering the
> > LPI state.
> > 
> > Disabling EEE advertisement on the phy prevent this feature to be
> > negociated with the link partner and solve the issue.
> > 
> > Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> > Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
> 
> Alexander,
> 
> unfortunately, this dt change alone won't fix the problem. The code related to
> eee-broken-**** has been merged into mainline around the same time as this
> particular change.
> 
> For this flag to actually do something you'll need the following commits:
> 
> d853d145ea3e63387a2ac759aa41d5e43876e561
> 1fc31357ad194fb98691f3d122bcd47e59239e83
> 3bb9ab63276696988d8224f52db20e87194deb4b
> 57f3986231bb2c69a55ccab1d2b30a00818027ac
> 308d3165d8b2b98d3dc3d97d6662062735daea67

Thanks, Jerome!

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume
  2017-06-04  8:57   ` Lukas Wunner
  2017-06-05 12:23     ` Levin, Alexander (Sasha Levin)
@ 2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
  1 sibling, 0 replies; 86+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-06-11 14:31 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: stable, Lyude Paul, Hans de Goede, Kilian Singer, David Airlie,
	Peter Ujfalusi

On Sun, Jun 04, 2017 at 10:57:44AM +0200, Lukas Wunner wrote:
> [cc += Peter Ujfalusi]
> 
> On Sun, Jun 04, 2017 at 08:12:31AM +0000, Levin, Alexander (Sasha Levin) wrote:
> > From: Lyude Paul <lyude@redhat.com>
> > 
> > [ Upstream commit cae9ff036eea577856d5b12860b4c79c5e71db4a ]
> 
> There's a fix for the above-quoted commit which landed in v4.12-rc2
> and may be worth applying on top:
> 
>     commit 9a2eba337cacefc95b97c2726e3efdd435b3460e
>     Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
>     Date:   Mon May 15 12:04:31 2017 +0300
> 
>     drm/nouveau: Fix drm poll_helper handling

Thanks Lukas!

-- 

Thanks,
Sasha

^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2017-06-11 14:32 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-04  8:11 [PATCH for v4.9 LTS 001/111] ibmvnic: Fix endian errors in error reporting output Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 002/111] ibmvnic: Fix endian error when requesting device capabilities Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 003/111] net: xilinx_emaclite: fix freezes due to unordered I/O Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 004/111] net: xilinx_emaclite: fix receive buffer overflow Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 005/111] tools lib bpf: Sync {tools,}/include/uapi/linux/bpf.h Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 006/111] bpf: kernel header files need to be copied into the tools directory Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 007/111] tcp: tcp_probe: use spin_lock_bh() Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 008/111] ipv6: Handle IPv4-mapped src to in6addr_any dst Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 009/111] ipv6: Inhibit IPv4-mapped src address on the wire Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 010/111] tipc: Fix tipc_sk_reinit race conditions Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 011/111] gfs2: Use rhashtable walk interface in glock_hash_walk Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 012/111] NET: Fix /proc/net/arp for AX.25 Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 013/111] ibmvnic: Call napi_disable instead of napi_enable in failure path Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 014/111] ibmvnic: Initialize completion variables before starting work Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 015/111] NET: mkiss: Fix panic Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 016/111] net: hns: Fix the device being used for dma mapping during TX Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 017/111] sierra_net: Skip validating irrelevant fields for IDLE LSIs Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 018/111] sierra_net: Add support for IPv6 and Dual-Stack Link Sense Indications Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 020/111] i2c: piix4: Fix request_region size Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 019/111] i2c: piix4: Request the SMBUS semaphore inside the mutex Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 021/111] powerpc/powernv: Properly set "host-ipi" on IPIs Levin, Alexander (Sasha Levin)
2017-06-04  8:11 ` [PATCH for v4.9 LTS 022/111] kernel/ucount.c: mark user_header with kmemleak_ignore() Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 023/111] net: thunderx: Fix PHY autoneg for SGMII QLM mode Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 024/111] ipv6: addrconf: fix generation of new temporary addresses Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 025/111] mm: fix KPF_SWAPCACHE in /proc/kpageflags Levin, Alexander (Sasha Levin)
2017-06-04 22:42   ` Hugh Dickins
2017-06-05 12:00     ` Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 027/111] ipv6: Fix IPv6 packet loss in scenarios involving roaming + snooping switches Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 026/111] vfio/spapr_tce: Set window when adding additional groups to container Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 028/111] ARM: defconfigs: make NF_CT_PROTO_SCTP and NF_CT_PROTO_UDPLITE built-in Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 029/111] PM / runtime: Avoid false-positive warnings from might_sleep_if() Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 030/111] jump label: pass kbuild_cflags when checking for asm goto support Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 031/111] shmem: fix sleeping from atomic context Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 032/111] kasan: respect /proc/sys/kernel/traceoff_on_warning Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 033/111] log2: make order_base_2() behave correctly on const input value zero Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 034/111] ethtool: do not vzalloc(0) on registers dump Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 035/111] net: phy: Fix lack of reference count on PHY driver Levin, Alexander (Sasha Levin)
2017-06-04 17:17   ` Florian Fainelli
2017-06-05 12:15     ` Levin, Alexander (Sasha Levin)
2017-06-05 16:56       ` Florian Fainelli
2017-06-05 19:58         ` Levin, Alexander (Sasha Levin)
2017-06-05 22:21           ` Florian Fainelli
2017-06-06  0:33           ` Florian Fainelli
2017-06-06  1:16             ` Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 036/111] drm/radeon: Fix vram_size/visible values in DRM_RADEON_GEM_INFO ioctl Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 037/111] net: fix ndo_features_check/ndo_fix_features comment ordering Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 039/111] fscache: Fix dead object requeue Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 038/111] scsi: mpt3sas: Force request partial completion alignment Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 041/111] FS-Cache: Initialise stores_lock in netfs cookie Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 040/111] fscache: Clear outstanding writes when disabling a cookie Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 042/111] ipv6: fix flow labels when the traffic class is non-0 Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 043/111] drm/nouveau: prevent userspace from deleting client object Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 044/111] drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 045/111] sparc64: Handle PIO & MEM non-resumable errors Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 046/111] sparc64: Zero pages on allocation for mondo and error queues Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 047/111] net/mlx4_core: Avoid command timeouts during VF driver device shutdown Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 048/111] gianfar: synchronize DMA API usage by free_skb_rx_queue w/ gfar_new_page Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 049/111] net: ethtool: add support for 2500BaseT and 5000BaseT link modes Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 050/111] pinctrl: baytrail: Rectify debounce support (part 2) Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 051/111] [media] cec: fix wrong last_la determination Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 052/111] drm: Add fake controlD* symlinks for backwards compat Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 053/111] drm: prevent double-(un)registration for connectors Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 054/111] drm: Don't race connector registration Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 055/111] pinctrl: berlin-bg4ct: fix the value for "sd1a" of pin SCRD0_CRD_PRES Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 056/111] net: adaptec: starfire: add checks for dma mapping errors Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 057/111] drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj() Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 059/111] net/mlx5: Return EOPNOTSUPP when failing to get steering name-space Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 058/111] net/mlx5: E-Switch, Err when retrieving steering name-space fails Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 060/111] parisc, parport_gsc: Fixes for printk continuation lines Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 061/111] net: phy: micrel: add support for KSZ8795 Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 062/111] ARM64: dts: amlogic: Add Meson GX dtsi from GXBB Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 064/111] ARM64: dts: meson-gxbb-odroidc2: fix GbE tx link breakage Levin, Alexander (Sasha Levin)
2017-06-04 20:45   ` Jerome Brunet
2017-06-05 12:20     ` Levin, Alexander (Sasha Levin)
2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 063/111] ARM64: dts: meson-gx: Add firmware reserved memory zones Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 065/111] gtp: add genl family modules alias Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 067/111] drm/nouveau: Rename acpi_work to hpd_work Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 066/111] drm/nouveau: Intercept ACPI_VIDEO_NOTIFY_PROBE Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 069/111] drm/nouveau: Don't enabling polling twice on runtime resume Levin, Alexander (Sasha Levin)
2017-06-04  8:57   ` Lukas Wunner
2017-06-05 12:23     ` Levin, Alexander (Sasha Levin)
2017-06-11 14:31     ` Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 068/111] drm/nouveau: Handle fbcon suspend/resume in seperate worker Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 070/111] drm/ast: Fixed system hanged if disable P2A Levin, Alexander (Sasha Levin)
2017-06-04  8:12 ` [PATCH for v4.9 LTS 071/111] ravb: unmap descriptors when freeing rings Levin, Alexander (Sasha Levin)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.