Commit 8c53e42d authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: failure case handling for PCIe events

Event buffers for PCIe interface are allocated during driver
initialisation, and respective physical addresses are sent to FW
in *_PCIE_DESC_DETAILS command so that FW can do DMA. These buffers
will be freed while unloading the driver. Therefore we should not
free them in event handling error path. Also we should skip next
pending events in failure case.

Also fixed 'returning -1 instead of -ENOMEM is sloppy' warnings.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b0327ffa
...@@ -386,7 +386,7 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) ...@@ -386,7 +386,7 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter)
card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL);
if (!card->txbd_ring_vbase) { if (!card->txbd_ring_vbase) {
dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n");
return -1; return -ENOMEM;
} }
card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase);
...@@ -476,7 +476,7 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) ...@@ -476,7 +476,7 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter)
if (!card->rxbd_ring_vbase) { if (!card->rxbd_ring_vbase) {
dev_err(adapter->dev, "Unable to allocate buffer for " dev_err(adapter->dev, "Unable to allocate buffer for "
"rxbd_ring.\n"); "rxbd_ring.\n");
return -1; return -ENOMEM;
} }
card->rxbd_ring_pbase = virt_to_phys(card->rxbd_ring_vbase); card->rxbd_ring_pbase = virt_to_phys(card->rxbd_ring_vbase);
...@@ -569,7 +569,7 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) ...@@ -569,7 +569,7 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter)
if (!card->evtbd_ring_vbase) { if (!card->evtbd_ring_vbase) {
dev_err(adapter->dev, "Unable to allocate buffer. " dev_err(adapter->dev, "Unable to allocate buffer. "
"Terminating download\n"); "Terminating download\n");
return -1; return -ENOMEM;
} }
card->evtbd_ring_pbase = virt_to_phys(card->evtbd_ring_vbase); card->evtbd_ring_pbase = virt_to_phys(card->evtbd_ring_vbase);
...@@ -1231,15 +1231,13 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, ...@@ -1231,15 +1231,13 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
if (rdptr >= MWIFIEX_MAX_EVT_BD) { if (rdptr >= MWIFIEX_MAX_EVT_BD) {
dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n",
rdptr); rdptr);
ret = -EINVAL; return -EINVAL;
goto done;
} }
/* Read the event ring write pointer set by firmware */ /* Read the event ring write pointer set by firmware */
if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) {
dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_WRPTR\n"); dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_WRPTR\n");
ret = -1; return -1;
goto done;
} }
if (!card->evt_buf_list[rdptr]) { if (!card->evt_buf_list[rdptr]) {
...@@ -1268,15 +1266,9 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, ...@@ -1268,15 +1266,9 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
/* Write the event ring read pointer in to REG_EVTBD_RDPTR */ /* Write the event ring read pointer in to REG_EVTBD_RDPTR */
if (mwifiex_write_reg(adapter, REG_EVTBD_RDPTR, card->evtbd_rdptr)) { if (mwifiex_write_reg(adapter, REG_EVTBD_RDPTR, card->evtbd_rdptr)) {
dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_RDPTR\n"); dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_RDPTR\n");
ret = -1; return -1;
goto done;
} }
done:
/* Free the buffer for failure case */
if (ret && skb)
dev_kfree_skb_any(skb);
dev_dbg(adapter->dev, "info: Check Events Again\n"); dev_dbg(adapter->dev, "info: Check Events Again\n");
ret = mwifiex_pcie_process_event_ready(adapter); ret = mwifiex_pcie_process_event_ready(adapter);
......
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