All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] IXP4xx networking cleanups
@ 2019-10-21  0:08 Linus Walleij
  2019-10-21  0:08 ` [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit Linus Walleij
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

This is a patch series which jams together Arnds and mine
cleanups for the IXP4xx networking.

I also have patches for device tree support but that
requires more elaborate work, this series is some of
mine and some of Arnds patches that is a good foundation
for his multiplatform work and my device tree work.

These are for application to the networking tree so
that can be taken in one separate sweep.

I have tested the patches for a bit using zeroday builds
and some boots on misc IXP4xx devices and haven't run
into any major problems. We might find some new stuff
as a result from the new compiler coverage.

The patch set also hits in the ARM tree but Arnd is
a ARM SoC maintainer and is hereby informed :)

Arnd Bergmann (4):
  wan: ixp4xx_hss: fix compile-testing on 64-bit
  wan: ixp4xx_hss: enable compile testing
  ptp: ixp46x: move next to ethernet driver
  ixp4xx_eth: move platform_data definition

Linus Walleij (6):
  net: ethernet: ixp4xx: Standard module init
  net: ethernet: ixp4xx: Use distinct local variable
  net: ehernet: ixp4xx: Use devm_alloc_etherdev()
  ARM/net: ixp4xx: Pass ethernet physical base as resource
  net: ethernet: ixp4xx: Get port ID from base address
  net: ethernet: ixp4xx: Use parent dev for DMA pool

 arch/arm/mach-ixp4xx/fsg-setup.c              |  20 ++
 arch/arm/mach-ixp4xx/goramo_mlr.c             |  24 +++
 arch/arm/mach-ixp4xx/include/mach/platform.h  |  22 +--
 arch/arm/mach-ixp4xx/ixdp425-setup.c          |  20 ++
 arch/arm/mach-ixp4xx/nas100d-setup.c          |  10 +
 arch/arm/mach-ixp4xx/nslu2-setup.c            |  10 +
 arch/arm/mach-ixp4xx/omixp-setup.c            |  20 ++
 arch/arm/mach-ixp4xx/vulcan-setup.c           |  20 ++
 drivers/net/ethernet/xscale/Kconfig           |  14 ++
 drivers/net/ethernet/xscale/Makefile          |   3 +-
 .../net/ethernet/xscale}/ixp46x_ts.h          |   0
 drivers/net/ethernet/xscale/ixp4xx_eth.c      | 177 +++++++++---------
 .../{ptp => net/ethernet/xscale}/ptp_ixp46x.c |   3 +-
 drivers/net/wan/Kconfig                       |   3 +-
 drivers/net/wan/ixp4xx_hss.c                  |  39 ++--
 drivers/ptp/Kconfig                           |  14 --
 drivers/ptp/Makefile                          |   1 -
 include/linux/platform_data/eth_ixp4xx.h      |  19 ++
 include/linux/platform_data/wan_ixp4xx_hss.h  |  17 ++
 19 files changed, 292 insertions(+), 144 deletions(-)
 rename {arch/arm/mach-ixp4xx/include/mach => drivers/net/ethernet/xscale}/ixp46x_ts.h (100%)
 rename drivers/{ptp => net/ethernet/xscale}/ptp_ixp46x.c (99%)
 create mode 100644 include/linux/platform_data/eth_ixp4xx.h
 create mode 100644 include/linux/platform_data/wan_ixp4xx_hss.h

-- 
2.21.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

From: Arnd Bergmann <arnd@arndb.de>

Change the driver to use portable integer types to avoid
warnings during compile testing:

drivers/net/wan/ixp4xx_hss.c:863:21: error: cast to 'u32 *' (aka 'unsigned int *') from smaller integer type 'int' [-Werror,-Wint-to-pointer-cast]
        memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4);
                           ^
drivers/net/wan/ixp4xx_hss.c:979:12: error: incompatible pointer types passing 'u32 *' (aka 'unsigned int *') to parameter of type 'dma_addr_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types]
                                              &port->desc_tab_phys)))
                                              ^~~~~~~~~~~~~~~~~~~~
include/linux/dmapool.h:27:20: note: passing argument to parameter 'handle' here
                     dma_addr_t *handle);
                                 ^

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/wan/ixp4xx_hss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index ea6ee6a608ce..e7619cec978a 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -258,7 +258,7 @@ struct port {
 	struct hss_plat_info *plat;
 	buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
 	struct desc *desc_tab;	/* coherent */
-	u32 desc_tab_phys;
+	dma_addr_t desc_tab_phys;
 	unsigned int id;
 	unsigned int clock_type, clock_rate, loopback;
 	unsigned int initialized, carrier;
@@ -858,7 +858,7 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
 		dev->stats.tx_dropped++;
 		return NETDEV_TX_OK;
 	}
-	memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4);
+	memcpy_swab32(mem, (u32 *)((uintptr_t)skb->data & ~3), bytes / 4);
 	dev_kfree_skb(skb);
 #endif
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/10] wan: ixp4xx_hss: enable compile testing
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
  2019-10-21  0:08 ` [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21 15:23   ` kbuild test robot
                     ` (2 more replies)
  2019-10-21  0:08 ` [PATCH 03/10] ptp: ixp46x: move next to ethernet driver Linus Walleij
                   ` (9 subsequent siblings)
  11 siblings, 3 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

From: Arnd Bergmann <arnd@arndb.de>

The ixp4xx_hss driver needs the platform data definition and the
system clock rate to be compiled. Move both into a new platform_data
header file and enable compile testing.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ixp4xx/goramo_mlr.c            |  4 +++
 arch/arm/mach-ixp4xx/include/mach/platform.h |  9 -----
 drivers/net/wan/Kconfig                      |  3 +-
 drivers/net/wan/ixp4xx_hss.c                 | 35 +++++++++++---------
 include/linux/platform_data/wan_ixp4xx_hss.h | 17 ++++++++++
 5 files changed, 43 insertions(+), 25 deletions(-)
 create mode 100644 include/linux/platform_data/wan_ixp4xx_hss.h

diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c
index a0e0b6b7dc5c..93b7afeee142 100644
--- a/arch/arm/mach-ixp4xx/goramo_mlr.c
+++ b/arch/arm/mach-ixp4xx/goramo_mlr.c
@@ -11,6 +11,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/platform_data/wan_ixp4xx_hss.h>
 #include <linux/serial_8250.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -405,6 +406,9 @@ static void __init gmlr_init(void)
 	if (hw_bits & CFG_HW_HAS_HSS1)
 		device_tab[devices++] = &device_hss_tab[1]; /* max index 5 */
 
+	hss_plat[0].timer_freq = ixp4xx_timer_freq;
+	hss_plat[1].timer_freq = ixp4xx_timer_freq;
+
 	gpio_request(GPIO_SCL, "SCL/clock");
 	gpio_request(GPIO_SDA, "SDA/data");
 	gpio_request(GPIO_STR, "strobe");
diff --git a/arch/arm/mach-ixp4xx/include/mach/platform.h b/arch/arm/mach-ixp4xx/include/mach/platform.h
index 342acbe20f7c..04ef8025accc 100644
--- a/arch/arm/mach-ixp4xx/include/mach/platform.h
+++ b/arch/arm/mach-ixp4xx/include/mach/platform.h
@@ -104,15 +104,6 @@ struct eth_plat_info {
 	u8 hwaddr[6];
 };
 
-/* Information about built-in HSS (synchronous serial) interfaces */
-struct hss_plat_info {
-	int (*set_clock)(int port, unsigned int clock_type);
-	int (*open)(int port, void *pdev,
-		    void (*set_carrier_cb)(void *pdev, int carrier));
-	void (*close)(int port, void *pdev);
-	u8 txreadyq;
-};
-
 /*
  * Frequency of clock used for primary clocksource
  */
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index dd1a147f2971..bf2fe1d602ea 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -315,7 +315,8 @@ config DSCC4_PCI_RST
 
 config IXP4XX_HSS
 	tristate "Intel IXP4xx HSS (synchronous serial port) support"
-	depends on HDLC && ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR
+	depends on HDLC && IXP4XX_NPE && IXP4XX_QMGR
+	depends on ARCH_IXP4XX || COMPILE_TEST
 	help
 	  Say Y here if you want to use built-in HSS ports
 	  on IXP4xx processor.
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index e7619cec978a..7c5cf77e9ef1 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -17,6 +17,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/wan_ixp4xx_hss.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/soc/ixp4xx/npe.h>
@@ -1182,14 +1183,14 @@ static int hss_hdlc_attach(struct net_device *dev, unsigned short encoding,
 	}
 }
 
-static u32 check_clock(u32 rate, u32 a, u32 b, u32 c,
+static u32 check_clock(u32 timer_freq, u32 rate, u32 a, u32 b, u32 c,
 		       u32 *best, u32 *best_diff, u32 *reg)
 {
 	/* a is 10-bit, b is 10-bit, c is 12-bit */
 	u64 new_rate;
 	u32 new_diff;
 
-	new_rate = ixp4xx_timer_freq * (u64)(c + 1);
+	new_rate = timer_freq * (u64)(c + 1);
 	do_div(new_rate, a * (c + 1) + b + 1);
 	new_diff = abs((u32)new_rate - rate);
 
@@ -1201,40 +1202,43 @@ static u32 check_clock(u32 rate, u32 a, u32 b, u32 c,
 	return new_diff;
 }
 
-static void find_best_clock(u32 rate, u32 *best, u32 *reg)
+static void find_best_clock(u32 timer_freq, u32 rate, u32 *best, u32 *reg)
 {
 	u32 a, b, diff = 0xFFFFFFFF;
 
-	a = ixp4xx_timer_freq / rate;
+	a = timer_freq / rate;
 
 	if (a > 0x3FF) { /* 10-bit value - we can go as slow as ca. 65 kb/s */
-		check_clock(rate, 0x3FF, 1, 1, best, &diff, reg);
+		check_clock(timer_freq, rate, 0x3FF, 1, 1, best, &diff, reg);
 		return;
 	}
 	if (a == 0) { /* > 66.666 MHz */
 		a = 1; /* minimum divider is 1 (a = 0, b = 1, c = 1) */
-		rate = ixp4xx_timer_freq;
+		rate = timer_freq;
 	}
 
-	if (rate * a == ixp4xx_timer_freq) { /* don't divide by 0 later */
-		check_clock(rate, a - 1, 1, 1, best, &diff, reg);
+	if (rate * a == timer_freq) { /* don't divide by 0 later */
+		check_clock(timer_freq, rate, a - 1, 1, 1, best, &diff, reg);
 		return;
 	}
 
 	for (b = 0; b < 0x400; b++) {
 		u64 c = (b + 1) * (u64)rate;
-		do_div(c, ixp4xx_timer_freq - rate * a);
+		do_div(c, timer_freq - rate * a);
 		c--;
 		if (c >= 0xFFF) { /* 12-bit - no need to check more 'b's */
 			if (b == 0 && /* also try a bit higher rate */
-			    !check_clock(rate, a - 1, 1, 1, best, &diff, reg))
+			    !check_clock(timer_freq, rate, a - 1, 1, 1, best,
+					 &diff, reg))
 				return;
-			check_clock(rate, a, b, 0xFFF, best, &diff, reg);
+			check_clock(timer_freq, rate, a, b, 0xFFF, best,
+				    &diff, reg);
 			return;
 		}
-		if (!check_clock(rate, a, b, c, best, &diff, reg))
+		if (!check_clock(timer_freq, rate, a, b, c, best, &diff, reg))
 			return;
-		if (!check_clock(rate, a, b, c + 1, best, &diff, reg))
+		if (!check_clock(timer_freq, rate, a, b, c + 1, best, &diff,
+				 reg))
 			return;
 	}
 }
@@ -1285,8 +1289,9 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
 		port->clock_type = clk; /* Update settings */
 		if (clk == CLOCK_INT)
-			find_best_clock(new_line.clock_rate, &port->clock_rate,
-					&port->clock_reg);
+			find_best_clock(port->plat->timer_freq,
+					new_line.clock_rate,
+					&port->clock_rate, &port->clock_reg);
 		else {
 			port->clock_rate = 0;
 			port->clock_reg = CLK42X_SPEED_2048KHZ;
diff --git a/include/linux/platform_data/wan_ixp4xx_hss.h b/include/linux/platform_data/wan_ixp4xx_hss.h
new file mode 100644
index 000000000000..d525a0feb9e1
--- /dev/null
+++ b/include/linux/platform_data/wan_ixp4xx_hss.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PLATFORM_DATA_WAN_IXP4XX_HSS_H
+#define __PLATFORM_DATA_WAN_IXP4XX_HSS_H
+
+#include <linux/types.h>
+
+/* Information about built-in HSS (synchronous serial) interfaces */
+struct hss_plat_info {
+	int (*set_clock)(int port, unsigned int clock_type);
+	int (*open)(int port, void *pdev,
+		    void (*set_carrier_cb)(void *pdev, int carrier));
+	void (*close)(int port, void *pdev);
+	u8 txreadyq;
+	u32 timer_freq;
+};
+
+#endif
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/10] ptp: ixp46x: move next to ethernet driver
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
  2019-10-21  0:08 ` [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit Linus Walleij
  2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21  0:08 ` [PATCH 04/10] ixp4xx_eth: move platform_data definition Linus Walleij
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

From: Arnd Bergmann <arnd@arndb.de>

The ixp46x ptp driver has a somewhat unusual setup, where the ptp
driver and the ethernet driver are in different directories but
access the same registers that are defined a platform specific
header file.

Moving everything into drivers/net/ makes it look more like most
other ptp drivers and allows compile-testing this driver on
other targets.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/Kconfig                | 14 ++++++++++++++
 drivers/net/ethernet/xscale/Makefile               |  3 ++-
 drivers/net/ethernet/xscale/ixp4xx_eth.c           |  3 ++-
 drivers/{ptp => net/ethernet/xscale}/ptp_ixp46x.c  |  3 ++-
 .../net/ethernet/xscale/ptp_ixp46x.h               |  0
 drivers/ptp/Kconfig                                | 14 --------------
 drivers/ptp/Makefile                               |  1 -
 7 files changed, 20 insertions(+), 18 deletions(-)
 rename drivers/{ptp => net/ethernet/xscale}/ptp_ixp46x.c (99%)
 rename arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h => drivers/net/ethernet/xscale/ptp_ixp46x.h (100%)

diff --git a/drivers/net/ethernet/xscale/Kconfig b/drivers/net/ethernet/xscale/Kconfig
index cd0a8f46e7c6..98aa7b8ddb06 100644
--- a/drivers/net/ethernet/xscale/Kconfig
+++ b/drivers/net/ethernet/xscale/Kconfig
@@ -27,4 +27,18 @@ config IXP4XX_ETH
 	  Say Y here if you want to use built-in Ethernet ports
 	  on IXP4xx processor.
 
+config PTP_1588_CLOCK_IXP46X
+	tristate "Intel IXP46x as PTP clock"
+	depends on IXP4XX_ETH
+	depends on PTP_1588_CLOCK
+	default y
+	help
+	  This driver adds support for using the IXP46X as a PTP
+	  clock. This clock is only useful if your PTP programs are
+	  getting hardware time stamps on the PTP Ethernet packets
+	  using the SO_TIMESTAMPING API.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called ptp_ixp46x.
+
 endif # NET_VENDOR_XSCALE
diff --git a/drivers/net/ethernet/xscale/Makefile b/drivers/net/ethernet/xscale/Makefile
index 794a519d07b3..607f91b1e878 100644
--- a/drivers/net/ethernet/xscale/Makefile
+++ b/drivers/net/ethernet/xscale/Makefile
@@ -3,4 +3,5 @@
 # Makefile for the Intel XScale IXP device drivers.
 #
 
-obj-$(CONFIG_IXP4XX_ETH) += ixp4xx_eth.o
+obj-$(CONFIG_IXP4XX_ETH)		+= ixp4xx_eth.o
+obj-$(CONFIG_PTP_1588_CLOCK_IXP46X)	+= ptp_ixp46x.o
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 6fc04ffb22c2..0075ecdb21f4 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -33,10 +33,11 @@
 #include <linux/ptp_classify.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include <mach/ixp46x_ts.h>
 #include <linux/soc/ixp4xx/npe.h>
 #include <linux/soc/ixp4xx/qmgr.h>
 
+#include "ixp46x_ts.h"
+
 #define DEBUG_DESC		0
 #define DEBUG_RX		0
 #define DEBUG_TX		0
diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/net/ethernet/xscale/ptp_ixp46x.c
similarity index 99%
rename from drivers/ptp/ptp_ixp46x.c
rename to drivers/net/ethernet/xscale/ptp_ixp46x.c
index 67028484e9a0..9ecc395239e9 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/net/ethernet/xscale/ptp_ixp46x.c
@@ -15,7 +15,8 @@
 #include <linux/module.h>
 
 #include <linux/ptp_clock_kernel.h>
-#include <mach/ixp46x_ts.h>
+
+#include "ixp46x_ts.h"
 
 #define DRIVER		"ptp_ixp46x"
 #define N_EXT_TS	2
diff --git a/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h b/drivers/net/ethernet/xscale/ptp_ixp46x.h
similarity index 100%
rename from arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h
rename to drivers/net/ethernet/xscale/ptp_ixp46x.h
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index 960961fb0d7c..0209e0ef082d 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -56,20 +56,6 @@ config PTP_1588_CLOCK_QORIQ
 	  To compile this driver as a module, choose M here: the module
 	  will be called ptp-qoriq.
 
-config PTP_1588_CLOCK_IXP46X
-	tristate "Intel IXP46x as PTP clock"
-	depends on IXP4XX_ETH
-	depends on PTP_1588_CLOCK
-	default y
-	help
-	  This driver adds support for using the IXP46X as a PTP
-	  clock. This clock is only useful if your PTP programs are
-	  getting hardware time stamps on the PTP Ethernet packets
-	  using the SO_TIMESTAMPING API.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called ptp_ixp46x.
-
 comment "Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks."
 	depends on PHYLIB=n || NETWORK_PHY_TIMESTAMPING=n
 
diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile
index 677d1d178a3e..8ac3513f61c9 100644
--- a/drivers/ptp/Makefile
+++ b/drivers/ptp/Makefile
@@ -6,7 +6,6 @@
 ptp-y					:= ptp_clock.o ptp_chardev.o ptp_sysfs.o
 obj-$(CONFIG_PTP_1588_CLOCK)		+= ptp.o
 obj-$(CONFIG_PTP_1588_CLOCK_DTE)	+= ptp_dte.o
-obj-$(CONFIG_PTP_1588_CLOCK_IXP46X)	+= ptp_ixp46x.o
 obj-$(CONFIG_PTP_1588_CLOCK_PCH)	+= ptp_pch.o
 obj-$(CONFIG_PTP_1588_CLOCK_KVM)	+= ptp_kvm.o
 obj-$(CONFIG_PTP_1588_CLOCK_QORIQ)	+= ptp-qoriq.o
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/10] ixp4xx_eth: move platform_data definition
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (2 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 03/10] ptp: ixp46x: move next to ethernet driver Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21  0:08 ` [PATCH 05/10] net: ethernet: ixp4xx: Standard module init Linus Walleij
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

From: Arnd Bergmann <arnd@arndb.de>

The platform data is needed to compile the driver as standalone,
so move it to a global location along with similar files.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ixp4xx/include/mach/platform.h  | 13 +------------
 .../xscale/{ptp_ixp46x.h => ixp46x_ts.h}      |  0
 drivers/net/ethernet/xscale/ixp4xx_eth.c      |  1 +
 include/linux/platform_data/eth_ixp4xx.h      | 19 +++++++++++++++++++
 4 files changed, 21 insertions(+), 12 deletions(-)
 rename drivers/net/ethernet/xscale/{ptp_ixp46x.h => ixp46x_ts.h} (100%)
 create mode 100644 include/linux/platform_data/eth_ixp4xx.h

diff --git a/arch/arm/mach-ixp4xx/include/mach/platform.h b/arch/arm/mach-ixp4xx/include/mach/platform.h
index 04ef8025accc..6d403fe0bf52 100644
--- a/arch/arm/mach-ixp4xx/include/mach/platform.h
+++ b/arch/arm/mach-ixp4xx/include/mach/platform.h
@@ -15,6 +15,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/reboot.h>
+#include <linux/platform_data/eth_ixp4xx.h>
 
 #include <asm/types.h>
 
@@ -92,18 +93,6 @@ struct ixp4xx_pata_data {
 	void __iomem	*cs1;
 };
 
-#define IXP4XX_ETH_NPEA		0x00
-#define IXP4XX_ETH_NPEB		0x10
-#define IXP4XX_ETH_NPEC		0x20
-
-/* Information about built-in Ethernet MAC interfaces */
-struct eth_plat_info {
-	u8 phy;		/* MII PHY ID, 0 - 31 */
-	u8 rxq;		/* configurable, currently 0 - 31 only */
-	u8 txreadyq;
-	u8 hwaddr[6];
-};
-
 /*
  * Frequency of clock used for primary clocksource
  */
diff --git a/drivers/net/ethernet/xscale/ptp_ixp46x.h b/drivers/net/ethernet/xscale/ixp46x_ts.h
similarity index 100%
rename from drivers/net/ethernet/xscale/ptp_ixp46x.h
rename to drivers/net/ethernet/xscale/ixp46x_ts.h
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 0075ecdb21f4..e811bf0d23cb 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -29,6 +29,7 @@
 #include <linux/net_tstamp.h>
 #include <linux/of.h>
 #include <linux/phy.h>
+#include <linux/platform_data/eth_ixp4xx.h>
 #include <linux/platform_device.h>
 #include <linux/ptp_classify.h>
 #include <linux/slab.h>
diff --git a/include/linux/platform_data/eth_ixp4xx.h b/include/linux/platform_data/eth_ixp4xx.h
new file mode 100644
index 000000000000..6f652ea0c6ae
--- /dev/null
+++ b/include/linux/platform_data/eth_ixp4xx.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PLATFORM_DATA_ETH_IXP4XX
+#define __PLATFORM_DATA_ETH_IXP4XX
+
+#include <linux/types.h>
+
+#define IXP4XX_ETH_NPEA		0x00
+#define IXP4XX_ETH_NPEB		0x10
+#define IXP4XX_ETH_NPEC		0x20
+
+/* Information about built-in Ethernet MAC interfaces */
+struct eth_plat_info {
+	u8 phy;		/* MII PHY ID, 0 - 31 */
+	u8 rxq;		/* configurable, currently 0 - 31 only */
+	u8 txreadyq;
+	u8 hwaddr[6];
+};
+
+#endif
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/10] net: ethernet: ixp4xx: Standard module init
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (3 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 04/10] ixp4xx_eth: move platform_data definition Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-22  1:19   ` Jakub Kicinski
  2019-10-21  0:08 ` [PATCH 06/10] net: ethernet: ixp4xx: Use distinct local variable Linus Walleij
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

The IXP4xx driver was initializing the MDIO bus before even
probing, in the callbacks supposed to be used for setting up
the module itself, and with the side effect of trying to
register the MDIO bus as soon as this module was loaded or
compiled into the kernel whether the device was discovered
or not.

This does not work with multiplatform environments.

To get rid of this: set up the MDIO bus from the probe()
callback and remove it in the remove() callback. Rename
the probe() and remove() calls to reflect the most common
conventions.

Since there is a bit of checking for the ethernet feature
to be present in the MDIO registering function, making the
whole module not even be registered if we can't find an
MDIO bus, we need something similar: register the MDIO
bus when the corresponding ethernet is probed, and
return -EPROBE_DEFER on the other interfaces until this
happens. If no MDIO bus is present on any of the
registered interfaces we will eventually bail out.

None of the platforms I've seen has e.g. MDIO on EthB
and only uses EthC, there is always a Ethernet hardware
on the NPE (B, C) that has the MDIO bus, we just might
have to wait for it.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 82 ++++++++++++------------
 1 file changed, 40 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index e811bf0d23cb..26da84402cfd 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -519,25 +519,14 @@ static int ixp4xx_mdio_write(struct mii_bus *bus, int phy_id, int location,
 	return ret;
 }
 
-static int ixp4xx_mdio_register(void)
+static int ixp4xx_mdio_register(struct eth_regs __iomem *regs)
 {
 	int err;
 
 	if (!(mdio_bus = mdiobus_alloc()))
 		return -ENOMEM;
 
-	if (cpu_is_ixp43x()) {
-		/* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */
-		if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH))
-			return -ENODEV;
-		mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
-	} else {
-		/* All MII PHY accesses use NPE-B Ethernet registers */
-		if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0))
-			return -ENODEV;
-		mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
-	}
-
+	mdio_regs = regs;
 	__raw_writel(DEFAULT_CORE_CNTRL, &mdio_regs->core_control);
 	spin_lock_init(&mdio_lock);
 	mdio_bus->name = "IXP4xx MII Bus";
@@ -1376,7 +1365,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = {
 	.ndo_validate_addr = eth_validate_addr,
 };
 
-static int eth_init_one(struct platform_device *pdev)
+static int ixp4xx_eth_probe(struct platform_device *pdev)
 {
 	struct port *port;
 	struct net_device *dev;
@@ -1396,14 +1385,46 @@ static int eth_init_one(struct platform_device *pdev)
 
 	switch (port->id) {
 	case IXP4XX_ETH_NPEA:
+		/* If the MDIO bus is not up yet, defer probe */
+		if (!mdio_bus)
+			return -EPROBE_DEFER;
 		port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
 		regs_phys  = IXP4XX_EthA_BASE_PHYS;
 		break;
 	case IXP4XX_ETH_NPEB:
+		/*
+		 * On all except IXP43x, NPE-B is used for the MDIO bus.
+		 * If there is no NPE-B in the feature set, bail out, else
+		 * register the MDIO bus.
+		 */
+		if (!cpu_is_ixp43x()) {
+			if (!(ixp4xx_read_feature_bits() &
+			      IXP4XX_FEATURE_NPEB_ETH0))
+				return -ENODEV;
+			/* Else register the MDIO bus on NPE-B */
+			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
+				return err;
+		}
+		if (!mdio_bus)
+			return -EPROBE_DEFER;
 		port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
 		regs_phys  = IXP4XX_EthB_BASE_PHYS;
 		break;
 	case IXP4XX_ETH_NPEC:
+		/*
+		 * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access,
+		 * of there is no NPE-C, no bus, nothing works, so bail out.
+		 */
+		if (cpu_is_ixp43x()) {
+			if (!(ixp4xx_read_feature_bits() &
+			      IXP4XX_FEATURE_NPEC_ETH))
+				return -ENODEV;
+			/* Else register the MDIO bus on NPE-C */
+			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
+				return err;
+		}
+		if (!mdio_bus)
+			return -EPROBE_DEFER;
 		port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
 		regs_phys  = IXP4XX_EthC_BASE_PHYS;
 		break;
@@ -1472,7 +1493,7 @@ static int eth_init_one(struct platform_device *pdev)
 	return err;
 }
 
-static int eth_remove_one(struct platform_device *pdev)
+static int ixp4xx_eth_remove(struct platform_device *pdev)
 {
 	struct net_device *dev = platform_get_drvdata(pdev);
 	struct phy_device *phydev = dev->phydev;
@@ -1480,6 +1501,7 @@ static int eth_remove_one(struct platform_device *pdev)
 
 	unregister_netdev(dev);
 	phy_disconnect(phydev);
+	ixp4xx_mdio_remove();
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	npe_release(port->npe);
 	release_resource(port->mem_res);
@@ -1489,36 +1511,12 @@ static int eth_remove_one(struct platform_device *pdev)
 
 static struct platform_driver ixp4xx_eth_driver = {
 	.driver.name	= DRV_NAME,
-	.probe		= eth_init_one,
-	.remove		= eth_remove_one,
+	.probe		= ixp4xx_eth_probe,
+	.remove		= ixp4xx_eth_remove,
 };
-
-static int __init eth_init_module(void)
-{
-	int err;
-
-	/*
-	 * FIXME: we bail out on device tree boot but this really needs
-	 * to be fixed in a nicer way: this registers the MDIO bus before
-	 * even matching the driver infrastructure, we should only probe
-	 * detected hardware.
-	 */
-	if (of_have_populated_dt())
-		return -ENODEV;
-	if ((err = ixp4xx_mdio_register()))
-		return err;
-	return platform_driver_register(&ixp4xx_eth_driver);
-}
-
-static void __exit eth_cleanup_module(void)
-{
-	platform_driver_unregister(&ixp4xx_eth_driver);
-	ixp4xx_mdio_remove();
-}
+module_platform_driver(ixp4xx_eth_driver);
 
 MODULE_AUTHOR("Krzysztof Halasa");
 MODULE_DESCRIPTION("Intel IXP4xx Ethernet driver");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:ixp4xx_eth");
-module_init(eth_init_module);
-module_exit(eth_cleanup_module);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/10] net: ethernet: ixp4xx: Use distinct local variable
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (4 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 05/10] net: ethernet: ixp4xx: Standard module init Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21  0:08 ` [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Linus Walleij
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

Use "ndev" for the struct net_device and "dev" for the
struct device in probe() and remove(). Add the local
"dev" pointer for later use in refactoring.

Take this opportunity to fix inverse christmas tree
coding style.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 51 +++++++++++++-----------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 26da84402cfd..fbe328693de5 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1367,20 +1367,23 @@ static const struct net_device_ops ixp4xx_netdev_ops = {
 
 static int ixp4xx_eth_probe(struct platform_device *pdev)
 {
-	struct port *port;
-	struct net_device *dev;
-	struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
+	char phy_id[MII_BUS_ID_SIZE + 3];
 	struct phy_device *phydev = NULL;
+	struct device *dev = &pdev->dev;
+	struct eth_plat_info *plat;
+	struct net_device *ndev;
+	struct port *port;
 	u32 regs_phys;
-	char phy_id[MII_BUS_ID_SIZE + 3];
 	int err;
 
-	if (!(dev = alloc_etherdev(sizeof(struct port))))
+	plat = dev_get_platdata(dev);
+
+	if (!(ndev = alloc_etherdev(sizeof(struct port))))
 		return -ENOMEM;
 
-	SET_NETDEV_DEV(dev, &pdev->dev);
-	port = netdev_priv(dev);
-	port->netdev = dev;
+	SET_NETDEV_DEV(ndev, dev);
+	port = netdev_priv(ndev);
+	port->netdev = ndev;
 	port->id = pdev->id;
 
 	switch (port->id) {
@@ -1433,18 +1436,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 		goto err_free;
 	}
 
-	dev->netdev_ops = &ixp4xx_netdev_ops;
-	dev->ethtool_ops = &ixp4xx_ethtool_ops;
-	dev->tx_queue_len = 100;
+	ndev->netdev_ops = &ixp4xx_netdev_ops;
+	ndev->ethtool_ops = &ixp4xx_ethtool_ops;
+	ndev->tx_queue_len = 100;
 
-	netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT);
+	netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT);
 
 	if (!(port->npe = npe_request(NPE_ID(port->id)))) {
 		err = -EIO;
 		goto err_free;
 	}
 
-	port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name);
+	port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name);
 	if (!port->mem_res) {
 		err = -EBUSY;
 		goto err_npe_rel;
@@ -1452,9 +1455,9 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	port->plat = plat;
 	npe_port_tab[NPE_ID(port->id)] = port;
-	memcpy(dev->dev_addr, plat->hwaddr, ETH_ALEN);
+	memcpy(ndev->dev_addr, plat->hwaddr, ETH_ALEN);
 
-	platform_set_drvdata(pdev, dev);
+	platform_set_drvdata(pdev, ndev);
 
 	__raw_writel(DEFAULT_CORE_CNTRL | CORE_RESET,
 		     &port->regs->core_control);
@@ -1464,7 +1467,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
 		mdio_bus->id, plat->phy);
