소스 검색

[ath9k] Remove broken ath_rxbuf_alloc()

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>
tags/v1.20.1
Michael Brown 8 년 전
부모
커밋
d0bfd830e4
3개의 변경된 파일5개의 추가작업 그리고 70개의 파일을 삭제
  1. 0
    4
      src/drivers/net/ath/ath.h
  2. 5
    7
      src/drivers/net/ath/ath9k/ath9k_recv.c
  3. 0
    59
      src/drivers/net/ath/ath_main.c

+ 0
- 4
src/drivers/net/ath/ath.h 파일 보기

@@ -229,10 +229,6 @@ struct ath_common {
229 229
 	int btcoex_enabled;
230 230
 };
231 231
 
232
-struct io_buffer *ath_rxbuf_alloc(struct ath_common *common,
233
-				u32 len,
234
-				u32 *iob_addr);
235
-
236 232
 void ath_hw_setbssidmask(struct ath_common *common);
237 233
 int ath_hw_keyreset(struct ath_common *common, u16 entry);
238 234
 void ath_hw_cycle_counters_update(struct ath_common *common);

+ 5
- 7
src/drivers/net/ath/ath9k/ath9k_recv.c 파일 보기

@@ -98,7 +98,6 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
98 98
 {
99 99
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
100 100
 	struct io_buffer *iob;
101
-	u32 *iob_addr = NULL;
102 101
 	struct ath_buf *bf;
103 102
 	int error = 0;
104 103
 
@@ -122,15 +121,14 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
122 121
 	}
123 122
 
124 123
 	list_for_each_entry(bf, &sc->rx.rxbuf, list) {
125
-		iob = ath_rxbuf_alloc(common, common->rx_bufsize,
126
-				      iob_addr);
124
+		iob = alloc_iob_raw ( common->rx_bufsize, common->cachelsz, 0 );
127 125
 		if (iob == NULL) {
128 126
 			error = -ENOMEM;
129 127
 			goto err;
130 128
 		}
131 129
 
132 130
 		bf->bf_mpdu = iob;
133
-		bf->bf_buf_addr = *iob_addr;
131
+		bf->bf_buf_addr = virt_to_bus ( iob->data );
134 132
 	}
135 133
 	sc->rx.rxlink = NULL;
136 134
 
@@ -433,7 +431,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
433 431
 {
434 432
 	struct ath_buf *bf;
435 433
 	struct io_buffer *iob = NULL, *requeue_iob;
436
-	u32 *requeue_iob_addr = NULL;
437 434
 	struct ath_hw *ah = sc->sc_ah;
438 435
 	struct ath_common *common = ath9k_hw_common(ah);
439 436
 	/*
@@ -476,7 +473,8 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
476 473
 
477 474
 		/* Ensure we always have an iob to requeue once we are done
478 475
 		 * processing the current buffer's iob */
479
-		requeue_iob = ath_rxbuf_alloc(common, common->rx_bufsize, requeue_iob_addr);
476
+		requeue_iob = alloc_iob_raw ( common->rx_bufsize,
477
+					      common->cachelsz, 0 );
480 478
 
481 479
 		/* If there is no memory we ignore the current RX'd frame,
482 480
 		 * 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)
491 489
 
492 490
 		/* We will now give hardware our shiny new allocated iob */
493 491
 		bf->bf_mpdu = requeue_iob;
494
-		bf->bf_buf_addr = *requeue_iob_addr;
492
+		bf->bf_buf_addr = virt_to_bus ( requeue_iob->data );
495 493
 
496 494
 		/*
497 495
 		 * change the default rx antenna if rx diversity chooses the

+ 0
- 59
src/drivers/net/ath/ath_main.c 파일 보기

@@ -1,59 +0,0 @@
1
-/*
2
- * Copyright (c) 2009 Atheros Communications Inc.
3
- *
4
- * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5
- * Original from Linux kernel 3.0.1
6
- *
7
- * Permission to use, copy, modify, and/or distribute this software for any
8
- * purpose with or without fee is hereby granted, provided that the above
9
- * copyright notice and this permission notice appear in all copies.
10
- *
11
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
- */
19
-
20
-#include <ipxe/io.h>
21
-
22
-#include "ath.h"
23
-
24
-struct io_buffer *ath_rxbuf_alloc(struct ath_common *common,
25
-				u32 len,
26
-				u32 *iob_addr)
27
-{
28
-	struct io_buffer *iob;
29
-	u32 off;
30
-
31
-	/*
32
-	 * Cache-line-align.  This is important (for the
33
-	 * 5210 at least) as not doing so causes bogus data
34
-	 * in rx'd frames.
35
-	 */
36
-
37
-	/* Note: the kernel can allocate a value greater than
38
-	 * what we ask it to give us. We really only need 4 KB as that
39
-	 * is this hardware supports and in fact we need at least 3849
40
-	 * as that is the MAX AMSDU size this hardware supports.
41
-	 * Unfortunately this means we may get 8 KB here from the
42
-	 * kernel... and that is actually what is observed on some
43
-	 * systems :( */
44
-	iob = alloc_iob(len + common->cachelsz - 1);
45
-	if (iob != NULL) {
46
-		*iob_addr = virt_to_bus(iob->data);
47
-		off = ((unsigned long) iob->data) % common->cachelsz;
48
-		if (off != 0)
49
-		{
50
-			iob_reserve(iob, common->cachelsz - off);
51
-			*iob_addr += common->cachelsz - off;
52
-		}
53
-	} else {
54
-		DBG("ath: iobuffer alloc of size %d failed\n", len);
55
-		return NULL;
56
-	}
57
-
58
-	return iob;
59
-}

Loading…
취소
저장