diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 16:04:53 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 16:04:53 -0800 |
commit | 949f6711b83d2809d1ccb9d830155a65fdacdff9 (patch) | |
tree | 4b8bdb0e98489bc8ad77fa144926931c37e2e4f2 /drivers/staging/brcm80211/util/hnddma.c | |
parent | 443e6221e465efa8efb752a8405a759ef1161af9 (diff) | |
parent | 7959d55679e4360205c9ebc89d40a5503c53bae2 (diff) | |
download | kernel_samsung_smdk4412-949f6711b83d2809d1ccb9d830155a65fdacdff9.zip kernel_samsung_smdk4412-949f6711b83d2809d1ccb9d830155a65fdacdff9.tar.gz kernel_samsung_smdk4412-949f6711b83d2809d1ccb9d830155a65fdacdff9.tar.bz2 |
Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (510 commits)
staging: speakup: fix failure handling
staging: usbip: remove double giveback of URB
Staging: batman-adv: Remove batman-adv from staging
Staging: hv: Use only one txf buffer per channel and kmalloc/GFP_KERNEL on initialize
staging: hv: remove unneeded osd_schedule_callback
staging: hv: convert channel_mgmt.c to not call osd_schedule_callback
staging: hv: convert vmbus_on_msg_dpc to not call osd_schedule_callback
staging: brcm80211: Fix WL_<type> logging macros
Staging: IIO: DDS: AD9833 / AD9834 driver
Staging: IIO: dds.h convenience macros
Staging: IIO: Direct digital synthesis abi documentation
staging: brcm80211: Convert ETHER_TYPE_802_1X to ETH_P_PAE
staging: brcm80211: Remove unused ETHER_TYPE_<foo> #defines
staging: brcm80211: Remove ETHER_HDR_LEN, use ETH_HLEN
staging: brcm80211: Convert ETHER_ADDR_LEN to ETH_ALEN
staging: brcm80211: Convert ETHER_IS<FOO> to is_<foo>_ether_addr
staging: brcm80211: Remove unused ether_<foo> #defines and struct
staging: brcm80211: Convert ETHER_IS_MULTI to is_multicast_ether_addr
staging: brcm80211: Remove unused #defines ETHER_<foo>_LOCALADDR
Staging: comedi: Fix checkpatch.pl issues in file s526.c
...
Fix up trivial conflict in drivers/video/udlfb.c
Diffstat (limited to 'drivers/staging/brcm80211/util/hnddma.c')
-rw-r--r-- | drivers/staging/brcm80211/util/hnddma.c | 136 |
1 files changed, 71 insertions, 65 deletions
diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index fe503e7..d088692 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -16,7 +16,8 @@ #include <linux/kernel.h> #include <linux/string.h> -#include <linuxver.h> +#include <linux/netdevice.h> +#include <linux/pci.h> #include <bcmdefs.h> #include <bcmdevs.h> #include <osl.h> @@ -28,6 +29,10 @@ #include <sbhnddma.h> #include <hnddma.h> +#if defined(__mips__) +#include <asm/addrspace.h> +#endif + /* debug/trace */ #ifdef BCMDBG #define DMA_ERROR(args) \ @@ -68,11 +73,12 @@ static uint dma_msg_level; #define DI_INFO(dmah) ((dma_info_t *)dmah) +#define R_SM(r) (*(r)) +#define W_SM(r, v) (*(r) = (v)) + /* dma engine software state */ typedef struct dma_info { - struct hnddma_pub hnddma; /* exported structure, don't use hnddma_t, - * which could be const - */ + struct hnddma_pub hnddma; /* exported structure */ uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ @@ -222,7 +228,7 @@ static void _dma_counterreset(dma_info_t *di); static void _dma_fifoloopbackenable(dma_info_t *di); static uint _dma_ctrlflags(dma_info_t *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); -static void *dma_ringalloc(osl_t *osh, u32 boundary, uint size, +static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, u16 *alignbits, uint *alloced, dmaaddr_t *descpa, osldma_t **dmah); @@ -231,7 +237,7 @@ static bool dma32_alloc(dma_info_t *di, uint direction); static bool dma32_txreset(dma_info_t *di); static bool dma32_rxreset(dma_info_t *di); static bool dma32_txsuspendedidle(dma_info_t *di); -static int dma32_txfast(dma_info_t *di, void *p0, bool commit); +static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit); static void *dma32_getnexttxp(dma_info_t *di, txd_range_t range); static void *dma32_getnextrxp(dma_info_t *di, bool forceall); static void dma32_txrotate(dma_info_t *di); @@ -246,14 +252,14 @@ static bool dma32_txstopped(dma_info_t *di); static bool dma32_rxstopped(dma_info_t *di); static bool dma32_rxenabled(dma_info_t *di); -static bool _dma32_addrext(osl_t *osh, dma32regs_t *dma32regs); +static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs); /* Prototypes for 64-bit routines */ static bool dma64_alloc(dma_info_t *di, uint direction); static bool dma64_txreset(dma_info_t *di); static bool dma64_rxreset(dma_info_t *di); static bool dma64_txsuspendedidle(dma_info_t *di); -static int dma64_txfast(dma_info_t *di, void *p0, bool commit); +static int dma64_txfast(dma_info_t *di, struct sk_buff *p0, bool commit); static int dma64_txunframed(dma_info_t *di, void *p0, uint len, bool commit); static void *dma64_getpos(dma_info_t *di, bool direction); static void *dma64_getnexttxp(dma_info_t *di, txd_range_t range); @@ -270,7 +276,7 @@ static void dma64_txreclaim(dma_info_t *di, txd_range_t range); static bool dma64_txstopped(dma_info_t *di); static bool dma64_rxstopped(dma_info_t *di); static bool dma64_rxenabled(dma_info_t *di); -static bool _dma64_addrext(osl_t *osh, dma64regs_t *dma64regs); +static bool _dma64_addrext(struct osl_info *osh, dma64regs_t *dma64regs); static inline u32 parity32(u32 data); @@ -368,10 +374,10 @@ static const di_fcn_t dma32proc = { 39 }; -hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, - void *dmaregsrx, uint ntxd, uint nrxd, uint rxbufsize, - int rxextheadroom, uint nrxpost, uint rxoffset, - uint *msg_level) +struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, + void *dmaregstx, void *dmaregsrx, uint ntxd, + uint nrxd, uint rxbufsize, int rxextheadroom, + uint nrxpost, uint rxoffset, uint *msg_level) { dma_info_t *di; uint size; @@ -570,7 +576,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, } } - return (hnddma_t *) di; + return (struct hnddma_pub *) di; fail: _dma_detach(di); @@ -663,7 +669,7 @@ dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, dmaaddr_t pa, uint outidx, } } -static bool _dma32_addrext(osl_t *osh, dma32regs_t *dma32regs) +static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs) { u32 w; @@ -902,7 +908,7 @@ static void _dma_rxinit(dma_info_t *di) /* clear rx descriptor ring */ if (DMA64_ENAB(di) && DMA64_MODE(di)) { - BZERO_SM((void *)di->rxd64, + memset((void *)di->rxd64, '\0', (di->nrxd * sizeof(dma64dd_t))); /* DMA engine with out alignment requirement requires table to be inited @@ -916,7 +922,7 @@ static void _dma_rxinit(dma_info_t *di) if (di->aligndesc_4k) _dma_ddtable_init(di, DMA_RX, di->rxdpa); } else if (DMA32_ENAB(di)) { - BZERO_SM((void *)di->rxd32, + memset((void *)di->rxd32, '\0', (di->nrxd * sizeof(dma32dd_t))); _dma_rxenable(di); _dma_ddtable_init(di, DMA_RX, di->rxdpa); @@ -978,7 +984,7 @@ _dma_rx_param_get(dma_info_t *di, u16 *rxoffset, u16 *rxbufsize) */ static void *BCMFASTPATH _dma_rx(dma_info_t *di) { - void *p, *head, *tail; + struct sk_buff *p, *head, *tail; uint len; uint pkt_len; int resid = 0; @@ -988,30 +994,31 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if (head == NULL) return NULL; - len = ltoh16(*(u16 *) (PKTDATA(head))); + len = ltoh16(*(u16 *) (head->data)); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); #if defined(__mips__) +#define OSL_UNCACHED(va) ((void *)KSEG1ADDR((va))) if (!len) { - while (!(len = *(u16 *) OSL_UNCACHED(PKTDATA(head)))) + while (!(len = *(u16 *) OSL_UNCACHED(head->data))) udelay(1); - *(u16 *) PKTDATA(head) = htol16((u16) len); + *(u16 *) (head->data) = htol16((u16) len); } #endif /* defined(__mips__) */ /* set actual length */ pkt_len = min((di->rxoffset + len), di->rxbufsize); - PKTSETLEN(head, pkt_len); + __skb_trim(head, pkt_len); resid = len - (di->rxbufsize - di->rxoffset); /* check for single or multi-buffer rx */ if (resid > 0) { tail = head; while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { - PKTSETNEXT(tail, p); + tail->next = p; pkt_len = min(resid, (int)di->rxbufsize); - PKTSETLEN(p, pkt_len); + __skb_trim(p, pkt_len); tail = p; resid -= di->rxbufsize; @@ -1037,7 +1044,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)); - PKTFREE(di->osh, head, false); + pkt_buf_free_skb(di->osh, head, false); di->hnddma.rxgiants++; goto next_frame; } @@ -1053,7 +1060,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) */ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) { - void *p; + struct sk_buff *p; u16 rxin, rxout; u32 flags = 0; uint n; @@ -1085,7 +1092,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) size to be allocated */ - p = osl_pktget(di->osh, di->rxbufsize + extra_offset); + p = pkt_buf_get_skb(di->osh, di->rxbufsize + extra_offset); if (p == NULL) { DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", @@ -1109,17 +1116,18 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) } /* reserve an extra headroom, if applicable */ if (extra_offset) - PKTPULL(p, extra_offset); + skb_pull(p, extra_offset); /* Do a cached write instead of uncached write since DMA_MAP * will flush the cache. */ - *(u32 *) (PKTDATA(p)) = 0; + *(u32 *) (p->data) = 0; if (DMASGLIST_ENAB) - bzero(&di->rxp_dmah[rxout], sizeof(hnddma_seg_map_t)); + memset(&di->rxp_dmah[rxout], 0, + sizeof(hnddma_seg_map_t)); - pa = DMA_MAP(di->osh, PKTDATA(p), + pa = DMA_MAP(di->osh, p->data, di->rxbufsize, DMA_RX, p, &di->rxp_dmah[rxout]); ASSERT(IS_ALIGNED(PHYSADDRLO(pa), 4)); @@ -1220,15 +1228,10 @@ static void _dma_rxreclaim(dma_info_t *di) { void *p; - /* "unused local" warning suppression for OSLs that - * define PKTFREE() without using the di->osh arg - */ - di = di; - DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); while ((p = _dma_getnextrxp(di, true))) - PKTFREE(di->osh, p, false); + pkt_buf_free_skb(di->osh, p, false); } static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall) @@ -1372,7 +1375,7 @@ static unsigned long _dma_getvar(dma_info_t *di, const char *name) return 0; } -void dma_txpioloopback(osl_t *osh, dma32regs_t *regs) +void dma_txpioloopback(struct osl_info *osh, dma32regs_t *regs) { OR_REG(osh, ®s->control, XC_LE); } @@ -1395,7 +1398,7 @@ u8 dma_align_sizetobits(uint size) * descriptor ring size aligned location. This will ensure that the ring will * not cross page boundary */ -static void *dma_ringalloc(osl_t *osh, u32 boundary, uint size, +static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, u16 *alignbits, uint *alloced, dmaaddr_t *descpa, osldma_t **dmah) { @@ -1434,7 +1437,7 @@ static void dma32_txinit(dma_info_t *di) di->hnddma.txavail = di->ntxd - 1; /* clear tx descriptor ring */ - BZERO_SM((void *)di->txd32, (di->ntxd * sizeof(dma32dd_t))); + memset((void *)di->txd32, '\0', (di->ntxd * sizeof(dma32dd_t))); if ((di->hnddma.dmactrlflags & DMA_CTRL_PEN) == 0) control |= XC_PD; @@ -1491,7 +1494,7 @@ static void dma32_txreclaim(dma_info_t *di, txd_range_t range) return; while ((p = dma32_getnexttxp(di, range))) - PKTFREE(di->osh, p, true); + pkt_buf_free_skb(di->osh, p, true); } static bool dma32_txstopped(dma_info_t *di) @@ -1651,9 +1654,9 @@ static bool dma32_txsuspendedidle(dma_info_t *di) * WARNING: call must check the return value for error. * the error(toss frames) could be fatal and cause many subsequent hard to debug problems */ -static int dma32_txfast(dma_info_t *di, void *p0, bool commit) +static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit) { - void *p, *next; + struct sk_buff *p, *next; unsigned char *data; uint len; u16 txout; @@ -1672,12 +1675,12 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) uint nsegs, j; hnddma_seg_map_t *map; - data = PKTDATA(p); - len = PKTLEN(p); + data = p->data; + len = p->len; #ifdef BCM_DMAPAD len += PKTDMAPAD(di->osh, p); #endif - next = PKTNEXT(p); + next = p->next; /* return nonzero if out of tx descriptors */ if (NEXTTXD(txout) == di->txin) @@ -1687,7 +1690,8 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) continue; if (DMASGLIST_ENAB) - bzero(&di->txp_dmah[txout], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[txout], 0, + sizeof(hnddma_seg_map_t)); /* get physical address of buffer start */ pa = DMA_MAP(di->osh, data, len, DMA_TX, p, @@ -1761,7 +1765,7 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name)); - PKTFREE(di->osh, p0, true); + pkt_buf_free_skb(di->osh, p0, true); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; @@ -1959,7 +1963,7 @@ static void dma32_txrotate(dma_info_t *di) if (DMASGLIST_ENAB) { bcopy(&di->txp_dmah[old], &di->txp_dmah[new], sizeof(hnddma_seg_map_t)); - bzero(&di->txp_dmah[old], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); } di->txp[old] = NULL; @@ -1989,7 +1993,7 @@ static void dma64_txinit(dma_info_t *di) di->hnddma.txavail = di->ntxd - 1; /* clear tx descriptor ring */ - BZERO_SM((void *)di->txd64, (di->ntxd * sizeof(dma64dd_t))); + memset((void *)di->txd64, '\0', (di->ntxd * sizeof(dma64dd_t))); /* DMA engine with out alignment requirement requires table to be inited * before enabling the engine @@ -2060,7 +2064,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)) - PKTFREE(di->osh, p, true); + pkt_buf_free_skb(di->osh, p, true); } } @@ -2300,9 +2304,10 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit) * WARNING: call must check the return value for error. * the error(toss frames) could be fatal and cause many subsequent hard to debug problems */ -static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) +static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, + bool commit) { - void *p, *next; + struct sk_buff *p, *next; unsigned char *data; uint len; u16 txout; @@ -2321,12 +2326,12 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) uint nsegs, j; hnddma_seg_map_t *map; - data = PKTDATA(p); - len = PKTLEN(p); + data = p->data; + len = p->len; #ifdef BCM_DMAPAD len += PKTDMAPAD(di->osh, p); #endif /* BCM_DMAPAD */ - next = PKTNEXT(p); + next = p->next; /* return nonzero if out of tx descriptors */ if (NEXTTXD(txout) == di->txin) @@ -2337,7 +2342,8 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) /* get physical address of buffer start */ if (DMASGLIST_ENAB) - bzero(&di->txp_dmah[txout], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[txout], 0, + sizeof(hnddma_seg_map_t)); pa = DMA_MAP(di->osh, data, len, DMA_TX, p, &di->txp_dmah[txout]); @@ -2409,7 +2415,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name)); - PKTFREE(di->osh, p0, true); + pkt_buf_free_skb(di->osh, p0, true); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; @@ -2563,7 +2569,7 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall) return rxp; } -static bool _dma64_addrext(osl_t *osh, dma64regs_t * dma64regs) +static bool _dma64_addrext(struct osl_info *osh, dma64regs_t * dma64regs) { u32 w; OR_REG(osh, &dma64regs->control, D64_XC_AE); @@ -2635,7 +2641,7 @@ static void dma64_txrotate(dma_info_t *di) if (DMASGLIST_ENAB) { bcopy(&di->txp_dmah[old], &di->txp_dmah[new], sizeof(hnddma_seg_map_t)); - bzero(&di->txp_dmah[old], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); } di->txp[old] = NULL; @@ -2654,7 +2660,7 @@ static void dma64_txrotate(dma_info_t *di) uint dma_addrwidth(si_t *sih, void *dmaregs) { dma32regs_t *dma32regs; - osl_t *osh; + struct osl_info *osh; osh = si_osh(sih); @@ -2664,8 +2670,8 @@ uint dma_addrwidth(si_t *sih, void *dmaregs) /* backplane are 64-bit capable */ if (si_backplane64(sih)) /* If bus is System Backplane or PCIE then we can access 64-bits */ - if ((BUSTYPE(sih->bustype) == SI_BUS) || - ((BUSTYPE(sih->bustype) == PCI_BUS) && + if ((sih->bustype == SI_BUS) || + ((sih->bustype == PCI_BUS) && (sih->buscoretype == PCIE_CORE_ID))) return DMADDRWIDTH_64; @@ -2679,8 +2685,8 @@ uint dma_addrwidth(si_t *sih, void *dmaregs) dma32regs = (dma32regs_t *) dmaregs; /* For System Backplane, PCIE bus or addrext feature, 32-bits ok */ - if ((BUSTYPE(sih->bustype) == SI_BUS) || - ((BUSTYPE(sih->bustype) == PCI_BUS) + if ((sih->bustype == SI_BUS) || + ((sih->bustype == PCI_BUS) && sih->buscoretype == PCIE_CORE_ID) || (_dma32_addrext(osh, dma32regs))) return DMADDRWIDTH_32; |