diff mbox series

[net-next,2/2] tsnep: Fix tsnep_tx_unmap() error path usage

Message ID 20220804183935.73763-3-gerhard@engleder-embedded.com (mailing list archive)
State Accepted
Commit b3bb8628bf64440065976c71e4ab09186c393597
Delegated to: Netdev Maintainers
Headers show
Series tsnep: Two fixes for the driver | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: edumazet@google.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gerhard Engleder Aug. 4, 2022, 6:39 p.m. UTC
If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write
index like tsnep_tx_map(). This is different to the normal operation.
Thus, add an additional parameter to tsnep_tx_unmap() to enable start at
different positions for successful TX and failed TX.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 drivers/net/ethernet/engleder/tsnep_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski Aug. 8, 2022, 7:23 p.m. UTC | #1
On Thu,  4 Aug 2022 20:39:35 +0200 Gerhard Engleder wrote:
> If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write
> index like tsnep_tx_map(). This is different to the normal operation.
> Thus, add an additional parameter to tsnep_tx_unmap() to enable start at
> different positions for successful TX and failed TX.
> 
> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>

Is this correct:

Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")

?
Gerhard Engleder Aug. 8, 2022, 7:29 p.m. UTC | #2
On 08.08.22 21:23, Jakub Kicinski wrote:
> On Thu,  4 Aug 2022 20:39:35 +0200 Gerhard Engleder wrote:
>> If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write
>> index like tsnep_tx_map(). This is different to the normal operation.
>> Thus, add an additional parameter to tsnep_tx_unmap() to enable start at
>> different positions for successful TX and failed TX.
>>
>> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> Is this correct:
>
> Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
>
> ?
Yes, that's correct. Sorry I forget to add it. Shall I add it and resend?
Gerhard Engleder Aug. 8, 2022, 7:30 p.m. UTC | #3
On 08.08.22 21:23, Jakub Kicinski wrote:
> On Thu,  4 Aug 2022 20:39:35 +0200 Gerhard Engleder wrote:
>> If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write
>> index like tsnep_tx_map(). This is different to the normal operation.
>> Thus, add an additional parameter to tsnep_tx_unmap() to enable start at
>> different positions for successful TX and failed TX.
>>
>> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> Is this correct:
>
> Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
>
> ?
Yes, that's correct. Sorry I forget to add it. Shall I add it and resend?
Jakub Kicinski Aug. 8, 2022, 9:30 p.m. UTC | #4
On Mon, 8 Aug 2022 21:30:02 +0200 Gerhard Engleder wrote:
> On 08.08.22 21:23, Jakub Kicinski wrote:
> > On Thu,  4 Aug 2022 20:39:35 +0200 Gerhard Engleder wrote:  
> >> If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write
> >> index like tsnep_tx_map(). This is different to the normal operation.
> >> Thus, add an additional parameter to tsnep_tx_unmap() to enable start at
> >> different positions for successful TX and failed TX.
> >>
> >> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>  
> > Is this correct:
> >
> > Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver")
> >
> > ?  
> Yes, that's correct. Sorry I forget to add it. Shall I add it and resend?

It's okay, I'll add it.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index d98199f3414b..a5f7152a1716 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -340,14 +340,14 @@  static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
 	return 0;
 }
 
-static void tsnep_tx_unmap(struct tsnep_tx *tx, int count)
+static void tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
 {
 	struct device *dmadev = tx->adapter->dmadev;
 	struct tsnep_tx_entry *entry;
 	int i;
 
 	for (i = 0; i < count; i++) {
-		entry = &tx->entry[(tx->read + i) % TSNEP_RING_SIZE];
+		entry = &tx->entry[(index + i) % TSNEP_RING_SIZE];
 
 		if (entry->len) {
 			if (i == 0)
@@ -395,7 +395,7 @@  static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
 
 	retval = tsnep_tx_map(skb, tx, count);
 	if (retval != 0) {
-		tsnep_tx_unmap(tx, count);
+		tsnep_tx_unmap(tx, tx->write, count);
 		dev_kfree_skb_any(entry->skb);
 		entry->skb = NULL;
 
@@ -464,7 +464,7 @@  static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
 		if (skb_shinfo(entry->skb)->nr_frags > 0)
 			count += skb_shinfo(entry->skb)->nr_frags;
 
-		tsnep_tx_unmap(tx, count);
+		tsnep_tx_unmap(tx, tx->read, count);
 
 		if ((skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) &&
 		    (__le32_to_cpu(entry->desc_wb->properties) &