[PATCH 1/1] net: usb: asix_devices: add .reset_resume for USB PM

2017-01-03 Thread Peter Chen
The USB core may call reset_resume when it fails to resume asix device.
And USB core can recovery this abnormal resume at low level driver,
the same .resume at asix driver can work too. Add .reset_resume can
avoid disconnecting after backing from system resume, and NFS can
still be mounted after this commit.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/usb/asix_devices.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 6c646e2..6e98ede 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -1367,6 +1367,7 @@ static struct usb_driver asix_driver = {
.probe =usbnet_probe,
.suspend =  asix_suspend,
.resume =   asix_resume,
+   .reset_resume = asix_resume,
.disconnect =   usbnet_disconnect,
.supports_autosuspend = 1,
.disable_hub_initiated_lpm = 1,
-- 
2.7.4



RE: [PATCH] net: arc_emac: add missing of_node_put() in arc_emac_probe()

2016-08-04 Thread Peter Chen
 
>
>Signed-off-by: Wei Yongjun <weiyj...@gmail.com>
>---
> drivers/net/ethernet/arc/emac_main.c | 6 --
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/arc/emac_main.c
>b/drivers/net/ethernet/arc/emac_main.c
>index 4bff0f3..b0da969 100644
>--- a/drivers/net/ethernet/arc/emac_main.c
>+++ b/drivers/net/ethernet/arc/emac_main.c
>@@ -771,8 +771,10 @@ int arc_emac_probe(struct net_device *ndev, int interface)
>   priv->dev = dev;
>
>   priv->regs = devm_ioremap_resource(dev, _regs);
>-  if (IS_ERR(priv->regs))
>-  return PTR_ERR(priv->regs);
>+  if (IS_ERR(priv->regs)) {
>+  err = PTR_ERR(priv->regs);
>+  goto out_put_node;
>+  }
>
>   dev_dbg(dev, "Registers base address is 0x%p\n", priv->regs);

Thanks, I missed that error path.

Reviewed-by: Peter Chen <peter.c...@nxp.com>

Peter


RE: [PATCH 14/15] ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
 
>
>>Hi,
>>
>>On 07/27/2016 04:20 AM, Peter Chen wrote:
>>> of_node_put needs to be called when the device node which is got from
>>> of_parse_phandle has finished using.
>>>
>>> Signed-off-by: Peter Chen <peter.c...@nxp.com>
>>> ---
>>>   drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 -
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> index f7dfc0a..8d88782 100644
>>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>>> @@ -113,8 +113,10 @@ static struct stmmac_axi
>>> *stmmac_axi_setup(struct
>>platform_device *pdev)
>>> return NULL;
>>>
>>> axi = kzalloc(sizeof(*axi), GFP_KERNEL);
>>> -   if (!axi)
>>> +   if (!axi) {
>>> +   of_node_put(np);
>>> return ERR_PTR(-ENOMEM);
>>> +   }
>>>
>>> axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
>>> axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); @@
>>> -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>>platform_device *pdev)
>>> of_property_read_u32(np, "snps,wr_osr_lmt", >axi_wr_osr_lmt);
>>> of_property_read_u32(np, "snps,rd_osr_lmt", >axi_rd_osr_lmt);
>>> of_property_read_u32_array(np, "snps,blen", axi->axi_blen,
>>> AXI_BLEN);
>>> +   of_node_put(np);
>>>
>>> return axi;
>>>   }
>>>
>>
>>I agree with the modification inside stmmac_axi. I just have a question
>>about np =
>>pdev->dev.of_node inside stmmac_probe_config_dt (same file).
>>We could add a "of_node_put(np)" just before "return plat" ?
>>
>
>Yes, you remind me there is still one node need to be put (should be 
>plat->phy_node),
>except for changing node name at error path, how about calling 
>of_node_put(plat-
>>phy_node) at stmmac_release after phy is disconnected?
>

Since the plat->phy_node will be used during the whole life cycle, I put it at
stmmac_dvr_remove at my v2 patch set.

Best regards,
Peter


