Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp308904pxx; Thu, 29 Oct 2020 03:15:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbvowaFnBHDh/N8z+6yoewWnOcMYUYZLIbKnsCbQlp6nSB204Lwul7zqEe2+Gg66X1muDC X-Received: by 2002:a50:a683:: with SMTP id e3mr3140822edc.33.1603966501327; Thu, 29 Oct 2020 03:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603966501; cv=none; d=google.com; s=arc-20160816; b=gSpj0nMjpOcTeYdCElPbLjCwdI4W5Hd4uSGEWhkGLzBK6u5ig4OITufkioBVtDfqP1 EOnucV3iIhA3gOX/oIQpJVTYgGkLZa0zBKiEnb8Wyd32Z0cJY01wM0zHhV7pDMHzLsnk cnEVy9FOFkvBAHaXxV1vs2LsngeZ/wM81ZPEQ2x1d3EGjvSOS+BOe6qtfO7Fu5fdrs+Y NI8HR/nnHS8KG0kaQY5f57RBJ3tbmDebyDMUKVWsetz6O1Oe6/HhShtXjGww1vWLtqOI wRcT7cNs2Ke+dqV9LxB8+CN8SxMzZ1Bzk6itr/pmhMGE6QY7rvq1t7wzBuqX1w5yq5bn 2xIg== 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=1NVHrKVUzYrEX8zo6KX71XgjcTijKs3LoNtSkoA5/9Q=; b=M65EsKFK7HCxaA0Qzw3Ad8Zt9KfcZwBv5OKBptXbq1HgImmRH3khLEW24J3UZlYaoK Uk4Jt/Z9MmCRYzbci8rNOt+k5Yq+AbmcRpn/1APwXNW0zsMl1xO0xrlgEH17yCTNpYGg f3rrC0oW970yOpsugmgjbnKW4iBakwHHMfbyzdwGQH7cF6FjftK9oMKL33MZvE3ePj7H SmoIxjNfel+QBVStYuEev+9CcN7sWlvD0sxJddbRZU0I6Gaqs+4zH7ipscPLIqSF9EEP yngWzUGOV+Hm+ijfewsHhGquDhD8ha3PpUgvK9VEQQPAKWPLULDMgl3ADkf8iPxuslUF 9LNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kAZXdect; 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 bh5si1443728ejb.221.2020.10.29.03.14.38; Thu, 29 Oct 2020 03:15:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kAZXdect; 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 S1726666AbgJ2KIt (ORCPT + 99 others); Thu, 29 Oct 2020 06:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbgJ2KIn (ORCPT ); Thu, 29 Oct 2020 06:08:43 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1BA1C0613CF; Thu, 29 Oct 2020 03:08:42 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id v19so2412051edx.9; Thu, 29 Oct 2020 03:08:42 -0700 (PDT) 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=1NVHrKVUzYrEX8zo6KX71XgjcTijKs3LoNtSkoA5/9Q=; b=kAZXdectd+O7+Gb0/8YCeaGC6D7DTDHvy3ZNs8BbfqZ9y8x1Hv2CARvTvP/idJo6dR WE2s2PM4qlqv4G+GCsJKvw0cwm3ZelWQqp8Lt79xYxqMXVY56ss80F8aakEBw2QK5y8f dstgOvGkhkzWZHe8ZthgSGd24OA+V4M6nd0+Sn+VbAMtYGGM/e2InwzSL5QiSFRTfGl3 bHS+N44SAEjVRU8h6koOVoO8looC93064gf26B7YubNq5EFJ1sXIEmGJXjjhokrJbpR8 sux9C4UthG05cGMEqUVm5oCMlTR0Xeon7k+caZ1D9HaGcCc2uHF2dNeDDs9PKSNJUgEP bJcw== 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=1NVHrKVUzYrEX8zo6KX71XgjcTijKs3LoNtSkoA5/9Q=; b=e4fXwuJH4qLKuuIzxVSx3vgeTCMUzhVMHNESl1UvQZeEsyLD8UGwM+mKTtczgsDUvx IOK7MH9OoHDUiy2p54uVOg1ig/amW5Xl+dPkvSAXuI/MFQR8RD/j4Vx1CJwD/LCCma1A kptxr9RlcozBK/JCh8Gajh5R+KWwmCJxjnSwJUoBMvwC8jW/2gY9IcvN7PujPmA2vxZu if7IALpGmmGquT1+1yJFSQVzYBq4HeWzm/Y91AJaPsH5hpjeaTZB5LS4pvw5V6Yc4Zza rDx1TKnHGULTL9WKrTxSKnhsoqIdXZMp5l5nzuYrpYyrQSDqB3oFL5LqwOSWVobQr2Ki MA7Q== X-Gm-Message-State: AOAM5316mTQ60+kwROjioEdGfGOcK43uveYBC/RPxJ2d3m19Z2vtSC7R 5LJlTyrRJFHT4sTzljWUKebhEdV5vva3HZ0x X-Received: by 2002:a50:d751:: with SMTP id i17mr3153897edj.337.1603966121342; Thu, 29 Oct 2020 03:08:41 -0700 (PDT) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id m1sm1198650ejj.117.2020.10.29.03.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 03:08:40 -0700 (PDT) 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: [PATCH net-next 02/19] net: phy: add a shutdown procedure Date: Thu, 29 Oct 2020 12:07:24 +0200 Message-Id: <20201029100741.462818-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201029100741.462818-1-ciorneiioana@gmail.com> References: <20201029100741.462818-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 --- 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