]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ath9k] Remove broken ath_rxbuf_alloc()
authorMichael Brown <mcb30@ipxe.org>
Thu, 28 Jan 2016 14:15:36 +0000 (14:15 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 28 Jan 2016 14:24:24 +0000 (14:24 +0000)
ath_rx_init() demonstrates some serious confusion over how to use
pointers, resulting in (uint32_t*)NULL being used as a temporary
variable.  This does not end well.

The broken code in question is performing manual alignment of I/O
buffers, which can now be achieved more simply using alloc_iob_raw().
Fix by removing ath_rxbuf_alloc() entirely.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/ath/ath.h
src/drivers/net/ath/ath9k/ath9k_recv.c
src/drivers/net/ath/ath_main.c [deleted file]

index 42ad59f781a8dcf73202857ab0ed0e3d45bce63a..65b97f6aa4596ab7ac786101729985072dc93187 100644 (file)
@@ -229,10 +229,6 @@ struct ath_common {
        int btcoex_enabled;
 };
 
-struct io_buffer *ath_rxbuf_alloc(struct ath_common *common,
-                               u32 len,
-                               u32 *iob_addr);
-
 void ath_hw_setbssidmask(struct ath_common *common);
 int ath_hw_keyreset(struct ath_common *common, u16 entry);
 void ath_hw_cycle_counters_update(struct ath_common *common);
index ba363c676565ffc2f644bfe0d81450bf54e45b2a..0ffe9d45a17059375002faf26cbf304e46085455 100644 (file)
@@ -98,7 +98,6 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
 {
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        struct io_buffer *iob;
-       u32 *iob_addr = NULL;
        struct ath_buf *bf;
        int error = 0;
 
@@ -122,15 +121,14 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
        }
 
        list_for_each_entry(bf, &sc->rx.rxbuf, list) {
-               iob = ath_rxbuf_alloc(common, common->rx_bufsize,
-                                     iob_addr);
+               iob = alloc_iob_raw ( common->rx_bufsize, common->cachelsz, 0 );
                if (iob == NULL) {
                        error = -ENOMEM;
                        goto err;
                }
 
                bf->bf_mpdu = iob;
-               bf->bf_buf_addr = *iob_addr;
+               bf->bf_buf_addr = virt_to_bus ( iob->data );
        }
        sc->rx.rxlink = NULL;
 
@@ -433,7 +431,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
 {
        struct ath_buf *bf;
        struct io_buffer *iob = NULL, *requeue_iob;
-       u32 *requeue_iob_addr = NULL;
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
        /*
@@ -476,7 +473,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
 
                /* Ensure we always have an iob to requeue once we are done
                 * processing the current buffer's iob */
-               requeue_iob = ath_rxbuf_alloc(common, common->rx_bufsize, requeue_iob_addr);
+               requeue_iob = alloc_iob_raw ( common->rx_bufsize,
+                                             common->cachelsz, 0 );
 
                /* If there is no memory we ignore the current RX'd frame,
                 * tell hardware it can give us a new frame using the old
@@ -491,7 +489,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
 
                /* We will now give hardware our shiny new allocated iob */
                bf->bf_mpdu = requeue_iob;
-               bf->bf_buf_addr = *requeue_iob_addr;
+               bf->bf_buf_addr = virt_to_bus ( requeue_iob->data );
 
                /*
                 * change the default rx antenna if rx diversity chooses the
diff --git a/src/drivers/net/ath/ath_main.c b/src/drivers/net/ath/ath_main.c
deleted file mode 100644 (file)
index 85d159a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2009 Atheros Communications Inc.
- *
- * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
- * Original from Linux kernel 3.0.1
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <ipxe/io.h>
-
-#include "ath.h"
-
-struct io_buffer *ath_rxbuf_alloc(struct ath_common *common,
-                               u32 len,
-                               u32 *iob_addr)
-{
-       struct io_buffer *iob;
-       u32 off;
-
-       /*
-        * Cache-line-align.  This is important (for the
-        * 5210 at least) as not doing so causes bogus data
-        * in rx'd frames.
-        */
-
-       /* Note: the kernel can allocate a value greater than
-        * what we ask it to give us. We really only need 4 KB as that
-        * is this hardware supports and in fact we need at least 3849
-        * as that is the MAX AMSDU size this hardware supports.
-        * Unfortunately this means we may get 8 KB here from the
-        * kernel... and that is actually what is observed on some
-        * systems :( */
-       iob = alloc_iob(len + common->cachelsz - 1);
-       if (iob != NULL) {
-               *iob_addr = virt_to_bus(iob->data);
-               off = ((unsigned long) iob->data) % common->cachelsz;
-               if (off != 0)
-               {
-                       iob_reserve(iob, common->cachelsz - off);
-                       *iob_addr += common->cachelsz - off;
-               }
-       } else {
-               DBG("ath: iobuffer alloc of size %d failed\n", len);
-               return NULL;
-       }
-
-       return iob;
-}