mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Hans Zhang <18255117159@163.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org,
	kwilczynski@kernel.org, mani@kernel.org, jingoohan1@gmail.com,
	robh@kernel.org, a-garg7@ti.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: dwc: Describe DWC PCIe fields with full masks and FIELD_PREP()
Date: Mon, 19 Oct 2026 12:12:44 -0500	[thread overview]
Message-ID: <20261019171244.GA2200874@bhelgaas> (raw)
In-Reply-To: <20260930013842.82476-1-18255117159@163.com>

On Wed, Sep 30, 2026 at 09:38:42AM +0800, Hans Zhang wrote:
> Several DWC PCIe register fields are described with a shift macro next
> to their mask, or with only a shift and the field width implied by the
> value written.  Document the field position and width in a single full
> mask and use FIELD_PREP() to encode it.
> 
> No functional change intended.

> @@ -278,15 +275,14 @@
>  #define RAS_DES_EVENT_COUNTER_CONTROL	0x8
>  #define EVENT_COUNTER_ALL_CLEAR		0x3
>  #define EVENT_COUNTER_ENABLE_ALL	0x7
> -#define EVENT_COUNTER_ENABLE_SHIFT	2
> -#define EVENT_COUNTER_EVENT_SEL_MASK	GENMASK(7, 0)
> -#define EVENT_COUNTER_EVENT_SEL_SHIFT	16
> +#define EVENT_COUNTER_ENABLE_MASK	GENMASK(4, 2)
> +#define EVENT_COUNTER_EVENT_SEL_MASK	GENMASK(23, 16)
> +#define EVENT_COUNTER_GROUP_SEL_MASK	GENMASK(27, 24)
>  #define EVENT_COUNTER_EVENT_Tx_L0S	0x2
>  #define EVENT_COUNTER_EVENT_Rx_L0S	0x3
>  #define EVENT_COUNTER_EVENT_L1		0x5
>  #define EVENT_COUNTER_EVENT_L1_1	0x7
>  #define EVENT_COUNTER_EVENT_L1_2	0x8
> -#define EVENT_COUNTER_GROUP_SEL_SHIFT	24
>  #define EVENT_COUNTER_GROUP_5		0x5
>  
>  #define RAS_DES_EVENT_COUNTER_DATA	0xc
> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
> index 8c610212a180..285a38178da8 100644
> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
> @@ -622,10 +622,10 @@ static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event)
>  
>  	val = dw_pcie_readl_dbi(&pcie->pci, pcie->ras_des_cap +
>  				RAS_DES_EVENT_COUNTER_CONTROL);
> -	val &= ~(EVENT_COUNTER_EVENT_SEL_MASK << EVENT_COUNTER_EVENT_SEL_SHIFT);
> -	val |= EVENT_COUNTER_GROUP_5 << EVENT_COUNTER_GROUP_SEL_SHIFT;
> -	val |= event << EVENT_COUNTER_EVENT_SEL_SHIFT;
> -	val |= EVENT_COUNTER_ENABLE_ALL << EVENT_COUNTER_ENABLE_SHIFT;
> +	val &= ~EVENT_COUNTER_EVENT_SEL_MASK;
> +	val |= FIELD_PREP(EVENT_COUNTER_GROUP_SEL_MASK, EVENT_COUNTER_GROUP_5);

Should EVENT_COUNTER_GROUP_SEL_MASK be cleared out before ORing
EVENT_COUNTER_GROUP_5 into it?

I see the previous code didn't clear it either, but I'm wondering if
this is a latent bug that should be fixed, probably with a separate
patch if so.

> +	val |= FIELD_PREP(EVENT_COUNTER_EVENT_SEL_MASK, event);
> +	val |= FIELD_PREP(EVENT_COUNTER_ENABLE_MASK, EVENT_COUNTER_ENABLE_ALL);
>  	dw_pcie_writel_dbi(&pcie->pci, pcie->ras_des_cap +
>  			   RAS_DES_EVENT_COUNTER_CONTROL, val);
>  	val = dw_pcie_readl_dbi(&pcie->pci, pcie->ras_des_cap +

      parent reply	other threads:[~2026-10-19 17:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  1:38 Hans Zhang
2026-10-14  6:52 ` Hans Zhang
2026-10-17  5:06 ` Manivannan Sadhasivam
2026-10-19 17:12 ` Bjorn Helgaas [this message]

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=20261019171244.GA2200874@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=18255117159@163.com \
    --cc=a-garg7@ti.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

all inboxes | Powered by JetHome®