netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch
Cc: netdev@vger.kernel.org, Gerhard Engleder <gerhard@engleder-embedded.com>
Subject: [PATCH net-next 4/6] tsnep: Fix tsnep_tx_unmap() error path usage
Date: Wed,  3 Aug 2022 22:49:45 +0200	[thread overview]
Message-ID: <20220803204947.52789-5-gerhard@engleder-embedded.com> (raw)
In-Reply-To: <20220803204947.52789-1-gerhard@engleder-embedded.com>

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(-)

diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index 3cae485e8689..9f8ca6d9a010 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -364,7 +364,7 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
 	return map_len;
 }
 
-static int tsnep_tx_unmap(struct tsnep_tx *tx, int count)
+static int tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
 {
 	struct device *dmadev = tx->adapter->dmadev;
 	struct tsnep_tx_entry *entry;
@@ -372,7 +372,7 @@ static int tsnep_tx_unmap(struct tsnep_tx *tx, int count)
 	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)
@@ -424,7 +424,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;
 
@@ -492,7 +492,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;
 
-		length = tsnep_tx_unmap(tx, count);
+		length = tsnep_tx_unmap(tx, tx->read, count);
 
 		if ((skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) &&
 		    (__le32_to_cpu(entry->desc_wb->properties) &
-- 
2.30.2


  parent reply	other threads:[~2022-08-03 20:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 20:49 [PATCH net-next 0/6] tsnep: Various minor driver improvements Gerhard Engleder
2022-08-03 20:49 ` [PATCH net-next 1/6] tsnep: Add loopback support Gerhard Engleder
2022-08-03 20:49 ` [PATCH net-next 2/6] tsnep: Fix unused warning for 'tsnep_of_match' Gerhard Engleder
2022-08-03 20:49 ` [PATCH net-next 3/6] tsnep: Improve TX length handling Gerhard Engleder
2022-08-03 20:49 ` Gerhard Engleder [this message]
2022-08-03 20:49 ` [PATCH net-next 5/6] tsnep: Support full DMA mask Gerhard Engleder
2022-08-03 20:49 ` [PATCH net-next 6/6] tsnep: Record RX queue Gerhard Engleder
2022-08-03 23:01 ` [PATCH net-next 0/6] tsnep: Various minor driver improvements Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220803204947.52789-5-gerhard@engleder-embedded.com \
    --to=gerhard@engleder-embedded.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).