All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shyam Sundar S K <ssundark@amd.com>
To: "Yu, Xiangliang" <Xiangliang.Yu@amd.com>, jdmason@kudzu.us
Cc: dave.jiang@intel.com, Allen.Hubbe@emc.com,
	linux-ntb@googlegroups.com, "Sen, Pankaj" <Pankaj.Sen@amd.com>,
	"Shah, Nehal-bakulchandra" <Nehal-bakulchandra.Shah@amd.com>,
	"Agrawal, Nitesh-kumar" <Nitesh-kumar.Agrawal@amd.com>,
	"Subramaniyan, Ramkumar" <ramkumar.ks@amd.com>,
	Richard1.Su@amd.com
Subject: [PATCH] NTB: Register and offset values fix for memory window
Date: Mon, 14 Nov 2016 14:30:23 +0530	[thread overview]
Message-ID: <c44465a3-780b-3dbd-22dc-4be241009e3c@amd.com> (raw)

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

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

Reviewed-by: Sen, Pankaj <Pankaj.Sen@amd.com>
Reviewed-by: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>
Acked-by: Xiangliang Yu <Xiangliang.Yu@amd.com>
Signed-off-by: S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>
---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 6ccba0d..9bbe3e0 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -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,9 @@ 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);
@@ -376,13 +371,11 @@ static u32 amd_ntb_spad_read(struct ntb_dev *ntb, int idx)
 {
 	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
 	void __iomem *mmio = ndev->self_mmio;
-	u32 offset;

-	if (idx < 0 || idx >= ndev->spad_count)
+	if (idx < 0 || idx >= (ndev->spad_count + 4))
 		return 0;

-	offset = ndev->self_spad + (idx << 2);
-	return readl(mmio + AMD_SPAD_OFFSET + offset);
+	return readl(mmio + AMD_SPAD_OFFSET + (idx << 2));
 }

 static int amd_ntb_spad_write(struct ntb_dev *ntb,
@@ -392,11 +385,10 @@ static int amd_ntb_spad_write(struct ntb_dev *ntb,
 	void __iomem *mmio = ndev->self_mmio;
 	u32 offset;

-	if (idx < 0 || idx >= ndev->spad_count)
+	if (idx < 0 || idx >= (ndev->spad_count + 4))
 		return -EINVAL;

-	offset = ndev->self_spad + (idx << 2);
-	writel(val, mmio + AMD_SPAD_OFFSET + offset);
+	writel(val, mmio + AMD_SPAD_OFFSET + (idx << 2));

 	return 0;
 }
@@ -405,13 +397,11 @@ static u32 amd_ntb_peer_spad_read(struct ntb_dev *ntb, int idx)
 {
 	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
 	void __iomem *mmio = ndev->self_mmio;
-	u32 offset;

-	if (idx < 0 || idx >= ndev->spad_count)
+	if (idx < 0 || idx >= (ndev->spad_count + 4))
 		return -EINVAL;

-	offset = ndev->peer_spad + (idx << 2);
-	return readl(mmio + AMD_SPAD_OFFSET + offset);
+	return readl(mmio + AMD_SPAD_OFFSET + (idx << 2));
 }

 static int amd_ntb_peer_spad_write(struct ntb_dev *ntb,
@@ -421,11 +411,10 @@ static int amd_ntb_peer_spad_write(struct ntb_dev *ntb,
 	void __iomem *mmio = ndev->self_mmio;
 	u32 offset;

-	if (idx < 0 || idx >= ndev->spad_count)
+	if (idx < 0 || idx >= (ndev->spad_count + 4))
 		return -EINVAL;

-	offset = ndev->peer_spad + (idx << 2);
-	writel(val, mmio + AMD_SPAD_OFFSET + offset);
+	writel(val, mmio + AMD_SPAD_OFFSET + (idx << 2));

 	return 0;
 }
-- 
2.7.4

             reply	other threads:[~2016-11-14  9:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14  9:00 Shyam Sundar S K [this message]
2016-11-14 14:35 ` [PATCH] NTB: Register and offset values fix for memory window Allen Hubbe
2016-11-15  7:04   ` Shyam Sundar S K
2016-11-17 15:39     ` Jon Mason
2016-11-22  1:45       ` Shyam Sundar S K
2016-11-22 14:19         ` Allen Hubbe
2016-11-22 15:12           ` Shyam Sundar S K
2016-11-29 14:55           ` Shyam Sundar S K
2016-11-29 16:03             ` Allen Hubbe
2016-12-01 18:57               ` Shyam Sundar S K

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=c44465a3-780b-3dbd-22dc-4be241009e3c@amd.com \
    --to=ssundark@amd.com \
    --cc=Allen.Hubbe@emc.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Nitesh-kumar.Agrawal@amd.com \
    --cc=Pankaj.Sen@amd.com \
    --cc=Richard1.Su@amd.com \
    --cc=Xiangliang.Yu@amd.com \
    --cc=dave.jiang@intel.com \
    --cc=jdmason@kudzu.us \
    --cc=linux-ntb@googlegroups.com \
    --cc=ramkumar.ks@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.