* [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper
@ 2025-08-28 13:59 Hans Zhang
2025-08-28 13:59 ` [PATCH v5 01/13] PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation Hans Zhang
` (13 more replies)
0 siblings, 14 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
From: Hans Zhang <hans.zhang@cixtech.com>
Register bit manipulation in DesignWare PCIe controllers currently
uses repetitive read-modify-write sequences across multiple drivers.
This pattern leads to code duplication and increases maintenance
complexity as each driver implements similar logic with minor variations.
This series introduces dw_pcie_*_dword() to centralize atomic
register modification. The helper performs read-clear-set-write operations
in a single function, replacing open-coded implementations. Subsequent
patches refactor individual drivers to use this helper, eliminating
redundant code and ensuring consistent bit handling.
The change reduces overall code size by ~350 lines while improving
maintainability. Each controller driver is updated in a separate
patch to preserve bisectability and simplify review.
---
Hi all,
At the beginning, two patches were made, 0001*.patch, and the others were
one patch. After consideration, I still split the patches. If splitting
is not necessary, I will recombine them into two patches in future
versions.
Changes for v5:
https://patchwork.kernel.org/project/linux-pci/patch/20250813044531.180411-1-18255117159@163.com/
- According to Mani's reminder, following Lukas' previous suggestion for
another patch, add the dw_pcie_clear/set_dword API.
- Fix the error pointed out by Mani.
- Use the dw_pcie_clear/set_dword API for some of the calls in other patches.
Changes for v4:
https://patchwork.kernel.org/project/linux-pci/cover/20250626145040.14180-1-18255117159@163.com/
- Rebase to v6.17-rc1
Changes for v3:
https://patchwork.kernel.org/project/linux-pci/patch/20250618152112.1010147-1-18255117159@163.com/
- patch 0002: s/u32 val = 0;/u32 val; (pcie-designware-debugfs.c -> set_event_number())
- patch 0013: Remove several val = 0. (Mani)
- patch 0013: s/PCIE_PL_CHK_REG_CONTROL_STATUS/0. (Error in copying the code.) (Mani)
Changes for v2:
- Re-send it in the company environment so that the entire patch series is in the 00/13 cover letter. (Bjorn)
- Modify the subject. (Bjorn and Frank)
---
Hans Zhang (13):
PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation
PCI: dwc: Refactor code by using dw_pcie_*_dword()
PCI: dra7xx: Refactor code by using dw_pcie_*_dword()
PCI: imx6: Refactor code by using dw_pcie_*_dword()
PCI: meson: Refactor code by using dw_pcie_*_dword()
PCI: armada8k: Refactor code by using dw_pcie_*_dword()
PCI: bt1: Refactor code by using dw_pcie_*_dword()
PCI: dw-rockchip: Refactor code by using dw_pcie_*_dword()
PCI: fu740: Refactor code by using dw_pcie_*_dword()
PCI: qcom: Refactor code by using dw_pcie_*_dword()
PCI: qcom-ep: Refactor code by using dw_pcie_*_dword()
PCI: rcar-gen4: Refactor code by using dw_pcie_*_dword()
PCI: tegra194: Refactor code by using dw_pcie_*_dword()
drivers/pci/controller/dwc/pci-dra7xx.c | 10 +-
drivers/pci/controller/dwc/pci-imx6.c | 26 ++--
drivers/pci/controller/dwc/pci-meson.c | 22 ++--
drivers/pci/controller/dwc/pcie-armada8k.c | 43 +++---
drivers/pci/controller/dwc/pcie-bt1.c | 5 +-
.../controller/dwc/pcie-designware-debugfs.c | 48 +++----
.../pci/controller/dwc/pcie-designware-ep.c | 19 ++-
.../pci/controller/dwc/pcie-designware-host.c | 26 ++--
drivers/pci/controller/dwc/pcie-designware.c | 75 +++++------
drivers/pci/controller/dwc/pcie-designware.h | 37 ++++--
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 7 +-
drivers/pci/controller/dwc/pcie-fu740.c | 5 +-
drivers/pci/controller/dwc/pcie-qcom-common.c | 62 +++++----
drivers/pci/controller/dwc/pcie-qcom-ep.c | 14 +-
drivers/pci/controller/dwc/pcie-rcar-gen4.c | 23 ++--
drivers/pci/controller/dwc/pcie-tegra194.c | 122 +++++++-----------
16 files changed, 223 insertions(+), 321 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 01/13] PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 02/13] PCI: dwc: Refactor code by using dw_pcie_*_dword() Hans Zhang
` (12 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
DesignWare PCIe controller drivers implement register bit manipulation
through explicit read-modify-write sequences. These patterns appear
repeatedly across multiple drivers with minor variations, creating
code duplication and maintenance overhead.
Implement dw_pcie_*_dword() helper to encapsulate atomic register
modification. The function reads the current register value, clears
specified bits, sets new bits, and writes back the result in a single
operation. This abstraction hides bitwise manipulation details
while ensuring consistent behavior across all usage sites.
Centralizing this logic reduces future maintenance effort when modifying
register access patterns and minimizes the risk of implementation
divergence between drivers.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-designware.h | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 00f52d472dcd..ae18b657938a 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -702,6 +702,29 @@ static inline void dw_pcie_ep_writel_dbi2(struct dw_pcie_ep *ep, u8 func_no,
dw_pcie_ep_write_dbi2(ep, func_no, reg, 0x4, val);
}
+static inline void dw_pcie_clear_and_set_dword(struct dw_pcie *pci, int pos,
+ u32 clear, u32 set)
+{
+ u32 val;
+
+ val = dw_pcie_readl_dbi(pci, pos);
+ val &= ~clear;
+ val |= set;
+ dw_pcie_writel_dbi(pci, pos, val);
+}
+
+static inline void dw_pcie_clear_dword(struct dw_pcie *pci, int pos,
+ u32 clear)
+{
+ dw_pcie_clear_and_set_dword(pci, pos, clear, 0);
+}
+
+static inline void dw_pcie_set_dword(struct dw_pcie *pci, int pos,
+ u32 set)
+{
+ dw_pcie_clear_and_set_dword(pci, pos, 0, set);
+}
+
static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
{
u32 reg;
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 02/13] PCI: dwc: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
2025-08-28 13:59 ` [PATCH v5 01/13] PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 03/13] PCI: dra7xx: " Hans Zhang
` (11 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
DesignWare core modules contain multiple instances of manual
read-modify-write operations for register bit manipulation.
These patterns duplicate functionality now provided by
dw_pcie_*_dword(), particularly in debugfs, endpoint,
host, and core initialization paths.
Replace open-coded bit manipulation sequences with calls to
dw_pcie_*_dword(). Affected areas include debugfs register
control, endpoint capability configuration, host setup routines, and
core link initialization logic. The changes simplify power management
handling, capability masking, and feature configuration.
Standardizing on the helper function reduces code duplication by ~140
lines across core modules while improving readability. The refactoring
also ensures consistent error handling for register operations and
provides a single point of control for future bit manipulation logic
updates.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
.../controller/dwc/pcie-designware-debugfs.c | 48 +++++-------
.../pci/controller/dwc/pcie-designware-ep.c | 19 ++---
.../pci/controller/dwc/pcie-designware-host.c | 26 +++----
drivers/pci/controller/dwc/pcie-designware.c | 75 +++++++------------
drivers/pci/controller/dwc/pcie-designware.h | 16 +---
5 files changed, 66 insertions(+), 118 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
index 0fbf86c0b97e..652e7cf691aa 100644
--- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
+++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
@@ -213,10 +213,8 @@ static ssize_t lane_detect_write(struct file *file, const char __user *buf,
if (val)
return val;
- val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG);
- val &= ~(LANE_SELECT);
- val |= FIELD_PREP(LANE_SELECT, lane);
- dw_pcie_writel_dbi(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG, val);
+ dw_pcie_clear_and_set_dword(pci, rinfo->ras_cap_offset + SD_STATUS_L1LANE_REG,
+ LANE_SELECT, FIELD_PREP(LANE_SELECT, lane));
return count;
}
@@ -415,10 +413,9 @@ static ssize_t counter_lane_write(struct file *file, const char __user *buf,
mutex_lock(&rinfo->reg_event_lock);
set_event_number(pdata, pci, rinfo);
- val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + RAS_DES_EVENT_COUNTER_CTRL_REG);
- val &= ~(EVENT_COUNTER_LANE_SELECT);
- val |= FIELD_PREP(EVENT_COUNTER_LANE_SELECT, lane);
- dw_pcie_writel_dbi(pci, rinfo->ras_cap_offset + RAS_DES_EVENT_COUNTER_CTRL_REG, val);
+ dw_pcie_clear_and_set_dword(pci, rinfo->ras_cap_offset + RAS_DES_EVENT_COUNTER_CTRL_REG,
+ EVENT_COUNTER_LANE_SELECT,
+ FIELD_PREP(EVENT_COUNTER_LANE_SELECT, lane));
mutex_unlock(&rinfo->reg_event_lock);
return count;
@@ -654,20 +651,15 @@ static int dw_pcie_ptm_check_capability(void *drvdata)
static int dw_pcie_ptm_context_update_write(void *drvdata, u8 mode)
{
struct dw_pcie *pci = drvdata;
- u32 val;
- if (mode == PCIE_PTM_CONTEXT_UPDATE_AUTO) {
- val = dw_pcie_readl_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL);
- val |= PTM_REQ_AUTO_UPDATE_ENABLED;
- dw_pcie_writel_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL, val);
- } else if (mode == PCIE_PTM_CONTEXT_UPDATE_MANUAL) {
- val = dw_pcie_readl_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL);
- val &= ~PTM_REQ_AUTO_UPDATE_ENABLED;
- val |= PTM_REQ_START_UPDATE;
- dw_pcie_writel_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL, val);
- } else {
+ if (mode == PCIE_PTM_CONTEXT_UPDATE_AUTO)
+ dw_pcie_set_dword(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL,
+ PTM_REQ_AUTO_UPDATE_ENABLED);
+ else if (mode == PCIE_PTM_CONTEXT_UPDATE_MANUAL)
+ dw_pcie_clear_and_set_dword(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL,
+ PTM_REQ_AUTO_UPDATE_ENABLED, PTM_REQ_START_UPDATE);
+ else
return -EINVAL;
- }
return 0;
}
@@ -694,17 +686,13 @@ static int dw_pcie_ptm_context_update_read(void *drvdata, u8 *mode)
static int dw_pcie_ptm_context_valid_write(void *drvdata, bool valid)
{
struct dw_pcie *pci = drvdata;
- u32 val;
- if (valid) {
- val = dw_pcie_readl_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL);
- val |= PTM_RES_CCONTEXT_VALID;
- dw_pcie_writel_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL, val);
- } else {
- val = dw_pcie_readl_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL);
- val &= ~PTM_RES_CCONTEXT_VALID;
- dw_pcie_writel_dbi(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL, val);
- }
+ if (valid)
+ dw_pcie_set_dword(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL,
+ PTM_RES_CCONTEXT_VALID);
+ else
+ dw_pcie_clear_dword(pci, pci->ptm_vsec_offset + PTM_RES_REQ_CTRL,
+ PTM_RES_CCONTEXT_VALID);
return 0;
}
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 0ae54a94809b..e5b59b2c2292 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -277,7 +277,7 @@ static int dw_pcie_ep_set_bar_resizable(struct dw_pcie_ep *ep, u8 func_no,
int flags = epf_bar->flags;
u32 reg = PCI_BASE_ADDRESS_0 + (4 * bar);
unsigned int rebar_offset;
- u32 rebar_cap, rebar_ctrl;
+ u32 rebar_cap;
int ret;
rebar_offset = dw_pcie_ep_get_rebar_offset(pci, bar);
@@ -310,9 +310,8 @@ static int dw_pcie_ep_set_bar_resizable(struct dw_pcie_ep *ep, u8 func_no,
* 1 MB to 128 TB. Bits 31:16 in PCI_REBAR_CTRL define "supported sizes"
* bits for sizes 256 TB to 8 EB. Disallow sizes 256 TB to 8 EB.
*/
- rebar_ctrl = dw_pcie_readl_dbi(pci, rebar_offset + PCI_REBAR_CTRL);
- rebar_ctrl &= ~GENMASK(31, 16);
- dw_pcie_writel_dbi(pci, rebar_offset + PCI_REBAR_CTRL, rebar_ctrl);
+ dw_pcie_clear_dword(pci, rebar_offset + PCI_REBAR_CTRL,
+ GENMASK(31, 16));
/*
* The "selected size" (bits 13:8) in PCI_REBAR_CTRL are automatically
@@ -925,7 +924,7 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
struct dw_pcie_ep_func *ep_func;
struct device *dev = pci->dev;
struct pci_epc *epc = ep->epc;
- u32 ptm_cap_base, reg;
+ u32 ptm_cap_base;
u8 hdr_type;
u8 func_no;
void *addr;
@@ -1001,13 +1000,11 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
*/
if (ptm_cap_base) {
dw_pcie_dbi_ro_wr_en(pci);
- reg = dw_pcie_readl_dbi(pci, ptm_cap_base + PCI_PTM_CAP);
- reg &= ~PCI_PTM_CAP_ROOT;
- dw_pcie_writel_dbi(pci, ptm_cap_base + PCI_PTM_CAP, reg);
+ dw_pcie_clear_dword(pci, ptm_cap_base + PCI_PTM_CAP,
+ PCI_PTM_CAP_ROOT);
- reg = dw_pcie_readl_dbi(pci, ptm_cap_base + PCI_PTM_CAP);
- reg &= ~(PCI_PTM_CAP_RES | PCI_PTM_GRANULARITY_MASK);
- dw_pcie_writel_dbi(pci, ptm_cap_base + PCI_PTM_CAP, reg);
+ dw_pcie_clear_dword(pci, ptm_cap_base + PCI_PTM_CAP,
+ PCI_PTM_CAP_RES | PCI_PTM_GRANULARITY_MASK);
dw_pcie_dbi_ro_wr_dis(pci);
}
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 952f8594b501..ded18122f5a6 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -904,7 +904,6 @@ static void dw_pcie_config_presets(struct dw_pcie_rp *pp)
int dw_pcie_setup_rc(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
- u32 val;
int ret;
/*
@@ -922,23 +921,17 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp)
dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_1, 0x00000000);
/* Setup interrupt pins */
- val = dw_pcie_readl_dbi(pci, PCI_INTERRUPT_LINE);
- val &= 0xffff00ff;
- val |= 0x00000100;
- dw_pcie_writel_dbi(pci, PCI_INTERRUPT_LINE, val);
+ dw_pcie_clear_and_set_dword(pci, PCI_INTERRUPT_LINE,
+ 0x0000ff00, 0x00000100);
/* Setup bus numbers */
- val = dw_pcie_readl_dbi(pci, PCI_PRIMARY_BUS);
- val &= 0xff000000;
- val |= 0x00ff0100;
- dw_pcie_writel_dbi(pci, PCI_PRIMARY_BUS, val);
+ dw_pcie_clear_and_set_dword(pci, PCI_PRIMARY_BUS,
+ 0x00ffffff, 0x00ff0100);
/* Setup command register */
- val = dw_pcie_readl_dbi(pci, PCI_COMMAND);
- val &= 0xffff0000;
- val |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
- PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
- dw_pcie_writel_dbi(pci, PCI_COMMAND, val);
+ dw_pcie_clear_and_set_dword(pci, PCI_COMMAND, 0x0000ffff,
+ PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
+ PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
dw_pcie_config_presets(pp);
/*
@@ -957,9 +950,8 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp)
/* Program correct class for RC */
dw_pcie_writew_dbi(pci, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_PCI);
- val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+ dw_pcie_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
dw_pcie_dbi_ro_wr_dis(pci);
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 89aad5a08928..77b66af73ab3 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -748,11 +748,8 @@ EXPORT_SYMBOL_GPL(dw_pcie_link_up);
void dw_pcie_upconfig_setup(struct dw_pcie *pci)
{
- u32 val;
-
- val = dw_pcie_readl_dbi(pci, PCIE_PORT_MULTI_LANE_CTRL);
- val |= PORT_MLTI_UPCFG_SUPPORT;
- dw_pcie_writel_dbi(pci, PCIE_PORT_MULTI_LANE_CTRL, val);
+ dw_pcie_set_dword(pci, PCIE_PORT_MULTI_LANE_CTRL,
+ PORT_MLTI_UPCFG_SUPPORT);
}
EXPORT_SYMBOL_GPL(dw_pcie_upconfig_setup);
@@ -813,21 +810,12 @@ int dw_pcie_link_get_max_link_width(struct dw_pcie *pci)
static void dw_pcie_link_set_max_link_width(struct dw_pcie *pci, u32 num_lanes)
{
- u32 lnkcap, lwsc, plc;
+ u32 plc = 0;
u8 cap;
if (!num_lanes)
return;
- /* Set the number of lanes */
- plc = dw_pcie_readl_dbi(pci, PCIE_PORT_LINK_CONTROL);
- plc &= ~PORT_LINK_FAST_LINK_MODE;
- plc &= ~PORT_LINK_MODE_MASK;
-
- /* Set link width speed control register */
- lwsc = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- lwsc &= ~PORT_LOGIC_LINK_WIDTH_MASK;
- lwsc |= PORT_LOGIC_LINK_WIDTH_1_LANES;
switch (num_lanes) {
case 1:
plc |= PORT_LINK_MODE_1_LANES;
@@ -845,14 +833,20 @@ static void dw_pcie_link_set_max_link_width(struct dw_pcie *pci, u32 num_lanes)
dev_err(pci->dev, "num-lanes %u: invalid value\n", num_lanes);
return;
}
- dw_pcie_writel_dbi(pci, PCIE_PORT_LINK_CONTROL, plc);
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, lwsc);
+ /* Set the number of lanes */
+ dw_pcie_clear_and_set_dword(pci, PCIE_PORT_LINK_CONTROL,
+ PORT_LINK_FAST_LINK_MODE | PORT_LINK_MODE_MASK,
+ plc);
+
+ /* Set link width speed control register */
+ dw_pcie_clear_and_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_LINK_WIDTH_MASK,
+ PORT_LOGIC_LINK_WIDTH_1_LANES);
cap = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- lnkcap = dw_pcie_readl_dbi(pci, cap + PCI_EXP_LNKCAP);
- lnkcap &= ~PCI_EXP_LNKCAP_MLW;
- lnkcap |= FIELD_PREP(PCI_EXP_LNKCAP_MLW, num_lanes);
- dw_pcie_writel_dbi(pci, cap + PCI_EXP_LNKCAP, lnkcap);
+ dw_pcie_clear_and_set_dword(pci, cap + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_MLW,
+ FIELD_PREP(PCI_EXP_LNKCAP_MLW, num_lanes));
}
void dw_pcie_iatu_detect(struct dw_pcie *pci)
@@ -1141,38 +1135,27 @@ void dw_pcie_edma_remove(struct dw_pcie *pci)
void dw_pcie_setup(struct dw_pcie *pci)
{
- u32 val;
-
dw_pcie_link_set_max_speed(pci);
/* Configure Gen1 N_FTS */
- if (pci->n_fts[0]) {
- val = dw_pcie_readl_dbi(pci, PCIE_PORT_AFR);
- val &= ~(PORT_AFR_N_FTS_MASK | PORT_AFR_CC_N_FTS_MASK);
- val |= PORT_AFR_N_FTS(pci->n_fts[0]);
- val |= PORT_AFR_CC_N_FTS(pci->n_fts[0]);
- dw_pcie_writel_dbi(pci, PCIE_PORT_AFR, val);
- }
+ if (pci->n_fts[0])
+ dw_pcie_clear_and_set_dword(pci, PCIE_PORT_AFR,
+ PORT_AFR_N_FTS_MASK | PORT_AFR_CC_N_FTS_MASK,
+ PORT_AFR_N_FTS(pci->n_fts[0]) |
+ PORT_AFR_CC_N_FTS(pci->n_fts[0]));
/* Configure Gen2+ N_FTS */
- if (pci->n_fts[1]) {
- val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val &= ~PORT_LOGIC_N_FTS_MASK;
- val |= pci->n_fts[1];
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
- }
+ if (pci->n_fts[1])
+ dw_pcie_clear_and_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_N_FTS_MASK, pci->n_fts[1]);
- if (dw_pcie_cap_is(pci, CDM_CHECK)) {
- val = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS);
- val |= PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS |
- PCIE_PL_CHK_REG_CHK_REG_START;
- dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val);
- }
+ if (dw_pcie_cap_is(pci, CDM_CHECK))
+ dw_pcie_set_dword(pci, PCIE_PL_CHK_REG_CONTROL_STATUS,
+ PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS |
+ PCIE_PL_CHK_REG_CHK_REG_START);
- val = dw_pcie_readl_dbi(pci, PCIE_PORT_LINK_CONTROL);
- val &= ~PORT_LINK_FAST_LINK_MODE;
- val |= PORT_LINK_DLL_LINK_EN;
- dw_pcie_writel_dbi(pci, PCIE_PORT_LINK_CONTROL, val);
+ dw_pcie_clear_and_set_dword(pci, PCIE_PORT_LINK_CONTROL,
+ PORT_LINK_FAST_LINK_MODE, PORT_LINK_DLL_LINK_EN);
dw_pcie_link_set_max_link_width(pci, pci->num_lanes);
}
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index ae18b657938a..fadc8bcb06bc 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -727,24 +727,12 @@ static inline void dw_pcie_set_dword(struct dw_pcie *pci, int pos,
static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
{
- u32 reg;
- u32 val;
-
- reg = PCIE_MISC_CONTROL_1_OFF;
- val = dw_pcie_readl_dbi(pci, reg);
- val |= PCIE_DBI_RO_WR_EN;
- dw_pcie_writel_dbi(pci, reg, val);
+ dw_pcie_set_dword(pci, PCIE_MISC_CONTROL_1_OFF, PCIE_DBI_RO_WR_EN);
}
static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci)
{
- u32 reg;
- u32 val;
-
- reg = PCIE_MISC_CONTROL_1_OFF;
- val = dw_pcie_readl_dbi(pci, reg);
- val &= ~PCIE_DBI_RO_WR_EN;
- dw_pcie_writel_dbi(pci, reg, val);
+ dw_pcie_clear_dword(pci, PCIE_MISC_CONTROL_1_OFF, PCIE_DBI_RO_WR_EN);
}
static inline int dw_pcie_start_link(struct dw_pcie *pci)
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 03/13] PCI: dra7xx: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
2025-08-28 13:59 ` [PATCH v5 01/13] PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation Hans Zhang
2025-08-28 13:59 ` [PATCH v5 02/13] PCI: dwc: Refactor code by using dw_pcie_*_dword() Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 04/13] PCI: imx6: " Hans Zhang
` (10 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
The dra7xx PCIe driver implements suspend/resume handling through
direct register manipulation. The current approach uses explicit
read-modify-write sequences to control the MEMORY enable bit in the
PCI_COMMAND register, declaring local variables for temporary storage.
Replace manual bit manipulation with dw_pcie_*_dword()
during suspend and resume operations. This eliminates redundant variable
declarations and simplifies the power management flow by handling bit
operations within a single function call.
Using the centralized helper improves code readability and aligns the
driver with standard DesignWare register access patterns. The change also
reduces the risk of bit manipulation errors in future modifications to the
power management logic.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pci-dra7xx.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index f97f5266d196..44fbd6751004 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -867,15 +867,12 @@ static int dra7xx_pcie_suspend(struct device *dev)
{
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
struct dw_pcie *pci = dra7xx->pci;
- u32 val;
if (dra7xx->mode != DW_PCIE_RC_TYPE)
return 0;
/* clear MSE */
- val = dw_pcie_readl_dbi(pci, PCI_COMMAND);
- val &= ~PCI_COMMAND_MEMORY;
- dw_pcie_writel_dbi(pci, PCI_COMMAND, val);
+ dw_pcie_clear_dword(pci, PCI_COMMAND, PCI_COMMAND_MEMORY);
return 0;
}
@@ -884,15 +881,12 @@ static int dra7xx_pcie_resume(struct device *dev)
{
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
struct dw_pcie *pci = dra7xx->pci;
- u32 val;
if (dra7xx->mode != DW_PCIE_RC_TYPE)
return 0;
/* set MSE */
- val = dw_pcie_readl_dbi(pci, PCI_COMMAND);
- val |= PCI_COMMAND_MEMORY;
- dw_pcie_writel_dbi(pci, PCI_COMMAND, val);
+ dw_pcie_set_dword(pci, PCI_COMMAND, PCI_COMMAND_MEMORY);
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 04/13] PCI: imx6: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (2 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 03/13] PCI: dra7xx: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 05/13] PCI: meson: " Hans Zhang
` (9 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang,
Frank Li
i.MX6 PCIe driver contains multiple read-modify-write sequences for
link training and speed configuration. These operations manually handle
bit masking and shifting to update specific fields in control registers,
particularly for link capabilities and speed change initiation.
Refactor link capability configuration and speed change handling using
dw_pcie_*_dword(). The helper simplifies LNKCAP modification
by encapsulating bit clear/set operations and eliminates intermediate
variables. For speed change control, replace explicit bit manipulation
with direct register updates through the helper.
Adopting the standard interface reduces code complexity in link training
paths and ensures consistent handling of speed-related bits. The change
also prepares the driver for future enhancements to Gen3 link training
by centralizing bit manipulation logic.
Signed-off-by: Hans Zhang <18255117159@163.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
drivers/pci/controller/dwc/pci-imx6.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 80e48746bbaf..acd8e1b927c5 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -939,7 +939,6 @@ static int imx_pcie_start_link(struct dw_pcie *pci)
struct imx_pcie *imx_pcie = to_imx_pcie(pci);
struct device *dev = pci->dev;
u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- u32 tmp;
int ret;
if (!(imx_pcie->drvdata->flags &
@@ -954,10 +953,9 @@ static int imx_pcie_start_link(struct dw_pcie *pci)
* bus will not be detected at all. This happens with PCIe switches.
*/
dw_pcie_dbi_ro_wr_en(pci);
- tmp = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
- tmp &= ~PCI_EXP_LNKCAP_SLS;
- tmp |= PCI_EXP_LNKCAP_SLS_2_5GB;
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, tmp);
+ dw_pcie_clear_and_set_dword(pci, offset + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_SLS,
+ PCI_EXP_LNKCAP_SLS_2_5GB);
dw_pcie_dbi_ro_wr_dis(pci);
/* Start LTSSM. */
@@ -970,18 +968,16 @@ static int imx_pcie_start_link(struct dw_pcie *pci)
/* Allow faster modes after the link is up */
dw_pcie_dbi_ro_wr_en(pci);
- tmp = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
- tmp &= ~PCI_EXP_LNKCAP_SLS;
- tmp |= pci->max_link_speed;
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, tmp);
+ dw_pcie_clear_and_set_dword(pci, offset + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_SLS,
+ pci->max_link_speed);
/*
* Start Directed Speed Change so the best possible
* speed both link partners support can be negotiated.
*/
- tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- tmp |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp);
+ dw_pcie_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
dw_pcie_dbi_ro_wr_dis(pci);
ret = imx_pcie_wait_for_speed_change(imx_pcie);
@@ -1302,7 +1298,6 @@ static void imx_pcie_host_post_init(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct imx_pcie *imx_pcie = to_imx_pcie(pci);
- u32 val;
if (imx_pcie->drvdata->flags & IMX_PCIE_FLAG_8GT_ECN_ERR051586) {
/*
@@ -1317,9 +1312,8 @@ static void imx_pcie_host_post_init(struct dw_pcie_rp *pp)
* to 0.
*/
dw_pcie_dbi_ro_wr_en(pci);
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL;
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
+ dw_pcie_clear_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL);
dw_pcie_dbi_ro_wr_dis(pci);
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 05/13] PCI: meson: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (3 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 04/13] PCI: imx6: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 06/13] PCI: armada8k: " Hans Zhang
` (8 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Meson PCIe driver implements payload size configuration through manual
register manipulation. The current code reads device control registers,
modifies specific bitfields for maximum payload and read request sizes,
then writes back the updated values. This pattern repeats twice with
similar logic but different bit masks.
Replace explicit bit manipulation with dw_pcie_*_dword() for
payload and read request size configuration. The helper consolidates
read-clear-set-write operations into a single call, eliminating redundant
register read operations and local variable usage.
This refactoring reduces code duplication in size configuration logic
and improves maintainability. By using the DesignWare helper, the driver
aligns with standard PCIe controller programming patterns and simplifies
future updates to device capability settings.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pci-meson.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 787469d1b396..e9375cfa6c8f 100644
--- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -264,33 +264,27 @@ static int meson_size_to_payload(struct meson_pcie *mp, int size)
static void meson_set_max_payload(struct meson_pcie *mp, int size)
{
struct dw_pcie *pci = &mp->pci;
- u32 val;
u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
int max_payload_size = meson_size_to_payload(mp, size);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val &= ~PCI_EXP_DEVCTL_PAYLOAD;
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val);
+ dw_pcie_clear_dword(pci, offset + PCI_EXP_DEVCTL,
+ PCI_EXP_DEVCTL_PAYLOAD);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val |= PCIE_CAP_MAX_PAYLOAD_SIZE(max_payload_size);
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val);
+ dw_pcie_set_dword(pci, offset + PCI_EXP_DEVCTL,
+ PCIE_CAP_MAX_PAYLOAD_SIZE(max_payload_size));
}
static void meson_set_max_rd_req_size(struct meson_pcie *mp, int size)
{
struct dw_pcie *pci = &mp->pci;
- u32 val;
u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
int max_rd_req_size = meson_size_to_payload(mp, size);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val &= ~PCI_EXP_DEVCTL_READRQ;
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val);
+ dw_pcie_clear_dword(pci, offset + PCI_EXP_DEVCTL,
+ PCI_EXP_DEVCTL_READRQ);
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val |= PCIE_CAP_MAX_READ_REQ_SIZE(max_rd_req_size);
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val);
+ dw_pcie_set_dword(pci, offset + PCI_EXP_DEVCTL,
+ PCIE_CAP_MAX_READ_REQ_SIZE(max_rd_req_size));
}
static int meson_pcie_start_link(struct dw_pcie *pci)
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 06/13] PCI: armada8k: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (4 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 05/13] PCI: meson: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 07/13] PCI: bt1: " Hans Zhang
` (7 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Armada8k PCIe driver uses explicit bitwise operations for global control
register configuration. The driver manually handles bit masking and
shifting for multiple fields including device type, domain attributes,
and interrupt masking. This approach requires repetitive read-modify-write
sequences and temporary variables.
Refactor global control setup, domain attribute configuration, and
interrupt masking using dw_pcie_*_dword(). The helper replaces
manual bit manipulation with declarative bit masks, directly specifying
which bits to clear and set. This eliminates intermediate variables and
reduces code complexity.
Standardizing on the helper improves code clarity in initialization paths
and ensures consistent handling of control register bits. The change also
centralizes bit manipulation logic, reducing the risk of errors in future
modifications to device configuration.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-armada8k.c | 43 ++++++++--------------
1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-armada8k.c b/drivers/pci/controller/dwc/pcie-armada8k.c
index c2650fd0d458..1b2879f89c61 100644
--- a/drivers/pci/controller/dwc/pcie-armada8k.c
+++ b/drivers/pci/controller/dwc/pcie-armada8k.c
@@ -155,54 +155,43 @@ static bool armada8k_pcie_link_up(struct dw_pcie *pci)
static int armada8k_pcie_start_link(struct dw_pcie *pci)
{
- u32 reg;
-
/* Start LTSSM */
- reg = dw_pcie_readl_dbi(pci, PCIE_GLOBAL_CONTROL_REG);
- reg |= PCIE_APP_LTSSM_EN;
- dw_pcie_writel_dbi(pci, PCIE_GLOBAL_CONTROL_REG, reg);
+ dw_pcie_set_dword(pci, PCIE_GLOBAL_CONTROL_REG, PCIE_APP_LTSSM_EN);
return 0;
}
static int armada8k_pcie_host_init(struct dw_pcie_rp *pp)
{
- u32 reg;
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
- if (!dw_pcie_link_up(pci)) {
+ if (!dw_pcie_link_up(pci))
/* Disable LTSSM state machine to enable configuration */
- reg = dw_pcie_readl_dbi(pci, PCIE_GLOBAL_CONTROL_REG);
- reg &= ~(PCIE_APP_LTSSM_EN);
- dw_pcie_writel_dbi(pci, PCIE_GLOBAL_CONTROL_REG, reg);
- }
+ dw_pcie_clear_dword(pci, PCIE_GLOBAL_CONTROL_REG,
+ PCIE_APP_LTSSM_EN);
/* Set the device to root complex mode */
- reg = dw_pcie_readl_dbi(pci, PCIE_GLOBAL_CONTROL_REG);
- reg &= ~(PCIE_DEVICE_TYPE_MASK << PCIE_DEVICE_TYPE_SHIFT);
- reg |= PCIE_DEVICE_TYPE_RC << PCIE_DEVICE_TYPE_SHIFT;
- dw_pcie_writel_dbi(pci, PCIE_GLOBAL_CONTROL_REG, reg);
+ dw_pcie_clear_and_set_dword(pci, PCIE_GLOBAL_CONTROL_REG,
+ PCIE_DEVICE_TYPE_MASK << PCIE_DEVICE_TYPE_SHIFT,
+ PCIE_DEVICE_TYPE_RC << PCIE_DEVICE_TYPE_SHIFT);
/* Set the PCIe master AxCache attributes */
dw_pcie_writel_dbi(pci, PCIE_ARCACHE_TRC_REG, ARCACHE_DEFAULT_VALUE);
dw_pcie_writel_dbi(pci, PCIE_AWCACHE_TRC_REG, AWCACHE_DEFAULT_VALUE);
/* Set the PCIe master AxDomain attributes */
- reg = dw_pcie_readl_dbi(pci, PCIE_ARUSER_REG);
- reg &= ~(AX_USER_DOMAIN_MASK << AX_USER_DOMAIN_SHIFT);
- reg |= DOMAIN_OUTER_SHAREABLE << AX_USER_DOMAIN_SHIFT;
- dw_pcie_writel_dbi(pci, PCIE_ARUSER_REG, reg);
+ dw_pcie_clear_and_set_dword(pci, PCIE_ARUSER_REG,
+ AX_USER_DOMAIN_MASK << AX_USER_DOMAIN_SHIFT,
+ DOMAIN_OUTER_SHAREABLE << AX_USER_DOMAIN_SHIFT);
- reg = dw_pcie_readl_dbi(pci, PCIE_AWUSER_REG);
- reg &= ~(AX_USER_DOMAIN_MASK << AX_USER_DOMAIN_SHIFT);
- reg |= DOMAIN_OUTER_SHAREABLE << AX_USER_DOMAIN_SHIFT;
- dw_pcie_writel_dbi(pci, PCIE_AWUSER_REG, reg);
+ dw_pcie_clear_and_set_dword(pci, PCIE_AWUSER_REG,
+ AX_USER_DOMAIN_MASK << AX_USER_DOMAIN_SHIFT,
+ DOMAIN_OUTER_SHAREABLE << AX_USER_DOMAIN_SHIFT);
/* Enable INT A-D interrupts */
- reg = dw_pcie_readl_dbi(pci, PCIE_GLOBAL_INT_MASK1_REG);
- reg |= PCIE_INT_A_ASSERT_MASK | PCIE_INT_B_ASSERT_MASK |
- PCIE_INT_C_ASSERT_MASK | PCIE_INT_D_ASSERT_MASK;
- dw_pcie_writel_dbi(pci, PCIE_GLOBAL_INT_MASK1_REG, reg);
+ dw_pcie_set_dword(pci, PCIE_GLOBAL_INT_MASK1_REG,
+ PCIE_INT_A_ASSERT_MASK | PCIE_INT_B_ASSERT_MASK |
+ PCIE_INT_C_ASSERT_MASK | PCIE_INT_D_ASSERT_MASK);
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 07/13] PCI: bt1: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (5 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 06/13] PCI: armada8k: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 08/13] PCI: dw-rockchip: " Hans Zhang
` (6 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Baikal-T1 PCIe driver contains a direct register write to initiate
speed change during link training. The current implementation sets
the PORT_LOGIC_SPEED_CHANGE bit via read-modify-write without using
the standard bit manipulation helper.
Replace manual bit set operation with dw_pcie_*_dword() to enable
speed change. The helper clearly expresses the intent to modify a
specific bit while preserving others, eliminating the need for explicit
read-before-write.
Using the standardized interface improves consistency with other
DesignWare drivers and reduces the risk of unintended bit modifications.
The change also simplifies future updates to link training logic.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-bt1.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-bt1.c b/drivers/pci/controller/dwc/pcie-bt1.c
index 1340edc18d12..0a9466827e2b 100644
--- a/drivers/pci/controller/dwc/pcie-bt1.c
+++ b/drivers/pci/controller/dwc/pcie-bt1.c
@@ -289,9 +289,8 @@ static int bt1_pcie_start_link(struct dw_pcie *pci)
* attempt to reach a higher bus performance (up to Gen.3 - 8.0 GT/s).
* This is required at least to get 8.0 GT/s speed.
*/
- val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+ dw_pcie_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
ret = regmap_read_poll_timeout(btpci->sys_regs, BT1_CCU_PCIE_PMSC, val,
BT1_CCU_PCIE_LTSSM_LINKUP(val),
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 08/13] PCI: dw-rockchip: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (6 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 07/13] PCI: bt1: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 09/13] PCI: fu740: " Hans Zhang
` (5 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Rockchip PCIe driver implements L0s capability enablement through
explicit register read-modify-write. The current approach reads the
LNKCAP register, modifies the ASPM_L0S bit, then writes back the
value with DBI write protection handling.
Refactor ASPM capability configuration using
dw_pcie_*_dword(). The helper combines bit manipulation with
DBI protection in a single call, replacing three-step manual operations.
This simplifies the capability setup flow and reduces code complexity.
Adopting the standard helper improves maintainability by eliminating
local variables and explicit bitwise operations. The change also ensures
consistent handling of DBI write protection across capability modification
functions.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index b5f5eee5a50e..5ae923907531 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -196,15 +196,14 @@ static bool rockchip_pcie_link_up(struct dw_pcie *pci)
static void rockchip_pcie_enable_l0s(struct dw_pcie *pci)
{
- u32 cap, lnkcap;
+ u32 cap;
/* Enable L0S capability for all SoCs */
cap = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
if (cap) {
- lnkcap = dw_pcie_readl_dbi(pci, cap + PCI_EXP_LNKCAP);
- lnkcap |= PCI_EXP_LNKCAP_ASPM_L0S;
dw_pcie_dbi_ro_wr_en(pci);
- dw_pcie_writel_dbi(pci, cap + PCI_EXP_LNKCAP, lnkcap);
+ dw_pcie_set_dword(pci, cap + PCI_EXP_LNKCAP,
+ PCI_EXP_LNKCAP_ASPM_L0S);
dw_pcie_dbi_ro_wr_dis(pci);
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 09/13] PCI: fu740: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (7 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 08/13] PCI: dw-rockchip: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 10/13] PCI: qcom: " Hans Zhang
` (4 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
SiFive FU740 PCIe driver uses direct register write to initiate link speed
change after setting target link capabilities. The current implementation
sets PORT_LOGIC_SPEED_CHANGE bit via explicit read-modify-write sequence.
Replace manual bit manipulation with dw_pcie_*_dword() for
speed change initiation. The helper encapsulates read-modify-write
operations while providing clear intent through "clear 0, set BIT" usage.
This refactoring aligns the driver with standard DesignWare programming
patterns and reduces code complexity. The change also ensures consistent
handling of speed change initiation across all DesignWare base
controllers.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-fu740.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-fu740.c b/drivers/pci/controller/dwc/pcie-fu740.c
index 66367252032b..5bb19da9e2b2 100644
--- a/drivers/pci/controller/dwc/pcie-fu740.c
+++ b/drivers/pci/controller/dwc/pcie-fu740.c
@@ -216,9 +216,8 @@ static int fu740_pcie_start_link(struct dw_pcie *pci)
tmp |= orig;
dw_pcie_writel_dbi(pci, cap_exp + PCI_EXP_LNKCAP, tmp);
- tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- tmp |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp);
+ dw_pcie_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
ret = dw_pcie_wait_for_link(pci);
if (ret) {
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 10/13] PCI: qcom: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (8 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 09/13] PCI: fu740: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 11/13] PCI: qcom-ep: " Hans Zhang
` (3 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Qcom PCIe common code contains complex bit manipulation for 16GT/s
equalization and lane margining configuration. These functions use
multiple read-modify-write sequences with manual bit masking and
field preparation, leading to verbose and error-prone code.
Refactor equalization and lane margining setup using
dw_pcie_*_dword(). The helper simplifies multi-field
configuration by combining clear and set operations in a single call.
Initialize local variables to zero before field insertion to ensure
unused bits are cleared appropriately.
This change reduces code complexity by ~40% in affected functions
while improving readability. Centralizing bit manipulation ensures
consistent handling of register fields across Qcom PCIe implementations
and provides a solid foundation for future 16GT/s enhancements.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-qcom-common.c | 62 +++++++++----------
1 file changed, 30 insertions(+), 32 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-qcom-common.c b/drivers/pci/controller/dwc/pcie-qcom-common.c
index 3aad19b56da8..f3a365daac8a 100644
--- a/drivers/pci/controller/dwc/pcie-qcom-common.c
+++ b/drivers/pci/controller/dwc/pcie-qcom-common.c
@@ -19,30 +19,29 @@ void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci)
* determines the data rate for which these equalization settings are
* applied.
*/
- reg = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- reg &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL;
- reg &= ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK;
- reg |= FIELD_PREP(GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK,
- GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT);
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, reg);
+ reg = FIELD_PREP(GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK,
+ GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT);
+ dw_pcie_clear_and_set_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL |
+ GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK,
+ reg);
- reg = dw_pcie_readl_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF);
- reg &= ~(GEN3_EQ_FMDC_T_MIN_PHASE23 |
- GEN3_EQ_FMDC_N_EVALS |
- GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA |
- GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA);
- reg |= FIELD_PREP(GEN3_EQ_FMDC_T_MIN_PHASE23, 0x1) |
- FIELD_PREP(GEN3_EQ_FMDC_N_EVALS, 0xd) |
- FIELD_PREP(GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA, 0x5) |
- FIELD_PREP(GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA, 0x5);
- dw_pcie_writel_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF, reg);
+ reg = FIELD_PREP(GEN3_EQ_FMDC_T_MIN_PHASE23, 0x1) |
+ FIELD_PREP(GEN3_EQ_FMDC_N_EVALS, 0xd) |
+ FIELD_PREP(GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA, 0x5) |
+ FIELD_PREP(GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA, 0x5);
+ dw_pcie_clear_and_set_dword(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF,
+ GEN3_EQ_FMDC_T_MIN_PHASE23 |
+ GEN3_EQ_FMDC_N_EVALS |
+ GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA |
+ GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA,
+ reg);
- reg = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
- reg &= ~(GEN3_EQ_CONTROL_OFF_FB_MODE |
- GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE |
- GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL |
- GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC);
- dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, reg);
+ dw_pcie_clear_dword(pci, GEN3_EQ_CONTROL_OFF,
+ GEN3_EQ_CONTROL_OFF_FB_MODE |
+ GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE |
+ GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL |
+ GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC);
}
EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_equalization);
@@ -50,16 +49,15 @@ void qcom_pcie_common_set_16gt_lane_margining(struct dw_pcie *pci)
{
u32 reg;
- reg = dw_pcie_readl_dbi(pci, GEN4_LANE_MARGINING_1_OFF);
- reg &= ~(MARGINING_MAX_VOLTAGE_OFFSET |
- MARGINING_NUM_VOLTAGE_STEPS |
- MARGINING_MAX_TIMING_OFFSET |
- MARGINING_NUM_TIMING_STEPS);
- reg |= FIELD_PREP(MARGINING_MAX_VOLTAGE_OFFSET, 0x24) |
- FIELD_PREP(MARGINING_NUM_VOLTAGE_STEPS, 0x78) |
- FIELD_PREP(MARGINING_MAX_TIMING_OFFSET, 0x32) |
- FIELD_PREP(MARGINING_NUM_TIMING_STEPS, 0x10);
- dw_pcie_writel_dbi(pci, GEN4_LANE_MARGINING_1_OFF, reg);
+ reg = FIELD_PREP(MARGINING_MAX_VOLTAGE_OFFSET, 0x24) |
+ FIELD_PREP(MARGINING_NUM_VOLTAGE_STEPS, 0x78) |
+ FIELD_PREP(MARGINING_MAX_TIMING_OFFSET, 0x32) |
+ FIELD_PREP(MARGINING_NUM_TIMING_STEPS, 0x10);
+ dw_pcie_clear_and_set_dword(pci, GEN4_LANE_MARGINING_1_OFF,
+ MARGINING_MAX_VOLTAGE_OFFSET |
+ MARGINING_NUM_VOLTAGE_STEPS |
+ MARGINING_MAX_TIMING_OFFSET |
+ MARGINING_NUM_TIMING_STEPS, reg);
reg = dw_pcie_readl_dbi(pci, GEN4_LANE_MARGINING_2_OFF);
reg |= MARGINING_IND_ERROR_SAMPLER |
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 11/13] PCI: qcom-ep: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (9 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 10/13] PCI: qcom: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 12/13] PCI: rcar-gen4: " Hans Zhang
` (2 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
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_*_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@163.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.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 12/13] PCI: rcar-gen4: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (10 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 11/13] PCI: qcom-ep: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 13:59 ` [PATCH v5 13/13] PCI: tegra194: " Hans Zhang
2025-08-28 20:44 ` [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Rob Herring
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
R-Car Gen4 PCIe driver contains multiple read-modify-write sequences for
speed change control and lane configuration. The driver manually handles
speed change initiation through bit set/clear operations and configures
lane skew with explicit bit masking.
Refactor speed change handling and lane skew configuration using
dw_pcie_*_dword(). For speed change operations, replace
manual bit toggling with clear-and-set sequences. For lane skew, use
the helper to conditionally set bits based on lane count.
Adopting the standard interface simplifies link training logic and
reduces code complexity. The change also ensures consistent handling
of control register bits and provides better documentation of intent
through declarative bit masks.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-rcar-gen4.c | 23 ++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
index 18055807a4f5..67be0aeaa7ec 100644
--- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
+++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
@@ -107,13 +107,11 @@ static int rcar_gen4_pcie_speed_change(struct dw_pcie *dw)
u32 val;
int i;
- val = dw_pcie_readl_dbi(dw, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val &= ~PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(dw, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+ dw_pcie_clear_dword(dw, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
- val = dw_pcie_readl_dbi(dw, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(dw, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+ dw_pcie_set_dword(dw, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
for (i = 0; i < RCAR_NUM_SPEED_CHANGE_RETRIES; i++) {
val = dw_pcie_readl_dbi(dw, PCIE_LINK_WIDTH_SPEED_CONTROL);
@@ -565,11 +563,9 @@ static void rcar_gen4_pcie_additional_common_init(struct rcar_gen4_pcie *rcar)
struct dw_pcie *dw = &rcar->dw;
u32 val;
- val = dw_pcie_readl_dbi(dw, PCIE_PORT_LANE_SKEW);
- val &= ~PORT_LANE_SKEW_INSERT_MASK;
- if (dw->num_lanes < 4)
- val |= BIT(6);
- dw_pcie_writel_dbi(dw, PCIE_PORT_LANE_SKEW, val);
+ dw_pcie_clear_and_set_dword(dw, PCIE_PORT_LANE_SKEW,
+ PORT_LANE_SKEW_INSERT_MASK,
+ (dw->num_lanes < 4) ? BIT(6) : 0);
val = readl(rcar->base + PCIEPWRMNGCTRL);
val |= APP_CLK_REQ_N | APP_CLK_PM_EN;
@@ -680,9 +676,8 @@ static int rcar_gen4_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable
return 0;
}
- val = dw_pcie_readl_dbi(dw, PCIE_PORT_FORCE);
- val |= PORT_FORCE_DO_DESKEW_FOR_SRIS;
- dw_pcie_writel_dbi(dw, PCIE_PORT_FORCE, val);
+ dw_pcie_set_dword(dw, PCIE_PORT_FORCE,
+ PORT_FORCE_DO_DESKEW_FOR_SRIS);
val = readl(rcar->base + PCIEMSR0);
val |= APP_SRIS_MODE;
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v5 13/13] PCI: tegra194: Refactor code by using dw_pcie_*_dword()
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (11 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 12/13] PCI: rcar-gen4: " Hans Zhang
@ 2025-08-28 13:59 ` Hans Zhang
2025-08-28 20:44 ` [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Rob Herring
13 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-08-28 13:59 UTC (permalink / raw)
To: lpieralisi, bhelgaas, mani, kwilczynski
Cc: robh, jingoohan1, cassel, linux-pci, linux-kernel, Hans Zhang
Tegra194 PCIe driver contains extensive manual bit manipulation across
interrupt handling, ASPM configuration, and controller initialization.
The driver implements complex read-modify-write sequences with explicit
bit masking, leading to verbose and hard-to-maintain code.
Refactor interrupt handling, ASPM setup, capability configuration, and
controller initialization using dw_pcie_*_dword(). Replace
multi-step register modifications with single helper calls, eliminating
intermediate variables and reducing code size by ~75 lines. For CDMA
error handling, initialize the value variable to zero before setting
status bits.
This comprehensive refactoring significantly improves code readability
and maintainability. Standardizing on the helper ensures consistent
register access patterns across all driver components and reduces the
risk of bit manipulation errors in this complex controller driver.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-tegra194.c | 122 ++++++++-------------
1 file changed, 47 insertions(+), 75 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index 4f26086f25da..f89dde9071cd 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -378,9 +378,8 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg)
val |= APPL_CAR_RESET_OVRD_CYA_OVERRIDE_CORE_RST_N;
appl_writel(pcie, val, APPL_CAR_RESET_OVRD);
- val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
- val |= PORT_LOGIC_SPEED_CHANGE;
- dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+ dw_pcie_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
+ PORT_LOGIC_SPEED_CHANGE);
}
}
@@ -610,20 +609,14 @@ static struct pci_ops tegra_pci_ops = {
#if defined(CONFIG_PCIEASPM)
static void disable_aspm_l11(struct tegra_pcie_dw *pcie)
{
- u32 val;
-
- val = dw_pcie_readl_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub);
- val &= ~PCI_L1SS_CAP_ASPM_L1_1;
- dw_pcie_writel_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub, val);
+ dw_pcie_clear_dword(&pcie->pci, pcie->cfg_link_cap_l1sub,
+ PCI_L1SS_CAP_ASPM_L1_1);
}
static void disable_aspm_l12(struct tegra_pcie_dw *pcie)
{
- u32 val;
-
- val = dw_pcie_readl_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub);
- val &= ~PCI_L1SS_CAP_ASPM_L1_2;
- dw_pcie_writel_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub, val);
+ dw_pcie_clear_dword(&pcie->pci, pcie->cfg_link_cap_l1sub,
+ PCI_L1SS_CAP_ASPM_L1_2);
}
static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event)
@@ -697,18 +690,18 @@ static void init_host_aspm(struct tegra_pcie_dw *pcie)
PCIE_RAS_DES_EVENT_COUNTER_CONTROL, val);
/* Program T_cmrt and T_pwr_on values */
- val = dw_pcie_readl_dbi(pci, pcie->cfg_link_cap_l1sub);
- val &= ~(PCI_L1SS_CAP_CM_RESTORE_TIME | PCI_L1SS_CAP_P_PWR_ON_VALUE);
- val |= (pcie->aspm_cmrt << 8);
+ val = (pcie->aspm_cmrt << 8);
val |= (pcie->aspm_pwr_on_t << 19);
- dw_pcie_writel_dbi(pci, pcie->cfg_link_cap_l1sub, val);
+ dw_pcie_clear_and_set_dword(pci, pcie->cfg_link_cap_l1sub,
+ PCI_L1SS_CAP_CM_RESTORE_TIME |
+ PCI_L1SS_CAP_P_PWR_ON_VALUE,
+ val);
/* Program L0s and L1 entrance latencies */
- val = dw_pcie_readl_dbi(pci, PCIE_PORT_AFR);
- val &= ~PORT_AFR_L0S_ENTRANCE_LAT_MASK;
- val |= (pcie->aspm_l0s_enter_lat << PORT_AFR_L0S_ENTRANCE_LAT_SHIFT);
+ val = (pcie->aspm_l0s_enter_lat << PORT_AFR_L0S_ENTRANCE_LAT_SHIFT);
val |= PORT_AFR_ENTER_ASPM;
- dw_pcie_writel_dbi(pci, PCIE_PORT_AFR, val);
+ dw_pcie_clear_and_set_dword(pci, PCIE_PORT_AFR,
+ PORT_AFR_L0S_ENTRANCE_LAT_MASK, val);
}
static void init_debugfs(struct tegra_pcie_dw *pcie)
@@ -860,9 +853,8 @@ static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie)
dw_pcie_writeb_dbi(pci, offset + i, val);
}
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK;
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
+ dw_pcie_clear_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK);
val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC;
@@ -870,10 +862,9 @@ static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie)
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE;
dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val);
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK;
- val |= (0x1 << GEN3_RELATED_OFF_RATE_SHADOW_SEL_SHIFT);
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
+ dw_pcie_clear_and_set_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK,
+ 0x1 << GEN3_RELATED_OFF_RATE_SHADOW_SEL_SHIFT);
val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC;
@@ -882,17 +873,14 @@ static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie)
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE;
dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val);
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK;
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
+ dw_pcie_clear_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK);
}
static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct tegra_pcie_dw *pcie = to_tegra_pcie(pci);
- u32 val;
- u16 val_16;
pp->bridge->ops = &tegra_pci_ops;
@@ -900,32 +888,25 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
pcie->pcie_cap_base = dw_pcie_find_capability(&pcie->pci,
PCI_CAP_ID_EXP);
- val = dw_pcie_readl_dbi(pci, PCI_IO_BASE);
- val &= ~(IO_BASE_IO_DECODE | IO_BASE_IO_DECODE_BIT8);
- dw_pcie_writel_dbi(pci, PCI_IO_BASE, val);
+ dw_pcie_clear_dword(pci, PCI_IO_BASE, IO_BASE_IO_DECODE |
+ IO_BASE_IO_DECODE_BIT8);
- val = dw_pcie_readl_dbi(pci, PCI_PREF_MEMORY_BASE);
- val |= CFG_PREF_MEM_LIMIT_BASE_MEM_DECODE;
- val |= CFG_PREF_MEM_LIMIT_BASE_MEM_LIMIT_DECODE;
- dw_pcie_writel_dbi(pci, PCI_PREF_MEMORY_BASE, val);
+ dw_pcie_set_dword(pci, PCI_PREF_MEMORY_BASE,
+ CFG_PREF_MEM_LIMIT_BASE_MEM_DECODE |
+ CFG_PREF_MEM_LIMIT_BASE_MEM_LIMIT_DECODE);
dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 0);
/* Enable as 0xFFFF0001 response for RRS */
- val = dw_pcie_readl_dbi(pci, PORT_LOGIC_AMBA_ERROR_RESPONSE_DEFAULT);
- val &= ~(AMBA_ERROR_RESPONSE_RRS_MASK << AMBA_ERROR_RESPONSE_RRS_SHIFT);
- val |= (AMBA_ERROR_RESPONSE_RRS_OKAY_FFFF0001 <<
- AMBA_ERROR_RESPONSE_RRS_SHIFT);
- dw_pcie_writel_dbi(pci, PORT_LOGIC_AMBA_ERROR_RESPONSE_DEFAULT, val);
+ dw_pcie_clear_and_set_dword(pci, PORT_LOGIC_AMBA_ERROR_RESPONSE_DEFAULT,
+ AMBA_ERROR_RESPONSE_RRS_MASK << AMBA_ERROR_RESPONSE_RRS_SHIFT,
+ AMBA_ERROR_RESPONSE_RRS_OKAY_FFFF0001 <<
+ AMBA_ERROR_RESPONSE_RRS_SHIFT);
/* Clear Slot Clock Configuration bit if SRNS configuration */
- if (pcie->enable_srns) {
- val_16 = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base +
- PCI_EXP_LNKSTA);
- val_16 &= ~PCI_EXP_LNKSTA_SLC;
- dw_pcie_writew_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA,
- val_16);
- }
+ if (pcie->enable_srns)
+ dw_pcie_clear_dword(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA,
+ PCI_EXP_LNKSTA_SLC);
config_gen3_gen4_eq_presets(pcie);
@@ -937,17 +918,13 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
disable_aspm_l12(pcie);
}
- if (!pcie->of_data->has_l1ss_exit_fix) {
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL;
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
- }
+ if (!pcie->of_data->has_l1ss_exit_fix)
+ dw_pcie_clear_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL);
- if (pcie->update_fc_fixup) {
- val = dw_pcie_readl_dbi(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF);
- val |= 0x1 << CFG_TIMER_CTRL_ACK_NAK_SHIFT;
- dw_pcie_writel_dbi(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF, val);
- }
+ if (pcie->update_fc_fixup)
+ dw_pcie_set_dword(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF,
+ 0x1 << CFG_TIMER_CTRL_ACK_NAK_SHIFT);
clk_set_rate(pcie->core_clk, GEN4_CORE_CLK_FREQ);
@@ -1018,9 +995,8 @@ static int tegra_pcie_dw_start_link(struct dw_pcie *pci)
reset_control_deassert(pcie->core_rst);
offset = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_DLF);
- val = dw_pcie_readl_dbi(pci, offset + PCI_DLF_CAP);
- val &= ~PCI_DLF_EXCHANGE_ENABLE;
- dw_pcie_writel_dbi(pci, offset + PCI_DLF_CAP, val);
+ dw_pcie_clear_dword(pci, offset + PCI_DLF_CAP,
+ PCI_DLF_EXCHANGE_ENABLE);
tegra_pcie_dw_host_init(pp);
dw_pcie_setup_rc(pp);
@@ -1847,11 +1823,9 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie)
reset_control_deassert(pcie->core_rst);
- if (pcie->update_fc_fixup) {
- val = dw_pcie_readl_dbi(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF);
- val |= 0x1 << CFG_TIMER_CTRL_ACK_NAK_SHIFT;
- dw_pcie_writel_dbi(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF, val);
- }
+ if (pcie->update_fc_fixup)
+ dw_pcie_set_dword(pci, CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF,
+ 0x1 << CFG_TIMER_CTRL_ACK_NAK_SHIFT);
config_gen3_gen4_eq_presets(pcie);
@@ -1863,11 +1837,9 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie)
disable_aspm_l12(pcie);
}
- if (!pcie->of_data->has_l1ss_exit_fix) {
- val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
- val &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL;
- dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
- }
+ if (!pcie->of_data->has_l1ss_exit_fix)
+ dw_pcie_clear_dword(pci, GEN3_RELATED_OFF,
+ GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL);
pcie->pcie_cap_base = dw_pcie_find_capability(&pcie->pci,
PCI_CAP_ID_EXP);
--
2.49.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
` (12 preceding siblings ...)
2025-08-28 13:59 ` [PATCH v5 13/13] PCI: tegra194: " Hans Zhang
@ 2025-08-28 20:44 ` Rob Herring
2025-09-03 17:25 ` Hans Zhang
13 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2025-08-28 20:44 UTC (permalink / raw)
To: Hans Zhang
Cc: lpieralisi, bhelgaas, mani, kwilczynski, jingoohan1, cassel,
linux-pci, linux-kernel, Hans Zhang
On Thu, Aug 28, 2025 at 9:00 AM Hans Zhang <18255117159@163.com> wrote:
>
> From: Hans Zhang <hans.zhang@cixtech.com>
>
> Register bit manipulation in DesignWare PCIe controllers currently
> uses repetitive read-modify-write sequences across multiple drivers.
> This pattern leads to code duplication and increases maintenance
> complexity as each driver implements similar logic with minor variations.
>
> This series introduces dw_pcie_*_dword() to centralize atomic
> register modification. The helper performs read-clear-set-write operations
> in a single function, replacing open-coded implementations. Subsequent
> patches refactor individual drivers to use this helper, eliminating
> redundant code and ensuring consistent bit handling.
>
> The change reduces overall code size by ~350 lines while improving
> maintainability. Each controller driver is updated in a separate
> patch to preserve bisectability and simplify review.
If RMW functions are an improvement, then they should go in io.h. I
don't think they are because they obfuscate the exact register
modifications and the possible need for locking. With common API,
anyone that understands kernel APIs will know what's going on. With a
driver specific API, then you have to go lookup what the API does
exactly. So I don't think this is an improvement.
Rob
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper
2025-08-28 20:44 ` [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Rob Herring
@ 2025-09-03 17:25 ` Hans Zhang
0 siblings, 0 replies; 16+ messages in thread
From: Hans Zhang @ 2025-09-03 17:25 UTC (permalink / raw)
To: Rob Herring
Cc: lpieralisi, bhelgaas, mani, kwilczynski, jingoohan1, cassel,
linux-pci, linux-kernel, Hans Zhang
On 2025/8/29 04:44, Rob Herring wrote:
> On Thu, Aug 28, 2025 at 9:00 AM Hans Zhang <18255117159@163.com> wrote:
>>
>> From: Hans Zhang <hans.zhang@cixtech.com>
>>
>> Register bit manipulation in DesignWare PCIe controllers currently
>> uses repetitive read-modify-write sequences across multiple drivers.
>> This pattern leads to code duplication and increases maintenance
>> complexity as each driver implements similar logic with minor variations.
>>
>> This series introduces dw_pcie_*_dword() to centralize atomic
>> register modification. The helper performs read-clear-set-write operations
>> in a single function, replacing open-coded implementations. Subsequent
>> patches refactor individual drivers to use this helper, eliminating
>> redundant code and ensuring consistent bit handling.
>>
>> The change reduces overall code size by ~350 lines while improving
>> maintainability. Each controller driver is updated in a separate
>> patch to preserve bisectability and simplify review.
>
> If RMW functions are an improvement, then they should go in io.h. I
> don't think they are because they obfuscate the exact register
> modifications and the possible need for locking. With common API,
> anyone that understands kernel APIs will know what's going on. With a
> driver specific API, then you have to go lookup what the API does
> exactly. So I don't think this is an improvement.
>
> Rob
Dear Rob,
Thank you very much for your reply.
My initial idea was to simplify the logic we wrote a lot of RMW under
the DWC driver. Then I saw that there were similar well-handled codes in
the linux kernel, so I came to do some cleaning work.
drivers/pci/access.c
int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
u32 clear, u32 set)
{
int ret;
u32 val;
ret = pcie_capability_read_dword(dev, pos, &val);
if (ret)
return ret;
val &= ~clear;
val |= set;
return pcie_capability_write_dword(dev, pos, val);
}
EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
include/linux/pci.h
static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
u32 set)
{
return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
}
static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
u32 clear)
{
return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
}
And the subsequent introduced API: Personally, I think they are very
valuable for reference. Of course, it depends on the final opinions of
the maintainer and all of you.
drivers/pci/access.c
void pci_clear_and_set_config_dword(const struct pci_dev *dev, int pos,
u32 clear, u32 set)
{
u32 val;
pci_read_config_dword(dev, pos, &val);
val &= ~clear;
val |= set;
pci_write_config_dword(dev, pos, val);
}
EXPORT_SYMBOL(pci_clear_and_set_config_dword);
Best regards,
Hans
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-09-03 17:26 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 13:59 [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Hans Zhang
2025-08-28 13:59 ` [PATCH v5 01/13] PCI: dwc: Add dw_pcie_*_dword() for register bit manipulation Hans Zhang
2025-08-28 13:59 ` [PATCH v5 02/13] PCI: dwc: Refactor code by using dw_pcie_*_dword() Hans Zhang
2025-08-28 13:59 ` [PATCH v5 03/13] PCI: dra7xx: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 04/13] PCI: imx6: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 05/13] PCI: meson: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 06/13] PCI: armada8k: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 07/13] PCI: bt1: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 08/13] PCI: dw-rockchip: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 09/13] PCI: fu740: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 10/13] PCI: qcom: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 11/13] PCI: qcom-ep: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 12/13] PCI: rcar-gen4: " Hans Zhang
2025-08-28 13:59 ` [PATCH v5 13/13] PCI: tegra194: " Hans Zhang
2025-08-28 20:44 ` [PATCH v5 00/13] PCI: dwc: Refactor register access with dw_pcie_*_dword helper Rob Herring
2025-09-03 17:25 ` Hans Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).