aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/freescale/gianfar.c
diff options
context:
space:
mode:
authorClaudiu Manoil <claudiu.manoil@freescale.com>2013-01-28 22:55:12 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-29 15:22:02 -0500
commitee873fda3bec7c668407b837fc5519eb961fcd37 (patch)
tree3743136009cf51fe350fdf984bc64ae8517ccc7c /drivers/net/ethernet/freescale/gianfar.c
parent5fedcc14d40e355f966d46e6b19c209e2b36fd5b (diff)
gianfar: Pack struct gfar_priv_grp into three cachelines
* remove unused members(!): imask, ievent * move space consuming interrupt name strings (int_name_* members) to external structures, unessential for the driver's hot path * keep high priority hot path data within the first 2 cache lines This reduces struct gfar_priv_grp from 6 to 3 cache lines. (Also fixed checkpatch warnings for the old code, in the process.) Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale/gianfar.c')
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c98
1 files changed, 65 insertions, 33 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index fdb80804cf2a..19c54a0acb56 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -544,6 +544,19 @@ static void unmap_group_regs(struct gfar_private *priv)
544 iounmap(priv->gfargrp[i].regs); 544 iounmap(priv->gfargrp[i].regs);
545} 545}
546 546
547static void free_gfar_dev(struct gfar_private *priv)
548{
549 int i, j;
550
551 for (i = 0; i < priv->num_grps; i++)
552 for (j = 0; j < GFAR_NUM_IRQS; j++) {
553 kfree(priv->gfargrp[i].irqinfo[j]);
554 priv->gfargrp[i].irqinfo[j] = NULL;
555 }
556
557 free_netdev(priv->ndev);
558}
559
547static void disable_napi(struct gfar_private *priv) 560static void disable_napi(struct gfar_private *priv)
548{ 561{
549 int i; 562 int i;
@@ -565,20 +578,36 @@ static int gfar_parse_group(struct device_node *np,
565{ 578{
566 struct gfar_priv_grp *grp = &priv->gfargrp[priv->num_grps]; 579 struct gfar_priv_grp *grp = &priv->gfargrp[priv->num_grps];
567 u32 *queue_mask; 580 u32 *queue_mask;
581 int i;
582
583 if (priv->mode == MQ_MG_MODE) {
584 for (i = 0; i < GFAR_NUM_IRQS; i++) {
585 grp->irqinfo[i] = kzalloc(sizeof(struct gfar_irqinfo),
586 GFP_KERNEL);
587 if (!grp->irqinfo[i])
588 return -ENOMEM;
589 }
590 } else {
591 grp->irqinfo[GFAR_TX] = kzalloc(sizeof(struct gfar_irqinfo),
592 GFP_KERNEL);
593 if (!grp->irqinfo[GFAR_TX])
594 return -ENOMEM;
595 grp->irqinfo[GFAR_RX] = grp->irqinfo[GFAR_ER] = NULL;
596 }
568 597
569 grp->regs = of_iomap(np, 0); 598 grp->regs = of_iomap(np, 0);
570 if (!grp->regs) 599 if (!grp->regs)
571 return -ENOMEM; 600 return -ENOMEM;
572 601
573 grp->interruptTransmit = irq_of_parse_and_map(np, 0); 602 gfar_irq(grp, TX)->irq = irq_of_parse_and_map(np, 0);
574 603
575 /* If we aren't the FEC we have multiple interrupts */ 604 /* If we aren't the FEC we have multiple interrupts */
576 if (model && strcasecmp(model, "FEC")) { 605 if (model && strcasecmp(model, "FEC")) {
577 grp->interruptReceive = irq_of_parse_and_map(np, 1); 606 gfar_irq(grp, RX)->irq = irq_of_parse_and_map(np, 1);
578 grp->interruptError = irq_of_parse_and_map(np, 2); 607 gfar_irq(grp, ER)->irq = irq_of_parse_and_map(np, 2);
579 if (grp->interruptTransmit == NO_IRQ || 608 if (gfar_irq(grp, TX)->irq == NO_IRQ ||
580 grp->interruptReceive == NO_IRQ || 609 gfar_irq(grp, RX)->irq == NO_IRQ ||
581 grp->interruptError == NO_IRQ) 610 gfar_irq(grp, ER)->irq == NO_IRQ)
582 return -EINVAL; 611 return -EINVAL;
583 } 612 }
584 613
@@ -779,7 +808,7 @@ tx_alloc_failed:
779 free_tx_pointers(priv); 808 free_tx_pointers(priv);
780err_grp_init: 809err_grp_init:
781 unmap_group_regs(priv); 810 unmap_group_regs(priv);
782 free_netdev(dev); 811 free_gfar_dev(priv);
783 return err; 812 return err;
784} 813}
785 814
@@ -1184,15 +1213,16 @@ static int gfar_probe(struct platform_device *ofdev)
1184 1213
1185 /* fill out IRQ number and name fields */ 1214 /* fill out IRQ number and name fields */
1186 for (i = 0; i < priv->num_grps; i++) { 1215 for (i = 0; i < priv->num_grps; i++) {
1216 struct gfar_priv_grp *grp = &priv->gfargrp[i];
1187 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { 1217 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
1188 sprintf(priv->gfargrp[i].int_name_tx, "%s%s%c%s", 1218 sprintf(gfar_irq(grp, TX)->name, "%s%s%c%s",
1189 dev->name, "_g", '0' + i, "_tx"); 1219 dev->name, "_g", '0' + i, "_tx");
1190 sprintf(priv->gfargrp[i].int_name_rx, "%s%s%c%s", 1220 sprintf(gfar_irq(grp, RX)->name, "%s%s%c%s",
1191 dev->name, "_g", '0' + i, "_rx"); 1221 dev->name, "_g", '0' + i, "_rx");
1192 sprintf(priv->gfargrp[i].int_name_er, "%s%s%c%s", 1222 sprintf(gfar_irq(grp, ER)->name, "%s%s%c%s",
1193 dev->name, "_g", '0' + i, "_er"); 1223 dev->name, "_g", '0' + i, "_er");
1194 } else 1224 } else
1195 strcpy(priv->gfargrp[i].int_name_tx, dev->name); 1225 strcpy(gfar_irq(grp, TX)->name, dev->name);
1196 } 1226 }
1197 1227
1198 /* Initialize the filer table */ 1228 /* Initialize the filer table */
@@ -1225,7 +1255,7 @@ register_fail:
1225 of_node_put(priv->phy_node); 1255 of_node_put(priv->phy_node);
1226 if (priv->tbi_node) 1256 if (priv->tbi_node)
1227 of_node_put(priv->tbi_node); 1257 of_node_put(priv->tbi_node);
1228 free_netdev(dev); 1258 free_gfar_dev(priv);
1229 return err; 1259 return err;
1230} 1260}
1231 1261
@@ -1242,7 +1272,7 @@ static int gfar_remove(struct platform_device *ofdev)
1242 1272
1243 unregister_netdev(priv->ndev); 1273 unregister_netdev(priv->ndev);
1244 unmap_group_regs(priv); 1274 unmap_group_regs(priv);
1245 free_netdev(priv->ndev); 1275 free_gfar_dev(priv);
1246 1276
1247 return 0; 1277 return 0;
1248} 1278}
@@ -1650,9 +1680,9 @@ void gfar_halt(struct net_device *dev)
1650 1680
1651static void free_grp_irqs(struct gfar_priv_grp *grp) 1681static void free_grp_irqs(struct gfar_priv_grp *grp)
1652{ 1682{
1653 free_irq(grp->interruptError, grp); 1683 free_irq(gfar_irq(grp, TX)->irq, grp);
1654 free_irq(grp->interruptTransmit, grp); 1684 free_irq(gfar_irq(grp, RX)->irq, grp);
1655 free_irq(grp->interruptReceive, grp); 1685 free_irq(gfar_irq(grp, ER)->irq, grp);
1656} 1686}
1657 1687
1658void stop_gfar(struct net_device *dev) 1688void stop_gfar(struct net_device *dev)
@@ -1681,7 +1711,7 @@ void stop_gfar(struct net_device *dev)
1681 free_grp_irqs(&priv->gfargrp[i]); 1711 free_grp_irqs(&priv->gfargrp[i]);
1682 } else { 1712 } else {
1683 for (i = 0; i < priv->num_grps; i++) 1713 for (i = 0; i < priv->num_grps; i++)
1684 free_irq(priv->gfargrp[i].interruptTransmit, 1714 free_irq(gfar_irq(&priv->gfargrp[i], TX)->irq,
1685 &priv->gfargrp[i]); 1715 &priv->gfargrp[i]);
1686 } 1716 }
1687 1717
@@ -1856,32 +1886,34 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1856 /* Install our interrupt handlers for Error, 1886 /* Install our interrupt handlers for Error,
1857 * Transmit, and Receive 1887 * Transmit, and Receive
1858 */ 1888 */
1859 if ((err = request_irq(grp->interruptError, gfar_error, 1889 err = request_irq(gfar_irq(grp, ER)->irq, gfar_error, 0,
1860 0, grp->int_name_er, grp)) < 0) { 1890 gfar_irq(grp, ER)->name, grp);
1891 if (err < 0) {
1861 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 1892 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
1862 grp->interruptError); 1893 gfar_irq(grp, ER)->irq);
1863 1894
1864 goto err_irq_fail; 1895 goto err_irq_fail;
1865 } 1896 }
1866 1897 err = request_irq(gfar_irq(grp, TX)->irq, gfar_transmit, 0,
1867 if ((err = request_irq(grp->interruptTransmit, gfar_transmit, 1898 gfar_irq(grp, TX)->name, grp);
1868 0, grp->int_name_tx, grp)) < 0) { 1899 if (err < 0) {
1869 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 1900 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
1870 grp->interruptTransmit); 1901 gfar_irq(grp, TX)->irq);
1871 goto tx_irq_fail; 1902 goto tx_irq_fail;
1872 } 1903 }
1873 1904 err = request_irq(gfar_irq(grp, RX)->irq, gfar_receive, 0,
1874 if ((err = request_irq(grp->interruptReceive, gfar_receive, 1905 gfar_irq(grp, RX)->name, grp);
1875 0, grp->int_name_rx, grp)) < 0) { 1906 if (err < 0) {
1876 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 1907 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
1877 grp->interruptReceive); 1908 gfar_irq(grp, RX)->irq);
1878 goto rx_irq_fail; 1909 goto rx_irq_fail;
1879 } 1910 }
1880 } else { 1911 } else {
1881 if ((err = request_irq(grp->interruptTransmit, gfar_interrupt, 1912 err = request_irq(gfar_irq(grp, TX)->irq, gfar_interrupt, 0,
1882 0, grp->int_name_tx, grp)) < 0) { 1913 gfar_irq(grp, TX)->name, grp);
1914 if (err < 0) {
1883 netif_err(priv, intr, dev, "Can't get IRQ %d\n", 1915 netif_err(priv, intr, dev, "Can't get IRQ %d\n",
1884 grp->interruptTransmit); 1916 gfar_irq(grp, TX)->irq);
1885 goto err_irq_fail; 1917 goto err_irq_fail;
1886 } 1918 }
1887 } 1919 }
@@ -1889,9 +1921,9 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1889 return 0; 1921 return 0;
1890 1922
1891rx_irq_fail: 1923rx_irq_fail:
1892 free_irq(grp->interruptTransmit, grp); 1924 free_irq(gfar_irq(grp, TX)->irq, grp);
1893tx_irq_fail: 1925tx_irq_fail:
1894 free_irq(grp->interruptError, grp); 1926 free_irq(gfar_irq(grp, ER)->irq, grp);
1895err_irq_fail: 1927err_irq_fail:
1896 return err; 1928 return err;
1897 1929