Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp700470pxb; Tue, 5 Apr 2022 19:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8E19+39yaAWfdLi4O83eV/TyFtIwAmAM3juIxH4gijG3tDfWdPiyXm/cgyyzIcYkJjVMB X-Received: by 2002:a17:902:7447:b0:156:a2cf:fdd with SMTP id e7-20020a170902744700b00156a2cf0fddmr6301099plt.77.1649211562024; Tue, 05 Apr 2022 19:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211562; cv=none; d=google.com; s=arc-20160816; b=Ic6rtBYNM6U+KYUIbF2ONWOiEPtfoQwnChfPNB/mE9Dtut/oKfnHbTh0yaZWQbni1D yMvan8Rg3srBEo4cPxl75aCYEqYqVa0TCCMq59ARoDKW4EZWwFTPLkHvpz4JOWg87vFL EeegFmUOVFst6zOKSuOzNfQUC2fcgTkMcuQrTK0BFh+YGFD32wsoNSCeWFmleq2a4whe D6YCQ/Ld9Rcg/xSFzdsYjUTpuP8z5MNf1T+VuQR/MGi+bc7ZsJdbhlD66DCqSgq8Ipul skLzZYnfbqI9J5MFr2BM5B6PyPpTk0OL/Gg/HAKH6WRh60u1vuYijTDPwY+WDJWDUMYm ikwA== 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=ufBHq/nUx8mGI3BMkLc21pQpPOmmrNBS1eF9/f26n48=; b=lLMx9E0OXEC4OWxzSnPsz8vThZQkTuKWjpGIa6W/wreqotm2O4XL0Fl1PAZQW4LauF auooYcMxpIMS11Z1+TCYbXDRgXRaWNXF+F5mtQV6Yufgajii2PubMXCwGWIr2JpjLIun a1XDXZfyzyWPgYFjmwAnjTygnIvJRQ3FSiovk/1KWHuKYjjwL54CnjXrIuMTV7Q+ipwf uJ6CSNM9KIYO5jvN09r8QX/WuSWrPXV7jwK6qEJInstdoCkFvAsvraeMb/MzjE82h4TH kdGiLBK9ghHLuxXNAwFo2v3wdawLUjayO+8uVPpdSnzf6T54fEDN5+ndcwGHxmYOOdFj AI0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nGImqPET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a170902b49000b00155fc0b4904si14143574plr.234.2022.04.05.19.19.07; Tue, 05 Apr 2022 19:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nGImqPET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240375AbiDEIqS (ORCPT + 99 others); Tue, 5 Apr 2022 04:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233196AbiDEIGa (ORCPT ); Tue, 5 Apr 2022 04:06:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7E069CE0; Tue, 5 Apr 2022 01:01:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13777617B8; Tue, 5 Apr 2022 08:01:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21136C385A0; Tue, 5 Apr 2022 08:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145706; bh=cRDnYp2WkHCe87lioc38yMSt2RNxl4sNkTVmMLLZVUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGImqPETtEmj3gkes5KWCPJaCKMmkmAk9MEnxyd2OehVKv+oD9qtyBIo4RhsC+/I1 rwbfZjWbJT8iB2gfXfHQEP1x5H2RO1pbw4MR8owDfuQO8cppk9AtIr6HIm0UxQcQdu kAYvw5zItM/HktPGxPEsHPlzZn83aRvRexfrUtOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.17 0499/1126] mt76: mt7615: fix a leftover race in runtime-pm Date: Tue, 5 Apr 2022 09:20:46 +0200 Message-Id: <20220405070422.273651178@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 42ce8d3b623162f3248db50a38359f294e6b06fd ] Fix a possible race in mt7615_pm_power_save_work() if rx/tx napi schedules ps_work and we are currently accessing device register on a different cpu. Fixes: db928f1ab9789 ("mt76: mt7663: rely on mt76_connac_pm_ref/mt76_connac_pm_unref in tx/rx napi") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index ec25e5a95d44..6d0ff5af8fec 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -2103,6 +2103,14 @@ void mt7615_pm_power_save_work(struct work_struct *work) test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state)) goto out; + if (mutex_is_locked(&dev->mt76.mutex)) + /* if mt76 mutex is held we should not put the device + * to sleep since we are currently accessing device + * register map. We need to wait for the next power_save + * trigger. + */ + goto out; + if (time_is_after_jiffies(dev->pm.last_activity + delta)) { delta = dev->pm.last_activity + delta - jiffies; goto out; -- 2.34.1