All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 00/10] ibmvnic: Updates and bug fixes
@ 2017-04-19 17:44 Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 01/10] ibmvnic: Report errors when failing to release sub-crqs Nathan Fontenot
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

This set of patches is a series of updates to remove some unneeded
and unused code in the driver as well as bug fixes for the
ibmvnic driver.

---

Brian King (4):
      ibmvnic: Unmap longer term buffer before free
      ibmvnic: Fixup atomic API usage
      ibmvnic: Do not disable IRQ after scheduling tasklet
      ibmvnic: Disable irq prior to close

Murilo Fossa Vicentini (1):
      ibmvnic: Fix ibmvnic_change_mac_addr struct format

Nathan Fontenot (4):
      ibmvnic: Remove inflight list
      ibmvnic: Correct crq and resource releasing
      ibmvnic: Allocate zero-filled memory for sub crqs
      ibmvnic: Remove unused bouce buffer

Thomas Falcon (1):
      ibmvnic: Report errors when failing to release sub-crqs


 drivers/net/ethernet/ibm/ibmvnic.c |  223 ++++++++++--------------------------
 drivers/net/ethernet/ibm/ibmvnic.h |   15 --
 2 files changed, 61 insertions(+), 177 deletions(-)

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

* [PATCH net-next 01/10] ibmvnic: Report errors when failing to release sub-crqs
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 02/10] ibmvnic: Fix ibmvnic_change_mac_addr struct format Nathan Fontenot
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

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

Add reporting of errors when releasing sub-crqs fails.

Signed-off-by: Thomas Falcon <tlfalcon@us.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 7ba43cf..7bf3507 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1309,6 +1309,12 @@ static void release_sub_crq_queue(struct ibmvnic_adapter *adapter,
 					scrq->crq_num);
 	} while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
 
+	if (rc) {
+		netdev_err(adapter->netdev,
+			   "Failed to release sub-CRQ %16lx, rc = %ld\n",
+			   scrq->crq_num, rc);
+	}
+
 	dma_unmap_single(dev, scrq->msg_token, 4 * PAGE_SIZE,
 			 DMA_BIDIRECTIONAL);
 	free_pages((unsigned long)scrq->msgs, 2);

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

* [PATCH net-next 02/10] ibmvnic: Fix ibmvnic_change_mac_addr struct format
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 01/10] ibmvnic: Report errors when failing to release sub-crqs Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 03/10] ibmvnic: Unmap longer term buffer before free Nathan Fontenot
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

From: Murilo Fossa Vicentini <muvic@linux.vnet.ibm.com>

The ibmvnic_change_mac_addr struct alignment was not matching the defined
format in PAPR+, it had the reserved and return code fields swapped. As a
consequence, the CHANGE_MAC_ADDR_RSP commands were being improperly handled
and executed even when the operation wasn't successfully completed by the
system firmware.

Also changing the endianness of the debug message to make it easier to
parse the CRQ content.

Signed-off-by: Murilo Fossa Vicentini <muvic@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |    5 +++--
 drivers/net/ethernet/ibm/ibmvnic.h |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 7bf3507..625896d 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2890,11 +2890,12 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
 	struct ibmvnic_generic_crq *gen_crq = &crq->generic;
 	struct net_device *netdev = adapter->netdev;
 	struct device *dev = &adapter->vdev->dev;
+	u64 *u64_crq = (u64 *)crq;
 	long rc;
 
 	netdev_dbg(netdev, "Handling CRQ: %016lx %016lx\n",
-		   ((unsigned long int *)crq)[0],
-		   ((unsigned long int *)crq)[1]);
+		   (unsigned long int)cpu_to_be64(u64_crq[0]),
+		   (unsigned long int)cpu_to_be64(u64_crq[1]));
 	switch (gen_crq->first) {
 	case IBMVNIC_CRQ_INIT_RSP:
 		switch (gen_crq->cmd) {
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index b0d0b89..1b404ca 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -518,8 +518,8 @@ struct ibmvnic_change_mac_addr {
 	u8 first;
 	u8 cmd;
 	u8 mac_addr[6];
-	struct ibmvnic_rc rc;
 	u8 reserved[4];
+	struct ibmvnic_rc rc;
 } __packed __aligned(8);
 
 struct ibmvnic_multicast_ctrl {

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

* [PATCH net-next 03/10] ibmvnic: Unmap longer term buffer before free
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 01/10] ibmvnic: Report errors when failing to release sub-crqs Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 02/10] ibmvnic: Fix ibmvnic_change_mac_addr struct format Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 04/10] ibmvnic: Fixup atomic API usage Nathan Fontenot
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

From: Brian King <brking@linux.vnet.ibm.com>

Make sure we unregister long term buffers from the adapter
prior to DMA unmapping it and freeing the buffer. Failure
to do so could result in a DMA to a now invalid address.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.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 625896d..c10bae7 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -193,9 +193,9 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter,
 	if (!ltb->buff)
 		return;
 
-	dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
 	if (!adapter->failover)
 		send_request_unmap(adapter, ltb->map_id);
+	dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
 }
 
 static void replenish_rx_pool(struct ibmvnic_adapter *adapter,

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

* [PATCH net-next 04/10] ibmvnic: Fixup atomic API usage
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (2 preceding siblings ...)
  2017-04-19 17:44 ` [PATCH net-next 03/10] ibmvnic: Unmap longer term buffer before free Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 05/10] ibmvnic: Do not disable IRQ after scheduling tasklet Nathan Fontenot
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

From: Brian King <brking@linux.vnet.ibm.com>

Replace a couple of modifications of an atomic followed
by a read of the atomic, which is no longer atomic, to
use atomic_XX_return variants to avoid race conditions.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index c10bae7..b5871df 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -962,9 +962,8 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		goto out;
 	}
 
-	atomic_inc(&tx_scrq->used);
-
-	if (atomic_read(&tx_scrq->used) >= adapter->req_tx_entries_per_subcrq) {
+	if (atomic_inc_return(&tx_scrq->used)
+					>= adapter->req_tx_entries_per_subcrq) {
 		netdev_info(netdev, "Stopping queue %d\n", queue_num);
 		netif_stop_subqueue(netdev, queue_num);
 	}
@@ -1499,9 +1498,8 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
 			}
 
 			if (txbuff->last_frag) {
-				atomic_dec(&scrq->used);
-
-				if (atomic_read(&scrq->used) <=
+				if (atomic_sub_return(next->tx_comp.num_comps,
+						      &scrq->used) <=
 				    (adapter->req_tx_entries_per_subcrq / 2) &&
 				    netif_subqueue_stopped(adapter->netdev,
 							   txbuff->skb)) {

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

* [PATCH net-next 05/10] ibmvnic: Do not disable IRQ after scheduling tasklet
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (3 preceding siblings ...)
  2017-04-19 17:44 ` [PATCH net-next 04/10] ibmvnic: Fixup atomic API usage Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:44 ` [PATCH net-next 06/10] ibmvnic: Remove inflight list Nathan Fontenot
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

From: Brian King <brking@linux.vnet.ibm.com>

Since the primary CRQ is only used for service functions and
not in the performance path, simplify the code a bit and avoid
disabling the IRQ.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index b5871df..27d7d27 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -3027,12 +3027,8 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
 static irqreturn_t ibmvnic_interrupt(int irq, void *instance)
 {
 	struct ibmvnic_adapter *adapter = instance;
-	unsigned long flags;
 
-	spin_lock_irqsave(&adapter->crq.lock, flags);
-	vio_disable_interrupts(adapter->vdev);
 	tasklet_schedule(&adapter->tasklet);
-	spin_unlock_irqrestore(&adapter->crq.lock, flags);
 	return IRQ_HANDLED;
 }
 
@@ -3040,32 +3036,23 @@ static void ibmvnic_tasklet(void *data)
 {
 	struct ibmvnic_adapter *adapter = data;
 	struct ibmvnic_crq_queue *queue = &adapter->crq;
-	struct vio_dev *vdev = adapter->vdev;
 	union ibmvnic_crq *crq;
 	unsigned long flags;
 	bool done = false;
 
 	spin_lock_irqsave(&queue->lock, flags);
-	vio_disable_interrupts(vdev);
 	while (!done) {
 		/* Pull all the valid messages off the CRQ */
 		while ((crq = ibmvnic_next_crq(adapter)) != NULL) {
 			ibmvnic_handle_crq(crq, adapter);
 			crq->generic.first = 0;
 		}
-		vio_enable_interrupts(vdev);
-		crq = ibmvnic_next_crq(adapter);
-		if (crq) {
-			vio_disable_interrupts(vdev);
-			ibmvnic_handle_crq(crq, adapter);
-			crq->generic.first = 0;
-		} else {
-			/* remain in tasklet until all
-			 * capabilities responses are received
-			 */
-			if (!adapter->wait_capability)
-				done = true;
-		}
+
+		/* remain in tasklet until all
+		 * capabilities responses are received
+		 */
+		if (!adapter->wait_capability)
+			done = true;
 	}
 	/* if capabilities CRQ's were sent in this tasklet, the following
 	 * tasklet must wait until all responses are received

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

* [PATCH net-next 06/10] ibmvnic: Remove inflight list
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (4 preceding siblings ...)
  2017-04-19 17:44 ` [PATCH net-next 05/10] ibmvnic: Do not disable IRQ after scheduling tasklet Nathan Fontenot
@ 2017-04-19 17:44 ` Nathan Fontenot
  2017-04-19 17:45 ` [PATCH net-next 07/10] ibmvnic: Correct crq and resource releasing Nathan Fontenot
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:44 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

The inflight list used to track memory that is allocated for crq that are
inflight is not needed. The one piece of the inflight list that does need
to be cleaned at module exit is the error buffer list which is already
attached to the adapter struct.

This patch removes the inflight list and moves checking the error buffer
list to ibmvnic_remove.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   98 +++++++-----------------------------
 drivers/net/ethernet/ibm/ibmvnic.h |    9 ---
 2 files changed, 19 insertions(+), 88 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 27d7d27..18673e2 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -546,6 +546,23 @@ static int init_bounce_buffer(struct net_device *netdev)
 	return 0;
 }
 
