DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Andrew Rybchenko <arybchenko@solarflare.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: Alejandro Lucero <alejandro.lucero@netronome.com>
Subject: Re: [dpdk-dev] [PATCH] vfio: set IOMMU type for the container once
Date: Fri, 28 Apr 2017 13:24:25 +0000	[thread overview]
Message-ID: <C6ECDF3AB251BE4894318F4E45123697822114C9@IRSMSX109.ger.corp.intel.com> (raw)
In-Reply-To: <1491321976-27290-1-git-send-email-arybchenko@solarflare.com>

> From: Andrew Rybchenko [mailto:arybchenko@solarflare.com]
> Sent: Tuesday, April 4, 2017 5:06 PM
> To: dev@dpdk.org
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>; Alejandro Lucero
> <alejandro.lucero@netronome.com>
> Subject: [PATCH] vfio: set IOMMU type for the container once
> 
> If more than one used PCI device belongs to one IOMMU group, it is still one
> IOMMU group and the container IOMMU type should be set only once.
> 
> Fixes: 94c0776b1bad ("vfio: support hotplug")
> 
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> My testing of the patch is limitted to my configuration with 2 PCI functions
> which belong to one IOMMU group.
> 
>  lib/librte_eal/linuxapp/eal/eal_vfio.c | 54 ++++++++++++++++++-------------
> ---
>  1 file changed, 29 insertions(+), 25 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> index 6e2e84c..dd59c1c 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> @@ -298,33 +298,37 @@ vfio_setup_device(const char *sysfs_base, const
> char *dev_addr,
>  			clear_group(vfio_group_fd);
>  			return -1;
>  		}
> -	}
> 
> -	/*
> -	 * pick an IOMMU type and set up DMA mappings for container
> -	 *
> -	 * needs to be done only once, only when first group is assigned to
> -	 * a container and only in primary process. Note this can happen
> several
> -	 * times with the hotplug functionality.
> -	 */
> -	if (internal_config.process_type == RTE_PROC_PRIMARY &&
> -			vfio_cfg.vfio_active_groups == 1) {
> -		/* select an IOMMU type which we will be using */
> -		const struct vfio_iommu_type *t =
> +		/*
> +		 * pick an IOMMU type and set up DMA mappings for
> container
> +		 *
> +		 * needs to be done only once, only when first group is
> +		 * assigned to a container and only in primary process.
> +		 * Note this can happen several times with the hotplug
> +		 * functionality.
> +		 */
> +		if (internal_config.process_type == RTE_PROC_PRIMARY &&
> +				vfio_cfg.vfio_active_groups == 1) {
> +			/* select an IOMMU type which we will be using */
> +			const struct vfio_iommu_type *t =
> 
> 	vfio_set_iommu_type(vfio_cfg.vfio_container_fd);
> -		if (!t) {
> -			RTE_LOG(ERR, EAL, "  %s failed to select IOMMU
> type\n", dev_addr);
> -			close(vfio_group_fd);
> -			clear_group(vfio_group_fd);
> -			return -1;
> -		}
> -		ret = t->dma_map_func(vfio_cfg.vfio_container_fd);
> -		if (ret) {
> -			RTE_LOG(ERR, EAL, "  %s DMA remapping failed, "
> -					"error %i (%s)\n", dev_addr, errno,
> strerror(errno));
> -			close(vfio_group_fd);
> -			clear_group(vfio_group_fd);
> -			return -1;
> +			if (!t) {
> +				RTE_LOG(ERR, EAL,
> +					"  %s failed to select IOMMU type\n",
> +					dev_addr);
> +				close(vfio_group_fd);
> +				clear_group(vfio_group_fd);
> +				return -1;
> +			}
> +			ret = t->dma_map_func(vfio_cfg.vfio_container_fd);
> +			if (ret) {
> +				RTE_LOG(ERR, EAL,
> +					"  %s DMA remapping failed, error %i
> (%s)\n",
> +					dev_addr, errno, strerror(errno));
> +				close(vfio_group_fd);
> +				clear_group(vfio_group_fd);
> +				return -1;
> +			}
>  		}
>  	}
> 
> --
> 2.7.4

Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>

  parent reply	other threads:[~2017-04-28 13:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 16:06 Andrew Rybchenko
2017-04-21  9:12 ` gowrishankar muthukrishnan
2017-04-21  9:23   ` Alejandro Lucero
2017-04-26 10:36     ` gowrishankar muthukrishnan
2017-04-26 10:52       ` Alejandro Lucero
2017-04-28 13:24 ` Burakov, Anatoly [this message]
2017-04-30 17:25   ` Thomas Monjalon

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=C6ECDF3AB251BE4894318F4E45123697822114C9@IRSMSX109.ger.corp.intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=alejandro.lucero@netronome.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.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).