From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08F84CDB465 for ; Mon, 16 Oct 2023 12:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6Oq8xs4S7PB/+m3pCWz36sxz5z91fVzoe/KG9XMBVyQ=; b=q7U7O/AmofLGNKnor+4StMGriR 664qI1qEiDzXX2kUtPKJwrSAcWlEKtre5Q2VwrMSVBGXfk06GRZcQ2ULt0YHvIpabGSh77d5yMYjR 60YNuPYUHKPmo5UeKIUO7CrSGlRfx1wLD6aHH3jDSbnk2tyfPR86ahR1raS3HcWpCvVtqNGVIhXzd YWRA+kgWW14AypXmolltpWm40RPL2auZmptnAROT0bCYNlKgBVsnLnzOEp8OxtRciG3ghirnOI2nG 2wfj6jRBT3lYR9hCrdF9yaapMKz9dtc2WmqOlYJodmf8/pwDtZeoCKlRLwfTf1aGi8U7T23wHp2Yh jo5YroCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9p-009evC-1p; Mon, 16 Oct 2023 12:57:17 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9m-009euW-1l; Mon, 16 Oct 2023 12:57:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461035; x=1728997035; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=lp+N0iDegos1KqT0YHUk8zJeCMUF891HPeNecMLT7Z88naTNfHsSkcgx QxsDd2OdH3NF6sY33CXGJ4W+CGAtBN77FUNwqpiuOt87MfgdZkxRN9Bet RFydGD5hSKrn3dlXzv3QToJkFQYsOY3JgFlyLabT2FGG2lDaFscvR9Jkj +2CDwF9J9ZAqUy/r21UPBBeql4cOU2JxUlKDVIdLMrB+C5+Hszkz+1P5/ ErO19JsuND5+5Y1ETsrzEzVJLcoUFVaRi7yVk5ahk0RznzNH82YU9Bn+H uRMz7/OESAn0Ioe7hyo4wV0qlPQZ/AMsLSvgfPGb32Xu+fssy3JVhbOQF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130584" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130584" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231016_055714_652251_7F6BD44E X-CRM114-Status: GOOD ( 43.65 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath10k" Errors-To: ath10k-bounces+ath10k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ath10k mailing list ath10k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath10k --8323329-1750157713-1697461032=:1986-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 464FBCDB465 for ; Mon, 16 Oct 2023 12:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9hp7roPJFIQ+ckv9OM6jsni7UGUksP5R/DbZu5sqGjo=; b=vwuqMtS6nGFltqU81qyzccCYTf 9WAA9QdXZ0KR1zFFSnB7pHMe6dGdhJvdn//2WfW+h+Jg3YV3glBeg6I1BufXkm2G2cXvj/XYJoP2S 0KtyuXr2uTFGpWw9Ch5vhbpU0EaXTbOsEEbJq3f6TXQwk807akt86tvyuui7Mk7EbS1h2z8cW2fEk /Vn70n/LJKzFJdqc4Z8e+BN/qle8+Kn/hyI7sKFKAP/lvAEyZbCJQ5de7Lm55vOgLGBgwS1kjfH7V sc8VK1Eip6AgAUimWVcbJvdm5GHexnWlFks6RSztWa7BfTb7ZjVA0gZszr/H/A8PbhRMK66c9iEd4 yqd0a+zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9r-009ewP-1F; Mon, 16 Oct 2023 12:57:19 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9m-009euW-1l; Mon, 16 Oct 2023 12:57:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461035; x=1728997035; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=lp+N0iDegos1KqT0YHUk8zJeCMUF891HPeNecMLT7Z88naTNfHsSkcgx QxsDd2OdH3NF6sY33CXGJ4W+CGAtBN77FUNwqpiuOt87MfgdZkxRN9Bet RFydGD5hSKrn3dlXzv3QToJkFQYsOY3JgFlyLabT2FGG2lDaFscvR9Jkj +2CDwF9J9ZAqUy/r21UPBBeql4cOU2JxUlKDVIdLMrB+C5+Hszkz+1P5/ ErO19JsuND5+5Y1ETsrzEzVJLcoUFVaRi7yVk5ahk0RznzNH82YU9Bn+H uRMz7/OESAn0Ioe7hyo4wV0qlPQZ/AMsLSvgfPGb32Xu+fssy3JVhbOQF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130584" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130584" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231016_055714_652251_7F6BD44E X-CRM114-Status: GOOD ( 43.65 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- ath11k mailing list ath11k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath11k --8323329-1750157713-1697461032=:1986-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 677D5CDB482 for ; Mon, 16 Oct 2023 12:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9Jvq4vhfpSOB8wXl5Ov1tIjd5f8qeamebm8h3bFLuQA=; b=BoGq0FR6YeygvzkZeLOQPhkhv5 Or2J0zaCWr2R0qNA/ici639KB95F9HfjhzptQncGQffI7CfY1wY9MFw7JDAjBwvkJLnqkEbGw3cjD xoj2ng4ZA2sS8eiDTkB0d8WlngM+Tz9lQm8ydMYCUq3Lz3bZXCGwrKA0Dtt3YySgD0j8EA4gpY6rm 8oMTpZZyFm2YHxKM5G2DVN/Pf1GkLyx5IdyHOCgmSI3zRD4GbiboXWW6eTVYgUXeuCTrRWbf8S2eB qH0AABawC0/E4HvhmdibZDEPVKbkyw6ZmYiECpIzsOmPzjhqrn92v8vavIHhrrgsLKm+SapfVjHcG JPxfG3RQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9q-009evT-0R for ath12k@archiver.kernel.org; Mon, 16 Oct 2023 12:57:18 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9m-009euW-1l; Mon, 16 Oct 2023 12:57:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461035; x=1728997035; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=lp+N0iDegos1KqT0YHUk8zJeCMUF891HPeNecMLT7Z88naTNfHsSkcgx QxsDd2OdH3NF6sY33CXGJ4W+CGAtBN77FUNwqpiuOt87MfgdZkxRN9Bet RFydGD5hSKrn3dlXzv3QToJkFQYsOY3JgFlyLabT2FGG2lDaFscvR9Jkj +2CDwF9J9ZAqUy/r21UPBBeql4cOU2JxUlKDVIdLMrB+C5+Hszkz+1P5/ ErO19JsuND5+5Y1ETsrzEzVJLcoUFVaRi7yVk5ahk0RznzNH82YU9Bn+H uRMz7/OESAn0Ioe7hyo4wV0qlPQZ/AMsLSvgfPGb32Xu+fssy3JVhbOQF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130584" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130584" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231016_055714_652251_7F6BD44E X-CRM114-Status: GOOD ( 43.65 ) X-BeenThere: ath12k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath12k" Errors-To: ath12k-bounces+ath12k=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- ath12k mailing list ath12k@lists.infradead.org https://lists.infradead.org/mailman/listinfo/ath12k --8323329-1750157713-1697461032=:1986-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20EE5CDB483 for ; Tue, 17 Oct 2023 17:26:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C62998219A; Tue, 17 Oct 2023 17:26:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C62998219A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1697563570; bh=FJ83ZF1/fARZsLfqjs5MS/ddtBXGU5LzT86lOVtHweo=; h=Date:From:To:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=VsQi3FKE91GOaLGGr7EgYfgDB/Yks2lUPz+mvQjPzLShEpqNOCpq2vYdW12yZSZSR XtrZiqcTTNMI32pvBGILTnDA6mzsYE6Xb8/n4/TSOm4zYAuLPfr4mRjYHFUeweTpd1 NS5v5uwjypyLYneDDa7+Q5zgJMlxcnema75TfUzDQFnB9BByJkeY+YgJHnIbHFfS2u f9VPdRdGn8nWe/s44O3RFW1fVr6jpjFrvds4G1rwCyAGY6CCw4vpeMQ08YZaUyvm7z P+2Jmn3EdBhxlrm67WHPL6AY58jNIpf6BOCOfwPjftd34bdR5zlLPK2CSU42O5TqrQ bgA+a7buFajIQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QBALHG8L1awr; Tue, 17 Oct 2023 17:26:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 89C1182195; Tue, 17 Oct 2023 17:26:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 89C1182195 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 98B4C1BF82D for ; Mon, 16 Oct 2023 12:57:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6F71C611CC for ; Mon, 16 Oct 2023 12:57:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6F71C611CC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jdc1h0CBRoZu for ; Mon, 16 Oct 2023 12:57:14 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2DA0F611C8 for ; Mon, 16 Oct 2023 12:57:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2DA0F611C8 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130585" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130585" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" X-Mailman-Approved-At: Tue, 17 Oct 2023 17:25:58 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461035; x=1728997035; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=lp+N0iDegos1KqT0YHUk8zJeCMUF891HPeNecMLT7Z88naTNfHsSkcgx QxsDd2OdH3NF6sY33CXGJ4W+CGAtBN77FUNwqpiuOt87MfgdZkxRN9Bet RFydGD5hSKrn3dlXzv3QToJkFQYsOY3JgFlyLabT2FGG2lDaFscvR9Jkj +2CDwF9J9ZAqUy/r21UPBBeql4cOU2JxUlKDVIdLMrB+C5+Hszkz+1P5/ ErO19JsuND5+5Y1ETsrzEzVJLcoUFVaRi7yVk5ahk0RznzNH82YU9Bn+H uRMz7/OESAn0Ioe7hyo4wV0qlPQZ/AMsLSvgfPGb32Xu+fssy3JVhbOQF A==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lp+N0iDe Subject: Re: [Intel-wired-lan] [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , linux-rdma@vger.kernel.org, Lorenzo Pieralisi , "Rafael J . Wysocki" , ath12k@lists.infradead.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, LKML , ath10k@lists.infradead.org, ath11k@lists.infradead.org, Emmanuel Grumbach , linux-bluetooth@vger.kernel.org, Lukas Wunner , intel-wired-lan@lists.osuosl.org, Netdev , Bjorn Helgaas , linux-mediatek@lists.infradead.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Heiner Kallweit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan --8323329-1750157713-1697461032=:1986-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9903C41513 for ; Mon, 16 Oct 2023 12:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233266AbjJPM5R (ORCPT ); Mon, 16 Oct 2023 08:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjJPM5Q (ORCPT ); Mon, 16 Oct 2023 08:57:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 674ABAD; Mon, 16 Oct 2023 05:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461034; x=1728997034; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=Xf/12PbHv7oGM5zCun8OHZP2oOMZxmhEH6ZJ5/lUhqXfYAqUQEckGFxg uhBxh6kGxA949FC6FN2zZBWyvKJUifUexGABTLbcEAf1OWjx7mkTVa8Th xcjaHeb44AZsDmv4pcw7gCTgvOCLukytu2kdP8klIQpb52JMIVDCQIG4w L1wXdn9S2w13DghDuKXdK3k7ITNbCmmBqcE7MLPz8phNpEUDr+k3GznJW WWb2zBxOO8yfgVXUiNz7waOrIXsq+sVisX6XfG9x/jLpM0Arh3YOUHPEd Uq4Y8ewK7wuy0L394EulosARaZq0Chiyy9OV9IB39oKpZLPVvwycCESLJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130579" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130579" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83662CDB482 for ; Mon, 16 Oct 2023 12:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HWubfbJhB8fY84ptyMo6cRwVpJifuDfTQCSe++gOguI=; b=Hsgzy3Z33kNkQQHrwwTd+Q+b8V CmwrSjZJTdlpe6vjPlAulX9dZ2kXz27+ThqNJOMd79+o6VXBRLSMlxOKpgn065a2254AstbfxK263 ZF1nmwfO67mTbNvaXWJoS5au0MFnetxVDeksYZxYFarPoSlBbR3Hy0ZiU7b3NGnuWuULnMAQHhNcH VBhnFQLorw+NjBpp6hrzwvd82Lx/T2l1/M9vKh1PWND2zBV+HKe4YTIaQl/NbC7gXrfpGt50faXUR rDGh661Tn6mYNdSJsqCg360JymVuZkAnz4ieaJH/8qJjWZEBExxRO55yeH1zDQTAB5QAOW6rmANb0 X+JphgeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9q-009evn-1o; Mon, 16 Oct 2023 12:57:18 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsN9m-009euW-1l; Mon, 16 Oct 2023 12:57:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697461035; x=1728997035; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=33VN831uWAKG7f4eIn44PpDJgWUV0McuEtJM+oSWIh4=; b=lp+N0iDegos1KqT0YHUk8zJeCMUF891HPeNecMLT7Z88naTNfHsSkcgx QxsDd2OdH3NF6sY33CXGJ4W+CGAtBN77FUNwqpiuOt87MfgdZkxRN9Bet RFydGD5hSKrn3dlXzv3QToJkFQYsOY3JgFlyLabT2FGG2lDaFscvR9Jkj +2CDwF9J9ZAqUy/r21UPBBeql4cOU2JxUlKDVIdLMrB+C5+Hszkz+1P5/ ErO19JsuND5+5Y1ETsrzEzVJLcoUFVaRi7yVk5ahk0RznzNH82YU9Bn+H uRMz7/OESAn0Ioe7hyo4wV0qlPQZ/AMsLSvgfPGb32Xu+fssy3JVhbOQF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="4130584" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="4130584" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1087063948" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087063948" Received: from rhaeussl-mobl.ger.corp.intel.com (HELO bhoerz-mobl1.ger.corp.intel.com) ([10.252.59.103]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 05:57:07 -0700 Date: Mon, 16 Oct 2023 15:57:05 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Bjorn Helgaas cc: linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?ISO-8859-2?Q?Krzysztof_Wilczy=F1ski?= , Lukas Wunner , "Rafael J . Wysocki" , Heiner Kallweit , Emmanuel Grumbach , LKML , Bjorn Helgaas , 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 Subject: Re: [PATCH v2 05/13] PCI/ASPM: Add pci_enable_link_state() In-Reply-To: <20231013164850.GA1118214@bhelgaas> Message-ID: <9da430a3-9336-8e75-7385-3d5ddcb6cb7@linux.intel.com> References: <20231013164850.GA1118214@bhelgaas> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1750157713-1697461032=:1986" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231016_055714_652251_7F6BD44E X-CRM114-Status: GOOD ( 43.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Fri, 13 Oct 2023, Bjorn Helgaas wrote: > On Thu, Oct 12, 2023 at 03:53:39PM +0300, Ilpo Järvinen wrote: > > On Wed, 11 Oct 2023, Bjorn Helgaas wrote: > > > On Mon, Sep 18, 2023 at 04:10:55PM +0300, Ilpo Järvinen wrote: > > > > pci_disable_link_state() lacks a symmetric pair. Some drivers want to > > > > disable ASPM during certain phases of their operation but then > > > > re-enable it later on. If pci_disable_link_state() is made for the > > > > device, there is currently no way to re-enable the states that were > > > > disabled. > > > > > > pci_disable_link_state() gives drivers a way to disable specified ASPM > > > states using a bitmask (PCIE_LINK_STATE_L0S, PCIE_LINK_STATE_L1, > > > PCIE_LINK_STATE_L1_1, etc), but IIUC the driver can't tell exactly > > > what changed and can't directly restore the original state, e.g., > > > > > > - PCIE_LINK_STATE_L1 enabled initially > > > - driver calls pci_disable_link_state(PCIE_LINK_STATE_L0S) > > > - driver calls pci_enable_link_state(PCIE_LINK_STATE_L0S) > > > - PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 are enabled now > > > > > > Now PCIE_LINK_STATE_L0S is enabled even though it was not initially > > > enabled. Maybe that's what we want; I dunno. > > > > > > pci_disable_link_state() currently returns success/failure, but only > > > r8169 and mt76 even check, and only rtl_init_one() (r8169) has a > > > non-trivial reason, so it's conceivable that it could return a bitmask > > > instead. > > > > It's great that you suggested this since it's actually what also I've been > > started to think should be done instead of this straightforward approach > > I used in V2. > > > > That is, don't have the drivers to get anything directly from LNKCTL > > but they should get everything through the API provided by the > > disable/enable calls which makes it easy for the driver to pass the same > > value back into the enable call. > > > > > > Add pci_enable_link_state() to remove ASPM states from the state > > > > disable mask. > > > > > > > > Signed-off-by: Ilpo Järvinen > > > > --- > > > > drivers/pci/pcie/aspm.c | 42 +++++++++++++++++++++++++++++++++++++++++ > > > > include/linux/pci.h | 2 ++ > > > > 2 files changed, 44 insertions(+) > > > > > > > > diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c > > > > index 91dc95aca90f..f45d18d47c20 100644 > > > > --- a/drivers/pci/pcie/aspm.c > > > > +++ b/drivers/pci/pcie/aspm.c > > > > @@ -1117,6 +1117,48 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) > > > > } > > > > EXPORT_SYMBOL(pci_disable_link_state); > > > > > > > > +/** > > > > + * pci_enable_link_state - Re-enable device's link state > > > > + * @pdev: PCI device > > > > + * @state: ASPM link states to re-enable > > > > + * > > > > + * Enable device's link state that were previously disable so the link is > > > > > > "state[s] that were previously disable[d]" alludes to the use case you > > > have in mind, but I don't think it describes how this function > > > actually works. This function just makes it possible to enable the > > > specified states. The @state parameter may have nothing to do with > > > any previously disabled states. > > > > Yes, it's what I've been thinking between the lines. But I see your point > > that this API didn't make it easy/obvious as is. > > > > Would you want me to enforce it too besides altering the API such that the > > states are actually returned from disable call? (I don't personally find > > that necessary as long as the API pair itself makes it obvious what the > > driver is expect to pass there.) > > This was just a comment about the doc not matching the function > behavior. > > I think we have to support pci_enable_link_state() even if the driver > hasn't previously called pci_disable_link_state(), so drivers have to > be able to specify the pci_enable_link_state() @state from scratch. > > Does that answer the enforcement question? Yes. -- i. > I don't think we can > really enforce anything other than that @state specifies valid ASPM > states. > > Bjorn > --8323329-1750157713-1697461032=:1986 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323329-1750157713-1697461032=:1986--