From: Arend van Spriel <arend@xxxxxxxxxxxx> The function pkt_buf_get_skb and pkt_buf_free_skb were using struct osl_info field pktalloced to maintain counter of buffers in use in the driver. It was decided to remove this facility. The prototypes of these functions have been modified and the calling code adapted. Reviewed-by: Brett Rudley <brudley@xxxxxxxxxxxx> Reviewed-by: Henry Ptasinski <henryp@xxxxxxxxxxxx> Reviewed-by: Roland Vossen <rvossen@xxxxxxxxxxxx> Signed-off-by: Arend van Spriel <arend@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx> --- drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 8 ++-- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 2 +- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 10 ---- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 47 ++++++++++----------- drivers/staging/brcm80211/brcmsmac/wlc_main.c | 20 ++++----- drivers/staging/brcm80211/include/bcmutils.h | 5 +- drivers/staging/brcm80211/util/bcmutils.c | 12 ++---- drivers/staging/brcm80211/util/hnddma.c | 10 ++-- 8 files changed, 46 insertions(+), 68 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 9b5075e..ef75219 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -1038,7 +1038,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, if (pkt == NULL) { sd_data(("%s: Creating new %s Packet, len=%d\n", __func__, write ? "TX" : "RX", buflen_u)); - mypkt = pkt_buf_get_skb(sd->osh, buflen_u); + mypkt = pkt_buf_get_skb(buflen_u); if (!mypkt) { sd_err(("%s: pkt_buf_get_skb failed: len %d\n", __func__, buflen_u)); @@ -1056,7 +1056,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, if (!write) memcpy(buffer, mypkt->data, buflen_u); - pkt_buf_free_skb(sd->osh, mypkt, write ? true : false); + pkt_buf_free_skb(mypkt); } else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) { /* Case 2: We have a packet, but it is unaligned. */ @@ -1065,7 +1065,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, sd_data(("%s: Creating aligned %s Packet, len=%d\n", __func__, write ? "TX" : "RX", pkt->len)); - mypkt = pkt_buf_get_skb(sd->osh, pkt->len); + mypkt = pkt_buf_get_skb(pkt->len); if (!mypkt) { sd_err(("%s: pkt_buf_get_skb failed: len %d\n", __func__, pkt->len)); @@ -1083,7 +1083,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, if (!write) memcpy(pkt->data, mypkt->data, mypkt->len); - pkt_buf_free_skb(sd->osh, mypkt, write ? true : false); + pkt_buf_free_skb(mypkt); } else { /* case 3: We have a packet and it is aligned. */ sd_data(("%s: Aligned %s Packet, direct DMA\n", diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 2d4a4b3..a80a5c3 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -347,7 +347,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt, ASSERT(p); } - pkt_buf_free_skb(dhdp->osh, p, true); + pkt_buf_free_skb(p); } /* Enqueue */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index 5041510..cd14b12 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -1049,11 +1049,6 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf) static inline void * osl_pkt_frmnative(struct osl_info *osh, struct sk_buff *skb) { - struct sk_buff *nskb; - - for (nskb = skb; nskb; nskb = nskb->next) - osh->pktalloced++; - return (void *)skb; } #define PKTFRMNATIVE(osh, skb) \ @@ -1062,11 +1057,6 @@ osl_pkt_frmnative(struct osl_info *osh, struct sk_buff *skb) static inline struct sk_buff * osl_pkt_tonative(struct osl_info *osh, void *pkt) { - struct sk_buff *nskb; - - for (nskb = (struct sk_buff *)pkt; nskb; nskb = nskb->next) - osh->pktalloced--; - return (struct sk_buff *)pkt; } #define PKTTONATIVE(osh, pkt) \ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index e85d2d2..cd5c083 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -141,7 +141,7 @@ * bufpool was present for gspi bus. */ #define PKTFREE2() if ((bus->bus != SPI_BUS) || bus->usebufpool) \ - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); /* * Conversion of 802.1D priority to precedence level @@ -939,7 +939,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, DHD_INFO(("%s: insufficient headroom %d for %d pad\n", __func__, skb_headroom(pkt), pad)); bus->dhd->tx_realloc++; - new = pkt_buf_get_skb(osh, (pkt->len + DHD_SDALIGN)); + new = pkt_buf_get_skb(pkt->len + DHD_SDALIGN); if (!new) { DHD_ERROR(("%s: couldn't allocate new %d-byte " "packet\n", @@ -951,7 +951,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, PKTALIGN(osh, new, pkt->len, DHD_SDALIGN); memcpy(new->data, pkt->data, pkt->len); if (free_pkt) - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); /* free the pkt if canned one is not used */ free_pkt = true; pkt = new; @@ -1065,7 +1065,7 @@ done: dhd_os_sdlock(bus->dhd); if (free_pkt) - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); return ret; } @@ -1116,7 +1116,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt) if (dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec) == false) { skb_pull(pkt, SDPCM_HDRLEN); dhd_txcomplete(bus->dhd, pkt, false); - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); DHD_ERROR(("%s: out of bus->txq !!!\n", __func__)); ret = BCME_NORESOURCE; } else { @@ -2886,10 +2886,10 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex) /* Clear any held glomming stuff */ if (bus->glomd) - pkt_buf_free_skb(osh, bus->glomd, false); + pkt_buf_free_skb(bus->glomd); if (bus->glom) - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); bus->glom = bus->glomd = NULL; @@ -3188,7 +3188,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) u16 sublen, check; struct sk_buff *pfirst, *plast, *pnext, *save_pfirst; - struct osl_info *osh = bus->dhd->osh; int errcode; u8 chan, seq, doff, sfdoff; @@ -3244,7 +3243,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) } /* Allocate/chain packet for next subframe */ - pnext = pkt_buf_get_skb(osh, sublen + DHD_SDALIGN); + pnext = pkt_buf_get_skb(sublen + DHD_SDALIGN); if (pnext == NULL) { DHD_ERROR(("%s: pkt_buf_get_skb failed, num %d len %d\n", __func__, num, sublen)); @@ -3280,13 +3279,13 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) pfirst = pnext = NULL; } else { if (pfirst) - pkt_buf_free_skb(osh, pfirst, false); + pkt_buf_free_skb(pfirst); bus->glom = NULL; num = 0; } /* Done with descriptor packet */ - pkt_buf_free_skb(osh, bus->glomd, false); + pkt_buf_free_skb(bus->glomd); bus->glomd = NULL; bus->nextlen = 0; @@ -3355,7 +3354,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) bus->glomerr = 0; dhdsdio_rxfail(bus, true, false); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); dhd_os_sdunlock_rxq(bus->dhd); bus->rxglomfail++; bus->glom = NULL; @@ -3484,7 +3483,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) bus->glomerr = 0; dhdsdio_rxfail(bus, true, false); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); dhd_os_sdunlock_rxq(bus->dhd); bus->rxglomfail++; bus->glom = NULL; @@ -3532,7 +3531,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) skb_pull(pfirst, doff); if (pfirst->len == 0) { - pkt_buf_free_skb(bus->dhd->osh, pfirst, false); + pkt_buf_free_skb(pfirst); if (plast) { plast->next = pnext; } else { @@ -3545,7 +3544,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) DHD_ERROR(("%s: rx protocol error\n", __func__)); bus->dhd->rx_errors++; - pkt_buf_free_skb(osh, pfirst, false); + pkt_buf_free_skb(pfirst); if (plast) { plast->next = pnext; } else { @@ -3589,7 +3588,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) /* Return true if there may be more frames to read */ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) { - struct osl_info *osh = bus->dhd->osh; bcmsdh_info_t *sdh = bus->sdh; u16 len, check; /* Extracted hardware header fields */ @@ -3684,7 +3682,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) */ /* Allocate a packet buffer */ dhd_os_sdlock_rxq(bus->dhd); - pkt = pkt_buf_get_skb(osh, rdlen + DHD_SDALIGN); + pkt = pkt_buf_get_skb(rdlen + DHD_SDALIGN); if (!pkt) { if (bus->bus == SPI_BUS) { bus->usebufpool = false; @@ -3757,7 +3755,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) if (sdret < 0) { DHD_ERROR(("%s (nextlen): read %d bytes failed: %d\n", __func__, rdlen, sdret)); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); bus->dhd->rx_errors++; dhd_os_sdunlock_rxq(bus->dhd); /* Force retry w/normal header read. @@ -3905,8 +3903,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) doff); if (bus->usebufpool) { dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, - false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); } continue; @@ -4095,7 +4092,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) } dhd_os_sdlock_rxq(bus->dhd); - pkt = pkt_buf_get_skb(osh, (rdlen + firstread + DHD_SDALIGN)); + pkt = pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN); if (!pkt) { /* Give up on data, request rtx of events */ DHD_ERROR(("%s: pkt_buf_get_skb failed: rdlen %d chan %d\n", @@ -4131,7 +4128,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ? "data" : "test")), sdret)); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); bus->dhd->rx_errors++; dhdsdio_rxfail(bus, true, RETRYCHAN(chan)); @@ -4184,13 +4181,13 @@ deliver: if (pkt->len == 0) { dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); continue; } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt) != 0) { DHD_ERROR(("%s: rx protocol error\n", __func__)); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); bus->dhd->rx_errors++; continue; @@ -5012,7 +5009,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen) /* Bump dongle by sending an empty event pkt. * sdpcm_sendup (RX) checks for virtual console input. */ - pkt = pkt_buf_get_skb(bus->dhd->osh, 4 + SDPCM_RESERVE); + pkt = pkt_buf_get_skb(4 + SDPCM_RESERVE); if ((pkt != NULL) && bus->clkstate == CLK_AVAIL) dhdsdio_txpkt(bus, pkt, SDPCM_EVENT_CHANNEL, true); diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_main.c b/drivers/staging/brcm80211/brcmsmac/wlc_main.c index 9224961..ace2000 100644 --- a/drivers/staging/brcm80211/brcmsmac/wlc_main.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_main.c @@ -2734,12 +2734,6 @@ uint wlc_down(struct wlc_info *wlc) /* wlc_bmac_down_finish has done wlc_coredisable(). so clk is off */ wlc->clk = false; - - /* Verify all packets are flushed from the driver */ - if (wlc->osh->pktalloced != 0) { - WL_ERROR("%d packets not freed at wlc_down!!!!!!\n", - wlc->osh->pktalloced); - } #ifdef BCMDBG /* Since all the packets should have been freed, * all callbacks should have been called @@ -5122,7 +5116,7 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt, tx_failed[WME_PRIO2AC(p->priority)].bytes, pkttotlen(p)); } - pkt_buf_free_skb(wlc->osh, p, true); + pkt_buf_free_skb(p); wlc->pub->_cnt->txnobuf++; } @@ -5154,8 +5148,11 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, WL_ERROR("wl%d: wlc_txq_enq: txq overflow\n", wlc->pub->unit); - /* ASSERT(9 == 8); *//* XXX we might hit this condtion in case packet flooding from mac80211 stack */ - pkt_buf_free_skb(wlc->osh, sdu, true); + /* + * XXX we might hit this condtion in case + * packet flooding from mac80211 stack + */ + pkt_buf_free_skb(sdu); wlc->pub->_cnt->txnobuf++; } @@ -6710,7 +6707,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) fatal: ASSERT(0); if (p) - pkt_buf_free_skb(wlc->osh, p, true); + pkt_buf_free_skb(p); return true; @@ -6977,7 +6974,6 @@ wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p) ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); wlc->pub->_cnt->ieee_rx++; - wlc->osh->pktalloced--; return; } @@ -7094,7 +7090,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) return; toss: - pkt_buf_free_skb(wlc->osh, p, false); + pkt_buf_free_skb(p); } /* calculate frame duration for Mixed-mode L-SIG spoofing, return diff --git a/drivers/staging/brcm80211/include/bcmutils.h b/drivers/staging/brcm80211/include/bcmutils.h index 0aa7c6f..0f13634 100644 --- a/drivers/staging/brcm80211/include/bcmutils.h +++ b/drivers/staging/brcm80211/include/bcmutils.h @@ -95,9 +95,8 @@ extern struct sk_buff *pktq_pdeq(struct pktq *pq, int prec); extern struct sk_buff *pktq_pdeq_tail(struct pktq *pq, int prec); /* packet primitives */ -extern struct sk_buff *pkt_buf_get_skb(struct osl_info *osh, uint len); -extern void pkt_buf_free_skb(struct osl_info *osh, - struct sk_buff *skb, bool send); +extern struct sk_buff *pkt_buf_get_skb(uint len); +extern void pkt_buf_free_skb(struct sk_buff *skb); /* Empty the queue at particular precedence level */ #ifdef BRCM_FULLMAC diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index d066ed7..5bb4770 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -33,7 +33,7 @@ /* Global ASSERT type flag */ u32 g_assert_type; -struct sk_buff *BCMFASTPATH pkt_buf_get_skb(struct osl_info *osh, uint len) +struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len) { struct sk_buff *skb; @@ -41,16 +41,13 @@ struct sk_buff *BCMFASTPATH pkt_buf_get_skb(struct osl_info *osh, uint len) if (skb) { skb_put(skb, len); skb->priority = 0; - - osh->pktalloced++; } return skb; } /* Free the driver packet. Free the tag if present */ -void BCMFASTPATH pkt_buf_free_skb(struct osl_info *osh, - struct sk_buff *skb, bool send) +void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb) { struct sk_buff *nskb; int nest = 0; @@ -73,7 +70,6 @@ void BCMFASTPATH pkt_buf_free_skb(struct osl_info *osh, */ dev_kfree_skb(skb); - osh->pktalloced--; nest++; skb = nskb; } @@ -245,7 +241,7 @@ void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir) while (p) { q->head = p->prev; p->prev = NULL; - pkt_buf_free_skb(osh, p, dir); + pkt_buf_free_skb(p); q->len--; pq->len--; p = q->head; @@ -279,7 +275,7 @@ pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir, else prev->prev = p->prev; p->prev = NULL; - pkt_buf_free_skb(osh, p, dir); + pkt_buf_free_skb(p); q->len--; pq->len--; p = (head ? q->head : prev->prev); diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index e773b9b..c82de14 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -804,7 +804,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if ((di->hnddma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); - pkt_buf_free_skb(di->osh, head, false); + pkt_buf_free_skb(head); di->hnddma.rxgiants++; goto next_frame; } @@ -852,7 +852,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) size to be allocated */ - p = pkt_buf_get_skb(di->osh, di->rxbufsize + extra_offset); + p = pkt_buf_get_skb(di->rxbufsize + extra_offset); if (p == NULL) { DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", @@ -953,7 +953,7 @@ static void _dma_rxreclaim(dma_info_t *di) DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); while ((p = _dma_getnextrxp(di, true))) - pkt_buf_free_skb(di->osh, p, false); + pkt_buf_free_skb(p); } static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall) @@ -1194,7 +1194,7 @@ static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range) while ((p = dma64_getnexttxp(di, range))) { /* For unframed data, we don't have any packets to free */ if (!(di->hnddma.dmactrlflags & DMA_CTRL_UNFRAMED)) - pkt_buf_free_skb(di->osh, p, true); + pkt_buf_free_skb(p); } } @@ -1544,7 +1544,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name)); - pkt_buf_free_skb(di->osh, p0, true); + pkt_buf_free_skb(p0); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; -- 1.7.4.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel