Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532601

[PATCH 14/22] NTB AMD: Move link-related methods being first in the driver

From Serge Semin <fancer.lancer@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 14/22] NTB AMD: Move link-related methods being first in the driver
Date 2016-11-29 18:30 +0100
Message-ID <sIUob-311-67@gated-at.bofh.it> (permalink)
References <sIUet-2Xs-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


See patch 01 for reasoning of this movement.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>

---
 drivers/ntb/hw/amd/ntb_hw_amd.c | 188 ++++++++++++++++++++--------------------
 1 file changed, 94 insertions(+), 94 deletions(-)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 6ccba0d..6704327 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -71,6 +71,97 @@ MODULE_AUTHOR("AMD Inc.");
 static const struct file_operations amd_ntb_debugfs_info;
 static struct dentry *debugfs_dir;
 
+static int amd_link_is_up(struct amd_ntb_dev *ndev)
+{
+	if (!ndev->peer_sta)
+		return NTB_LNK_STA_ACTIVE(ndev->cntl_sta);
+
+	/* If peer_sta is reset or D0 event, the ISR has
+	 * started a timer to check link status of hardware.
+	 * So here just clear status bit. And if peer_sta is
+	 * D3 or PME_TO, D0/reset event will be happened when
+	 * system wakeup/poweron, so do nothing here.
+	 */
+	if (ndev->peer_sta & AMD_PEER_RESET_EVENT)
+		ndev->peer_sta &= ~AMD_PEER_RESET_EVENT;
+	else if (ndev->peer_sta & AMD_PEER_D0_EVENT)
+		ndev->peer_sta = 0;
+
+	return 0;
+}
+
+static int amd_ntb_link_is_up(struct ntb_dev *ntb,
+			      enum ntb_speed *speed,
+			      enum ntb_width *width)
+{
+	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+	int ret = 0;
+
+	if (amd_link_is_up(ndev)) {
+		if (speed)
+			*speed = NTB_LNK_STA_SPEED(ndev->lnk_sta);
+		if (width)
+			*width = NTB_LNK_STA_WIDTH(ndev->lnk_sta);
+
+		dev_dbg(ndev_dev(ndev), "link is up.\n");
+
+		ret = 1;
+	} else {
+		if (speed)
+			*speed = NTB_SPEED_NONE;
+		if (width)
+			*width = NTB_WIDTH_NONE;
+
+		dev_dbg(ndev_dev(ndev), "link is down.\n");
+	}
+
+	return ret;
+}
+
+static int amd_ntb_link_enable(struct ntb_dev *ntb,
+			       enum ntb_speed max_speed,
+			       enum ntb_width max_width)
+{
+	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+	void __iomem *mmio = ndev->self_mmio;
+	u32 ntb_ctl;
+
+	/* Enable event interrupt */
+	ndev->int_mask &= ~AMD_EVENT_INTMASK;
+	writel(ndev->int_mask, mmio + AMD_INTMASK_OFFSET);
+
+	if (ndev->ntb.topo == NTB_TOPO_SEC)
+		return -EINVAL;
+	dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
+
+	ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
+	ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
+	writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
+
+	return 0;
+}
+
+static int amd_ntb_link_disable(struct ntb_dev *ntb)
+{
+	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
+	void __iomem *mmio = ndev->self_mmio;
+	u32 ntb_ctl;
+
+	/* Disable event interrupt */
+	ndev->int_mask |= AMD_EVENT_INTMASK;
+	writel(ndev->int_mask, mmio + AMD_INTMASK_OFFSET);
+
+	if (ndev->ntb.topo == NTB_TOPO_SEC)
+		return -EINVAL;
+	dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
+
+	ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
+	ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);
+	writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
+
+	return 0;
+}
+
 static int ndev_mw_to_bar(struct amd_ntb_dev *ndev, int idx)
 {
 	if (idx < 0 || idx > ndev->mw_count)
@@ -194,97 +285,6 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int idx,
 	return 0;
 }
 
