From patchwork Wed May 17 10:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 95168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1044620vqo; Wed, 17 May 2023 04:06:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+8Gn2bzbl77So6NQpCNnNus6mEcLVJivh9tuIX12GChs3eujY49g3MlSEAbsHpww42g67 X-Received: by 2002:a05:6a00:138b:b0:648:c1be:496 with SMTP id t11-20020a056a00138b00b00648c1be0496mr498833pfg.22.1684321597560; Wed, 17 May 2023 04:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684321597; cv=none; d=google.com; s=arc-20160816; b=dp9MU4aS8Zo4ZcKx5qjbHObz0UxsrIYoSF5HbW/yd7Ji3OsaX3re+3RwKAcSlJQzdo B2swUj8MNNmLhBYE0Ubzgvi3H/zPsykNaz3uN7dkRQScF3hHQ68O4Ujv6a5aDPsONfVr IsLEsQ8SPWcZWFB6WzuTcGYjBJ5+3gn1KOKeQXgAeZxR0TRDeYhu85DnRz3ooiYN4Xkr C/6e7DsjMYFFqwC1EDDTnjV8pCyFaQBwNOKaUHuv3MZatk7gclm8qyhzy5y2TPeDjEm0 D/d+2U1yga1/CmOgL5+sxhMK/s8sDfdorTv0KqMB4sJ+1E37CwTrviRiTn2P3ABicJga bz3Q== 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/nUQqCUOwf7H1lG/oDKWKjg5tOQQEwgVShCL/0I5LE=; b=DHa4WP+HRFeZ1r9SDsQLV8gjZt3kIFPOM6BSgoceCBaMefCT/PBob2UdCp/bH85U7w 2lcpc65xtoUCVdRwg1hTvM+d22bE6QGa4kfaX1aIGBWtDpRQoBuHOpSkph1gbd55Q64p yzUlvv6tVNSGAhNz5PL2qxv2P6s4VRGkyFIjb7gKVEty8DdZZ4G80TVuOqFANlnkYIzE 5YUFtjLmpvoXWmWo7DBucmP9a0GCaQ4WJGtP1x3db90J+CY1YK4OwJk4ZFwbAg4+RHlT pOOTFhdZamwU7cq86V2UUSV6pu5WL6XmmLE4JyGz5mgVVNlPSNyYaj0v+Scb7/AZtlTR eZ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Hbus/kkr"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020aa79561000000b0064398136d6esi22197151pfq.132.2023.05.17.04.06.22; Wed, 17 May 2023 04:06:37 -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="Hbus/kkr"; 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 S230096AbjEQK63 (ORCPT + 99 others); Wed, 17 May 2023 06:58:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjEQK61 (ORCPT ); Wed, 17 May 2023 06:58:27 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 544B24EE4; Wed, 17 May 2023 03:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684321076; x=1715857076; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GAwPOA0tQmE3vBPrO0FLOM6LBo5LJsgKdd/0NNFNf9o=; b=Hbus/kkrrkWb6Jz6YK+itFYDBqwBX2+VBpTFklzOglsGnH3WwZOFNQ0r bTDWZp6C5cJ8CPOlXZFERy/yCkuHbIQ9WE2nMNMhi619R5UPIfV+8Bgz7 pMZn47vMHf9f9TqW6CTNW8APbJmNMm+uSajv8upGHf1Y66TMUKuJpuvGD JMJD/ARKfhKlbGQqappfgsReP+u4CLg69qnKC3pc1NaV7UhmLCkn7d6+B sxZI6SaNfZW1F/AMOIOIy4YBs93QpnX2Tg1jAp/dVMelkRL6WnFp4YYHy 9ZXpOgWBR5JhNj9top9OKbbVFvg7KJxBZxzyBN3CrE52SgTg0tdh7JWF0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="438071758" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="438071758" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 03:53:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="734651211" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="734651211" Received: from lnstern-mobl1.amr.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.251.221.185]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 03:53:38 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Emmanuel Grumbach , "Rafael J . Wysocki" , Heiner Kallweit , Lukas Wunner , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Carl Huang , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dean Luick , Andy Shevchenko , =?utf-8?q?Ilpo_J=C3=A4?= =?utf-8?q?rvinen?= , stable@vger.kernel.org Subject: [PATCH v2 7/9] wifi: ath11k: Use RMW accessors for changing LNKCTL Date: Wed, 17 May 2023 13:52:33 +0300 Message-Id: <20230517105235.29176-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230517105235.29176-1-ilpo.jarvinen@linux.intel.com> References: <20230517105235.29176-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766139203823143003?= X-GMAIL-MSGID: =?utf-8?q?1766139203823143003?= 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 do proper locking to avoid losing concurrent updates to the register value. On restore, clear the ASPMC field properly. Fixes: e9603f4bdcc0 ("ath11k: pci: disable ASPM L0sLs before downloading firmware") Suggested-by: Lukas Wunner Signed-off-by: Ilpo Järvinen Cc: stable@vger.kernel.org Acked-by: Kalle Valo --- drivers/net/wireless/ath/ath11k/pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c index 7b33731a50ee..6ba4cef6b1c7 100644 --- a/drivers/net/wireless/ath/ath11k/pci.c +++ b/drivers/net/wireless/ath/ath11k/pci.c @@ -581,8 +581,8 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); /* disable L0s and L1 */ - pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, - ab_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); + pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_ASPMC); set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); } @@ -590,8 +590,10 @@ static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) { if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags)) - pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, - ab_pci->link_ctl); + pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_ASPMC, + ab_pci->link_ctl & + PCI_EXP_LNKCTL_ASPMC); } static int ath11k_pci_power_up(struct ath11k_base *ab)