Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2631325pxx; Sun, 1 Nov 2020 04:54:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHDKTSS3qz4WbJRE9lAnj3agx3cdlw/h9idWPMITTFBPjoxdY8yTCJO70denNockiNfJ31 X-Received: by 2002:a05:6402:17c2:: with SMTP id s2mr5292419edy.40.1604235254673; Sun, 01 Nov 2020 04:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604235254; cv=none; d=google.com; s=arc-20160816; b=qXeEU10/rjqLrAd6iw3I6g4imFtCI/1hG+HVZNr9WxPidUf+Jc0r8JiaIseEvBRPxp srWUoP8NDyD4g0lG2WQvttvhBX2uhgWKK/zRG99FvGE67qQqIE3Sb5/ubQOH6TWeQz6E 0u+2hmnjoytA1KcBurSwL3WuKbmdO7P3ECcq6yepol3y4/xp0ZrC/oZhkYZwePuFTDN6 iIxLGOf0GxwPLti2GQmY04JahDQEeTfHqgUF/pW1WnoHpPlax6AOY00sPk4pkm+XIoOT 0IF1DXnlmsgytrxM09cm4t5H3eA1lwAZqplBK7B7eGCw5JbAh/ObImi5/MVvnxYGHbyk 2MaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9GApglWVha/Wm6ZpEPj/3soIrOPKEJEBr7djBJ0S7Zc=; b=G2/En4HEOjNhINxNped/dsJxQu/V+99T7MIPPaY3QK5JXcZO1vF02Nq+0C5xTTXdYL qyjfdldR0GhufdbHeCYyISClPoR5kh0Ctp3TVI3xOvquQ8WZl/WW23fI0VK/6qLFzG7s rO/k98oTe5UwCDx4AUkgmjWaFeF2oUOD94WzFa/Tagt2aurEQvViAMydK70oMPbt/vxX 8IDMeCnMY9iXsWTe9Brs2ZW/Lmb5LFXZwzvMIoFnOb+WU74SzPStLYul/ud7KEaws9bq MjyOvpvEcfFaMRSx2JI7GNRZYYz3uXohx97k7oVy4jjLcj0TCzSX1uVsn9QjQzxuOBg6 4rWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lXMiEldW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si8111149ejc.705.2020.11.01.04.53.52; Sun, 01 Nov 2020 04:54:14 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lXMiEldW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgKAMw1 (ORCPT + 99 others); Sun, 1 Nov 2020 07:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgKAMwZ (ORCPT ); Sun, 1 Nov 2020 07:52:25 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E894C0617A6; Sun, 1 Nov 2020 04:52:23 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id w25so11396661edx.2; Sun, 01 Nov 2020 04:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9GApglWVha/Wm6ZpEPj/3soIrOPKEJEBr7djBJ0S7Zc=; b=lXMiEldW7rgzDtLCQps8xDZ8V3/IUgPnOpcIX9vnQuZk05RQFZmhfMATZJAN+SH6Ag iTBzjB6PiiaW2lFDqG84O7ZFSkss58Uzv8RGCBg+J6mc1Baq0hsg4iph5p7jmzPE30q9 mJouEUfcjA1j31k3MC7DgL3jhrzpuLRjVbCFwcDDk4SczwT+4RlrO23OOe2GNOblmibX y7aLTe+a4kpGi/Hc+/RIX8l8YRH/MQuyR+F4RMaykcC8jC4nL+Ze4YD5gwt0CHH3pnxH l2sqrvn6yMwITWzi87OZGMLW1QcCQnJvyjuNUl2sZz5w/UPazI0yNJi62rD9jN6eswfw FhTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9GApglWVha/Wm6ZpEPj/3soIrOPKEJEBr7djBJ0S7Zc=; b=ReDyl4qnAGZ+yYCZrRo954pl0i4bcPjl6YaHEWWiY4jK9t/I7iHZlz7O+OryLDpE8Y hBwGtrB7wxDqaHZ9AUJkYPn0wIyEkUnsYktk6AWOmnsc0vuzm5xDwsOuq1W0G0CkZ7CI Nl2oO7BAKOEViFG+v03v7pZezKx1cT3OkgqLrQpWTeRLLCpMWVWhe03H4UOZP58TlALM E0i9urebtn5a1uUn0Hlm2NZB+cnYrD9E2Yun15zvHuuorPvBx1283McQ7ySLaSanZJUt jeXQ/YO+woTohMc7dQb7CKIvc0S6Vu5iFTyePmB0YS0goMw3HfFCQAnMklVBwcDi7qyj j7gw== X-Gm-Message-State: AOAM530jAmmVOsxCpL+fvN2wi0LeBltxKppS7IvqdeZdAyzoNxkKq12z YBh9XoprX0ZI5IIIRMw5Mo8= X-Received: by 2002:a50:fd99:: with SMTP id o25mr11355025edt.6.1604235142065; Sun, 01 Nov 2020 04:52:22 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:21 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , 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 , 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: [PATCH net-next v2 02/19] net: phy: add a shutdown procedure Date: Sun, 1 Nov 2020 14:50:57 +0200 Message-Id: <20201101125114.1316879-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ioana Ciornei 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 --- Changes in v2: - none 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