linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: cadence: Fix next function value in case of ARI
@ 2023-01-18  7:20 Achal Verma
  2023-01-18  9:06 ` Siddharth Vadapalli
  2023-01-18 17:04 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Achal Verma @ 2023-01-18  7:20 UTC (permalink / raw)
  To: Tom Joseph, Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczy_ski,
	Bjorn Helgaas, Vignesh Raghavendra
  Cc: linux-pci, linux-kernel, linux-omap, linux-arm-kernel,
	Achal Verma, Milind Parab, Jian Wang

From: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>

Next function field in ARI_CAP_AND_CTR field register for last
function should be zero but thats not the case, so this patch
programs the next function field for last function as zero.

Signed-off-by: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
Signed-off-by: Achal Verma <a-verma1@ti.com>
---
 drivers/pci/controller/cadence/pcie-cadence-ep.c | 15 ++++++++++++++-
 drivers/pci/controller/cadence/pcie-cadence.h    |  6 ++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
index b8b655d4047e..6b6904cf0123 100644
--- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
+++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
@@ -565,7 +565,8 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
 	struct cdns_pcie *pcie = &ep->pcie;
 	struct device *dev = pcie->dev;
 	int max_epfs = sizeof(epc->function_num_map) * 8;
-	int ret, value, epf;
+	int ret, epf, last_fn;
+	u32 reg, value;
 
 	/*
 	 * BIT(0) is hardwired to 1, hence function 0 is always enabled
@@ -573,6 +574,18 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
 	 */
 	cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map);
 
+	/* Setup ARI Next Function Number.
+	 * This field should point to the next physical Function and 0 for
+	 * last Function.
+	 */
+	last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG);
+	reg     = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn);
+
+	// Clear Next Function Number for the last function used.
+	value  = cdns_pcie_readl(pcie, reg);
+	value &= ~CDNS_PCIE_ARI_CAP_NFN_MASK;
+	cdns_pcie_writel(pcie, reg, value);
+
 	if (ep->quirk_disable_flr) {
 		for (epf = 0; epf < max_epfs; epf++) {
 			if (!(epc->function_num_map & BIT(epf)))
diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
index 190786e47df9..68c4c7878111 100644
--- a/drivers/pci/controller/cadence/pcie-cadence.h
+++ b/drivers/pci/controller/cadence/pcie-cadence.h
@@ -130,6 +130,12 @@
 #define CDNS_PCIE_EP_FUNC_DEV_CAP_OFFSET	0xc0
 #define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET	0x200
 
+/*
+ * Endpoint PF Registers
+ */
+#define CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(fn)	(0x144 + (fn) * 0x1000)
+#define CDNS_PCIE_ARI_CAP_NFN_MASK	GENMASK(15, 8)
+
 /*
  * Root Port Registers (PCI configuration space for the root port function)
  */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: cadence: Fix next function value in case of ARI
  2023-01-18  7:20 [PATCH] PCI: cadence: Fix next function value in case of ARI Achal Verma
@ 2023-01-18  9:06 ` Siddharth Vadapalli
  2023-01-18 17:04 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Siddharth Vadapalli @ 2023-01-18  9:06 UTC (permalink / raw)
  To: Achal Verma
  Cc: Tom Joseph, Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczy_ski,
	Bjorn Helgaas, Vignesh Raghavendra, linux-pci, linux-kernel,
	linux-omap, linux-arm-kernel, Milind Parab, Jian Wang,
	s-vadapalli

Hello Achal,

On 18/01/23 12:50, Achal Verma wrote:
> From: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
> 
> Next function field in ARI_CAP_AND_CTR field register for last
> function should be zero but thats not the case, so this patch
> programs the next function field for last function as zero.
> 
> Signed-off-by: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
> Signed-off-by: Achal Verma <a-verma1@ti.com>
> ---
>  drivers/pci/controller/cadence/pcie-cadence-ep.c | 15 ++++++++++++++-
>  drivers/pci/controller/cadence/pcie-cadence.h    |  6 ++++++
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> index b8b655d4047e..6b6904cf0123 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> @@ -565,7 +565,8 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
>  	struct cdns_pcie *pcie = &ep->pcie;
>  	struct device *dev = pcie->dev;
>  	int max_epfs = sizeof(epc->function_num_map) * 8;
> -	int ret, value, epf;
> +	int ret, epf, last_fn;
> +	u32 reg, value;
>  
>  	/*
>  	 * BIT(0) is hardwired to 1, hence function 0 is always enabled
> @@ -573,6 +574,18 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
>  	 */
>  	cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map);
>  
> +	/* Setup ARI Next Function Number.

Please follow the standard multi-line commenting style with the first line being
"/*" followed by the comment on the next line.

> +	 * This field should point to the next physical Function and 0 for
> +	 * last Function.
> +	 */
> +	last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG);
> +	reg     = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn);
> +
> +	// Clear Next Function Number for the last function used.

