Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1014745pxb; Wed, 6 Apr 2022 06:45:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKihfU+GgHsDOQLVOmtskIik+68Jhbgu9nhz+EhGrcCyUmUlwu11bJqdC8qeCk17xnp63y X-Received: by 2002:a17:902:ecd1:b0:154:5393:aaa4 with SMTP id a17-20020a170902ecd100b001545393aaa4mr8489026plh.131.1649252753879; Wed, 06 Apr 2022 06:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252753; cv=none; d=google.com; s=arc-20160816; b=FuGPXaQ9WGM/3VUGl7VcfDUrXZZuM+ifDCQhKZwWy4fw70l5oHnxcCIemtxerW5vi9 8BmNYOmNO5liQXLCZeXPXD9bStLkTy8SyVNYku1ZXW3HGQVOeMuwsI85NqzIIpgbOm79 sf43Bwa7CxF57399N6vru8BD961pwAGkZ2czUwPMlIu228huzut5gww76bwmDPX7DSlX PSJ5cLTpBRiM7zHdP9sXTNSUwVBziXZn9cqi31PR9Gu3A7oJai6JV/9FviBbCl35rOsF lAAJ9M6JP2YU1QmLMad7+N8hfULjAbgzLESpzLcQorOQNNnsopI2pzRdEZik19G0be54 ps3g== 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=8YNpaTTwe4a+phncCzKq/e4CZmt7kANHg9TyHd2unYg=; b=H8URRx4j1Kuu0CiaHLXtjYYSA9D5a1fhJvhdrwkOnJvM9+hBX1s95ZeAHCXH1NnLw5 kAmKg0qa+SZ+Dg+ZDa+LFNWl5sAXYwvQVa8TLOHMnc9qM9Xb6ifhPI+e0W0p7hPGr7nA orbP5kh4NuHylVTqVLuzCLjsQqcObFL1rkzFUcpJbqr2Bu8t/tEQDtdyBSYd8qhj9gH1 0tD3Ed/18wEdjIK02VszgFNEDJah1UZ3Br1M+OfLEKp24LVg7EVPlzmgJksdTtUhVD1m A1/GJYGecsR8QhbH0RuUGeo4x84HGokAEc5qNc9bjsJ1QJur0+eC6lGqCk9BVnpV+Uil hpjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=grJ19rz0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id i11-20020a17090a64cb00b001c6fdf85547si4716789pjm.88.2022.04.06.06.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:45:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=grJ19rz0; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 7098F6F0378; Wed, 6 Apr 2022 04:38:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442114AbiDFBAD (ORCPT + 99 others); Tue, 5 Apr 2022 21:00:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348923AbiDEJss (ORCPT ); Tue, 5 Apr 2022 05:48:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A584EE4F2; Tue, 5 Apr 2022 02:37:41 -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 364B66164D; Tue, 5 Apr 2022 09:37:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 438BFC385A0; Tue, 5 Apr 2022 09:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151460; bh=FsqVb7UY4dwPIR3FljaqZy0qpdr4pSnoSN/L8zEspPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grJ19rz0icPRHRPlUAGg4Ko8/e8hXQnMo1YHSokXGaGtvdzavduBsOS0KngDesZT6 sdGM2trRwAbeKycC1Y8UlvLCNubV5ZLCN1oex67UzMPM/qoKSXzpoEVUyjvCalx+yB hpKJcwQ0Jgco7p44UjD8wmchhl/EsTcWr7V0lk8U= 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.15 424/913] mt76: mt7921: fix a leftover race in runtime-pm Date: Tue, 5 Apr 2022 09:24:46 +0200 Message-Id: <20220405070352.554938115@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 04a288029c98..c093920a597d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -1550,6 +1550,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