* [PATCH AUTOSEL 5.7 095/388] NTB: ntb_pingpong: Choose doorbells based on port number
[not found] <20200618010805.600873-1-sashal@kernel.org>
@ 2020-06-18 1:03 ` Sasha Levin
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 096/388] NTB: Fix the default port and peer numbers for legacy drivers Sasha Levin
` (8 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:03 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit ca93c45755da98302c93abdd788fc09113baf9e0 ]
This commit fixes pingpong support for existing drivers that do not
implement ntb_default_port_number() and ntb_default_peer_port_number().
This is required for hardware (like the crosslink topology of
switchtec) which cannot assign reasonable port numbers to each port due
to its perfect symmetry.
Instead of picking the doorbell to use based on the the index of the
peer, we use the peer's port number. This is a bit clearer and easier
to understand.
Fixes: c7aeb0afdcc2 ("NTB: ntb_pp: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_pingpong.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
index 04dd46647db3..2164e8492772 100644
--- a/drivers/ntb/test/ntb_pingpong.c
+++ b/drivers/ntb/test/ntb_pingpong.c
@@ -121,15 +121,14 @@ static int pp_find_next_peer(struct pp_ctx *pp)
link = ntb_link_is_up(pp->ntb, NULL, NULL);
/* Find next available peer */
- if (link & pp->nmask) {
+ if (link & pp->nmask)
pidx = __ffs64(link & pp->nmask);
- out_db = BIT_ULL(pidx + 1);
- } else if (link & pp->pmask) {
+ else if (link & pp->pmask)
pidx = __ffs64(link & pp->pmask);
- out_db = BIT_ULL(pidx);
- } else {
+ else
return -ENODEV;
- }
+
+ out_db = BIT_ULL(ntb_peer_port_number(pp->ntb, pidx));
spin_lock(&pp->lock);
pp->out_pidx = pidx;
@@ -303,7 +302,7 @@ static void pp_init_flds(struct pp_ctx *pp)
break;
}
- pp->in_db = BIT_ULL(pidx);
+ pp->in_db = BIT_ULL(lport);
pp->pmask = GENMASK_ULL(pidx, 0) >> 1;
pp->nmask = GENMASK_ULL(pcnt - 1, pidx);
@@ -432,4 +431,3 @@ static void __exit pp_exit(void)
debugfs_remove_recursive(pp_dbgfs_topdir);
}
module_exit(pp_exit);
-
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 096/388] NTB: Fix the default port and peer numbers for legacy drivers
[not found] <20200618010805.600873-1-sashal@kernel.org>
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 095/388] NTB: ntb_pingpong: Choose doorbells based on port number Sasha Levin
@ 2020-06-18 1:03 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 347/388] ntb_perf: pass correct struct device to dma_alloc_coherent Sasha Levin
` (7 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:03 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit fc8b086d9dbd57458d136c4fa70ee26f832c3a2e ]
When the commit adding ntb_default_port_number() and
ntb_default_peer_port_number() entered the kernel there was no
users of it so it was impossible to tell what the API needed.
When a user finally landed a year later (ntb_pingpong) there were
more NTB topologies were created and no consideration was considered
to how other drivers had changed.
Now that there is a user it can be fixed to provide a sensible default
for the legacy drivers that do not implement ntb_{peer_}port_number().
Seeing ntb_pingpong doesn't check error codes returning EINVAL was also
not sensible.
Patches for ntb_pingpong and ntb_perf follow (which are broken
otherwise) to support hardware that doesn't have port numbers. This is
important not only to not break support with existing drivers but for
the cross link topology which, due to its perfect symmetry, cannot
assign unique port numbers to each side.
Fixes: 1e5301196a88 ("NTB: Add indexed ports NTB API")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/core.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c
index 2581ab724c34..c9a0912b175f 100644
--- a/drivers/ntb/core.c
+++ b/drivers/ntb/core.c
@@ -214,10 +214,8 @@ int ntb_default_port_number(struct ntb_dev *ntb)
case NTB_TOPO_B2B_DSD:
return NTB_PORT_SEC_DSD;
default:
- break;
+ return 0;
}
-
- return -EINVAL;
}
EXPORT_SYMBOL(ntb_default_port_number);
@@ -240,10 +238,8 @@ int ntb_default_peer_port_number(struct ntb_dev *ntb, int pidx)
case NTB_TOPO_B2B_DSD:
return NTB_PORT_PRI_USD;
default:
- break;
+ return 0;
}
-
- return -EINVAL;
}
EXPORT_SYMBOL(ntb_default_peer_port_number);
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 347/388] ntb_perf: pass correct struct device to dma_alloc_coherent
[not found] <20200618010805.600873-1-sashal@kernel.org>
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 095/388] NTB: ntb_pingpong: Choose doorbells based on port number Sasha Levin
2020-06-18 1:03 ` [PATCH AUTOSEL 5.7 096/388] NTB: Fix the default port and peer numbers for legacy drivers Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 348/388] ntb_tool: " Sasha Levin
` (6 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sanjay R Mehta, Logan Gunthorpe, Arindam Nath, Jon Mason,
Sasha Levin, linux-ntb
From: Sanjay R Mehta <sanju.mehta@amd.com>
[ Upstream commit 98f4e140264eeb52f22ff05be6b6dd48237255ac ]
Currently, ntb->dev is passed to dma_alloc_coherent
and dma_free_coherent calls. The returned dma_addr_t
is the CPU physical address. This works fine as long
as IOMMU is disabled. But when IOMMU is enabled, we
need to make sure that IOVA is returned for dma_addr_t.
So the correct way to achieve this is by changing the
first parameter of dma_alloc_coherent() as ntb->pdev->dev
instead.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_perf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 972f6d984f6d..1c93b9f5c73b 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -557,7 +557,7 @@ static void perf_free_inbuf(struct perf_peer *peer)
return;
(void)ntb_mw_clear_trans(peer->perf->ntb, peer->pidx, peer->gidx);
- dma_free_coherent(&peer->perf->ntb->dev, peer->inbuf_size,
+ dma_free_coherent(&peer->perf->ntb->pdev->dev, peer->inbuf_size,
peer->inbuf, peer->inbuf_xlat);
peer->inbuf = NULL;
}
@@ -586,8 +586,9 @@ static int perf_setup_inbuf(struct perf_peer *peer)
perf_free_inbuf(peer);
- peer->inbuf = dma_alloc_coherent(&perf->ntb->dev, peer->inbuf_size,
- &peer->inbuf_xlat, GFP_KERNEL);
+ peer->inbuf = dma_alloc_coherent(&perf->ntb->pdev->dev,
+ peer->inbuf_size, &peer->inbuf_xlat,
+ GFP_KERNEL);
if (!peer->inbuf) {
dev_err(&perf->ntb->dev, "Failed to alloc inbuf of %pa\n",
&peer->inbuf_size);
@@ -1554,4 +1555,3 @@ static void __exit perf_exit(void)
destroy_workqueue(perf_wq);
}
module_exit(perf_exit);
-
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 348/388] ntb_tool: pass correct struct device to dma_alloc_coherent
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (2 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 347/388] ntb_perf: pass correct struct device to dma_alloc_coherent Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 349/388] NTB: ntb_tool: reading the link file should not end in a NULL byte Sasha Levin
` (5 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sanjay R Mehta, Arindam Nath, Jon Mason, Sasha Levin, linux-ntb
From: Sanjay R Mehta <sanju.mehta@amd.com>
[ Upstream commit 433efe720674efd9fdbcef78be75793393cf05db ]
Currently, ntb->dev is passed to dma_alloc_coherent
and dma_free_coherent calls. The returned dma_addr_t
is the CPU physical address. This works fine as long
as IOMMU is disabled. But when IOMMU is enabled, we
need to make sure that IOVA is returned for dma_addr_t.
So the correct way to achieve this is by changing the
first parameter of dma_alloc_coherent() as ntb->pdev->dev
instead.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Arindam Nath <arindam.nath@amd.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_tool.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
index 69da758fe64c..9eaeb221d980 100644
--- a/drivers/ntb/test/ntb_tool.c
+++ b/drivers/ntb/test/ntb_tool.c
@@ -590,7 +590,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
inmw->size = min_t(resource_size_t, req_size, size);
inmw->size = round_up(inmw->size, addr_align);
inmw->size = round_up(inmw->size, size_align);
- inmw->mm_base = dma_alloc_coherent(&tc->ntb->dev, inmw->size,
+ inmw->mm_base = dma_alloc_coherent(&tc->ntb->pdev->dev, inmw->size,
&inmw->dma_base, GFP_KERNEL);
if (!inmw->mm_base)
return -ENOMEM;
@@ -612,7 +612,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
return 0;
err_free_dma:
- dma_free_coherent(&tc->ntb->dev, inmw->size, inmw->mm_base,
+ dma_free_coherent(&tc->ntb->pdev->dev, inmw->size, inmw->mm_base,
inmw->dma_base);
inmw->mm_base = NULL;
inmw->dma_base = 0;
@@ -629,7 +629,7 @@ static void tool_free_mw(struct tool_ctx *tc, int pidx, int widx)
if (inmw->mm_base != NULL) {
ntb_mw_clear_trans(tc->ntb, pidx, widx);
- dma_free_coherent(&tc->ntb->dev, inmw->size,
+ dma_free_coherent(&tc->ntb->pdev->dev, inmw->size,
inmw->mm_base, inmw->dma_base);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 349/388] NTB: ntb_tool: reading the link file should not end in a NULL byte
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (3 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 348/388] ntb_tool: " Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 350/388] NTB: Revert the change to use the NTB device dev for DMA allocations Sasha Levin
` (4 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit 912e12813dd03c602e4922fc34709ec4d4380cf0 ]
When running ntb_test this warning is issued:
./ntb_test.sh: line 200: warning: command substitution: ignored null
byte in input
This is caused by the kernel returning one more byte than is necessary
when reading the link file.
Reduce the number of bytes read back to 2 as it was before the
commit that regressed this.
Fixes: 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_tool.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
index 9eaeb221d980..b7bf3f863d79 100644
--- a/drivers/ntb/test/ntb_tool.c
+++ b/drivers/ntb/test/ntb_tool.c
@@ -504,7 +504,7 @@ static ssize_t tool_peer_link_read(struct file *filep, char __user *ubuf,
buf[1] = '\n';
buf[2] = '\0';
- return simple_read_from_buffer(ubuf, size, offp, buf, 3);
+ return simple_read_from_buffer(ubuf, size, offp, buf, 2);
}
static TOOL_FOPS_RDWR(tool_peer_link_fops,
@@ -1690,4 +1690,3 @@ static void __exit tool_exit(void)
debugfs_remove_recursive(tool_dbgfs_topdir);
}
module_exit(tool_exit);
-
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 350/388] NTB: Revert the change to use the NTB device dev for DMA allocations
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (4 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 349/388] NTB: ntb_tool: reading the link file should not end in a NULL byte Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 351/388] NTB: perf: Don't require one more memory window than number of peers Sasha Levin
` (3 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Alexander Fomichev, Jon Mason, Sasha Levin,
linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit 40da7d9a93c8941737ef4a1208d32c13ce017fe1 ]
Commit 417cf39cfea9 ("NTB: Set dma mask and dma coherent mask to NTB
devices") started using the NTB device for DMA allocations which was
turns out was wrong. If the IOMMU is enabled, such alloctanions will
always fail with messages such as:
DMAR: Allocating domain for 0000:02:00.1 failed
This is because the IOMMU has not setup the device for such use.
Change the tools back to using the PCI device for allocations seeing
it doesn't make sense to add an IOMMU group for the non-physical NTB
device. Also remove the code that sets the DMA mask as it no longer
makes sense to do this.
Fixes: 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/ntb/core.c b/drivers/ntb/core.c
index c9a0912b175f..f8f75a504a58 100644
--- a/drivers/ntb/core.c
+++ b/drivers/ntb/core.c
@@ -311,4 +311,3 @@ static void __exit ntb_driver_exit(void)
bus_unregister(&ntb_bus);
}
module_exit(ntb_driver_exit);
-
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 351/388] NTB: perf: Don't require one more memory window than number of peers
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (5 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 350/388] NTB: Revert the change to use the NTB device dev for DMA allocations Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 352/388] NTB: perf: Fix support for hardware that doesn't have port numbers Sasha Levin
` (2 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit a9c4211ac918ade1522aced6b5acfbe824722f7d ]
ntb_perf should not require more than one memory window per peer. This
was probably an off-by-one error.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_perf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 1c93b9f5c73b..21c8a3bac1e0 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -654,7 +654,7 @@ static int perf_init_service(struct perf_ctx *perf)
{
u64 mask;
- if (ntb_peer_mw_count(perf->ntb) < perf->pcnt + 1) {
+ if (ntb_peer_mw_count(perf->ntb) < perf->pcnt) {
dev_err(&perf->ntb->dev, "Not enough memory windows\n");
return -EINVAL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 352/388] NTB: perf: Fix support for hardware that doesn't have port numbers
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (6 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 351/388] NTB: perf: Don't require one more memory window than number of peers Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 353/388] NTB: perf: Fix race condition when run with ntb_test Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 354/388] NTB: ntb_test: Fix bug when counting remote files Sasha Levin
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit b54369a248c2e033bfcf5d6917e08cf9d73d54a6 ]
Legacy drivers do not have port numbers (but is reliably only two ports)
and was broken by the recent commit that added mult-port support to
ntb_perf. This is especially important to support the cross link
topology which is perfectly symmetric and cannot assign unique port
numbers easily.
Hardware that returns zero for both the local port and the peer should
just always use gidx=0 for the only peer.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_perf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 21c8a3bac1e0..0b1eae07b133 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -1460,6 +1460,16 @@ static int perf_init_peers(struct perf_ctx *perf)
if (perf->gidx == -1)
perf->gidx = pidx;
+ /*
+ * Hardware with only two ports may not have unique port
+ * numbers. In this case, the gidxs should all be zero.
+ */
+ if (perf->pcnt == 1 && ntb_port_number(perf->ntb) == 0 &&
+ ntb_peer_port_number(perf->ntb, 0) == 0) {
+ perf->gidx = 0;
+ perf->peers[0].gidx = 0;
+ }
+
for (pidx = 0; pidx < perf->pcnt; pidx++) {
ret = perf_setup_peer_mw(&perf->peers[pidx]);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 353/388] NTB: perf: Fix race condition when run with ntb_test
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (7 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 352/388] NTB: perf: Fix support for hardware that doesn't have port numbers Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 354/388] NTB: ntb_test: Fix bug when counting remote files Sasha Levin
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit 34d8673a01b053b6231a995a4eec9341163d63be ]
When running ntb_test, the script tries to run the ntb_perf test
immediately after probing the modules. Since adding multi-port support,
this fails seeing the new initialization procedure in ntb_perf
can not complete instantly.
To fix this we add a completion which is waited on when a test is
started. In this way, run can be written any time after the module is
loaded and it will wait for the initialization to complete instead of
sending an error.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ntb/test/ntb_perf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 0b1eae07b133..528751803419 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -159,6 +159,8 @@ struct perf_peer {
/* NTB connection setup service */
struct work_struct service;
unsigned long sts;
+
+ struct completion init_comp;
};
#define to_peer_service(__work) \
container_of(__work, struct perf_peer, service)
@@ -547,6 +549,7 @@ static int perf_setup_outbuf(struct perf_peer *peer)
/* Initialization is finally done */
set_bit(PERF_STS_DONE, &peer->sts);
+ complete_all(&peer->init_comp);
return 0;
}
@@ -638,6 +641,7 @@ static void perf_service_work(struct work_struct *work)
perf_setup_outbuf(peer);
if (test_and_clear_bit(PERF_CMD_CLEAR, &peer->sts)) {
+ init_completion(&peer->init_comp);
clear_bit(PERF_STS_DONE, &peer->sts);
if (test_bit(0, &peer->perf->busy_flag) &&
peer == peer->perf->test_peer) {
@@ -1084,8 +1088,9 @@ static int perf_submit_test(struct perf_peer *peer)
struct perf_thread *pthr;
int tidx, ret;
- if (!test_bit(PERF_STS_DONE, &peer->sts))
- return -ENOLINK;
+ ret = wait_for_completion_interruptible(&peer->init_comp);
+ if (ret < 0)
+ return ret;
if (test_and_set_bit_lock(0, &perf->busy_flag))
return -EBUSY;
@@ -1456,6 +1461,7 @@ static int perf_init_peers(struct perf_ctx *perf)
peer->gidx = pidx;
}
INIT_WORK(&peer->service, perf_service_work);
+ init_completion(&peer->init_comp);
}
if (perf->gidx == -1)
perf->gidx = pidx;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH AUTOSEL 5.7 354/388] NTB: ntb_test: Fix bug when counting remote files
[not found] <20200618010805.600873-1-sashal@kernel.org>
` (8 preceding siblings ...)
2020-06-18 1:07 ` [PATCH AUTOSEL 5.7 353/388] NTB: perf: Fix race condition when run with ntb_test Sasha Levin
@ 2020-06-18 1:07 ` Sasha Levin
9 siblings, 0 replies; 10+ messages in thread
From: Sasha Levin @ 2020-06-18 1:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Logan Gunthorpe, Allen Hubbe, Alexander Fomichev, Jon Mason,
Sasha Levin, linux-ntb, linux-kselftest
From: Logan Gunthorpe <logang@deltatee.com>
[ Upstream commit 2130c0ba69d69bb21f5c52787f2587db00d13d8a ]
When remote files are counted in get_files_count, without using SSH,
the code returns 0 because there is a colon prepended to $LOC. $VPATH
should have been used instead of $LOC.
Fixes: 06bd0407d06c ("NTB: ntb_test: Update ntb_tool Scratchpad tests")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Allen Hubbe <allenbh@gmail.com>
Tested-by: Alexander Fomichev <fomichev.ru@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/ntb/ntb_test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ntb/ntb_test.sh b/tools/testing/selftests/ntb/ntb_test.sh
index 9c60337317c6..020137b61407 100755
--- a/tools/testing/selftests/ntb/ntb_test.sh
+++ b/tools/testing/selftests/ntb/ntb_test.sh
@@ -241,7 +241,7 @@ function get_files_count()
split_remote $LOC
if [[ "$REMOTE" == "" ]]; then
- echo $(ls -1 "$LOC"/${NAME}* 2>/dev/null | wc -l)
+ echo $(ls -1 "$VPATH"/${NAME}* 2>/dev/null | wc -l)
else
echo $(ssh "$REMOTE" "ls -1 \"$VPATH\"/${NAME}* | \
wc -l" 2> /dev/null)
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread