Skip to contentSkip to conversation

NTB: Register and offset values fix for memory window

PATCH Applied Shyam Sundar S K 3 participants 3 messages Dec 1, 2016 – Dec 21, 2016

Subsystems (2)

v1 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 NTB: Register and offset values fix for memory window

Due to incorrect limit and translation register values, NTB link was going down when the memory window was setup. Made appropriate changes as per spec.

Fix limit register values for BAR1, which was overlapping with the BAR23 address.

---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +4 -10
index 6ccba0d..d59f494 100644
@@ -138,11 +138,11 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 	base_addr = pci_resource_start(ndev->ntb.pdev, bar);
 
 	if (bar != 1) {
-		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 3);
-		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 3);
+		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2);
+		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 2);
 
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
@@ -164,14 +164,8 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 		xlat_reg = AMD_BAR1XLAT_OFFSET;
 		limit_reg = AMD_BAR1LMT_OFFSET;
 
-		/* split bar addr range must all be 32 bit */
-		if (addr & (~0ull << 32))
-			return -EINVAL;
-		if ((addr + size) & (~0ull << 32))
-			return -EINVAL;
-
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
Signature · 1 line
2.7.4
Acked-by on v1 2/2
#1 lore raw

From: Shyam Sundar S K

Quoted 11 lines

Due to incorrect limit and translation register values, NTB link was going down when the memory window was setup. Made appropriate changes as per spec.

Fix limit register values for BAR1, which was overlapping with the BAR23 address.

Quoted 41 lines
---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +4 -11
index 6ccba0d..d59f494 100644
@@ -138,11 +138,11 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 	base_addr = pci_resource_start(ndev->ntb.pdev, bar);
 
 	if (bar != 1) {
-		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 3);
-		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 3);
+		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2);
+		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 2);
 
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
@@ -164,14 +164,8 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 		xlat_reg = AMD_BAR1XLAT_OFFSET;
 		limit_reg = AMD_BAR1LMT_OFFSET;
 
-		/* split bar addr range must all be 32 bit */
-		if (addr & (~0ull << 32))
-			return -EINVAL;
-		if ((addr + size) & (~0ull << 32))
-			return -EINVAL;
-
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
--

2.7.4

maintainer Applied
#2 lore raw
Quoted 8 lines · Allen Hubbe

From: Shyam Sundar S K

Quoted 7 lines

Due to incorrect limit and translation register values, NTB link was going down when the memory window was setup. Made appropriate changes as per spec.

Fix limit register values for BAR1, which was overlapping with the BAR23 address.

Quoted 6 lines
Quoted 4 lines

Applied to my NTB branch

Thanks,
Jon

Quoted 43 lines
Quoted 42 lines
---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/ntb/hw/amd/ntb_hw_amd.c +4 -11
index 6ccba0d..d59f494 100644
@@ -138,11 +138,11 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 	base_addr = pci_resource_start(ndev->ntb.pdev, bar);
 
 	if (bar != 1) {
-		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 3);
-		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 3);
+		xlat_reg = AMD_BAR23XLAT_OFFSET + ((bar - 2) << 2);
+		limit_reg = AMD_BAR23LMT_OFFSET + ((bar - 2) << 2);
 
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
@@ -164,14 +164,8 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 		xlat_reg = AMD_BAR1XLAT_OFFSET;
 		limit_reg = AMD_BAR1LMT_OFFSET;
 
-		/* split bar addr range must all be 32 bit */
-		if (addr & (~0ull << 32))
-			return -EINVAL;
-		if ((addr + size) & (~0ull << 32))
-			return -EINVAL;
-
 		/* Set the limit if supported */
-		limit = base_addr + size;
+		limit = size;
 
 		/* set and verify setting the translation address */
 		write64(addr, peer_mmio + xlat_reg);
--

2.7.4