Skip to contentSkip to conversation

sh_eth: merge sh_eth_free_dma_buffer() into sh_eth_ring_free()

PATCH Applied Sergei Shtylyov 3 participants 9 messages Nov 3, 2015 – Nov 5, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh_eth: merge sh_eth_free_dma_buffer() into sh_eth_ring_free()

While the ring allocation is done by a single function, sh_eth_ring_init(), the ring deallocation was split into two functions (almost always called one after the other) for no good reason. Merge sh_eth_free_dma_buffer() into sh_eth_ring_free() which allows us to save space not only on the direct calls of the former function but also on the sh_eth_ring_init()'s simplified error path...

---
The patch is against DaveM's 'net-next.git' repo plus the patch just posted.

 drivers/net/ethernet/renesas/sh_eth.c |   60 ++++++++++++----------------------
 1 file changed, 22 insertions(+), 38 deletions(-)

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -1098,7 +1098,7 @@ static struct mdiobb_ops bb_ops = {
static void sh_eth_ring_free(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
- int i;
+ int ringsize, i;

/* Free Rx skb ringbuffer */
if (mdp->rx_skbuff) {
@@ -1115,6 +1115,20 @@ static void sh_eth_ring_free(struct net_
}
kfree(mdp->tx_skbuff);
mdp->tx_skbuff = NULL;
+
+ if (mdp->rx_ring) {
+ ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring;
+ dma_free_coherent(NULL, ringsize, mdp->rx_ring,
+ mdp->rx_desc_dma);
+ mdp->rx_ring = NULL;
+ }
+
+ if (mdp->tx_ring) {
+ ringsize = sizeof(struct sh_eth_txdesc) * mdp->num_tx_ring;
+ dma_free_coherent(NULL, ringsize, mdp->tx_ring,
+ mdp->tx_desc_dma);
+ mdp->tx_ring = NULL;
+ }
}

/* format skb and descriptor buffer */
@@ -1220,14 +1234,14 @@ static int sh_eth_ring_init(struct net_d
mdp->tx_skbuff = kcalloc(mdp->num_tx_ring, sizeof(*mdp->tx_skbuff),
GFP_KERNEL);
if (!mdp->tx_skbuff)
- goto skb_ring_free;
+ goto ring_free;

/* Allocate all Rx descriptors. */
rx_ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring; mdp->rx_ring = dma_alloc_coherent(NULL, rx_ringsize, &mdp->rx_desc_dma,
GFP_KERNEL);
if (!mdp->rx_ring)
- goto skb_ring_free;
+ goto ring_free;

mdp->dirty_rx = 0;

@@ -1236,41 +1250,16 @@ static int sh_eth_ring_init(struct net_d
mdp->tx_ring = dma_alloc_coherent(NULL, tx_ringsize, &mdp->tx_desc_dma,
GFP_KERNEL);
if (!mdp->tx_ring)
- goto desc_ring_free;
+ goto ring_free;
return 0;

-desc_ring_free:
- /* free DMA buffer */
- dma_free_coherent(NULL, rx_ringsize, mdp->rx_ring, mdp->rx_desc_dma);
-
-skb_ring_free:
- /* Free Rx and Tx skb ring buffer */
+ring_free:
+ /* Free Rx and Tx skb ring buffer and DMA buffer */
sh_eth_ring_free(ndev);
- mdp->tx_ring = NULL;
- mdp->rx_ring = NULL;

return -ENOMEM;
}

-static void sh_eth_free_dma_buffer(struct sh_eth_private *mdp) -{
- int ringsize;
-
- if (mdp->rx_ring) {
- ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring;
- dma_free_coherent(NULL, ringsize, mdp->rx_ring,
- mdp->rx_desc_dma);
- mdp->rx_ring = NULL;
- }
-
- if (mdp->tx_ring) {
- ringsize = sizeof(struct sh_eth_txdesc) * mdp->num_tx_ring;
- dma_free_coherent(NULL, ringsize, mdp->tx_ring,
- mdp->tx_desc_dma);
- mdp->tx_ring = NULL;
- }
-}
-
static int sh_eth_dev_init(struct net_device *ndev, bool start) {
int ret = 0;
@@ -2231,10 +2220,8 @@ static int sh_eth_set_ringparam(struct n

sh_eth_dev_exit(ndev);

- /* Free all the skbuffs in the Rx queue. */
+ /* Free all the skbuffs in the Rx queue and the DMA buffers. */
sh_eth_ring_free(ndev);
- /* Free DMA buffer */
- sh_eth_free_dma_buffer(mdp);
}

/* Set new parameters */
@@ -2479,12 +2466,9 @@ static int sh_eth_close(struct net_devic

free_irq(ndev->irq, ndev);

- /* Free all the skbuffs in the Rx queue. */
+ /* Free all the skbuffs in the Rx queue and the DMA buffer. */
sh_eth_ring_free(ndev);

- /* free DMA buffer */
- sh_eth_free_dma_buffer(mdp);
-
pm_runtime_put_sync(&mdp->pdev->dev);

mdp->is_opened = 0;

maintainer Applied
#1 lore raw

From: Sergei Shtylyov <[email protected]>
Date: Wed, 04 Nov 2015 00:55:13 +0300

Quoted 8 lines

While the ring allocation is done by a single function, sh_eth_ring_init(), the ring deallocation was split into two functions (almost always called one after the other) for no good reason. Merge sh_eth_free_dma_buffer() into sh_eth_ring_free() which allows us to save space not only on the direct calls of the former function but also on the sh_eth_ring_init()'s simplified error path...

Applied.

#2 lore raw

Hello.

Quoted 10 lines · David Miller
Quoted 8 lines

While the ring allocation is done by a single function, sh_eth_ring_init(), the ring deallocation was split into two functions (almost always called one after the other) for no good reason. Merge sh_eth_free_dma_buffer() into sh_eth_ring_free() which allows us to save space not only on the direct calls of the former function but also on the sh_eth_ring_init()'s simplified error path...

Applied.

Hum, I'm seeing both patches in the net.git repo, while they were clearly
targeted to net-next.git... Did you really consider these 2 patches fixes?

MBR, Sergei

maintainer
#3 lore raw

From: Sergei Shtylyov <[email protected]>
Date: Thu, 5 Nov 2015 15:53:24 +0300

Quoted 15 lines

Hello.

Quoted 11 lines · David Miller
Quoted 11 lines

While the ring allocation is done by a single function, sh_eth_ring_init(),
the ring deallocation was split into two functions (almost always called
one after the other) for no good reason. Merge sh_eth_free_dma_buffer()
into sh_eth_ring_free() which allows us to save space not only on the direct calls of the former function but also on the sh_eth_ring_init()'s
simplified error path...

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied.

Hum, I'm seeing both patches in the net.git repo, while they were clearly targeted to net-next.git... Did you really consider these 2 patches fixes?

It was more work for me to let the patches rot in patchwork until I openned net-next back up than to simply just apply them to net.

You guys really make an enormous amount of work and stress for me when you submit net-next patches when I _CLEARLY_ and _EXPLICITLY_ state that the tree is closed right now.

#4 lore raw

Hello.

Quoted 13 lines · David Miller
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

While the ring allocation is done by a single function, sh_eth_ring_init(),
the ring deallocation was split into two functions (almost always called
one after the other) for no good reason. Merge sh_eth_free_dma_buffer()
into sh_eth_ring_free() which allows us to save space not only on the direct calls of the former function but also on the sh_eth_ring_init()'s
simplified error path...

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Applied.

Hum, I'm seeing both patches in the net.git repo, while they were clearly targeted to net-next.git... Did you really consider these 2 patches fixes?

It was more work for me to let the patches rot in patchwork until I openned net-next back up than to simply just apply them to net.

OK, thank you!

Quoted 3 lines

You guys really make an enormous amount of work and stress for me when you submit net-next patches when I _CLEARLY_ and _EXPLICITLY_ state that the tree is closed right now.

Hmm, I hadn't seen your announcement, else I would have refrained from
sending. Will look for it now...

MBR, Sergei

#5 lore raw
Quoted 6 lines · Sergei Shtylyov
Quoted 3 lines

You guys really make an enormous amount of work and stress for me when you submit net-next patches when I _CLEARLY_ and _EXPLICITLY_ state that the tree is closed right now.

Hmm, I hadn't seen your announcement, else I would have refrained from
sending. Will look for it now...

Nay, still not seeing anything...

MBR, Sergei

#7 lore raw
Quoted 6 lines · David Miller
Quoted 2 lines

Hmm, I hadn't seen your announcement, else I would have refrained from sending. Will look for it now...

I really don't know how to better get people's attention than this:

	http://marc.info/?l=linux-netdev&m4652382428132&w=2

Umm, I'm seeing it now, it's been even marked as read but I for the life
of me couldn't remember reading it. Now I'll have to say I'm really sorry for sending out my last 2 or 3 patches, I was under full impression your tree is still open... :-<

Quoted 1 line

Do I have to use all CAPS?

Well, perhaps that would have drawn more attention (it has in the past). :-)

Quoted 1 line

Flashing LEDs in the Subject?

    :-)

MBR, Sergei

#8 lore raw
In reply to David Miller
Quoted 6 lines · David Miller

From: Sergei Shtylyov <[email protected]>
Date: Thu, 5 Nov 2015 20:19:17 +0300

Quoted 2 lines

Hmm, I hadn't seen your announcement, else I would have refrained from sending. Will look for it now...

Quoted 7 lines

I really don't know how to better get people's attention than this:

	http://marc.info/?l=linux-netdev&m4652382428132&w=2

Do I have to use all CAPS? Flashing LEDs in the Subject?

Just tell me, I'll do it...

web page on www.isnetnextopen.com, with a giant word saying YES or NO :)

Dave