Make macb/gem RT driver to be built against linux >= 5.0 kernels
PATCH v2 1/1 Make macb/gem RT driver to be built against linux >= 5.0 kernels
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.
--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)
kernel/drivers/net/drivers/macb.c +39 -21
@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 ); +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )if (pdata && pdata->rev_eth_addr) { addr[5 ] = bottom &0xff ; addr[4 ] = (bottom >>8 ) &0xff ;
@@ -139,7 +140,9 @@ void rtmacb_get_hwaddr(struct macb *bp) addr[2 ] = (bottom >>24 ) &0xff ; addr[1 ] = top &0xff ; addr[0 ] = (top &0xff00 ) >>8 ; - }else { + } else +#endif + { addr[0 ] = bottom &0xff ; addr[1 ] = (bottom >>8 ) &0xff ; addr[2 ] = (bottom >>16 ) &0xff ;
@@ -311,10 +314,14 @@ static int macb_mii_probe(struct rtnet_device *dev) {struct macb *bp =rtnetdev_priv (dev);struct macb_dummy_netdev_priv *p; +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )struct macb_platform_data *pdata; +int phy_irq; +#endif struct phy_device *phydev;struct net_device *dummy; -int phy_irq; +struct ethtool_link_ksettings bitmap; +struct ethtool_link_ksettings bitmap_phy;int ret; phydev =phy_find_first (bp->mii_bus);
@@ -323,6 +330,7 @@ static int macb_mii_probe(struct rtnet_device *dev)return -ENXIO ; } +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 ) pdata =dev_get_platdata (&bp->pdev->dev);if (pdata &&gpio_is_valid (pdata->phy_irq_pin)) { ret =devm_gpio_request (&bp->pdev->dev, pdata->phy_irq_pin,"phy int" );
@@ -331,6 +339,7 @@ static int macb_mii_probe(struct rtnet_device *dev) phydev->irq = (phy_irq < 0) ? PHY_POLL : phy_irq; } } +#endif dummy =alloc_etherdev (sizeof (*p)); p =netdev_priv (dummy);
@@ -346,12 +355,26 @@ static int macb_mii_probe(struct rtnet_device *dev) }/* mask with MAC supported features */ -if (macb_is_gem (bp)) - phydev->supported &=PHY_GBIT_FEATURES ; -else - phydev->supported &=PHY_BASIC_FEATURES ; +if (macb_is_gem (bp)) { +ethtool_convert_legacy_u32_to_link_mode ( + bitmap.link_modes.supported, *PHY_GBIT_FEATURES ); +memcpy (bitmap_phy.link_modes.supported, phydev->supported, +sizeof (bitmap_phy.link_modes.supported)); +ethtool_intersect_link_masks (&bitmap_phy, &bitmap); +memcpy (phydev->supported, bitmap_phy.link_modes.supported, +sizeof (phydev->supported)); + }else { +ethtool_convert_legacy_u32_to_link_mode ( + bitmap.link_modes.supported, *PHY_BASIC_FEATURES ); +memcpy (bitmap_phy.link_modes.supported, phydev->supported, +sizeof (bitmap_phy.link_modes.supported)); +ethtool_intersect_link_masks (&bitmap_phy, &bitmap); +memcpy (phydev->supported, bitmap_phy.link_modes.supported, +sizeof (phydev->supported)); + } - phydev->advertising = phydev->supported; +memcpy (phydev->advertising, phydev->supported, +sizeof (phydev->supported)); bp->link =0 ; bp->speed =0 ;
@@ -385,12 +408,6 @@ int rtmacb_mii_init(struct macb *bp) bp->mii_bus->parent = &bp->pdev->dev; pdata =dev_get_platdata (&bp->pdev->dev); - bp->mii_bus->irq =kmalloc (sizeof (int )*PHY_MAX_ADDR ,GFP_KERNEL ); -if (!bp->mii_bus->irq) { - err = -ENOMEM ; - goto err_out_free_mdiobus; - } - np = bp->pdev->dev.of_node;if (np) {/* try dt phy registration */
@@ -434,8 +451,6 @@ int rtmacb_mii_init(struct macb *bp) err_out_unregister_bus:mdiobus_unregister (bp->mii_bus); err_out_free_mdio_irq: -kfree (bp->mii_bus->irq); -err_out_free_mdiobus:mdiobus_free (bp->mii_bus); err_out:return err;
@@ -1532,7 +1547,7 @@ struct net_device_stats *rtmacb_get_stats(struct rtnet_device *dev) }EXPORT_SYMBOL_GPL (rtmacb_get_stats); -int rtmacb_ioctl (struct rtnet_device *dev,unsigned cmd,void *rq) +int rtmacb_ioctl (struct rtnet_device *dev,struct ifreq *rq,int cmd) {struct macb *bp =rtnetdev_priv (dev);struct phy_device *phydev = bp->phy_dev;
@@ -1551,7 +1566,7 @@ EXPORT_SYMBOL_GPL(rtmacb_ioctl);static const struct of_device_id macb_dt_ids[] = { { .compatible ="cdns,at32ap7000-macb" }, { .compatible ="cdns,at91sam9260-macb" }, - { .compatible ="cdns,macb" }, + { .compatible ="cdns,macb_rt" }, { .compatible ="cdns,pc302-gem" }, { .compatible ="cdns,gem" }, { .compatible ="atmel,sama5d3-gem" },
@@ -1562,7 +1577,9 @@ MODULE_DEVICE_TABLE(of, macb_dt_ids);static int __init macb_probe (struct platform_device *pdev) { +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )struct macb_platform_data *pdata; +#endif struct resource *regs;struct rtnet_device *dev;struct macb *bp;
@@ -1695,12 +1712,13 @@ static int __init macb_probe(struct platform_device *pdev)if (err) #else mac =of_get_mac_address (pdev->dev.of_node); -if (mac) +if (!IS_ERR_OR_NULL (mac))memcpy (bp->dev->dev_addr, mac,ETH_ALEN ); else#endif rtmacb_get_hwaddr (bp); +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 ) err =of_get_phy_mode (pdev->dev.of_node);if (err <0 ) { pdata =dev_get_platdata (&pdev->dev);
@@ -1711,6 +1729,7 @@ static int __init macb_probe(struct platform_device *pdev) } else { bp->phy_interface = err; } +#endif if (bp->phy_interface ==PHY_INTERFACE_MODE_RGMII )macb_or_gem_writel (bp,USRIO ,GEM_BIT (RGMII ));
@@ -1748,7 +1767,7 @@ static int __init macb_probe(struct platform_device *pdev) phydev = bp->phy_dev;rtdev_info (dev,"attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n" , - phydev->drv->name,dev_name (&phydev->dev), phydev->irq); + phydev->drv->name,dev_name (&phydev->mdio.dev), phydev->irq);return 0 ;
@@ -1783,7 +1802,6 @@ static int __exit macb_remove(struct platform_device *pdev)mdiobus_unregister (bp->mii_bus);if (bp->phy_phony_net_device)free_netdev (bp->phy_phony_net_device); -kfree (bp->mii_bus->irq);rt_rtdev_disconnect (dev);rtdm_irq_free (&bp->irq_handle);mdiobus_free (bp->mii_bus);
@@ -1801,7 +1819,7 @@ static int __exit macb_remove(struct platform_device *pdev)static struct platform_driver macb_driver = { .remove =__exit_p (macb_remove), .driver = { - .name ="macb" , + .name ="rtmacb" , .owner =THIS_MODULE , .of_match_table =of_match_ptr (macb_dt_ids), },
kernel/drivers/net/drivers/rt_macb.h +1 -1
@@ -611,7 +611,7 @@ struct macb {extern const struct ethtool_ops macb_ethtool_ops;int rtmacb_mii_init (struct macb *bp); -int rtmacb_ioctl (struct rtnet_device *dev,unsigned cmd,void *arg); +int rtmacb_ioctl (struct rtnet_device *dev,struct ifreq *rq,int cmd);struct net_device_stats *rtmacb_get_stats (struct rtnet_device *dev);void rtmacb_set_hwaddr (struct macb *bp);void rtmacb_get_hwaddr (struct macb *bp);
--
2.20.1
Quoted 17 lines · François Legal
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.Signed-off-by François LEGAL <[email protected]>--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)kernel/drivers/net/drivers/macb.c +0
-0
kernel/drivers/net/drivers/macb.c void rtmacb_get_hwaddr(struct macb *bp) · line 135
Quoted 4 lines
kernel/drivers/net/drivers/macb.c +1
-0@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 ); +#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )
Thanks for the patch, but master does not support kernels older than 5.10 (dovetail) anymore.
Is this patch needed for stable/v3.2.x or can it wait for v3.3? In any case, we need a master patch first, then we can discuss whether to backport it as well.
What we also need is enabling of the driver for CI to catch such issues earlier. See .gitlab-ci.yml and all those driver configs there.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · François Legal
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.Signed-off-by François LEGAL <[email protected]>--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)kernel/drivers/net/drivers/macb.c +0
-0@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 );
Quoted 8 lines
kernel/drivers/net/drivers/macb.c void rtmacb_get_hwaddr(struct macb *bp) · line 135
Quoted 1 line
kernel/drivers/net/drivers/macb.c +1
-0+#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )Thanks for the patch, but master does not support kernels older than 5.10 (dovetail) anymore.
Is this patch needed for stable/v3.2.x or can it wait for v3.3? In any case, we need a master patch first, then we can discuss whether to backport it as well.
Well, I started patching 3.2 then submitted it against master. I can submit for 3.2 as well. I believe this is my target version.
Quoted 3 lines
What we also need is enabling of the driver for CI to catch such issues earlier. See .gitlab-ci.yml and all those driver configs there.
I don't really know about this.
Do you want me to submit a patch for this file ? Would it be something like
- ./scripts/config -m XENO_DRIVERS_NET_DRV_E1000_NEW
- ./scripts/config -m XENO_DRIVERS_NET_DRV_RT2500
+ - ./scripts/config -m XENO_DRIVERS_NET_DRV_MACB
- ./scripts/config -m XENO_DRIVERS_NET_FEC
- ./scripts/config -m XENO_DRIVERS_NET_ADDON_RTCAP
François
Quoted 7 lines
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
Quoted 38 lines · François Legal
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · François Legal
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.Signed-off-by François LEGAL <[email protected]>--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)kernel/drivers/net/drivers/macb.c +0
-0@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 );Quoted 8 lines
kernel/drivers/net/drivers/macb.c void rtmacb_get_hwaddr(struct macb *bp) · line 135
Quoted 1 line
kernel/drivers/net/drivers/macb.c +1
-0+#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )Thanks for the patch, but master does not support kernels older than 5.10 (dovetail) anymore.
Is this patch needed for stable/v3.2.x or can it wait for v3.3? In any case, we need a master patch first, then we can discuss whether to backport it as well.
Well, I started patching 3.2 then submitted it against master. I can submit for 3.2 as well. I believe this is my target version.
Quoted 3 lines
What we also need is enabling of the driver for CI to catch such issues earlier. See .gitlab-ci.yml and all those driver configs there.
Quoted 9 lines
I don't really know about this.
Do you want me to submit a patch for this file ? Would it be something like
-./scripts/config-mXENO_DRIVERS_NET_DRV_E1000_NEW
-./scripts/config-mXENO_DRIVERS_NET_DRV_RT2500
+ -./scripts/config-mXENO_DRIVERS_NET_DRV_MACB
-./scripts/config-mXENO_DRIVERS_NET_FEC
-./scripts/config-mXENO_DRIVERS_NET_ADDON_RTCAP
Yes, if that is sufficient to actually build it (check if it has dependencies that may not be fulfilled in a defconfig).
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux
Quoted 49 lines · Jan Kiszka
Quoted 38 lines · François Legal
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · François Legal
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.Signed-off-by François LEGAL <[email protected]>--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)kernel/drivers/net/drivers/macb.c +0
-0@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 );Quoted 8 lines
kernel/drivers/net/drivers/macb.c void rtmacb_get_hwaddr(struct macb *bp) · line 135
Quoted 1 line
kernel/drivers/net/drivers/macb.c +1
-0+#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )Thanks for the patch, but master does not support kernels older than 5.10 (dovetail) anymore.
Is this patch needed for stable/v3.2.x or can it wait for v3.3? In any case, we need a master patch first, then we can discuss whether to backport it as well.
Well, I started patching 3.2 then submitted it against master. I can submit for 3.2 as well. I believe this is my target version.
Quoted 3 lines
What we also need is enabling of the driver for CI to catch such issues earlier. See .gitlab-ci.yml and all those driver configs there.
Quoted 9 lines
I don't really know about this.
Do you want me to submit a patch for this file ? Would it be something like
-./scripts/config-mXENO_DRIVERS_NET_DRV_E1000_NEW
-./scripts/config-mXENO_DRIVERS_NET_DRV_RT2500
+ -./scripts/config-mXENO_DRIVERS_NET_DRV_MACB
-./scripts/config-mXENO_DRIVERS_NET_FEC
-./scripts/config-mXENO_DRIVERS_NET_ADDON_RTCAP
Quoted 2 lines
Yes, if that is sufficient to actually build it (check if it has dependencies that may not be fulfilled in a defconfig).
Thing is, XENO_DRIVERS_NET_DRV_MACB depends on ARM. I'm not sure how this can be achieved in your CI build system
François
Quoted 7 lines
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
Quoted 51 lines · François Legal
Quoted 49 lines · Jan Kiszka
Quoted 47 lines · François Legal
Quoted 21 lines · Jan Kiszka
Quoted 20 lines · François Legal
PHY layer in upstream has changed a little after 5.0 in the way autonegociation capabilities are encoded.
MACB platform data tend to disappear after 5.2 upstream.
Plus, ioctl prototype has changed in xenomai. RTMACB driver does not build anymore.Signed-off-by François LEGAL <[email protected]>--- kernel/drivers/net/drivers/macb.c | 60 ++++++++++++++++++---------- kernel/drivers/net/drivers/rt_macb.h | 2 +- 2 files changed, 40 insertions(+), 22 deletions(-)kernel/drivers/net/drivers/macb.c +0
-0@@ -132,6 +132,7 @@ void rtmacb_get_hwaddr(struct macb *bp) bottom =macb_or_gem_readl (bp,SA1B + i *8 ); top =macb_or_gem_readl (bp,SA1T + i *8 );Quoted 8 lines
kernel/drivers/net/drivers/macb.c void rtmacb_get_hwaddr(struct macb *bp) · line 135
Quoted 1 line
kernel/drivers/net/drivers/macb.c +1
-0+#if LINUX_VERSION_CODE <KERNEL_VERSION (5 ,2 ,0 )Thanks for the patch, but master does not support kernels older than 5.10 (dovetail) anymore.
Is this patch needed for stable/v3.2.x or can it wait for v3.3? In any case, we need a master patch first, then we can discuss whether to backport it as well.
Well, I started patching 3.2 then submitted it against master. I can submit for 3.2 as well. I believe this is my target version.
Quoted 3 lines
What we also need is enabling of the driver for CI to catch such issues earlier. See .gitlab-ci.yml and all those driver configs there.
I don't really know about this.
Do you want me to submit a patch for this file ? Would it be something like
-./scripts/config-mXENO_DRIVERS_NET_DRV_E1000_NEW
-./scripts/config-mXENO_DRIVERS_NET_DRV_RT2500
+ -./scripts/config-mXENO_DRIVERS_NET_DRV_MACB
-./scripts/config-mXENO_DRIVERS_NET_FEC
-./scripts/config-mXENO_DRIVERS_NET_ADDON_RTCAP
Quoted 4 lines
Quoted 2 lines
Yes, if that is sufficient to actually build it (check if it has dependencies that may not be fulfilled in a defconfig).
Thing is,
XENO_DRIVERS_NET_DRV_MACBdepends on ARM. I'm not sure how this can be achieved in your CI build system
Yes, we build for multiple arch, so the driver should at least be tested via the arm-* targets.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux