From: Hans Zhang <18255117159@163.com>
To: Frank Li <Frank.li@nxp.com>
Cc: lpieralisi@kernel.org, bhelgaas@google.com, mani@kernel.org,
kwilczynski@kernel.org, robh@kernel.org, jingoohan1@gmail.com,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 04/13] PCI: imx6: Refactor code by using dw_pcie_clear_and_set_dword()
Date: Fri, 27 Jun 2025 23:33:20 +0800 [thread overview]
Message-ID: <f24aac22-d53e-4751-8bc5-db86a6d12598@163.com> (raw)
In-Reply-To: <aF1/DzLRRhtgFVsH@lizhi-Precision-Tower-5810>
On 2025/6/27 01:10, Frank Li wrote:
> On Thu, Jun 26, 2025 at 10:50:31PM +0800, Hans Zhang wrote:
>> 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_clear_and_set_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>
>
> missed my review tag, you need collect all review tags when respin patches.
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> https://lore.kernel.org/linux-pci/aFQp4MYpRaEUXNQy@lizhi-Precision-Tower-5810/
>
Dear Frank,
Sorry. Next time I will check the corresponding tag.
Best regards,
Hans
>
>> ---
>> 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 5a38cfaf989b..3004e432f013 100644
>> --- a/drivers/pci/controller/dwc/pci-imx6.c
>> +++ b/drivers/pci/controller/dwc/pci-imx6.c
>> @@ -941,7 +941,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 &
>> @@ -956,10 +955,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. */
>> @@ -972,18 +970,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_clear_and_set_dword(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
>> + 0, PORT_LOGIC_SPEED_CHANGE);
>> dw_pcie_dbi_ro_wr_dis(pci);
>>
>> ret = imx_pcie_wait_for_speed_change(imx_pcie);
>> @@ -1295,7 +1291,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) {
>> /*
>> @@ -1310,9 +1305,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_and_set_dword(pci, GEN3_RELATED_OFF,
>> + GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL, 0);
>> dw_pcie_dbi_ro_wr_dis(pci);
>> }
>> }
>> --
>> 2.25.1
>>
next prev parent reply other threads:[~2025-06-27 15:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 14:50 [PATCH v3 00/13] PCI: dwc: Refactor register access with dw_pcie_clear_and_set_dword helper Hans Zhang
2025-06-26 14:50 ` [PATCH v3 01/13] PCI: dwc: Add dw_pcie_clear_and_set_dword() for register bit manipulation Hans Zhang
2025-06-26 14:50 ` [PATCH v3] PCI: dwc: Refactor code by using dw_pcie_clear_and_set_dword() Hans Zhang
2025-06-26 14:55 ` Hans Zhang
2025-06-27 22:20 ` kernel test robot
2025-06-28 15:44 ` Hans Zhang
2025-06-26 14:50 ` [PATCH v3 03/13] PCI: dra7xx: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 04/13] PCI: imx6: " Hans Zhang
2025-06-26 17:10 ` Frank Li
2025-06-27 15:33 ` Hans Zhang [this message]
2025-06-26 14:50 ` [PATCH v3 05/13] PCI: meson: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 06/13] PCI: armada8k: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 07/13] PCI: bt1: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 08/13] PCI: dw-rockchip: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 09/13] PCI: fu740: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 10/13] PCI: qcom: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 11/13] PCI: qcom-ep: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 12/13] PCI: rcar-gen4: " Hans Zhang
2025-06-26 14:50 ` [PATCH v3 13/13] PCI: tegra194: " Hans Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f24aac22-d53e-4751-8bc5-db86a6d12598@163.com \
--to=18255117159@163.com \
--cc=Frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=jingoohan1@gmail.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).