-	phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
+	phydev = phy_connect(ndev, phy_id, &ixp4xx_adjust_link,
 			     PHY_INTERFACE_MODE_MII);
 	if (IS_ERR(phydev)) {
 		err = PTR_ERR(phydev);
@@ -1473,10 +1476,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	phydev->irq = PHY_POLL;
 
-	if ((err = register_netdev(dev)))
+	if ((err = register_netdev(ndev)))
 		goto err_phy_dis;
 
-	printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
+	printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
 	       npe_name(port->npe));
 
 	return 0;
@@ -1489,23 +1492,23 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 err_npe_rel:
 	npe_release(port->npe);
 err_free:
-	free_netdev(dev);
+	free_netdev(ndev);
 	return err;
 }
 
 static int ixp4xx_eth_remove(struct platform_device *pdev)
 {
-	struct net_device *dev = platform_get_drvdata(pdev);
-	struct phy_device *phydev = dev->phydev;
-	struct port *port = netdev_priv(dev);
+	struct net_device *ndev = platform_get_drvdata(pdev);
+	struct phy_device *phydev = ndev->phydev;
+	struct port *port = netdev_priv(ndev);
 
-	unregister_netdev(dev);
+	unregister_netdev(ndev);
 	phy_disconnect(phydev);
 	ixp4xx_mdio_remove();
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	npe_release(port->npe);
 	release_resource(port->mem_res);
-	free_netdev(dev);
+	free_netdev(ndev);
 	return 0;
 }
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev()
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (5 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 06/10] net: ethernet: ixp4xx: Use distinct local variable Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-22  1:21   ` Jakub Kicinski
  2019-10-26 22:24   ` Joe Perches
  2019-10-21  0:08 ` [PATCH 08/10] ARM/net: ixp4xx: Pass ethernet physical base as resource Linus Walleij
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

Using the devm_alloc_etherdev() function simplifies the error
path. I also patch the message to use dev_info().

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index fbe328693de5..df18d8ebb170 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	plat = dev_get_platdata(dev);
 
-	if (!(ndev = alloc_etherdev(sizeof(struct port))))
+	if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port))))
 		return -ENOMEM;
 
 	SET_NETDEV_DEV(ndev, dev);
@@ -1432,8 +1432,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 		regs_phys  = IXP4XX_EthC_BASE_PHYS;
 		break;
 	default:
-		err = -ENODEV;
-		goto err_free;
+		return -ENODEV;
 	}
 
 	ndev->netdev_ops = &ixp4xx_netdev_ops;
@@ -1442,10 +1441,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 
 	netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT);
 
-	if (!(port->npe = npe_request(NPE_ID(port->id)))) {
-		err = -EIO;
-		goto err_free;
-	}
+	if (!(port->npe = npe_request(NPE_ID(port->id))))
+		return -EIO;
 
 	port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name);
 	if (!port->mem_res) {
@@ -1479,8 +1476,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	if ((err = register_netdev(ndev)))
 		goto err_phy_dis;
 
-	printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
-	       npe_name(port->npe));
+	dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
+		 npe_name(port->npe));
 
 	return 0;
 
@@ -1491,8 +1488,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	release_resource(port->mem_res);
 err_npe_rel:
 	npe_release(port->npe);
-err_free:
-	free_netdev(ndev);
 	return err;
 }
 
@@ -1508,7 +1503,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev)
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	npe_release(port->npe);
 	release_resource(port->mem_res);
-	free_netdev(ndev);
 	return 0;
 }
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/10] ARM/net: ixp4xx: Pass ethernet physical base as resource
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (6 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21  0:08 ` [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address Linus Walleij
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

In order to probe this ethernet interface from the device tree
all physical MMIO regions must be passed as resources. Begin
this rewrite by first passing the port base address as a
resource for all platforms using this driver, remap it in
the driver and avoid using any reference of the statically
mapped virtual address in the driver.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/mach-ixp4xx/fsg-setup.c         | 20 ++++++++++++++++++++
 arch/arm/mach-ixp4xx/goramo_mlr.c        | 20 ++++++++++++++++++++
 arch/arm/mach-ixp4xx/ixdp425-setup.c     | 20 ++++++++++++++++++++
 arch/arm/mach-ixp4xx/nas100d-setup.c     | 10 ++++++++++
 arch/arm/mach-ixp4xx/nslu2-setup.c       | 10 ++++++++++
 arch/arm/mach-ixp4xx/omixp-setup.c       | 20 ++++++++++++++++++++
 arch/arm/mach-ixp4xx/vulcan-setup.c      | 20 ++++++++++++++++++++
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 20 +++++++++++---------
 8 files changed, 131 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c
index 648932d8d7a8..507ee3878769 100644
--- a/arch/arm/mach-ixp4xx/fsg-setup.c
+++ b/arch/arm/mach-ixp4xx/fsg-setup.c
@@ -132,6 +132,22 @@ static struct platform_device fsg_leds = {
 };
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource fsg_eth_npeb_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct resource fsg_eth_npec_resources[] = {
+	{
+		.start		= IXP4XX_EthC_BASE_PHYS,
+		.end		= IXP4XX_EthC_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info fsg_plat_eth[] = {
 	{
 		.phy		= 5,
@@ -151,12 +167,16 @@ static struct platform_device fsg_eth[] = {
 		.dev = {
 			.platform_data	= fsg_plat_eth,
 		},
+		.num_resources	= ARRAY_SIZE(fsg_eth_npeb_resources),
+		.resource	= fsg_eth_npeb_resources,
 	}, {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEC,
 		.dev = {
 			.platform_data	= fsg_plat_eth + 1,
 		},
+		.num_resources	= ARRAY_SIZE(fsg_eth_npec_resources),
+		.resource	= fsg_eth_npec_resources,
 	}
 };
 
diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c
index 93b7afeee142..07b50dfcc489 100644
--- a/arch/arm/mach-ixp4xx/goramo_mlr.c
+++ b/arch/arm/mach-ixp4xx/goramo_mlr.c
@@ -273,6 +273,22 @@ static struct platform_device device_uarts = {
 
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource eth_npeb_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct resource eth_npec_resources[] = {
+	{
+		.start		= IXP4XX_EthC_BASE_PHYS,
+		.end		= IXP4XX_EthC_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info eth_plat[] = {
 	{
 		.phy		= 0,
@@ -290,10 +306,14 @@ static struct platform_device device_eth_tab[] = {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEB,
 		.dev.platform_data	= eth_plat,
+		.num_resources		= ARRAY_SIZE(eth_npeb_resources),
+		.resource		= eth_npeb_resources,
 	}, {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEC,
 		.dev.platform_data	= eth_plat + 1,
+		.num_resources		= ARRAY_SIZE(eth_npec_resources),
+		.resource		= eth_npec_resources,
 	}
 };
 
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index 6f0f7ed18ea8..45d5b720ded6 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -187,6 +187,22 @@ static struct platform_device ixdp425_uart = {
 };
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource ixp425_npeb_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct resource ixp425_npec_resources[] = {
+	{
+		.start		= IXP4XX_EthC_BASE_PHYS,
+		.end		= IXP4XX_EthC_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info ixdp425_plat_eth[] = {
 	{
 		.phy		= 0,
@@ -204,10 +220,14 @@ static struct platform_device ixdp425_eth[] = {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEB,
 		.dev.platform_data	= ixdp425_plat_eth,
+		.num_resources		= ARRAY_SIZE(ixp425_npeb_resources),
+		.resource		= ixp425_npeb_resources,
 	}, {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEC,
 		.dev.platform_data	= ixdp425_plat_eth + 1,
+		.num_resources		= ARRAY_SIZE(ixp425_npec_resources),
+		.resource		= ixp425_npec_resources,
 	}
 };
 
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index c142cfa8c5d6..6959ad2e3aec 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -165,6 +165,14 @@ static struct platform_device nas100d_uart = {
 };
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource nas100d_eth_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info nas100d_plat_eth[] = {
 	{
 		.phy		= 0,
@@ -178,6 +186,8 @@ static struct platform_device nas100d_eth[] = {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEB,
 		.dev.platform_data	= nas100d_plat_eth,
+		.num_resources		= ARRAY_SIZE(nas100d_eth_resources),
+		.resource		= nas100d_eth_resources,
 	}
 };
 
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index ee1877fcfafe..a428bb918703 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -185,6 +185,14 @@ static struct platform_device nslu2_uart = {
 };
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource nslu2_eth_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info nslu2_plat_eth[] = {
 	{
 		.phy		= 1,
@@ -198,6 +206,8 @@ static struct platform_device nslu2_eth[] = {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEB,
 		.dev.platform_data	= nslu2_plat_eth,
+		.num_resources		= ARRAY_SIZE(nslu2_eth_resources),
+		.resource		= nslu2_eth_resources,
 	}
 };
 
diff --git a/arch/arm/mach-ixp4xx/omixp-setup.c b/arch/arm/mach-ixp4xx/omixp-setup.c
index 6ed5a9aed600..8f2b8c473d7a 100644
--- a/arch/arm/mach-ixp4xx/omixp-setup.c
+++ b/arch/arm/mach-ixp4xx/omixp-setup.c
@@ -170,6 +170,22 @@ static struct platform_device mic256_leds = {
 };
 
 /* Built-in 10/100 Ethernet MAC interfaces */
+static struct resource ixp425_npeb_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct resource ixp425_npec_resources[] = {
+	{
+		.start		= IXP4XX_EthC_BASE_PHYS,
+		.end		= IXP4XX_EthC_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info ixdp425_plat_eth[] = {
 	{
 		.phy		= 0,
@@ -187,10 +203,14 @@ static struct platform_device ixdp425_eth[] = {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEB,
 		.dev.platform_data	= ixdp425_plat_eth,
+		.num_resources		= ARRAY_SIZE(ixp425_npeb_resources),
+		.resource		= ixp425_npeb_resources,
 	}, {
 		.name			= "ixp4xx_eth",
 		.id			= IXP4XX_ETH_NPEC,
 		.dev.platform_data	= ixdp425_plat_eth + 1,
+		.num_resources		= ARRAY_SIZE(ixp425_npec_resources),
+		.resource		= ixp425_npec_resources,
 	},
 };
 
diff --git a/arch/arm/mach-ixp4xx/vulcan-setup.c b/arch/arm/mach-ixp4xx/vulcan-setup.c
index d2ebb7c675a8..e506d2af98ad 100644
--- a/arch/arm/mach-ixp4xx/vulcan-setup.c
+++ b/arch/arm/mach-ixp4xx/vulcan-setup.c
@@ -124,6 +124,22 @@ static struct platform_device vulcan_uart = {
 	.num_resources		= ARRAY_SIZE(vulcan_uart_resources),
 };
 
+static struct resource vulcan_npeb_resources[] = {
+	{
+		.start		= IXP4XX_EthB_BASE_PHYS,
+		.end		= IXP4XX_EthB_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct resource vulcan_npec_resources[] = {
+	{
+		.start		= IXP4XX_EthC_BASE_PHYS,
+		.end		= IXP4XX_EthC_BASE_PHYS + 0x0fff,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
 static struct eth_plat_info vulcan_plat_eth[] = {
 	[0] = {
 		.phy		= 0,
@@ -144,6 +160,8 @@ static struct platform_device vulcan_eth[] = {
 		.dev = {
 			.platform_data	= &vulcan_plat_eth[0],
 		},
+		.num_resources		= ARRAY_SIZE(vulcan_npeb_resources),
+		.resource		= vulcan_npeb_resources,
 	},
 	[1] = {
 		.name			= "ixp4xx_eth",
@@ -151,6 +169,8 @@ static struct platform_device vulcan_eth[] = {
 		.dev = {
 			.platform_data	= &vulcan_plat_eth[1],
 		},
+		.num_resources		= ARRAY_SIZE(vulcan_npec_resources),
+		.resource		= vulcan_npec_resources,
 	},
 };
 
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index df18d8ebb170..60cff1bce113 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1371,9 +1371,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	struct phy_device *phydev = NULL;
 	struct device *dev = &pdev->dev;
 	struct eth_plat_info *plat;
+	resource_size_t regs_phys;
 	struct net_device *ndev;
+	struct resource *res;
 	struct port *port;
-	u32 regs_phys;
 	int err;
 
 	plat = dev_get_platdata(dev);
@@ -1386,13 +1387,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	port->netdev = ndev;
 	port->id = pdev->id;
 
+	/* Get the port resource and remap */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+	regs_phys = res->start;
+	port->regs = devm_ioremap_resource(dev, res);
+
 	switch (port->id) {
 	case IXP4XX_ETH_NPEA:
 		/* If the MDIO bus is not up yet, defer probe */
 		if (!mdio_bus)
 			return -EPROBE_DEFER;
-		port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
-		regs_phys  = IXP4XX_EthA_BASE_PHYS;
 		break;
 	case IXP4XX_ETH_NPEB:
 		/*
@@ -1405,13 +1411,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 			      IXP4XX_FEATURE_NPEB_ETH0))
 				return -ENODEV;
 			/* Else register the MDIO bus on NPE-B */
-			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
+			if ((err = ixp4xx_mdio_register(port->regs)))
 				return err;
 		}
 		if (!mdio_bus)
 			return -EPROBE_DEFER;
-		port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
-		regs_phys  = IXP4XX_EthB_BASE_PHYS;
 		break;
 	case IXP4XX_ETH_NPEC:
 		/*
@@ -1423,13 +1427,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 			      IXP4XX_FEATURE_NPEC_ETH))
 				return -ENODEV;
 			/* Else register the MDIO bus on NPE-C */
-			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
+			if ((err = ixp4xx_mdio_register(port->regs)))
 				return err;
 		}
 		if (!mdio_bus)
 			return -EPROBE_DEFER;
-		port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
-		regs_phys  = IXP4XX_EthC_BASE_PHYS;
 		break;
 	default:
 		return -ENODEV;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (7 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 08/10] ARM/net: ixp4xx: Pass ethernet physical base as resource Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21 10:30   ` Arnd Bergmann
  2019-10-21  0:08 ` [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool Linus Walleij
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

The port->id was picked from the platform device .id field,
but this is not supposed to be used for passing around
random numbers in hardware. Identify the port ID number
from the base address instead.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 60cff1bce113..0996046bd046 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1385,7 +1385,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	SET_NETDEV_DEV(ndev, dev);
 	port = netdev_priv(ndev);
 	port->netdev = ndev;
-	port->id = pdev->id;
 
 	/* Get the port resource and remap */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1394,13 +1393,15 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 	regs_phys = res->start;
 	port->regs = devm_ioremap_resource(dev, res);
 
-	switch (port->id) {
-	case IXP4XX_ETH_NPEA:
+	switch (res->start) {
+	case 0xc800c000:
+		port->id = IXP4XX_ETH_NPEA;
 		/* If the MDIO bus is not up yet, defer probe */
 		if (!mdio_bus)
 			return -EPROBE_DEFER;
 		break;
-	case IXP4XX_ETH_NPEB:
+	case 0xc8009000:
+		port->id = IXP4XX_ETH_NPEB;
 		/*
 		 * On all except IXP43x, NPE-B is used for the MDIO bus.
 		 * If there is no NPE-B in the feature set, bail out, else
@@ -1417,7 +1418,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
 		if (!mdio_bus)
 			return -EPROBE_DEFER;
 		break;
-	case IXP4XX_ETH_NPEC:
+	case 0xc800a000:
+		port->id = IXP4XX_ETH_NPEC;
 		/*
 		 * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access,
 		 * of there is no NPE-C, no bus, nothing works, so bail out.
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (8 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address Linus Walleij
@ 2019-10-21  0:08 ` Linus Walleij
  2019-10-21 10:27   ` Arnd Bergmann
  2019-10-21 10:33 ` [PATCH 00/10] IXP4xx networking cleanups Arnd Bergmann
  2019-10-22  1:25 ` Jakub Kicinski
  11 siblings, 1 reply; 23+ messages in thread
From: Linus Walleij @ 2019-10-21  0:08 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Arnd Bergmann, Linus Walleij

Use the netdevice struct device .parent field when calling
dma_pool_create(): the .dma_coherent_mask and .dma_mask
pertains to the bus device on the hardware (platform)
bus in this case, not the struct device inside the network
device. This makes the pool allocation work.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 0996046bd046..3ee6d7232eb9 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1090,7 +1090,7 @@ static int init_queues(struct port *port)
 	int i;
 
 	if (!ports_open) {
-		dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
+		dma_pool = dma_pool_create(DRV_NAME, port->netdev->dev.parent,
 					   POOL_ALLOC_SIZE, 32, 0);
 		if (!dma_pool)
 			return -ENOMEM;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool
  2019-10-21  0:08 ` [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool Linus Walleij
@ 2019-10-21 10:27   ` Arnd Bergmann
  0 siblings, 0 replies; 23+ messages in thread
From: Arnd Bergmann @ 2019-10-21 10:27 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Networking, David S . Miller

On Mon, Oct 21, 2019 at 2:10 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Use the netdevice struct device .parent field when calling
> dma_pool_create(): the .dma_coherent_mask and .dma_mask
> pertains to the bus device on the hardware (platform)
> bus in this case, not the struct device inside the network
> device. This makes the pool allocation work.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Has this always been broken, or can you identify when it stopped
working? It might be a candidate for stable backports.

> ---
>  drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
> index 0996046bd046..3ee6d7232eb9 100644
> --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
> +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
> @@ -1090,7 +1090,7 @@ static int init_queues(struct port *port)
>         int i;
>
>         if (!ports_open) {
> -               dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
> +               dma_pool = dma_pool_create(DRV_NAME, port->netdev->dev.parent,
>                                            POOL_ALLOC_SIZE, 32, 0);
>                 if (!dma_pool)
>                         return -ENOMEM;
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address
  2019-10-21  0:08 ` [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address Linus Walleij
@ 2019-10-21 10:30   ` Arnd Bergmann
  2019-10-31 23:17     ` Linus Walleij
  0 siblings, 1 reply; 23+ messages in thread
From: Arnd Bergmann @ 2019-10-21 10:30 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Networking, David S . Miller

On Mon, Oct 21, 2019 at 2:10 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The port->id was picked from the platform device .id field,
> but this is not supposed to be used for passing around
> random numbers in hardware. Identify the port ID number
> from the base address instead.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

I'm not sure this is better, as now the driver hardcodes the physical
address, and the port->id value is still the same as the pdev->id
value that all boards still pass.

Is this just meant to avoid setting the port id explicitly in DT?

       Arnd

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/10] IXP4xx networking cleanups
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (9 preceding siblings ...)
  2019-10-21  0:08 ` [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool Linus Walleij
@ 2019-10-21 10:33 ` Arnd Bergmann
  2019-10-22  1:25 ` Jakub Kicinski
  11 siblings, 0 replies; 23+ messages in thread
From: Arnd Bergmann @ 2019-10-21 10:33 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Networking, David S . Miller

On Mon, Oct 21, 2019 at 2:08 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> This is a patch series which jams together Arnds and mine
> cleanups for the IXP4xx networking.
>
> I also have patches for device tree support but that
> requires more elaborate work, this series is some of
> mine and some of Arnds patches that is a good foundation
> for his multiplatform work and my device tree work.
>
> These are for application to the networking tree so
> that can be taken in one separate sweep.
>
> I have tested the patches for a bit using zeroday builds
> and some boots on misc IXP4xx devices and haven't run
> into any major problems. We might find some new stuff
> as a result from the new compiler coverage.
>
> The patch set also hits in the ARM tree but Arnd is
> a ARM SoC maintainer and is hereby informed :)

Thanks a lot for collecting these, it looks very good overall.

I had two minor comments for your patches and noticed one
more thing about one of mine:

> Arnd Bergmann (4):
>   wan: ixp4xx_hss: fix compile-testing on 64-bit
>   wan: ixp4xx_hss: enable compile testing
>   ptp: ixp46x: move next to ethernet driver

That subject "move next to ..." makes no sense. I don't
know what I tried to write there, but if you send a new
version, please drop the "next" or try to come up with a
better subject than what I had.

     Arnd

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] wan: ixp4xx_hss: enable compile testing
  2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
@ 2019-10-21 15:23   ` kbuild test robot
  2019-10-21 16:05   ` kbuild test robot
  2019-10-21 18:01   ` kbuild test robot
  2 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-10-21 15:23 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3562 bytes --]

Hi Linus,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-Walleij/IXP4xx-networking-cleanups/20191021-213456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 2a06b8982f8f2f40d03a3daf634676386bd84dbc
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net//wan/ixp4xx_hss.c: In function 'hss_init_module':
>> drivers/net//wan/ixp4xx_hss.c:1400:7: error: implicit declaration of function 'ixp4xx_read_feature_bits' [-Werror=implicit-function-declaration]
     if ((ixp4xx_read_feature_bits() &
          ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net//wan/ixp4xx_hss.c:1401:8: error: 'IXP4XX_FEATURE_HDLC' undeclared (first use in this function); did you mean 'IXP4XX_QMGR_H'?
          (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
           ^~~~~~~~~~~~~~~~~~~
           IXP4XX_QMGR_H
   drivers/net//wan/ixp4xx_hss.c:1401:8: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/net//wan/ixp4xx_hss.c:1401:30: error: 'IXP4XX_FEATURE_HSS' undeclared (first use in this function); did you mean 'IXP4XX_FEATURE_HDLC'?
          (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
                                 ^~~~~~~~~~~~~~~~~~
                                 IXP4XX_FEATURE_HDLC
   cc1: some warnings being treated as errors

vim +/ixp4xx_read_feature_bits +1400 drivers/net//wan/ixp4xx_hss.c

f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1397  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1398  static int __init hss_init_module(void)
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1399  {
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21 @1400  	if ((ixp4xx_read_feature_bits() &
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21 @1401  	     (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1402  	    (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS))
3ba8c792055286 Krzysztof Hałasa 2009-04-28  1403  		return -ENODEV;
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1404  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1405  	spin_lock_init(&npe_lock);
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1406  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1407  	return platform_driver_register(&ixp4xx_hss_driver);
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1408  }
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  1409  

:::::: The code at line 1400 was first introduced by commit
:::::: f5b89e41ce7a980aa2fd8ad105626b9ed4e8d347 WAN: Add IXP4xx HSS HDLC driver.

:::::: TO: Krzysztof Hałasa <khc@pm.waw.pl>
:::::: CC: Krzysztof Hałasa <khc@pm.waw.pl>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 52255 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] wan: ixp4xx_hss: enable compile testing
  2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
  2019-10-21 15:23   ` kbuild test robot
@ 2019-10-21 16:05   ` kbuild test robot
  2019-10-21 18:01   ` kbuild test robot
  2 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-10-21 16:05 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7428 bytes --]

Hi Linus,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-Walleij/IXP4xx-networking-cleanups/20191021-213456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 2a06b8982f8f2f40d03a3daf634676386bd84dbc
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/wan/ixp4xx_hss.c:45:0: warning: "FRAME_SIZE" redefined
    #define FRAME_SIZE  256 /* doesn't matter at this point */
    
   In file included from arch/x86/include/uapi/asm/ptrace.h:6:0,
                    from arch/x86/include/asm/ptrace.h:7,
                    from arch/x86/include/asm/math_emu.h:5,
                    from arch/x86/include/asm/processor.h:12,
                    from arch/x86/include/asm/cpufeature.h:5,
                    from arch/x86/include/asm/thread_info.h:53,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:10,
                    from drivers/net/wan/ixp4xx_hss.c:10:
   arch/x86/include/uapi/asm/ptrace-abi.h:24:0: note: this is the location of the previous definition
    #define FRAME_SIZE 17
    
>> drivers/net/wan/ixp4xx_hss.c:46:0: warning: "FRAME_OFFSET" redefined
    #define FRAME_OFFSET  0
    
   In file included from arch/x86/include/asm/paravirt.h:18:0,
                    from arch/x86/include/asm/spinlock.h:10,
                    from include/linux/spinlock.h:89,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:10,
                    from drivers/net/wan/ixp4xx_hss.c:10:
   arch/x86/include/asm/frame.h:73:0: note: this is the location of the previous definition
    #define FRAME_OFFSET __ASM_SEL(4, 8)
    
   drivers/net/wan/ixp4xx_hss.c: In function 'hss_init_module':
   drivers/net/wan/ixp4xx_hss.c:1400:7: error: implicit declaration of function 'ixp4xx_read_feature_bits' [-Werror=implicit-function-declaration]
     if ((ixp4xx_read_feature_bits() &
          ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/wan/ixp4xx_hss.c:1401:8: error: 'IXP4XX_FEATURE_HDLC' undeclared (first use in this function); did you mean 'X86_FEATURE_HLE'?
          (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
           ^~~~~~~~~~~~~~~~~~~
           X86_FEATURE_HLE
   drivers/net/wan/ixp4xx_hss.c:1401:8: note: each undeclared identifier is reported only once for each function it appears in
   drivers/net/wan/ixp4xx_hss.c:1401:30: error: 'IXP4XX_FEATURE_HSS' undeclared (first use in this function); did you mean 'IXP4XX_FEATURE_HDLC'?
          (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
                                 ^~~~~~~~~~~~~~~~~~
                                 IXP4XX_FEATURE_HDLC
   cc1: some warnings being treated as errors

vim +/FRAME_OFFSET +46 drivers/net/wan/ixp4xx_hss.c

c75bb2c6f0cf45 Joe Perches      2011-06-26   9  
0b836ddde177bd Florian Fainelli 2012-09-10 @10  #include <linux/module.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  11  #include <linux/bitops.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  12  #include <linux/cdev.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  13  #include <linux/dma-mapping.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  14  #include <linux/dmapool.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  15  #include <linux/fs.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  16  #include <linux/hdlc.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  17  #include <linux/io.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  18  #include <linux/kernel.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  19  #include <linux/platform_device.h>
191e3434201001 Arnd Bergmann    2019-10-21  20  #include <linux/platform_data/wan_ixp4xx_hss.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  21  #include <linux/poll.h>
5a0e3ad6af8660 Tejun Heo        2010-03-24  22  #include <linux/slab.h>
4af20dc583b364 Linus Walleij    2019-02-10  23  #include <linux/soc/ixp4xx/npe.h>
4af20dc583b364 Linus Walleij    2019-02-10  24  #include <linux/soc/ixp4xx/qmgr.h>
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  25  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  26  #define DEBUG_DESC		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  27  #define DEBUG_RX		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  28  #define DEBUG_TX		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  29  #define DEBUG_PKT_BYTES		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  30  #define DEBUG_CLOSE		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  31  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  32  #define DRV_NAME		"ixp4xx_hss"
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  33  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  34  #define PKT_EXTRA_FLAGS		0 /* orig 1 */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  35  #define PKT_NUM_PIPES		1 /* 1, 2 or 4 */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  36  #define PKT_PIPE_FIFO_SIZEW	4 /* total 4 dwords per HSS */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  37  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  38  #define RX_DESCS		16 /* also length of all RX queues */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  39  #define TX_DESCS		16 /* also length of all TX queues */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  40  
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  41  #define POOL_ALLOC_SIZE		(sizeof(struct desc) * (RX_DESCS + TX_DESCS))
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  42  #define RX_SIZE			(HDLC_MAX_MRU + 4) /* NPE needs more space */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  43  #define MAX_CLOSE_WAIT		1000 /* microseconds */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  44  #define HSS_COUNT		2
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  45  #define FRAME_SIZE		256 /* doesn't matter at this point */
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21 @46  #define FRAME_OFFSET		0
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  47  #define MAX_CHANNELS		(FRAME_SIZE / 8)
f5b89e41ce7a98 Krzysztof Hałasa 2008-12-21  48  

:::::: The code at line 46 was first introduced by commit
:::::: f5b89e41ce7a980aa2fd8ad105626b9ed4e8d347 WAN: Add IXP4xx HSS HDLC driver.

:::::: TO: Krzysztof Hałasa <khc@pm.waw.pl>
:::::: CC: Krzysztof Hałasa <khc@pm.waw.pl>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 70220 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] wan: ixp4xx_hss: enable compile testing
  2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
  2019-10-21 15:23   ` kbuild test robot
  2019-10-21 16:05   ` kbuild test robot
@ 2019-10-21 18:01   ` kbuild test robot
  2 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2019-10-21 18:01 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2577 bytes --]

Hi Linus,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-Walleij/IXP4xx-networking-cleanups/20191021-213456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 2a06b8982f8f2f40d03a3daf634676386bd84dbc
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

   drivers/net/wan/ixp4xx_hss.c:45:9: sparse: sparse: preprocessor token FRAME_SIZE redefined
>> arch/x86/include/uapi/asm/ptrace-abi.h:63:9: sparse: this was the original definition
   drivers/net/wan/ixp4xx_hss.c:1400:14: sparse: sparse: undefined identifier 'ixp4xx_read_feature_bits'
   drivers/net/wan/ixp4xx_hss.c:1401:15: sparse: sparse: undefined identifier 'IXP4XX_FEATURE_HDLC'
   drivers/net/wan/ixp4xx_hss.c:1401:37: sparse: sparse: undefined identifier 'IXP4XX_FEATURE_HSS'
   drivers/net/wan/ixp4xx_hss.c:1402:14: sparse: sparse: undefined identifier 'IXP4XX_FEATURE_HDLC'
   drivers/net/wan/ixp4xx_hss.c:1402:36: sparse: sparse: undefined identifier 'IXP4XX_FEATURE_HSS'
   drivers/net/wan/ixp4xx_hss.c:855:23: sparse: sparse: non size-preserving pointer to integer cast

vim +63 arch/x86/include/uapi/asm/ptrace-abi.h

686d8c63d530a5 include/asm-x86/ptrace-abi.h Thomas Gleixner 2007-10-17  61  
686d8c63d530a5 include/asm-x86/ptrace-abi.h Thomas Gleixner 2007-10-17  62  /* top of stack page */
686d8c63d530a5 include/asm-x86/ptrace-abi.h Thomas Gleixner 2007-10-17 @63  #define FRAME_SIZE 168
686d8c63d530a5 include/asm-x86/ptrace-abi.h Thomas Gleixner 2007-10-17  64  

:::::: The code at line 63 was first introduced by commit
:::::: 686d8c63d530a5cfdbab2523825e37b904be56f9 x86: unify include/asm/ptrace-abi_32/64.h

:::::: TO: Thomas Gleixner <tglx@linutronix.de>
:::::: CC: Thomas Gleixner <tglx@inhelltoy.tec.linutronix.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 05/10] net: ethernet: ixp4xx: Standard module init
  2019-10-21  0:08 ` [PATCH 05/10] net: ethernet: ixp4xx: Standard module init Linus Walleij
@ 2019-10-22  1:19   ` Jakub Kicinski
  0 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2019-10-22  1:19 UTC (permalink / raw)
  To: Linus Walleij; +Cc: netdev, David S . Miller, Arnd Bergmann

On Mon, 21 Oct 2019 02:08:19 +0200, Linus Walleij wrote:
> @@ -1376,7 +1365,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = {
>  	.ndo_validate_addr = eth_validate_addr,
>  };
>  
> -static int eth_init_one(struct platform_device *pdev)
> +static int ixp4xx_eth_probe(struct platform_device *pdev)
>  {
>  	struct port *port;
>  	struct net_device *dev;
> @@ -1396,14 +1385,46 @@ static int eth_init_one(struct platform_device *pdev)
>  
>  	switch (port->id) {
>  	case IXP4XX_ETH_NPEA:
> +		/* If the MDIO bus is not up yet, defer probe */
> +		if (!mdio_bus)
> +			return -EPROBE_DEFER;

There's an allocation at the top of this function. All the rest of the
code does goto err_xyz. I don't think you can just return directly here,
or anywhere below.

>  		port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
>  		regs_phys  = IXP4XX_EthA_BASE_PHYS;
>  		break;
>  	case IXP4XX_ETH_NPEB:
> +		/*
> +		 * On all except IXP43x, NPE-B is used for the MDIO bus.
> +		 * If there is no NPE-B in the feature set, bail out, else
> +		 * register the MDIO bus.
> +		 */
> +		if (!cpu_is_ixp43x()) {
> +			if (!(ixp4xx_read_feature_bits() &
> +			      IXP4XX_FEATURE_NPEB_ETH0))
> +				return -ENODEV;
> +			/* Else register the MDIO bus on NPE-B */
> +			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
> +				return err;
> +		}
> +		if (!mdio_bus)
> +			return -EPROBE_DEFER;
>  		port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
>  		regs_phys  = IXP4XX_EthB_BASE_PHYS;
>  		break;
>  	case IXP4XX_ETH_NPEC:
> +		/*
> +		 * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access,
> +		 * of there is no NPE-C, no bus, nothing works, so bail out.
> +		 */
> +		if (cpu_is_ixp43x()) {
> +			if (!(ixp4xx_read_feature_bits() &
> +			      IXP4XX_FEATURE_NPEC_ETH))
> +				return -ENODEV;
> +			/* Else register the MDIO bus on NPE-C */
> +			if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
> +				return err;
> +		}
> +		if (!mdio_bus)
> +			return -EPROBE_DEFER;
>  		port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
>  		regs_phys  = IXP4XX_EthC_BASE_PHYS;
>  		break;


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev()
  2019-10-21  0:08 ` [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Linus Walleij
@ 2019-10-22  1:21   ` Jakub Kicinski
  2019-10-26 22:24   ` Joe Perches
  1 sibling, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2019-10-22  1:21 UTC (permalink / raw)
  To: Linus Walleij; +Cc: netdev, David S . Miller, Arnd Bergmann

On Mon, 21 Oct 2019 02:08:21 +0200, Linus Walleij wrote:
> Using the devm_alloc_etherdev() function simplifies the error
> path. I also patch the message to use dev_info().
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
> index fbe328693de5..df18d8ebb170 100644
> --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
> +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
> @@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
>  
>  	plat = dev_get_platdata(dev);
>  
> -	if (!(ndev = alloc_etherdev(sizeof(struct port))))
> +	if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port))))
>  		return -ENOMEM;
>  
>  	SET_NETDEV_DEV(ndev, dev);

Okay, I see you do devm_ here.. please reorder the patches, then.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/10] IXP4xx networking cleanups
  2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
                   ` (10 preceding siblings ...)
  2019-10-21 10:33 ` [PATCH 00/10] IXP4xx networking cleanups Arnd Bergmann
@ 2019-10-22  1:25 ` Jakub Kicinski
  11 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2019-10-22  1:25 UTC (permalink / raw)
  To: Linus Walleij; +Cc: netdev, David S . Miller, Arnd Bergmann

On Mon, 21 Oct 2019 02:08:14 +0200, Linus Walleij wrote:
> This is a patch series which jams together Arnds and mine
> cleanups for the IXP4xx networking.
> 
> I also have patches for device tree support but that
> requires more elaborate work, this series is some of
> mine and some of Arnds patches that is a good foundation
> for his multiplatform work and my device tree work.
> 
> These are for application to the networking tree so
> that can be taken in one separate sweep.

Also looks good for me with the minor request to reorder
the patches.

FWIW if you're targeting the networking tree feel free to
add --subject-prefix="PATCH net-next" when generating the
patches, this way they stand out nicely in the inbox and
in patchwork.

> I have tested the patches for a bit using zeroday builds
> and some boots on misc IXP4xx devices and haven't run
> into any major problems. We might find some new stuff
> as a result from the new compiler coverage.
> 
> The patch set also hits in the ARM tree but Arnd is
> a ARM SoC maintainer and is hereby informed :)


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev()
  2019-10-21  0:08 ` [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Linus Walleij
  2019-10-22  1:21   ` Jakub Kicinski
@ 2019-10-26 22:24   ` Joe Perches
  2019-10-31 23:13     ` Linus Walleij
  1 sibling, 1 reply; 23+ messages in thread
From: Joe Perches @ 2019-10-26 22:24 UTC (permalink / raw)
  To: Linus Walleij, netdev, David S . Miller; +Cc: Arnd Bergmann

On Mon, 2019-10-21 at 02:08 +0200, Linus Walleij wrote:
> Using the devm_alloc_etherdev() function simplifies the error
> path. I also patch the message to use dev_info().

slight typo in subject

> diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c

Maybe it's better to avoid changing this driver.
Is this device still sold?  It's 15+ years old.

> @@ -1378,7 +1378,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
>  
>  	plat = dev_get_platdata(dev);
>  
> -	if (!(ndev = alloc_etherdev(sizeof(struct port))))
> +	if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port))))

Probably nicer to split the assignment and test too.

> @@ -1479,8 +1476,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
>  	if ((err = register_netdev(ndev)))
>  		goto err_phy_dis;
>  
> -	printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
> -	       npe_name(port->npe));
> +	dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy,
> +		 npe_name(port->npe));

and this should probably be

	netdev_info(ndev, "MII PHY %d on %s\n", plat->phy, npe_name(port->npe));

But there are 30+ printks in this file, so why just this one?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev()
  2019-10-26 22:24   ` Joe Perches
@ 2019-10-31 23:13     ` Linus Walleij
  0 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-31 23:13 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, David S . Miller, Arnd Bergmann

On Sun, Oct 27, 2019 at 12:24 AM Joe Perches <joe@perches.com> wrote:
> On Mon, 2019-10-21 at 02:08 +0200, Linus Walleij wrote:

> > diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
>
> Maybe it's better to avoid changing this driver.
> Is this device still sold?  It's 15+ years old.

I am converting the whole platform to device tree so I need to
change this and many other drivers.

The rationale has been explained elsewhere but here it is for your
convenience:

A major reason why IXP4xx silicon is still produced and deployed is
the operating conditions. If you look at for example the Gateworks
Cambria GW2358-4 network processor you notice the strictly
military operating conditions:

Temperature: -40°C to +85°C
Humidity (non-condensing): 20% to 90%
MTBF (mean time before failure): 60 Years at 55°C

We have good reasons to believe that these are used in critical
systems that are not consumer products and do not adhere to
consumer product life cycle expectations. Think more like this:
https://www.c4isrnet.com/air/2019/10/17/the-us-nuclear-forces-dr-strangelove-era-messaging-system-finally-got-rid-of-its-floppy-disks/

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address
  2019-10-21 10:30   ` Arnd Bergmann
@ 2019-10-31 23:17     ` Linus Walleij
  0 siblings, 0 replies; 23+ messages in thread
From: Linus Walleij @ 2019-10-31 23:17 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Networking, David S . Miller

On Mon, Oct 21, 2019 at 12:30 PM Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Oct 21, 2019 at 2:10 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > The port->id was picked from the platform device .id field,
> > but this is not supposed to be used for passing around
> > random numbers in hardware. Identify the port ID number
> > from the base address instead.
> >
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> I'm not sure this is better, as now the driver hardcodes the physical
> address, and the port->id value is still the same as the pdev->id
> value that all boards still pass.
>
> Is this just meant to avoid setting the port id explicitly in DT?

Yes, because the DT bindings people would not like us to encode
that in DT, as it is a Linuxism.

To DT these are just three networking engines (NPEs) that the
OS can choose to use however it likes.

That they behave differently and that the driver has to cope
with that is due to different firmware being loaded into the
different NPE:s. DT doesn't care about that.

I will mention it in the commit message.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-10-31 23:18 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  0:08 [PATCH 00/10] IXP4xx networking cleanups Linus Walleij
2019-10-21  0:08 ` [PATCH 01/10] wan: ixp4xx_hss: fix compile-testing on 64-bit Linus Walleij
2019-10-21  0:08 ` [PATCH 02/10] wan: ixp4xx_hss: enable compile testing Linus Walleij
2019-10-21 15:23   ` kbuild test robot
2019-10-21 16:05   ` kbuild test robot
2019-10-21 18:01   ` kbuild test robot
2019-10-21  0:08 ` [PATCH 03/10] ptp: ixp46x: move next to ethernet driver Linus Walleij
2019-10-21  0:08 ` [PATCH 04/10] ixp4xx_eth: move platform_data definition Linus Walleij
2019-10-21  0:08 ` [PATCH 05/10] net: ethernet: ixp4xx: Standard module init Linus Walleij
2019-10-22  1:19   ` Jakub Kicinski
2019-10-21  0:08 ` [PATCH 06/10] net: ethernet: ixp4xx: Use distinct local variable Linus Walleij
2019-10-21  0:08 ` [PATCH 07/10] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Linus Walleij
2019-10-22  1:21   ` Jakub Kicinski
2019-10-26 22:24   ` Joe Perches
2019-10-31 23:13     ` Linus Walleij
2019-10-21  0:08 ` [PATCH 08/10] ARM/net: ixp4xx: Pass ethernet physical base as resource Linus Walleij
2019-10-21  0:08 ` [PATCH 09/10] net: ethernet: ixp4xx: Get port ID from base address Linus Walleij
2019-10-21 10:30   ` Arnd Bergmann
2019-10-31 23:17     ` Linus Walleij
2019-10-21  0:08 ` [PATCH 10/10] net: ethernet: ixp4xx: Use parent dev for DMA pool Linus Walleij
2019-10-21 10:27   ` Arnd Bergmann
2019-10-21 10:33 ` [PATCH 00/10] IXP4xx networking cleanups Arnd Bergmann
2019-10-22  1:25 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.