All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cassini: Use local-mac-address prom property for Cassini
@ 2011-01-06  0:17 Richard Mortimer
  2011-01-06  0:39 ` Julian Calaby
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Mortimer @ 2011-01-06  0:17 UTC (permalink / raw)
  To: sparclinux

Fallback on the local-mac-address prom property if the Cassini device
does not have an address programmed in the VPD ROM. This uses the same
technique as implemented by the sungem driver.

The problem was reported by Frans van Berckel using Debian kernel 2.6.34-7
on Sun Fire V440. udev was assigning a new eth<n> device name on each reboot
because the cassini driver was using a random MAC address.

Fix tested on 2.6.34-7/Sun Fire V440. Compile tested only against 2.6.36
davem/sparc-2.6.git because Sun Fire V440 does not currently boot recent
kernels so runtime test is not possible at present.

Reported-by: Frans van Berckel <fberckel@xs4all.nl>
Tested-by: Frans van Berckel <fberckel@xs4all.nl>
Signed-off-by: Richard Mortimer <richm@oldelvet.org.uk>
---
 drivers/net/cassini.c |   20 ++++++++++++++++++++
 drivers/net/cassini.h |    3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index d6b6d6a..4541e3f 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -82,6 +82,10 @@
 #include <linux/highmem.h>
 #include <linux/list.h>
 #include <linux/dma-mapping.h>
+#if defined(CONFIG_SPARC)
+#include <linux/of.h>
+#include <linux/of_device.h>
+#endif
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -3203,6 +3207,10 @@ static int cas_get_vpd_info(struct cas *cp, unsigned char *dev_addr,
 	int phy_type = CAS_PHY_MII_MDIO0; /* default phy type */
 	int mac_off  = 0;
 
+#if defined(CONFIG_SPARC)
+	const unsigned char *addr;
+#endif
+
 	/* give us access to the PROM */
 	writel(BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_PAD,
 	       cp->regs + REG_BIM_LOCAL_DEV_EN);
@@ -3350,6 +3358,14 @@ use_random_mac_addr:
 	if (found & VPD_FOUND_MAC)
 		goto done;
 
+#if defined(CONFIG_SPARC)
+	addr = of_get_property(cp->of_node, "local-mac-address", NULL);
+	if (addr != NULL) {
+		memcpy(dev_addr, addr, 6);
+		goto done;
+	}
+#endif
+
 	/* Sun MAC prefix then 3 random bytes. */
 	pr_info("MAC address not found in ROM VPD\n");
 	dev_addr[0] = 0x08;
@@ -5019,6 +5035,10 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
 	cp->msg_enable = (cassini_debug < 0) ? CAS_DEF_MSG_ENABLE :
 	  cassini_debug;
 
+#if defined(CONFIG_SPARC)
+	cp->of_node = pci_device_to_OF_node(pdev);
+#endif
+
 	cp->link_transition = LINK_TRANSITION_UNKNOWN;
 	cp->link_transition_jiffies_valid = 0;
 
diff --git a/drivers/net/cassini.h b/drivers/net/cassini.h
index dbc4787..34d46fa 100644
--- a/drivers/net/cassini.h
+++ b/drivers/net/cassini.h
@@ -2868,6 +2868,9 @@ struct cas {
 	dma_addr_t block_dvma, tx_tiny_dvma[N_TX_RINGS];
 	struct pci_dev *pdev;
 	struct net_device *dev;
+#if defined(CONFIG_SPARC)
+	struct device_node	*of_node;
+#endif
 
 	/* Firmware Info */
 	u16			fw_load_addr;
-- 
1.4.4.4




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

* Re: [PATCH] cassini: Use local-mac-address prom property for Cassini
  2011-01-06  0:17 [PATCH] cassini: Use local-mac-address prom property for Cassini Richard Mortimer
@ 2011-01-06  0:39 ` Julian Calaby
  2011-01-06  9:27 ` Richard Mortimer
  2011-01-06 13:41 ` [PATCH] cassini: Use local-mac-address prom property for Frans van Berckel
  2 siblings, 0 replies; 4+ messages in thread
From: Julian Calaby @ 2011-01-06  0:39 UTC (permalink / raw)
  To: sparclinux

On Thu, Jan 6, 2011 at 11:17, Richard Mortimer <richm@oldelvet.org.uk> wrote:
> Fallback on the local-mac-address prom property if the Cassini device
> does not have an address programmed in the VPD ROM. This uses the same
> technique as implemented by the sungem driver.

Should this possibly depend on CONFIG_OF instead of CONFIG_SPARC?

Thanks,

-- 

Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/

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

* Re: [PATCH] cassini: Use local-mac-address prom property for Cassini
  2011-01-06  0:17 [PATCH] cassini: Use local-mac-address prom property for Cassini Richard Mortimer
  2011-01-06  0:39 ` Julian Calaby
@ 2011-01-06  9:27 ` Richard Mortimer
  2011-01-06 13:41 ` [PATCH] cassini: Use local-mac-address prom property for Frans van Berckel
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Mortimer @ 2011-01-06  9:27 UTC (permalink / raw)
  To: sparclinux


On 06/01/2011 00:39, Julian Calaby wrote:
> On Thu, Jan 6, 2011 at 11:17, Richard Mortimer<richm@oldelvet.org.uk>  wrote:
>> Fallback on the local-mac-address prom property if the Cassini device
>> does not have an address programmed in the VPD ROM. This uses the same
>> technique as implemented by the sungem driver.
>
> Should this possibly depend on CONFIG_OF instead of CONFIG_SPARC?
>

Hi Julian,

Thanks for the tip. I'll cook a version up using CONFIG_OF later today.

Regards

Richard

> Thanks,
>

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

* Re: [PATCH] cassini: Use local-mac-address prom property for
  2011-01-06  0:17 [PATCH] cassini: Use local-mac-address prom property for Cassini Richard Mortimer
  2011-01-06  0:39 ` Julian Calaby
  2011-01-06  9:27 ` Richard Mortimer
@ 2011-01-06 13:41 ` Frans van Berckel
  2 siblings, 0 replies; 4+ messages in thread
From: Frans van Berckel @ 2011-01-06 13:41 UTC (permalink / raw)
  To: sparclinux

On Thu, 2011-01-06 at 00:17 +0000, Richard Mortimer wrote:
> Fallback on the local-mac-address prom property if the Cassini device
> does not have an address programmed in the VPD ROM. This uses the same
> technique as implemented by the sungem driver.
> 
> The problem was reported by Frans van Berckel using Debian kernel 2.6.34-7
> on Sun Fire V440. udev was assigning a new eth<n> device name on each reboot
> because the cassini driver was using a random MAC address.
> 
> Fix tested on 2.6.34-7/Sun Fire V440. Compile tested only against 2.6.36
> davem/sparc-2.6.git because Sun Fire V440 does not currently boot recent
> kernels so runtime test is not possible at present.
> 
> Reported-by: Frans van Berckel <fberckel@xs4all.nl>
> Tested-by: Frans van Berckel <fberckel@xs4all.nl>
> Signed-off-by: Richard Mortimer <richm@oldelvet.org.uk>

Good news. I did a 2.6.37 release build today with this patch. It's boot
tested now and goes the same as it did in 2.6.34-7. Being happy.


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

end of thread, other threads:[~2011-01-06 13:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06  0:17 [PATCH] cassini: Use local-mac-address prom property for Cassini Richard Mortimer
2011-01-06  0:39 ` Julian Calaby
2011-01-06  9:27 ` Richard Mortimer
2011-01-06 13:41 ` [PATCH] cassini: Use local-mac-address prom property for Frans van Berckel

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.