* [PATCH 0/2] ntb_perf: Adjustments for perf_copy_chunk()
@ 2024-09-23 9:11 Markus Elfring
2024-09-23 9:15 ` [PATCH 1/2] ntb_perf: Delete duplicate dmaengine_unmap_put() call in perf_copy_chunk() Markus Elfring
2024-09-23 9:16 ` [PATCH 2/2] ntb_perf: Use common error handling code " Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2024-09-23 9:11 UTC (permalink / raw)
To: ntb, kernel-janitors, Allen Hubbe, Dave Jiang, Jon Mason,
Max Hawking, Serge Semin
Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Sep 2024 11:00:22 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete duplicate dmaengine_unmap_put() call
Use common error handling code
drivers/ntb/test/ntb_perf.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
--
2.46.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] ntb_perf: Delete duplicate dmaengine_unmap_put() call in perf_copy_chunk()
2024-09-23 9:11 [PATCH 0/2] ntb_perf: Adjustments for perf_copy_chunk() Markus Elfring
@ 2024-09-23 9:15 ` Markus Elfring
2024-09-23 9:16 ` [PATCH 2/2] ntb_perf: Use common error handling code " Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-09-23 9:15 UTC (permalink / raw)
To: ntb, kernel-janitors, Allen Hubbe, Dave Jiang, Jon Mason,
Max Hawking, Serge Semin
Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Sep 2024 10:38:11 +0200
The function call “dmaengine_unmap_put(unmap)” was used in an if branch.
The same call was immediately triggered by a subsequent goto statement.
Thus avoid such a call repetition.
This issue was detected by using the Coccinelle software.
Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
I imagine that a single function call “dmaengine_unmap_put(unmap)”
can be sufficient for this use case.
https://elixir.bootlin.com/linux/v6.11/source/drivers/dma/dmaengine.c#L1377
How do you think about to improve resource management any further?
drivers/ntb/test/ntb_perf.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 72bc1d017a46..dfd175f79e8f 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -839,10 +839,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
dma_set_unmap(tx, unmap);
ret = dma_submit_error(dmaengine_submit(tx));
- if (ret) {
- dmaengine_unmap_put(unmap);
+ if (ret)
goto err_free_resource;
- }
dmaengine_unmap_put(unmap);
--
2.46.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ntb_perf: Use common error handling code in perf_copy_chunk()
2024-09-23 9:11 [PATCH 0/2] ntb_perf: Adjustments for perf_copy_chunk() Markus Elfring
2024-09-23 9:15 ` [PATCH 1/2] ntb_perf: Delete duplicate dmaengine_unmap_put() call in perf_copy_chunk() Markus Elfring
@ 2024-09-23 9:16 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-09-23 9:16 UTC (permalink / raw)
To: ntb, kernel-janitors, Allen Hubbe, Dave Jiang, Jon Mason,
Max Hawking, Serge Semin
Cc: LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Sep 2024 10:48:17 +0200
Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/ntb/test/ntb_perf.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index dfd175f79e8f..88c5192b81eb 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -816,10 +816,9 @@ static int perf_copy_chunk(struct perf_thread *pthr,
unmap->len = len;
unmap->addr[0] = dma_map_page(dma_dev, virt_to_page(src),
offset_in_page(src), len, DMA_TO_DEVICE);
- if (dma_mapping_error(dma_dev, unmap->addr[0])) {
- ret = -EIO;
- goto err_free_resource;
- }
+ if (dma_mapping_error(dma_dev, unmap->addr[0]))
+ goto e_io;
+
unmap->to_cnt = 1;
do {
@@ -829,10 +828,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
msleep(DMA_MDELAY);
} while (!tx && (try++ < DMA_TRIES));
- if (!tx) {
- ret = -EIO;
- goto err_free_resource;
- }
+ if (!tx)
+ goto e_io;
tx->callback = perf_dma_copy_callback;
tx->callback_param = pthr;
@@ -850,6 +847,8 @@ static int perf_copy_chunk(struct perf_thread *pthr,
ret_check_tsync:
return likely(atomic_read(&pthr->perf->tsync) > 0) ? 0 : -EINTR;
+e_io:
+ ret = -EIO;
err_free_resource:
dmaengine_unmap_put(unmap);
--
2.46.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-23 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-23 9:11 [PATCH 0/2] ntb_perf: Adjustments for perf_copy_chunk() Markus Elfring
2024-09-23 9:15 ` [PATCH 1/2] ntb_perf: Delete duplicate dmaengine_unmap_put() call in perf_copy_chunk() Markus Elfring
2024-09-23 9:16 ` [PATCH 2/2] ntb_perf: Use common error handling code " Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®