aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt61pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-12-20 04:54:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:34 -0500
commiteb20b4e8a6998ca68d9ac0963ee36a1a36fe241d (patch)
treecf35161f1f7573f73b9e2da74fc562a77169e459 /drivers/net/wireless/rt2x00/rt61pci.c
parent84e3196ff867c623056eea02c11a45e046490d89 (diff)
rt2x00: Reduce calls to bbp_read()
The link_tuner() function will always call bbp_read() at the start of the function. Because this is an indirect register access has some costs attached to it (especially for USB hardware). We already store the value read from the register into the vgc_level value inside the link structure. Instead of reading from the register we can read that field directly and base the tuner on that value. This reduces the time the registers are locked with the csr_mutex and speeds up the link_tuner processing. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt61pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index c7ab744f0052..94523f7f0d88 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1046,21 +1046,27 @@ static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev,
1046 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); 1046 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
1047} 1047}
1048 1048
1049static inline void rt61pci_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level)
1050{
1051 if (rt2x00dev->link.vgc_level != vgc_level) {
1052 rt61pci_bbp_write(rt2x00dev, 17, vgc_level);
1053 rt2x00dev->link.vgc_level = vgc_level;
1054 rt2x00dev->link.vgc_level_reg = vgc_level;
1055 }
1056}
1057
1049static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 1058static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
1050{ 1059{
1051 rt61pci_bbp_write(rt2x00dev, 17, 0x20); 1060 rt61pci_set_vgc(rt2x00dev, 0x20);
1052 rt2x00dev->link.vgc_level = 0x20;
1053} 1061}
1054 1062
1055static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) 1063static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1056{ 1064{
1057 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link); 1065 struct link *link = &rt2x00dev->link;
1058 u8 r17; 1066 int rssi = rt2x00_get_link_rssi(link);
1059 u8 up_bound; 1067 u8 up_bound;
1060 u8 low_bound; 1068 u8 low_bound;
1061 1069
1062 rt61pci_bbp_read(rt2x00dev, 17, &r17);
1063
1064 /* 1070 /*
1065 * Determine r17 bounds. 1071 * Determine r17 bounds.
1066 */ 1072 */
@@ -1091,8 +1097,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1091 * Special big-R17 for very short distance 1097 * Special big-R17 for very short distance
1092 */ 1098 */
1093 if (rssi >= -35) { 1099 if (rssi >= -35) {
1094 if (r17 != 0x60) 1100 rt61pci_set_vgc(rt2x00dev, 0x60);
1095 rt61pci_bbp_write(rt2x00dev, 17, 0x60);
1096 return; 1101 return;
1097 } 1102 }
1098 1103
@@ -1100,8 +1105,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1100 * Special big-R17 for short distance 1105 * Special big-R17 for short distance
1101 */ 1106 */
1102 if (rssi >= -58) { 1107 if (rssi >= -58) {
1103 if (r17 != up_bound) 1108 rt61pci_set_vgc(rt2x00dev, up_bound);
1104 rt61pci_bbp_write(rt2x00dev, 17, up_bound);
1105 return; 1109 return;
1106 } 1110 }
1107 1111
@@ -1109,9 +1113,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1109 * Special big-R17 for middle-short distance 1113 * Special big-R17 for middle-short distance
1110 */ 1114 */
1111 if (rssi >= -66) { 1115 if (rssi >= -66) {
1112 low_bound += 0x10; 1116 rt61pci_set_vgc(rt2x00dev, low_bound + 0x10);
1113 if (r17 != low_bound)
1114 rt61pci_bbp_write(rt2x00dev, 17, low_bound);
1115 return; 1117 return;
1116 } 1118 }
1117 1119
@@ -1119,9 +1121,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1119 * Special mid-R17 for middle distance 1121 * Special mid-R17 for middle distance
1120 */ 1122 */
1121 if (rssi >= -74) { 1123 if (rssi >= -74) {
1122 low_bound += 0x08; 1124 rt61pci_set_vgc(rt2x00dev, low_bound + 0x08);
1123 if (r17 != low_bound)
1124 rt61pci_bbp_write(rt2x00dev, 17, low_bound);
1125 return; 1125 return;
1126 } 1126 }
1127 1127
@@ -1133,8 +1133,8 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1133 if (low_bound > up_bound) 1133 if (low_bound > up_bound)
1134 up_bound = low_bound; 1134 up_bound = low_bound;
1135 1135
1136 if (r17 > up_bound) { 1136 if (link->vgc_level > up_bound) {
1137 rt61pci_bbp_write(rt2x00dev, 17, up_bound); 1137 rt61pci_set_vgc(rt2x00dev, up_bound);
1138 return; 1138 return;
1139 } 1139 }
1140 1140
@@ -1144,15 +1144,10 @@ dynamic_cca_tune:
1144 * r17 does not yet exceed upper limit, continue and base 1144 * r17 does not yet exceed upper limit, continue and base
1145 * the r17 tuning on the false CCA count. 1145 * the r17 tuning on the false CCA count.
1146 */ 1146 */
1147 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) { 1147 if ((link->qual.false_cca > 512) && (link->vgc_level < up_bound))
1148 if (++r17 > up_bound) 1148 rt61pci_set_vgc(rt2x00dev, ++link->vgc_level);
1149 r17 = up_bound; 1149 else if ((link->qual.false_cca < 100) && (link->vgc_level > low_bound))
1150 rt61pci_bbp_write(rt2x00dev, 17, r17); 1150 rt61pci_set_vgc(rt2x00dev, --link->vgc_level);
1151 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
1152 if (--r17 < low_bound)
1153 r17 = low_bound;
1154 rt61pci_bbp_write(rt2x00dev, 17, r17);
1155 }
1156} 1151}
1157 1152
1158/* 1153/*