2013-09-14 16:10:17

by Mark Cave-Ayland

[permalink] [raw]
Subject: rtl8192cu: notes on investigating power issues

Hi Larry,

I spent some time yesterday evening adding various debugging statements
around the driver to get a feel for what was happening, with some
success. Included below are my notes from testing.

The key appears to be the calculation of the dig (transmitter gain?)
value, for which the function chain looks like this:

1) rtl92c_dm_ctrl_initgain_by_rssi() sets the dig value

This value controls the power output from the transmitter and should lie
between DM_DIG_MIN and DM_DIG_MAX (note the *higher* the number, the
*lower* the power output). Setting the penultimate line to read
"digtable->cur_igvalue = DM_DIG_MIN" appears to force maximum power and
actually gives me a working connection.

Displaying various values in this function showed that the problem was
that I had an exceptionally high value of digtable->rssi_val_min which
was much higher than DM_DIG_MAX and so had the effect of disabling the
radio.

2) rtl92c_dm_dynamic_bb_powersaving() sets digtable->rssi_val_min

This is actually done by a simple assignment "dm_pstable->rssi_val_min =
rtlpriv->dm.undec_sm_pwdb".

3) _rtl92c_process_pwdb() sets rltpriv->dm.undec_sm_pwdb

This value is updated by comparing the existing value with the current
value of pstats->rx_pwdb_all. If there is a difference, then slide the
new value towards pstats->rx_pwdb_all and then use it to update
rltpriv->dm.undec_sm_pwdb.

4) _rtl92c_query_rxphystatus() sets pstats->rx_pwdb_all

pstats->rx_pwdb_all was set to be a percentage conversion of the current
antenna power read from the radio.

What was happening in my case:

1) pstats->rx_pwdb_all was mostly set to 100 (%) due to high signal strength

2) rltpriv->dm.undec_sm_pwdb would then slide towards a high value
(around 0x40-0x4d) within a few seconds

3) Hence digtable->rssi_val_min would tend to hover at around the same level

4) digtable->cur_igvalue would be set to the same high value (> 0x3f or
DM_DIG_MAX), therefore disabling the radio and disconnecting from the AP


Unfortunately I'm not particularly familiar with these types of power
calculations (and there weren't many comments explaining how they
worked), but the one thing that didn't seem right is that
pstats->rx_pwdb_all claims to be a *percentage* and yet
rtl92c_dm_dynamic_bb_powersaving() uses it as the basis to set the
*value* of dm_pstable->rssi_val_min.


ATB,

Mark.