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 3EA85C43334 for ; Wed, 8 Jun 2022 23:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wThTl8PFhVXcNOQDIEpcnpVD5wDs/Ph7NX8hDZ65RYo=; b=gjvIwp1ovAsBt6 tuclG9xEYiX0/jm01yaEABgYDmZLmw6owmGW8cCsgY1Bi2q1v9M4cYmx9+JJ5bFMYaR23BvBCvLdr V9iSbmYBguSXwYGiUmzQJMJ45N4/tSCMM4Vy+LkqDYpUp9Cg/igl36O0EEh0WlSfYNtLfb3+fZZCv w4IUKXhioLSa1REGLDK9npyaZk71GPyPXoMf65Bn1dDUHiGUH52giuJ0ucKBG+yoQ5T0Bo7KWq5oL S6YSNwA67p6V2/Qnjx5EhyLdtz1312Bhx3B06SBBUI4TlBD8XmPrLCn7fZScJmrHwP7rQbuo3Wee9 xrI0FqtxIyoloJuC8Awg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nz4ex-00FCwN-ST; Wed, 08 Jun 2022 23:00:19 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nz4et-00FCvT-Q8 for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 23:00:17 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id AFC80B82B93; Wed, 8 Jun 2022 23:00:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F93C34116; Wed, 8 Jun 2022 23:00:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654729212; bh=JZmu1SU0V7QTJVGAH6DytmdJ+Pdq1qgCXSsZHp2+VrQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dxkKU2M+F1uHGb88/xUI3l2cG2eaZbSugK6S2ZLDZgBR04f1POAM5WriFpil6k1m5 vWsdLd0ogrmYqVquWWc0LbfhbnEgJ4ZIilcmq1odq1oR49b32xtGOvjOOunClU3V1d YoTp9EKrdo2/CWayu/YtvWfrIdk9A5qPUK/OwMl7BIPNF4F+qiwIW+4i1o4IKGHTYX sD9rxvKl1K+OW+XfzSVeLoZAYGoJaJbp3yPC5iYDKEuIWoTRroVbcqOog3x4KsEvpm WGMWgVFrjIR35XCg0ilfsBFCKzvWxwxhaFKfGxwkdZPKZlFsaqqLwcbsI6PKzxr/CL vZtZTcLENaGOw== Received: by pali.im (Postfix) id E913D2191; Thu, 9 Jun 2022 01:00:08 +0200 (CEST) Date: Thu, 9 Jun 2022 01:00:08 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Baruch Siach Cc: Andy Gross , Bjorn Andersson , Baruch Siach , Selvam Sathappan Periakaruppan , Kathiravan T , Bjorn Helgaas , Rob Herring , Thierry Reding , Jonathan Hunter , Jingoo Han , Gustavo Pimentel , Robert Marko , Bryan O'Donoghue , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH v6 2/3] PCI: qcom: Define slot capabilities using PCI_EXP_SLTCAP_* Message-ID: <20220608230008.acp6lwu6xjin62ql@pali> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_160016_197340_0C094AA1 X-CRM114-Status: GOOD ( 18.11 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Monday 07 February 2022 16:51:25 Baruch Siach wrote: > From: Baruch Siach > > The PCIE_CAP_LINK1_VAL macro actually defines slot capabilities. Use > PCI_EXP_SLTCAP_* macros to spell its value, and rename it to better > describe its meaning. > > Signed-off-by: Baruch Siach > --- > drivers/pci/controller/dwc/pcie-qcom.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index c19cd506ed3f..01e58b057d2a 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -69,7 +69,18 @@ > #define PCIE20_AXI_MSTR_RESP_COMP_CTRL1 0x81c > #define CFG_BRIDGE_SB_INIT BIT(0) > > -#define PCIE_CAP_LINK1_VAL 0x2FD7F > +#define PCIE_CAP_SLOT_POWER_LIMIT_VAL 0x7D00 > +#define PCIE_CAP_SLOT_POWER_LIMIT_SCALE 0x8000 Hello! Please do not use hardcoded values for slot power limit value and scale numbers. There are macros PCI_EXP_SLTCAP_SPLV and PCI_EXP_SLTCAP_SPLS for composing mask: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/pci_regs.h?h=v5.19-rc1#n593 Which could be used together with FIELD_PREP(). See e.g. aardvark commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0d5b8c298545c827ca9f2461b2655277ce0aef79 And the important information: Slot power limit is board specific and depends on how power supply and power regulators are designed. So slot power limit **cannot** be hardcoded in driver. Instead this value should be read from device tree file for the current board. There is a new kernel function of_pci_get_slot_power_limit() which reads it and compose PCIe slot power limit value and scale numbers. See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/of.c?h=v5.19-rc1#n631 > +#define PCIE_CAP_SLOT_VAL (PCI_EXP_SLTCAP_ABP | \ > + PCI_EXP_SLTCAP_PCP | \ > + PCI_EXP_SLTCAP_MRLSP | \ > + PCI_EXP_SLTCAP_AIP | \ > + PCI_EXP_SLTCAP_PIP | \ > + PCI_EXP_SLTCAP_HPS | \ > + PCI_EXP_SLTCAP_HPC | \ > + PCI_EXP_SLTCAP_EIP | \ > + PCIE_CAP_SLOT_POWER_LIMIT_VAL | \ > + PCIE_CAP_SLOT_POWER_LIMIT_SCALE) > > #define PCIE20_PARF_Q2A_FLUSH 0x1AC > > @@ -1111,7 +1122,7 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) > > writel(PCI_COMMAND_MASTER, pci->dbi_base + PCI_COMMAND); > writel(DBI_RO_WR_EN, pci->dbi_base + PCIE20_MISC_CONTROL_1_REG); > - writel(PCIE_CAP_LINK1_VAL, pci->dbi_base + offset + PCI_EXP_SLTCAP); > + writel(PCIE_CAP_SLOT_VAL, pci->dbi_base + offset + PCI_EXP_SLTCAP); > > val = readl(pci->dbi_base + offset + PCI_EXP_LNKCAP); > val &= ~PCI_EXP_LNKCAP_ASPMS; > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel