ibmvnic: Move initialization of sub crqs to ibmvnic_init
authorNathan Fontenot <nfont@linux.vnet.ibm.com>
Tue, 25 Apr 2017 19:01:10 +0000 (15:01 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Apr 2017 18:49:15 +0000 (14:49 -0400)
The sub crq structures are initialized in interrupt context while
handling the response to crqs when negotiating capabilities for
the driver. The sub crqs do not need to be initialized at this point
and can be moved to being done from ibmvnic_init. Moving the init
of the sub crqs to ibmvnic_init also allows use to allocate the
memory with GFP_KERNEL instead of GFP_ATOMIC.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ibmvnic.c

index c2e260ce45bbac1b0da8d8fb7c3bc70118d8b16f..4fcd2f0378bad26d91ee2f5c8840dff16cfe836f 100644 (file)
@@ -1390,12 +1390,12 @@ static struct ibmvnic_sub_crq_queue *init_sub_crq_queue(struct ibmvnic_adapter
        struct ibmvnic_sub_crq_queue *scrq;
        int rc;
 
-       scrq = kzalloc(sizeof(*scrq), GFP_ATOMIC);
+       scrq = kzalloc(sizeof(*scrq), GFP_KERNEL);
        if (!scrq)
                return NULL;
 
        scrq->msgs =
-               (union sub_crq *)__get_free_pages(GFP_ATOMIC | __GFP_ZERO, 2);
+               (union sub_crq *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 2);
        if (!scrq->msgs) {
                dev_warn(dev, "Couldn't allocate crq queue messages page\n");
                goto zero_page_failed;
@@ -1689,7 +1689,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
 
        total_queues = adapter->req_tx_queues + adapter->req_rx_queues;
 
-       allqueues = kcalloc(total_queues, sizeof(*allqueues), GFP_ATOMIC);
+       allqueues = kcalloc(total_queues, sizeof(*allqueues), GFP_KERNEL);
        if (!allqueues)
                return -1;
 
@@ -1729,7 +1729,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
        }
 
        adapter->tx_scrq = kcalloc(adapter->req_tx_queues,
-                                  sizeof(*adapter->tx_scrq), GFP_ATOMIC);
+                                  sizeof(*adapter->tx_scrq), GFP_KERNEL);
        if (!adapter->tx_scrq)
                goto tx_failed;
 
@@ -1739,7 +1739,7 @@ static int init_sub_crqs(struct ibmvnic_adapter *adapter)
        }
 
        adapter->rx_scrq = kcalloc(adapter->req_rx_queues,
-                                  sizeof(*adapter->rx_scrq), GFP_ATOMIC);
+                                  sizeof(*adapter->rx_scrq), GFP_KERNEL);
        if (!adapter->rx_scrq)
                goto rx_failed;
 
@@ -1765,7 +1765,6 @@ static void ibmvnic_send_req_caps(struct ibmvnic_adapter *adapter, int retry)
 {
        struct device *dev = &adapter->vdev->dev;
        union ibmvnic_crq crq;
-       int rc;
 
        if (!retry) {
                /* Sub-CRQ entries are 32 byte long */
@@ -1794,10 +1793,6 @@ static void ibmvnic_send_req_caps(struct ibmvnic_adapter *adapter, int retry)
                adapter->req_mtu = adapter->netdev->mtu + ETH_HLEN;
        }
 
-       rc = init_sub_crqs(adapter);
-       if (rc)
-               return;
-
        memset(&crq, 0, sizeof(crq));
        crq.request_capability.first = IBMVNIC_CRQ_CMD;
        crq.request_capability.cmd = REQUEST_CAPABILITY;
@@ -3317,7 +3312,13 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
                return -1;
        }
 
-       return 0;
+       rc = init_sub_crqs(adapter);
+       if (rc) {
+               dev_err(dev, "Initialization of sub crqs failed\n");
+               release_crq_queue(adapter);
+       }
+
+       return rc;
 }
 
 static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)