Skip to contentSkip to conversation

net: sgi: ioc3-eth: two changes for the IOC3 on SGI IP35 machines

PATCH New Imre Kaloz 1 participant 3 messages Nov 28

Subsystems (4)
lore
Share & tools
lore

Imre Kaloz

author
#0 lore raw

v3 cover net: sgi: ioc3-eth: two changes for the IOC3 on SGI IP35 machines

These two changes prepare ioc3-eth for the IOC3 of the SGI Fuel, which sits behind an XBridge and has no MAC PROM. They were part of the IP35 support series, which hands the IOC3 window addresses; its next version attaches the MAC property. Neither side has a build dependency on the other.

v2 was tested on an SGI Fuel with the IP35 support, where the address comes only from the property, so the new order in patch 2 is not exercised there.

---
Changes in v3:
- Patch 1: message only; it now says that window DMA takes its attributes and RX barrier from Device(x), where no in-tree code sets them, and why ERBAR stays 0.
- Patch 2 reads the device property before the 1-wire PROM, and its message names the board.

v2: https://lore.kernel.org/r/[email protected]

Imre Kaloz (2):
net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses
net: sgi: ioc3-eth: take the MAC address from a device property

 drivers/net/ethernet/sgi/ioc3-eth.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

base-commit: f89726ffabef1b08c52e6163b7ab94b0d5f15503

Signature · 1 line
2.47.3
author
#1 lore raw

PATCH v3 1/2 net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses

A Bridge 32-bit direct window address carries no target widget, so DMA attributes OR-ed onto it aim it at widget 0. IP27 and IP30 only hand the IOC3 64-bit direct addresses; IP35 will hand it window addresses.

DMA through the window takes its attributes and barrier only from the slot's Device(x) register, where no in-tree code sets them. ERBAR stays 0 for a window address, as its upper bits would make the last RX store a widget 0 address.

---
 drivers/net/ethernet/sgi/ioc3-eth.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +21 -3
index ee284a4f75ff..8ea6a54d6da3 100644
@@ -152,19 +152,37 @@ static inline int ioc3_alloc_skb(struct ioc3_private *ip, struct sk_buff **skb,
 }
 
 #ifdef CONFIG_PCI_XTALK_BRIDGE
+/* A Bridge 64-bit direct-mapped DMA address carries the target widget in
+ * bits 63:60 and the DMA attributes below it.  An address in the 32-bit
+ * direct window carries neither, so attributes OR-ed onto one form a
+ * 64-bit address aimed at widget 0.
+ */
 static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
 {
+	if (!(addr & PCI64_ATTR_TARG_MASK))
+		return addr;
+
 	return (addr & ~PCI64_ATTR_BAR) | attr;
 }
 
-#define ERBAR_VAL	(ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT)
+/* The RX barrier's upper address bits follow the same form. */
+static inline u32 ioc3_erbar(dma_addr_t addr)
+{
+	if (!(addr & PCI64_ATTR_TARG_MASK))
+		return 0;
+
+	return ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT;
+}
 #else
 static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
 {
 	return addr;
 }
 
-#define ERBAR_VAL	0
+static inline u32 ioc3_erbar(dma_addr_t addr)
+{
+	return 0;
+}
 #endif
 
 static int ioc3eth_nvmem_match(struct device *dev, const void *data)
@@ -727,7 +745,7 @@ static void ioc3_init(struct net_device *dev)
 	readl(&regs->emcr);
 
 	/* Misc registers  */
-	writel(ERBAR_VAL, &regs->erbar);
+	writel(ioc3_erbar(ip->rxr_dma), &regs->erbar);
 	readl(&regs->etcdc);			/* Clear on read */
 	writel(15, &regs->ercsr);		/* RX low watermark  */
 	writel(0, &regs->ertr);			/* Interrupt immediately */
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH v3 2/2 net: sgi: ioc3-eth: take the MAC address from a device property

In reply to Imre Kaloz

The system-board IOC3 of the SGI Fuel has no MAC PROM on its 1-wire bus, so an ioc3-eth probe there would defer forever. The Fuel and the Origin 300 take the address from the L1 controller. Take it from a device property, for platforms that describe the address that way.

Read the property first, so a board with both does not depend on when the 1-wire bus is enumerated.

---
 drivers/net/ethernet/sgi/ioc3-eth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +3 -2
index 8ea6a54d6da3..a3e6f511d43d 100644
@@ -857,8 +857,9 @@ static int ioc3eth_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Invalid resource\n");
 		return -EINVAL;
 	}
-	/* get mac addr from one wire prom */
-	if (ioc3eth_get_mac_addr(regs, mac_addr))
+	/* get mac addr from a device property, or from one wire prom */
+	if (device_get_mac_address(&pdev->dev, mac_addr) &&
+	    ioc3eth_get_mac_addr(regs, mac_addr))
 		return -EPROBE_DEFER; /* not available yet */
 
 	dev = alloc_etherdev(sizeof(struct ioc3_private));
Signature · 1 line
2.47.3