Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1532549 > unrolled thread
| Started by | Serge Semin <fancer.lancer@gmail.com> |
|---|---|
| First post | 2016-11-29 18:20 +0100 |
| Last post | 2016-11-29 18:30 +0100 |
| Articles | 2 on this page of 22 — 2 participants |
Back to article view | Back to linux.kernel
[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
Page 2 of 2 — ← Prev page 1 [2]
| From | Serge Semin <fancer.lancer@gmail.com> |
|---|---|
| Date | 2016-11-29 18:30 +0100 |
| Subject | [PATCH 14/22] NTB AMD: Move link-related methods being first in the driver |
| Message-ID | <sIUob-311-67@gated-at.bofh.it> |
| In reply to | #1532549 |
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
[toc] | [prev] | [next] | [standalone]
| From | Serge Semin <fancer.lancer@gmail.com> |
|---|---|
| Date | 2016-11-29 18:30 +0100 |
| Subject | [PATCH 07/22] NTB: Fix a few ntb.h issues |
| Message-ID | <sIUob-311-69@gated-at.bofh.it> |
| In reply to | #1532549 |
Fix some minor issues found in ntb.h file.
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
---
include/linux/ntb.h | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index a59a155..8b19327 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -90,6 +90,7 @@ static inline char *ntb_topo_string(enum ntb_topo topo)
* @NTB_SPEED_GEN1: Link is trained to gen1 speed.
* @NTB_SPEED_GEN2: Link is trained to gen2 speed.
* @NTB_SPEED_GEN3: Link is trained to gen3 speed.
+ * @NTB_SPEED_GEN4: Link is trained to gen4 speed.
*/
enum ntb_speed {
NTB_SPEED_AUTO = -1,
@@ -97,6 +98,7 @@ enum ntb_speed {
NTB_SPEED_GEN1 = 1,
NTB_SPEED_GEN2 = 2,
NTB_SPEED_GEN3 = 3,
+ NTB_SPEED_GEN4 = 4
};
/**
@@ -292,13 +294,18 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
{
/* commented callbacks are not required: */
return
+ /* Port operations are required */
ops->port_number &&
ops->peer_port_count &&
ops->peer_port_number &&
ops->peer_port_idx &&
+
+ /* Link operations are requiered */
ops->link_is_up &&
ops->link_enable &&
ops->link_disable &&
+
+ /* One or both MW interfaces should be developed */
ops->mw_count &&
ops->mw_get_align &&
(ops->mw_set_trans ||
@@ -308,12 +315,11 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
ops->peer_mw_get_addr &&
/* ops->peer_mw_clear_trans && */
+ /* Doorbell operations are mostly required */
/* ops->db_is_unsafe && */
ops->db_valid_mask &&
-
/* both set, or both unset */
(!ops->db_vector_count == !ops->db_vector_mask) &&
-
ops->db_read &&
/* ops->db_set && */
ops->db_clear &&
@@ -327,6 +333,8 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
/* ops->peer_db_read_mask && */
/* ops->peer_db_set_mask && */
/* ops->peer_db_clear_mask && */
+
+ /* Scrachpad or messaging interfaces should be developed */
((/* ops->spad_is_unsafe && */
ops->spad_count &&
ops->spad_read &&
@@ -355,13 +363,12 @@ struct ntb_client {
struct device_driver drv;
const struct ntb_client_ops ops;
};
-
#define drv_ntb_client(__drv) container_of((__drv), struct ntb_client, drv)
/**
* struct ntb_device - ntb device
* @dev: Linux device object.
- * @pdev: Pci device entry of the ntb.
+ * @pdev: PCI device entry of the ntb.
* @topo: Detected topology of the ntb.
* @port: Local port of the ntb.
* @ops: See &ntb_dev_ops.
@@ -384,7 +391,6 @@ struct ntb_dev {
/* block unregister until device is fully released */
struct completion released;
};
-
#define dev_ntb(__dev) container_of((__dev), struct ntb_dev, dev)
/**
@@ -481,7 +487,7 @@ void ntb_link_event(struct ntb_dev *ntb);
* multiple interrupt vectors for doorbells, the vector number indicates which
* vector received the interrupt. The vector number is relative to the first
* vector used for doorbells, starting at zero, and must be less than
- ** ntb_db_vector_count(). The driver may call ntb_db_read() to check which
+ * ntb_db_vector_count(). The driver may call ntb_db_read() to check which
* doorbell bits need service, and ntb_db_vector_mask() to determine which of
* those bits are associated with the vector number.
*/
--
2.6.6
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web