Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3850765pxb; Tue, 17 Nov 2020 05:22:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfDD0Em0PXKKqLnpfUDdYAHDxeSMaqjIxidApbybkKQBrniKn9Gk5ynug8620az0GMO6TT X-Received: by 2002:a17:906:ae52:: with SMTP id lf18mr20367194ejb.9.1605619358513; Tue, 17 Nov 2020 05:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619358; cv=none; d=google.com; s=arc-20160816; b=rwsolAqJWebo60CSQ9cmCzAV2LtJVG6UCrG6jvx9gmGmtBeTxHfQF2KWHuBv/MHD/6 /oiwgeYISdP+Qs2DiBcXoTpHXUImepq7rmluLzKQfAso6/SvuSLjzkKDgpB/1wwMM6H7 SJi8W0PL0z/snrzYTU823c8ys1aqKV2u6U2V6tB1Ut5BKQiwjUnHenKWsKMb6Z/lMIug LywiBqK2Lmtfpskp+4RKiNzSoQy/JMKfI7+aUOflwduwDS1p3yhB2qhAjKMnA5NbGzMi TdxV0CPtBH4Sc0YKYQ23st28fR1m3jzhgf+6jYLruOYchJSKqeyhFd31tGw8CHcOxYcw A/mg== 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=hLE4gEVE5+0Zi0mEup7zNUw4JZ8o6P1OZ2C2WtpeB9A=; b=isNiTccItASpQjCKL6ZZFHYJeEPS550Vsee1HuAyxRXXpmzhOeOQ3zc9bU64UfDj3K HSqUsGOQMnjJOSMktK7tDo1QAph7MIJgciSZ247SeVPYQwg6lVRaptgRlC/FLmjdT8XR oFDQqIViQOSZI6Pjmbg8m8Fl6y+RU56PxtopGqeRzQoYm3rx43Hh+7QntVxdcvOUasUr dyIIL5EYNMYJCKbMHCyCAQcisik1DwYLxf4tWTzsHDNzK6k7+/E0+KXSGdR+Mq5YS0y3 kITlOwcnqfF2cKFU9bwv+u4pyimigPB4tIfygn3hVffSXaC/vy/CD+ipbZljigAIWpr6 lerQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aBEkhufy; 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=fail (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 ml22si12806537ejb.172.2020.11.17.05.22.13; Tue, 17 Nov 2020 05:22:38 -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=@kernel.org header.s=default header.b=aBEkhufy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730462AbgKQNT6 (ORCPT + 99 others); Tue, 17 Nov 2020 08:19:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:53170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730412AbgKQNTu (ORCPT ); Tue, 17 Nov 2020 08:19:50 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CA6B24248; Tue, 17 Nov 2020 13:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619189; bh=9KR9emB6vwp1BsTaAAB3Ljt/BM+q5eDOtc6D+Gvnyh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aBEkhufyunQyN2xAjRA9QdIgzIZYZdpMsNp6dIvTrZlHhzcXmQ6UPJvn2T7sU7C3c 4PH24F8aWeiTxlSxvV7olK1BftYzE4tYAu6Tv/rPdIfEm72fhWz32nhgiroluGFEeZ xHFUldpF7D8/s3zBRkf7G8URL3Mnf4P9I+4ANGyg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Van Asbroeck , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 058/101] lan743x: fix "BUG: invalid wait context" when setting rx mode Date: Tue, 17 Nov 2020 14:05:25 +0100 Message-Id: <20201117122115.927004640@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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: Sven Van Asbroeck [ Upstream commit 2b52a4b65bc8f14520fe6e996ea7fb3f7e400761 ] In the net core, the struct net_device_ops -> ndo_set_rx_mode() callback is called with the dev->addr_list_lock spinlock held. However, this driver's ndo_set_rx_mode callback eventually calls lan743x_dp_write(), which acquires a mutex. Mutex acquisition may sleep, and this is not allowed when holding a spinlock. Fix by removing the dp_lock mutex entirely. Its purpose is to prevent concurrent accesses to the data port. No concurrent accesses are possible, because the dev->addr_list_lock spinlock in the core only lets through one thread at a time. Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver") Signed-off-by: Sven Van Asbroeck Link: https://lore.kernel.org/r/20201109203828.5115-1-TheSven73@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/microchip/lan743x_main.c | 12 +++--------- drivers/net/ethernet/microchip/lan743x_main.h | 3 --- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index 208341541087e..085fdceb3821b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -672,14 +672,12 @@ clean_up: static int lan743x_dp_write(struct lan743x_adapter *adapter, u32 select, u32 addr, u32 length, u32 *buf) { - int ret = -EIO; u32 dp_sel; int i; - mutex_lock(&adapter->dp_lock); if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, 1, 40, 100, 100)) - goto unlock; + return -EIO; dp_sel = lan743x_csr_read(adapter, DP_SEL); dp_sel &= ~DP_SEL_MASK_; dp_sel |= select; @@ -691,13 +689,10 @@ static int lan743x_dp_write(struct lan743x_adapter *adapter, lan743x_csr_write(adapter, DP_CMD, DP_CMD_WRITE_); if (lan743x_csr_wait_for_bit(adapter, DP_SEL, DP_SEL_DPRDY_, 1, 40, 100, 100)) - goto unlock; + return -EIO; } - ret = 0; -unlock: - mutex_unlock(&adapter->dp_lock); - return ret; + return 0; } static u32 lan743x_mac_mii_access(u16 id, u16 index, int read) @@ -2679,7 +2674,6 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter, adapter->intr.irq = adapter->pdev->irq; lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF); - mutex_init(&adapter->dp_lock); ret = lan743x_gpio_init(adapter); if (ret) diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h index 2d6eea18973e8..77273be2d1ee0 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.h +++ b/drivers/net/ethernet/microchip/lan743x_main.h @@ -702,9 +702,6 @@ struct lan743x_adapter { struct lan743x_csr csr; struct lan743x_intr intr; - /* lock, used to prevent concurrent access to data port */ - struct mutex dp_lock; - struct lan743x_gpio gpio; struct lan743x_ptp ptp; -- 2.27.0