diff options
Diffstat (limited to 'drivers/net/arm/ks8695net.c')
-rw-r--r-- | drivers/net/arm/ks8695net.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c index 8ca639127dbc..84f8a8f73802 100644 --- a/drivers/net/arm/ks8695net.c +++ b/drivers/net/arm/ks8695net.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/irq.h> | 31 | #include <linux/irq.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/slab.h> | ||
33 | 34 | ||
34 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
35 | 36 | ||
@@ -449,11 +450,10 @@ ks8695_rx_irq(int irq, void *dev_id) | |||
449 | } | 450 | } |
450 | 451 | ||
451 | /** | 452 | /** |
452 | * ks8695_rx - Receive packets called by NAPI poll method | 453 | * ks8695_rx - Receive packets called by NAPI poll method |
453 | * @ksp: Private data for the KS8695 Ethernet | 454 | * @ksp: Private data for the KS8695 Ethernet |
454 | * @budget: The max packets would be receive | 455 | * @budget: Number of packets allowed to process |
455 | */ | 456 | */ |
456 | |||
457 | static int ks8695_rx(struct ks8695_priv *ksp, int budget) | 457 | static int ks8695_rx(struct ks8695_priv *ksp, int budget) |
458 | { | 458 | { |
459 | struct net_device *ndev = ksp->ndev; | 459 | struct net_device *ndev = ksp->ndev; |
@@ -461,7 +461,6 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget) | |||
461 | int buff_n; | 461 | int buff_n; |
462 | u32 flags; | 462 | u32 flags; |
463 | int pktlen; | 463 | int pktlen; |
464 | int last_rx_processed = -1; | ||
465 | int received = 0; | 464 | int received = 0; |
466 | 465 | ||
467 | buff_n = ksp->next_rx_desc_read; | 466 | buff_n = ksp->next_rx_desc_read; |
@@ -471,6 +470,7 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget) | |||
471 | cpu_to_le32(RDES_OWN)))) { | 470 | cpu_to_le32(RDES_OWN)))) { |
472 | rmb(); | 471 | rmb(); |
473 | flags = le32_to_cpu(ksp->rx_ring[buff_n].status); | 472 | flags = le32_to_cpu(ksp->rx_ring[buff_n].status); |
473 | |||
474 | /* Found an SKB which we own, this means we | 474 | /* Found an SKB which we own, this means we |
475 | * received a packet | 475 | * received a packet |
476 | */ | 476 | */ |
@@ -533,23 +533,18 @@ rx_failure: | |||
533 | ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN); | 533 | ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN); |
534 | rx_finished: | 534 | rx_finished: |
535 | received++; | 535 | received++; |
536 | /* And note this as processed so we can start | ||
537 | * from here next time | ||
538 | */ | ||
539 | last_rx_processed = buff_n; | ||
540 | buff_n = (buff_n + 1) & MAX_RX_DESC_MASK; | 536 | buff_n = (buff_n + 1) & MAX_RX_DESC_MASK; |
541 | /*And note which RX descriptor we last did */ | ||
542 | if (likely(last_rx_processed != -1)) | ||
543 | ksp->next_rx_desc_read = | ||
544 | (last_rx_processed + 1) & | ||
545 | MAX_RX_DESC_MASK; | ||
546 | } | 537 | } |
538 | |||
539 | /* And note which RX descriptor we last did */ | ||
540 | ksp->next_rx_desc_read = buff_n; | ||
541 | |||
547 | /* And refill the buffers */ | 542 | /* And refill the buffers */ |
548 | ks8695_refill_rxbuffers(ksp); | 543 | ks8695_refill_rxbuffers(ksp); |
549 | 544 | ||
550 | /* Kick the RX DMA engine, in case it became | 545 | /* Kick the RX DMA engine, in case it became suspended */ |
551 | * suspended */ | ||
552 | ks8695_writereg(ksp, KS8695_DRSC, 0); | 546 | ks8695_writereg(ksp, KS8695_DRSC, 0); |
547 | |||
553 | return received; | 548 | return received; |
554 | } | 549 | } |
555 | 550 | ||
@@ -575,9 +570,9 @@ static int ks8695_poll(struct napi_struct *napi, int budget) | |||
575 | if (work_done < budget) { | 570 | if (work_done < budget) { |
576 | unsigned long flags; | 571 | unsigned long flags; |
577 | spin_lock_irqsave(&ksp->rx_lock, flags); | 572 | spin_lock_irqsave(&ksp->rx_lock, flags); |
573 | __napi_complete(napi); | ||
578 | /*enable rx interrupt*/ | 574 | /*enable rx interrupt*/ |
579 | writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN); | 575 | writel(isr | mask_bit, KS8695_IRQ_VA + KS8695_INTEN); |
580 | __napi_complete(napi); | ||
581 | spin_unlock_irqrestore(&ksp->rx_lock, flags); | 576 | spin_unlock_irqrestore(&ksp->rx_lock, flags); |
582 | } | 577 | } |
583 | return work_done; | 578 | return work_done; |