Skip to contentSkip to conversation

fsl/man: Inherit parent device and of_node

RFC PATCH In review Florian Fainelli 2 participants 2 messages Aug 19, 2017 – Aug 22, 2017

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

RFC PATCH 1/1 fsl/man: Inherit parent device and of_node

Junote Cai reported that he was not able to get a DSA setup involving the Freescale DPAA/FMAN driver to work and narrowed it down to of_find_net_device_by_node(). This function requires the network device's device reference to be correctly set which is the case here, though we have lost any device_node association there.

The problem is that dpaa_eth_add_device() allocates a "dpaa-ethernet" platform device, and later on dpaa_eth_probe() is called but SET_NETDEV_DEV() won't be propagating &pdev->dev.of_node properly. Fix this by inherenting both the parent device and the of_node when dpaa_eth_add_device() creates the platform device.

Fixes 3933961682a3 ("fsl/fman: Add FMan MAC driver")

---
Madalin,

After this patch, Junote was able to get the DSA switch probed correctly however he was also observing a resource conflict, but I don't think this patch is responsible for that per-se, please review:

iommu: Adding device ffe488000.port to group 21 fsl_mac ffe4e0000.ethernet: FMan dTSEC version: 0x08240101 fsl_mac ffe4e0000.ethernet: FMan MAC address: 00:04:9f:ef:05:01 fsl_mac dpaa-ethernet.0: __devm_request_mem_region(mac) failed
fsl_mac: probe of dpaa-ethernet.0 failed with error -16 fsl_mac dpaa-ethernet.0: __devm_request_mem_region(mac) failed
fsl_mac: probe of dpaa-ethernet.0 failed with error -16 fsl_dpa dpaa-ethernet.0 eth0: Probed interface eth0

 drivers/net/ethernet/freescale/fman/mac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fman/mac.c +2 -0
index 6e67d22fd0d5..1c7da16ad0ff 100644
@@ -623,6 +623,8 @@ static struct platform_device *dpaa_eth_add_device(int fman_id,
 		goto no_mem;
 	}
 
+	pdev->dev.of_node = node;
+	pdev->dev.parent = priv->dev;
 	set_dma_ops(&pdev->dev, get_dma_ops(priv->dev));
 
 	ret = platform_device_add_data(pdev, &data, sizeof(data));
Signature · 1 line
2.11.0
maintainer
#1 lore raw

From: Florian Fainelli <[email protected]>
Date: Fri, 18 Aug 2017 17:12:55 -0700

drivers/net/ethernet/freescale/fman/mac.c static struct platform_device *dpaa_eth_add_device(int fman_id, · line 630

Quoted 9 lines
drivers/net/ethernet/freescale/fman/mac.c +2 -0
@@ -623,6 +623,8 @@ static struct platform_device *dpaa_eth_add_device(int fman_id,
 		goto no_mem;
 	}
 
+	pdev->dev.of_node = node;
+	pdev->dev.parent = priv->dev;
 	set_dma_ops(&pdev->dev, get_dma_ops(priv->dev));
 
 	ret = platform_device_add_data(pdev, &data, sizeof(data));

I guess since we allocate and manage the platform device here, we can fumble around safely with it's device node pointer and parent.

So this should be ok.