diff mbox series

misc: pci_endpoint_test: Use a unique test pattern for each BAR

Message ID 20231215105952.1531683-1-nks@flawful.org (mailing list archive)
State Accepted
Delegated to: Krzysztof Wilczyński
Headers show
Series misc: pci_endpoint_test: Use a unique test pattern for each BAR | expand

Commit Message

Niklas Cassel Dec. 15, 2023, 10:59 a.m. UTC
From: Niklas Cassel <niklas.cassel@wdc.com>

Use a unique test pattern for each BAR in. This makes it easier to
detect/debug address translation issues, since a developer can dump
the backing memory on the EP side, using e.g. devmem, to verify that
the address translation for each BAR is actually correct.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 drivers/misc/pci_endpoint_test.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Damien Le Moal Dec. 18, 2023, 10:03 a.m. UTC | #1
On 2023/12/15 19:59, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> Use a unique test pattern for each BAR in. This makes it easier to
> detect/debug address translation issues, since a developer can dump
> the backing memory on the EP side, using e.g. devmem, to verify that
> the address translation for each BAR is actually correct.
> 
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>

Looks OK to me.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Manivannan Sadhasivam Dec. 18, 2023, 4:18 p.m. UTC | #2
On Fri, Dec 15, 2023 at 11:59:51AM +0100, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> Use a unique test pattern for each BAR in. This makes it easier to
> detect/debug address translation issues, since a developer can dump
> the backing memory on the EP side, using e.g. devmem, to verify that
> the address translation for each BAR is actually correct.
> 
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> ---
>  drivers/misc/pci_endpoint_test.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> index a765a05f0c64..7ac1922475af 100644
> --- a/drivers/misc/pci_endpoint_test.c
> +++ b/drivers/misc/pci_endpoint_test.c
> @@ -263,6 +263,15 @@ static bool pci_endpoint_test_request_irq(struct pci_endpoint_test *test)
>  	return false;
>  }
>  
> +static const u32 bar_test_pattern[] = {
> +	0xA0A0A0A0,
> +	0xA1A1A1A1,
> +	0xA2A2A2A2,
> +	0xA3A3A3A3,
> +	0xA4A4A4A4,
> +	0xA5A5A5A5,
> +};
> +
>  static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
>  				  enum pci_barno barno)
>  {
> @@ -280,11 +289,12 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
>  		size = 0x4;
>  
>  	for (j = 0; j < size; j += 4)
> -		pci_endpoint_test_bar_writel(test, barno, j, 0xA0A0A0A0);
> +		pci_endpoint_test_bar_writel(test, barno, j,
> +					     bar_test_pattern[barno]);
>  
>  	for (j = 0; j < size; j += 4) {
>  		val = pci_endpoint_test_bar_readl(test, barno, j);
> -		if (val != 0xA0A0A0A0)
> +		if (val != bar_test_pattern[barno])
>  			return false;
>  	}
>  
> -- 
> 2.43.0
>
Krzysztof Wilczyński Jan. 6, 2024, 5:03 a.m. UTC | #3
Hello,

> Use a unique test pattern for each BAR in. This makes it easier to
> detect/debug address translation issues, since a developer can dump
> the backing memory on the EP side, using e.g. devmem, to verify that
> the address translation for each BAR is actually correct.

Applied to misc, thank you!

[1/1] misc: pci_endpoint_test: Use a unique test pattern for each BAR
      https://git.kernel.org/pci/pci/c/516f366434e1

	Krzysztof
diff mbox series

Patch

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index a765a05f0c64..7ac1922475af 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -263,6 +263,15 @@  static bool pci_endpoint_test_request_irq(struct pci_endpoint_test *test)
 	return false;
 }
 
+static const u32 bar_test_pattern[] = {
+	0xA0A0A0A0,
+	0xA1A1A1A1,
+	0xA2A2A2A2,
+	0xA3A3A3A3,
+	0xA4A4A4A4,
+	0xA5A5A5A5,
+};
+
 static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
 				  enum pci_barno barno)
 {
@@ -280,11 +289,12 @@  static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
 		size = 0x4;
 
 	for (j = 0; j < size; j += 4)
-		pci_endpoint_test_bar_writel(test, barno, j, 0xA0A0A0A0);
+		pci_endpoint_test_bar_writel(test, barno, j,
+					     bar_test_pattern[barno]);
 
 	for (j = 0; j < size; j += 4) {
 		val = pci_endpoint_test_bar_readl(test, barno, j);
-		if (val != 0xA0A0A0A0)
+		if (val != bar_test_pattern[barno])
 			return false;
 	}