Skip to contentSkip to conversation

ath9k: Move rate control alg register/unregister to appropriate place

PATCH New Vasanthakumar Thiagarajan 1 participant 3 messages Dec 15, 2008 – Dec 16, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: Move rate control alg register/unregister to appropriate place

This patch makes sure the rate control alg is registered/unregistered only once for this module.

---
 drivers/net/wireless/ath9k/main.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/ath9k/main.c +13 -10
index 05416db..6376fdf 100644
@@ -1231,9 +1231,6 @@ static void ath_detach(struct ath_softc *sc)
 	ath_deinit_leds(sc);
 
 	ieee80211_unregister_hw(hw);
-
-	ath_rate_control_unregister();
-
 	ath_rx_cleanup(sc);
 	ath_tx_cleanup(sc);
 
@@ -1520,13 +1517,6 @@ static int ath_attach(u16 devid, struct ath_softc *sc)
 
 	/* Register rate control */
 	hw->rate_control_algorithm = "ath9k_rate_control";
-	error = ath_rate_control_register();
-	if (error != 0) {
-		DPRINTF(sc, ATH_DBG_FATAL,
-			"Unable to register rate control algorithm: %d\n", error);
-		ath_rate_control_unregister();
-		goto bad;
-	}
 
 	if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) {
 		setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
@@ -2727,8 +2717,20 @@ static struct pci_driver ath_pci_driver = {
 
 static int __init init_ath_pci(void)
 {
+	int error;
+
 	printk(KERN_INFO "%s: %s\n", dev_info, ATH_PCI_VERSION);
 
+	/* Register rate control algorithm */
+	error = ath_rate_control_register();
+	if (error != 0) {
+		printk(KERN_ERR
+			"Unable to register rate control algorithm: %d\n",
+			error);
+		ath_rate_control_unregister();
+		return -EIO;
+	}
+
 	if (pci_register_driver(&ath_pci_driver) < 0) {
 		printk(KERN_ERR
 			"ath_pci: No devices found, driver not installed.\n");
@@ -2742,6 +2744,7 @@ module_init(init_ath_pci);
 
 static void __exit exit_ath_pci(void)
 {
+	ath_rate_control_unregister();
 	pci_unregister_driver(&ath_pci_driver);
 	printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }
Signature · 1 line
1.5.5.1
#1 lore raw

PATCH 1/1 ath9k: Synchronize DMA transfer with CPU at right place

This patch does pci_dma_sync_single_for_cpu() before accessing the header of the frame and queueing the same buffer into h/w.

---
 drivers/net/wireless/ath9k/recv.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/wireless/ath9k/recv.c +10 -4
index 6a91d04..6f81feb 100644
@@ -525,6 +525,15 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 			continue;
 
 		/*
+		 * Synchronize the DMA transfer with CPU before
+		 * 1. accessing the frame
+		 * 2. requeueing the same buffer to h/w
+		 */
+		pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
+				sc->rx.bufsize,
+				PCI_DMA_FROMDEVICE);
+
+		/*
 		 * If we're asked to flush receive queue, directly
 		 * chain it back at the queue without processing it.
 		 */
@@ -558,10 +567,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 		if (!requeue_skb)
 			goto requeue;
 
-		/* Sync and unmap the frame */
-		pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
-					    sc->rx.bufsize,
-					    PCI_DMA_FROMDEVICE);
+		/* Unmap the frame */
 		pci_unmap_single(sc->pdev, bf->bf_buf_addr,
 				 sc->rx.bufsize,
 				 PCI_DMA_FROMDEVICE);
Signature · 1 line
1.5.5.1
#2 lore raw

PATCH 1/1 ath9k: Move rate control alg register/unregister to appropriate place

In reply to Vasanthakumar Thiagarajan
Quoted 58 lines · Vasanth Thiagarajan

This patch makes sure the rate control alg is registered/unregistered only once for this module.

---
 drivers/net/wireless/ath9k/main.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/ath9k/main.c +12 -10
index 05416db..6376fdf 100644
@@ -1231,9 +1231,6 @@ static void ath_detach(struct ath_softc *sc)
        ath_deinit_leds(sc);
 
        ieee80211_unregister_hw(hw);
-
-       ath_rate_control_unregister();
-
        ath_rx_cleanup(sc);
        ath_tx_cleanup(sc);
 
@@ -1520,13 +1517,6 @@ static int ath_attach(u16 devid, struct ath_softc *sc)
 
        /* Register rate control */
        hw->rate_control_algorithm = "ath9k_rate_control";
-       error = ath_rate_control_register();
-       if (error != 0) {
-               DPRINTF(sc, ATH_DBG_FATAL,
-                       "Unable to register rate control algorithm: %d\n", error);
-               ath_rate_control_unregister();
-               goto bad;
-       }
 
        if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) {
                setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
@@ -2727,8 +2717,20 @@ static struct pci_driver ath_pci_driver = {
 
 static int __init init_ath_pci(void)
 {
+       int error;
+
        printk(KERN_INFO "%s: %s\n", dev_info, ATH_PCI_VERSION);
 
+       /* Register rate control algorithm */
+       error = ath_rate_control_register();
+       if (error != 0) {
+               printk(KERN_ERR
+                       "Unable to register rate control algorithm: %d\n",
+                       error);
+               ath_rate_control_unregister();
+               return -EIO;
+       }
+
        if (pci_register_driver(&ath_pci_driver) < 0) {
                printk(KERN_ERR
                        "ath_pci: No devices found, driver not installed.\n");

drivers/net/wireless/ath9k/main.c module_init(init_ath_pci); · line 2750

Quoted 7 lines
drivers/net/wireless/ath9k/main.c +1 -0
@@ -2742,6 +2744,7 @@ module_init(init_ath_pci);
 
 static void __exit exit_ath_pci(void)
 {
+       ath_rate_control_unregister();
        pci_unregister_driver(&ath_pci_driver);
        printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }

Please ignore this patch. This patch does not handle the rate control unregistration when pci_register_driver() fails. I will be sending out a more cleaner patch.

Thanks,

Vasanth