Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / staging / rtl8723au / hal / rtl8723a_sreset.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  ******************************************************************************/
15 #define _RTL8723A_SRESET_C_
16
17 #include <rtl8723a_sreset.h>
18 #include <rtl8723a_hal.h>
19 #include <usb_ops_linux.h>
20
21 void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter)
22 {
23         struct hal_data_8723a   *pHalData = GET_HAL_DATA(padapter);
24         struct sreset_priv *psrtpriv = &pHalData->srestpriv;
25
26         unsigned long current_time;
27         struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
28         unsigned int diff_time;
29         u32 txdma_status;
30
31         txdma_status = rtl8723au_read32(padapter, REG_TXDMA_STATUS);
32         if (txdma_status != 0) {
33                 DBG_8723A("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status);
34                 rtw_sreset_reset(padapter);
35         }
36
37         current_time = jiffies;
38
39         if (0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {
40
41                 diff_time = jiffies_to_msecs(jiffies - psrtpriv->last_tx_time);
42
43                 if (diff_time > 2000) {
44                         if (psrtpriv->last_tx_complete_time == 0) {
45                                 psrtpriv->last_tx_complete_time = current_time;
46                         } else {
47                                 diff_time = jiffies_to_msecs(jiffies - psrtpriv->last_tx_complete_time);
48                                 if (diff_time > 4000) {
49                                         DBG_8723A("%s tx hang\n", __func__);
50                                         rtw_sreset_reset(padapter);
51                                 }
52                         }
53                 }
54         }
55 }