···952952 int rc = NETDEV_TX_OK;953953 dma_addr_t mapping;954954 u32 len, entry, ctrl;955955+ unsigned long flags;955956956957 len = skb->len;957957- spin_lock_irq(&bp->lock);958958+ spin_lock_irqsave(&bp->lock, flags);958959959960 /* This is a hard error, log it. */960961 if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) {···10281027 dev->trans_start = jiffies;1029102810301029out_unlock:10311031- spin_unlock_irq(&bp->lock);10301030+ spin_unlock_irqrestore(&bp->lock, flags);1032103110331032 return rc;10341033
···4141 struct ixpdev_priv *ip = netdev_priv(dev);4242 struct ixpdev_tx_desc *desc;4343 int entry;4444+ unsigned long flags;44454546 if (unlikely(skb->len > PAGE_SIZE)) {4647 /* @@@ Count drops. */···64636564 dev->trans_start = jiffies;66656767- local_irq_disable();6666+ local_irq_save(flags);6867 ip->tx_queue_entries++;6968 if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN)7069 netif_stop_queue(dev);7171- local_irq_enable();7070+ local_irq_restore(flags);72717372 return NETDEV_TX_OK;7473}
+4-3
drivers/net/macb.c
···620620 dma_addr_t mapping;621621 unsigned int len, entry;622622 u32 ctrl;623623+ unsigned long flags;623624624625#ifdef DEBUG625626 int i;···636635#endif637636638637 len = skb->len;639639- spin_lock_irq(&bp->lock);638638+ spin_lock_irqsave(&bp->lock, flags);640639641640 /* This is a hard error, log it. */642641 if (TX_BUFFS_AVAIL(bp) < 1) {643642 netif_stop_queue(dev);644644- spin_unlock_irq(&bp->lock);643643+ spin_unlock_irqrestore(&bp->lock, flags);645644 dev_err(&bp->pdev->dev,646645 "BUG! Tx Ring full when queue awake!\n");647646 dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n",···675674 if (TX_BUFFS_AVAIL(bp) < 1)676675 netif_stop_queue(dev);677676678678- spin_unlock_irq(&bp->lock);677677+ spin_unlock_irqrestore(&bp->lock, flags);679678680679 dev->trans_start = jiffies;681680
+3-2
drivers/net/mlx4/en_tx.c
···437437{438438 struct mlx4_en_cq *cq = &priv->tx_cq[tx_ind];439439 struct mlx4_en_tx_ring *ring = &priv->tx_ring[tx_ind];440440+ unsigned long flags;440441441442 /* If we don't have a pending timer, set one up to catch our recent442443 post in case the interface becomes idle */···446445447446 /* Poll the CQ every mlx4_en_TX_MODER_POLL packets */448447 if ((++ring->poll_cnt & (MLX4_EN_TX_POLL_MODER - 1)) == 0)449449- if (spin_trylock_irq(&ring->comp_lock)) {448448+ if (spin_trylock_irqsave(&ring->comp_lock, flags)) {450449 mlx4_en_process_tx_cq(priv->dev, cq);451451- spin_unlock_irq(&ring->comp_lock);450450+ spin_unlock_irqrestore(&ring->comp_lock, flags);452451 }453452}454453
+22-18
drivers/net/smc91x.c
···196196/* this enables an interrupt in the interrupt mask register */197197#define SMC_ENABLE_INT(lp, x) do { \198198 unsigned char mask; \199199- spin_lock_irq(&lp->lock); \199199+ unsigned long smc_enable_flags; \200200+ spin_lock_irqsave(&lp->lock, smc_enable_flags); \200201 mask = SMC_GET_INT_MASK(lp); \201202 mask |= (x); \202203 SMC_SET_INT_MASK(lp, mask); \203203- spin_unlock_irq(&lp->lock); \204204+ spin_unlock_irqrestore(&lp->lock, smc_enable_flags); \204205} while (0)205206206207/* this disables an interrupt from the interrupt mask register */207208#define SMC_DISABLE_INT(lp, x) do { \208209 unsigned char mask; \209209- spin_lock_irq(&lp->lock); \210210+ unsigned long smc_disable_flags; \211211+ spin_lock_irqsave(&lp->lock, smc_disable_flags); \210212 mask = SMC_GET_INT_MASK(lp); \211213 mask &= ~(x); \212214 SMC_SET_INT_MASK(lp, mask); \213213- spin_unlock_irq(&lp->lock); \215215+ spin_unlock_irqrestore(&lp->lock, smc_disable_flags); \214216} while (0)215217216218/*···522520 * any other concurrent access and C would always interrupt B. But life523521 * isn't that easy in a SMP world...524522 */525525-#define smc_special_trylock(lock) \523523+#define smc_special_trylock(lock, flags) \526524({ \527525 int __ret; \528528- local_irq_disable(); \526526+ local_irq_save(flags); \529527 __ret = spin_trylock(lock); \530528 if (!__ret) \531531- local_irq_enable(); \529529+ local_irq_restore(flags); \532530 __ret; \533531})534534-#define smc_special_lock(lock) spin_lock_irq(lock)535535-#define smc_special_unlock(lock) spin_unlock_irq(lock)532532+#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)533533+#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)536534#else537537-#define smc_special_trylock(lock) (1)538538-#define smc_special_lock(lock) do { } while (0)539539-#define smc_special_unlock(lock) do { } while (0)535535+#define smc_special_trylock(lock, flags) (1)536536+#define smc_special_lock(lock, flags) do { } while (0)537537+#define smc_special_unlock(lock, flags) do { } while (0)540538#endif541539542540/*···550548 struct sk_buff *skb;551549 unsigned int packet_no, len;552550 unsigned char *buf;551551+ unsigned long flags;553552554553 DBG(3, "%s: %s\n", dev->name, __func__);555554556556- if (!smc_special_trylock(&lp->lock)) {555555+ if (!smc_special_trylock(&lp->lock, flags)) {557556 netif_stop_queue(dev);558557 tasklet_schedule(&lp->tx_task);559558 return;···562559563560 skb = lp->pending_tx_skb;564561 if (unlikely(!skb)) {565565- smc_special_unlock(&lp->lock);562562+ smc_special_unlock(&lp->lock, flags);566563 return;567564 }568565 lp->pending_tx_skb = NULL;···572569 printk("%s: Memory allocation failed.\n", dev->name);573570 dev->stats.tx_errors++;574571 dev->stats.tx_fifo_errors++;575575- smc_special_unlock(&lp->lock);572572+ smc_special_unlock(&lp->lock, flags);576573 goto done;577574 }578575···611608612609 /* queue the packet for TX */613610 SMC_SET_MMU_CMD(lp, MC_ENQUEUE);614614- smc_special_unlock(&lp->lock);611611+ smc_special_unlock(&lp->lock, flags);615612616613 dev->trans_start = jiffies;617614 dev->stats.tx_packets++;···636633 struct smc_local *lp = netdev_priv(dev);637634 void __iomem *ioaddr = lp->base;638635 unsigned int numPages, poll_count, status;636636+ unsigned long flags;639637640638 DBG(3, "%s: %s\n", dev->name, __func__);641639···662658 return NETDEV_TX_OK;663659 }664660665665- smc_special_lock(&lp->lock);661661+ smc_special_lock(&lp->lock, flags);666662667663 /* now, try to allocate the memory */668664 SMC_SET_MMU_CMD(lp, MC_ALLOC | numPages);···680676 }681677 } while (--poll_count);682678683683- smc_special_unlock(&lp->lock);679679+ smc_special_unlock(&lp->lock, flags);684680685681 lp->pending_tx_skb = skb;686682 if (!poll_count) {
+3-2
drivers/net/tulip/tulip_core.c
···653653 int entry;654654 u32 flag;655655 dma_addr_t mapping;656656+ unsigned long flags;656657657657- spin_lock_irq(&tp->lock);658658+ spin_lock_irqsave(&tp->lock, flags);658659659660 /* Calculate the next Tx descriptor entry. */660661 entry = tp->cur_tx % TX_RING_SIZE;···690689 /* Trigger an immediate transmit demand. */691690 iowrite32(0, tp->base_addr + CSR1);692691693693- spin_unlock_irq(&tp->lock);692692+ spin_unlock_irqrestore(&tp->lock, flags);694693695694 dev->trans_start = jiffies;696695
···250250 DEFAULT_GPIO_RESET )251251PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913,252252 DEFAULT_GPIO_RESET | PEGASUS_II )253253+PEGASUS_DEV( "IO DATA USB ETX-US2", VENDOR_IODATA, 0x092a,254254+ DEFAULT_GPIO_RESET | PEGASUS_II )253255PEGASUS_DEV( "Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a,254256 DEFAULT_GPIO_RESET)255257PEGASUS_DEV( "LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002,
+3-2
drivers/net/via-rhine.c
···12201220 struct rhine_private *rp = netdev_priv(dev);12211221 void __iomem *ioaddr = rp->base;12221222 unsigned entry;12231223+ unsigned long flags;1223122412241225 /* Caution: the write order is important here, set the field12251226 with the "ownership" bits last. */···12641263 cpu_to_le32(TXDESC | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN));1265126412661265 /* lock eth irq */12671267- spin_lock_irq(&rp->lock);12661266+ spin_lock_irqsave(&rp->lock, flags);12681267 wmb();12691268 rp->tx_ring[entry].tx_status = cpu_to_le32(DescOwn);12701269 wmb();···1283128212841283 dev->trans_start = jiffies;1285128412861286- spin_unlock_irq(&rp->lock);12851285+ spin_unlock_irqrestore(&rp->lock, flags);1287128612881287 if (debug > 4) {12891288 printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n",
+1-1
drivers/net/via-velocity.c
···17891789 * mode17901790 */17911791 if (vptr->rev_id < REV_ID_VT3216_A0) {17921792- if (vptr->mii_status | VELOCITY_DUPLEX_FULL)17921792+ if (vptr->mii_status & VELOCITY_DUPLEX_FULL)17931793 BYTE_REG_BITS_ON(TCR_TB2BDIS, ®s->TCR);17941794 else17951795 BYTE_REG_BITS_OFF(TCR_TB2BDIS, ®s->TCR);
+46-15
drivers/net/virtio_net.c
···7070 struct sk_buff_head recv;7171 struct sk_buff_head send;72727373+ /* Work struct for refilling if we run low on memory. */7474+ struct delayed_work refill;7575+7376 /* Chain pages by the private ptr. */7477 struct page *pages;7578};···276273 dev_kfree_skb(skb);277274}278275279279-static void try_fill_recv_maxbufs(struct virtnet_info *vi)276276+static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp)280277{281278 struct sk_buff *skb;282279 struct scatterlist sg[2+MAX_SKB_FRAGS];283280 int num, err, i;281281+ bool oom = false;284282285283 sg_init_table(sg, 2+MAX_SKB_FRAGS);286284 for (;;) {287285 struct virtio_net_hdr *hdr;288286289287 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);290290- if (unlikely(!skb))288288+ if (unlikely(!skb)) {289289+ oom = true;291290 break;291291+ }292292293293 skb_reserve(skb, NET_IP_ALIGN);294294 skb_put(skb, MAX_PACKET_LEN);···302296 if (vi->big_packets) {303297 for (i = 0; i < MAX_SKB_FRAGS; i++) {304298 skb_frag_t *f = &skb_shinfo(skb)->frags[i];305305- f->page = get_a_page(vi, GFP_ATOMIC);299299+ f->page = get_a_page(vi, gfp);306300 if (!f->page)307301 break;308302···331325 if (unlikely(vi->num > vi->max))332326 vi->max = vi->num;333327 vi->rvq->vq_ops->kick(vi->rvq);328328+ return !oom;334329}335330336336-static void try_fill_recv(struct virtnet_info *vi)331331+/* Returns false if we couldn't fill entirely (OOM). */332332+static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)337333{338334 struct sk_buff *skb;339335 struct scatterlist sg[1];340336 int err;337337+ bool oom = false;341338342342- if (!vi->mergeable_rx_bufs) {343343- try_fill_recv_maxbufs(vi);344344- return;345345- }339339+ if (!vi->mergeable_rx_bufs)340340+ return try_fill_recv_maxbufs(vi, gfp);346341347342 for (;;) {348343 skb_frag_t *f;349344350345 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN);351351- if (unlikely(!skb))346346+ if (unlikely(!skb)) {347347+ oom = true;352348 break;349349+ }353350354351 skb_reserve(skb, NET_IP_ALIGN);355352356353 f = &skb_shinfo(skb)->frags[0];357357- f->page = get_a_page(vi, GFP_ATOMIC);354354+ f->page = get_a_page(vi, gfp);358355 if (!f->page) {356356+ oom = true;359357 kfree_skb(skb);360358 break;361359 }···383373 if (unlikely(vi->num > vi->max))384374 vi->max = vi->num;385375 vi->rvq->vq_ops->kick(vi->rvq);376376+ return !oom;386377}387378388379static void skb_recv_done(struct virtqueue *rvq)···394383 rvq->vq_ops->disable_cb(rvq);395384 __napi_schedule(&vi->napi);396385 }386386+}387387+388388+static void refill_work(struct work_struct *work)389389+{390390+ struct virtnet_info *vi;391391+ bool still_empty;392392+393393+ vi = container_of(work, struct virtnet_info, refill.work);394394+ napi_disable(&vi->napi);395395+ try_fill_recv(vi, GFP_KERNEL);396396+ still_empty = (vi->num == 0);397397+ napi_enable(&vi->napi);398398+399399+ /* In theory, this can happen: if we don't get any buffers in400400+ * we will *never* try to fill again. */401401+ if (still_empty)402402+ schedule_delayed_work(&vi->refill, HZ/2);397403}398404399405static int virtnet_poll(struct napi_struct *napi, int budget)···428400 received++;429401 }430402431431- /* FIXME: If we oom and completely run out of inbufs, we need432432- * to start a timer trying to fill more. */433433- if (vi->num < vi->max / 2)434434- try_fill_recv(vi);403403+ if (vi->num < vi->max / 2) {404404+ if (!try_fill_recv(vi, GFP_ATOMIC))405405+ schedule_delayed_work(&vi->refill, 0);406406+ }435407436408 /* Out of packets? */437409 if (received < budget) {···922894 vi->vdev = vdev;923895 vdev->priv = vi;924896 vi->pages = NULL;897897+ INIT_DELAYED_WORK(&vi->refill, refill_work);925898926899 /* If they give us a callback when all buffers are done, we don't need927900 * the timer. */···971942 }972943973944 /* Last of all, set up some receive buffers. */974974- try_fill_recv(vi);945945+ try_fill_recv(vi, GFP_KERNEL);975946976947 /* If we didn't even get one input buffer, we're useless. */977948 if (vi->num == 0) {···988959989960unregister:990961 unregister_netdev(dev);962962+ cancel_delayed_work_sync(&vi->refill);991963free_vqs:992964 vdev->config->del_vqs(vdev);993965free:···1017987 BUG_ON(vi->num != 0);10189881019989 unregister_netdev(vi->dev);990990+ cancel_delayed_work_sync(&vi->refill);10209911021992 vdev->config->del_vqs(vi->vdev);1022993
+67-53
drivers/net/wireless/ipw2x00/ipw2200.c
···28932893 return 0;28942894}2895289528962896-static int ipw_fw_dma_add_buffer(struct ipw_priv *priv,28972897- u32 src_phys, u32 dest_address, u32 length)28962896+static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, dma_addr_t *src_address,28972897+ int nr, u32 dest_address, u32 len)28982898{28992899- u32 bytes_left = length;29002900- u32 src_offset = 0;29012901- u32 dest_offset = 0;29022902- int status = 0;28992899+ int ret, i;29002900+ u32 size;29012901+29032902 IPW_DEBUG_FW(">> \n");29042904- IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n",29052905- src_phys, dest_address, length);29062906- while (bytes_left > CB_MAX_LENGTH) {29072907- status = ipw_fw_dma_add_command_block(priv,29082908- src_phys + src_offset,29092909- dest_address +29102910- dest_offset,29112911- CB_MAX_LENGTH, 0, 0);29122912- if (status) {29032903+ IPW_DEBUG_FW_INFO("nr=%d dest_address=0x%x len=0x%x\n",29042904+ nr, dest_address, len);29052905+29062906+ for (i = 0; i < nr; i++) {29072907+ size = min_t(u32, len - i * CB_MAX_LENGTH, CB_MAX_LENGTH);29082908+ ret = ipw_fw_dma_add_command_block(priv, src_address[i],29092909+ dest_address +29102910+ i * CB_MAX_LENGTH, size,29112911+ 0, 0);29122912+ if (ret) {29132913 IPW_DEBUG_FW_INFO(": Failed\n");29142914 return -1;29152915 } else29162916 IPW_DEBUG_FW_INFO(": Added new cb\n");29172917-29182918- src_offset += CB_MAX_LENGTH;29192919- dest_offset += CB_MAX_LENGTH;29202920- bytes_left -= CB_MAX_LENGTH;29212921- }29222922-29232923- /* add the buffer tail */29242924- if (bytes_left > 0) {29252925- status =29262926- ipw_fw_dma_add_command_block(priv, src_phys + src_offset,29272927- dest_address + dest_offset,29282928- bytes_left, 0, 0);29292929- if (status) {29302930- IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n");29312931- return -1;29322932- } else29332933- IPW_DEBUG_FW_INFO29342934- (": Adding new cb - the buffer tail\n");29352917 }2936291829372919 IPW_DEBUG_FW("<< \n");···3161317931623180static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)31633181{31643164- int rc = -1;31823182+ int ret = -1;31653183 int offset = 0;31663184 struct fw_chunk *chunk;31673167- dma_addr_t shared_phys;31683168- u8 *shared_virt;31853185+ int total_nr = 0;31863186+ int i;31873187+ struct pci_pool *pool;31883188+ u32 *virts[CB_NUMBER_OF_ELEMENTS_SMALL];31893189+ dma_addr_t phys[CB_NUMBER_OF_ELEMENTS_SMALL];3169319031703191 IPW_DEBUG_TRACE("<< : \n");31713171- shared_virt = pci_alloc_consistent(priv->pci_dev, len, &shared_phys);3172319231733173- if (!shared_virt)31933193+ pool = pci_pool_create("ipw2200", priv->pci_dev, CB_MAX_LENGTH, 0, 0);31943194+ if (!pool) {31953195+ IPW_ERROR("pci_pool_create failed\n");31743196 return -ENOMEM;31753175-31763176- memmove(shared_virt, data, len);31973197+ }3177319831783199 /* Start the Dma */31793179- rc = ipw_fw_dma_enable(priv);32003200+ ret = ipw_fw_dma_enable(priv);3180320131813202 /* the DMA is already ready this would be a bug. */31823203 BUG_ON(priv->sram_desc.last_cb_index > 0);3183320431843205 do {32063206+ u32 chunk_len;32073207+ u8 *start;32083208+ int size;32093209+ int nr = 0;32103210+31853211 chunk = (struct fw_chunk *)(data + offset);31863212 offset += sizeof(struct fw_chunk);32133213+ chunk_len = le32_to_cpu(chunk->length);32143214+ start = data + offset;32153215+32163216+ nr = (chunk_len + CB_MAX_LENGTH - 1) / CB_MAX_LENGTH;32173217+ for (i = 0; i < nr; i++) {32183218+ virts[total_nr] = pci_pool_alloc(pool, GFP_KERNEL,32193219+ &phys[total_nr]);32203220+ if (!virts[total_nr]) {32213221+ ret = -ENOMEM;32223222+ goto out;32233223+ }32243224+ size = min_t(u32, chunk_len - i * CB_MAX_LENGTH,32253225+ CB_MAX_LENGTH);32263226+ memcpy(virts[total_nr], start, size);32273227+ start += size;32283228+ total_nr++;32293229+ /* We don't support fw chunk larger than 64*8K */32303230+ BUG_ON(total_nr > CB_NUMBER_OF_ELEMENTS_SMALL);32313231+ }32323232+31873233 /* build DMA packet and queue up for sending */31883234 /* dma to chunk->address, the chunk->length bytes from data +31893235 * offeset*/31903236 /* Dma loading */31913191- rc = ipw_fw_dma_add_buffer(priv, shared_phys + offset,31923192- le32_to_cpu(chunk->address),31933193- le32_to_cpu(chunk->length));31943194- if (rc) {32373237+ ret = ipw_fw_dma_add_buffer(priv, &phys[total_nr - nr],32383238+ nr, le32_to_cpu(chunk->address),32393239+ chunk_len);32403240+ if (ret) {31953241 IPW_DEBUG_INFO("dmaAddBuffer Failed\n");31963242 goto out;31973243 }3198324431993199- offset += le32_to_cpu(chunk->length);32453245+ offset += chunk_len;32003246 } while (offset < len);3201324732023248 /* Run the DMA and wait for the answer */32033203- rc = ipw_fw_dma_kick(priv);32043204- if (rc) {32493249+ ret = ipw_fw_dma_kick(priv);32503250+ if (ret) {32053251 IPW_ERROR("dmaKick Failed\n");32063252 goto out;32073253 }3208325432093209- rc = ipw_fw_dma_wait(priv);32103210- if (rc) {32553255+ ret = ipw_fw_dma_wait(priv);32563256+ if (ret) {32113257 IPW_ERROR("dmaWaitSync Failed\n");32123258 goto out;32133259 }32143214- out:32153215- pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys);32163216- return rc;32603260+ out:32613261+ for (i = 0; i < total_nr; i++)32623262+ pci_pool_free(pool, virts[i], phys[i]);32633263+32643264+ pci_pool_destroy(pool);32653265+32663266+ return ret;32173267}3218326832193269/* stop nic */
+1-1
drivers/net/wireless/orinoco/hw.c
···644644 int err = 0;645645 u8 tsc_arr[4][ORINOCO_SEQ_LEN];646646647647- if ((key < 0) || (key > 4))647647+ if ((key < 0) || (key >= 4))648648 return -EINVAL;649649650650 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV,