Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp263759rdb; Mon, 18 Sep 2023 14:30:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx6gfmfjNL9MPvPg+UtKYJmEI+5NdA0nGGHMgsIiE6s27IiehQIhoXx2q/ILzIdn7O0HwI X-Received: by 2002:a17:90a:dac4:b0:26d:d81:82fb with SMTP id g4-20020a17090adac400b0026d0d8182fbmr7246679pjx.29.1695072628374; Mon, 18 Sep 2023 14:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695072628; cv=none; d=google.com; s=arc-20160816; b=NYExcGv960BmNqRNVAT0ZAdzg5avd3+/YZaIFt450EDI9e0d1J2xruDc53x84nJtyc 9KgkVaLis6CgKBxp7a21hxyUtI28JASvVNdq+XYRhtoYD49/1hMKAo50056Uw5WjvVgy L8CywaFnbj4IlgAYGBJJR5+1/L+clfue8iYYnhp3N/lypnC05I976ZsyYXH4WEr4vs2S fW43FPM4xNZzqyAVgs8BMoaswJijm7VoVnS90t0dGxiymc1qaqYTChtfwNuBfVjpXH8G B4SCiy0van3uEkc8pWITPf60wO7nXZFFqWDvmAkBQNHIJJpUwScjtruPtnkZ5u0kDUQS TwLw== 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=UCfLuylS5mlTJri5OrkWw39dG1L9JsgH5woxfhcXej4=; fh=V/jkFcPu7MmAy3MJPsn2heI/qTpS90GSlS8FQJiXILA=; b=NenV5B4jZ906WmkOKTD5MwKTc11szID2hBjWuJcj8fWyOGAU/Rw7oG+6IBbhXBgxri sOyf5Nu3KWyJmzGD/sHbF47TnzGWz+opmcxLWHC32O5vNXOnUDQVDBvPwFea35zsSLzt fBScmKe1KA/vEoDA8Apmv1xfZe28lAST3EgXgGNum7np9hej2dw7hD2WGg+ahU/8mBb4 EEW7K9tWPLaHykVRTf3ycNduB/CQTuZk+DRoJI+Cq0+r9xchpouQj7YvPLYC9OW/6j9c ggkBt3Z6udmUZWKkOcka8naJ1YQK5QFvnNdto85HS/6JLwFQo0SuDfRXsMR71gvY9DZm T35Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NPsXbfSc; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id rm12-20020a17090b3ecc00b00273e22de340si11410975pjb.0.2023.09.18.14.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 14:30:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NPsXbfSc; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1DA2D80D44EB; Mon, 18 Sep 2023 09:32:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbjIRQce (ORCPT + 99 others); Mon, 18 Sep 2023 12:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbjIRQcY (ORCPT ); Mon, 18 Sep 2023 12:32:24 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1236EF9; Mon, 18 Sep 2023 09:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695053862; x=1726589862; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/jlflr+zDO/ybJEIj9ZeNbSBAg1LjrmA0JjnTT6qqL0=; b=NPsXbfSc9IPT94hOIIrNw/67t2VR+JhPjuDVykOsCKaDlVXy2p+FMbTA GTb86C7h+BuEfgDYFoHleY31PYmFwn/JH8Z1iIw50IMRKQR1XxT7Sglow iO58ySRv3gMvX59UGQVNeZ+Lrwfv1wAJgTIAyuMJHMlJ+kDDHAXYTmBBR NLJh7geSMk+NKR69+b8rXsbggqJvVRD9Q4Wt3JQ0PtG6rj1NjBzMomEcZ xc3dogm5JFgKGATaztjOSUtj9IudJWsZFo5qGdP2p6+6QXGWpWWgYtBvc eBeG7AIRRca48GUX44UpUlqM7o9nm231xa//lVetXTgoWmsg+n4N4/B/F g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446113641" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="446113641" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:14:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811343218" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="811343218" Received: from nprotaso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.49.156]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 06:13:54 -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?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , linux-kernel@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman Cc: ath10k@lists.infradead.org, ath11k@lists.infradead.org, ath12k@lists.infradead.org, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 13/13] misc: rtsx: Use pci_disable/enable_link_state() Date: Mon, 18 Sep 2023 16:11:03 +0300 Message-Id: <20230918131103.24119-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230918131103.24119-1-ilpo.jarvinen@linux.intel.com> References: <20230918131103.24119-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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:32:37 -0700 (PDT) rtsx driver adjusts ASPM state itself which leaves ASPM service driver in PCI core unaware of the link state changes the driver implemented. Call pci_disable_link_state() and pci_enable_link_state() instead of adjusting ASPMC field in LNKCTL directly in the driver and let PCI core handle the ASPM state management. Signed-off-by: Ilpo Järvinen --- drivers/misc/cardreader/rts5228.c | 6 ++---- drivers/misc/cardreader/rts5261.c | 6 ++---- drivers/misc/cardreader/rtsx_pcr.c | 8 +++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/misc/cardreader/rts5228.c b/drivers/misc/cardreader/rts5228.c index f4ab09439da7..8d3216c64ad1 100644 --- a/drivers/misc/cardreader/rts5228.c +++ b/drivers/misc/cardreader/rts5228.c @@ -497,8 +497,7 @@ static void rts5228_enable_aspm(struct rtsx_pcr *pcr, bool enable) val = FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; val |= (pcr->aspm_en & 0x02); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, pcr->aspm_en); + pci_enable_link_state(pcr->pci, pcr->aspm_en); pcr->aspm_enabled = enable; } @@ -509,8 +508,7 @@ static void rts5228_disable_aspm(struct rtsx_pcr *pcr, bool enable) if (pcr->aspm_enabled == enable) return; - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0); + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); mask = FORCE_ASPM_VAL_MASK | FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; val = FORCE_ASPM_CTL0 | FORCE_ASPM_CTL1; rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); diff --git a/drivers/misc/cardreader/rts5261.c b/drivers/misc/cardreader/rts5261.c index 94af6bf8a25a..f1ef15683a2f 100644 --- a/drivers/misc/cardreader/rts5261.c +++ b/drivers/misc/cardreader/rts5261.c @@ -578,8 +578,7 @@ static void rts5261_enable_aspm(struct rtsx_pcr *pcr, bool enable) val |= (pcr->aspm_en & 0x02); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, pcr->aspm_en); + pci_enable_link_state(pcr->pci, pcr->aspm_en); pcr->aspm_enabled = enable; } @@ -591,8 +590,7 @@ static void rts5261_disable_aspm(struct rtsx_pcr *pcr, bool enable) if (pcr->aspm_enabled == enable) return; - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, 0); + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); rtsx_pci_write_register(pcr, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0); udelay(10); diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c index a3f4b52bb159..6efb792152f2 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -86,9 +86,11 @@ static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable) return; if (pcr->aspm_mode == ASPM_MODE_CFG) { - pcie_capability_clear_and_set_word(pcr->pci, PCI_EXP_LNKCTL, - PCI_EXP_LNKCTL_ASPMC, - enable ? pcr->aspm_en : 0); + if (enable) + pci_enable_link_state(pcr->pci, pcr->aspm_en); + else + pci_disable_link_state(pcr->pci, PCIE_LINK_STATE_L0S | + PCIE_LINK_STATE_L1); } else if (pcr->aspm_mode == ASPM_MODE_REG) { if (pcr->aspm_en & 0x02) rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, FORCE_ASPM_CTL0 | -- 2.30.2