Re: [RESEND PATCH net 07/10] net: ethernet: mediatek: fix issue of driver removal with interface is up

2016-08-25 Thread Sean Wang
Date: Thu, 25 Aug 2016 15:35:34 +0200, John Crispin wrote:
>On 25/08/2016 12:44, Sean Wang wrote:
>> 1) mtk_stop() must be called to stop for freeing DMA resources
>> acquired and restoring state changed by mtk_open() when module
>> removal.
>> 
>> 2) group clock disabled related function into mtk_hw_deinit which
>> could be reused with others functionality such as the whole ethernet
>> reset that would be posted in the later series of patches.
>> 
>
>Hi Sean,
>
>these are 2 unrelated changes so they really need to go into two
>separate patches. i also think that change 1) would better fit into the
>future series making use of that functionality.
>
>   John
>

okay. splitting makes sense more

I will leave 1) here 
and move 2) into the better place that is one part of the future series 
about whole ethernet reset, I will post them after the current series is done

thanks for your effort on reviewing

>> Signed-off-by: Sean Wang 
>> ---
>>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 ++
>>  1 file changed, 18 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
>> b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> index 0a4c782..c573475 100644
>> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
>> @@ -1478,6 +1478,16 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
>>  return 0;
>>  }
>>  
>> +static int mtk_hw_deinit(struct mtk_eth *eth)
>> +{
>> +clk_disable_unprepare(eth->clk_esw);
>> +clk_disable_unprepare(eth->clk_gp1);
>> +clk_disable_unprepare(eth->clk_gp2);
>> +clk_disable_unprepare(eth->clk_ethif);
>> +
>> +return 0;
>> +}
>> +
>>  static int __init mtk_init(struct net_device *dev)
>>  {
>>  struct mtk_mac *mac = netdev_priv(dev);
>> @@ -1919,11 +1929,15 @@ err_free_dev:
>>  static int mtk_remove(struct platform_device *pdev)
>>  {
>>  struct mtk_eth *eth = platform_get_drvdata(pdev);
>> +int i;
>>  
>> -clk_disable_unprepare(eth->clk_ethif);
>> -clk_disable_unprepare(eth->clk_esw);
>> -clk_disable_unprepare(eth->clk_gp1);
>> -clk_disable_unprepare(eth->clk_gp2);
>> +/* stop all devices to make sure that dma is properly shut down */
>> +for (i = 0; i < MTK_MAC_COUNT; i++) {
>> +if (!eth->netdev[i])
>> +continue;
>> +mtk_stop(eth->netdev[i]);
>> +}
>> +mtk_hw_deinit(eth);
>>  
>>  netif_napi_del(>tx_napi);
>>  netif_napi_del(>rx_napi);
>> 


Re: [RESEND PATCH net 07/10] net: ethernet: mediatek: fix issue of driver removal with interface is up

2016-08-25 Thread John Crispin


On 25/08/2016 12:44, Sean Wang wrote:
> 1) mtk_stop() must be called to stop for freeing DMA resources
> acquired and restoring state changed by mtk_open() when module
> removal.
> 
> 2) group clock disabled related function into mtk_hw_deinit which
> could be reused with others functionality such as the whole ethernet
> reset that would be posted in the later series of patches.
> 

Hi Sean,

these are 2 unrelated changes so they really need to go into two
separate patches. i also think that change 1) would better fit into the
future series making use of that functionality.

John

> Signed-off-by: Sean Wang 
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 ++
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
> b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 0a4c782..c573475 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -1478,6 +1478,16 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
>   return 0;
>  }
>  
> +static int mtk_hw_deinit(struct mtk_eth *eth)
> +{
> + clk_disable_unprepare(eth->clk_esw);
> + clk_disable_unprepare(eth->clk_gp1);
> + clk_disable_unprepare(eth->clk_gp2);
> + clk_disable_unprepare(eth->clk_ethif);
> +
> + return 0;
> +}
> +
>  static int __init mtk_init(struct net_device *dev)
>  {
>   struct mtk_mac *mac = netdev_priv(dev);
> @@ -1919,11 +1929,15 @@ err_free_dev:
>  static int mtk_remove(struct platform_device *pdev)
>  {
>   struct mtk_eth *eth = platform_get_drvdata(pdev);
> + int i;
>  
> - clk_disable_unprepare(eth->clk_ethif);
> - clk_disable_unprepare(eth->clk_esw);
> - clk_disable_unprepare(eth->clk_gp1);
> - clk_disable_unprepare(eth->clk_gp2);
> + /* stop all devices to make sure that dma is properly shut down */
> + for (i = 0; i < MTK_MAC_COUNT; i++) {
> + if (!eth->netdev[i])
> + continue;
> + mtk_stop(eth->netdev[i]);
> + }
> + mtk_hw_deinit(eth);
>  
>   netif_napi_del(>tx_napi);
>   netif_napi_del(>rx_napi);
> 


[RESEND PATCH net 07/10] net: ethernet: mediatek: fix issue of driver removal with interface is up

2016-08-25 Thread Sean Wang
1) mtk_stop() must be called to stop for freeing DMA resources
acquired and restoring state changed by mtk_open() when module
removal.

2) group clock disabled related function into mtk_hw_deinit which
could be reused with others functionality such as the whole ethernet
reset that would be posted in the later series of patches.

Signed-off-by: Sean Wang 
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 0a4c782..c573475 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1478,6 +1478,16 @@ static int __init mtk_hw_init(struct mtk_eth *eth)
return 0;
 }
 
+static int mtk_hw_deinit(struct mtk_eth *eth)
+{
+   clk_disable_unprepare(eth->clk_esw);
+   clk_disable_unprepare(eth->clk_gp1);
+   clk_disable_unprepare(eth->clk_gp2);
+   clk_disable_unprepare(eth->clk_ethif);
+
+   return 0;
+}
+
 static int __init mtk_init(struct net_device *dev)
 {
struct mtk_mac *mac = netdev_priv(dev);
@@ -1919,11 +1929,15 @@ err_free_dev:
 static int mtk_remove(struct platform_device *pdev)
 {
struct mtk_eth *eth = platform_get_drvdata(pdev);
+   int i;
 
-   clk_disable_unprepare(eth->clk_ethif);
-   clk_disable_unprepare(eth->clk_esw);
-   clk_disable_unprepare(eth->clk_gp1);
-   clk_disable_unprepare(eth->clk_gp2);
+   /* stop all devices to make sure that dma is properly shut down */
+   for (i = 0; i < MTK_MAC_COUNT; i++) {
+   if (!eth->netdev[i])
+   continue;
+   mtk_stop(eth->netdev[i]);
+   }
+   mtk_hw_deinit(eth);
 
netif_napi_del(>tx_napi);
netif_napi_del(>rx_napi);
-- 
1.9.1