Skip to contentSkip to conversation

net: smc91x: improve neponset hack

PATCH In review Arnd Bergmann 5 participants 9 messages Feb 18, 2015 – Mar 9, 2015

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: smc91x: improve neponset hack

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

Trying to build for CONFIG_SA1100_ASSABET without CONFIG_ASSABET_NEPONSET results in this link error:

drivers/built-in.o: In function `smc_drv_probe':
:(.text+0x33310c): undefined reference to `neponset_ncr_frob'

since the neponset_ncr_set function is not defined otherwise.

Similarly, building for both CONFIG_SA1100_ASSABET and CONFIG_SA1100_PLEB results in a different build error:

smsc/smc91x.c: In function 'smc_drv_probe':
smsc/smc91x.c:2299:2: error: implicit declaration of function 'neponset_ncr_set' [-Werror=implicit-function-declaration]
neponset_ncr_set(NCR_ENET_OSC_EN);
^
smsc/smc91x.c:2299:19: error: 'NCR_ENET_OSC_EN' undeclared (first use in this function)

  neponset_ncr_set(NCR_ENET_OSC_EN);
                   ^

This is an attempt to fix the call site responsible for both errors, making sure we call the function exactly when the driver is actually trying to run on the assabet/neponset machine. With this patch, I no longer see randconfig build errors in this file.

drivers/net/ethernet/smsc/smc91x.c +1 -1
index 88a55f95fe09..fa3f193b5f4d 100644
@@ -2355,7 +2355,7 @@ static int smc_drv_probe(struct platform_device *pdev)
 	ret = smc_request_attrib(pdev, ndev);
 	if (ret)
 		goto out_release_io;
-#if defined(CONFIG_SA1100_ASSABET)
+#if defined(CONFIG_ASSABET_NEPONSET) && !defined(CONFIG_SA1100_PLEB)
 	neponset_ncr_set(NCR_ENET_OSC_EN);
 #endif
 	platform_set_drvdata(pdev, ndev);
#1 lore raw
Quoted 3 lines · Arnd Bergmann

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#2 lore raw
Quoted 7 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 3 lines · Arnd Bergmann

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Can you check if the approach below makes sense to you?

I've verified that each machine that defines an smc91x device now sets the correct platform data, irq flags and access width, which should be enough to collapse all the CONFIG_ARM cases into one.

 arch/arm/mach-msm/board-halibut.c    |   8 ++-
 arch/arm/mach-msm/board-qsd8x50.c    |   8 ++-
 arch/arm/mach-pxa/idp.c              |   5 ++
 arch/arm/mach-pxa/lpd270.c           |   8 ++-
 arch/arm/mach-realview/core.c        |   7 +++
 arch/arm/mach-realview/realview_eb.c |   2 +-
 arch/arm/mach-sa1100/neponset.c      |   6 ++
 arch/arm/mach-sa1100/pleb.c          |   7 +++
 drivers/net/ethernet/smsc/smc91x.c   |   9 ++-
 drivers/net/ethernet/smsc/smc91x.h   | 114 +----------------------------------
 10 files changed, 57 insertions(+), 117 deletions(-)
arch/arm/mach-msm/board-halibut.c +7 -1
index 61bfe584a9d7..fc832040c6e9 100644
@@ -20,6 +20,7 @@
 #include <linux/input.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/smc91x.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -46,15 +47,20 @@ static struct resource smc91x_resources[] = {
 	[1] = {
 		.start	= MSM_GPIO_TO_INT(49),
 		.end	= MSM_GPIO_TO_INT(49),
-		.flags	= IORESOURCE_IRQ,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
 	},
 };
 
+static struct smc91x_platdata smc91x_platdata = {
+	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
+};
+
 static struct platform_device smc91x_device = {
 	.name		= "smc91x",
 	.id		= 0,
 	.num_resources	= ARRAY_SIZE(smc91x_resources),
 	.resource	= smc91x_resources,
+	.dev.platform_data = &smc91x_platdata,
 };
 
 static struct platform_device *devices[] __initdata = {
arch/arm/mach-msm/board-qsd8x50.c +7 -1
index 4c748616ef47..10016a3bc698 100644
@@ -22,6 +22,7 @@
 #include <linux/usb/msm_hsusb.h>
 #include <linux/err.h>
 #include <linux/clkdev.h>
+#include <linux/smc91x.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -49,15 +50,20 @@ static struct resource smc91x_resources[] = {
 		.flags = IORESOURCE_MEM,
 	},
 	[1] = {
-		.flags = IORESOURCE_IRQ,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
 	},
 };
 
+static struct smc91x_platdata smc91x_platdata = {
+	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
+};
+
 static struct platform_device smc91x_device = {
 	.name           = "smc91x",
 	.id             = 0,
 	.num_resources  = ARRAY_SIZE(smc91x_resources),
 	.resource       = smc91x_resources,
+	.dev.platform_data = &smc91x_platdata,
 };
 
 static int __init msm_init_smc91x(void)
arch/arm/mach-pxa/idp.c +5 -0
index 343c4e3a7c5d..7d8eab857a93 100644
@@ -81,11 +81,16 @@ static struct resource smc91x_resources[] = {
 	}
 };
 
+static struct smc91x_platdata smc91x_platdata = {
+	.flags = SMC91X_USE_32BIT | SMC91X_USE_DMA | SMC91X_NOWAIT,
+};
+
 static struct platform_device smc91x_device = {
 	.name		= "smc91x",
 	.id		= 0,
 	.num_resources	= ARRAY_SIZE(smc91x_resources),
 	.resource	= smc91x_resources,
+	.dev.platform_data = &smc91x_platdata,
 };
 
 static void idp_backlight_power(int on)
arch/arm/mach-pxa/lpd270.c +7 -1
index ad777b353bd5..28da319d389f 100644
@@ -24,6 +24,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/pwm_backlight.h>
+#include <linux/smc91x.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -189,15 +190,20 @@ static struct resource smc91x_resources[] = {
 	[1] = {
 		.start	= LPD270_ETHERNET_IRQ,
 		.end	= LPD270_ETHERNET_IRQ,
-		.flags	= IORESOURCE_IRQ,
+		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 	},
 };
 
+struct smc91x_platdata smc91x_platdata = {
+	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT;
+};
+
 static struct platform_device smc91x_device = {
 	.name		= "smc91x",
 	.id		= 0,
 	.num_resources	= ARRAY_SIZE(smc91x_resources),
 	.resource	= smc91x_resources,
+	.dev.platform_data = &smc91x_platdata,
 };
 
 static struct resource lpd270_flash_resources[] = {
arch/arm/mach-realview/core.c +7 -0
index 850e506926df..838b327cf9ce 100644
@@ -28,6 +28,7 @@
 #include <linux/platform_data/video-clcd-versatile.h>
 #include <linux/io.h>
 #include <linux/smsc911x.h>
+#include <linux/smsc91x.h>
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
@@ -94,6 +95,10 @@ static struct smsc911x_platform_config smsc911x_config = {
 	.phy_interface	= PHY_INTERFACE_MODE_MII,
 };
 
+static struct smc91x_platdata smc91x_platdata =
+	.flags = SMC91X_USE_32BIT | SMC_NOWAIT,
+};
+
 static struct platform_device realview_eth_device = {
 	.name		= "smsc911x",
 	.id		= 0,
@@ -107,6 +112,8 @@ int realview_eth_register(const char *name, struct resource *res)
 	realview_eth_device.resource = res;
 	if (strcmp(realview_eth_device.name, "smsc911x") == 0)
 		realview_eth_device.dev.platform_data = &smsc911x_config;
+	else
+		realview_eth_device.dev.platform_data = &smc91x_platdata;
 
 	return platform_device_register(&realview_eth_device);
 }
arch/arm/mach-realview/realview_eb.c +1 -1
index 64c88d657f9e..b3869cbbcc68 100644
@@ -234,7 +234,7 @@ static struct resource realview_eb_eth_resources[] = {
 	[1] = {
 		.start		= IRQ_EB_ETH,
 		.end		= IRQ_EB_ETH,
-		.flags		= IORESOURCE_IRQ,
+		.flags		= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 	},
 };
 
arch/arm/mach-sa1100/neponset.c +6 -0
index 169262e3040d..7b0cd3172354 100644
@@ -12,6 +12,7 @@
 #include <linux/pm.h>
 #include <linux/serial_core.h>
 #include <linux/slab.h>
+#include <linux/smc91x.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
@@ -258,12 +259,17 @@ static int neponset_probe(struct platform_device *dev)
 			0x02000000, "smc91x-attrib"),
 		{ .flags = IORESOURCE_IRQ },
 	};
+	struct smc91x_platdata smc91x_platdata = {
+		.flags = SMC91X_USE_8BIT | SMC91X_IO_SHIFT_2 | SMC91X_NOWAIT,
+	};
 	struct platform_device_info smc91x_devinfo = {
 		.parent = &dev->dev,
 		.name = "smc91x",
 		.id = 0,
 		.res = smc91x_resources,
 		.num_res = ARRAY_SIZE(smc91x_resources),
+		.data = &smc91c_platdata,
+		.size_data = sizeof(smc91c_platdata),
 	};
 	int ret, irq;
 
arch/arm/mach-sa1100/pleb.c +7 -0
index 091261878eff..696fd0fe4806 100644
@@ -11,6 +11,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/mtd/partitions.h>
+#include <linux/smc91x.h>
 
 #include <mach/hardware.h>
 #include <asm/setup.h>
@@ -43,12 +44,18 @@ static struct resource smc91x_resources[] = {
 #endif
 };
 
+static struct smc91x_platdata smc91x_platdata = {
+	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
+};
 
 static struct platform_device smc91x_device = {
 	.name		= "smc91x",
 	.id		= 0,
 	.num_resources	= ARRAY_SIZE(smc91x_resources),
 	.resource	= smc91x_resources,
+	.dev = {
+		.platform_data  = &smc91c_platdata,
+	},
 };
 
 static struct platform_device *devices[] __initdata = {
drivers/net/ethernet/smsc/smc91x.c +7 -2
index fa3f193b5f4d..f4700d4c9c77 100644
@@ -91,6 +91,10 @@ static const char version[] =
 
 #include "smc91x.h"
 
+#if defined(CONFIG_ASSABET_NEPONSET)
+#include <mach/neponset.h>
+#endif
+
 #ifndef SMC_NOWAIT
 # define SMC_NOWAIT		0
 #endif
@@ -2355,8 +2359,9 @@ static int smc_drv_probe(struct platform_device *pdev)
 	ret = smc_request_attrib(pdev, ndev);
 	if (ret)
 		goto out_release_io;
-#if defined(CONFIG_ASSABET_NEPONSET) && !defined(CONFIG_SA1100_PLEB)
-	neponset_ncr_set(NCR_ENET_OSC_EN);
+#if defined(CONFIG_ASSABET_NEPONSET)
+	if (machine_is_assabet() && !machine_has_neponset())
+		neponset_ncr_set(NCR_ENET_OSC_EN);
 #endif
 	platform_set_drvdata(pdev, ndev);
 	ret = smc_enable_device(pdev);
drivers/net/ethernet/smsc/smc91x.h +3 -111

132 lines not on this page · raw message

maintainer
#3 lore raw
Quoted 13 lines · Arnd Bergmann
Quoted 7 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 3 lines · Arnd Bergmann

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Quoted 7 lines

Can you check if the approach below makes sense to you?

I've verified that each machine that defines an smc91x device now sets the correct platform data, irq flags and access width, which should be enough to collapse all the CONFIG_ARM cases into one.

When you're both satisfied with the smc91x patch, I can offer to test it across the pxa boards (lubbock, zylonite, and maybe mainstone). As I'm actively using the first 2, I'm interested in them being as functional as now :)

Cheers.

--
Robert

maintainer
#4 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Fri, 20 Feb 2015 16:47:06 +0100

Quoted 13 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 7 lines · Arnd Bergmann
Quoted 3 lines

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Quoted 7 lines

Can you check if the approach below makes sense to you?

I've verified that each machine that defines an smc91x device now sets the correct platform data, irq flags and access width, which should be enough to collapse all the CONFIG_ARM cases into one.

This is a nice cleanup but for 'net' to fix the build error I prefer the original one-line patch.

We can apply this thing here to net-next.

#5 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 3 lines · Arnd Bergmann

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

Quoted 8 lines
Quoted 2 lines

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Can you check if the approach below makes sense to you?

I don't know who's carrying what patches, but this is still broken.

arch/arm/mach-sa1100/neponset.c: In function 'neponset_probe':
arch/arm/mach-sa1100/neponset.c:271:12: error: 'smc91c_platdata' undeclared (first use in this function) drivers/net/ethernet/smsc/smc91x.c: In function 'smc_drv_probe':
drivers/net/ethernet/smsc/smc91x.c:2363:2: error: implicit declaration of function 'machine_has_neponset' [-Werror=implicit-function-declaration]

This is from building Linus' tree as of Saturday plus arm-soc.

Let's revert all this crap and start again, this time testing it better?

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#6 lore raw
Quoted 18 lines · Russell King - ARM Linux
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 3 lines · Arnd Bergmann

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

Quoted 8 lines
Quoted 2 lines

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Can you check if the approach below makes sense to you?

I don't know who's carrying what patches, but this is still broken.

Quoted 8 lines

arch/arm/mach-sa1100/neponset.c: In function 'neponset_probe':
arch/arm/mach-sa1100/neponset.c:271:12: error: 'smc91c_platdata' undeclared (first use in this function) drivers/net/ethernet/smsc/smc91x.c: In function 'smc_drv_probe':
drivers/net/ethernet/smsc/smc91x.c:2363:2: error: implicit declaration of function 'machine_has_neponset' [-Werror=implicit-function-declaration]

This is from building Linus' tree as of Saturday plus arm-soc.

Let's revert all this crap and start again, this time testing it better?

I'm also getting:

arch/arm/mach-pxa/idp.c:84:15: error: variable 'smc91x_platdata' has initializer but incomplete type arch/arm/mach-pxa/idp.c:85:2: error: unknown field 'flags' specified in initializer arch/arm/mach-pxa/idp.c:85:11: error: 'SMC91X_USE_32BIT' undeclared here (not in a function) arch/arm/mach-pxa/idp.c:85:30: error: 'SMC91X_USE_DMA' undeclared here (not in a function) arch/arm/mach-pxa/idp.c:85:47: error: 'SMC91X_NOWAIT' undeclared here (not in a function) arch/arm/mach-pxa/idp.c:85:2: warning: excess elements in struct initializer [enabled by default] arch/arm/mach-pxa/idp.c:85:2: warning: (near initialization for 'smc91x_platdata') [enabled by default] arch/arm/mach-pxa/lpd270.c:198:30: error: expected '}' before ';' token

Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
#7 lore raw

From: Russell King - ARM Linux <[email protected]>
Date: Mon, 9 Mar 2015 12:34:47 +0000

Quoted 24 lines · Russell King - ARM Linux
Quoted 23 lines · Arnd Bergmann
Quoted 6 lines · On Thursday 19 February 2015 00:35:49 Russell King - ARM Linux wrote:
Quoted 5 lines · Arnd Bergmann
Quoted 3 lines

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

Quoted 8 lines
Quoted 2 lines

I'd prefer to rework this to fix that properly. From what I remember, the whole SA11x0 stuff in this driver was a mess.

I guess that's reasonable. I've looked through the driver and it seems we did most of the multiplatform work but left a few things alone that should have been converted a long time ago.

Can you check if the approach below makes sense to you?

I don't know who's carrying what patches, but this is still broken.

arch/arm/mach-sa1100/neponset.c: In function 'neponset_probe':
arch/arm/mach-sa1100/neponset.c:271:12: error: 'smc91c_platdata' undeclared (first use in this function) drivers/net/ethernet/smsc/smc91x.c: In function 'smc_drv_probe':
drivers/net/ethernet/smsc/smc91x.c:2363:2: error: implicit declaration of function 'machine_has_neponset' [-Werror=implicit-function-declaration]

Quoted 5 lines
Quoted 3 lines

This is from building Linus' tree as of Saturday plus arm-soc.

Let's revert all this crap and start again, this time testing it better?

I'm also getting:

I have the fix in my tree still and is pending to be sent to Linus.

Please be patient.

maintainer
#8 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Wed, 18 Feb 2015 20:47:30 +0100

Quoted 23 lines

The smc91x driver tries to support multiple platforms at compile time, but they are mutually exclusive at runtime, and not clearly defined.

Trying to build for CONFIG_SA1100_ASSABET without CONFIG_ASSABET_NEPONSET results in this link error:

drivers/built-in.o: In function `smc_drv_probe':
:(.text+0x33310c): undefined reference to `neponset_ncr_frob'

since the neponset_ncr_set function is not defined otherwise.

Similarly, building for both CONFIG_SA1100_ASSABET and CONFIG_SA1100_PLEB results in a different build error:

smsc/smc91x.c: In function 'smc_drv_probe':
smsc/smc91x.c:2299:2: error: implicit declaration of function 'neponset_ncr_set' [-Werror=implicit-function-declaration]
neponset_ncr_set(NCR_ENET_OSC_EN);
^
smsc/smc91x.c:2299:19: error: 'NCR_ENET_OSC_EN' undeclared (first use in this function)

  neponset_ncr_set(NCR_ENET_OSC_EN);
                   ^
Quoted 6 lines

This is an attempt to fix the call site responsible for both errors, making sure we call the function exactly when the driver is actually trying to run on the assabet/neponset machine. With this patch, I no longer see randconfig build errors in this file.

I know this isn't the desired long term solution to this problem, but it's the most minimal risk-free fix for these build failures.

Thus, I've applied this, thanks.