Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp639369pxb; Tue, 5 Apr 2022 16:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc3JhgMjpJHp9yOeIvJAtf4sJ1SpEGGwSzdWVKJM+nc1JnbUuvViKLKz64BvhSjnU4+KWt X-Received: by 2002:a65:5941:0:b0:375:9bfd:473d with SMTP id g1-20020a655941000000b003759bfd473dmr4840636pgu.348.1649202977438; Tue, 05 Apr 2022 16:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202977; cv=none; d=google.com; s=arc-20160816; b=FCgA1srdPSoOg1fPd5QZh5m0ch+knxWuxPC64gxcElBbLJoTE3nbztS1r4Gz5BCxIa 7vj/lpOcOG1TJ1N4dbUOoHeo9PWEF+N8XX74h7FlKOX9AJ04iwaRal+UvYgNKzZhnop4 9tUdIMoJPtDlfW+hXlXaN5OfTOzjPlaMAzTDI4c1SR4p17gZtEXmnt0w+8uMNMKZe9Sp LofyLN0DfjktDTEFVhyAr1r8SWrTvvrPyMtanf7c5skuB8zqjiFCIKWCqmGdHLJGGt2o D9GKqUJFTgroAMCg+7fJaLm2Dya9/Q6+EKCaNJP8mzgWyDav+lvSJ+y88SIF8yWEeKT8 44qQ== 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=I0HOJK6IuhM1eJwwi1xjLp9DFk6lb+9jdQCLrelvMfU=; b=TFlEzRSAt4D7aReKsAnAOr/LPkORQlmcejFo2GBJBpky/vtBcMgiZA6r9XZ1v/ZAJI rQERDsX3Hka4oydMTOfdgCjgaJPUUKFsUdKlP/qitCK0js/NBJfgFE7ZQRhJqgEPoS+u 5hvhcvQtDtlTKtWm/YUW62DjBJIaGGWpcpBrQtkcvBnBsguhq4SlmXJRqYURQyoVIrqp idqXDoNMN1U90Kc6qysuUEj+k6xOfiAeqXTyabZ9fQl0uh70vVPBj0qfbRBpWuAzz29A PUcnf4JksUIN2BqfY7jX85j3HiXyTZk65qHRlFl29a0SU2bT4ATSifmbuE15HjsEkWBy /MXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zx+bAoK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f22-20020a631016000000b00398a43dd2f3si14833764pgl.103.2022.04.05.16.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zx+bAoK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D70F1D7DBD; Tue, 5 Apr 2022 16:41:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384630AbiDEM1t (ORCPT + 99 others); Tue, 5 Apr 2022 08:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245208AbiDEIyN (ORCPT ); Tue, 5 Apr 2022 04:54:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12C315FB5; Tue, 5 Apr 2022 01:52:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id A79D8B81BC0; Tue, 5 Apr 2022 08:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4CB8C385A1; Tue, 5 Apr 2022 08:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148723; bh=ZpYxQzMbWq9VFdzbyTTC+uP5ynNLub8AhNQdYd8W74o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zx+bAoK7wfYOQNaWmj1B9YdS044gGFrP6V4hUkxo06CfTDUg8DhPadwPvcur16h3c svAA574J0Bot3s0l7csdx115TED66Pr8ghYmK02cczmtwTMNoB504O7Fwp2ZQREHDF QovkXVB0nSpNvtJNCkYV7EFNuUGuC/M0T7h5VrpQ= 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.16 0457/1017] mt76: mt7921: fix a leftover race in runtime-pm Date: Tue, 5 Apr 2022 09:22:50 +0200 Message-Id: <20220405070407.864554065@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 591cdccebdd4d02eb46d400dea911136400cc567 ] Fix a possible race in mt7921_pm_power_save_work() if rx/tx napi schedules ps_work and we are currently accessing device register on a different cpu. Fixes: 1d8efc741df8 ("mt76: mt7921: introduce Runtime PM support") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index fc21a78b37c4..1fea9266d4b8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1472,6 +1472,14 @@ void mt7921_pm_power_save_work(struct work_struct *work) test_bit(MT76_HW_SCHED_SCANNING, &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