diff options
Diffstat (limited to 'drivers/net/spider_net.c')
-rw-r--r-- | drivers/net/spider_net.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index 418138dd6c68..13e0a43e423b 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -88,12 +88,11 @@ MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl); | |||
88 | static inline u32 | 88 | static inline u32 |
89 | spider_net_read_reg(struct spider_net_card *card, u32 reg) | 89 | spider_net_read_reg(struct spider_net_card *card, u32 reg) |
90 | { | 90 | { |
91 | u32 value; | 91 | /* We use the powerpc specific variants instead of readl_be() because |
92 | 92 | * we know spidernet is not a real PCI device and we can thus avoid the | |
93 | value = readl(card->regs + reg); | 93 | * performance hit caused by the PCI workarounds. |
94 | value = le32_to_cpu(value); | 94 | */ |
95 | 95 | return in_be32(card->regs + reg); | |
96 | return value; | ||
97 | } | 96 | } |
98 | 97 | ||
99 | /** | 98 | /** |
@@ -105,8 +104,11 @@ spider_net_read_reg(struct spider_net_card *card, u32 reg) | |||
105 | static inline void | 104 | static inline void |
106 | spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) | 105 | spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) |
107 | { | 106 | { |
108 | value = cpu_to_le32(value); | 107 | /* We use the powerpc specific variants instead of writel_be() because |
109 | writel(value, card->regs + reg); | 108 | * we know spidernet is not a real PCI device and we can thus avoid the |
109 | * performance hit caused by the PCI workarounds. | ||
110 | */ | ||
111 | out_be32(card->regs + reg, value); | ||
110 | } | 112 | } |
111 | 113 | ||
112 | /** spider_net_write_phy - write to phy register | 114 | /** spider_net_write_phy - write to phy register |
@@ -644,20 +646,12 @@ spider_net_prepare_tx_descr(struct spider_net_card *card, | |||
644 | struct spider_net_descr *descr; | 646 | struct spider_net_descr *descr; |
645 | dma_addr_t buf; | 647 | dma_addr_t buf; |
646 | unsigned long flags; | 648 | unsigned long flags; |
647 | int length; | ||
648 | |||
649 | length = skb->len; | ||
650 | if (length < ETH_ZLEN) { | ||
651 | if (skb_pad(skb, ETH_ZLEN-length)) | ||
652 | return 0; | ||
653 | length = ETH_ZLEN; | ||
654 | } | ||
655 | 649 | ||
656 | buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE); | 650 | buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); |
657 | if (pci_dma_mapping_error(buf)) { | 651 | if (pci_dma_mapping_error(buf)) { |
658 | if (netif_msg_tx_err(card) && net_ratelimit()) | 652 | if (netif_msg_tx_err(card) && net_ratelimit()) |
659 | pr_err("could not iommu-map packet (%p, %i). " | 653 | pr_err("could not iommu-map packet (%p, %i). " |
660 | "Dropping packet\n", skb->data, length); | 654 | "Dropping packet\n", skb->data, skb->len); |
661 | card->spider_stats.tx_iommu_map_error++; | 655 | card->spider_stats.tx_iommu_map_error++; |
662 | return -ENOMEM; | 656 | return -ENOMEM; |
663 | } | 657 | } |
@@ -667,7 +661,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card, | |||
667 | card->tx_chain.head = descr->next; | 661 | card->tx_chain.head = descr->next; |
668 | 662 | ||
669 | descr->buf_addr = buf; | 663 | descr->buf_addr = buf; |
670 | descr->buf_size = length; | 664 | descr->buf_size = skb->len; |
671 | descr->next_descr_addr = 0; | 665 | descr->next_descr_addr = 0; |
672 | descr->skb = skb; | 666 | descr->skb = skb; |
673 | descr->data_status = 0; | 667 | descr->data_status = 0; |
@@ -802,8 +796,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal) | |||
802 | 796 | ||
803 | /* unmap the skb */ | 797 | /* unmap the skb */ |
804 | if (skb) { | 798 | if (skb) { |
805 | int len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; | 799 | pci_unmap_single(card->pdev, buf_addr, skb->len, |
806 | pci_unmap_single(card->pdev, buf_addr, len, PCI_DMA_TODEVICE); | 800 | PCI_DMA_TODEVICE); |
807 | dev_kfree_skb(skb); | 801 | dev_kfree_skb(skb); |
808 | } | 802 | } |
809 | } | 803 | } |
@@ -1641,7 +1635,7 @@ spider_net_enable_card(struct spider_net_card *card) | |||
1641 | SPIDER_NET_INT2_MASK_VALUE); | 1635 | SPIDER_NET_INT2_MASK_VALUE); |
1642 | 1636 | ||
1643 | spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, | 1637 | spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, |
1644 | SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS); | 1638 | SPIDER_NET_GDTBSTA); |
1645 | } | 1639 | } |
1646 | 1640 | ||
1647 | /** | 1641 | /** |