Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp478895pxt; Fri, 6 Aug 2021 06:39:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxflb2+9GVLTOWrxIJcyhT1Hwab6CRifdZ0EYC4NG6SLumsUYpP9uKMGs3fh/kw58nUQeKf X-Received: by 2002:a6b:f101:: with SMTP id e1mr494787iog.118.1628257184032; Fri, 06 Aug 2021 06:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628257184; cv=none; d=google.com; s=arc-20160816; b=pPfaB7idWWaUqmoQ4ACLJ0ndugbjdz5qaslqFaB5twZC/2arvWaclncD9Qwxd4H06Z 5tBxp6BCuwPdW4xFszhuemgU1q38Hv/FGT+9Fkp/sq3Im7zOv03eWJ/7d1IR4mMPiTO4 DRrMGMizG9Yfc59Fz+laol//KLjHFJ1JgzZY3rolZlFfCUKoAbf0m+XWbPLBbJ8uPj/w Ix6eonKubtFS9GSXQ7PlEunO25kJfh3p1EAILp51RDH92nnNCkgOsUodVGhY5LbgsLtG 1gJMhthQ3vxUmiksTkjiNOAm7O5DJwI2JsbqETgKsDyoZz/8SL0hwLSGla5DBcspeOxe TX3A== 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=dUsjeB8M/k16GO3cs3yk0Z6eIiaOKZpNI2F5nmpMa2M=; b=MWXgajcNppGoSYmpIGSNvNOSVzOlrd0pOfrJyN67siFkuIc/5YlvfXOz4VpAJz8gMt eb4e5cXCKcqSf9pG8UwbhIs7yiBKt5VfeUbRY0Gn06LNwXmmz8J3pZsZ8akncLZKUhYk 66cRrNRxOdg8KtWqoAMyFfVR2iZzlTZE+Wua8GJqcDAmFwRocwAx4CzACH3OP1AQuz3D mKudWghSS3by6csZquX5z96X897HkqxJgMSWlugF3aQTCgr9RMcFS/grFtN9y3v5OKmi GSdA+fTuIPT3QOaLP0zJzUcwKumcJXyhkdcmNbnUO1K+ppYJRV6ymVVW699K41nAh83m ovfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zPMB08Y+; 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 t16si4057066iov.17.2021.08.06.06.39.30; Fri, 06 Aug 2021 06:39:44 -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=zPMB08Y+; 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 S244697AbhHFIYI (ORCPT + 99 others); Fri, 6 Aug 2021 04:24:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:50684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243428AbhHFIUf (ORCPT ); Fri, 6 Aug 2021 04:20:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A0F66120D; Fri, 6 Aug 2021 08:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628238018; bh=4dGRU6wbGefDj45r4umdl1N8zIxJ1aCI5VWDm0LvqpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zPMB08Y+8yYfVk6zAjFL+iD3nqqeqQQnZrdInEd+0B/VzNJ21W9VpHbEC08zk2t3K kHygMTgkRxNmPhQFPaU821ZNBevtJrwaGWUzCHwHEyEzNvbtZkBJxDH/Xe9CU129tM 0q8MPQkhi7YUp6SRyHU1dPIuEO2jKj3IoRcaoxwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 20/35] r8152: Fix a deadlock by doubly PM resume Date: Fri, 6 Aug 2021 10:17:03 +0200 Message-Id: <20210806081114.396738543@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210806081113.718626745@linuxfoundation.org> References: <20210806081113.718626745@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: Takashi Iwai [ 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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