+static void release_error_buffers(struct ibmvnic_adapter *adapter)
+{
+	struct device *dev = &adapter->vdev->dev;
+	struct ibmvnic_error_buff *error_buff, *tmp;
+	unsigned long flags;
+
+	spin_lock_irqsave(&adapter->error_list_lock, flags);
+	list_for_each_entry_safe(error_buff, tmp, &adapter->errors, list) {
+		list_del(&error_buff->list);
+		dma_unmap_single(dev, error_buff->dma, error_buff->len,
+				 DMA_FROM_DEVICE);
+		kfree(error_buff->buff);
+		kfree(error_buff);
+	}
+	spin_unlock_irqrestore(&adapter->error_list_lock, flags);
+}
+
 static int ibmvnic_login(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -588,6 +605,7 @@ static void release_resources(struct ibmvnic_adapter *adapter)
 	release_crq_queue(adapter);
 
 	release_stats_token(adapter);
+	release_error_buffers(adapter);
 }
 
 static int ibmvnic_open(struct net_device *netdev)
@@ -1957,13 +1975,11 @@ static void send_login(struct ibmvnic_adapter *adapter)
 {
 	struct ibmvnic_login_rsp_buffer *login_rsp_buffer;
 	struct ibmvnic_login_buffer *login_buffer;
-	struct ibmvnic_inflight_cmd *inflight_cmd;
 	struct device *dev = &adapter->vdev->dev;
 	dma_addr_t rsp_buffer_token;
 	dma_addr_t buffer_token;
 	size_t rsp_buffer_size;
 	union ibmvnic_crq crq;
-	unsigned long flags;
 	size_t buffer_size;
 	__be64 *tx_list_p;
 	__be64 *rx_list_p;
@@ -2000,11 +2016,7 @@ static void send_login(struct ibmvnic_adapter *adapter)
 		dev_err(dev, "Couldn't map login rsp buffer\n");
 		goto buf_rsp_map_failed;
 	}
-	inflight_cmd = kmalloc(sizeof(*inflight_cmd), GFP_ATOMIC);
-	if (!inflight_cmd) {
-		dev_err(dev, "Couldn't allocate inflight_cmd\n");
-		goto inflight_alloc_failed;
-	}
+
 	adapter->login_buf = login_buffer;
 	adapter->login_buf_token = buffer_token;
 	adapter->login_buf_sz = buffer_size;
@@ -2055,20 +2067,10 @@ static void send_login(struct ibmvnic_adapter *adapter)
 	crq.login.cmd = LOGIN;
 	crq.login.ioba = cpu_to_be32(buffer_token);
 	crq.login.len = cpu_to_be32(buffer_size);
