From patchwork Tue Sep 1 13:36:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 52927 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 05F592157D for ; Tue, 1 Sep 2015 13:36:28 +0000 (UTC) Received: by labip2 with SMTP id ip2sf53056519lab.1 for ; Tue, 01 Sep 2015 06:36:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=XuzRDR0KdWUp5tBh/zj88V7xaloG4+mwvU7PTPujPNg=; b=aRG0cWXKkuQqg3P+4wsBqqIrLpKaYACZqFmFNeya7tPyGYjRazGDGBSBEXBfjKVDHK IKpmmgCpfFlsoKEG0gSEZ5AL1P5t5chK/X/41mSVRmhr8MZzciB/xW9mx0nCu7E+8/HX 3gLwRHFjckSeXaOPbrgOEISICAaga1B/6k3NR7tPV7uVTfJXkzSkNVvIw+uvt6wx4ITp nImp0l4ZIhK4PQed0AyR0SPfWiA+R6roHQ3y6C0chrcI0kAoM1c07zXb95eMdJpCu94R CNMNNZxW4oeaghAlXeGEhWmbwX7LOpKW/HbvKI/1zRXnOVIJ2pEaHV89xE/wi3qTJBBh xLUA== X-Gm-Message-State: ALoCoQn8l8pxoHqsNo8zw/6oeDYwgt6oZHOIIYUpURkJGQqTiWFR8zHGQdJD2SmpeVelkFXqncAY X-Received: by 10.152.9.4 with SMTP id v4mr7716350laa.6.1441114587001; Tue, 01 Sep 2015 06:36:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls425680laj.98.gmail; Tue, 01 Sep 2015 06:36:26 -0700 (PDT) X-Received: by 10.152.237.34 with SMTP id uz2mr889674lac.84.1441114586772; Tue, 01 Sep 2015 06:36:26 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id xv9si16435215lbb.111.2015.09.01.06.36.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 06:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by laboe4 with SMTP id oe4so66723730lab.0 for ; Tue, 01 Sep 2015 06:36:26 -0700 (PDT) X-Received: by 10.112.198.202 with SMTP id je10mr1125497lbc.86.1441114586656; Tue, 01 Sep 2015 06:36:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp544335lbb; Tue, 1 Sep 2015 06:36:25 -0700 (PDT) X-Received: by 10.68.197.231 with SMTP id ix7mr47060903pbc.85.1441114585480; Tue, 01 Sep 2015 06:36:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sv1si29906838pab.150.2015.09.01.06.36.24; Tue, 01 Sep 2015 06:36:25 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753410AbbIANgW (ORCPT + 28 others); Tue, 1 Sep 2015 09:36:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40870 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141AbbIANgV (ORCPT ); Tue, 1 Sep 2015 09:36:21 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C490796A8; Tue, 1 Sep 2015 13:36:20 +0000 (UTC) Received: from deneb.redhat.com.localdomain (ovpn-113-174.phx2.redhat.com [10.3.113.174]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81DaI9F011174; Tue, 1 Sep 2015 09:36:19 -0400 From: Mark Salter To: David Miller Cc: David Daney , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, f.fainelli@gmail.com, buytenh@wantstofly.org, grant.likely@secretlab.ca, Mark Salter Subject: [PATCH] phylib: fix device deletion order in mdiobus_unregister() Date: Tue, 1 Sep 2015 09:36:05 -0400 Message-Id: <1441114565-2340-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , commit 8b63ec1837fa ("phylib: Make PHYs children of their MDIO bus, not the bus' parent.") uncovered a problem in mdiobus_unregister() which leads to this warning when I reboot an APM Mustang (arm64) platform: WARNING: CPU: 7 PID: 4239 at fs/sysfs/group.c:224 sysfs_remove_group+0xa0/0xa4() sysfs group fffffe0000e07a10 not found for kobject 'xgene-mii-eth0:03' ... CPU: 7 PID: 4239 Comm: reboot Tainted: G E 4.2.0-0.18.el7.test15.aarch64 #1 Hardware name: AppliedMicro Mustang/Mustang, BIOS 1.1.0 Aug 26 2015 Call Trace: [] dump_backtrace+0x0/0x170 [] show_stack+0x20/0x2c [] dump_stack+0x78/0x9c [] warn_slowpath_common+0xa0/0xd8 [] warn_slowpath_fmt+0x74/0x88 [] sysfs_remove_group+0x9c/0xa4 [] dpm_sysfs_remove+0x5c/0x70 [] device_del+0x44/0x208 [] device_unregister+0x2c/0x7c [] mdiobus_unregister+0x48/0x94 [] xgene_enet_mdio_remove+0x28/0x44 [] xgene_enet_remove+0xd0/0xd8 [] xgene_enet_shutdown+0x2c/0x3c [] platform_drv_shutdown+0x24/0x40 [] device_shutdown+0xf0/0x1b4 [] kernel_restart_prepare+0x40/0x4c [] kernel_restart+0x1c/0x80 [] SyS_reboot+0x17c/0x250 The problem is that mdiobus_unregister() deletes the bus device before unregistering the phy devices on the bus. This wasn't a problem before because the phys were not children of the bus: /sys/devices/platform/APMC0D05:00/net/eth0/xgene-mii-eth0:03 /sys/devices/platform/APMC0D05:00/net/eth0/xgene-mii-eth0 But now that they are: /sys/devices/platform/APMC0D05:00/net/eth0/xgene-mii-eth0/xgene-mii-eth0:03 when mdiobus_unregister deletes the bus device, the phy subdirs are removed from sysfs also. So when the phys are unregistered afterward, we get the warning. This patch changes the order so that phys are unregistered before the bus device is deleted. Signed-off-by: Mark Salter Reviewed-by: Florian Fainelli Tested-by: Mark Langsdorf --- drivers/net/phy/mdio_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 46a14cb..02a4615 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -303,12 +303,12 @@ void mdiobus_unregister(struct mii_bus *bus) BUG_ON(bus->state != MDIOBUS_REGISTERED); bus->state = MDIOBUS_UNREGISTERED; - device_del(&bus->dev); for (i = 0; i < PHY_MAX_ADDR; i++) { if (bus->phy_map[i]) device_unregister(&bus->phy_map[i]->dev); bus->phy_map[i] = NULL; } + device_del(&bus->dev); } EXPORT_SYMBOL(mdiobus_unregister);