From 920845357fc6f84fe1a8bcb4a504fff499bce085 Mon Sep 17 00:00:00 2001 From: Roman Yeryomin Date: Sun, 25 Nov 2018 14:55:38 +0200 Subject: rb532: add 4.14 support Signed-off-by: Roman Yeryomin --- .../rb532/patches-4.14/001-cmdline_hack.patch | 20 +++ .../004-rb532-fix-partition-info.patch | 17 +++ ...e-rx-overflow-and-tx-underflow-interrupts.patch | 156 +++++++++++++++++++++ ...a-refactor-rx-descriptor-flags-processing.patch | 110 +++++++++++++++ .../patches-4.14/107-use-NAPI_POLL_WEIGHT.patch | 11 ++ .../rb532/patches-4.14/108-korina-use-gro.patch | 11 ++ .../109-korina-whitespace-cleanup-2.patch | 135 ++++++++++++++++++ .../patches-4.14/110-korina-update-authors.patch | 17 +++ .../patches-4.14/111-korina-version-bump.patch | 13 ++ 9 files changed, 490 insertions(+) create mode 100644 target/linux/rb532/patches-4.14/001-cmdline_hack.patch create mode 100644 target/linux/rb532/patches-4.14/004-rb532-fix-partition-info.patch create mode 100644 target/linux/rb532/patches-4.14/106-dont-use-rx-overflow-and-tx-underflow-interrupts.patch create mode 100644 target/linux/rb532/patches-4.14/107-korina-refactor-rx-descriptor-flags-processing.patch create mode 100644 target/linux/rb532/patches-4.14/107-use-NAPI_POLL_WEIGHT.patch create mode 100644 target/linux/rb532/patches-4.14/108-korina-use-gro.patch create mode 100644 target/linux/rb532/patches-4.14/109-korina-whitespace-cleanup-2.patch create mode 100644 target/linux/rb532/patches-4.14/110-korina-update-authors.patch create mode 100644 target/linux/rb532/patches-4.14/111-korina-version-bump.patch (limited to 'target/linux/rb532/patches-4.14') diff --git a/target/linux/rb532/patches-4.14/001-cmdline_hack.patch b/target/linux/rb532/patches-4.14/001-cmdline_hack.patch new file mode 100644 index 0000000000..a39da9c14a --- /dev/null +++ b/target/linux/rb532/patches-4.14/001-cmdline_hack.patch @@ -0,0 +1,20 @@ +--- a/arch/mips/rb532/prom.c ++++ b/arch/mips/rb532/prom.c +@@ -67,6 +67,7 @@ static inline unsigned long tag2ul(char + return simple_strtoul(num, 0, 10); + } + ++extern char __image_cmdline[]; + void __init prom_setup_cmdline(void) + { + static char cmd_line[COMMAND_LINE_SIZE] __initdata; +@@ -108,6 +109,9 @@ void __init prom_setup_cmdline(void) + } + *(cp++) = ' '; + ++ strcpy(cp,(__image_cmdline)); ++ cp += strlen(__image_cmdline); ++ + i = strlen(arcs_cmdline); + if (i > 0) { + *(cp++) = ' '; diff --git a/target/linux/rb532/patches-4.14/004-rb532-fix-partition-info.patch b/target/linux/rb532/patches-4.14/004-rb532-fix-partition-info.patch new file mode 100644 index 0000000000..5161a233dd --- /dev/null +++ b/target/linux/rb532/patches-4.14/004-rb532-fix-partition-info.patch @@ -0,0 +1,17 @@ +--- a/arch/mips/rb532/devices.c ++++ b/arch/mips/rb532/devices.c +@@ -186,11 +186,11 @@ static struct platform_device nand_slot0 + + static struct mtd_partition rb532_partition_info[] = { + { +- .name = "Routerboard NAND boot", ++ .name = "kernel", + .offset = 0, +- .size = 4 * 1024 * 1024, ++ .size = 8 * 1024 * 1024, + }, { +- .name = "rootfs", ++ .name = "ubi", + .offset = MTDPART_OFS_NXTBLK, + .size = MTDPART_SIZ_FULL, + } diff --git a/target/linux/rb532/patches-4.14/106-dont-use-rx-overflow-and-tx-underflow-interrupts.patch b/target/linux/rb532/patches-4.14/106-dont-use-rx-overflow-and-tx-underflow-interrupts.patch new file mode 100644 index 0000000000..e75079b12f --- /dev/null +++ b/target/linux/rb532/patches-4.14/106-dont-use-rx-overflow-and-tx-underflow-interrupts.patch @@ -0,0 +1,156 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -122,8 +122,6 @@ struct korina_private { + + int rx_irq; + int tx_irq; +- int ovr_irq; +- int und_irq; + + spinlock_t lock; /* NIC xmit lock */ + +@@ -890,8 +888,6 @@ static void korina_restart_task(struct w + */ + disable_irq(lp->rx_irq); + disable_irq(lp->tx_irq); +- disable_irq(lp->ovr_irq); +- disable_irq(lp->und_irq); + + writel(readl(&lp->tx_dma_regs->dmasm) | + DMA_STAT_FINI | DMA_STAT_ERR, +@@ -910,40 +906,10 @@ static void korina_restart_task(struct w + } + korina_multicast_list(dev); + +- enable_irq(lp->und_irq); +- enable_irq(lp->ovr_irq); + enable_irq(lp->tx_irq); + enable_irq(lp->rx_irq); + } + +-static void korina_clear_and_restart(struct net_device *dev, u32 value) +-{ +- struct korina_private *lp = netdev_priv(dev); +- +- netif_stop_queue(dev); +- writel(value, &lp->eth_regs->ethintfc); +- schedule_work(&lp->restart_task); +-} +- +-/* Ethernet Tx Underflow interrupt */ +-static irqreturn_t korina_und_interrupt(int irq, void *dev_id) +-{ +- struct net_device *dev = dev_id; +- struct korina_private *lp = netdev_priv(dev); +- unsigned int und; +- +- spin_lock(&lp->lock); +- +- und = readl(&lp->eth_regs->ethintfc); +- +- if (und & ETH_INT_FC_UND) +- korina_clear_and_restart(dev, und & ~ETH_INT_FC_UND); +- +- spin_unlock(&lp->lock); +- +- return IRQ_HANDLED; +-} +- + static void korina_tx_timeout(struct net_device *dev) + { + struct korina_private *lp = netdev_priv(dev); +@@ -951,25 +917,6 @@ static void korina_tx_timeout(struct net + schedule_work(&lp->restart_task); + } + +-/* Ethernet Rx Overflow interrupt */ +-static irqreturn_t +-korina_ovr_interrupt(int irq, void *dev_id) +-{ +- struct net_device *dev = dev_id; +- struct korina_private *lp = netdev_priv(dev); +- unsigned int ovr; +- +- spin_lock(&lp->lock); +- ovr = readl(&lp->eth_regs->ethintfc); +- +- if (ovr & ETH_INT_FC_OVR) +- korina_clear_and_restart(dev, ovr & ~ETH_INT_FC_OVR); +- +- spin_unlock(&lp->lock); +- +- return IRQ_HANDLED; +-} +- + #ifdef CONFIG_NET_POLL_CONTROLLER + static void korina_poll_controller(struct net_device *dev) + { +@@ -992,8 +939,7 @@ static int korina_open(struct net_device + } + + /* Install the interrupt handler +- * that handles the Done Finished +- * Ovr and Und Events */ ++ * that handles the Done Finished */ + ret = request_irq(lp->rx_irq, korina_rx_dma_interrupt, + 0, "Korina ethernet Rx", dev); + if (ret < 0) { +@@ -1009,31 +955,10 @@ static int korina_open(struct net_device + goto err_free_rx_irq; + } + +- /* Install handler for overrun error. */ +- ret = request_irq(lp->ovr_irq, korina_ovr_interrupt, +- 0, "Ethernet Overflow", dev); +- if (ret < 0) { +- printk(KERN_ERR "%s: unable to get OVR IRQ %d\n", +- dev->name, lp->ovr_irq); +- goto err_free_tx_irq; +- } +- +- /* Install handler for underflow error. */ +- ret = request_irq(lp->und_irq, korina_und_interrupt, +- 0, "Ethernet Underflow", dev); +- if (ret < 0) { +- printk(KERN_ERR "%s: unable to get UND IRQ %d\n", +- dev->name, lp->und_irq); +- goto err_free_ovr_irq; +- } + mod_timer(&lp->media_check_timer, jiffies + 1); + out: + return ret; + +-err_free_ovr_irq: +- free_irq(lp->ovr_irq, dev); +-err_free_tx_irq: +- free_irq(lp->tx_irq, dev); + err_free_rx_irq: + free_irq(lp->rx_irq, dev); + err_release: +@@ -1051,8 +976,6 @@ static int korina_close(struct net_devic + /* Disable interrupts */ + disable_irq(lp->rx_irq); + disable_irq(lp->tx_irq); +- disable_irq(lp->ovr_irq); +- disable_irq(lp->und_irq); + + korina_abort_tx(dev); + tmp = readl(&lp->tx_dma_regs->dmasm); +@@ -1072,8 +995,6 @@ static int korina_close(struct net_devic + + free_irq(lp->rx_irq, dev); + free_irq(lp->tx_irq, dev); +- free_irq(lp->ovr_irq, dev); +- free_irq(lp->und_irq, dev); + + return 0; + } +@@ -1113,8 +1034,6 @@ static int korina_probe(struct platform_ + + lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx"); + lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx"); +- lp->ovr_irq = platform_get_irq_byname(pdev, "korina_ovr"); +- lp->und_irq = platform_get_irq_byname(pdev, "korina_und"); + + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_regs"); + dev->base_addr = r->start; diff --git a/target/linux/rb532/patches-4.14/107-korina-refactor-rx-descriptor-flags-processing.patch b/target/linux/rb532/patches-4.14/107-korina-refactor-rx-descriptor-flags-processing.patch new file mode 100644 index 0000000000..80745f534d --- /dev/null +++ b/target/linux/rb532/patches-4.14/107-korina-refactor-rx-descriptor-flags-processing.patch @@ -0,0 +1,110 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -363,59 +363,60 @@ static int korina_rx(struct net_device * + if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0) + break; + +- /* Update statistics counters */ +- if (devcs & ETH_RX_CRC) +- dev->stats.rx_crc_errors++; +- if (devcs & ETH_RX_LOR) +- dev->stats.rx_length_errors++; +- if (devcs & ETH_RX_LE) +- dev->stats.rx_length_errors++; +- if (devcs & ETH_RX_OVR) +- dev->stats.rx_fifo_errors++; +- if (devcs & ETH_RX_CV) +- dev->stats.rx_frame_errors++; +- if (devcs & ETH_RX_CES) +- dev->stats.rx_length_errors++; +- if (devcs & ETH_RX_MP) +- dev->stats.multicast++; ++ /* check that this is a whole packet ++ * WARNING: DMA_FD bit incorrectly set ++ * in Rc32434 (errata ref #077) */ ++ if (!(devcs & ETH_RX_LD)) ++ goto next; + +- if ((devcs & ETH_RX_LD) != ETH_RX_LD) { +- /* check that this is a whole packet +- * WARNING: DMA_FD bit incorrectly set +- * in Rc32434 (errata ref #077) */ ++ if (!(devcs & ETH_RX_ROK)) { ++ /* Update statistics counters */ + dev->stats.rx_errors++; + dev->stats.rx_dropped++; +- } else if ((devcs & ETH_RX_ROK)) { +- pkt_len = RCVPKT_LENGTH(devcs); ++ if (devcs & ETH_RX_CRC) ++ dev->stats.rx_crc_errors++; ++ if (devcs & ETH_RX_LE) ++ dev->stats.rx_length_errors++; ++ if (devcs & ETH_RX_OVR) ++ dev->stats.rx_fifo_errors++; ++ if (devcs & ETH_RX_CV) ++ dev->stats.rx_frame_errors++; ++ if (devcs & ETH_RX_CES) ++ dev->stats.rx_frame_errors++; + +- /* must be the (first and) last +- * descriptor then */ +- pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data; +- +- /* invalidate the cache */ +- dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4); +- +- /* Malloc up new buffer. */ +- skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE); +- +- if (!skb_new) +- break; +- /* Do not count the CRC */ +- skb_put(skb, pkt_len - 4); +- skb->protocol = eth_type_trans(skb, dev); +- +- /* Pass the packet to upper layers */ +- netif_receive_skb(skb); +- dev->stats.rx_packets++; +- dev->stats.rx_bytes += pkt_len; +- +- /* Update the mcast stats */ +- if (devcs & ETH_RX_MP) +- dev->stats.multicast++; +- +- lp->rx_skb[lp->rx_next_done] = skb_new; ++ goto next; + } + ++ pkt_len = RCVPKT_LENGTH(devcs); ++ ++ /* must be the (first and) last ++ * descriptor then */ ++ pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data; ++ ++ /* invalidate the cache */ ++ dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4); ++ ++ /* Malloc up new buffer. */ ++ skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE); ++ ++ if (!skb_new) ++ break; ++ /* Do not count the CRC */ ++ skb_put(skb, pkt_len - 4); ++ skb->protocol = eth_type_trans(skb, dev); ++ ++ /* Pass the packet to upper layers */ ++ netif_receive_skb(skb); ++ dev->stats.rx_packets++; ++ dev->stats.rx_bytes += pkt_len; ++ ++ /* Update the mcast stats */ ++ if (devcs & ETH_RX_MP) ++ dev->stats.multicast++; ++ ++ lp->rx_skb[lp->rx_next_done] = skb_new; ++ ++next: + rd->devcs = 0; + + /* Restore descriptor's curr_addr */ diff --git a/target/linux/rb532/patches-4.14/107-use-NAPI_POLL_WEIGHT.patch b/target/linux/rb532/patches-4.14/107-use-NAPI_POLL_WEIGHT.patch new file mode 100644 index 0000000000..d4af90636f --- /dev/null +++ b/target/linux/rb532/patches-4.14/107-use-NAPI_POLL_WEIGHT.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -1082,7 +1082,7 @@ static int korina_probe(struct platform_ + dev->netdev_ops = &korina_netdev_ops; + dev->ethtool_ops = &netdev_ethtool_ops; + dev->watchdog_timeo = TX_TIMEOUT; +- netif_napi_add(dev, &lp->napi, korina_poll, 64); ++ netif_napi_add(dev, &lp->napi, korina_poll, NAPI_POLL_WEIGHT); + + lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05); + lp->mii_if.dev = dev; diff --git a/target/linux/rb532/patches-4.14/108-korina-use-gro.patch b/target/linux/rb532/patches-4.14/108-korina-use-gro.patch new file mode 100644 index 0000000000..8cbe2a0777 --- /dev/null +++ b/target/linux/rb532/patches-4.14/108-korina-use-gro.patch @@ -0,0 +1,11 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -406,7 +406,7 @@ static int korina_rx(struct net_device * + skb->protocol = eth_type_trans(skb, dev); + + /* Pass the packet to upper layers */ +- netif_receive_skb(skb); ++ napi_gro_receive(&lp->napi, skb); + dev->stats.rx_packets++; + dev->stats.rx_bytes += pkt_len; + diff --git a/target/linux/rb532/patches-4.14/109-korina-whitespace-cleanup-2.patch b/target/linux/rb532/patches-4.14/109-korina-whitespace-cleanup-2.patch new file mode 100644 index 0000000000..4a2cb8997d --- /dev/null +++ b/target/linux/rb532/patches-4.14/109-korina-whitespace-cleanup-2.patch @@ -0,0 +1,135 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -64,9 +64,9 @@ + #include + #include + +-#define DRV_NAME "korina" +-#define DRV_VERSION "0.10" +-#define DRV_RELDATE "04Mar2008" ++#define DRV_NAME "korina" ++#define DRV_VERSION "0.10" ++#define DRV_RELDATE "04Mar2008" + + #define STATION_ADDRESS_HIGH(dev) (((dev)->dev_addr[0] << 8) | \ + ((dev)->dev_addr[1])) +@@ -75,7 +75,7 @@ + ((dev)->dev_addr[4] << 8) | \ + ((dev)->dev_addr[5])) + +-#define MII_CLOCK 1250000 /* no more than 2.5MHz */ ++#define MII_CLOCK 1250000 /* no more than 2.5MHz */ + + /* the following must be powers of two */ + #define KORINA_NUM_RDS 64 /* number of receive descriptors */ +@@ -87,15 +87,19 @@ + #define KORINA_RBSIZE 1536 /* size of one resource buffer = Ether MTU */ + #define KORINA_RDS_MASK (KORINA_NUM_RDS - 1) + #define KORINA_TDS_MASK (KORINA_NUM_TDS - 1) +-#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc)) ++#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc)) + #define TD_RING_SIZE (KORINA_NUM_TDS * sizeof(struct dma_desc)) + +-#define TX_TIMEOUT (6000 * HZ / 1000) ++#define TX_TIMEOUT (6000 * HZ / 1000) + +-enum chain_status { desc_filled, desc_empty }; +-#define IS_DMA_FINISHED(X) (((X) & (DMA_DESC_FINI)) != 0) +-#define IS_DMA_DONE(X) (((X) & (DMA_DESC_DONE)) != 0) +-#define RCVPKT_LENGTH(X) (((X) & ETH_RX_LEN) >> ETH_RX_LEN_BIT) ++enum chain_status { ++ desc_filled, ++ desc_empty ++}; ++ ++#define IS_DMA_FINISHED(X) (((X) & (DMA_DESC_FINI)) != 0) ++#define IS_DMA_DONE(X) (((X) & (DMA_DESC_DONE)) != 0) ++#define RCVPKT_LENGTH(X) (((X) & ETH_RX_LEN) >> ETH_RX_LEN_BIT) + + /* Information that need to be kept for each board. */ + struct korina_private { +@@ -123,7 +127,7 @@ struct korina_private { + int rx_irq; + int tx_irq; + +- spinlock_t lock; /* NIC xmit lock */ ++ spinlock_t lock; /* NIC xmit lock */ + + int dma_halt_cnt; + int dma_run_cnt; +@@ -146,17 +150,17 @@ static inline void korina_start_dma(stru + static inline void korina_abort_dma(struct net_device *dev, + struct dma_reg *ch) + { +- if (readl(&ch->dmac) & DMA_CHAN_RUN_BIT) { +- writel(0x10, &ch->dmac); ++ if (readl(&ch->dmac) & DMA_CHAN_RUN_BIT) { ++ writel(0x10, &ch->dmac); + +- while (!(readl(&ch->dmas) & DMA_STAT_HALT)) +- netif_trans_update(dev); ++ while (!(readl(&ch->dmas) & DMA_STAT_HALT)) ++ netif_trans_update(dev); + +- writel(0, &ch->dmas); +- } ++ writel(0, &ch->dmas); ++ } + +- writel(0, &ch->dmadptr); +- writel(0, &ch->dmandptr); ++ writel(0, &ch->dmadptr); ++ writel(0, &ch->dmandptr); + } + + static inline void korina_chain_dma(struct dma_reg *ch, u32 dma_addr) +@@ -685,7 +689,7 @@ static int korina_ioctl(struct net_devic + + /* ethtool helpers */ + static void netdev_get_drvinfo(struct net_device *dev, +- struct ethtool_drvinfo *info) ++ struct ethtool_drvinfo *info) + { + struct korina_private *lp = netdev_priv(dev); + +@@ -727,10 +731,10 @@ static u32 netdev_get_link(struct net_de + } + + static const struct ethtool_ops netdev_ethtool_ops = { +- .get_drvinfo = netdev_get_drvinfo, +- .get_link = netdev_get_link, +- .get_link_ksettings = netdev_get_link_ksettings, +- .set_link_ksettings = netdev_set_link_ksettings, ++ .get_drvinfo = netdev_get_drvinfo, ++ .get_link = netdev_get_link, ++ .get_link_ksettings = netdev_get_link_ksettings, ++ .set_link_ksettings = netdev_set_link_ksettings, + }; + + static int korina_alloc_ring(struct net_device *dev) +@@ -862,7 +866,7 @@ static int korina_init(struct net_device + /* Management Clock Prescaler Divisor + * Clock independent setting */ + writel(((idt_cpu_freq) / MII_CLOCK + 1) & ~1, +- &lp->eth_regs->ethmcp); ++ &lp->eth_regs->ethmcp); + + /* don't transmit until fifo contains 48b */ + writel(48, &lp->eth_regs->ethfifott); +@@ -945,14 +949,14 @@ static int korina_open(struct net_device + 0, "Korina ethernet Rx", dev); + if (ret < 0) { + printk(KERN_ERR "%s: unable to get Rx DMA IRQ %d\n", +- dev->name, lp->rx_irq); ++ dev->name, lp->rx_irq); + goto err_release; + } + ret = request_irq(lp->tx_irq, korina_tx_dma_interrupt, + 0, "Korina ethernet Tx", dev); + if (ret < 0) { + printk(KERN_ERR "%s: unable to get Tx DMA IRQ %d\n", +- dev->name, lp->tx_irq); ++ dev->name, lp->tx_irq); + goto err_free_rx_irq; + } + diff --git a/target/linux/rb532/patches-4.14/110-korina-update-authors.patch b/target/linux/rb532/patches-4.14/110-korina-update-authors.patch new file mode 100644 index 0000000000..843397cf37 --- /dev/null +++ b/target/linux/rb532/patches-4.14/110-korina-update-authors.patch @@ -0,0 +1,17 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -4,6 +4,7 @@ + * Copyright 2004 IDT Inc. (rischelp@idt.com) + * Copyright 2006 Felix Fietkau + * Copyright 2008 Florian Fainelli ++ * Copyright 2017 Roman Yeryomin + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the +@@ -1150,5 +1151,6 @@ module_platform_driver(korina_driver); + MODULE_AUTHOR("Philip Rischel "); + MODULE_AUTHOR("Felix Fietkau "); + MODULE_AUTHOR("Florian Fainelli "); ++MODULE_AUTHOR("Roman Yeryomin "); + MODULE_DESCRIPTION("IDT RC32434 (Korina) Ethernet driver"); + MODULE_LICENSE("GPL"); diff --git a/target/linux/rb532/patches-4.14/111-korina-version-bump.patch b/target/linux/rb532/patches-4.14/111-korina-version-bump.patch new file mode 100644 index 0000000000..1501e174b1 --- /dev/null +++ b/target/linux/rb532/patches-4.14/111-korina-version-bump.patch @@ -0,0 +1,13 @@ +--- a/drivers/net/ethernet/korina.c ++++ b/drivers/net/ethernet/korina.c +@@ -66,8 +66,8 @@ + #include + + #define DRV_NAME "korina" +-#define DRV_VERSION "0.10" +-#define DRV_RELDATE "04Mar2008" ++#define DRV_VERSION "0.20" ++#define DRV_RELDATE "15Sep2017" + + #define STATION_ADDRESS_HIGH(dev) (((dev)->dev_addr[0] << 8) | \ + ((dev)->dev_addr[1])) -- cgit v1.2.3