Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp271276imu; Fri, 14 Dec 2018 19:19:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/W6w6DeVJsbDUqUwQ/SXSR27R/NAvrjwV7ELcNEpbVvM8yeU/tgQKU4ErH2PS7iJ+lXhNWE X-Received: by 2002:a62:68c5:: with SMTP id d188mr5372952pfc.194.1544843980979; Fri, 14 Dec 2018 19:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544843980; cv=none; d=google.com; s=arc-20160816; b=YN8+AMqVy2r/LgLTB3fNfo/fqnr1KnUaI3P4ZMDuOzQg/wJdNOGpHAkDzuqRL4b777 w6mWRbFbbzRmFgYotzEyW0z6gEJS1paSzqxii1qlNT+eok6fs42RmN3Ws3nSrGR63Fl0 veeh28pGbaPrj1YICtlfJBQ816D7qvtaXg+5UGUGVFjZia1RzBv+joQfQnOxZAvZdwF1 foyMgW0CX4WQFYUl5coxVunJHCCBt840jCN5SE5QJBmanf6GoQAjnf/gXsJzhMjBcM4J I9Yd8ifQewlkmSWPbOX7ilH8B+PcsRkDGOWzZmqJM5iXRAvEWWc7iHnhnDzQA0TN+wXJ xnUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=EMYEttFFscyHh5zesS2Zb7zhHoFFXAXNWLkqqJESSuA=; b=p/AIhXYEZ4UXQFfMTS8+VqlFviBl4mq++Cre6WegwoIXeSp8CdrgoQyLIzq4PYAs+Z USJcM2MgwbA2oGxnA2mdpQqbsfhEVhNDGDuKO1Ho2j5ihCooElss2s+6x1cZ17hHeJt/ j6bSI6MuQlcoMgNUknty0UM9PNqNPXS0q0ARRyun/36jegIanQvXX8Wdb1Vy7n+67xTB DvlJ1UgOlF0+aPe27IFVHf+alY2Ukqul8iIAwnun+HGP24tPMroPmfyf3NSVH41FbdX1 S4PLIpRozhKwOfWZmNufhT9cUK4AfI0AYABJaSXSvCJ0NRhbOZEkIRFTP8C0ckPeIORf 7rLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18si5434902pfm.39.2018.12.14.19.19.26; Fri, 14 Dec 2018 19:19:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730460AbeLODSC (ORCPT + 99 others); Fri, 14 Dec 2018 22:18:02 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16134 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729943AbeLODRe (ORCPT ); Fri, 14 Dec 2018 22:17:34 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F0BC1617D818D; Sat, 15 Dec 2018 11:17:29 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Sat, 15 Dec 2018 11:17:22 +0800 From: Peng Li To: CC: , , , , , Subject: [Patch net 02/10] net: hns: All ports can not work when insmod hns ko after rmmod. Date: Sat, 15 Dec 2018 11:53:21 +0800 Message-ID: <1544846009-50276-3-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> References: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonglong Liu There are two test cases: 1. Remove the 4 modules:hns_enet_drv/hns_dsaf/hnae/hns_mdio, and install them again, must use "ifconfig down/ifconfig up" command pair to bring port to work. This patch calls phy_stop function when init phy to fix this bug. 2. Remove the 2 modules:hns_enet_drv/hns_dsaf, and install them again, all ports can not use anymore, because of the phy devices register failed(phy devices already exists). Phy devices are registered when hns_dsaf installed, this patch removes them when hns_dsaf removed. The two cases are sometimes related, fixing the second case also requires fixing the first case, so fix them together. Signed-off-by: Yonglong Liu Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 15 +++++++++++++++ drivers/net/ethernet/hisilicon/hns/hns_enet.c | 3 +++ 2 files changed, 18 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c index 3613e40..a97228c 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c @@ -778,6 +778,17 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) return rc; } +static void hns_mac_remove_phydev(struct hns_mac_cb *mac_cb) +{ + if (!to_acpi_device_node(mac_cb->fw_port) || !mac_cb->phy_dev) + return; + + phy_device_remove(mac_cb->phy_dev); + phy_device_free(mac_cb->phy_dev); + + mac_cb->phy_dev = NULL; +} + #define MAC_MEDIA_TYPE_MAX_LEN 16 static const struct { @@ -1117,7 +1128,11 @@ void hns_mac_uninit(struct dsaf_device *dsaf_dev) int max_port_num = hns_mac_get_max_port_num(dsaf_dev); for (i = 0; i < max_port_num; i++) { + if (!dsaf_dev->mac_cb[i]) + continue; + dsaf_dev->misc_op->cpld_reset_led(dsaf_dev->mac_cb[i]); + hns_mac_remove_phydev(dsaf_dev->mac_cb[i]); dsaf_dev->mac_cb[i] = NULL; } } diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 28e9078..c205a0e 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1186,6 +1186,9 @@ int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h) if (h->phy_if == PHY_INTERFACE_MODE_XGMII) phy_dev->autoneg = false; + if (h->phy_if == PHY_INTERFACE_MODE_SGMII) + phy_stop(phy_dev); + return 0; } -- 1.9.1