Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13782020pxu; Mon, 4 Jan 2021 04:29:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnChxOeotAhBeKyiovqL6GnplMLzjGw0cuC7S3xgVjUzCySs5+bX9bvXj/d3Sncf1zAjDe X-Received: by 2002:a50:f299:: with SMTP id f25mr70155362edm.133.1609763355511; Mon, 04 Jan 2021 04:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609763355; cv=none; d=google.com; s=arc-20160816; b=ek/wh7mutD8gkccI7lOSg2MI+s9kho8i2H7Efgg77nNnnjkYbTEz2ueotF0IHTW+dr 7Jma1mjTnPkz4kssQNZxnij/U2a9k23ZHJOdli7ozJRnuG/EPWSb2Z92CW4n1ZyL4Tjo F+0VDlE3IPzFXSA8J5z9gwzsqLZ2tCTGQTrAeIn1lYIM0gRgKU2dEKaQtsk0zuCMBt9w NvfIoBIrPOZEujEbg5ZGhiRS/DeqLt7uF2gLDmoXnJYEY5HoFfv2648J1fw23ozg3oI5 tIHOqMqDr4+/EBZg4nmaHhiK+uttseQMl77BEz3HWYhyH3eH8Y4wkNv44wiGeDejwdZi vLQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NImoEpSppIlgQxC+rcwbWOWfHpQcdIZgT9VcwhR7yAw=; b=RZgEZ4FU3rp3X4TU5ddzYskAi3wkb++o6TnHSK4DCzpEh1Q1WWaNlPw9FeldnS0RFP uyd05CIKMFbZwSNTOAgZmNDO1hAxZ4EhDEsZJs7hrGByYFNEBBmAb/FKLhBm5jwJpwjA +C1cdrBdfHCFVmLEd/zxbsSEgrvcFKmp0wKCvT5JoP1OR5LU+VR8KxH4zd8Kajigx/QQ cwEP36OnJk9XZ/PuZUZUFogpW++vKkz3EEEXNRRiWYQBWnGnl6KPK8RozJGZ4mjAYdYq iDz1/D7S7xCPFUsjshHYU5I0COFSjpzYkpY2H5EcmfHVbf51qn08XkTha0nR0KLxhWPm 53zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 33si31501661edr.343.2021.01.04.04.28.51; Mon, 04 Jan 2021 04:29:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbhADMZD (ORCPT + 99 others); Mon, 4 Jan 2021 07:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbhADMZC (ORCPT ); Mon, 4 Jan 2021 07:25:02 -0500 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B6ADC061574 for ; Mon, 4 Jan 2021 04:24:21 -0800 (PST) Received: from ramsan.of.borg ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id CcQG2400w4C55Sk01cQGKE; Mon, 04 Jan 2021 13:24:18 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kwOuG-00169y-EN; Mon, 04 Jan 2021 13:24:16 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1kwOuF-005IiT-Vv; Mon, 04 Jan 2021 13:24:15 +0100 From: Geert Uytterhoeven To: Ioana Ciornei , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Jakub Kicinski , Russell King Cc: Wolfram Sang , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] [RFC] net: phy: Fix reboot crash if CONFIG_IP_PNP is not set Date: Mon, 4 Jan 2021 13:24:15 +0100 Message-Id: <20210104122415.1263541-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wolfram reports that his R-Car H2-based Lager board can no longer be rebooted in v5.11-rc1, as it crashes with an imprecise external abort. The issue can be reproduced on other boards (e.g. Koelsch with R-Car M2-W) too, if CONFIG_IP_PNP is disabled: Unhandled fault: imprecise external abort (0x1406) at 0x00000000 pgd = (ptrval) [00000000] *pgd=422b6835, *pte=00000000, *ppte=00000000 Internal error: : 1406 [#1] ARM Modules linked in: CPU: 0 PID: 1105 Comm: init Tainted: G W 5.10.0-rc1-00402-ge2f016cf7751 #1048 Hardware name: Generic R-Car Gen2 (Flattened Device Tree) PC is at sh_mdio_ctrl+0x44/0x60 LR is at sh_mmd_ctrl+0x20/0x24 ... Backtrace: [] (sh_mdio_ctrl) from [] (sh_mmd_ctrl+0x20/0x24) r7:0000001f r6:00000020 r5:00000002 r4:c22a1dc4 [] (sh_mmd_ctrl) from [] (mdiobb_cmd+0x38/0xa8) [] (mdiobb_cmd) from [] (mdiobb_read+0x58/0xdc) r9:c229f844 r8:c0c329dc r7:c221e000 r6:00000001 r5:c22a1dc4 r4:00000001 [] (mdiobb_read) from [] (__mdiobus_read+0x74/0xe0) r7:0000001f r6:00000001 r5:c221e000 r4:c221e000 [] (__mdiobus_read) from [] (mdiobus_read+0x40/0x54) r7:0000001f r6:00000001 r5:c221e000 r4:c221e458 [] (mdiobus_read) from [] (phy_read+0x1c/0x20) r7:ffffe000 r6:c221e470 r5:00000200 r4:c229f800 [] (phy_read) from [] (kszphy_config_intr+0x44/0x80) [] (kszphy_config_intr) from [] (phy_disable_interrupts+0x44/0x50) r5:c229f800 r4:c229f800 [] (phy_disable_interrupts) from [] (phy_shutdown+0x18/0x1c) r5:c229f800 r4:c229f804 [] (phy_shutdown) from [] (device_shutdown+0x168/0x1f8) [] (device_shutdown) from [] (kernel_restart_prepare+0x3c/0x48) r9:c22d2000 r8:c0100264 r7:c0b0d034 r6:00000000 r5:4321fedc r4:00000000 [] (kernel_restart_prepare) from [] (kernel_restart+0x1c/0x60) [] (kernel_restart) from [] (__do_sys_reboot+0x168/0x208) r5:4321fedc r4:01234567 [] (__do_sys_reboot) from [] (sys_reboot+0x18/0x1c) r7:00000058 r6:00000000 r5:00000000 r4:00000000 [] (sys_reboot) from [] (ret_fast_syscall+0x0/0x54) Calling phy_disable_interrupts() unconditionally means that the PHY registers may be accessed while the device is suspended, causing undefined behavior, which may crash the system. Fix this by calling phy_disable_interrupts() only when the PHY has been started. Reported-by: Wolfram Sang Fixes: e2f016cf775129c0 ("net: phy: add a shutdown procedure") Signed-off-by: Geert Uytterhoeven --- Marked RFC as I do not know if this change breaks the use case fixed by the faulty commit. Alternatively, the device may have to be started explicitly first. --- drivers/net/phy/phy_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 80c2e646c0934311..5985061b00128f8a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2962,7 +2962,8 @@ static void phy_shutdown(struct device *dev) { struct phy_device *phydev = to_phy_device(dev); - phy_disable_interrupts(phydev); + if (phy_is_started(phydev)) + phy_disable_interrupts(phydev); } /** -- 2.25.1