Please enclose the comment within /* and */.

Regards,
Siddharth.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: cadence: Fix next function value in case of ARI
  2023-01-18  7:20 [PATCH] PCI: cadence: Fix next function value in case of ARI Achal Verma
  2023-01-18  9:06 ` Siddharth Vadapalli
@ 2023-01-18 17:04 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2023-01-18 17:04 UTC (permalink / raw)
  To: Achal Verma
  Cc: Tom Joseph, Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczy_ski,
	Bjorn Helgaas, Vignesh Raghavendra, linux-pci, linux-kernel,
	linux-omap, linux-arm-kernel, Milind Parab, Jian Wang

On Wed, Jan 18, 2023 at 12:50:35PM +0530, Achal Verma wrote:
> From: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
> 
> Next function field in ARI_CAP_AND_CTR field register for last
> function should be zero but thats not the case, so this patch
> programs the next function field for last function as zero.

s/thats/that's/

When you fix the comment formatting, also update the commit log to be
imperative style and use the terms from the spec, e.g.,

  Clear the ARI Capability Next Function Number of the last function.

ARI_CAP_AND_CTR is a Cadence-specific name (and doesn't seem to appear
even in that driver).  The commit log should use the PCIe term.

See https://chris.beams.io/posts/git-commit/

> Signed-off-by: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
> Signed-off-by: Achal Verma <a-verma1@ti.com>
> ---
>  drivers/pci/controller/cadence/pcie-cadence-ep.c | 15 ++++++++++++++-
>  drivers/pci/controller/cadence/pcie-cadence.h    |  6 ++++++
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> index b8b655d4047e..6b6904cf0123 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
> @@ -565,7 +565,8 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
>  	struct cdns_pcie *pcie = &ep->pcie;
>  	struct device *dev = pcie->dev;
>  	int max_epfs = sizeof(epc->function_num_map) * 8;
> -	int ret, value, epf;
> +	int ret, epf, last_fn;
> +	u32 reg, value;
>  
>  	/*
>  	 * BIT(0) is hardwired to 1, hence function 0 is always enabled
> @@ -573,6 +574,18 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
>  	 */
>  	cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, epc->function_num_map);
>  
> +	/* Setup ARI Next Function Number.
> +	 * This field should point to the next physical Function and 0 for
> +	 * last Function.
> +	 */
> +	last_fn = find_last_bit(&epc->function_num_map, BITS_PER_LONG);
> +	reg     = CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(last_fn);
> +
> +	// Clear Next Function Number for the last function used.
> +	value  = cdns_pcie_readl(pcie, reg);
> +	value &= ~CDNS_PCIE_ARI_CAP_NFN_MASK;
> +	cdns_pcie_writel(pcie, reg, value);
> +
>  	if (ep->quirk_disable_flr) {
>  		for (epf = 0; epf < max_epfs; epf++) {
>  			if (!(epc->function_num_map & BIT(epf)))
> diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h
> index 190786e47df9..68c4c7878111 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence.h
> +++ b/drivers/pci/controller/cadence/pcie-cadence.h
> @@ -130,6 +130,12 @@
>  #define CDNS_PCIE_EP_FUNC_DEV_CAP_OFFSET	0xc0
>  #define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET	0x200
>  
> +/*
> + * Endpoint PF Registers
> + */
> +#define CDNS_PCIE_CORE_PF_I_ARI_CAP_AND_CTRL(fn)	(0x144 + (fn) * 0x1000)
> +#define CDNS_PCIE_ARI_CAP_NFN_MASK	GENMASK(15, 8)
> +
>  /*
>   * Root Port Registers (PCI configuration space for the root port function)
>   */
> -- 
> 2.25.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-18 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18  7:20 [PATCH] PCI: cadence: Fix next function value in case of ARI Achal Verma
2023-01-18  9:06 ` Siddharth Vadapalli
2023-01-18 17:04 ` Bjorn Helgaas

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).