ath9k_htc: Protect RX stream variables

Use a spin lock to prevent concurrent access
to variables dealing with RX stream mode handling.
Currently, no protection is implemented - which
causes problems in RX.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Sujith 2010-04-06 15:28:11 +05:30 коммит произвёл John W. Linville
Родитель 62c33447fa
Коммит 46baa1a249
2 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -330,6 +330,8 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
u16 pkt_len, pkt_tag, pool_index = 0; u16 pkt_len, pkt_tag, pool_index = 0;
u8 *ptr; u8 *ptr;
spin_lock(&hif_dev->rx_lock);
rx_remain_len = hif_dev->rx_remain_len; rx_remain_len = hif_dev->rx_remain_len;
rx_pkt_len = hif_dev->rx_transfer_len; rx_pkt_len = hif_dev->rx_transfer_len;
@ -356,6 +358,8 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
} }
} }
spin_unlock(&hif_dev->rx_lock);
while (index < len) { while (index < len) {
ptr = (u8 *) skb->data; ptr = (u8 *) skb->data;
@ -373,6 +377,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
index = index + 4 + pkt_len + pad_len; index = index + 4 + pkt_len + pad_len;
if (index > MAX_RX_BUF_SIZE) { if (index > MAX_RX_BUF_SIZE) {
spin_lock(&hif_dev->rx_lock);
hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE; hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;
hif_dev->rx_transfer_len = hif_dev->rx_transfer_len =
MAX_RX_BUF_SIZE - chk_idx - 4; MAX_RX_BUF_SIZE - chk_idx - 4;
@ -384,6 +389,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
dev_err(&hif_dev->udev->dev, dev_err(&hif_dev->udev->dev,
"ath9k_htc: RX memory allocation" "ath9k_htc: RX memory allocation"
" error\n"); " error\n");
spin_unlock(&hif_dev->rx_lock);
goto err; goto err;
} }
skb_reserve(nskb, 32); skb_reserve(nskb, 32);
@ -394,6 +400,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
/* Record the buffer pointer */ /* Record the buffer pointer */
hif_dev->remain_skb = nskb; hif_dev->remain_skb = nskb;
spin_unlock(&hif_dev->rx_lock);
} else { } else {
nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC); nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
if (!nskb) { if (!nskb) {
@ -612,6 +619,7 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
int i, ret; int i, ret;
init_usb_anchor(&hif_dev->rx_submitted); init_usb_anchor(&hif_dev->rx_submitted);
spin_lock_init(&hif_dev->rx_lock);
for (i = 0; i < MAX_RX_URB_NUM; i++) { for (i = 0; i < MAX_RX_URB_NUM; i++) {

Просмотреть файл

@ -93,6 +93,7 @@ struct hif_device_usb {
int rx_pkt_len; int rx_pkt_len;
int rx_transfer_len; int rx_transfer_len;
int rx_pad_len; int rx_pad_len;
spinlock_t rx_lock;
u8 flags; /* HIF_USB_* */ u8 flags; /* HIF_USB_* */
}; };