Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1358369pxu; Sat, 24 Oct 2020 08:13:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkqsnd8hDpjBHI27e89jp7dY34e/p40M6dE2Ps7QhOUnMpMtlUk0VL3VTIJ/K3i3sMdP6L X-Received: by 2002:a50:be87:: with SMTP id b7mr7780732edk.185.1603552430118; Sat, 24 Oct 2020 08:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603552430; cv=none; d=google.com; s=arc-20160816; b=aksonflQr+W7kpdUq6Z4z2Jnn7HPqPql8XMc6M+ugzVeLX1SZHFhs8RC7/qhgRsaSd hIaWjVt6duaA27CFPGeSNxLvxIqfmXfxT7KzbMN7QNBZqnTPXWgsB6qms1f/RZtxBIWp PvFLh3qhwGmYk5/xqW4p/qBVqtxlTFPX6LI7VeaKGsXGZbw8Y/3iVj1LLy+um49QyGOf e8ZTK1N6mm0zax8jGiwlWP05zozNb/PJ82cgLb1wtE9rIrbHCJEoN0lAI0ZsCUSuXwkm wH8HfvnKpSYTjlFVlLdf1usbAvOg6UwxJSH4/UeqyH0161ZY/i0X9hVt0BOqNvRqWWei N32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=nY8JOSby9EAsxHh26PF9YfbPQRfletJKTAMUQ8S9G2w=; b=TCnYl8cqAMvWKrCUA0m5BWKHaIRKxfvMxPHfidH9hnrgTtFIlC1TWpTqeH6wPg4n3Z ST+bUduyAjFfAtcdpQkMJ6V5dbesioO37V/ZbXZxFhHlCvgZkz8Eiof4ww72t37Y6Aqb 9FLNh4sGP72twubP2Qr4mWajlEzug63mTAvp/9e6GYTJrBFjOlWpV/zJosTERnxkM0rB wqOXrPQyIZZv6zRjWfA1W7hIoSDcyjlBhEjlkjLq8Y+8+DQfs4NzF3ZCR2vdUQrpnJGQ zxs4SmC4arVzgpo1hTOBbjvvV1oRfPKuCl+hDd1Tew49Hxtuq96ebpXSwzzx9doNCvwA 5sYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si3240225ejk.598.2020.10.24.08.13.28; Sat, 24 Oct 2020 08:13:50 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761277AbgJXMOo (ORCPT + 99 others); Sat, 24 Oct 2020 08:14:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59856 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761238AbgJXMOk (ORCPT ); Sat, 24 Oct 2020 08:14:40 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2C971200F0B; Sat, 24 Oct 2020 14:14:38 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 14E7C200F06; Sat, 24 Oct 2020 14:14:38 +0200 (CEST) Received: from fsr-ub1864-126.ea.freescale.net (fsr-ub1864-126.ea.freescale.net [10.171.82.212]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id F00D1202EC; Sat, 24 Oct 2020 14:14:36 +0200 (CEST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean , Andre Edich , Antoine Tenart , Baruch Siach , Christophe Leroy , Dan Murphy , Divya Koppera , Florian Fainelli , Hauke Mehrtens , Jerome Brunet , Kavya Sree Kotagiri , Linus Walleij , Marco Felsch , Marek Vasut , Martin Blumenstingl , Mathias Kresin , Maxim Kochetkov , Michael Walle , Neil Armstrong , Nisar Sayed , Oleksij Rempel , Philippe Schenker , Willy Liu , Yuiko Oshino Subject: [RFC net-next 2/5] net: phy: add a shutdown procedure Date: Sat, 24 Oct 2020 15:14:09 +0300 Message-Id: <20201024121412.10070-3-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201024121412.10070-1-ioana.ciornei@nxp.com> References: <20201024121412.10070-1-ioana.ciornei@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of a board which uses a shared IRQ we can easily end up with an IRQ storm after a forced reboot. For example, a 'reboot -f' will trigger a call to the .shutdown() callbacks of all devices. Because phylib does not implement that hook, the PHY is not quiesced, thus it can very well leave its IRQ enabled. At the next boot, if that IRQ line is found asserted by the first PHY driver that uses it, but _before_ the driver that is _actually_ keeping the shared IRQ asserted is probed, the IRQ is not going to be acknowledged, thus it will keep being fired preventing the boot process of the kernel to continue. This is even worse when the second PHY driver is a module. To fix this, implement the .shutdown() callback and disable the interrupts if these are used. Note that we are still susceptible to IRQ storms if the previous kernel exited with a panic or if the bootloader left the shared IRQ active, but there is absolutely nothing we can do about these cases. Cc: Alexandru Ardelean Cc: Andre Edich Cc: Antoine Tenart Cc: Baruch Siach Cc: Christophe Leroy Cc: Dan Murphy Cc: Divya Koppera Cc: Florian Fainelli Cc: Hauke Mehrtens Cc: Heiner Kallweit Cc: Jerome Brunet Cc: Kavya Sree Kotagiri Cc: Linus Walleij Cc: Marco Felsch Cc: Marek Vasut Cc: Martin Blumenstingl Cc: Mathias Kresin Cc: Maxim Kochetkov Cc: Michael Walle Cc: Neil Armstrong Cc: Nisar Sayed Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Willy Liu Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- drivers/net/phy/phy_device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5dab6be6fc38..413a0a2c5d51 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2947,6 +2947,13 @@ static int phy_remove(struct device *dev) return 0; } +static void phy_shutdown(struct device *dev) +{ + struct phy_device *phydev = to_phy_device(dev); + + phy_disable_interrupts(phydev); +} + /** * phy_driver_register - register a phy_driver with the PHY layer * @new_driver: new phy_driver to register @@ -2970,6 +2977,7 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) new_driver->mdiodrv.driver.bus = &mdio_bus_type; new_driver->mdiodrv.driver.probe = phy_probe; new_driver->mdiodrv.driver.remove = phy_remove; + new_driver->mdiodrv.driver.shutdown = phy_shutdown; new_driver->mdiodrv.driver.owner = owner; new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS; -- 2.28.0