aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500pci.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/rt2500pci.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/rt2500pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index bf5e81162f25..5b98a74a2554 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -639,16 +639,23 @@ static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev,
639 qual->false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA); 639 qual->false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA);
640} 640}
641 641
642static inline void rt2500pci_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level)
643{
644 if (rt2x00dev->link.vgc_level_reg != vgc_level) {
645 rt2500pci_bbp_write(rt2x00dev, 17, vgc_level);
646 rt2x00dev->link.vgc_level_reg = vgc_level;
647 }
648}
649
642static void rt2500pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 650static void rt2500pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
643{ 651{
644 rt2500pci_bbp_write(rt2x00dev, 17, 0x48); 652 rt2500pci_set_vgc(rt2x00dev, 0x48);
645 rt2x00dev->link.vgc_level = 0x48;
646} 653}
647 654
648static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev) 655static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
649{ 656{
650 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link); 657 struct link *link = &rt2x00dev->link;
651 u8 r17; 658 int rssi = rt2x00_get_link_rssi(link);
652 659
653 /* 660 /*
654 * To prevent collisions with MAC ASIC on chipsets 661 * To prevent collisions with MAC ASIC on chipsets
@@ -656,12 +663,9 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
656 * seconds while being associated. 663 * seconds while being associated.
657 */ 664 */
658 if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D && 665 if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D &&
659 rt2x00dev->intf_associated && 666 rt2x00dev->intf_associated && link->count > 20)
660 rt2x00dev->link.count > 20)
661 return; 667 return;
662 668
663 rt2500pci_bbp_read(rt2x00dev, 17, &r17);
664
665 /* 669 /*
666 * Chipset versions C and lower should directly continue 670 * Chipset versions C and lower should directly continue
667 * to the dynamic CCA tuning. Chipset version D and higher 671 * to the dynamic CCA tuning. Chipset version D and higher
@@ -677,11 +681,9 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
677 * then corrupt the R17 tuning. To remidy this the tuning should 681 * then corrupt the R17 tuning. To remidy this the tuning should
678 * be stopped (While making sure the R17 value will not exceed limits) 682 * be stopped (While making sure the R17 value will not exceed limits)
679 */ 683 */
680 if (rssi < -80 && rt2x00dev->link.count > 20) { 684 if (rssi < -80 && link->count > 20) {
681 if (r17 >= 0x41) { 685 if (link->vgc_level_reg >= 0x41)
682 r17 = rt2x00dev->link.vgc_level; 686 rt2500pci_set_vgc(rt2x00dev, link->vgc_level);
683 rt2500pci_bbp_write(rt2x00dev, 17, r17);
684 }
685 return; 687 return;
686 } 688 }
687 689
@@ -689,8 +691,7 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
689 * Special big-R17 for short distance 691 * Special big-R17 for short distance
690 */ 692 */
691 if (rssi >= -58) { 693 if (rssi >= -58) {
692 if (r17 != 0x50) 694 rt2500pci_set_vgc(rt2x00dev, 0x50);
693 rt2500pci_bbp_write(rt2x00dev, 17, 0x50);
694 return; 695 return;
695 } 696 }
696 697
@@ -698,8 +699,7 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
698 * Special mid-R17 for middle distance 699 * Special mid-R17 for middle distance
699 */ 700 */
700 if (rssi >= -74) { 701 if (rssi >= -74) {
701 if (r17 != 0x41) 702 rt2500pci_set_vgc(rt2x00dev, 0x41);
702 rt2500pci_bbp_write(rt2x00dev, 17, 0x41);
703 return; 703 return;
704 } 704 }
705 705
@@ -707,8 +707,8 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
707 * Leave short or middle distance condition, restore r17 707 * Leave short or middle distance condition, restore r17
708 * to the dynamic tuning range. 708 * to the dynamic tuning range.
709 */ 709 */
710 if (r17 >= 0x41) { 710 if (link->vgc_level_reg >= 0x41) {
711 rt2500pci_bbp_write(rt2x00dev, 17, rt2x00dev->link.vgc_level); 711 rt2500pci_set_vgc(rt2x00dev, link->vgc_level);
712 return; 712 return;
713 } 713 }
714 714
@@ -718,12 +718,12 @@ dynamic_cca_tune:
718 * R17 is inside the dynamic tuning range, 718 * R17 is inside the dynamic tuning range,
719 * start tuning the link based on the false cca counter. 719 * start tuning the link based on the false cca counter.
720 */ 720 */
721 if (rt2x00dev->link.qual.false_cca > 512 && r17 < 0x40) { 721 if (link->qual.false_cca > 512 && link->vgc_level_reg < 0x40) {
722 rt2500pci_bbp_write(rt2x00dev, 17, ++r17); 722 rt2500pci_set_vgc(rt2x00dev, ++link->vgc_level_reg);
723 rt2x00dev->link.vgc_level = r17; 723 link->vgc_level = link->vgc_level_reg;
724 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > 0x32) { 724 } else if (link->qual.false_cca < 100 && link->vgc_level_reg > 0x32) {
725 rt2500pci_bbp_write(rt2x00dev, 17, --r17); 725 rt2500pci_set_vgc(rt2x00dev, --link->vgc_level_reg);
726 rt2x00dev->link.vgc_level = r17; 726 link->vgc_level = link->vgc_level_reg;
727 } 727 }
728} 728}
729 729