-
-	memcpy(&inflight_cmd->crq, &crq, sizeof(crq));
-
-	spin_lock_irqsave(&adapter->inflight_lock, flags);
-	list_add_tail(&inflight_cmd->list, &adapter->inflight);
-	spin_unlock_irqrestore(&adapter->inflight_lock, flags);
-
 	ibmvnic_send_crq(adapter, &crq);
 
 	return;
 
-inflight_alloc_failed:
-	dma_unmap_single(dev, rsp_buffer_token, rsp_buffer_size,
-			 DMA_FROM_DEVICE);
 buf_rsp_map_failed:
 	kfree(login_rsp_buffer);
 buf_rsp_alloc_failed:
@@ -2374,7 +2376,6 @@ static void handle_error_indication(union ibmvnic_crq *crq,
 				    struct ibmvnic_adapter *adapter)
 {
 	int detail_len = be32_to_cpu(crq->error_indication.detail_error_sz);
-	struct ibmvnic_inflight_cmd *inflight_cmd;
 	struct device *dev = &adapter->vdev->dev;
 	struct ibmvnic_error_buff *error_buff;
 	union ibmvnic_crq new_crq;
@@ -2406,15 +2407,6 @@ static void handle_error_indication(union ibmvnic_crq *crq,
 		return;
 	}
 
-	inflight_cmd = kmalloc(sizeof(*inflight_cmd), GFP_ATOMIC);
-	if (!inflight_cmd) {
-		dma_unmap_single(dev, error_buff->dma, detail_len,
-				 DMA_FROM_DEVICE);
-		kfree(error_buff->buff);
-		kfree(error_buff);
-		return;
-	}
-
 	error_buff->len = detail_len;
 	error_buff->error_id = crq->error_indication.error_id;
 
@@ -2428,13 +2420,6 @@ static void handle_error_indication(union ibmvnic_crq *crq,
 	new_crq.request_error_info.ioba = cpu_to_be32(error_buff->dma);
 	new_crq.request_error_info.len = cpu_to_be32(detail_len);
 	new_crq.request_error_info.error_id = crq->error_indication.error_id;
-
-	memcpy(&inflight_cmd->crq, &crq, sizeof(crq));
-
-	spin_lock_irqsave(&adapter->inflight_lock, flags);
-	list_add_tail(&inflight_cmd->list, &adapter->inflight);
-	spin_unlock_irqrestore(&adapter->inflight_lock, flags);
-
 	ibmvnic_send_crq(adapter, &new_crq);
 }
 
@@ -2819,48 +2804,6 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
 	}
 }
 
