From: Simon Horman <horms@verge.net.au>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: David Miller <davem@davemloft.net>,
Magnus Damm <magnus.damm@gmail.com>,
netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH/RFC v2 net-next] ravb: unmap descriptors when freeing rings
Date: Fri, 13 Jan 2017 13:01:35 +0100 [thread overview]
Message-ID: <20170113120133.GA31006@verge.net.au> (raw)
In-Reply-To: <dc41bc36-8239-39d7-def1-a60603e3890a@cogentembedded.com>
On Thu, Jan 12, 2017 at 07:33:51PM +0300, Sergei Shtylyov wrote:
> On 01/12/2017 04:18 PM, Simon Horman wrote:
>
> >...
> >
> >>>> Here, it stop once an untransmitted buffer is encountered...
> >>>
> >>>Yes, I see that now.
> >>>
> >>>I wonder if we should:
> >>>
> >>>a) paramatise ravb_tx_free() so it may either clear all transmitted buffers
> >>> (current behaviour) or all buffers (new behaviour).
> >>>b) provide a different version of this loop in ravb_ring_free()
> >>>
> >>>What are your thoughts?
> >>
> >> I'm voting for (b).
> >
> >Ok, something like this?
> >
> >@@ -215,6 +225,30 @@ static void ravb_ring_free(struct net_device *ndev, int q)
> > }
> >
> > if (priv->tx_ring[q]) {
> >+ for (; priv->cur_tx[q] - priv->dirty_tx[q] > 0; priv->dirty_tx[q]++) {
>
> You're still copying the loop logic from ravb_tx_free() while we (I
> think) need a simple loop over all the descriptor ring.
I thought the above may be better as it seems to me that only descriptors
in the range described above could need to be freed. But simpler may be
better. And I also noticed several other problems with the code I posted
yesterday afternoon.
How about something like this?
@@ -215,6 +225,17 @@ static void ravb_ring_free(struct net_device *ndev, int q)
}
if (priv->tx_ring[q]) {
+ for (i = 0; i < priv->num_tx_ring[q] * NUM_TX_DESC; i++) {
+ struct ravb_tx_desc *desc = &priv->tx_ring[q][i];
+
+ if (desc->die_dt != DT_EEMPTY) {
+ u32 size = le16_to_cpu(desc->ds_tagl) & TX_DS;
+
+ dma_unmap_single(ndev->dev.parent,
+ le32_to_cpu(desc->dptr),
+ size, DMA_TO_DEVICE);
+ }
+ }
ring_size = sizeof(struct ravb_tx_desc) *
(priv->num_tx_ring[q] * NUM_TX_DESC + 1);
dma_free_coherent(ndev->dev.parent, ring_size, priv->tx_ring[q],
next prev parent reply other threads:[~2017-01-13 12:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 10:43 [PATCH/RFC v2 net-next] ravb: unmap descriptors when freeing rings Simon Horman
2017-01-06 19:02 ` Sergei Shtylyov
2017-01-12 9:11 ` Simon Horman
2017-01-12 12:03 ` Sergei Shtylyov
2017-01-12 13:18 ` Simon Horman
2017-01-12 16:33 ` Sergei Shtylyov
2017-01-13 12:01 ` Simon Horman [this message]
2017-01-16 20:41 ` Sergei Shtylyov
2017-01-23 9:19 ` Simon Horman
2017-01-12 13:23 ` Lino Sanfilippo
2017-01-12 16:37 ` Sergei Shtylyov
2017-01-12 16:55 ` [EXT] " Lino Sanfilippo
2017-01-12 18:00 ` Sergei Shtylyov
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=20170113120133.GA31006@verge.net.au \
--to=horms@verge.net.au \
--cc=davem@davemloft.net \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
/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).