ibm: emac: more cleanups
Subsystems (2)
v3 cover ibm: emac: more cleanups
Tested on Cisco MX60W.
Added devm for the submodules and removed custom init/exit functions as EPROBE_DEFER is handled now.
v2: fixed build errors. Also added extra commits to clean the driver up further.
v3: Added tested message. Removed bad alloc_netdev_dummy commit.
Rosen Penev (17):
net: ibm: emac: use netif_receive_skb_list
net: ibm: emac: remove custom init/exit functions
net: ibm: emac: use module_platform_driver for modules
net: ibm: emac: use devm_platform_ioremap_resource
net: ibm: emac: use platform_get_irq
net: ibm: emac: remove bootlist support
net: ibm: emac: tah: use devm for kzalloc
net: ibm: emac: tah: devm_platform_get_resources
net: ibm: emac: rgmii: use devm for kzalloc
net: ibm: emac: rgmii: devm_platform_get_resource
net: ibm: emac: zmii: use devm for kzalloc
net: ibm: emac: zmii: devm_platform_get_resource
net: ibm: emac: mal: use devm for kzalloc
net: ibm: emac: mal: use devm for request_irq
net: ibm: emac: mal: move irq maps down
net: ibm: emac: mal: add dcr_unmap to _remove
net: ibm: emac: mal: move dcr map down
drivers/net/ethernet/ibm/emac/core.c | 175 +++----------------------- drivers/net/ethernet/ibm/emac/mal.c | 117 ++++++----------- drivers/net/ethernet/ibm/emac/mal.h | 4 - drivers/net/ethernet/ibm/emac/rgmii.c | 53 ++------ drivers/net/ethernet/ibm/emac/rgmii.h | 4 - drivers/net/ethernet/ibm/emac/tah.c | 53 ++------ drivers/net/ethernet/ibm/emac/tah.h | 4 - drivers/net/ethernet/ibm/emac/zmii.c | 53 ++------ drivers/net/ethernet/ibm/emac/zmii.h | 4 - 9 files changed, 84 insertions(+), 383 deletions(-)
Signature · 1 line
2.46.2
PATCH v3 1/17 net: ibm: emac: use netif_receive_skb_list
Small rx improvement. Would use napi_gro_receive instead but that's a lot more involved than netif_receive_skb_list because of how the function is implemented.
Before:
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 51556 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 559 MBytes 467 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 48228 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.03 sec 558 MBytes 467 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 47600 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 557 MBytes 466 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 37252 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 559 MBytes 467 Mbits/sec
After:
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 40786 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 572 MBytes 478 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 52482 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 571 MBytes 477 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 48370 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 572 MBytes 478 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 46086 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.05 sec 571 MBytes 476 Mbits/sec
Quoted 1 line
iperf -c 192.168.1.1
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 1] local 192.168.1.101 port 46062 connected with 192.168.1.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.00-10.04 sec 572 MBytes 478 Mbits/sec
--- drivers/net/ethernet/ibm/emac/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +4 -2
@@ -1727,6 +1727,7 @@ static inline int emac_rx_sg_append(struct emac_instance *dev, int slot)/* NAPI poll context */ static int emac_poll_rx (void *param,int budget) { +LIST_HEAD (rx_list);struct emac_instance *dev = param;int slot = dev->rx_slot, received =0 ;
@@ -1783,8 +1784,7 @@ static int emac_poll_rx(void *param, int budget) skb->protocol =eth_type_trans (skb, dev->ndev);emac_rx_csum (dev, skb, ctrl); -if (unlikely (netif_receive_skb (skb) ==NET_RX_DROP )) - ++dev->estats.rx_dropped_stack; +list_add_tail (&skb->list, &rx_list); next: ++dev->stats.rx_packets; skip:
@@ -1828,6 +1828,8 @@ static int emac_poll_rx(void *param, int budget) goto next; } +netif_receive_skb_list (&rx_list); +if (received) {DBG2 (dev,"rx %d BDs" NL , received); dev->rx_slot = slot;
Signature · 1 line
2.46.2
PATCH v3 2/17 net: ibm: emac: remove custom init/exit functions
In reply to Rosen PenevNow that we're using EPROBE_DEFER, we don't have to do custom initialization and we can let the core handle this for us.
--- drivers/net/ethernet/ibm/emac/core.c | 39 +-------------------------- drivers/net/ethernet/ibm/emac/mal.h | 4 --- drivers/net/ethernet/ibm/emac/rgmii.h | 4 --- drivers/net/ethernet/ibm/emac/tah.h | 4 --- drivers/net/ethernet/ibm/emac/zmii.h | 4 --- 5 files changed, 1 insertion(+), 54 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +1 -38
@@ -3283,42 +3283,10 @@ static void __init emac_make_bootlist(void)static int __init emac_init (void ) { -int rc; - - printk(KERN_INFO DRV_DESC ", version " DRV_VERSION "\n"); -/* Build EMAC boot list */ emac_make_bootlist (); -/* Init submodules */ - rc =mal_init (); -if (rc) - goto err; - rc =zmii_init (); -if (rc) - goto err_mal; - rc =rgmii_init (); -if (rc) - goto err_zmii; - rc =tah_init (); -if (rc) - goto err_rgmii; - rc =platform_driver_register (&emac_driver); -if (rc) - goto err_tah; - -return 0 ; - - err_tah: -tah_exit (); - err_rgmii: -rgmii_exit (); - err_zmii: -zmii_exit (); - err_mal: -mal_exit (); - err: -return rc; +return platform_driver_register (&emac_driver); } static void __exit emac_exit(void)
@@ -3327,11 +3295,6 @@ static void __exit emac_exit(void)platform_driver_unregister (&emac_driver); -tah_exit (); -rgmii_exit (); -zmii_exit (); -mal_exit (); -/* Destroy EMAC boot list */ for (i =0 ; i <EMAC_BOOT_LIST_SIZE ; i++)of_node_put (emac_boot_list[i]);
drivers/net/ethernet/ibm/emac/mal.h +0 -4
@@ -252,10 +252,6 @@ static inline int mal_has_feature(struct mal_instance *dev, (MAL_FTRS_POSSIBLE & dev->features & feature); } -/* Register MAL devices */ -int mal_init (void ); -void mal_exit (void ); -int mal_register_commac (struct mal_instance *mal,struct mal_commac *commac); void mal_unregister_commac(struct mal_instance *mal,
drivers/net/ethernet/ibm/emac/rgmii.h +0 -4
@@ -52,8 +52,6 @@ struct rgmii_instance {#ifdef CONFIG_IBM_EMAC_RGMII -int rgmii_init (void ); -void rgmii_exit (void );int rgmii_attach (struct platform_device *ofdev,int input,int mode);void rgmii_detach (struct platform_device *ofdev,int input);void rgmii_get_mdio (struct platform_device *ofdev,int input);
@@ -64,8 +62,6 @@ void *rgmii_dump_regs(struct platform_device *ofdev, void *buf);#else -# define rgmii_init () 0 -# define rgmii_exit () do { } while(0)# define rgmii_attach (x,y,z) (-ENXIO)# define rgmii_detach (x,y) do { } while(0)# define rgmii_get_mdio (o,i) do { } while (0)
drivers/net/ethernet/ibm/emac/tah.h +0 -4
@@ -68,8 +68,6 @@ struct tah_instance {#ifdef CONFIG_IBM_EMAC_TAH -int tah_init (void ); -void tah_exit (void );int tah_attach (struct platform_device *ofdev,int channel);void tah_detach (struct platform_device *ofdev,int channel);void tah_reset (struct platform_device *ofdev);
@@ -78,8 +76,6 @@ void *tah_dump_regs(struct platform_device *ofdev, void *buf);#else -# define tah_init () 0 -# define tah_exit () do { } while(0)# define tah_attach (x,y) (-ENXIO)# define tah_detach (x,y) do { } while(0)# define tah_reset (x) do { } while(0)
drivers/net/ethernet/ibm/emac/zmii.h +0 -4
@@ -48,8 +48,6 @@ struct zmii_instance {#ifdef CONFIG_IBM_EMAC_ZMII -int zmii_init (void ); -void zmii_exit (void );int zmii_attach (struct platform_device *ofdev,int input,phy_interface_t *mode);void zmii_detach (struct platform_device *ofdev,int input);
@@ -60,8 +58,6 @@ int zmii_get_regs_len(struct platform_device *ocpdev);void *zmii_dump_regs (struct platform_device *ofdev,void *buf);#else -# define zmii_init () 0 -# define zmii_exit () do { } while(0)# define zmii_attach (x,y,z) (-ENXIO)# define zmii_detach (x,y) do { } while(0)# define zmii_get_mdio (x,y) do { } while(0)
Signature · 1 line
2.46.2
Jakub Kicinski
maintainerRe: [PATCH net-next v3 02/17] net: ibm: emac: remove custom init/exit functions
Quoted 2 lines · On Wed, 2 Oct 2024 19:11:20 -0700 Rosen Penev wrote:
Now that we're using
EPROBE_DEFER, we don't have to do custom initialization and we can let the core handle this for us.
Could you add a reference for this "now"? Which commit changes things?
PATCH v3 3/17 net: ibm: emac: use module_platform_driver for modules
In reply to Rosen PenevThese init and exit functions don't do anything special. Just macro it away.
--- drivers/net/ethernet/ibm/emac/mal.c | 10 +--------- drivers/net/ethernet/ibm/emac/rgmii.c | 10 +--------- drivers/net/ethernet/ibm/emac/tah.c | 10 +--------- drivers/net/ethernet/ibm/emac/zmii.c | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-)
drivers/net/ethernet/ibm/emac/mal.c +1 -9
@@ -779,12 +779,4 @@ static struct platform_driver mal_of_driver = { .remove_new = mal_remove, }; -int __init mal_init (void ) -{ -return platform_driver_register (&mal_of_driver); -} - -void mal_exit (void ) -{ -platform_driver_unregister (&mal_of_driver); -} +module_platform_driver (mal_of_driver);
drivers/net/ethernet/ibm/emac/rgmii.c +1 -9
@@ -303,12 +303,4 @@ static struct platform_driver rgmii_driver = { .remove_new = rgmii_remove, }; -int __init rgmii_init (void ) -{ -return platform_driver_register (&rgmii_driver); -} - -void rgmii_exit (void ) -{ -platform_driver_unregister (&rgmii_driver); -} +module_platform_driver (rgmii_driver);
drivers/net/ethernet/ibm/emac/tah.c +1 -9
@@ -161,12 +161,4 @@ static struct platform_driver tah_driver = { .remove_new = tah_remove, }; -int __init tah_init (void ) -{ -return platform_driver_register (&tah_driver); -} - -void tah_exit (void ) -{ -platform_driver_unregister (&tah_driver); -} +module_platform_driver (tah_driver);
drivers/net/ethernet/ibm/emac/zmii.c +1 -9
@@ -309,12 +309,4 @@ static struct platform_driver zmii_driver = { .remove_new = zmii_remove, }; -int __init zmii_init (void ) -{ -return platform_driver_register (&zmii_driver); -} - -void zmii_exit (void ) -{ -platform_driver_unregister (&zmii_driver); -} +module_platform_driver (zmii_driver);
Signature · 1 line
2.46.2
Jakub Kicinski
maintainerRe: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules
Quoted 19 lines · On Wed, 2 Oct 2024 19:11:21 -0700 Rosen Penev wrote:
These init and exit functions don't do anything special. Just macro it away.
Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/ibm/emac/mal.c | 10 +--------- drivers/net/ethernet/ibm/emac/rgmii.c | 10 +--------- drivers/net/ethernet/ibm/emac/tah.c | 10 +--------- drivers/net/ethernet/ibm/emac/zmii.c | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-)drivers/net/ethernet/ibm/emac/mal.c +0
-0@@ -779,12 +779,4 @@ static struct platform_driver mal_of_driver = { .remove_new = mal_remove, };
drivers/net/ethernet/ibm/emac/mal.c static struct platform_driver mal_of_driver = { · line 782
Quoted 10 lines
drivers/net/ethernet/ibm/emac/mal.c +1
-9-int __init mal_init (void ) -{ -return platform_driver_register (&mal_of_driver); -} - -void mal_exit (void ) -{ -platform_driver_unregister (&mal_of_driver); -} +module_platform_driver (mal_of_driver);
This is not 1:1, right? We're now implicitly adding module_init() module_exit() annotations which weren't there before. Needs to be at least mentioned in the commit msg.
Re: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules
Quoted 21 lines · Jakub Kicinski
Quoted 19 lines · On Wed, 2 Oct 2024 19:11:21 -0700 Rosen Penev wrote:
These init and exit functions don't do anything special. Just macro it away.
Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/ibm/emac/mal.c | 10 +--------- drivers/net/ethernet/ibm/emac/rgmii.c | 10 +--------- drivers/net/ethernet/ibm/emac/tah.c | 10 +--------- drivers/net/ethernet/ibm/emac/zmii.c | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-)drivers/net/ethernet/ibm/emac/mal.c +0
-0@@ -779,12 +779,4 @@ static struct platform_driver mal_of_driver = { .remove_new = mal_remove, };
Quoted 14 lines
drivers/net/ethernet/ibm/emac/mal.c static struct platform_driver mal_of_driver = { · line 782
Quoted 10 lines
drivers/net/ethernet/ibm/emac/mal.c +1
-9-int __init mal_init (void ) -{ -return platform_driver_register (&mal_of_driver); -} - -void mal_exit (void ) -{ -platform_driver_unregister (&mal_of_driver); -} +module_platform_driver (mal_of_driver);This is not 1:1, right? We're now implicitly adding
module_init()module_exit()annotations which weren't there before. Needs to be at least mentioned in the commit msg.
Sure. The prior commit removes direct usage by core.c of these functions.
kernel test robot
build botRe: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules
In reply to Rosen Penevkernel test robot noticed the following build errors:
Hi Rosen,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-ibm-emac-use-netif_receive_skb_list/20241003-101754 base: net-next/main patch link: https://lore.kernel.org/r/20241003021135.1952928-4-rosenp%40gmail.com patch subject: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20241006/[email protected]/config) compiler: powerpc64-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241006/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/core.o: in function `emac_init':
>> core.c:(.init.text+0x8): multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.init.text+0x8): first defined here powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/core.o: in function `emac_exit': >> core.c:(.exit.text+0x8): multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.exit.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/zmii.o: in function `zmii_driver_init':
zmii.c:(.init.text+0x8): multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.init.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/zmii.o: in function `zmii_driver_exit':
zmii.c:(.exit.text+0x8): multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.exit.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/rgmii.o: in function `rgmii_driver_init':
rgmii.c:(.init.text+0x8): multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.init.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/rgmii.o: in function `rgmii_driver_exit':
rgmii.c:(.exit.text+0x8): multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.exit.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/tah.o: in function `tah_driver_init':
tah.c:(.init.text+0x8): multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.init.text+0x8): first defined here
powerpc64-linux-ld: drivers/net/ethernet/ibm/emac/tah.o: in function `tah_driver_exit':
tah.c:(.exit.text+0x8): multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:mal.c:(.exit.text+0x8): first defined here
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules
In reply to Rosen Penevkernel test robot noticed the following build errors:
Hi Rosen,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-ibm-emac-use-netif_receive_skb_list/20241003-101754 base: net-next/main patch link: https://lore.kernel.org/r/20241003021135.1952928-4-rosenp%40gmail.com patch subject: [PATCH net-next v3 03/17] net: ibm: emac: use module_platform_driver for modules config: powerpc-fsp2_defconfig (https://download.01.org/0day-ci/archive/20241007/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241007/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
powerpc-linux-ld: drivers/net/ethernet/ibm/emac/core.o: in function `emac_init':
>> drivers/net/ethernet/ibm/emac/core.c:3285: multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:drivers/net/ethernet/ibm/emac/mal.c:782: first defined here powerpc-linux-ld: drivers/net/ethernet/ibm/emac/core.o: in function `emac_exit': >> drivers/net/ethernet/ibm/emac/core.c:3293: multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:drivers/net/ethernet/ibm/emac/mal.c:782: first defined here
powerpc-linux-ld: drivers/net/ethernet/ibm/emac/rgmii.o: in function `rgmii_driver_init':
drivers/net/ethernet/ibm/emac/rgmii.c:306: multiple definition of `init_module'; drivers/net/ethernet/ibm/emac/mal.o:drivers/net/ethernet/ibm/emac/mal.c:782: first defined here
powerpc-linux-ld: drivers/net/ethernet/ibm/emac/rgmii.o: in function `rgmii_driver_exit':
drivers/net/ethernet/ibm/emac/rgmii.c:306: multiple definition of `cleanup_module'; drivers/net/ethernet/ibm/emac/mal.o:drivers/net/ethernet/ibm/emac/mal.c:782: first defined here
vim +3285 drivers/net/ethernet/ibm/emac/core.c
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3283
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3284 static int __init emac_init(void)
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 @3285 {
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3286 /* Build EMAC boot list */
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3287 emac_make_bootlist();
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3288
c142fce2e67e1b drivers/net/ethernet/ibm/emac/core.c Rosen Penev 2024-10-02 3289 return platform_driver_register(&emac_driver);
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3290 }
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3291
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3292 static void __exit emac_exit(void)
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 @3293 {
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3294 int i;
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3295
74888760d40b3a drivers/net/ibm_newemac/core.c Grant Likely 2011-02-22 3296 platform_driver_unregister(&emac_driver);
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3297
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3298 /* Destroy EMAC boot list */
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3299 for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3300 of_node_put(emac_boot_list[i]);
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3301 }
1d3bb996481e11 drivers/net/ibm_newemac/core.c David Gibson 2007-08-23 3302 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 4/17 net: ibm: emac: use devm_platform_ioremap_resource
In reply to Rosen PenevNo need to have a struct resource. Gets rid of the TODO.
--- drivers/net/ethernet/ibm/emac/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +3 -5
@@ -3050,12 +3050,10 @@ static int emac_probe(struct platform_device *ofdev) ndev->irq = dev->emac_irq; -/* Map EMAC regs */ -// TODO : platform_get_resource() and devm_ioremap_resource() - dev->emacp =devm_of_iomap (&ofdev->dev, np,0 ,NULL ); -if (!dev->emacp) { + dev->emacp =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (dev->emacp)) {dev_err (&ofdev->dev,"can't map device registers" ); - err = -ENOMEM ; + err =PTR_ERR (dev->emacp); goto err_gone; }
Signature · 1 line
2.46.2
PATCH v3 5/17 net: ibm: emac: use platform_get_irq
In reply to Rosen PenevNo need for irq_of_parse_and_map since we have platform_device.
--- drivers/net/ethernet/ibm/emac/core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +1 -8
@@ -3031,15 +3031,8 @@ static int emac_probe(struct platform_device *ofdev)if (err) goto err_gone; -/* Get interrupts. EMAC irq is mandatory */ - dev->emac_irq =irq_of_parse_and_map (np,0 ); -if (!dev->emac_irq) { -printk (KERN_ERR "%pOF: Can't map main interrupt\n" , np); - err = -ENODEV ; - goto err_gone; - } -/* Setup error IRQ handler */ + dev->emac_irq =platform_get_irq (ofdev,0 ); err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , dev);if (err) {
Signature · 1 line
2.46.2
PATCH v3 6/17 net: ibm: emac: remove bootlist support
In reply to Rosen PenevThis seems to be mainly used for deterministic interfaces. systemd already does this in userspace.
Allows simplifying the driver with a single module_platform_driver.
--- drivers/net/ethernet/ibm/emac/core.c | 117 +++------------------------ 1 file changed, 9 insertions(+), 108 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +9 -108
@@ -95,21 +95,6 @@ MODULE_LICENSE("GPL");static u32 busy_phy_map;static DEFINE_MUTEX (emac_phy_map_lock); -/* Having stable interface names is a doomed idea. However, it would be nice -* if we didn't have completely random interface names at boot too :-) It's -* just a matter of making everybody's life easier. Since we are doing -* threaded probing, it's a bit harder though. The base idea here is that -* we make up a list of all emacs in the device-tree before we register the -* driver. Every emac will then wait for the previous one in the list to -* initialize before itself. We should also keep that list ordered by -* cell_index. -* That list is only 4 entries long, meaning that additional EMACs don't -* get ordering guarantees unless EMAC_BOOT_LIST_SIZE is increased. -*/ - -#define EMAC_BOOT_LIST_SIZE 4 -static struct device_node *emac_boot_list[EMAC_BOOT_LIST_SIZE ]; -/* I don't want to litter system log with timeout errors * when we have brain-damaged PHY. */
@@ -2330,14 +2315,12 @@ struct emac_depentry {#define EMAC_DEP_RGMII_IDX 2#define EMAC_DEP_TAH_IDX 3#define EMAC_DEP_MDIO_IDX 4 -#define EMAC_DEP_PREV_IDX 5 -#define EMAC_DEP_COUNT 6 +#define EMAC_DEP_COUNT 5static int emac_check_deps (struct emac_instance *dev,struct emac_depentry *deps) {int i, there =0 ; -struct device_node *np;for (i =0 ; i <EMAC_DEP_COUNT ; i++) {/* no dependency on that item, allright */
@@ -2345,17 +2328,6 @@ static int emac_check_deps(struct emac_instance *dev, there++;continue ; } -/* special case for blist as the dependency might go away */ -if (i ==EMAC_DEP_PREV_IDX ) { - np = *(dev->blist -1 ); -if (np ==NULL ) { - deps[i].phandle =0 ; - there++; -continue ; - } -if (deps[i].node ==NULL ) - deps[i].node =of_node_get (np); - }if (deps[i].node ==NULL ) deps[i].node =of_find_node_by_phandle (deps[i].phandle);if (deps[i].node ==NULL )
@@ -2397,8 +2369,6 @@ static int emac_wait_deps(struct emac_instance *dev) deps[EMAC_DEP_TAH_IDX ].phandle = dev->tah_ph;if (dev->mdio_ph) deps[EMAC_DEP_MDIO_IDX ].phandle = dev->mdio_ph; -if (dev->blist && dev->blist > emac_boot_list) - deps[EMAC_DEP_PREV_IDX ].phandle =0xffffffffu ; err =emac_check_deps (dev, deps);for (i =0 ; i <EMAC_DEP_COUNT ; i++) {of_node_put (deps[i].node);
@@ -2412,7 +2382,6 @@ static int emac_wait_deps(struct emac_instance *dev) dev->tah_dev = deps[EMAC_DEP_TAH_IDX ].ofdev; dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX ].ofdev; } -platform_device_put (deps[EMAC_DEP_PREV_IDX ].ofdev);return err; }
@@ -2993,8 +2962,7 @@ static int emac_probe(struct platform_device *ofdev)struct net_device *ndev;struct emac_instance *dev;struct device_node *np = ofdev->dev.of_node; -struct device_node **blist =NULL ; -int err, i; +int err;/* Skip unused/unwired EMACS. We leave the check for an unused * property here for now, but new flat device trees should set a
@@ -3003,21 +2971,14 @@ static int emac_probe(struct platform_device *ofdev)if (of_property_read_bool (np,"unused" ) || !of_device_is_available (np))return -ENODEV ; -/* Find ourselves in the bootlist if we are there */ -for (i =0 ; i <EMAC_BOOT_LIST_SIZE ; i++) -if (emac_boot_list[i] == np) - blist = &emac_boot_list[i]; -/* Allocate our net_device structure */ - err = -ENOMEM ; ndev =devm_alloc_etherdev (&ofdev->dev,sizeof (struct emac_instance ));if (!ndev) - goto err_gone; +return -ENOMEM ; dev =netdev_priv (ndev); dev->ndev = ndev; dev->ofdev = ofdev; - dev->blist = blist;SET_NETDEV_DEV (ndev, &ofdev->dev);/* Initialize some embedded data structures */
@@ -3029,16 +2990,15 @@ static int emac_probe(struct platform_device *ofdev)/* Init various config data based on device-tree */ err =emac_init_config (dev);if (err) - goto err_gone; +return err;/* Setup error IRQ handler */ dev->emac_irq =platform_get_irq (ofdev,0 ); err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , dev);if (err) { -dev_err_probe (&ofdev->dev, err,"failed to request IRQ %d" , - dev->emac_irq); - goto err_gone; +return dev_err_probe (&ofdev->dev, err, +"failed to request IRQ %d" , dev->emac_irq); } ndev->irq = dev->emac_irq;
@@ -3046,14 +3006,13 @@ static int emac_probe(struct platform_device *ofdev) dev->emacp =devm_platform_ioremap_resource (ofdev,0 );if (IS_ERR (dev->emacp)) {dev_err (&ofdev->dev,"can't map device registers" ); - err =PTR_ERR (dev->emacp); - goto err_gone; +return PTR_ERR (dev->emacp); }/* Wait for dependent devices */ err =emac_wait_deps (dev);if (err) - goto err_gone; +return err; dev->mal =platform_get_drvdata (dev->mal_dev);if (dev->mdio_dev !=NULL ) dev->mdio_instance =platform_get_drvdata (dev->mdio_dev);
@@ -3181,9 +3140,6 @@ static int emac_probe(struct platform_device *ofdev)mal_unregister_commac (dev->mal, &dev->commac); err_rel_deps:emac_put_deps (dev); - err_gone: -if (blist) - *blist =NULL ;return err; }
@@ -3237,59 +3193,4 @@ static struct platform_driver emac_driver = { .remove_new = emac_remove, }; -static void __init emac_make_bootlist (void ) -{ -struct device_node *np =NULL ; -int j, max, i =0 ; -int cell_indices[EMAC_BOOT_LIST_SIZE ]; - -/* Collect EMACs */ -while ((np =of_find_all_nodes (np)) !=NULL ) { -u32 idx; - -if (of_match_node (emac_match, np) ==NULL ) -continue ; -if (of_property_read_bool (np,"unused" )) -continue ; -if (of_property_read_u32 (np,"cell-index" , &idx)) -continue ; - cell_indices[i] = idx; - emac_boot_list[i++] =of_node_get (np); -if (i >=EMAC_BOOT_LIST_SIZE ) { -of_node_put (np); -break ; - } - } - max = i; - -/* Bubble sort them (doh, what a creative algorithm :-) */ -for (i =0 ; max >1 && (i < (max -1 )); i++) -for (j = i; j < max; j++) { -if (cell_indices[i] > cell_indices[j]) { -swap (emac_boot_list[i], emac_boot_list[j]); -swap (cell_indices[i], cell_indices[j]); - } - } -} - -static int __init emac_init (void ) -{ -/* Build EMAC boot list */ -emac_make_bootlist (); - -return platform_driver_register (&emac_driver); -} - -static void __exit emac_exit(void) -{ -int i; - -platform_driver_unregister (&emac_driver); - -/* Destroy EMAC boot list */ -for (i =0 ; i <EMAC_BOOT_LIST_SIZE ; i++) -of_node_put (emac_boot_list[i]); -} - -module_init (emac_init); -module_exit (emac_exit); +module_platform_driver (emac_driver);
Signature · 1 line
2.46.2
Jakub Kicinski
maintainerRe: [PATCH net-next v3 06/17] net: ibm: emac: remove bootlist support
Quoted 2 lines · On Wed, 2 Oct 2024 19:11:24 -0700 Rosen Penev wrote:
This seems to be mainly used for deterministic interfaces. systemd already does this in userspace.
I guess.. but what gives you the confidence this is not going to cause a regression for people? There's certainly plenty of machines with "stable naming" disabled. Whether that's wise or not is a separate question..
Re: [PATCH net-next v3 06/17] net: ibm: emac: remove bootlist support
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Wed, 2 Oct 2024 19:11:24 -0700 Rosen Penev wrote:
This seems to be mainly used for deterministic interfaces. systemd already does this in userspace.
I guess.. but what gives you the confidence this is not going to cause a regression for people? There's certainly plenty of machines with "stable naming" disabled. Whether that's wise or not is a separate question..
The ultimate goal was to remove custom init/exit functions. Although I could just move all of this logic to probe...
PATCH v3 7/17 net: ibm: emac: tah: use devm for kzalloc
In reply to Rosen PenevSimplifies the probe function by removing gotos.
--- drivers/net/ethernet/ibm/emac/tah.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/net/ethernet/ibm/emac/tah.c +6 -15
@@ -90,28 +90,25 @@ static int tah_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct tah_instance *dev;struct resource regs; -int rc; - rc = -ENOMEM ; - dev =kzalloc (sizeof (struct tah_instance ),GFP_KERNEL ); -if (dev ==NULL ) - goto err_gone; + dev =devm_kzalloc (&ofdev->dev,sizeof (struct tah_instance ), +GFP_KERNEL ); +if (!dev) +return -ENOMEM ;mutex_init (&dev->lock); dev->ofdev = ofdev; - rc = -ENXIO ;if (of_address_to_resource (np,0 , ®s)) {printk (KERN_ERR "%pOF: Can't get registers address\n" , np); - goto err_free; +return -ENXIO ; } - rc = -ENOMEM ; dev->base = (struct tah_regs __iomem *)ioremap (regs.start,sizeof (struct tah_regs ));if (dev->base ==NULL ) {printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); - goto err_free; +return -ENOMEM ; }platform_set_drvdata (ofdev, dev);
@@ -123,11 +120,6 @@ static int tah_probe(struct platform_device *ofdev)wmb ();return 0 ; - - err_free: -kfree (dev); - err_gone: -return rc; }static void tah_remove (struct platform_device *ofdev)
@@ -137,7 +129,6 @@ static void tah_remove(struct platform_device *ofdev)WARN_ON (dev->users !=0 );iounmap (dev->base); -kfree (dev); } static const struct of_device_id tah_match[] =
Signature · 1 line
2.46.2
PATCH v3 8/17 net: ibm: emac: tah: devm_platform_get_resources
In reply to Rosen PenevSimplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup.
printk gets converted to dev_err as np is now gone.
--- drivers/net/ethernet/ibm/emac/tah.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/net/ethernet/ibm/emac/tah.c +4 -22
@@ -87,9 +87,7 @@ void *tah_dump_regs(struct platform_device *ofdev, void *buf)static int tah_probe (struct platform_device *ofdev) { -struct device_node *np = ofdev->dev.of_node;struct tah_instance *dev; -struct resource regs; dev =devm_kzalloc (&ofdev->dev,sizeof (struct tah_instance ),GFP_KERNEL );
@@ -99,16 +97,10 @@ static int tah_probe(struct platform_device *ofdev)mutex_init (&dev->lock); dev->ofdev = ofdev; -if (of_address_to_resource (np,0 , ®s)) { -printk (KERN_ERR "%pOF: Can't get registers address\n" , np); -return -ENXIO ; - } - - dev->base = (struct tah_regs __iomem *)ioremap (regs.start, -sizeof (struct tah_regs )); -if (dev->base ==NULL ) { -printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); -return -ENOMEM ; + dev->base =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (dev->base)) { +dev_err (&ofdev->dev,"can't map device registers" ); +return PTR_ERR (dev->base); }platform_set_drvdata (ofdev, dev);
@@ -122,15 +114,6 @@ static int tah_probe(struct platform_device *ofdev)return 0 ; } -static void tah_remove (struct platform_device *ofdev) -{ -struct tah_instance *dev =platform_get_drvdata (ofdev); - -WARN_ON (dev->users !=0 ); - -iounmap (dev->base); -} -static const struct of_device_id tah_match[] = { {
@@ -149,7 +132,6 @@ static struct platform_driver tah_driver = { .of_match_table = tah_match, }, .probe = tah_probe, - .remove_new = tah_remove, };module_platform_driver (tah_driver);
Signature · 1 line
2.46.2
PATCH v3 9/17 net: ibm: emac: rgmii: use devm for kzalloc
In reply to Rosen PenevSimplifies the probe function by removing gotos.
--- drivers/net/ethernet/ibm/emac/rgmii.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/net/ethernet/ibm/emac/rgmii.c +6 -15
@@ -219,28 +219,25 @@ static int rgmii_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct rgmii_instance *dev;struct resource regs; -int rc; - rc = -ENOMEM ; - dev =kzalloc (sizeof (struct rgmii_instance ),GFP_KERNEL ); -if (dev ==NULL ) - goto err_gone; + dev =devm_kzalloc (&ofdev->dev,sizeof (struct rgmii_instance ), +GFP_KERNEL ); +if (!dev) +return -ENOMEM ;mutex_init (&dev->lock); dev->ofdev = ofdev; - rc = -ENXIO ;if (of_address_to_resource (np,0 , ®s)) {printk (KERN_ERR "%pOF: Can't get registers address\n" , np); - goto err_free; +return -ENXIO ; } - rc = -ENOMEM ; dev->base = (struct rgmii_regs __iomem *)ioremap (regs.start,sizeof (struct rgmii_regs ));if (dev->base ==NULL ) {printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); - goto err_free; +return -ENOMEM ; }/* Check for RGMII flags */
@@ -266,11 +263,6 @@ static int rgmii_probe(struct platform_device *ofdev)platform_set_drvdata (ofdev, dev);return 0 ; - - err_free: -kfree (dev); - err_gone: -return rc; }static void rgmii_remove (struct platform_device *ofdev)
@@ -280,7 +272,6 @@ static void rgmii_remove(struct platform_device *ofdev)WARN_ON (dev->users !=0 );iounmap (dev->base); -kfree (dev); } static const struct of_device_id rgmii_match[] =
Signature · 1 line
2.46.2
PATCH v3 10/17 net: ibm: emac: rgmii: devm_platform_get_resource
In reply to Rosen PenevSimplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup.
printk gets converted to dev_err as np is now gone.
--- drivers/net/ethernet/ibm/emac/rgmii.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/net/ethernet/ibm/emac/rgmii.c +4 -22
@@ -216,9 +216,7 @@ void *rgmii_dump_regs(struct platform_device *ofdev, void *buf)static int rgmii_probe (struct platform_device *ofdev) { -struct device_node *np = ofdev->dev.of_node;struct rgmii_instance *dev; -struct resource regs; dev =devm_kzalloc (&ofdev->dev,sizeof (struct rgmii_instance ),GFP_KERNEL );
@@ -228,16 +226,10 @@ static int rgmii_probe(struct platform_device *ofdev)mutex_init (&dev->lock); dev->ofdev = ofdev; -if (of_address_to_resource (np,0 , ®s)) { -printk (KERN_ERR "%pOF: Can't get registers address\n" , np); -return -ENXIO ; - } - - dev->base = (struct rgmii_regs __iomem *)ioremap (regs.start, -sizeof (struct rgmii_regs )); -if (dev->base ==NULL ) { -printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); -return -ENOMEM ; + dev->base =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (dev->base)) { +dev_err (&ofdev->dev,"can't map device registers" ); +return PTR_ERR (dev->base); }/* Check for RGMII flags */
@@ -265,15 +257,6 @@ static int rgmii_probe(struct platform_device *ofdev)return 0 ; } -static void rgmii_remove (struct platform_device *ofdev) -{ -struct rgmii_instance *dev =platform_get_drvdata (ofdev); - -WARN_ON (dev->users !=0 ); - -iounmap (dev->base); -} -static const struct of_device_id rgmii_match[] = { {
@@ -291,7 +274,6 @@ static struct platform_driver rgmii_driver = { .of_match_table = rgmii_match, }, .probe = rgmii_probe, - .remove_new = rgmii_remove, };module_platform_driver (rgmii_driver);
Signature · 1 line
2.46.2
PATCH v3 11/17 net: ibm: emac: zmii: use devm for kzalloc
In reply to Rosen PenevSimplifies the probe function by removing gotos.
--- drivers/net/ethernet/ibm/emac/zmii.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/net/ethernet/ibm/emac/zmii.c +7 -16
@@ -235,29 +235,26 @@ static int zmii_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct zmii_instance *dev;struct resource regs; -int rc; - rc = -ENOMEM ; - dev =kzalloc (sizeof (struct zmii_instance ),GFP_KERNEL ); -if (dev ==NULL ) - goto err_gone; + dev =devm_kzalloc (&ofdev->dev,sizeof (struct zmii_instance ), +GFP_KERNEL ); +if (!dev) +return -ENOMEM ;mutex_init (&dev->lock); dev->ofdev = ofdev; dev->mode =PHY_INTERFACE_MODE_NA ; - rc = -ENXIO ;if (of_address_to_resource (np,0 , ®s)) {printk (KERN_ERR "%pOF: Can't get registers address\n" , np); - goto err_free; +return -ENXIO ; } - rc = -ENOMEM ; dev->base = (struct zmii_regs __iomem *)ioremap (regs.start,sizeof (struct zmii_regs )); -if (dev->base ==NULL ) { +if (!dev->base) {printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); - goto err_free; +return -ENOMEM ; }/* We may need FER value for autodetection later */
@@ -271,11 +268,6 @@ static int zmii_probe(struct platform_device *ofdev)platform_set_drvdata (ofdev, dev);return 0 ; - - err_free: -kfree (dev); - err_gone: -return rc; }static void zmii_remove (struct platform_device *ofdev)
@@ -285,7 +277,6 @@ static void zmii_remove(struct platform_device *ofdev)WARN_ON (dev->users !=0 );iounmap (dev->base); -kfree (dev); } static const struct of_device_id zmii_match[] =
Signature · 1 line
2.46.2
PATCH v3 12/17 net: ibm: emac: zmii: devm_platform_get_resource
In reply to Rosen PenevSimplifies the probe function by a bit and allows removing the _remove function such that devm now handles all cleanup.
printk gets converted to dev_err as np is now gone.
--- drivers/net/ethernet/ibm/emac/zmii.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/net/ethernet/ibm/emac/zmii.c +4 -22
@@ -232,9 +232,7 @@ void *zmii_dump_regs(struct platform_device *ofdev, void *buf)static int zmii_probe (struct platform_device *ofdev) { -struct device_node *np = ofdev->dev.of_node;struct zmii_instance *dev; -struct resource regs; dev =devm_kzalloc (&ofdev->dev,sizeof (struct zmii_instance ),GFP_KERNEL );
@@ -245,16 +243,10 @@ static int zmii_probe(struct platform_device *ofdev) dev->ofdev = ofdev; dev->mode =PHY_INTERFACE_MODE_NA ; -if (of_address_to_resource (np,0 , ®s)) { -printk (KERN_ERR "%pOF: Can't get registers address\n" , np); -return -ENXIO ; - } - - dev->base = (struct zmii_regs __iomem *)ioremap (regs.start, -sizeof (struct zmii_regs )); -if (!dev->base) { -printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); -return -ENOMEM ; + dev->base =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (dev->base)) { +dev_err (&ofdev->dev,"can't map device registers" ); +return PTR_ERR (dev->base); }/* We may need FER value for autodetection later */
@@ -270,15 +262,6 @@ static int zmii_probe(struct platform_device *ofdev)return 0 ; } -static void zmii_remove (struct platform_device *ofdev) -{ -struct zmii_instance *dev =platform_get_drvdata (ofdev); - -WARN_ON (dev->users !=0 ); - -iounmap (dev->base); -} -static const struct of_device_id zmii_match[] = { {
@@ -297,7 +280,6 @@ static struct platform_driver zmii_driver = { .of_match_table = zmii_match, }, .probe = zmii_probe, - .remove_new = zmii_remove, };module_platform_driver (zmii_driver);
Signature · 1 line
2.46.2
PATCH v3 13/17 net: ibm: emac: mal: use devm for kzalloc
In reply to Rosen PenevSimplifies the probe function by removing gotos.
--- drivers/net/ethernet/ibm/emac/mal.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/net/ethernet/ibm/emac/mal.c +10 -18
@@ -524,7 +524,8 @@ static int mal_probe(struct platform_device *ofdev)unsigned long irqflags;irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde; - mal =kzalloc (sizeof (struct mal_instance ),GFP_KERNEL ); + mal =devm_kzalloc (&ofdev->dev,sizeof (struct mal_instance ), +GFP_KERNEL );if (!mal)return -ENOMEM ;
@@ -539,8 +540,7 @@ static int mal_probe(struct platform_device *ofdev)printk (KERN_ERR "mal%d: can't find MAL num-tx-chans property!\n" , index); - err = -ENODEV ; - goto fail; +return -ENODEV ; } mal->num_tx_chans = prop[0 ];
@@ -549,8 +549,7 @@ static int mal_probe(struct platform_device *ofdev)printk (KERN_ERR "mal%d: can't find MAL num-rx-chans property!\n" , index); - err = -ENODEV ; - goto fail; +return -ENODEV ; } mal->num_rx_chans = prop[0 ];
@@ -558,15 +557,13 @@ static int mal_probe(struct platform_device *ofdev)if (dcr_base ==0 ) {printk (KERN_ERR "mal%d: can't find DCR resource!\n" , index); - err = -ENODEV ; - goto fail; +return -ENODEV ; } mal->dcr_host =dcr_map (ofdev->dev.of_node, dcr_base,0x100 );if (!DCR_MAP_OK (mal->dcr_host)) {printk (KERN_ERR "mal%d: failed to map DCRs !\n" , index); - err = -ENODEV ; - goto fail; +return -ENODEV ; }if (of_device_is_compatible (ofdev->dev.of_node,"ibm,mcmal-405ez" )) {
@@ -577,8 +574,7 @@ static int mal_probe(struct platform_device *ofdev)#else printk (KERN_ERR "%pOF: Support for 405EZ not enabled!\n" , ofdev->dev.of_node); - err = -ENODEV ; - goto fail; +return -ENODEV ;#endif }
@@ -711,9 +707,6 @@ static int mal_probe(struct platform_device *ofdev)free_netdev (mal->dummy_dev); fail_unmap:dcr_unmap (mal->dcr_host,0x100 ); - fail: -kfree (mal); -return err; }
@@ -744,10 +737,9 @@ static void mal_remove(struct platform_device *ofdev)dma_free_coherent (&ofdev->dev,sizeof (struct mal_descriptor ) * - (NUM_TX_BUFF * mal->num_tx_chans + -NUM_RX_BUFF * mal->num_rx_chans), mal->bd_virt, - mal->bd_dma); -kfree (mal); + (NUM_TX_BUFF * mal->num_tx_chans + +NUM_RX_BUFF * mal->num_rx_chans), + mal->bd_virt, mal->bd_dma); } static const struct of_device_id mal_platform_match[] =
Signature · 1 line
2.46.2
PATCH v3 14/17 net: ibm: emac: mal: use devm for request_irq
In reply to Rosen PenevAvoids manual frees. Also replaced irq_of_parse_and_map with platform_get_irq since it's simpler and does the same thing.
--- drivers/net/ethernet/ibm/emac/mal.c | 51 ++++++++++++----------------- 1 file changed, 21 insertions(+), 30 deletions(-)
drivers/net/ethernet/ibm/emac/mal.c +21 -30
@@ -578,19 +578,19 @@ static int mal_probe(struct platform_device *ofdev)#endif } - mal->txeob_irq =irq_of_parse_and_map (ofdev->dev.of_node,0 ); - mal->rxeob_irq =irq_of_parse_and_map (ofdev->dev.of_node,1 ); - mal->serr_irq =irq_of_parse_and_map (ofdev->dev.of_node,2 ); + mal->txeob_irq =platform_get_irq (ofdev,0 ); + mal->rxeob_irq =platform_get_irq (ofdev,1 ); + mal->serr_irq =platform_get_irq (ofdev,2 );if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { mal->txde_irq = mal->rxde_irq = mal->serr_irq; }else { - mal->txde_irq =irq_of_parse_and_map (ofdev->dev.of_node,3 ); - mal->rxde_irq =irq_of_parse_and_map (ofdev->dev.of_node,4 ); + mal->txde_irq =platform_get_irq (ofdev,3 ); + mal->rxde_irq =platform_get_irq (ofdev,4 ); } -if (!mal->txeob_irq || !mal->rxeob_irq || !mal->serr_irq || - !mal->txde_irq || !mal->rxde_irq) { +if (mal->txeob_irq <0 || mal->rxeob_irq <0 || mal->serr_irq <0 || + mal->txde_irq <0 || mal->rxde_irq <0 ) {printk (KERN_ERR "mal%d: failed to map interrupts !\n" , index); err = -ENODEV ;
@@ -660,21 +660,26 @@ static int mal_probe(struct platform_device *ofdev) hdlr_rxde = mal_rxde; } - err =request_irq (mal->serr_irq, hdlr_serr, irqflags,"MAL SERR" , mal); + err =devm_request_irq (&ofdev->dev, mal->serr_irq, hdlr_serr, irqflags, +"MAL SERR" , mal);if (err) goto fail2; - err =request_irq (mal->txde_irq, hdlr_txde, irqflags,"MAL TX DE" , mal); + err =devm_request_irq (&ofdev->dev, mal->txde_irq, hdlr_txde, irqflags, +"MAL TX DE" , mal);if (err) - goto fail3; - err =request_irq (mal->txeob_irq, mal_txeob,0 ,"MAL TX EOB" , mal); + goto fail2; + err =devm_request_irq (&ofdev->dev, mal->txeob_irq, mal_txeob,0 , +"MAL TX EOB" , mal);if (err) - goto fail4; - err =request_irq (mal->rxde_irq, hdlr_rxde, irqflags,"MAL RX DE" , mal); + goto fail2; + err =devm_request_irq (&ofdev->dev, mal->rxde_irq, hdlr_rxde, irqflags, +"MAL RX DE" , mal);if (err) - goto fail5; - err =request_irq (mal->rxeob_irq, mal_rxeob,0 ,"MAL RX EOB" , mal); + goto fail2; + err =devm_request_irq (&ofdev->dev, mal->rxeob_irq, mal_rxeob,0 , +"MAL RX EOB" , mal);if (err) - goto fail6; + goto fail2;/* Enable all MAL SERR interrupt sources */ set_mal_dcrn (mal,MAL_IER ,MAL_IER_EVENTS );
@@ -693,14 +698,6 @@ static int mal_probe(struct platform_device *ofdev)return 0 ; - fail6: -free_irq (mal->rxde_irq, mal); - fail5: -free_irq (mal->txeob_irq, mal); - fail4: -free_irq (mal->txde_irq, mal); - fail3: -free_irq (mal->serr_irq, mal); fail2:dma_free_coherent (&ofdev->dev, bd_size, mal->bd_virt, mal->bd_dma); fail_dummy:
@@ -725,12 +722,6 @@ static void mal_remove(struct platform_device *ofdev)"mal%d: commac list is not empty on remove!\n" , mal->index); -free_irq (mal->serr_irq, mal); -free_irq (mal->txde_irq, mal); -free_irq (mal->txeob_irq, mal); -free_irq (mal->rxde_irq, mal); -free_irq (mal->rxeob_irq, mal); -mal_reset (mal);free_netdev (mal->dummy_dev);
Signature · 1 line
2.46.2
PATCH v3 15/17 net: ibm: emac: mal: move irq maps down
In reply to Rosen PenevMoves the handling right before they are used and allows merging a branch.
Also get rid of the error handling as devm_request_irq can handle that.
--- drivers/net/ethernet/ibm/emac/mal.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/net/ethernet/ibm/emac/mal.c +7 -19
@@ -578,25 +578,6 @@ static int mal_probe(struct platform_device *ofdev)#endif } - mal->txeob_irq =platform_get_irq (ofdev,0 ); - mal->rxeob_irq =platform_get_irq (ofdev,1 ); - mal->serr_irq =platform_get_irq (ofdev,2 ); - -if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { - mal->txde_irq = mal->rxde_irq = mal->serr_irq; - }else { - mal->txde_irq =platform_get_irq (ofdev,3 ); - mal->rxde_irq =platform_get_irq (ofdev,4 ); - } - -if (mal->txeob_irq <0 || mal->rxeob_irq <0 || mal->serr_irq <0 || - mal->txde_irq <0 || mal->rxde_irq <0 ) { -printk (KERN_ERR -"mal%d: failed to map interrupts !\n" , index); - err = -ENODEV ; - goto fail_unmap; - } -INIT_LIST_HEAD (&mal->poll_list);INIT_LIST_HEAD (&mal->list);spin_lock_init (&mal->lock);
@@ -650,10 +631,17 @@ static int mal_probe(struct platform_device *ofdev)sizeof (struct mal_descriptor ) * mal_rx_bd_offset(mal, i)); + mal->txeob_irq =platform_get_irq (ofdev,0 ); + mal->rxeob_irq =platform_get_irq (ofdev,1 ); + mal->serr_irq =platform_get_irq (ofdev,2 ); +if (mal_has_feature (mal,MAL_FTR_COMMON_ERR_INT )) { + mal->txde_irq = mal->rxde_irq = mal->serr_irq; irqflags =IRQF_SHARED ; hdlr_serr = hdlr_txde = hdlr_rxde = mal_int; }else { + mal->txde_irq =platform_get_irq (ofdev,3 ); + mal->rxde_irq =platform_get_irq (ofdev,4 ); irqflags =0 ; hdlr_serr = mal_serr; hdlr_txde = mal_txde;
Signature · 1 line
2.46.2
PATCH v3 16/17 net: ibm: emac: mal: add dcr_unmap to _remove
In reply to Rosen PenevIt's done in probe so it should be done here.
--- drivers/net/ethernet/ibm/emac/mal.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/ibm/emac/mal.c +2 -0
@@ -714,6 +714,8 @@ static void mal_remove(struct platform_device *ofdev)free_netdev (mal->dummy_dev); +dcr_unmap (mal->dcr_host,0x100 ); + dma_free_coherent(&ofdev->dev, sizeof(struct mal_descriptor) * (NUM_TX_BUFF * mal->num_tx_chans +
Signature · 1 line
2.46.2
Jakub Kicinski
maintainerRe: [PATCH net-next v3 16/17] net: ibm: emac: mal: add dcr_unmap to _remove
Quoted 1 line · On Wed, 2 Oct 2024 19:11:34 -0700 Rosen Penev wrote:
It's done in probe so it should be done here.
second done -> undone ?
Also is this not a bug fix?
Re: [PATCH net-next v3 16/17] net: ibm: emac: mal: add dcr_unmap to _remove
Quoted 6 lines · Jakub Kicinski
Quoted 1 line · On Wed, 2 Oct 2024 19:11:34 -0700 Rosen Penev wrote:
It's done in probe so it should be done here.
second done -> undone ?
Also is this not a bug fix?
Correct. Looking at git blame dcr_unmap has never been in remove.
PATCH v3 17/17 net: ibm: emac: mal: move dcr map down
In reply to Rosen PenevThere's actually a bug above where it returns instead of calling goto. Instead of calling goto, move dcr_map and friends down as they're used right after the spinlock in mal_reset.
--- drivers/net/ethernet/ibm/emac/mal.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/net/ethernet/ibm/emac/mal.c +12 -12
@@ -553,6 +553,18 @@ static int mal_probe(struct platform_device *ofdev) } mal->num_rx_chans = prop[0 ]; +if (of_device_is_compatible (ofdev->dev.of_node,"ibm,mcmal-405ez" )) { +#if defined(CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT ) && \ + defined(CONFIG_IBM_EMAC_MAL_COMMON_ERR ) + mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | +MAL_FTR_COMMON_ERR_INT ); +#else +printk (KERN_ERR "%pOF: Support for 405EZ not enabled!\n" , + ofdev->dev.of_node); +return -ENODEV ; +#endif + } + dcr_base =dcr_resource_start (ofdev->dev.of_node,0 );if (dcr_base ==0 ) { printk(KERN_ERR
@@ -566,18 +578,6 @@ static int mal_probe(struct platform_device *ofdev)return -ENODEV ; } -if (of_device_is_compatible (ofdev->dev.of_node,"ibm,mcmal-405ez" )) { -#if defined(CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT ) && \ - defined(CONFIG_IBM_EMAC_MAL_COMMON_ERR ) - mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | -MAL_FTR_COMMON_ERR_INT ); -#else -printk (KERN_ERR "%pOF: Support for 405EZ not enabled!\n" , - ofdev->dev.of_node); -return -ENODEV ; -#endif - } -INIT_LIST_HEAD (&mal->poll_list);INIT_LIST_HEAD (&mal->list);spin_lock_init (&mal->lock);
Signature · 1 line
2.46.2
Jakub Kicinski
maintainerRe: [PATCH net-next v3 17/17] net: ibm: emac: mal: move dcr map down
Quoted 3 lines · On Wed, 2 Oct 2024 19:11:35 -0700 Rosen Penev wrote:
There's actually a bug above where it returns instead of calling goto. Instead of calling goto, move
dcr_mapand friends down as they're used right after the spinlock inmal_reset.
Not a fix?
Re: [PATCH net-next v3 17/17] net: ibm: emac: mal: move dcr map down
Quoted 7 lines · Jakub Kicinski
Quoted 3 lines · On Wed, 2 Oct 2024 19:11:35 -0700 Rosen Penev wrote:
There's actually a bug above where it returns instead of calling goto. Instead of calling goto, move
dcr_mapand friends down as they're used right after the spinlock inmal_reset.Not a fix?
It's a fix for a prior commit, yes. 6d3ba097ee81d if I'm using git blame correctly.
Jakub Kicinski
maintainerRe: [PATCH net-next v3 17/17] net: ibm: emac: mal: move dcr map down
Quoted 8 lines · On Fri, 4 Oct 2024 16:43:48 -0700 Rosen Penev wrote:
Quoted 6 lines · On Wed, 2 Oct 2024 19:11:35 -0700 Rosen Penev wrote:
Quoted 3 lines
There's actually a bug above where it returns instead of calling goto. Instead of calling goto, move
dcr_mapand friends down as they're used right after the spinlock inmal_reset.Not a fix?
It's a fix for a prior commit, yes.
6d3ba097ee81dif I'm using git blame correctly.
Hm, I don't have this hash in my local tree.
What I'm getting at is that if it's a fix for a patch already in networking trees the patch needs to have a Fixes tag. And if the bug is present in net - the patch needs to go to net rather than net-next.
Jakub Kicinski
maintainerRe: [PATCH net-next v3 17/17] net: ibm: emac: mal: move dcr map down
Quoted 9 lines · On Mon, 7 Oct 2024 07:05:14 -0700 Jakub Kicinski wrote:
Quoted 3 lines
Quoted 1 line
Not a fix?
It's a fix for a prior commit, yes.
6d3ba097ee81dif I'm using git blame correctly.Hm, I don't have this hash in my local tree.
What I'm getting at is that if it's a fix for a patch already in networking trees the patch needs to have a Fixes tag. And if the bug is present in net - the patch needs to go to net rather than net-next.
Looking closer I think this got added in:
commit 1ff0fcfcb1a6 ("ibm_newemac: Fix new MAL feature handling") please post the first to net. Then once net gets merged to net-next (which happens every Thu), you can proceed with the net-next conversions.
Jakub Kicinski
maintainerQuoted 1 line · On Wed, 2 Oct 2024 19:11:18 -0700 Rosen Penev wrote:
Tested on Cisco MX60W.
Thanks for including this info.
Looks like there are various "sub drivers" in emac. Which one(s) is Cisco MX60W using / exercising?
Quoted 7 lines · Jakub Kicinski
Quoted 1 line · On Wed, 2 Oct 2024 19:11:18 -0700 Rosen Penev wrote:
Tested on Cisco MX60W.
Thanks for including this info.
Looks like there are various "sub drivers" in emac. Which one(s) is Cisco MX60W using / exercising?
All except zmii. That's for 100Mbit ports AFAIK. Cisco MX60W has only gigabit ones.
Jakub Kicinski
maintainerQuoted 1 line · On Wed, 2 Oct 2024 19:11:18 -0700 Rosen Penev wrote:
Rosen Penev (17):
17 is too many, I see no reason why these have to all be posted at once.