-static void ibmvnic_free_inflight(struct ibmvnic_adapter *adapter)
-{
-	struct ibmvnic_inflight_cmd *inflight_cmd, *tmp1;
-	struct device *dev = &adapter->vdev->dev;
-	struct ibmvnic_error_buff *error_buff, *tmp2;
-	unsigned long flags;
-	unsigned long flags2;
-
-	spin_lock_irqsave(&adapter->inflight_lock, flags);
-	list_for_each_entry_safe(inflight_cmd, tmp1, &adapter->inflight, list) {
-		switch (inflight_cmd->crq.generic.cmd) {
-		case LOGIN:
-			dma_unmap_single(dev, adapter->login_buf_token,
-					 adapter->login_buf_sz,
-					 DMA_BIDIRECTIONAL);
-			dma_unmap_single(dev, adapter->login_rsp_buf_token,
-					 adapter->login_rsp_buf_sz,
-					 DMA_BIDIRECTIONAL);
-			kfree(adapter->login_rsp_buf);
-			kfree(adapter->login_buf);
-			break;
-		case REQUEST_ERROR_INFO:
-			spin_lock_irqsave(&adapter->error_list_lock, flags2);
-			list_for_each_entry_safe(error_buff, tmp2,
-						 &adapter->errors, list) {
-				dma_unmap_single(dev, error_buff->dma,
-						 error_buff->len,
-						 DMA_FROM_DEVICE);
-				kfree(error_buff->buff);
-				list_del(&error_buff->list);
-				kfree(error_buff);
-			}
-			spin_unlock_irqrestore(&adapter->error_list_lock,
-					       flags2);
-			break;
-		}
-		list_del(&inflight_cmd->list);
-		kfree(inflight_cmd);
-	}
-	spin_unlock_irqrestore(&adapter->inflight_lock, flags);
-}
-
 static void ibmvnic_xport_event(struct work_struct *work)
 {
 	struct ibmvnic_adapter *adapter = container_of(work,
@@ -2869,7 +2812,6 @@ static void ibmvnic_xport_event(struct work_struct *work)
 	struct device *dev = &adapter->vdev->dev;
 	long rc;
 
-	ibmvnic_free_inflight(adapter);
 	release_sub_crqs(adapter);
 	if (adapter->migrated) {
 		rc = ibmvnic_reenable_crq_queue(adapter);
@@ -3333,9 +3275,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 	spin_lock_init(&adapter->stats_lock);
 
 	INIT_LIST_HEAD(&adapter->errors);
-	INIT_LIST_HEAD(&adapter->inflight);
 	spin_lock_init(&adapter->error_list_lock);
-	spin_lock_init(&adapter->inflight_lock);
 
 	rc = ibmvnic_init(adapter);
 	if (rc) {
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 1b404ca..8fbe05d 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -913,11 +913,6 @@ struct ibmvnic_error_buff {
 	__be32 error_id;
 };
 
-struct ibmvnic_inflight_cmd {
-	union ibmvnic_crq crq;
-	struct list_head list;
-};
-
 struct ibmvnic_adapter {
 	struct vio_dev *vdev;
 	struct net_device *netdev;
@@ -978,10 +973,6 @@ struct ibmvnic_adapter {
 
 	struct completion fw_done;
 
-	/* in-flight commands that allocate and/or map memory*/
-	struct list_head inflight;
-	spinlock_t inflight_lock;
-
 	/* partner capabilities */
 	u64 min_tx_queues;
 	u64 min_rx_queues;

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

* [PATCH net-next 07/10] ibmvnic: Correct crq and resource releasing
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (5 preceding siblings ...)
  2017-04-19 17:44 ` [PATCH net-next 06/10] ibmvnic: Remove inflight list Nathan Fontenot
@ 2017-04-19 17:45 ` Nathan Fontenot
  2017-04-19 17:45 ` [PATCH net-next 08/10] ibmvnic: Disable irq prior to close Nathan Fontenot
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:45 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

We should not be releasing the crq's when calling close for the
adapter, these need to remain open to facilitate operations such
as updating the mac address. The crq's should be released in the
adpaters remove routine.

Additionally, we need to call release_reources from remove. This
corrects the scenario of trying to remove an adapter that has only
been probed.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 18673e2..a8b3c57 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -601,9 +601,6 @@ static void release_resources(struct ibmvnic_adapter *adapter)
 	release_tx_pools(adapter);
 	release_rx_pools(adapter);
 
-	release_sub_crqs(adapter);
-	release_crq_queue(adapter);
-
 	release_stats_token(adapter);
 	release_error_buffers(adapter);
 }
@@ -3300,8 +3297,14 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
 static int ibmvnic_remove(struct vio_dev *dev)
 {
 	struct net_device *netdev = dev_get_drvdata(&dev->dev);
+	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
 
 	unregister_netdev(netdev);
+
+	release_resources(adapter);
+	release_sub_crqs(adapter);
+	release_crq_queue(adapter);
+
 	free_netdev(netdev);
 	dev_set_drvdata(&dev->dev, NULL);
 

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

* [PATCH net-next 08/10] ibmvnic: Disable irq prior to close
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (6 preceding siblings ...)
  2017-04-19 17:45 ` [PATCH net-next 07/10] ibmvnic: Correct crq and resource releasing Nathan Fontenot
@ 2017-04-19 17:45 ` Nathan Fontenot
  2017-04-19 17:45 ` [PATCH net-next 09/10] ibmvnic: Allocate zero-filled memory for sub crqs Nathan Fontenot
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:45 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

From: Brian King <brking@linux.vnet.ibm.com>

    Add some code to call disable_irq on all the vnic interface's irqs.
    This fixes a crash observed when closing an active interface, as
    seen in the oops below when we try to access a buffer in the interrupt
    handler which we've already freed.

    Unable to handle kernel paging request for data at address 0x00000001
    Faulting instruction address: 0xd000000003886824
    Oops: Kernel access of bad area, sig: 11 [#1]
    SMP NR_CPUS=2048 NUMA pSeries
    Modules linked in: ibmvnic(OEN) rpadlpar_io(X) rpaphp(X) tcp_diag udp_diag inet_diag unix_diag af_packet_diag netlink_diag rpcsec_
    Supported: No, Unsupported modules are loaded
    CPU: 8 PID: 0 Comm: swapper/8 Tainted: G           OE   NX 4.4.49-92.11-default #1
    task: c00000007f990110 ti: c0000000fffa0000 task.ti: c00000007f9b8000
    NIP: d000000003886824 LR: d000000003886824 CTR: c0000000007eff60
    REGS: c0000000fffa3a70 TRAP: 0300   Tainted: G           OE   NX  (4.4.49-92.11-default)
    MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE>  CR: 22008042  XER: 20000008
    CFAR: c000000000008468 DAR: 0000000000000001 DSISR: 40000000 SOFTE: 0
    GPR00: d000000003886824 c0000000fffa3cf0 d000000003894118 0000000000000000
    GPR04: 0000000000000000 0000000000000000 c000000001249da0 0000000000000000
    GPR08: 000000000000000e 0000000000000000 c0000000ccb00000 d000000003889180
    GPR12: c0000000007eff60 c000000007af4c00 0000000000000001 c0000000010def30
    GPR16: c00000007f9b8000 c000000000b98c30 c00000007f9b8080 c000000000bab858
    GPR20: 0000000000000005 0000000000000000 c0000000ff5d7e80 c0000000f809f648
    GPR24: c0000000ff5d7ec8 0000000000000000 0000000000000000 c0000000ccb001a0
    GPR28: 000000000000000a c0000000f809f600 c0000000fd4cd900 c0000000f9cd5b00
    NIP [d000000003886824] ibmvnic_interrupt_tx+0x114/0x380 [ibmvnic]
    LR [d000000003886824] ibmvnic_interrupt_tx+0x114/0x380 [ibmvnic]
    Call Trace:
    [c0000000fffa3cf0] [d000000003886824] ibmvnic_interrupt_tx+0x114/0x380 [ibmvnic] (unreliable)
    [c0000000fffa3dd0] [c000000000132940] __handle_irq_event_percpu+0x90/0x2e0
    [c0000000fffa3e90] [c000000000132bcc] handle_irq_event_percpu+0x3c/0x90
    [c0000000fffa3ed0] [c000000000132c88] handle_irq_event+0x68/0xc0
    [c0000000fffa3f00] [c000000000137edc] handle_fasteoi_irq+0xec/0x250
    [c0000000fffa3f30] [c000000000131b04] generic_handle_irq+0x54/0x80
    [c0000000fffa3f60] [c000000000011190] __do_irq+0x80/0x1d0
    [c0000000fffa3f90] [c0000000000248d8] call_do_irq+0x14/0x24
    [c00000007f9bb9e0] [c000000000011380] do_IRQ+0xa0/0x120
    [c00000007f9bba40] [c000000000002594] hardware_interrupt_common+0x114/0x180

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a8b3c57..ce8b147 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -689,6 +689,23 @@ static int ibmvnic_open(struct net_device *netdev)
 	return -ENOMEM;
 }
 
+static void disable_sub_crqs(struct ibmvnic_adapter *adapter)
+{
+	int i;
+
+	if (adapter->tx_scrq) {
+		for (i = 0; i < adapter->req_tx_queues; i++)
+			if (adapter->tx_scrq[i])
+				disable_irq(adapter->tx_scrq[i]->irq);
+	}
+
+	if (adapter->rx_scrq) {
+		for (i = 0; i < adapter->req_rx_queues; i++)
+			if (adapter->rx_scrq[i])
+				disable_irq(adapter->rx_scrq[i]->irq);
+	}
+}
+
 static int ibmvnic_close(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -696,6 +713,7 @@ static int ibmvnic_close(struct net_device *netdev)
 	int i;
 
 	adapter->closing = true;
+	disable_sub_crqs(adapter);
 
 	for (i = 0; i < adapter->req_rx_queues; i++)
 		napi_disable(&adapter->napi[i]);

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

* [PATCH net-next 09/10] ibmvnic: Allocate zero-filled memory for sub crqs
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (7 preceding siblings ...)
  2017-04-19 17:45 ` [PATCH net-next 08/10] ibmvnic: Disable irq prior to close Nathan Fontenot
@ 2017-04-19 17:45 ` Nathan Fontenot
  2017-04-19 17:45 ` [PATCH net-next 10/10] ibmvnic: Remove unused bouce buffer Nathan Fontenot
  2017-04-21 17:45 ` [PATCH net-next 00/10] ibmvnic: Updates and bug fixes David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:45 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

Update the allocation of memory for the sub crq structs and their
associated pages to allocate zero-filled memory.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index ce8b147..221d652 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1360,12 +1360,12 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
 	struct ibmvnic_sub_crq_queue *scrq;
 	int rc;
 
-	scrq = kmalloc(sizeof(*scrq), GFP_ATOMIC);
+	scrq = kzalloc(sizeof(*scrq), GFP_ATOMIC);
 	if (!scrq)
 		return NULL;
 
-	scrq->msgs = (union sub_crq *)__get_free_pages(GFP_ATOMIC, 2);
-	memset(scrq->msgs, 0, 4 * PAGE_SIZE);
+	scrq->msgs =
+		(union sub_crq *)__get_free_pages(GFP_ATOMIC | __GFP_ZERO, 2);
 	if (!scrq->msgs) {
 		dev_warn(dev, "Couldn't allocate crq queue messages page\n");
 		goto zero_page_failed;
@@ -1393,9 +1393,6 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
 
 	scrq->adapter = adapter;
 	scrq->size = 4 * PAGE_SIZE / sizeof(*scrq->msgs);
-	scrq->cur = 0;
-	atomic_set(&scrq->used, 0);
-	scrq->rx_skb_top = NULL;
 	spin_lock_init(&scrq->lock);
 
 	netdev_dbg(adapter->netdev,

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

* [PATCH net-next 10/10] ibmvnic: Remove unused bouce buffer
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (8 preceding siblings ...)
  2017-04-19 17:45 ` [PATCH net-next 09/10] ibmvnic: Allocate zero-filled memory for sub crqs Nathan Fontenot
@ 2017-04-19 17:45 ` Nathan Fontenot
  2017-04-21 17:45 ` [PATCH net-next 00/10] ibmvnic: Updates and bug fixes David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: Nathan Fontenot @ 2017-04-19 17:45 UTC (permalink / raw)
  To: netdev; +Cc: brking, jallen, muvic, tlfalcon

The bounce buffer is not used in the ibmvnic driver, just
get rid of it.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   53 ------------------------------------
 drivers/net/ethernet/ibm/ibmvnic.h |    4 ---
 2 files changed, 57 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 221d652..e8c72ab 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -502,50 +502,6 @@ static int init_tx_pools(struct net_device *netdev)
 	return 0;
 }
 
-static void release_bounce_buffer(struct ibmvnic_adapter *adapter)
-{
-	struct device *dev = &adapter->vdev->dev;
-
-	if (!adapter->bounce_buffer)
-		return;
-
-	if (!dma_mapping_error(dev, adapter->bounce_buffer_dma)) {
-		dma_unmap_single(dev, adapter->bounce_buffer_dma,
-				 adapter->bounce_buffer_size,
-				 DMA_BIDIRECTIONAL);
-		adapter->bounce_buffer_dma = DMA_ERROR_CODE;
-	}
-
-	kfree(adapter->bounce_buffer);
-	adapter->bounce_buffer = NULL;
-}
-
-static int init_bounce_buffer(struct net_device *netdev)
-{
-	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
-	struct device *dev = &adapter->vdev->dev;
-	char *buf;
-	int buf_sz;
-	dma_addr_t map_addr;
-
-	buf_sz = (netdev->mtu + ETH_HLEN - 1) / PAGE_SIZE + 1;
-	buf = kmalloc(adapter->bounce_buffer_size, GFP_KERNEL);
-	if (!buf)
-		return -1;
-
-	map_addr = dma_map_single(dev, buf, buf_sz, DMA_TO_DEVICE);
-	if (dma_mapping_error(dev, map_addr)) {
-		dev_err(dev, "Couldn't map bounce buffer\n");
-		kfree(buf);
-		return -1;
-	}
-
-	adapter->bounce_buffer = buf;
-	adapter->bounce_buffer_size = buf_sz;
-	adapter->bounce_buffer_dma = map_addr;
-	return 0;
-}
-
 static void release_error_buffers(struct ibmvnic_adapter *adapter)
 {
 	struct device *dev = &adapter->vdev->dev;
@@ -597,7 +553,6 @@ static int ibmvnic_login(struct net_device *netdev)
 
 static void release_resources(struct ibmvnic_adapter *adapter)
 {
-	release_bounce_buffer(adapter);
 	release_tx_pools(adapter);
 	release_rx_pools(adapter);
 
@@ -656,10 +611,6 @@ static int ibmvnic_open(struct net_device *netdev)
 	if (rc)
 		goto ibmvnic_open_fail;
 
-	rc = init_bounce_buffer(netdev);
-	if (rc)
-		goto ibmvnic_open_fail;
-
 	replenish_pools(adapter);
 
 	/* We're ready to receive frames, enable the sub-crq interrupts and
@@ -880,7 +831,6 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 	unsigned int tx_bytes = 0;
 	dma_addr_t data_dma_addr;
 	struct netdev_queue *txq;
-	bool used_bounce = false;
 	unsigned long lpar_rc;
 	union sub_crq tx_crq;
 	unsigned int offset;
@@ -921,7 +871,6 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 	tx_buff->index = index;
 	tx_buff->pool_index = queue_num;
 	tx_buff->last_frag = true;
-	tx_buff->used_bounce = used_bounce;
 
 	memset(&tx_crq, 0, sizeof(tx_crq));
 	tx_crq.v1.first = IBMVNIC_CRQ_CMD;
@@ -1517,7 +1466,6 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
 					continue;
 
 				txbuff->data_dma[j] = 0;
-				txbuff->used_bounce = false;
 			}
 			/* if sub_crq was sent indirectly */
 			first = txbuff->indir_arr[0].generic.first;
@@ -3343,7 +3291,6 @@ static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
 	adapter = netdev_priv(netdev);
 
 	ret += PAGE_SIZE; /* the crq message queue */
-	ret += adapter->bounce_buffer_size;
 	ret += IOMMU_PAGE_ALIGN(sizeof(struct ibmvnic_statistics), tbl);
 
 	for (i = 0; i < adapter->req_tx_queues + adapter->req_rx_queues; i++)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 8fbe05d..355225c 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -868,7 +868,6 @@ struct ibmvnic_tx_buff {
 	int index;
 	int pool_index;
 	bool last_frag;
-	bool used_bounce;
 	union sub_crq indir_arr[6];
 	u8 hdr_data[140];
 	dma_addr_t indir_dma;
@@ -924,9 +923,6 @@ struct ibmvnic_adapter {
 	dma_addr_t ip_offload_ctrl_tok;
 	bool migrated;
 	u32 msg_enable;
-	void *bounce_buffer;
-	int bounce_buffer_size;
-	dma_addr_t bounce_buffer_dma;
 
 	/* Statistics */
 	struct ibmvnic_statistics stats;

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

* Re: [PATCH net-next 00/10] ibmvnic: Updates and bug fixes
  2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
                   ` (9 preceding siblings ...)
  2017-04-19 17:45 ` [PATCH net-next 10/10] ibmvnic: Remove unused bouce buffer Nathan Fontenot
@ 2017-04-21 17:45 ` David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2017-04-21 17:45 UTC (permalink / raw)
  To: nfont; +Cc: netdev, brking, jallen, muvic, tlfalcon

From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Date: Wed, 19 Apr 2017 13:44:22 -0400

> This set of patches is a series of updates to remove some unneeded
> and unused code in the driver as well as bug fixes for the
> ibmvnic driver.

Series applied, thanks.

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

end of thread, other threads:[~2017-04-21 18:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 17:44 [PATCH net-next 00/10] ibmvnic: Updates and bug fixes Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 01/10] ibmvnic: Report errors when failing to release sub-crqs Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 02/10] ibmvnic: Fix ibmvnic_change_mac_addr struct format Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 03/10] ibmvnic: Unmap longer term buffer before free Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 04/10] ibmvnic: Fixup atomic API usage Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 05/10] ibmvnic: Do not disable IRQ after scheduling tasklet Nathan Fontenot
2017-04-19 17:44 ` [PATCH net-next 06/10] ibmvnic: Remove inflight list Nathan Fontenot
2017-04-19 17:45 ` [PATCH net-next 07/10] ibmvnic: Correct crq and resource releasing Nathan Fontenot
2017-04-19 17:45 ` [PATCH net-next 08/10] ibmvnic: Disable irq prior to close Nathan Fontenot
2017-04-19 17:45 ` [PATCH net-next 09/10] ibmvnic: Allocate zero-filled memory for sub crqs Nathan Fontenot
2017-04-19 17:45 ` [PATCH net-next 10/10] ibmvnic: Remove unused bouce buffer Nathan Fontenot
2017-04-21 17:45 ` [PATCH net-next 00/10] ibmvnic: Updates and bug fixes David Miller

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.