linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yelena Krivosheev <yelena@marvell.com>
To: Gregory CLEMENT <gregory.clement@bootlin.com>,
	Antoine Tenart <antoine.tenart@bootlin.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"thomas.petazzoni@bootlin.com" <thomas.petazzoni@bootlin.com>,
	"maxime.chevallier@bootlin.com" <maxime.chevallier@bootlin.com>,
	"miquel.raynal@bootlin.com" <miquel.raynal@bootlin.com>,
	Nadav Haklai <nadavh@marvell.com>,
	"Stefan Chulski" <stefanc@marvell.com>,
	Yan Markman <ymarkman@marvell.com>,
	"mw@semihalf.com" <mw@semihalf.com>
Subject: RE: [EXT] [PATCH net] net: mvneta: fix the Rx desc buffer DMA unmapping
Date: Sat, 22 Sep 2018 07:07:57 +0000	[thread overview]
Message-ID: <92138f5d3c8548f4ad9637cd0736139d@IL-EXCH01.marvell.com> (raw)
In-Reply-To: <87k1ngjjtd.fsf@bootlin.com>

Hi Gregory.

I want to clarify static mvneta_rxq_drop_pkts():

static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
				 struct mvneta_rx_queue *rxq)
{
	int rx_done, i;

	rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
	if (rx_done)
		mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);

	if (pp->bm_priv) { <---------------------------- this is case for HWBM
		for (i = 0; i < rx_done; i++) {
			struct mvneta_rx_desc *rx_desc =
						  mvneta_rxq_next_desc_get(rxq);
			u8 pool_id = MVNETA_RX_GET_BM_POOL_ID(rx_desc);
			struct mvneta_bm_pool *bm_pool;

			bm_pool = &pp->bm_priv->bm_pools[pool_id];
			/* Return dropped buffer to the pool */
			mvneta_bm_pool_put_bp(pp->bm_priv, bm_pool,
					      rx_desc->buf_phys_addr);
		}
		return;
	}

<-------- this is case for SWBM only
	for (i = 0; i < rxq->size; i++) {
		struct mvneta_rx_desc *rx_desc = rxq->descs + i;
		void *data = rxq->buf_virt_addr[i];

		if (!data || !(rx_desc->buf_phys_addr))
			continue;
		dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
				 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
		__free_page(data);
	}
}

So I suggest to fix dma_unmap_single() call too.

Thanks.
Yelena


-----Original Message-----
From: Gregory CLEMENT [mailto:gregory.clement@bootlin.com] 
Sent: Thursday, September 20, 2018 6:00 PM
To: Antoine Tenart <antoine.tenart@bootlin.com>
Cc: Yelena Krivosheev <yelena@marvell.com>; davem@davemloft.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; thomas.petazzoni@bootlin.com; maxime.chevallier@bootlin.com; miquel.raynal@bootlin.com; Nadav Haklai <nadavh@marvell.com>; Stefan Chulski <stefanc@marvell.com>; Yan Markman <ymarkman@marvell.com>; mw@semihalf.com
Subject: Re: [EXT] [PATCH net] net: mvneta: fix the Rx desc buffer DMA unmapping

Hi Antoine,
 
 On jeu., sept. 20 2018, Antoine Tenart <antoine.tenart@bootlin.com> wrote:

> Hi Yelena,
>
> On Thu, Sep 20, 2018 at 10:14:56AM +0000, Yelena Krivosheev wrote:
>> 
>> Please, check and fix all cases of dma_unmap_single() usage.
>> See mvneta_rxq_drop_pkts()
>> ...
>> 		if (!data || !(rx_desc->buf_phys_addr))
>> 			continue;
>> 		dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
>> 				 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
>> 		__free_page(data);
>> ...
>
> I had a look at the one reported by CONFIG_DMA_API_DEBUG, and at DMA 
> unmapping calls using PAGE_SIZE. As you pointed out there might be 
> others parts, thanks!

Actually Jisheng had submitted a similar patch few weeks ago and as I pointed at this time, the dma_unmap in mvneta_rxq_drop_pkts can be called when the allocation is done in with HWBM in this case which use a dma_map_single.

I though that in this case using dma_map_single is the things to do even if in the SWBM case it is less optimal.

Gregory

>
> Antoine
>
> --
> Antoine Ténart, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

--
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

      reply	other threads:[~2018-09-22  7:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19 13:29 [PATCH net] net: mvneta: fix the Rx desc buffer DMA unmapping Antoine Tenart
2018-09-20  4:25 ` David Miller
2018-09-20 10:14 ` [EXT] " Yelena Krivosheev
2018-09-20 11:20   ` Antoine Tenart
2018-09-20 14:59     ` Gregory CLEMENT
2018-09-22  7:07       ` Yelena Krivosheev [this message]

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=92138f5d3c8548f4ad9637cd0736139d@IL-EXCH01.marvell.com \
    --to=yelena@marvell.com \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=gregory.clement@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=stefanc@marvell.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=ymarkman@marvell.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).