DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Qiu, Michael" <michael.qiu@intel.com>
To: Tetsuya Mukawa <mukawa@igel.co.jp>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] eal: fix vfio device never works.
Date: Tue, 14 Jul 2015 05:03:04 +0000	[thread overview]
Message-ID: <533710CFB86FA344BFBF2D6802E60286046BA583@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1436596189-1831-1-git-send-email-mukawa@igel.co.jp>

Hi, Tetsuya

So this patch  make linux app back to original?

Thanks,
Michael

On 7/11/2015 2:30 PM, Tetsuya Mukawa wrote:
> The patch fixes vfio initialization issue introduced by below patch.
>  - Commit 35b3313e322b ("pci: merge mapping functions for linux and bsd")
>
> Root cause is that VFIO_PRESENT is inaccessible in eal common level.
> To fix it, remove pci_map/unmap_device from common code, then implement
> in linux and bsd code.
>
> Reported-by: Michael Qiu <michael.qiu@intel.com>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> ---
>  lib/librte_eal/bsdapp/eal/eal_pci.c    | 39 ++++++++++++++++++++++++
>  lib/librte_eal/common/eal_common_pci.c | 55 ----------------------------------
>  lib/librte_eal/common/eal_private.h    | 18 +++++++++++
>  lib/librte_eal/linuxapp/eal/eal_pci.c  | 50 +++++++++++++++++++++++++++++++
>  4 files changed, 107 insertions(+), 55 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
> index 12f39d9..ed31222 100644
> --- a/lib/librte_eal/bsdapp/eal/eal_pci.c
> +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
> @@ -92,6 +92,45 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
>  	return -ENOTSUP;
>  }
>  
> +/* Map pci device */
> +int
> +pci_map_device(struct rte_pci_device *dev)
> +{
> +	int ret = -1;
> +
> +	/* try mapping the NIC resources */
> +	switch (dev->kdrv) {
> +	case RTE_KDRV_NIC_UIO:
> +		/* map resources for devices that use uio */
> +		ret = pci_uio_map_resource(dev);
> +		break;
> +	default:
> +		RTE_LOG(DEBUG, EAL,
> +			"  Not managed by a supported kernel driver, skipped\n");
> +		ret = 1;
> +		break;
> +	}
> +
> +	return ret;
> +}
> +
> +/* Unmap pci device */
> +void
> +pci_unmap_device(struct rte_pci_device *dev)
> +{
> +	/* try unmapping the NIC resources */
> +	switch (dev->kdrv) {
> +	case RTE_KDRV_NIC_UIO:
> +		/* unmap resources for devices that use uio */
> +		pci_uio_unmap_resource(dev);
> +		break;
> +	default:
> +		RTE_LOG(DEBUG, EAL,
> +			"  Not managed by a supported kernel driver, skipped\n");
> +		break;
> +	}
> +}
> +
>  void
>  pci_uio_free_resource(struct rte_pci_device *dev,
>  		struct mapped_pci_resource *uio_res)
> diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
> index 3805aed..60e40e0 100644
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -137,61 +137,6 @@ pci_unmap_resource(void *requested_addr, size_t size)
>  				requested_addr);
>  }
>  
> -/* Map pci device */
> -static int
> -pci_map_device(struct rte_pci_device *dev)
> -{
> -	int ret = -1;
> -
> -	/* try mapping the NIC resources using VFIO if it exists */
> -	switch (dev->kdrv) {
> -	case RTE_KDRV_VFIO:
> -#ifdef VFIO_PRESENT
> -		if (pci_vfio_is_enabled())
> -			ret = pci_vfio_map_resource(dev);
> -#endif
> -		break;
> -	case RTE_KDRV_IGB_UIO:
> -	case RTE_KDRV_UIO_GENERIC:
> -	case RTE_KDRV_NIC_UIO:
> -		/* map resources for devices that use uio */
> -		ret = pci_uio_map_resource(dev);
> -		break;
> -	default:
> -		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
> -			" skipped\n");
> -		ret = 1;
> -		break;
> -	}
> -
> -	return ret;
> -}
> -
> -/* Unmap pci device */
> -static void
> -pci_unmap_device(struct rte_pci_device *dev)
> -{
> -	if (dev == NULL)
> -		return;
> -
> -	/* try unmapping the NIC resources using VFIO if it exists */
> -	switch (dev->kdrv) {
> -	case RTE_KDRV_VFIO:
> -		RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
> -		break;
> -	case RTE_KDRV_IGB_UIO:
> -	case RTE_KDRV_UIO_GENERIC:
> -	case RTE_KDRV_NIC_UIO:
> -		/* unmap resources for devices that use uio */
> -		pci_uio_unmap_resource(dev);
> -		break;
> -	default:
> -		RTE_LOG(DEBUG, EAL, "  Not managed by a supported kernel driver,"
> -			" skipped\n");
> -		break;
> -	}
> -}
> -
>  /*
>   * If vendor/device ID match, call the devinit() function of the
>   * driver.
> diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
> index e16bb68..73363f6 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -165,6 +165,24 @@ struct rte_pci_device;
>  int pci_unbind_kernel_driver(struct rte_pci_device *dev);
>  
>  /**
> + * Map this device
> + *
> + * This function is private to EAL.
> + *
> + * @return
> + *   0 on success, negative on error and positive if no driver
> + *   is found for the device.
> + */
> +int pci_map_device(struct rte_pci_device *dev);
> +
> +/**
> + * Unmap this device
> + *
> + * This function is private to EAL.
> + */
> +void pci_unmap_device(struct rte_pci_device *dev);
> +
> +/**
>   * Map the PCI resource of a PCI device in virtual memory
>   *
>   * This function is private to EAL.
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index 1d5a13b..9a28ede 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -123,6 +123,56 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
>  	return -1;
>  }
>  
> +/* Map pci device */
> +int
> +pci_map_device(struct rte_pci_device *dev)
> +{
> +	int ret = -1;
> +
> +	/* try mapping the NIC resources using VFIO if it exists */
> +	switch (dev->kdrv) {
> +	case RTE_KDRV_VFIO:
> +#ifdef VFIO_PRESENT
> +		if (pci_vfio_is_enabled())
> +			ret = pci_vfio_map_resource(dev);
> +#endif
> +		break;
> +	case RTE_KDRV_IGB_UIO:
> +	case RTE_KDRV_UIO_GENERIC:
> +		/* map resources for devices that use uio */
> +		ret = pci_uio_map_resource(dev);
> +		break;
> +	default:
> +		RTE_LOG(DEBUG, EAL,
> +			"  Not managed by a supported kernel driver, skipped\n");
> +		ret = 1;
> +		break;
> +	}
> +
> +	return ret;
> +}
> +
> +/* Unmap pci device */
> +void
> +pci_unmap_device(struct rte_pci_device *dev)
> +{
> +	/* try unmapping the NIC resources using VFIO if it exists */
> +	switch (dev->kdrv) {
> +	case RTE_KDRV_VFIO:
> +		RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
> +		break;
> +	case RTE_KDRV_IGB_UIO:
> +	case RTE_KDRV_UIO_GENERIC:
> +		/* unmap resources for devices that use uio */
> +		pci_uio_unmap_resource(dev);
> +		break;
> +	default:
> +		RTE_LOG(DEBUG, EAL,
> +			"  Not managed by a supported kernel driver, skipped\n");
> +		break;
> +	}
> +}
> +
>  void *
>  pci_find_max_end_va(void)
>  {


  reply	other threads:[~2015-07-14  5:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  7:47 [dpdk-dev] [PATCH] BugFix: VFIO " Michael Qiu
2015-07-10  8:34 ` Tetsuya Mukawa
2015-07-10 11:25   ` David Marchand
2015-07-10 11:35     ` Tetsuya Mukawa
2015-07-10 11:38     ` Bruce Richardson
2015-07-10 12:12       ` Tetsuya Mukawa
2015-07-10 12:16       ` Thomas Monjalon
2015-07-11  6:32         ` Tetsuya Mukawa
2015-07-11  6:29 ` [dpdk-dev] [PATCH] eal: fix vfio device " Tetsuya Mukawa
2015-07-14  5:03   ` Qiu, Michael [this message]
2015-07-14  7:43     ` Tetsuya Mukawa
2015-07-14  8:44   ` 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=533710CFB86FA344BFBF2D6802E60286046BA583@SHSMSX101.ccr.corp.intel.com \
    --to=michael.qiu@intel.com \
    --cc=dev@dpdk.org \
    --cc=mukawa@igel.co.jp \
    /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).