-static int amd_link_is_up(struct amd_ntb_dev *ndev)
-{
-	if (!ndev->peer_sta)
-		return NTB_LNK_STA_ACTIVE(ndev->cntl_sta);
-
-	/* If peer_sta is reset or D0 event, the ISR has
-	 * started a timer to check link status of hardware.
-	 * So here just clear status bit. And if peer_sta is
-	 * D3 or PME_TO, D0/reset event will be happened when
-	 * system wakeup/poweron, so do nothing here.
-	 */
-	if (ndev->peer_sta & AMD_PEER_RESET_EVENT)
-		ndev->peer_sta &= ~AMD_PEER_RESET_EVENT;
-	else if (ndev->peer_sta & AMD_PEER_D0_EVENT)
-		ndev->peer_sta = 0;
-
-	return 0;
-}
-
-static int amd_ntb_link_is_up(struct ntb_dev *ntb,
-			      enum ntb_speed *speed,
-			      enum ntb_width *width)
-{
-	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
-	int ret = 0;
-
-	if (amd_link_is_up(ndev)) {
-		if (speed)
-			*speed = NTB_LNK_STA_SPEED(ndev->lnk_sta);
-		if (width)
-			*width = NTB_LNK_STA_WIDTH(ndev->lnk_sta);
-
-		dev_dbg(ndev_dev(ndev), "link is up.\n");
-
-		ret = 1;
-	} else {
-		if (speed)
-			*speed = NTB_SPEED_NONE;
-		if (width)
-			*width = NTB_WIDTH_NONE;
-
-		dev_dbg(ndev_dev(ndev), "link is down.\n");
-	}
-
-	return ret;
-}
-
-static int amd_ntb_link_enable(struct ntb_dev *ntb,
-			       enum ntb_speed max_speed,
-			       enum ntb_width max_width)
-{
-	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
-	void __iomem *mmio = ndev->self_mmio;
-	u32 ntb_ctl;
-
-	/* Enable event interrupt */
-	ndev->int_mask &= ~AMD_EVENT_INTMASK;
-	writel(ndev->int_mask, mmio + AMD_INTMASK_OFFSET);
-
-	if (ndev->ntb.topo == NTB_TOPO_SEC)
-		return -EINVAL;
-	dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
-
-	ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
-	ntb_ctl |= (PMM_REG_CTL | SMM_REG_CTL);
-	writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
-
-	return 0;
-}
-
-static int amd_ntb_link_disable(struct ntb_dev *ntb)
-{
-	struct amd_ntb_dev *ndev = ntb_ndev(ntb);
-	void __iomem *mmio = ndev->self_mmio;
-	u32 ntb_ctl;
-
-	/* Disable event interrupt */
-	ndev->int_mask |= AMD_EVENT_INTMASK;
-	writel(ndev->int_mask, mmio + AMD_INTMASK_OFFSET);
-
-	if (ndev->ntb.topo == NTB_TOPO_SEC)
-		return -EINVAL;
-	dev_dbg(ndev_dev(ndev), "Enabling Link.\n");
-
-	ntb_ctl = readl(mmio + AMD_CNTL_OFFSET);
-	ntb_ctl &= ~(PMM_REG_CTL | SMM_REG_CTL);
-	writel(ntb_ctl, mmio + AMD_CNTL_OFFSET);
-
-	return 0;
-}
-
 static u64 amd_ntb_db_valid_mask(struct ntb_dev *ntb)
 {
 	return ntb_ndev(ntb)->db_valid_mask;
@@ -431,12 +431,12 @@ static int amd_ntb_peer_spad_write(struct ntb_dev *ntb,
 }
 
 static const struct ntb_dev_ops amd_ntb_ops = {
-	.mw_count		= amd_ntb_mw_count,
-	.mw_get_range		= amd_ntb_mw_get_range,
-	.mw_set_trans		= amd_ntb_mw_set_trans,
 	.link_is_up		= amd_ntb_link_is_up,
 	.link_enable		= amd_ntb_link_enable,
 	.link_disable		= amd_ntb_link_disable,
+	.mw_count		= amd_ntb_mw_count,
+	.mw_get_range		= amd_ntb_mw_get_range,
+	.mw_set_trans		= amd_ntb_mw_set_trans,
 	.db_valid_mask		= amd_ntb_db_valid_mask,
 	.db_vector_count	= amd_ntb_db_vector_count,
 	.db_vector_mask		= amd_ntb_db_vector_mask,
-- 
2.6.6

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/22] NTB: Alter kernel API to support multi-port devices Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 01/22] NTB: Move link state API being first in sources Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 16/22] NTB AMD: Alter MW interface to fit new NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 22/22] NTB Transport: Alter driver to work with two-ports NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 13/22] NTB Intel: Add T-Platforms copyrights to Intel NTB driver Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 20/22] NTB Tool: Alter driver to work with two-ports NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 19/22] NTB PingPong: Alter driver to work with two-ports NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 03/22] NTB: Alter NTB API to support both inbound and outbound MW based interfaces Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:20 +0100
  [PATCH 06/22] NTB: Slightly alter link state NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 18/22] NTB AMD: Add T-Platforms copyrights to AMD NTB driver Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 08/22] NTB: Add T-Platforms copyrights to NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 09/22] NTB Intel: Move link-related methods being first in the driver Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 15/22] NTB AMD: Add port-related NTB API callback methods Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 17/22] NTB AMD: Alter Scratchpads interface to fit new NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 04/22] NTB: Add messaging NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 05/22] NTB: Alter Scratchpads NTB API to support multi-ports interface Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 10/22] NTB Intel: Add port-related NTB API callback methods Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
    RE: [PATCH 10/22] NTB Intel: Add port-related NTB API callback methods "Allen Hubbe" <Allen.Hubbe@dell.com> - 2016-12-08 00:00 +0100
  [PATCH 12/22] NTB Intel: Alter Scratchpads interface to fit new NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 11/22] NTB Intel: Alter MW interface to fit new NTB API Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 14/22] NTB AMD: Move link-related methods being first in the driver Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100
  [PATCH 07/22] NTB: Fix a few ntb.h issues Serge Semin <fancer.lancer@gmail.com> - 2016-11-29 18:30 +0100

csiph-web