Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5506841rwp; Mon, 17 Jul 2023 05:27:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPVTxurWPDJwv7qGaVsJQyD7CPVtzpC1iI0u7OOdI1xKj6wB9wVNiNronFVzoM9jrNYTXC X-Received: by 2002:a05:651c:112:b0:2b9:43a7:376e with SMTP id a18-20020a05651c011200b002b943a7376emr1162695ljb.29.1689596867431; Mon, 17 Jul 2023 05:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689596867; cv=none; d=google.com; s=arc-20160816; b=0jua/Asu/Y7386+lK336T69gtLIo+Dei38HW5t3I+pt401N1EC/Es09079hpfLkk6K 6gC/Zyjuy6iYilinGiEoj1Ky5UPjZsARuyFw7GKnF42mmhlIdpY+x6eIHTHV7R64+GQP 4sr1vt61mSWpOXVXAsBb371AN1341psILMcnuOJxE9P0iKrElfxaa96Xv6ge37MaztPh lbr3nZzxZAIKMUy87TKhGpkDm3n067KQtchPWxxxlzoS8zWjAxTcz9S3jF71Za0/9nIp yLcaenZQNrP+t2rfWurom9ZXYN8lwfX7UgT45S+URUKDAZOZZSnnlsFFUrHt9ZJCy0Nb TS3A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u+Pqo2oY8FzT9sKS7Qm9/zJUdGVGrBdrDqJHLHMbpys=; fh=MlhFwdKozBn8La55vcPzBESZs2gGEswQzya+8yZ+81g=; b=Ifqp/z8Tv5gFFTVIGJGf8/Ep+yk+YxwDq45205ErwuJ0+BBp41aIe8wVSz+0dHfCHQ 5jxxj41GxQquQUwb0R6eZbxY9CXKzV+qTqD5e1+VSYxUq5xu5uH1XME9bXj85zfwjU3d 9rRMNvLS5zNcWzdUMUx3IUZLsKFvPIJEyA31h8O/GcIU0gDhvQ1zN+CvKYZCnwHNAlRZ N6zAYJ6QouhBOTvUUfPvKUNP8OefOhrp8yVO8efmoVaksrYqThSP9rYqdEcfHg2ys1j/ BWadO2voTs6h66BSm+0tB04lqogPf4ohXvXIAogOzq5jrs1HpntFM80c+G8i5VeigFCE +F4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e4moeCEt; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kf25-20020a17090776d900b009930d1379a0si5515185ejc.885.2023.07.17.05.27.23; Mon, 17 Jul 2023 05:27:47 -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=@intel.com header.s=Intel header.b=e4moeCEt; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbjGQMHi (ORCPT + 99 others); Mon, 17 Jul 2023 08:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbjGQMHe (ORCPT ); Mon, 17 Jul 2023 08:07:34 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB9C1710; Mon, 17 Jul 2023 05:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689595634; x=1721131634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AAJmAZ+sXj0MECM7XPTmd1pa5VhGBIS57bxBnXZUE7M=; b=e4moeCEtKM/OyMXwPwNQWZnQkSS1KjTyGkCYs9QvCSY377wuzxhCI3Sn 858mLmORVV/PREb9WburAjKpuBhbnD6p/9lBDzOebWxTIHL/As+yX8nrJ PkYh2V/XRGluxjpM9bdiNasDVMO3Ua3dt9dAwzNAeH1d7F8FBN6X59e44 QLzN2wy0058LrJRnSgptxWwrSe5oJ0PaaOISaL5ocOs07bvkYZh7rRh2d b6az3VDzPi/dGtrZp9oeavGEhnX20dWGyVCbFCb3XLwUK0z71+tlT2FK+ 7xTBDnBznx8xizcq5vZtbYRnJ4KWxAqCV3t2jrAhllCNZMCx0WOT92ash w==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="432081920" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="432081920" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 05:07:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="752876404" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="752876404" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 05:06:55 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Emmanuel Grumbach , "Rafael J . Wysocki" , Heiner Kallweit , Lukas Wunner , Andy Shevchenko , Kalle Valo , Michal Kazior , Janusz Dziedzic , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dean Luick , =?UTF-8?q?Jonas=20Dre=C3=9Fler?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Simon Horman , stable@vger.kernel.org Subject: [PATCH v5 10/11] wifi: ath10k: Use RMW accessors for changing LNKCTL Date: Mon, 17 Jul 2023 15:05:02 +0300 Message-Id: <20230717120503.15276-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717120503.15276-1-ilpo.jarvinen@linux.intel.com> References: <20230717120503.15276-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Don't assume that only the driver would be accessing LNKCTL. ASPM policy changes can trigger write to LNKCTL outside of driver's control. Use RMW capability accessors which does proper locking to avoid losing concurrent updates to the register value. On restore, clear the ASPMC field properly. Fixes: 76d870ed09ab ("ath10k: enable ASPM") Suggested-by: Lukas Wunner Signed-off-by: Ilpo Järvinen Reviewed-by: Simon Horman Acked-by: Kalle Valo Cc: stable@vger.kernel.org --- drivers/net/wireless/ath/ath10k/pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index a7f44f6335fb..9275a672f90c 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1963,8 +1963,9 @@ static int ath10k_pci_hif_start(struct ath10k *ar) ath10k_pci_irq_enable(ar); ath10k_pci_rx_post(ar); - pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, - ar_pci->link_ctl); + pcie_capability_clear_and_set_word(ar_pci->pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_ASPMC, + ar_pci->link_ctl & PCI_EXP_LNKCTL_ASPMC); return 0; } @@ -2821,8 +2822,8 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar, pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL, &ar_pci->link_ctl); - pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, - ar_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); + pcie_capability_clear_word(ar_pci->pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_ASPMC); /* * Bring the target up cleanly. -- 2.30.2