[PATCH v2 03/15] ethernet: arc: emac_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/arc/emac_main.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_main.c 
b/drivers/net/ethernet/arc/emac_main.c
index 586beda..4bff0f3 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -749,14 +749,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = of_address_to_resource(dev->of_node, 0, _regs);
if (err) {
dev_err(dev, "failed to retrieve registers base from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
/* Get IRQ from device tree */
irq = irq_of_parse_and_map(dev->of_node, 0);
if (!irq) {
dev_err(dev, "failed to retrieve  value from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
ndev->netdev_ops = _emac_netdev_ops;
@@ -778,7 +780,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = clk_prepare_enable(priv->clk);
if (err) {
dev_err(dev, "failed to enable clock\n");
-   return err;
+   goto out_put_node;
}
 
clock_frequency = clk_get_rate(priv->clk);
@@ -787,7 +789,8 @@ int arc_emac_probe(struct net_device *ndev, int interface)
if (of_property_read_u32(dev->of_node, "clock-frequency",
 _frequency)) {
dev_err(dev, "failed to retrieve  from 
device tree\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto out_put_node;
}
}
 
@@ -867,6 +870,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
goto out_netif_api;
}
 
+   of_node_put(phy_node);
return 0;
 
 out_netif_api:
@@ -877,6 +881,9 @@ out_mdio:
 out_clken:
if (priv->clk)
clk_disable_unprepare(priv->clk);
+out_put_node:
+   of_node_put(phy_node);
+
return err;
 }
 EXPORT_SYMBOL_GPL(arc_emac_probe);
-- 
1.9.1



[PATCH v2 07/15] ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 2ef4277..afb5daa 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -51,7 +51,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
const char *mode_str;
struct regmap *syscon;
struct resource *res;
-   struct device_node *np = dsaf_dev->dev->of_node;
+   struct device_node *np = dsaf_dev->dev->of_node, *np_temp;
struct platform_device *pdev = to_platform_device(dsaf_dev->dev);
 
if (dev_of_node(dsaf_dev->dev)) {
@@ -102,8 +102,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
dsaf_dev->dsaf_tc_mode = HRD_DSAF_4TC_MODE;
 
if (dev_of_node(dsaf_dev->dev)) {
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(np, "subctrl-syscon", 0));
+   np_temp = of_parse_phandle(np, "subctrl-syscon", 0);
+   syscon = syscon_node_to_regmap(np_temp);
+   of_node_put(np_temp);
if (IS_ERR_OR_NULL(syscon)) {
res = platform_get_resource(pdev, IORESOURCE_MEM,
res_idx++);
-- 
1.9.1



[PATCH v2 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/ti/davinci_emac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c 
b/drivers/net/ethernet/ti/davinci_emac.c
index c6c5465..45ab9d4 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -2060,6 +2060,7 @@ static int davinci_emac_remove(struct platform_device 
*pdev)
cpdma_ctlr_destroy(priv->dma);
 
unregister_netdev(ndev);
+   of_node_put(priv->phy_node);
pm_runtime_disable(>dev);
free_netdev(ndev);
 
-- 
1.9.1



[PATCH v2 13/15] ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index edd20c3..bec6963 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -135,7 +135,9 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
 
np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
if (np_splitter) {
-   if (of_address_to_resource(np_splitter, 0, _splitter)) {
+   ret = of_address_to_resource(np_splitter, 0, _splitter);
+   of_node_put(np_splitter);
+   if (ret) {
dev_info(dev, "Missing emac splitter address\n");
return -EINVAL;
}
@@ -159,14 +161,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: missing emac splitter 
address\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->splitter_base =
devm_ioremap_resource(dev, _splitter);
 
-   if (IS_ERR(dwmac->splitter_base))
-   return PTR_ERR(dwmac->splitter_base);
+   if (IS_ERR(dwmac->splitter_base)) {
+   ret = PTR_ERR(dwmac->splitter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -178,14 +183,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping adapter\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.sgmii_adapter_base =
devm_ioremap_resource(dev, _sgmii_adapter);
 
-   if (IS_ERR(dwmac->pcs.sgmii_adapter_base))
-   return PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
+   ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -197,22 +205,30 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping tse control 
port\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.tse_pcs_base =
devm_ioremap_resource(dev, _tse_pcs);
 
-   if (IS_ERR(dwmac->pcs.tse_pcs_base))
-   return PTR_ERR(dwmac->pcs.tse_pcs_base);
+   if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
+   ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
+   goto err_node_put;
+   }
}
}
dwmac->reg_offset = reg_offset;
dwmac->reg_shift = reg_shift;
dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
dwmac->dev = dev;
+   of_node_put(np_sgmii_adapter);
 
return 0;
+
+err_node_put:
+   of_node_put(np_sgmii_adapter);
+   return ret;
 }
 
 static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
-- 
1.9.1



[PATCH v2 12/15] ethernet: renesas: sh_eth: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c 
b/drivers/net/ethernet/renesas/sh_eth.c
index 7bd910c..799d58d 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1780,6 +1780,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
sh_eth_adjust_link, 0,
mdp->phy_interface);
 
+   of_node_put(pn);
if (!phydev)
phydev = ERR_PTR(-ENOENT);
} else {
-- 
1.9.1



[PATCH v2 09/15] ethernet: marvell: mvpp2: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 0b04717..60227a3 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -6234,6 +6234,7 @@ err_free_stats:
 err_free_irq:
irq_dispose_mapping(port->irq);
 err_free_netdev:
+   of_node_put(phy_node);
free_netdev(dev);
return err;
 }
@@ -6244,6 +6245,7 @@ static void mvpp2_port_remove(struct mvpp2_port *port)
int i;
 
unregister_netdev(port->dev);
+   of_node_put(port->phy_node);
free_percpu(port->pcpu);
free_percpu(port->stats);
for (i = 0; i < txq_number; i++)
-- 
1.9.1



[PATCH v2 10/15] ethernet: marvell: pxa168_eth: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c 
b/drivers/net/ethernet/marvell/pxa168_eth.c
index aeeb2e7..5d5000c 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1506,6 +1506,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
}
of_property_read_u32(np, "reg", >phy_addr);
pep->phy_intf = of_get_phy_mode(pdev->dev.of_node);
+   of_node_put(np);
}
 
/* Hardware supports only 3 ports */
-- 
1.9.1



[PATCH v2 11/15] ethernet: renesas: ravb_main: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 8377d02..1e1cc0f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1005,6 +1005,7 @@ static int ravb_phy_init(struct net_device *ndev)
}
phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0,
priv->phy_interface);
+   of_node_put(pn);
if (!phydev) {
netdev_err(ndev, "failed to connect PHY\n");
return -ENOENT;
-- 
1.9.1



[PATCH v2 14/15] ethernet: stmicro: stmmac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

This commit fixes both local (in stmmac_axi_setup) and global
(plat->phy_node) device_node for this issue, and using the
correct device node when tries to put node at stmmac_probe_config_dt
for error path.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c23ccab..4c8c60a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3397,6 +3397,7 @@ int stmmac_dvr_remove(struct device *dev)
stmmac_set_mac(priv->ioaddr, false);
netif_carrier_off(ndev);
unregister_netdev(ndev);
+   of_node_put(priv->plat->phy_node);
if (priv->stmmac_rst)
reset_control_assert(priv->stmmac_rst);
clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..756bb54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
return NULL;
 
axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-   if (!axi)
+   if (!axi) {
+   of_node_put(np);
return ERR_PTR(-ENOMEM);
+   }
 
axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
of_property_read_u32(np, "snps,wr_osr_lmt", >axi_wr_osr_lmt);
of_property_read_u32(np, "snps,rd_osr_lmt", >axi_rd_osr_lmt);
of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+   of_node_put(np);
 
return axi;
 }
@@ -302,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const 
char **mac)
dma_cfg = devm_kzalloc(>dev, sizeof(*dma_cfg),
   GFP_KERNEL);
if (!dma_cfg) {
-   of_node_put(np);
+   of_node_put(plat->phy_node);
return ERR_PTR(-ENOMEM);
}
plat->dma_cfg = dma_cfg;
-- 
1.9.1



[PATCH v2 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 3fb87e2..5c8afe1 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -795,6 +795,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
mac_cb->mac_id, np->name);
}
+   of_node_put(np);
 
