aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorCindy H Kao <cindy.h.kao@intel.com>2010-04-23 20:19:06 -0400
committerInaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>2010-05-11 17:05:55 -0400
commitd94401742dc662747db5bb9e444d353a4feba018 (patch)
tree1fa229f7d23b09b7b4c4e0262ed8e4e232876c26 /drivers
parent2354161dd33b204d36caa0bc48c95cc6c1a984fb (diff)
wimax/i2400m: Reset the TX FIFO indices when allocating the TX FIFO in tx_setup()
This patch makes sure whenever tx_setup() is invoked during driver initialization or device reset where TX FIFO is released and re-allocated, the indices tx_in, tx_out, tx_msg_size, tx_sequence, tx_msg are properly initialized. When a device reset happens and the TX FIFO is released/re-allocated, a new block of memory may be allocated for the TX FIFO, therefore tx_msg should be cleared so that no any TX threads (tx_worker, tx) would access to the out-of-date addresses. Also, the TX threads use tx_in and tx_out to decide where to put the new host-to-device messages and from where to copy them to the device HW FIFO, these indices have to be cleared so after the TX FIFO is re-allocated during the reset, the indices both refer to the head of the FIFO, ie. a new start. The same rational applies to tx_msg_size and tx_sequence. To protect the indices from being accessed by multiple threads simultaneously, the lock tx_lock has to be obtained before the initializations and released afterwards. Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wimax/i2400m/tx.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/net/wimax/i2400m/tx.c b/drivers/net/wimax/i2400m/tx.c
index 8561c0766535..21909e5d2010 100644
--- a/drivers/net/wimax/i2400m/tx.c
+++ b/drivers/net/wimax/i2400m/tx.c
@@ -877,27 +877,40 @@ EXPORT_SYMBOL_GPL(i2400m_tx_msg_sent);
877 * i2400m_tx_setup - Initialize the TX queue and infrastructure 877 * i2400m_tx_setup - Initialize the TX queue and infrastructure
878 * 878 *
879 * Make sure we reset the TX sequence to zero, as when this function 879 * Make sure we reset the TX sequence to zero, as when this function
880 * is called, the firmware has been just restarted. 880 * is called, the firmware has been just restarted. Same rational
881 * for tx_in, tx_out, tx_msg_size and tx_msg. We reset them since
882 * the memory for TX queue is reallocated.
881 */ 883 */
882int i2400m_tx_setup(struct i2400m *i2400m) 884int i2400m_tx_setup(struct i2400m *i2400m)
883{ 885{
884 int result; 886 int result = 0;
887 void *tx_buf;
888 unsigned long flags;
885 889
886 /* Do this here only once -- can't do on 890 /* Do this here only once -- can't do on
887 * i2400m_hard_start_xmit() as we'll cause race conditions if 891 * i2400m_hard_start_xmit() as we'll cause race conditions if
888 * the WS was scheduled on another CPU */ 892 * the WS was scheduled on another CPU */
889 INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work); 893 INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work);
890 894
891 i2400m->tx_sequence = 0; 895 tx_buf = kmalloc(I2400M_TX_BUF_SIZE, GFP_ATOMIC);
896 if (tx_buf == NULL) {
897 result = -ENOMEM;
898 goto error_kmalloc;
899 }
900
892 /* Warn if the calculated buffer size exceeds I2400M_TX_BUF_SIZE. */ 901 /* Warn if the calculated buffer size exceeds I2400M_TX_BUF_SIZE. */
893 BUILD_BUG_ON(I2400M_TX_PDU_TOTAL_SIZE > I2400M_TX_BUF_SIZE); 902 BUILD_BUG_ON(I2400M_TX_PDU_TOTAL_SIZE > I2400M_TX_BUF_SIZE);
894 i2400m->tx_buf = kmalloc(I2400M_TX_BUF_SIZE, GFP_KERNEL); 903 spin_lock_irqsave(&i2400m->tx_lock, flags);
895 if (i2400m->tx_buf == NULL) 904 i2400m->tx_sequence = 0;
896 result = -ENOMEM; 905 i2400m->tx_in = 0;
897 else 906 i2400m->tx_out = 0;
898 result = 0; 907 i2400m->tx_msg_size = 0;
908 i2400m->tx_msg = NULL;
909 i2400m->tx_buf = tx_buf;
910 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
899 /* Huh? the bus layer has to define this... */ 911 /* Huh? the bus layer has to define this... */
900 BUG_ON(i2400m->bus_tx_block_size == 0); 912 BUG_ON(i2400m->bus_tx_block_size == 0);
913error_kmalloc:
901 return result; 914 return result;
902 915
903} 916}