All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Takashi Iwai <tiwai@suse.de>,
	"David S. Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.13 20/35] r8152: Fix a deadlock by doubly PM resume
Date: Fri,  6 Aug 2021 10:17:03 +0200	[thread overview]
Message-ID: <20210806081114.396738543@linuxfoundation.org> (raw)
In-Reply-To: <20210806081113.718626745@linuxfoundation.org>

From: Takashi Iwai <tiwai@suse.de>

[ Upstream commit 776ac63a986d211286230c4fd70f85390eabedcd ]

r8152 driver sets up the MAC address at reset-resume, while
rtl8152_set_mac_address() has the temporary autopm get/put.  This may
lead to a deadlock as the PM lock has been already taken for the
execution of the runtime PM callback.

This patch adds the workaround to avoid the superfluous autpm when
called from rtl8152_reset_resume().

Link: https://bugzilla.suse.com/show_bug.cgi?id=1186194
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/usb/r8152.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 8dcc55e4a5bc..2cf763b4ea84 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1550,7 +1550,8 @@ static int
 rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u32 speed, u8 duplex,
 		  u32 advertising);
 
-static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
+static int __rtl8152_set_mac_address(struct net_device *netdev, void *p,
+				     bool in_resume)
 {
 	struct r8152 *tp = netdev_priv(netdev);
 	struct sockaddr *addr = p;
@@ -1559,9 +1560,11 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
 	if (!is_valid_ether_addr(addr->sa_data))
 		goto out1;
 
-	ret = usb_autopm_get_interface(tp->intf);
-	if (ret < 0)
-		goto out1;
+	if (!in_resume) {
+		ret = usb_autopm_get_interface(tp->intf);
+		if (ret < 0)
+			goto out1;
+	}
 
 	mutex_lock(&tp->control);
 
@@ -1573,11 +1576,17 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
 
 	mutex_unlock(&tp->control);
 
-	usb_autopm_put_interface(tp->intf);
+	if (!in_resume)
+		usb_autopm_put_interface(tp->intf);
 out1:
 	return ret;
 }
 
+static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
+{
+	return __rtl8152_set_mac_address(netdev, p, false);
+}
+
 /* Devices containing proper chips can support a persistent
  * host system provided MAC address.
  * Examples of this are Dell TB15 and Dell WD15 docks
@@ -1696,7 +1705,7 @@ static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 	return ret;
 }
 
-static int set_ethernet_addr(struct r8152 *tp)
+static int set_ethernet_addr(struct r8152 *tp, bool in_resume)
 {
 	struct net_device *dev = tp->netdev;
 	struct sockaddr sa;
@@ -1709,7 +1718,7 @@ static int set_ethernet_addr(struct r8152 *tp)
 	if (tp->version == RTL_VER_01)
 		ether_addr_copy(dev->dev_addr, sa.sa_data);
 	else
-		ret = rtl8152_set_mac_address(dev, &sa);
+		ret = __rtl8152_set_mac_address(dev, &sa, in_resume);
 
 	return ret;
 }
@@ -8442,7 +8451,7 @@ static int rtl8152_reset_resume(struct usb_interface *intf)
 	clear_bit(SELECTIVE_SUSPEND, &tp->flags);
 	tp->rtl_ops.init(tp);
 	queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
-	set_ethernet_addr(tp);
+	set_ethernet_addr(tp, true);
 	return rtl8152_resume(intf);
 }
 
@@ -9562,7 +9571,7 @@ static int rtl8152_probe(struct usb_interface *intf,
 	tp->rtl_fw.retry = true;
 #endif
 	queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0);
-	set_ethernet_addr(tp);
+	set_ethernet_addr(tp, false);
 
 	usb_set_intfdata(intf, tp);
 
-- 
2.30.2




  parent reply	other threads:[~2021-08-06  8:25 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  8:16 [PATCH 5.13 00/35] 5.13.9-rc1 review Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 01/35] drm/i915: Revert "drm/i915/gem: Asynchronous cmdparser" Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 02/35] Revert "drm/i915: Propagate errors on awaiting already signaled fences" Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 03/35] power: supply: ab8500: Call battery population once Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 04/35] skmsg: Increase sk->sk_drops when dropping packets Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 05/35] skmsg: Pass source psock to sk_psock_skb_redirect() Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 06/35] bpf, sockmap: On cleanup we additionally need to remove cached skb Greg Kroah-Hartman
2021-08-07 17:45   ` Naresh Kamboju
2021-08-09 17:33     ` John Fastabend
2021-08-06  8:16 ` [PATCH 5.13 07/35] cifs: use helpers when parsing uid/gid mount options and validate them Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 08/35] cifs: add missing parsing of backupuid Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 09/35] net: dsa: sja1105: parameterize the number of ports Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 10/35] net: dsa: sja1105: fix address learning getting disabled on the CPU port Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 11/35] ASoC: Intel: boards: handle hda-dsp-common as a module Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 12/35] ASoC: Intel: boards: create sof-maxim-common module Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 13/35] ASoC: Intel: boards: fix xrun issue on platform with max98373 Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 14/35] regulator: rtmv20: Fix wrong mask for strobe-polarity-high Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 15/35] regulator: rt5033: Fix n_voltages settings for BUCK and LDO Greg Kroah-Hartman
2021-08-06  8:16 ` [PATCH 5.13 16/35] spi: stm32h7: fix full duplex irq handler handling Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 17/35] ASoC: tlv320aic31xx: fix reversed bclk/wclk master bits Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 18/35] regulator: mtk-dvfsrc: Fix wrong dev pointer for devm_regulator_register Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 19/35] r8152: Fix potential PM refcount imbalance Greg Kroah-Hartman
2021-08-06  8:17 ` Greg Kroah-Hartman [this message]
2021-08-06  8:17 ` [PATCH 5.13 21/35] qed: fix possible unpaired spin_{un}lock_bh in _qed_mcp_cmd_and_union() Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 22/35] ASoC: rt5682: Fix the issue of garbled recording after powerd_dbus_suspend Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 23/35] net: Fix zero-copy head len calculation Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 24/35] ASoC: ti: j721e-evm: Fix unbalanced domain activity tracking during startup Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 25/35] ASoC: ti: j721e-evm: Check for not initialized parent_clk_id Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 26/35] efi/mokvar: Reserve the table only if it is in boot services data Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 27/35] nvme: fix nvme_setup_command metadata trace event Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 28/35] drm/amd/display: Fix comparison error in dcn21 DML Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 29/35] drm/amd/display: Fix max vstartup calculation for modes with borders Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 30/35] io_uring: never attempt iopoll reissue from release path Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 31/35] io_uring: explicitly catch any illegal async queue attempt Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 32/35] Revert "spi: mediatek: fix fifo rx mode" Greg Kroah-Hartman
2021-08-06 18:54   ` Guenter Roeck
2021-08-07  8:20     ` Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 33/35] Revert "Bluetooth: Shutdown controller after workqueues are flushed or cancelled" Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 34/35] Revert "watchdog: iTCO_wdt: Account for rebooting on second timeout" Greg Kroah-Hartman
2021-08-06  8:17 ` [PATCH 5.13 35/35] drm/amd/display: Fix ASSR regression on embedded panels Greg Kroah-Hartman
2021-08-06 10:44 ` [PATCH 5.13 00/35] 5.13.9-rc1 review Fox Chen
2021-08-06 14:33 ` Jon Hunter
2021-08-06 18:59 ` Guenter Roeck
2021-08-06 23:45 ` Justin Forbes
2021-08-07 13:16 ` Aakash Hemadri
2021-08-07 17:55 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210806081114.396738543@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.