return 0;
}
@@ -812,10 +813,12 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
mac_cb->mac_id, np->name);
}
+   of_node_put(np);
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
+   np = of_parse_phandle(to_of_node(mac_cb->fw_port),
+   "serdes-syscon", 0);
+   syscon = syscon_node_to_regmap(np);
+   of_node_put(np);
if (IS_ERR_OR_NULL(syscon)) {
dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
return -EINVAL;
-- 
1.9.1



[PATCH v2 04/15] ethernet: aurora: nb8800: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/aurora/nb8800.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/aurora/nb8800.c 
b/drivers/net/ethernet/aurora/nb8800.c
index 0d4ea92..b047fd6 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -1504,6 +1504,7 @@ static int nb8800_probe(struct platform_device *pdev)
 err_free_dma:
nb8800_dma_free(dev);
 err_free_bus:
+   of_node_put(priv->phy_node);
mdiobus_unregister(bus);
 err_disable_clk:
clk_disable_unprepare(priv->clk);
@@ -1519,6 +1520,7 @@ static int nb8800_remove(struct platform_device *pdev)
struct nb8800_priv *priv = netdev_priv(ndev);
 
unregister_netdev(ndev);
+   of_node_put(priv->phy_node);
 
mdiobus_unregister(priv->mii_bus);
 
-- 
1.9.1



[PATCH v2 00/15] add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
Hi David,

This patch set fixes missing of_node_put issue at ethernet driver.
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

The compilation test has passed by using allmodconfig for drivers/net/ethernet.

Thanks.

Changes for v2:
- If the device node is local variable, it can be put in the same function.
- If the device node will be used the whole driver life cycle,
  it should be put (call of_node_put) at driver's remove. 
  Patch [4, 5, 9, 14, 15/15]
- Fix the issue that the node still be used at error patch [6/15]
- Add acked for patch [11,12/15]

Peter Chen (15):
  ethernet: altera: add missing of_node_put
  ethernet: apm: xgene: add missing of_node_put after calling
of_parse_phandle
  ethernet: arc: emac_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: aurora: nb8800: add missing of_node_put after calling
of_parse_phandle
  ethernet: cavium: octeon: add missing of_node_put after calling
of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after
calling of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after
calling of_parse_phandle
  ethernet: marvell: mvneta: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: mvpp2: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: pxa168_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: ravb_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: sh_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put
after calling of_parse_phandle
  ethernet: stmicro: stmmac: add missing of_node_put after calling
of_parse_phandle
  ethernet: ti: davinci_emac: add missing of_node_put after calling
of_parse_phandle

 drivers/net/ethernet/altera/altera_tse_main.c  |  1 +
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c |  1 +
 drivers/net/ethernet/arc/emac_main.c   | 15 ++---
 drivers/net/ethernet/aurora/nb8800.c   |  2 ++
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c   |  3 ++
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  9 --
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |  7 +++--
 drivers/net/ethernet/marvell/mvneta.c  |  1 +
 drivers/net/ethernet/marvell/mvpp2.c   |  2 ++
 drivers/net/ethernet/marvell/pxa168_eth.c  |  1 +
 drivers/net/ethernet/renesas/ravb_main.c   |  1 +
 drivers/net/ethernet/renesas/sh_eth.c  |  1 +
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  7 +++--
 drivers/net/ethernet/ti/davinci_emac.c |  1 +
 16 files changed, 67 insertions(+), 22 deletions(-)

-- 
1.9.1



[PATCH v2 05/15] ethernet: cavium: octeon: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c 
b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index e8bc15b..4ab404f 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -1513,6 +1513,7 @@ static int octeon_mgmt_probe(struct platform_device *pdev)
return 0;
 
 err:
+   of_node_put(p->phy_np);
free_netdev(netdev);
return result;
 }
@@ -1520,8 +1521,10 @@ err:
 static int octeon_mgmt_remove(struct platform_device *pdev)
 {
struct net_device *netdev = platform_get_drvdata(pdev);
+   struct octeon_mgmt *p = netdev_priv(netdev);
 
unregister_netdev(netdev);
+   of_node_put(p->phy_np);
free_netdev(netdev);
return 0;
 }
-- 
1.9.1



[PATCH v2 01/15] ethernet: altera: add missing of_node_put

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle (or of_node_get) has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c 
b/drivers/net/ethernet/altera/altera_tse_main.c
index 49025e9..bda31f3 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -815,6 +815,7 @@ static int init_phy(struct net_device *dev)
phydev = of_phy_connect(dev, phynode,
_tse_adjust_link, 0, priv->phy_iface);
}
+   of_node_put(phynode);
 
if (!phydev) {
netdev_err(dev, "Could not find the PHY\n");
-- 
1.9.1



[PATCH v2 02/15] ethernet: apm: xgene: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 2f5638f..fb23408 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -758,6 +758,7 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
 
phy_dev = of_phy_connect(ndev, phy_np, _enet_adjust_link,
 0, pdata->phy_mode);
+   of_node_put(phy_np);
if (!phy_dev) {
netdev_err(ndev, "Could not connect to PHY\n");
return -ENODEV;
-- 
1.9.1



[PATCH v2 08/15] ethernet: marvell: mvneta: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f92018b..d41c28d 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4118,6 +4118,7 @@ static int mvneta_probe(struct platform_device *pdev)
pp->bm_priv = NULL;
}
}
+   of_node_put(bm_node);
 
err = mvneta_init(>dev, pp);
if (err < 0)
-- 
1.9.1



RE: [PATCH 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-08-01 Thread Peter Chen
 
>>
>>> On Wednesday 27 July 2016 07:50 AM, Peter Chen wrote:
>>>> of_node_put needs to be called when the device node which is got
>>>> from of_parse_phandle has finished using.
>>>>
>>>> Signed-off-by: Peter Chen <peter.c...@nxp.com>
>>>> ---
>>>>  drivers/net/ethernet/ti/davinci_emac.c | 1 +
>>>>  1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/net/ethernet/ti/davinci_emac.c
>>>> b/drivers/net/ethernet/ti/davinci_emac.c
>>>> index c6c5465..d8cb9d0 100644
>>>> --- a/drivers/net/ethernet/ti/davinci_emac.c
>>>> +++ b/drivers/net/ethernet/ti/davinci_emac.c
>>>> @@ -1571,6 +1571,7 @@ static int emac_dev_open(struct net_device *ndev)
>>>>if (priv->phy_node) {
>>>>phydev = of_phy_connect(ndev, priv->phy_node,
>>>>_adjust_link, 0, 0);
>>>> +  of_node_put(priv->phy_node);
>>>>if (!phydev) {
>>>>dev_err(emac_dev, "could not connect to phy %s\n",
>>>>priv->phy_node->full_name);
>>>>
>>>
>>> phy_node is accessed in case of of_phy_connect() returns error, so it
>>> has to be moved after the dev_err log
>>>
>>
>> Yeah, you are right. I will change it, thanks.
>>
>
>I see one more problem, when you stop and open the interface there is no way 
>to get
>the phy_node and interface will be unusable, so of_node_put() should be moved 
>to
>remove()
>

It is my careless. Like I replied to David I did not know the phy_node would be 
used
in whole driver's life cycle. I will change it, thanks.

Peter


RE: [PATCH 04/15] ethernet: aurora: nb8800: add missing of_node_put after calling of_parse_phandle

2016-07-31 Thread Peter Chen
 
>> diff --git a/drivers/net/ethernet/aurora/nb8800.c
>> b/drivers/net/ethernet/aurora/nb8800.c
>> index 0d4ea92..d15d96b 100644
>> --- a/drivers/net/ethernet/aurora/nb8800.c
>> +++ b/drivers/net/ethernet/aurora/nb8800.c
>> @@ -1006,6 +1006,7 @@ static int nb8800_stop(struct net_device *dev)
>>
>>  netif_stop_queue(dev);
>>  napi_disable(>napi);
>> +of_node_put(priv->phy_node);
>>
>>  nb8800_dma_stop(dev);
>>  nb8800_mac_rx(dev, false);
>
>This is broken.  The priv->phy_node reference is taken in the probe function,
>therefore you have to drop that reference in the "remove" function not the 
>"stop"
>function.
>
>I'm just looking over basic details of this patch series, and along with some 
>other
>feedback you've received, it looks like you really didn't put a lot of 
>auditing into the
>changes you are making.
>
>Please go over this series one more time and resubmit the entire thing after
>everything is sorted out and double-checked.
>

Thanks for your comments, David. I do not familiar with Ethernet driver, and 
thought
if the node is used up, it can be freed like other drivers. But for phy_node, 
it will be
used in whole driver's life cycle, it is my careless. I will review each patch 
in this series
again.

Best regards,
Peter


RE: [PATCH 14/15] ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put after calling of_parse_phandle

2016-07-28 Thread Peter Chen
 
>Hi,
>
>On 07/27/2016 04:20 AM, Peter Chen wrote:
>> of_node_put needs to be called when the device node which is got from
>> of_parse_phandle has finished using.
>>
>> Signed-off-by: Peter Chen <peter.c...@nxp.com>
>> ---
>>   drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 -
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> index f7dfc0a..8d88782 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> @@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>platform_device *pdev)
>>  return NULL;
>>
>>  axi = kzalloc(sizeof(*axi), GFP_KERNEL);
>> -if (!axi)
>> +if (!axi) {
>> +of_node_put(np);
>>  return ERR_PTR(-ENOMEM);
>> +}
>>
>>  axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
>>  axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); @@
>> -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct
>platform_device *pdev)
>>  of_property_read_u32(np, "snps,wr_osr_lmt", >axi_wr_osr_lmt);
>>  of_property_read_u32(np, "snps,rd_osr_lmt", >axi_rd_osr_lmt);
>>  of_property_read_u32_array(np, "snps,blen", axi->axi_blen,
>> AXI_BLEN);
>> +of_node_put(np);
>>
>>  return axi;
>>   }
>>
>
>I agree with the modification inside stmmac_axi. I just have a question about 
>np =
>pdev->dev.of_node inside stmmac_probe_config_dt (same file).
>We could add a "of_node_put(np)" just before "return plat" ?
>

Yes, you remind me there is still one node need to be put (should be 
plat->phy_node),
except for changing node name at error path, how about calling 
of_node_put(plat->phy_node) at
stmmac_release after phy is disconnected?

Peter


RE: [PATCH 05/15] ethernet: cavium: octeon: add missing of_node_put after calling of_parse_phandle

2016-07-28 Thread Peter Chen
 
>
>> ---
>>   drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
>> b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
>> index e8bc15b..5eb9d8c 100644
>> --- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
>> +++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
>> @@ -960,6 +960,7 @@ static int octeon_mgmt_init_phy(struct net_device 
>> *netdev)
>>  phydev = of_phy_connect(netdev, p->phy_np,
>>  octeon_mgmt_adjust_link, 0,
>>  PHY_INTERFACE_MODE_MII);
>> +of_node_put(p->phy_np);
>
>I don't think you can do this here.  octeon_mgmt_init_phy() may be called 
>multiple
>times in the life of the driver, so p->phy_np must remain valid.
>
>It may be appropriate to do the  of_node_put() in the
>octeon_mgmt_remove() function.
 
Thanks, I will change it.

Peter



RE: [PATCH 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after calling of_parse_phandle

2016-07-28 Thread Peter Chen
 
>在 2016/7/27 10:20, Peter Chen 写道:
>> of_node_put needs to be called when the device node which is got from
>> of_parse_phandle has finished using.
>>
>> Signed-off-by: Peter Chen <peter.c...@nxp.com>
>> ---
>>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> index 3fb87e2..18d72ea 100644
>> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
>> @@ -786,6 +786,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
>>  np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",
>>mac_cb->mac_id);
>>  mac_cb->phy_dev = of_phy_find_device(np);
>> +of_node_put(np);
>>  if (mac_cb->phy_dev) {
>>  /* refcount is held by of_phy_find_device()
>>   * if the phy_dev is found
>
>np is accessed in case of of_phy_find_device() returns a no null value, so it 
>has to be
>moved after the dev_dbg log.
>
>> @@ -804,6 +805,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
>>  np = of_parse_phandle(to_of_node(mac_cb->fw_port),
>>"phy-handle", 0);
>>  mac_cb->phy_dev = of_phy_find_device(np);
>> +of_node_put(np);
>>  if (mac_cb->phy_dev) {
>>  /* refcount is held by of_phy_find_device()
>>   * if the phy_dev is found
>
>np is accessed in case of of_phy_find_device() returns a no null value, so it 
>has to be
>moved after the dev_dbg log.
>

Thanks, I will change them.

Peter



RE: [PATCH 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-07-27 Thread Peter Chen
 
>On Wednesday 27 July 2016 07:50 AM, Peter Chen wrote:
>> of_node_put needs to be called when the device node which is got from
>> of_parse_phandle has finished using.
>>
>> Signed-off-by: Peter Chen <peter.c...@nxp.com>
>> ---
>>  drivers/net/ethernet/ti/davinci_emac.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/ethernet/ti/davinci_emac.c
>> b/drivers/net/ethernet/ti/davinci_emac.c
>> index c6c5465..d8cb9d0 100644
>> --- a/drivers/net/ethernet/ti/davinci_emac.c
>> +++ b/drivers/net/ethernet/ti/davinci_emac.c
>> @@ -1571,6 +1571,7 @@ static int emac_dev_open(struct net_device *ndev)
>>  if (priv->phy_node) {
>>  phydev = of_phy_connect(ndev, priv->phy_node,
>>  _adjust_link, 0, 0);
>> +of_node_put(priv->phy_node);
>>  if (!phydev) {
>>  dev_err(emac_dev, "could not connect to phy %s\n",
>>  priv->phy_node->full_name);
>>
>
>phy_node is accessed in case of of_phy_connect() returns error, so it has to be
>moved after the dev_err log
>

Yeah, you are right. I will change it, thanks.

Peter


[PATCH 14/15] ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..8d88782 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
return NULL;
 
axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-   if (!axi)
+   if (!axi) {
+   of_node_put(np);
return ERR_PTR(-ENOMEM);
+   }
 
axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct 
platform_device *pdev)
of_property_read_u32(np, "snps,wr_osr_lmt", >axi_wr_osr_lmt);
of_property_read_u32(np, "snps,rd_osr_lmt", >axi_rd_osr_lmt);
of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+   of_node_put(np);
 
return axi;
 }
-- 
1.9.1



[PATCH 15/15] ethernet: ti: davinci_emac: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/ti/davinci_emac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c 
b/drivers/net/ethernet/ti/davinci_emac.c
index c6c5465..d8cb9d0 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1571,6 +1571,7 @@ static int emac_dev_open(struct net_device *ndev)
if (priv->phy_node) {
phydev = of_phy_connect(ndev, priv->phy_node,
_adjust_link, 0, 0);
+   of_node_put(priv->phy_node);
if (!phydev) {
dev_err(emac_dev, "could not connect to phy %s\n",
priv->phy_node->full_name);
-- 
1.9.1



[PATCH 12/15] ethernet: renesas: sh_eth: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/renesas/sh_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c 
b/drivers/net/ethernet/renesas/sh_eth.c
index 7bd910c..799d58d 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1780,6 +1780,7 @@ static int sh_eth_phy_init(struct net_device *ndev)
sh_eth_adjust_link, 0,
mdp->phy_interface);
 
+   of_node_put(pn);
if (!phydev)
phydev = ERR_PTR(-ENOENT);
} else {
-- 
1.9.1



[PATCH 09/15] ethernet: marvell: mvpp2: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 0b04717..a86f22b 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5531,6 +5531,7 @@ static int mvpp2_phy_connect(struct mvpp2_port *port)
 
phy_dev = of_phy_connect(port->dev, port->phy_node, mvpp2_link_event, 0,
 port->phy_interface);
+   of_node_put(port->phy_node);
if (!phy_dev) {
netdev_err(port->dev, "cannot connect to phy\n");
return -ENODEV;
@@ -6234,6 +6235,7 @@ err_free_stats:
 err_free_irq:
irq_dispose_mapping(port->irq);
 err_free_netdev:
+   of_node_put(phy_node);
free_netdev(dev);
return err;
 }
-- 
1.9.1



[PATCH 13/15] ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index edd20c3..bec6963 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -135,7 +135,9 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
 
np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
if (np_splitter) {
-   if (of_address_to_resource(np_splitter, 0, _splitter)) {
+   ret = of_address_to_resource(np_splitter, 0, _splitter);
+   of_node_put(np_splitter);
+   if (ret) {
dev_info(dev, "Missing emac splitter address\n");
return -EINVAL;
}
@@ -159,14 +161,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: missing emac splitter 
address\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->splitter_base =
devm_ioremap_resource(dev, _splitter);
 
-   if (IS_ERR(dwmac->splitter_base))
-   return PTR_ERR(dwmac->splitter_base);
+   if (IS_ERR(dwmac->splitter_base)) {
+   ret = PTR_ERR(dwmac->splitter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -178,14 +183,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping adapter\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.sgmii_adapter_base =
devm_ioremap_resource(dev, _sgmii_adapter);
 
-   if (IS_ERR(dwmac->pcs.sgmii_adapter_base))
-   return PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
+   ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+   goto err_node_put;
+   }
}
 
index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -197,22 +205,30 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac 
*dwmac, struct device *
dev_err(dev,
"%s: ERROR: failed mapping tse control 
port\n",
__func__);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto err_node_put;
}
 
dwmac->pcs.tse_pcs_base =
devm_ioremap_resource(dev, _tse_pcs);
 
-   if (IS_ERR(dwmac->pcs.tse_pcs_base))
-   return PTR_ERR(dwmac->pcs.tse_pcs_base);
+   if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
+   ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
+   goto err_node_put;
+   }
}
}
dwmac->reg_offset = reg_offset;
dwmac->reg_shift = reg_shift;
dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
dwmac->dev = dev;
+   of_node_put(np_sgmii_adapter);
 
return 0;
+
+err_node_put:
+   of_node_put(np_sgmii_adapter);
+   return ret;
 }
 
 static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
-- 
1.9.1



[PATCH 08/15] ethernet: marvell: mvneta: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f92018b..16aca9d 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -4113,6 +4113,7 @@ static int mvneta_probe(struct platform_device *pdev)
if (bm_node && bm_node->data) {
pp->bm_priv = bm_node->data;
err = mvneta_bm_port_init(pdev, pp);
+   of_node_put(bm_node);
if (err < 0) {
dev_info(>dev, "use SW buffer management\n");
pp->bm_priv = NULL;
-- 
1.9.1



[PATCH 11/15] ethernet: renesas: ravb_main: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/renesas/ravb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 8377d02..1e1cc0f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1005,6 +1005,7 @@ static int ravb_phy_init(struct net_device *ndev)
}
phydev = of_phy_connect(ndev, pn, ravb_adjust_link, 0,
priv->phy_interface);
+   of_node_put(pn);
if (!phydev) {
netdev_err(ndev, "failed to connect PHY\n");
return -ENOENT;
-- 
1.9.1



[PATCH 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 3fb87e2..18d72ea 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -786,6 +786,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",
  mac_cb->mac_id);
mac_cb->phy_dev = of_phy_find_device(np);
+   of_node_put(np);
if (mac_cb->phy_dev) {
/* refcount is held by of_phy_find_device()
 * if the phy_dev is found
@@ -804,6 +805,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
np = of_parse_phandle(to_of_node(mac_cb->fw_port),
  "phy-handle", 0);
mac_cb->phy_dev = of_phy_find_device(np);
+   of_node_put(np);
if (mac_cb->phy_dev) {
/* refcount is held by of_phy_find_device()
 * if the phy_dev is found
@@ -813,9 +815,10 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
mac_cb->mac_id, np->name);
}
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
+   np = of_parse_phandle(to_of_node(mac_cb->fw_port),
+   "serdes-syscon", 0);
+   syscon = syscon_node_to_regmap(np);
+   of_node_put(np);
if (IS_ERR_OR_NULL(syscon)) {
dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
return -EINVAL;
-- 
1.9.1



[PATCH 07/15] ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 2ef4277..afb5daa 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -51,7 +51,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
const char *mode_str;
struct regmap *syscon;
struct resource *res;
-   struct device_node *np = dsaf_dev->dev->of_node;
+   struct device_node *np = dsaf_dev->dev->of_node, *np_temp;
struct platform_device *pdev = to_platform_device(dsaf_dev->dev);
 
if (dev_of_node(dsaf_dev->dev)) {
@@ -102,8 +102,9 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
dsaf_dev->dsaf_tc_mode = HRD_DSAF_4TC_MODE;
 
if (dev_of_node(dsaf_dev->dev)) {
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(np, "subctrl-syscon", 0));
+   np_temp = of_parse_phandle(np, "subctrl-syscon", 0);
+   syscon = syscon_node_to_regmap(np_temp);
+   of_node_put(np_temp);
if (IS_ERR_OR_NULL(syscon)) {
res = platform_get_resource(pdev, IORESOURCE_MEM,
res_idx++);
-- 
1.9.1



[PATCH 10/15] ethernet: marvell: pxa168_eth: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c 
b/drivers/net/ethernet/marvell/pxa168_eth.c
index aeeb2e7..5d5000c 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1506,6 +1506,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
}
of_property_read_u32(np, "reg", >phy_addr);
pep->phy_intf = of_get_phy_mode(pdev->dev.of_node);
+   of_node_put(np);
}
 
/* Hardware supports only 3 ports */
-- 
1.9.1



[PATCH 04/15] ethernet: aurora: nb8800: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/aurora/nb8800.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/aurora/nb8800.c 
b/drivers/net/ethernet/aurora/nb8800.c
index 0d4ea92..d15d96b 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -1006,6 +1006,7 @@ static int nb8800_stop(struct net_device *dev)
 
netif_stop_queue(dev);
napi_disable(>napi);
+   of_node_put(priv->phy_node);
 
nb8800_dma_stop(dev);
nb8800_mac_rx(dev, false);
@@ -1504,6 +1505,7 @@ static int nb8800_probe(struct platform_device *pdev)
 err_free_dma:
nb8800_dma_free(dev);
 err_free_bus:
+   of_node_put(priv->phy_node);
mdiobus_unregister(bus);
 err_disable_clk:
clk_disable_unprepare(priv->clk);
-- 
1.9.1



[PATCH 05/15] ethernet: cavium: octeon: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c 
b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index e8bc15b..5eb9d8c 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -960,6 +960,7 @@ static int octeon_mgmt_init_phy(struct net_device *netdev)
phydev = of_phy_connect(netdev, p->phy_np,
octeon_mgmt_adjust_link, 0,
PHY_INTERFACE_MODE_MII);
+   of_node_put(p->phy_np);
 
if (!phydev)
return -ENODEV;
-- 
1.9.1



[PATCH 03/15] ethernet: arc: emac_main: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/arc/emac_main.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_main.c 
b/drivers/net/ethernet/arc/emac_main.c
index 586beda..0e6331c 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -749,14 +749,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = of_address_to_resource(dev->of_node, 0, _regs);
if (err) {
dev_err(dev, "failed to retrieve registers base from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
/* Get IRQ from device tree */
irq = irq_of_parse_and_map(dev->of_node, 0);
if (!irq) {
dev_err(dev, "failed to retrieve  value from device 
tree\n");
-   return -ENODEV;
+   err = -ENODEV;
+   goto out_put_node;
}
 
ndev->netdev_ops = _emac_netdev_ops;
@@ -778,7 +780,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
err = clk_prepare_enable(priv->clk);
if (err) {
dev_err(dev, "failed to enable clock\n");
-   return err;
+   goto out_put_node;
}
 
clock_frequency = clk_get_rate(priv->clk);
@@ -787,7 +789,8 @@ int arc_emac_probe(struct net_device *ndev, int interface)
if (of_property_read_u32(dev->of_node, "clock-frequency",
 _frequency)) {
dev_err(dev, "failed to retrieve  from 
device tree\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto out_put_node;
}
}
 
@@ -877,6 +880,9 @@ out_mdio:
 out_clken:
if (priv->clk)
clk_disable_unprepare(priv->clk);
+out_put_node:
+   of_node_put(phy_node);
+
return err;
 }
 EXPORT_SYMBOL_GPL(arc_emac_probe);
-- 
1.9.1



[PATCH 01/15] ethernet: altera: add missing of_node_put

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle (or of_node_get) has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c 
b/drivers/net/ethernet/altera/altera_tse_main.c
index 49025e9..bda31f3 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -815,6 +815,7 @@ static int init_phy(struct net_device *dev)
phydev = of_phy_connect(dev, phynode,
_tse_adjust_link, 0, priv->phy_iface);
}
+   of_node_put(phynode);
 
if (!phydev) {
netdev_err(dev, "Could not find the PHY\n");
-- 
1.9.1



[PATCH 02/15] ethernet: apm: xgene: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
---
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 2f5638f..fb23408 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -758,6 +758,7 @@ static int xgene_enet_phy_connect(struct net_device *ndev)
 
phy_dev = of_phy_connect(ndev, phy_np, _enet_adjust_link,
 0, pdata->phy_mode);
+   of_node_put(phy_np);
if (!phy_dev) {
netdev_err(ndev, "Could not connect to PHY\n");
return -ENODEV;
-- 
1.9.1



[PATCH 00/15] ethernet: add missing of_node_put after calling of_parse_phandle

2016-07-26 Thread Peter Chen
Hi David,

This patch set fixes missing of_node_put issue at ethernet driver.
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Thanks.

Peter Chen (15):
  ethernet: altera: add missing of_node_put
  ethernet: apm: xgene: add missing of_node_put after calling
of_parse_phandle
  ethernet: arc: emac_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: aurora: nb8800: add missing of_node_put after calling
of_parse_phandle
  ethernet: cavium: octeon: add missing of_node_put after calling
of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_mac: add missing of_node_put after
calling of_parse_phandle
  ethernet: hisilicon: hns: hns_dsaf_main: add missing of_node_put after
calling of_parse_phandle
  ethernet: marvell: mvneta: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: mvpp2: add missing of_node_put after calling
of_parse_phandle
  ethernet: marvell: pxa168_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: ravb_main: add missing of_node_put after calling
of_parse_phandle
  ethernet: renesas: sh_eth: add missing of_node_put after calling
of_parse_phandle
  ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put
after calling of_parse_phandle
  ethernet: stmicro: stmmac: stmmac_platform: add missing of_node_put
after calling of_parse_phandle
  ethernet: ti: davinci_emac: add missing of_node_put after calling
of_parse_phandle

 drivers/net/ethernet/altera/altera_tse_main.c  |  1 +
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c |  1 +
 drivers/net/ethernet/arc/emac_main.c   | 14 ++---
 drivers/net/ethernet/aurora/nb8800.c   |  2 ++
 drivers/net/ethernet/cavium/octeon/octeon_mgmt.c   |  1 +
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  |  9 --
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |  7 +++--
 drivers/net/ethernet/marvell/mvneta.c  |  1 +
 drivers/net/ethernet/marvell/mvpp2.c   |  2 ++
 drivers/net/ethernet/marvell/pxa168_eth.c  |  1 +
 drivers/net/ethernet/renesas/ravb_main.c   |  1 +
 drivers/net/ethernet/renesas/sh_eth.c  |  1 +
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c| 36 --
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  5 ++-
 drivers/net/ethernet/ti/davinci_emac.c |  1 +
 15 files changed, 62 insertions(+), 21 deletions(-)

-- 
1.9.1



Getting IP address and port of a file descriptor

2016-07-18 Thread Peter Chen
Hi,

   I was wondering, if I was in the kernel, and I intercepted a system
call such as read(). Would I be able, from the fd, determine the
whether the fd is (1) a network socket? (2) the IP address and port of
this socket? What are the kernel data structures and functions that
can get these information for me in the kernel? Thanks.

Peter


[PATCH 1/1] Revert net: fec: Ensure clocks are enabled while using mdio bus

2015-08-14 Thread Peter Chen
It causes the i.mx6sx sdb board hang when using nfsroot during boots
up at v4.2-rc6.

This reverts commit 8fff755e9f8d0f70a595e79f248695ce6aef5cc3.

Cc: netdev@vger.kernel.org
Cc: Fugang Duan b38...@freescale.com
Cc: shawn@linaro.org
Cc: fabio.este...@freescale.com
Cc: tyler.ba...@linaro.org
Cc: Lucas Stach l.st...@pengutronix.de
Cc: Andrew Lunn and...@lunn.ch
Signed-off-by: Peter Chen peter.c...@freescale.com
---

According to Fugang Duan, the i.mx series has different clock control
sequence among SoCs, this patch may only consider certain SoCs.

 drivers/net/ethernet/freescale/fec_main.c | 89 +--
 1 file changed, 13 insertions(+), 76 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index 32e3807c..5e8b837 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -24,7 +24,6 @@
 #include linux/module.h
 #include linux/kernel.h
 #include linux/string.h
-#include linux/pm_runtime.h
 #include linux/ptrace.h
 #include linux/errno.h
 #include linux/ioport.h
@@ -78,7 +77,6 @@ static void fec_enet_itr_coal_init(struct net_device *ndev);
 #define FEC_ENET_RAEM_V0x8
 #define FEC_ENET_RAFL_V0x8
 #define FEC_ENET_OPD_V 0xFFF0
-#define FEC_MDIO_PM_TIMEOUT  100 /* ms */
 
 static struct platform_device_id fec_devtype[] = {
{
@@ -1769,13 +1767,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
 static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 {
struct fec_enet_private *fep = bus-priv;
-   struct device *dev = fep-pdev-dev;
unsigned long time_left;
-   int ret = 0;
-
-   ret = pm_runtime_get_sync(dev);
-   if (IS_ERR_VALUE(ret))
-   return ret;
 
fep-mii_timeout = 0;
init_completion(fep-mdio_done);
@@ -1791,30 +1783,18 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int 
mii_id, int regnum)
if (time_left == 0) {
fep-mii_timeout = 1;
netdev_err(fep-netdev, MDIO read timeout\n);
-   ret = -ETIMEDOUT;
-   goto out;
+   return -ETIMEDOUT;
}
 
-   ret = FEC_MMFR_DATA(readl(fep-hwp + FEC_MII_DATA));
-
-out:
-   pm_runtime_mark_last_busy(dev);
-   pm_runtime_put_autosuspend(dev);
-
-   return ret;
+   /* return value */
+   return FEC_MMFR_DATA(readl(fep-hwp + FEC_MII_DATA));
 }
 
 static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
   u16 value)
 {
struct fec_enet_private *fep = bus-priv;
-   struct device *dev = fep-pdev-dev;
unsigned long time_left;
-   int ret = 0;
-
-   ret = pm_runtime_get_sync(dev);
-   if (IS_ERR_VALUE(ret))
-   return ret;
 
fep-mii_timeout = 0;
init_completion(fep-mdio_done);
@@ -1831,13 +1811,10 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int 
mii_id, int regnum,
if (time_left == 0) {
fep-mii_timeout = 1;
netdev_err(fep-netdev, MDIO write timeout\n);
-   ret  = -ETIMEDOUT;
+   return -ETIMEDOUT;
}
 
-   pm_runtime_mark_last_busy(dev);
-   pm_runtime_put_autosuspend(dev);
-
-   return ret;
+   return 0;
 }
 
 static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
@@ -1849,6 +1826,9 @@ static int fec_enet_clk_enable(struct net_device *ndev, 
bool enable)
ret = clk_prepare_enable(fep-clk_ahb);
if (ret)
return ret;
+   ret = clk_prepare_enable(fep-clk_ipg);
+   if (ret)
+   goto failed_clk_ipg;
if (fep-clk_enet_out) {
ret = clk_prepare_enable(fep-clk_enet_out);
if (ret)
@@ -1872,6 +1852,7 @@ static int fec_enet_clk_enable(struct net_device *ndev, 
bool enable)
}
} else {
clk_disable_unprepare(fep-clk_ahb);
+   clk_disable_unprepare(fep-clk_ipg);
if (fep-clk_enet_out)
clk_disable_unprepare(fep-clk_enet_out);
if (fep-clk_ptp) {
@@ -1893,6 +1874,8 @@ failed_clk_ptp:
if (fep-clk_enet_out)
clk_disable_unprepare(fep-clk_enet_out);
 failed_clk_enet_out:
+   clk_disable_unprepare(fep-clk_ipg);
+failed_clk_ipg:
clk_disable_unprepare(fep-clk_ahb);
 
return ret;
@@ -2864,14 +2847,10 @@ fec_enet_open(struct net_device *ndev)
struct fec_enet_private *fep = netdev_priv(ndev);
int ret;
 
-   ret = pm_runtime_get_sync(fep-pdev-dev);
-   if (IS_ERR_VALUE(ret))
-   return ret;
-
pinctrl_pm_select_default_state(fep-pdev-dev);
ret = fec_enet_clk_enable(ndev, true);
if (ret)
-   goto clk_enable;
+   return ret

RE: [PATCH 1/1] Revert net: fec: Ensure clocks are enabled while using mdio bus

2015-08-14 Thread Peter Chen
 
 
 Am Freitag, den 14.08.2015, 13:47 +0800 schrieb Peter Chen:
  It causes the i.mx6sx sdb board hang when using nfsroot during boots
  up at v4.2-rc6.
 
  This reverts commit 8fff755e9f8d0f70a595e79f248695ce6aef5cc3.
 
  Cc: netdev@vger.kernel.org
  Cc: Fugang Duan b38...@freescale.com
  Cc: shawn@linaro.org
  Cc: fabio.este...@freescale.com
  Cc: tyler.ba...@linaro.org
  Cc: Lucas Stach l.st...@pengutronix.de
  Cc: Andrew Lunn and...@lunn.ch
  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
 
  According to Fugang Duan, the i.mx series has different clock control
  sequence among SoCs, this patch may only consider certain SoCs.
 
 Sorry, but NACK.
 
 Please test current mainline (what will become v4.2-rc7). There is already a
 patch in that fixes i.MX27 and probably fixes the same problem on i.MX6SX.
 

Would you help point to me which commit and at which tree?

Peter

   drivers/net/ethernet/freescale/fec_main.c | 89
  +--
   1 file changed, 13 insertions(+), 76 deletions(-)
 
  diff --git a/drivers/net/ethernet/freescale/fec_main.c
  b/drivers/net/ethernet/freescale/fec_main.c
  index 32e3807c..5e8b837 100644
  --- a/drivers/net/ethernet/freescale/fec_main.c
  +++ b/drivers/net/ethernet/freescale/fec_main.c
  @@ -24,7 +24,6 @@
   #include linux/module.h
   #include linux/kernel.h
   #include linux/string.h
  -#include linux/pm_runtime.h
   #include linux/ptrace.h
   #include linux/errno.h
   #include linux/ioport.h
  @@ -78,7 +77,6 @@ static void fec_enet_itr_coal_init(struct net_device
 *ndev);
   #define FEC_ENET_RAEM_V0x8
   #define FEC_ENET_RAFL_V0x8
   #define FEC_ENET_OPD_V 0xFFF0
  -#define FEC_MDIO_PM_TIMEOUT  100 /* ms */
 
   static struct platform_device_id fec_devtype[] = {
  {
  @@ -1769,13 +1767,7 @@ static void fec_enet_adjust_link(struct
  net_device *ndev)  static int fec_enet_mdio_read(struct mii_bus *bus,
  int mii_id, int regnum)  {
  struct fec_enet_private *fep = bus-priv;
  -   struct device *dev = fep-pdev-dev;
  unsigned long time_left;
  -   int ret = 0;
  -
  -   ret = pm_runtime_get_sync(dev);
  -   if (IS_ERR_VALUE(ret))
  -   return ret;
 
  fep-mii_timeout = 0;
  init_completion(fep-mdio_done);
  @@ -1791,30 +1783,18 @@ static int fec_enet_mdio_read(struct mii_bus
 *bus, int mii_id, int regnum)
  if (time_left == 0) {
  fep-mii_timeout = 1;
  netdev_err(fep-netdev, MDIO read timeout\n);
  -   ret = -ETIMEDOUT;
  -   goto out;
  +   return -ETIMEDOUT;
  }
 
  -   ret = FEC_MMFR_DATA(readl(fep-hwp + FEC_MII_DATA));
  -
  -out:
  -   pm_runtime_mark_last_busy(dev);
  -   pm_runtime_put_autosuspend(dev);
  -
  -   return ret;
  +   /* return value */
  +   return FEC_MMFR_DATA(readl(fep-hwp + FEC_MII_DATA));
   }
 
   static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 u16 value)
   {
  struct fec_enet_private *fep = bus-priv;
  -   struct device *dev = fep-pdev-dev;
  unsigned long time_left;
  -   int ret = 0;
  -
  -   ret = pm_runtime_get_sync(dev);
  -   if (IS_ERR_VALUE(ret))
  -   return ret;
 
  fep-mii_timeout = 0;
  init_completion(fep-mdio_done);
  @@ -1831,13 +1811,10 @@ static int fec_enet_mdio_write(struct mii_bus
 *bus, int mii_id, int regnum,
  if (time_left == 0) {
  fep-mii_timeout = 1;
  netdev_err(fep-netdev, MDIO write timeout\n);
  -   ret  = -ETIMEDOUT;
  +   return -ETIMEDOUT;
  }
 
  -   pm_runtime_mark_last_busy(dev);
  -   pm_runtime_put_autosuspend(dev);
  -
  -   return ret;
  +   return 0;
   }
 
   static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
  @@ -1849,6 +1826,9 @@ static int fec_enet_clk_enable(struct net_device
 *ndev, bool enable)
  ret = clk_prepare_enable(fep-clk_ahb);
  if (ret)
  return ret;
  +   ret = clk_prepare_enable(fep-clk_ipg);
  +   if (ret)
  +   goto failed_clk_ipg;
  if (fep-clk_enet_out) {
  ret = clk_prepare_enable(fep-clk_enet_out);
  if (ret)
  @@ -1872,6 +1852,7 @@ static int fec_enet_clk_enable(struct net_device
 *ndev, bool enable)
  }
  } else {
  clk_disable_unprepare(fep-clk_ahb);
  +   clk_disable_unprepare(fep-clk_ipg);
  if (fep-clk_enet_out)
  clk_disable_unprepare(fep-clk_enet_out);
  if (fep-clk_ptp) {
  @@ -1893,6 +1874,8 @@ failed_clk_ptp:
  if (fep-clk_enet_out)
  clk_disable_unprepare(fep-clk_enet_out);
   failed_clk_enet_out:
  +   clk_disable_unprepare(fep-clk_ipg);
  +failed_clk_ipg:
  clk_disable_unprepare(fep-clk_ahb);
 
  return ret;
  @@ -2864,14 +2847,10 @@ fec_enet_open(struct net_device *ndev)
  struct fec_enet_private *fep = netdev_priv(ndev);
  int ret

Re: [PATCH 1/1] Revert net: fec: Ensure clocks are enabled while using mdio bus

2015-08-14 Thread Peter Chen
On Fri, Aug 14, 2015 at 10:27:33AM +0200, Lucas Stach wrote:
 Am Freitag, den 14.08.2015, 08:25 + schrieb Peter Chen:
   
   
   Am Freitag, den 14.08.2015, 13:47 +0800 schrieb Peter Chen:
It causes the i.mx6sx sdb board hang when using nfsroot during boots
up at v4.2-rc6.
   
This reverts commit 8fff755e9f8d0f70a595e79f248695ce6aef5cc3.
   
Cc: netdev@vger.kernel.org
Cc: Fugang Duan b38...@freescale.com
Cc: shawn@linaro.org
Cc: fabio.este...@freescale.com
Cc: tyler.ba...@linaro.org
Cc: Lucas Stach l.st...@pengutronix.de
Cc: Andrew Lunn and...@lunn.ch
Signed-off-by: Peter Chen peter.c...@freescale.com
---
   
According to Fugang Duan, the i.mx series has different clock control
sequence among SoCs, this patch may only consider certain SoCs.
   
   Sorry, but NACK.
   
   Please test current mainline (what will become v4.2-rc7). There is 
   already a
   patch in that fixes i.MX27 and probably fixes the same problem on i.MX6SX.
   
  
  Would you help point to me which commit and at which tree?
  
 Mainline, so Linus Torvalds tree.
 
 http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=14d2b7c1a96ef37eb571599c73d4a1a606b964d6

It fixes my imx6sx-sdb board. It is interesting that there was
no problem for some platforms, but with problem for others.
Your fix is a common runtime PM fix.

Again, why we need this as a bug-fix, not but as new feature for next
rc1?

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


A Regression between v4.2-rc2 and v4.2-rc3

2015-07-22 Thread Peter Chen
: nonblocking pool is initialized

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html