* [PATCH 0/3] net/phy: Fixes for Cavium Thunder MDIO code. @ 2016-03-15 0:30 David Daney 2016-03-15 0:30 ` [PATCH 1/3] phy: mdio-cavium: Add missing MODULE_* annotations David Daney ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: David Daney @ 2016-03-15 0:30 UTC (permalink / raw) To: linux-arm-kernel From: David Daney <david.daney@cavium.com> Previous patch set: commit 5fc7cf179449 ("net: thunderx: Cleanup PHY probing code.") commit 1eefee901fca ("phy: mdio-octeon: Refactor into two files/modules") commit 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.") Had several problems. We try to fix them here. David Daney (3): phy: mdio-cavium: Add missing MODULE_* annotations. net: cavium: For Kconfig THUNDER_NIC_BGX, select MDIO_THUNDER. net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition. drivers/net/ethernet/cavium/Kconfig | 2 +- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 26 +++++++++++++++++------ drivers/net/phy/mdio-cavium.c | 4 ++++ 3 files changed, 25 insertions(+), 7 deletions(-) -- 1.7.11.7 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] phy: mdio-cavium: Add missing MODULE_* annotations. 2016-03-15 0:30 [PATCH 0/3] net/phy: Fixes for Cavium Thunder MDIO code David Daney @ 2016-03-15 0:30 ` David Daney 2016-03-15 0:30 ` [PATCH 2/3] net: cavium: For Kconfig THUNDER_NIC_BGX, select MDIO_THUNDER David Daney 2016-03-15 0:30 ` [PATCH 3/3] net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition David Daney 2 siblings, 0 replies; 4+ messages in thread From: David Daney @ 2016-03-15 0:30 UTC (permalink / raw) To: linux-arm-kernel From: David Daney <david.daney@cavium.com> When the code was factored out of mdio-octeon.c, the MODULE_DESCRIPTION, MODULE_AUTHOR and MODULE_LICENSE annotations were inadvertently omitted. Restore them so that we don't get kernel taint warnings upon module loading. Signed-off-by: David Daney <david.daney@cavium.com> --- drivers/net/phy/mdio-cavium.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/mdio-cavium.c b/drivers/net/phy/mdio-cavium.c index e796ee1..6df2fa7 100644 --- a/drivers/net/phy/mdio-cavium.c +++ b/drivers/net/phy/mdio-cavium.c @@ -147,3 +147,7 @@ int cavium_mdiobus_write(struct mii_bus *bus, int phy_id, int regnum, u16 val) return 0; } EXPORT_SYMBOL(cavium_mdiobus_write); + +MODULE_DESCRIPTION("Common code for OCTEON and Thunder MDIO bus drivers"); +MODULE_AUTHOR("David Daney"); +MODULE_LICENSE("GPL"); -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] net: cavium: For Kconfig THUNDER_NIC_BGX, select MDIO_THUNDER. 2016-03-15 0:30 [PATCH 0/3] net/phy: Fixes for Cavium Thunder MDIO code David Daney 2016-03-15 0:30 ` [PATCH 1/3] phy: mdio-cavium: Add missing MODULE_* annotations David Daney @ 2016-03-15 0:30 ` David Daney 2016-03-15 0:30 ` [PATCH 3/3] net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition David Daney 2 siblings, 0 replies; 4+ messages in thread From: David Daney @ 2016-03-15 0:30 UTC (permalink / raw) To: linux-arm-kernel From: David Daney <david.daney@cavium.com> Previously we selected MDIO_OCTEON, which after creating the Thunder specific MDIO bus driver is much less useful. Signed-off-by: David Daney <david.daney@cavium.com> --- drivers/net/ethernet/cavium/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig index 8fb84e6..953aa40 100644 --- a/drivers/net/ethernet/cavium/Kconfig +++ b/drivers/net/ethernet/cavium/Kconfig @@ -35,7 +35,7 @@ config THUNDER_NIC_BGX tristate "Thunder MAC interface driver (BGX)" depends on 64BIT select PHYLIB - select MDIO_OCTEON + select MDIO_THUNDER ---help--- This driver supports programming and controlling of MAC interface from NIC physical function driver. -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition. 2016-03-15 0:30 [PATCH 0/3] net/phy: Fixes for Cavium Thunder MDIO code David Daney 2016-03-15 0:30 ` [PATCH 1/3] phy: mdio-cavium: Add missing MODULE_* annotations David Daney 2016-03-15 0:30 ` [PATCH 2/3] net: cavium: For Kconfig THUNDER_NIC_BGX, select MDIO_THUNDER David Daney @ 2016-03-15 0:30 ` David Daney 2 siblings, 0 replies; 4+ messages in thread From: David Daney @ 2016-03-15 0:30 UTC (permalink / raw) To: linux-arm-kernel From: David Daney <david.daney@cavium.com> It is possible, although unlikely, that probing will find the phy_device for the first LMAC of a thunder BGX device, but then need to fail with -EPROBE_DEFER on a subsequent LMAC. In this case, we need to call put_device() on each of the phy_devices that were obtained, but will be unused due to returning -EPROBE_DEFER. Also, since we can break out of the probing loop early, we need to explicitly call of_node_put() outside of the loop. Signed-off-by: David Daney <david.daney@cavium.com> --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index feed231..9679515 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -974,17 +974,18 @@ static int bgx_init_acpi_phy(struct bgx *bgx) static int bgx_init_of_phy(struct bgx *bgx) { struct fwnode_handle *fwn; + struct device_node *node = NULL; u8 lmac = 0; - const char *mac; device_for_each_child_node(&bgx->pdev->dev, fwn) { struct phy_device *pd; struct device_node *phy_np; - struct device_node *node = to_of_node(fwn); + const char *mac; /* Should always be an OF node. But if it is not, we * cannot handle it, so exit the loop. */ + node = to_of_node(fwn); if (!node) break; @@ -1005,17 +1006,30 @@ static int bgx_init_of_phy(struct bgx *bgx) /* Wait until the phy drivers are available */ pd = of_phy_find_device(phy_np); if (!pd) - return -EPROBE_DEFER; + goto defer; bgx->lmac[lmac].phydev = pd; } lmac++; - if (lmac == MAX_LMAC_PER_BGX) { - of_node_put(node); + if (lmac == MAX_LMAC_PER_BGX) break; - } } + of_node_put(node); return 0; + +defer: + /* We are bailing out, try not to leak device reference counts + * for phy devices we may have already found. + */ + while (lmac) { + if (bgx->lmac[lmac].phydev) { + put_device(&bgx->lmac[lmac].phydev->mdio.dev); + bgx->lmac[lmac].phydev = NULL; + } + lmac--; + } + of_node_put(node); + return -EPROBE_DEFER; } #else -- 1.7.11.7 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-15 0:30 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-15 0:30 [PATCH 0/3] net/phy: Fixes for Cavium Thunder MDIO code David Daney 2016-03-15 0:30 ` [PATCH 1/3] phy: mdio-cavium: Add missing MODULE_* annotations David Daney 2016-03-15 0:30 ` [PATCH 2/3] net: cavium: For Kconfig THUNDER_NIC_BGX, select MDIO_THUNDER David Daney 2016-03-15 0:30 ` [PATCH 3/3] net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition David Daney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).