Commit f992887c authored by Nathan Fontenot's avatar Nathan Fontenot Committed by David S. Miller

ibmvnic: Update main crq initialization and release

Update the initialization and release routines for the crq queue so that
we validate the crq queue.

Additionally this updates the naming of the init and release routines
for the crq queue to drop the ibmvnic prefix. This matches the naming
for similar routines in the driver
Signed-off-by: default avatarNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1935299d
...@@ -113,7 +113,7 @@ static void send_login(struct ibmvnic_adapter *adapter); ...@@ -113,7 +113,7 @@ static void send_login(struct ibmvnic_adapter *adapter);
static void send_cap_queries(struct ibmvnic_adapter *adapter); static void send_cap_queries(struct ibmvnic_adapter *adapter);
static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter); static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter);
static int ibmvnic_init(struct ibmvnic_adapter *); static int ibmvnic_init(struct ibmvnic_adapter *);
static void ibmvnic_release_crq_queue(struct ibmvnic_adapter *); static void release_crq_queue(struct ibmvnic_adapter *);
struct ibmvnic_stat { struct ibmvnic_stat {
char name[ETH_GSTRING_LEN]; char name[ETH_GSTRING_LEN];
...@@ -612,7 +612,7 @@ static void ibmvnic_release_resources(struct ibmvnic_adapter *adapter) ...@@ -612,7 +612,7 @@ static void ibmvnic_release_resources(struct ibmvnic_adapter *adapter)
adapter->rx_pool = NULL; adapter->rx_pool = NULL;
release_sub_crqs(adapter); release_sub_crqs(adapter);
ibmvnic_release_crq_queue(adapter); release_crq_queue(adapter);
if (adapter->stats_token) if (adapter->stats_token)
dma_unmap_single(dev, adapter->stats_token, dma_unmap_single(dev, adapter->stats_token,
...@@ -3069,12 +3069,15 @@ static int ibmvnic_reset_crq(struct ibmvnic_adapter *adapter) ...@@ -3069,12 +3069,15 @@ static int ibmvnic_reset_crq(struct ibmvnic_adapter *adapter)
return rc; return rc;
} }
static void ibmvnic_release_crq_queue(struct ibmvnic_adapter *adapter) static void release_crq_queue(struct ibmvnic_adapter *adapter)
{ {
struct ibmvnic_crq_queue *crq = &adapter->crq; struct ibmvnic_crq_queue *crq = &adapter->crq;
struct vio_dev *vdev = adapter->vdev; struct vio_dev *vdev = adapter->vdev;
long rc; long rc;
if (!crq->msgs)
return;
netdev_dbg(adapter->netdev, "Releasing CRQ\n"); netdev_dbg(adapter->netdev, "Releasing CRQ\n");
free_irq(vdev->irq, adapter); free_irq(vdev->irq, adapter);
tasklet_kill(&adapter->tasklet); tasklet_kill(&adapter->tasklet);
...@@ -3085,15 +3088,19 @@ static void ibmvnic_release_crq_queue(struct ibmvnic_adapter *adapter) ...@@ -3085,15 +3088,19 @@ static void ibmvnic_release_crq_queue(struct ibmvnic_adapter *adapter)
dma_unmap_single(&vdev->dev, crq->msg_token, PAGE_SIZE, dma_unmap_single(&vdev->dev, crq->msg_token, PAGE_SIZE,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
free_page((unsigned long)crq->msgs); free_page((unsigned long)crq->msgs);
crq->msgs = NULL;
} }
static int ibmvnic_init_crq_queue(struct ibmvnic_adapter *adapter) static int init_crq_queue(struct ibmvnic_adapter *adapter)
{ {
struct ibmvnic_crq_queue *crq = &adapter->crq; struct ibmvnic_crq_queue *crq = &adapter->crq;
struct device *dev = &adapter->vdev->dev; struct device *dev = &adapter->vdev->dev;
struct vio_dev *vdev = adapter->vdev; struct vio_dev *vdev = adapter->vdev;
int rc, retrc = -ENOMEM; int rc, retrc = -ENOMEM;
if (crq->msgs)
return 0;
crq->msgs = (union ibmvnic_crq *)get_zeroed_page(GFP_KERNEL); crq->msgs = (union ibmvnic_crq *)get_zeroed_page(GFP_KERNEL);
/* Should we allocate more than one page? */ /* Should we allocate more than one page? */
...@@ -3155,6 +3162,7 @@ static int ibmvnic_init_crq_queue(struct ibmvnic_adapter *adapter) ...@@ -3155,6 +3162,7 @@ static int ibmvnic_init_crq_queue(struct ibmvnic_adapter *adapter)
dma_unmap_single(dev, crq->msg_token, PAGE_SIZE, DMA_BIDIRECTIONAL); dma_unmap_single(dev, crq->msg_token, PAGE_SIZE, DMA_BIDIRECTIONAL);
map_failed: map_failed:
free_page((unsigned long)crq->msgs); free_page((unsigned long)crq->msgs);
crq->msgs = NULL;
return retrc; return retrc;
} }
...@@ -3222,7 +3230,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter) ...@@ -3222,7 +3230,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
unsigned long timeout = msecs_to_jiffies(30000); unsigned long timeout = msecs_to_jiffies(30000);
int rc; int rc;
rc = ibmvnic_init_crq_queue(adapter); rc = init_crq_queue(adapter);
if (rc) { if (rc) {
dev_err(dev, "Couldn't initialize crq. rc=%d\n", rc); dev_err(dev, "Couldn't initialize crq. rc=%d\n", rc);
return rc; return rc;
...@@ -3232,7 +3240,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter) ...@@ -3232,7 +3240,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
sizeof(struct ibmvnic_statistics), sizeof(struct ibmvnic_statistics),
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (dma_mapping_error(dev, adapter->stats_token)) { if (dma_mapping_error(dev, adapter->stats_token)) {
ibmvnic_release_crq_queue(adapter); release_crq_queue(adapter);
dev_err(dev, "Couldn't map stats buffer\n"); dev_err(dev, "Couldn't map stats buffer\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -3241,7 +3249,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter) ...@@ -3241,7 +3249,7 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
ibmvnic_send_crq_init(adapter); ibmvnic_send_crq_init(adapter);
if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { if (!wait_for_completion_timeout(&adapter->init_done, timeout)) {
dev_err(dev, "Initialization sequence timed out\n"); dev_err(dev, "Initialization sequence timed out\n");
ibmvnic_release_crq_queue(adapter); release_crq_queue(adapter);
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment