{"id":810507,"url":"http://patchwork.ozlabs.org/api/patches/810507/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/CE371C1263339941885964188A0225FA333370@CHN-SV-EXMX03.mchp-main.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<CE371C1263339941885964188A0225FA333370@CHN-SV-EXMX03.mchp-main.com>","list_archive_url":null,"date":"2017-09-06T10:51:31","name":"[net,1/4] lan78xx: Fix for crash associated with System suspend","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"cefa33eff35a4294b88ce0e28be182aede051edb","submitter":{"id":71648,"url":"http://patchwork.ozlabs.org/api/people/71648/?format=json","name":"Nisar Sayed","email":"Nisar.Sayed@microchip.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/CE371C1263339941885964188A0225FA333370@CHN-SV-EXMX03.mchp-main.com/mbox/","series":[{"id":1761,"url":"http://patchwork.ozlabs.org/api/series/1761/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=1761","date":"2017-09-06T10:49:39","name":"lan78xx: Fixes and Enhancements to lan78xx driver","version":1,"mbox":"http://patchwork.ozlabs.org/series/1761/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810507/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810507/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xnL5L0CQ5z9s3T\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed,  6 Sep 2017 20:52:38 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753266AbdIFKwf convert rfc822-to-8bit (ORCPT\n\t<rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 6 Sep 2017 06:52:35 -0400","from esa5.microchip.iphmx.com ([216.71.150.166]:65533 \"EHLO\n\tesa5.microchip.iphmx.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1753117AbdIFKwP (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 6 Sep 2017 06:52:15 -0400","from exsmtp03.microchip.com (HELO email.microchip.com)\n\t([198.175.253.49])\n\tby esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA;\n\t06 Sep 2017 03:51:33 -0700","from CHN-SV-EXMX03.mchp-main.com ([fe80::58f5:b949:4b1:3df4]) by\n\tchn-sv-exch03.mchp-main.com ([fe80::9916:1afa:df82:7a64%13]) with\n\tmapi id 14.03.0352.000; Wed, 6 Sep 2017 03:51:31 -0700"],"X-IronPort-AV":"E=Sophos;i=\"5.41,483,1498546800\"; d=\"scan'208\";a=\"4457353\"","From":"<Nisar.Sayed@microchip.com>","To":"<davem@davemloft.net>, <UNGLinuxDriver@microchip.com>","CC":"<netdev@vger.kernel.org>","Subject":"[PATCH net 1/4] lan78xx: Fix for crash associated with System\n\tsuspend","Thread-Topic":"[PATCH net 1/4] lan78xx: Fix for crash associated with System\n\tsuspend","Thread-Index":"AdMm/FT/4xwnv4GdSm2C6fB/QqdHjg==","Date":"Wed, 6 Sep 2017 10:51:31 +0000","Message-ID":"<CE371C1263339941885964188A0225FA333370@CHN-SV-EXMX03.mchp-main.com>","Accept-Language":"en-US","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","x-originating-ip":"[10.10.215.90]","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"8BIT","MIME-Version":"1.0","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Nisar Sayed <Nisar.Sayed@microchip.com>\n\nFix for crash associated with System suspend\n\nSince ndo_stop removes phydev which makes phydev NULL.\nWhenever system suspend is initiated or after \"ifconfig <interface> down\",\nif set_wol or get_wol is triggered phydev is NULL leads system crash.\nHence phy_start/phy_stop for ndo_start/ndo_stop fixes the issues\ninstead of adding/removing phydevice\n\nSigned-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>\n---\n drivers/net/usb/lan78xx.c | 44 ++++++++++++++++++++++++++++----------------\n 1 file changed, 28 insertions(+), 16 deletions(-)","diff":"diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c\nindex b99a7fb..955ab3b 100644\n--- a/drivers/net/usb/lan78xx.c\n+++ b/drivers/net/usb/lan78xx.c\n@@ -2024,6 +2024,8 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)\n \t\t\t\t\t\t lan8835_fixup);\n \t\tif (ret < 0) {\n \t\t\tnetdev_err(dev->net, \"fail to register fixup\\n\");\n+\t\t\tphy_unregister_fixup_for_uid(PHY_KSZ9031RNX,\n+\t\t\t\t\t\t     0xfffffff0);\n \t\t\treturn ret;\n \t\t}\n \t\t/* add more external PHY fixup here if needed */\n@@ -2031,8 +2033,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)\n \t\tphydev->is_internal = false;\n \t} else {\n \t\tnetdev_err(dev->net, \"unknown ID found\\n\");\n-\t\tret = -EIO;\n-\t\tgoto error;\n+\t\treturn -EIO;\n \t}\n \n \t/* if phyirq is not set, use polling mode in phylib */\n@@ -2051,7 +2052,10 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)\n \tif (ret) {\n \t\tnetdev_err(dev->net, \"can't attach PHY to %s\\n\",\n \t\t\t   dev->mdiobus->id);\n-\t\treturn -EIO;\n+\t\tret = -EIO;\n+\t\tif (dev->chipid == ID_REV_CHIP_ID_7801_)\n+\t\t\tgoto error;\n+\t\treturn ret;\n \t}\n \n \t/* MAC doesn't support 1000T Half */\n@@ -2067,8 +2071,6 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)\n \n \tdev->fc_autoneg = phydev->autoneg;\n \n-\tphy_start(phydev);\n-\n \tnetif_dbg(dev, ifup, dev->net, \"phy initialised successfully\");\n \n \treturn 0;\n@@ -2497,9 +2499,9 @@ static int lan78xx_open(struct net_device *net)\n \tif (ret < 0)\n \t\tgoto done;\n \n-\tret = lan78xx_phy_init(dev);\n-\tif (ret < 0)\n-\t\tgoto done;\n+\tif (dev->domain_data.phyirq > 0)\n+\t\tphy_start_interrupts(dev->net->phydev);\n+\tphy_start(dev->net->phydev);\n \n \t/* for Link Check */\n \tif (dev->urb_intr) {\n@@ -2560,13 +2562,11 @@ static int lan78xx_stop(struct net_device *net)\n \tif (timer_pending(&dev->stat_monitor))\n \t\tdel_timer_sync(&dev->stat_monitor);\n \n-\tphy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0);\n-\tphy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);\n-\n-\tphy_stop(net->phydev);\n-\tphy_disconnect(net->phydev);\n-\n-\tnet->phydev = NULL;\n+\tif (net->phydev) {\n+\t\tif (dev->domain_data.phyirq > 0)\n+\t\t\tphy_stop_interrupts(net->phydev);\n+\t\tphy_stop(net->phydev);\n+\t}\n \n \tclear_bit(EVENT_DEV_OPEN, &dev->flags);\n \tnetif_stop_queue(net);\n@@ -3464,6 +3464,12 @@ static void lan78xx_disconnect(struct usb_interface *intf)\n \tudev = interface_to_usbdev(intf);\n \n \tnet = dev->net;\n+\tif (dev->chipid == ID_REV_CHIP_ID_7801_) {\n+\t\tphy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0);\n+\t\tphy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);\n+\t}\n+\tphy_disconnect(net->phydev);\n+\tnet->phydev = NULL;\n \tunregister_netdev(net);\n \n \tcancel_delayed_work_sync(&dev->wq);\n@@ -3613,6 +3619,10 @@ static int lan78xx_probe(struct usb_interface *intf,\n \t\tgoto out3;\n \t}\n \n+\tret = lan78xx_phy_init(dev);\n+\tif (ret < 0)\n+\t\tgoto out3;\n+\n \tusb_set_intfdata(intf, dev);\n \n \tret = device_set_wakeup_enable(&udev->dev, true);\n@@ -3972,7 +3982,9 @@ static int lan78xx_reset_resume(struct usb_interface *intf)\n \n \tlan78xx_reset(dev);\n \n-\tlan78xx_phy_init(dev);\n+\tif (dev->domain_data.phyirq > 0)\n+\t\tphy_start_interrupts(dev->net->phydev);\n+\tphy_start(dev->net->phydev);\n \n \treturn lan78xx_resume(intf);\n }\n","prefixes":["net","1/4"]}