[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250611163215.861242-1-18255117159@163.com>
Date: Thu, 12 Jun 2025 00:32:15 +0800
From: Hans Zhang <18255117159@....com>
To: lpieralisi@...nel.org,
bhelgaas@...gle.com,
mani@...nel.org,
kwilczynski@...nel.org
Cc: robh@...nel.org,
jingoohan1@...il.com,
linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org,
Hans Zhang <18255117159@....com>
Subject: [PATCH 11/13] PCI: dwc: Refactor qcom-ep to use dw_pcie_clear_and_set_dword()
Qcom PCIe endpoint driver implements L0s/L1 latency configuration through
manual register manipulation. The current approach reads LNKCAP register,
modifies specific latency fields, then writes back the value. This pattern
repeats twice with similar logic but different bit masks.
Replace explicit latency configuration with dw_pcie_clear_and_set_dword().
The helper combines field clearing and setting in a single operation,
replacing three-step manual sequences. Initialize the set value with
FIELD_PREP() to clearly express the intended bitfield value.
This refactoring reduces code duplication in latency configuration paths
and improves maintainability. Using the standard helper ensures consistent
handling of capability registers and simplifies future updates to ASPM
settings.
Signed-off-by: Hans Zhang <18255117159@....com>
---
drivers/pci/controller/dwc/pcie-qcom-ep.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c
index bf7c6ac0f3e3..c2b4f172385d 100644
--- a/drivers/pci/controller/dwc/pcie-qcom-ep.c
+++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c
@@ -475,17 +475,15 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
/* Set the L0s Exit Latency to 2us-4us = 0x6 */
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
- val &= ~PCI_EXP_LNKCAP_L0SEL;
- val |= FIELD_PREP(PCI_EXP_LNKCAP_L0SEL, 0x6);
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, val);
+ dw_pcie_clear_and_set_dword(pci, offset + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_L0SEL,
+ FIELD_PREP(PCI_EXP_LNKCAP_L0SEL, 0x6));
/* Set the L1 Exit Latency to be 32us-64 us = 0x6 */
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
- val &= ~PCI_EXP_LNKCAP_L1EL;
- val |= FIELD_PREP(PCI_EXP_LNKCAP_L1EL, 0x6);
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, val);
+ dw_pcie_clear_and_set_dword(pci, offset + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_L1EL,
+ FIELD_PREP(PCI_EXP_LNKCAP_L1EL, 0x6));
dw_pcie_dbi_ro_wr_dis(pci);
--
2.25.1
Powered by blists - more mailing lists