Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2265901pxb; Fri, 8 Oct 2021 04:32:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMzDzUGFYe7t5OOpxoslkFIDp1/4z1PJepGSG9FxfvHsT0bRBazSruVQTTMjaWg1KHNh/Y X-Received: by 2002:a63:f90b:: with SMTP id h11mr4169301pgi.165.1633692730354; Fri, 08 Oct 2021 04:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692730; cv=none; d=google.com; s=arc-20160816; b=kXcmw2z6I84xsfMj54T2ES5QzIgl1jth3z7W05gngylO7LBb62VeHiKhkADYw2mcNx AXqHn2GjW9/Vs/LZ7UwLxnXH2H6WhLbQeqATICmw9xAhg5V21Ur+4M3aPPMot41Ek5z/ kMIhi4CzihGbNdxPw6DxPovmqWkLjcIv9wHM+mYR1UBbdxqGDeOkVKy17EwwpBN5LdNT PI1vdIycgEyAmlPbIW9pvJAPc9zHROlMw3R+1GH3cUvpjutQBgh166Xsn7P9VqZbOvYm ZrANEFNmGAlJPrvyANb8hz0n42BNyVOiKXI/cm7V7MHBilRFddwRQDzGMRqYwUujJDC6 jIjA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FiSAubsfILyF7mj8+QQnCtZ0skhiVHxCpy/8QGEKpqI=; b=xywp+aMZLo0Bl36vrfEO4UEGcAdY/Y9u2OXpc5o5MZAGDsJOnrjZZfx8nSIj6jiQTi wwGDQD8VJm8asniPI2c7SKcdgyvLMj1UaoLGTmKjRSNne3K8cTAvZkOqOvFF7uS1DsHP iLJ5JqsDaH5Y5aONG3WTTUcTlaiemvsH74GId894qDLGH1qDxYYTGY5zM6yWN93cwXOG x+gDGE2A7cDZg6uUgHiY0f0YnVlWFbcQNz341xvL4iWWOgtsYhPZeOCPxxzTXKZX9Owi 1V/xWbeV6MHepJLedAY1KtWyoGIi0Xm1/d8j/BL0GXnv+9xzm0r3cMVyncQ5EEsJ6ZTh UVdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n6KrDwSe; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w185si37609985pfb.365.2021.10.08.04.31.57; Fri, 08 Oct 2021 04:32:10 -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=@linuxfoundation.org header.s=korg header.b=n6KrDwSe; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240598AbhJHLbc (ORCPT + 99 others); Fri, 8 Oct 2021 07:31:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:58384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240600AbhJHLav (ORCPT ); Fri, 8 Oct 2021 07:30:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4377161038; Fri, 8 Oct 2021 11:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692536; bh=QH4WM6JybP8VY6blTEobSCVrUtbDcdaxuYSvThxX7sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6KrDwSeZsLDQPyWmoizRyZHhxy1sxj3d0nmO+++Xy0+BAsP9s/RS/0627fejA9YZ f5O7YLVQIe/xbUQvdw2uRET/N9gL3ni5ih3jvn/A0Vy6itgg4G9Pi+9LQaQTnl1AJm 8gIuRiQyC+bM7htRf4r0mtWodoSM3bbiwaeyzJMg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Andrew Lunn , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 2/8] net: mdio: introduce a shutdown method to mdio device drivers Date: Fri, 8 Oct 2021 13:27:39 +0200 Message-Id: <20211008112714.023146177@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112713.941269121@linuxfoundation.org> References: <20211008112713.941269121@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit cf9579976f724ad517cc15b7caadea728c7e245c ] MDIO-attached devices might have interrupts and other things that might need quiesced when we kexec into a new kernel. Things are even more creepy when those interrupt lines are shared, and in that case it is absolutely mandatory to disable all interrupt sources. Moreover, MDIO devices might be DSA switches, and DSA needs its own shutdown method to unlink from the DSA master, which is a new requirement that appeared after commit 2f1e8ea726e9 ("net: dsa: link interfaces with the DSA master to get rid of lockdep warnings"). So introduce a ->shutdown method in the MDIO device driver structure. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/mdio_device.c | 11 +++++++++++ include/linux/mdio.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index 9c88e6749b9a..34600b0061bb 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -135,6 +135,16 @@ static int mdio_remove(struct device *dev) return 0; } +static void mdio_shutdown(struct device *dev) +{ + struct mdio_device *mdiodev = to_mdio_device(dev); + struct device_driver *drv = mdiodev->dev.driver; + struct mdio_driver *mdiodrv = to_mdio_driver(drv); + + if (mdiodrv->shutdown) + mdiodrv->shutdown(mdiodev); +} + /** * mdio_driver_register - register an mdio_driver with the MDIO layer * @new_driver: new mdio_driver to register @@ -149,6 +159,7 @@ int mdio_driver_register(struct mdio_driver *drv) mdiodrv->driver.bus = &mdio_bus_type; mdiodrv->driver.probe = mdio_probe; mdiodrv->driver.remove = mdio_remove; + mdiodrv->driver.shutdown = mdio_shutdown; retval = driver_register(&mdiodrv->driver); if (retval) { diff --git a/include/linux/mdio.h b/include/linux/mdio.h index bf9d1d750693..78b3cf50566f 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -61,6 +61,9 @@ struct mdio_driver { /* Clears up any memory if needed */ void (*remove)(struct mdio_device *mdiodev); + + /* Quiesces the device on system shutdown, turns off interrupts etc */ + void (*shutdown)(struct mdio_device *mdiodev); }; #define to_mdio_driver(d) \ container_of(to_mdio_common_driver(d), struct mdio_driver, mdiodrv) -- 2.33.0