DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ding, Xuan" <xuan.ding@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	"Xia, Chenbo" <chenbo.xia@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Hu, Jiayu" <jiayu.hu@intel.com>,
	"He, Xingguang" <xingguang.he@intel.com>,
	"Yang, YvonneX" <yvonnex.yang@intel.com>,
	"Jiang, Cheng1" <cheng1.jiang@intel.com>,
	"Wang, YuanX" <yuanx.wang@intel.com>,
	"Ma, WenwuX" <wenwux.ma@intel.com>
Subject: RE: [PATCH v4 2/2] examples/vhost: unconfigure DMA vchannel
Date: Thu, 13 Oct 2022 08:49:50 +0000	[thread overview]
Message-ID: <BN9PR11MB55133D295E612833961BB875E7259@BN9PR11MB5513.namprd11.prod.outlook.com> (raw)
In-Reply-To: <d4e192bb-eebf-dac4-f2b5-135c3c446978@redhat.com>



> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Thursday, October 13, 2022 4:07 PM
> To: Ding, Xuan <xuan.ding@intel.com>; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; He, Xingguang
> <xingguang.he@intel.com>; Yang, YvonneX <yvonnex.yang@intel.com>;
> Jiang, Cheng1 <cheng1.jiang@intel.com>; Wang, YuanX
> <yuanx.wang@intel.com>; Ma, WenwuX <wenwux.ma@intel.com>
> Subject: Re: [PATCH v4 2/2] examples/vhost: unconfigure DMA vchannel
> 
> 
> 
> On 10/13/22 08:40, xuan.ding@intel.com wrote:
> > From: Xuan Ding <xuan.ding@intel.com>
> >
> > This patch applies rte_vhost_async_dma_unconfigure() to manually free
> > DMA vchannels. Before unconfiguration, need make sure the specified
> > DMA device is no longer used by any vhost ports.
> >
> > Signed-off-by: Xuan Ding <xuan.ding@intel.com>
> > ---
> >   examples/vhost/main.c | 38 +++++++++++++++++++++++++-------------
> >   1 file changed, 25 insertions(+), 13 deletions(-)
> >
> > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index
> > ac78704d79..bfeb808dcc 100644
> > --- a/examples/vhost/main.c
> > +++ b/examples/vhost/main.c
> > @@ -73,6 +73,7 @@ static int total_num_mbufs = NUM_MBUFS_DEFAULT;
> >
> >   struct dma_for_vhost dma_bind[RTE_MAX_VHOST_DEVICE];
> >   int16_t dmas_id[RTE_DMADEV_DEFAULT_MAX];
> > +int16_t dma_ref_count[RTE_DMADEV_DEFAULT_MAX];
> >   static int dma_count;
> >
> >   /* mask of enabled ports */
> > @@ -371,6 +372,7 @@ open_dma(const char *value)
> >   done:
> >   		(dma_info + socketid)->dmas[vring_id].dev_id = dev_id;
> >   		(dma_info + socketid)->async_flag |= async_flag;
> > +		dma_ref_count[dev_id]++;
> >   		i++;
> >   	}
> >   out:
> > @@ -1562,6 +1564,27 @@ vhost_clear_queue(struct vhost_dev *vdev,
> uint16_t queue_id)
> >   	}
> >   }
> >
> > +static void
> > +vhost_clear_async(struct vhost_dev *vdev, int vid, uint16_t queue_id)
> > +{
> > +	int16_t dma_id;
> > +
> > +	if (dma_bind[vid].dmas[queue_id].async_enabled) {
> 
> if (!dma_bind[vid].dmas[queue_id].async_enabled)
> 	return;
> 
> > +		vhost_clear_queue(vdev, queue_id);
> > +		rte_vhost_async_channel_unregister(vid, queue_id);
> > +		dma_bind[vid].dmas[queue_id].async_enabled = false;
> > +
> > +		dma_id = dma_bind[vid2socketid[vdev-
> >vid]].dmas[queue_id].dev_id;
> > +		dma_ref_count[dma_id]--;
> > +
> > +		if (dma_ref_count[dma_id] == 0) {
> 
> if (dma_ref_count[dma_id] > 0)
> 	return;
> 
> Doing this should improve readability.

Good suggestion! Please see v5.

Thanks,
Xuan

> 
> > +			if (rte_vhost_async_dma_unconfigure(dma_id, 0) < 0)
> > +				RTE_LOG(ERR, VHOST_CONFIG,
> > +				       "Failed to unconfigure DMA %d in
> vhost.\n", dma_id);
> > +		}
> > +	}
> > +}
> > +
> >   /*
> >    * Remove a device from the specific data core linked list and from the
> >    * main linked list. Synchronization  occurs through the use of the
> > @@ -1618,17 +1641,8 @@ destroy_device(int vid)
> >   		"(%d) device has been removed from data core\n",
> >   		vdev->vid);
> >
> > -	if (dma_bind[vid].dmas[VIRTIO_RXQ].async_enabled) {
> > -		vhost_clear_queue(vdev, VIRTIO_RXQ);
> > -		rte_vhost_async_channel_unregister(vid, VIRTIO_RXQ);
> > -		dma_bind[vid].dmas[VIRTIO_RXQ].async_enabled = false;
> > -	}
> > -
> > -	if (dma_bind[vid].dmas[VIRTIO_TXQ].async_enabled) {
> > -		vhost_clear_queue(vdev, VIRTIO_TXQ);
> > -		rte_vhost_async_channel_unregister(vid, VIRTIO_TXQ);
> > -		dma_bind[vid].dmas[VIRTIO_TXQ].async_enabled = false;
> > -	}
> > +	vhost_clear_async(vdev, vid, VIRTIO_RXQ);
> > +	vhost_clear_async(vdev, vid, VIRTIO_TXQ);
> >
> >   	rte_free(vdev);
> >   }
> > @@ -1690,8 +1704,6 @@ vhost_async_channel_register(int vid)
> >   	return rx_ret | tx_ret;
> >   }
> >
> > -
> > -
> >   /*
> >    * A new device is added to a data core. First the device is added to the
> main linked list
> >    * and then allocated to a specific data core.


  reply	other threads:[~2022-10-13  8:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-14 14:04 [PATCH v1 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-08-14 14:04 ` [PATCH v1 1/2] " xuan.ding
2022-08-14 14:04 ` [PATCH v1 2/2] example/vhost: unconfigure DMA vchannel xuan.ding
2022-09-06  5:21 ` [PATCH v2 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-09-06  5:21   ` [PATCH v2 1/2] " xuan.ding
2022-09-26  6:06     ` Xia, Chenbo
2022-09-26  6:43       ` Ding, Xuan
2022-09-06  5:21   ` [PATCH v2 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-09-29  1:32 ` [PATCH v3 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-09-29  1:32   ` [PATCH v3 1/2] " xuan.ding
2022-09-29  1:32   ` [PATCH v3 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-09-29  8:27     ` Xia, Chenbo
2022-10-08  0:38       ` Ding, Xuan
2022-10-13  6:40 ` [PATCH v4 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-10-13  6:40   ` [PATCH v4 1/2] " xuan.ding
2022-10-13  8:01     ` Maxime Coquelin
2022-10-13  8:45       ` Ding, Xuan
2022-10-13  6:40   ` [PATCH v4 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-10-13  8:07     ` Maxime Coquelin
2022-10-13  8:49       ` Ding, Xuan [this message]
2022-10-13  9:27 ` [PATCH v5 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-10-13  9:27   ` [PATCH v5 1/2] " xuan.ding
2022-10-13  9:27   ` [PATCH v5 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-10-18 15:22 ` [PATCH v6 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-10-18 15:22   ` [PATCH v6 1/2] " xuan.ding
2022-10-19  9:28     ` Xia, Chenbo
2022-10-18 15:22   ` [PATCH v6 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-10-19  2:57     ` Ling, WeiX
2022-10-20  9:11 ` [PATCH v7 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-10-20  9:11   ` [PATCH v7 1/2] " xuan.ding
2022-10-21  8:09     ` Maxime Coquelin
2022-10-21  8:22       ` Ding, Xuan
2022-10-20  9:11   ` [PATCH v7 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-10-21  8:12     ` Maxime Coquelin
2022-10-25  8:25 ` [PATCH v8 0/2] vhost: introduce DMA vchannel unconfiguration xuan.ding
2022-10-25  8:25   ` [PATCH v8 1/2] " xuan.ding
2022-10-26  5:13     ` Maxime Coquelin
2022-10-26  9:02     ` Xia, Chenbo
2022-10-25  8:25   ` [PATCH v8 2/2] examples/vhost: unconfigure DMA vchannel xuan.ding
2022-10-25  9:56     ` Ling, WeiX
2022-10-26  5:14     ` Maxime Coquelin
2022-10-26  9:03     ` Xia, Chenbo
2022-10-26  9:07   ` [PATCH v8 0/2] vhost: introduce DMA vchannel unconfiguration Xia, Chenbo

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=BN9PR11MB55133D295E612833961BB875E7259@BN9PR11MB5513.namprd11.prod.outlook.com \
    --to=xuan.ding@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=cheng1.jiang@intel.com \
    --cc=dev@dpdk.org \
    --cc=jiayu.hu@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=wenwux.ma@intel.com \
    --cc=xingguang.he@intel.com \
    --cc=yuanx.wang@intel.com \
    --cc=yvonnex.yang@intel.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).