Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp437270imu; Wed, 12 Dec 2018 20:53:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/VFQ5pl60Gy1MoiUaVf/l60inRWTldJsRrtTUPnmBzSHrgdlidH54gR+WWt/9agEnD1E2LF X-Received: by 2002:a65:6684:: with SMTP id b4mr20807804pgw.55.1544676821567; Wed, 12 Dec 2018 20:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544676821; cv=none; d=google.com; s=arc-20160816; b=BYEuUaMgbuizSkFZ4ndXe94rGEy4do4tLEA0qz3c9zezyVrwsqhajL1BR8fv5strJb 2NjrjWwgO2KJlebDTFBwCWA4/2MOfKwaboUsKE63jfM46+TdJ7f8gT9FmPDkDgL6HK1/ nbGYLRiL+N7KbtcjlYXVv9t2RHeKtSdXqWTz/SVmRa/r5t/l4sC52BbwXjluwD1yOH5u OJzihlWngHHduGOjFE/yXM9Mgp4bbzCcEDUgFRv6mbXwFB4YrSCdquxX6+HXKeDyX1aV rHffaoDqABGL/91KFFxQo7NtIdaOd98yplpPY1WN7xDrjDT4ixF7FbcreCHc4X2Pn5bh QXPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tgyEM48iQGVADW3iwP8SfGoWopuMRXGgdpxXWcqeEt0=; b=kFkX7XbVkAqDv5EVVdD1Wl/P/Wa1f/U0mG2XotWBprPN4NTGEkXaoiFfCSSmsbVc1J tqOy9S5syhsIGET7mNS4hQTFNN63wOWhNPuNXn2jxUrWBshjf23c2seSnG7coWw3xCP9 LmCKiRyzTl6wgSNWUgQuMrNnMxlzrXJuzP7Q51R1qepELJWlXdFotV1moZaA0Z/6ZVvn 6vBWFvYhl7kE6sdI2PwThCCStDXS2qxFD3w+HF9Cqp+xtiOVX+vkIUVHxQbA/p5/LOpf T6XisGnCoPQlplLlVTkvHM6SnvNS1OANbz68sVUui5lFDtc3HEZFLBu3ZASq9y6baE8Y ysaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jDR9WQDy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p11si638112pgb.219.2018.12.12.20.53.26; Wed, 12 Dec 2018 20:53:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=jDR9WQDy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbeLME3O (ORCPT + 99 others); Wed, 12 Dec 2018 23:29:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:42208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727426AbeLME3M (ORCPT ); Wed, 12 Dec 2018 23:29:12 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3152A20879; Thu, 13 Dec 2018 04:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544675351; bh=ot1LONLli4TkGZ0V5BAmBpNBI5tLrn5Choolk0aduB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jDR9WQDyhUwYg4kUa5FkXe3B6yYfdzBjd6s53BJK0jsBc6TbL4MyyPYqy5WtlAFib KEMv0AHOLNF+QYJf64NV7iriHmi5ZSUfkY8nRnUyc1ARjUTTXuO4aRwFDEVW2KUUSo aqsQcJ7Dg3ffrbT4m362f0K9dPKFMcSKeP/Pifcc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thierry Reding , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 20/73] net: stmmac: Move debugfs init/exit to ->probe()/->remove() Date: Wed, 12 Dec 2018 23:27:45 -0500 Message-Id: <20181213042838.75160-20-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181213042838.75160-1-sashal@kernel.org> References: <20181213042838.75160-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding [ Upstream commit 5f2b8b62786853341a20d4cd4948f9cbca3db002 ] Setting up and tearing down debugfs is current unbalanced, as seen by this error during resume from suspend: [ 752.134067] dwc-eth-dwmac 2490000.ethernet eth0: ERROR failed to create debugfs directory [ 752.134347] dwc-eth-dwmac 2490000.ethernet eth0: stmmac_hw_setup: failed debugFS registration The imbalance happens because the driver creates the debugfs hierarchy when the device is opened and tears it down when the device is closed. There's little gain in that, and it could be argued that it is even surprising because it's not usually done for other devices. Fix the imbalance by moving the debugfs creation and teardown to the driver's ->probe() and ->remove() implementations instead. Note that the ring descriptors cannot be read while the interface is down, so make sure to return an empty file when the descriptors_status debugfs file is read. Signed-off-by: Thierry Reding Acked-by: Jose Abreu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 75896d6ba6e2..99ea5c4ce29c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2547,12 +2547,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) netdev_warn(priv->dev, "PTP init failed\n"); } -#ifdef CONFIG_DEBUG_FS - ret = stmmac_init_fs(dev); - if (ret < 0) - netdev_warn(priv->dev, "%s: failed debugFS registration\n", - __func__); -#endif priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; if (priv->use_riwt) { @@ -2753,10 +2747,6 @@ static int stmmac_release(struct net_device *dev) netif_carrier_off(dev); -#ifdef CONFIG_DEBUG_FS - stmmac_exit_fs(dev); -#endif - stmmac_release_ptp(priv); return 0; @@ -3896,6 +3886,9 @@ static int stmmac_sysfs_ring_read(struct seq_file *seq, void *v) u32 tx_count = priv->plat->tx_queues_to_use; u32 queue; + if ((dev->flags & IFF_UP) == 0) + return 0; + for (queue = 0; queue < rx_count; queue++) { struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; @@ -4394,6 +4387,13 @@ int stmmac_dvr_probe(struct device *device, goto error_netdev_register; } +#ifdef CONFIG_DEBUG_FS + ret = stmmac_init_fs(ndev); + if (ret < 0) + netdev_warn(priv->dev, "%s: failed debugFS registration\n", + __func__); +#endif + return ret; error_netdev_register: @@ -4429,6 +4429,9 @@ int stmmac_dvr_remove(struct device *dev) netdev_info(priv->dev, "%s: removing driver", __func__); +#ifdef CONFIG_DEBUG_FS + stmmac_exit_fs(ndev); +#endif stmmac_stop_all_dma(priv); stmmac_mac_set(priv, priv->ioaddr, false); -- 2.19.1