From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Guo, Jia" <jia.guo@intel.com>,
"stephen@networkplumber.org" <stephen@networkplumber.org>,
"Richardson, Bruce" <bruce.richardson@intel.com>,
"Yigit, Ferruh" <ferruh.yigit@intel.com>,
"gaetan.rivet@6wind.com" <gaetan.rivet@6wind.com>,
"Wu, Jingjing" <jingjing.wu@intel.com>,
"thomas@monjalon.net" <thomas@monjalon.net>,
"motih@mellanox.com" <motih@mellanox.com>,
"Van Haaren, Harry" <harry.van.haaren@intel.com>,
"Tan, Jianfeng" <jianfeng.tan@intel.com>
Cc: "jblunck@infradead.org" <jblunck@infradead.org>,
"shreyansh.jain@nxp.com" <shreyansh.jain@nxp.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Zhang, Helin" <helin.zhang@intel.com>
Subject: Re: [dpdk-dev] [PATCH V19 1/4] bus/pci: introduce device hot unplug handle
Date: Mon, 9 Apr 2018 17:47:57 +0000 [thread overview]
Message-ID: <2601191342CEEE43887BDE71AB977258AE91269E@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <1523012217-31146-2-git-send-email-jia.guo@intel.com>
> -----Original Message-----
> From: Guo, Jia
> Sent: Friday, April 6, 2018 11:57 AM
> To: stephen@networkplumber.org; Richardson, Bruce <bruce.richardson@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Ananyev,
> Konstantin <konstantin.ananyev@intel.com>; gaetan.rivet@6wind.com; Wu, Jingjing <jingjing.wu@intel.com>; thomas@monjalon.net;
> motih@mellanox.com; Van Haaren, Harry <harry.van.haaren@intel.com>; Tan, Jianfeng <jianfeng.tan@intel.com>
> Cc: jblunck@infradead.org; shreyansh.jain@nxp.com; dev@dpdk.org; Guo, Jia <jia.guo@intel.com>; Zhang, Helin <helin.zhang@intel.com>
> Subject: [PATCH V19 1/4] bus/pci: introduce device hot unplug handle
>
> As of device hot unplug, we need some preparatory measures so that we will
> not encounter memory fault after device be plug out of the system,
> and also let we could recover the running data path but not been break.
> This allows the buses to handle device hot unplug event.
> The patch only enable the ops in pci bus, when handle device hot unplug
> event, remap a dummy memory to avoid bus read/write error.
> Other buses could accordingly implement this ops specific by themselves.
>
> Signed-off-by: Jeff Guo <jia.guo@intel.com>
> ---
> v19->v18:
> fix some typo and squeeze patch
> ---
> drivers/bus/pci/pci_common.c | 42 +++++++++++++++++++++++++++++++++
> drivers/bus/pci/pci_common_uio.c | 32 +++++++++++++++++++++++++
> drivers/bus/pci/private.h | 12 ++++++++++
> lib/librte_eal/common/include/rte_bus.h | 15 ++++++++++++
> 4 files changed, 101 insertions(+)
>
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 2a00f36..09192ed 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -474,6 +474,47 @@ pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
> }
>
> static int
> +pci_handle_hot_unplug(struct rte_device *dev)
> +{
> + struct rte_pci_device *pdev;
> + int ret;
> +
> + if (dev == NULL)
> + return -EINVAL;
> +
> + pdev = RTE_DEV_TO_PCI(dev);
> +
> + /* remap resources for devices */
> + switch (pdev->kdrv) {
> + case RTE_KDRV_VFIO:
> +#ifdef VFIO_PRESENT
> + /* TODO */
> +#endif
> + break;
> + case RTE_KDRV_IGB_UIO:
> + case RTE_KDRV_UIO_GENERIC:
> + if (rte_eal_using_phys_addrs()) {
> + /* map resources for devices that use uio */
> + ret = pci_uio_remap_resource(pdev);
> + }
> + break;
> + case RTE_KDRV_NIC_UIO:
> + ret = pci_uio_remap_resource(pdev);
> + break;
> + default:
> + RTE_LOG(DEBUG, EAL,
> + " Not managed by a supported kernel driver, skipped\n");
> + ret = -1;
> + break;
> + }
> +
> + if (ret != 0)
> + RTE_LOG(ERR, EAL, "failed to handle hot unplug of %s",
> + pdev->name);
> + return ret;
> +}
> +
> +static int
> pci_plug(struct rte_device *dev)
> {
> return pci_probe_all_drivers(RTE_DEV_TO_PCI(dev));
> @@ -503,6 +544,7 @@ struct rte_pci_bus rte_pci_bus = {
> .unplug = pci_unplug,
> .parse = pci_parse,
> .get_iommu_class = rte_pci_get_iommu_class,
> + .handle_hot_unplug = pci_handle_hot_unplug,
> },
> .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
> .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
> diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c
> index 54bc20b..31a4094 100644
> --- a/drivers/bus/pci/pci_common_uio.c
> +++ b/drivers/bus/pci/pci_common_uio.c
> @@ -146,6 +146,38 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
> }
> }
>
> +/* remap the PCI resource of a PCI device in private virtual memory */
> +int
> +pci_uio_remap_resource(struct rte_pci_device *dev)
> +{
> + int i;
> + void *map_address;
> +
> + if (dev == NULL)
> + return -1;
> +
> + /* Remap all BARs */
> + for (i = 0; i != PCI_MAX_RESOURCE; i++) {
> + /* skip empty BAR */
> + if (dev->mem_resource[i].phys_addr == 0)
> + continue;
> + pci_unmap_resource(dev->mem_resource[i].addr,
> + (size_t)dev->mem_resource[i].len);
> + map_address = pci_map_resource(
> + dev->mem_resource[i].addr, -1, 0,
> + (size_t)dev->mem_resource[i].len,
> + MAP_ANONYMOUS | MAP_FIXED);
Wouldn't it be possible to use mremap() here?
To do munmap/mmap in one go?
> + if (map_address == MAP_FAILED) {
> + RTE_LOG(ERR, EAL,
> + "Cannot remap resource for device %s\n",
> + dev->name);
> + return -1;
> + }
> + }
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2018-04-09 17:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 18:17 [dpdk-dev] [PATCH V18 0/5] add hot plug failure and auto bind handler Jeff Guo
2018-04-03 18:17 ` [dpdk-dev] [PATCH V18 1/5] bus: introduce device hot unplug handle Jeff Guo
2018-04-04 4:31 ` Tan, Jianfeng
2018-04-06 10:54 ` Guo, Jia
2018-04-03 18:17 ` [dpdk-dev] [PATCH V18 2/5] bus/pci: implement handle hot unplug operation Jeff Guo
2018-04-04 5:25 ` Tan, Jianfeng
2018-04-06 10:57 ` Guo, Jia
2018-04-03 18:17 ` [dpdk-dev] [PATCH V18 3/5] eal: add failure handler mechanism for hot plug Jeff Guo
2018-04-04 2:58 ` Zhang, Qi Z
2018-04-06 10:53 ` Guo, Jia
2018-04-03 18:17 ` [dpdk-dev] [PATCH V18 4/5] eal: add driver auto bind for hot insertion Jeff Guo
2018-04-03 18:17 ` [dpdk-dev] [PATCH V18 5/5] app/testpmd: use auto handle for hotplug Jeff Guo
2018-04-06 10:56 ` [dpdk-dev] [PATCH V19 0/4] add hot plug failure and auto bind handler Jeff Guo
2018-04-06 10:56 ` [dpdk-dev] [PATCH V19 1/4] bus/pci: introduce device hot unplug handle Jeff Guo
2018-04-09 17:47 ` Ananyev, Konstantin [this message]
2018-04-11 11:37 ` Guo, Jia
2018-04-06 10:56 ` [dpdk-dev] [PATCH V19 2/4] eal: add failure handler mechanism for hot plug Jeff Guo
2018-04-06 14:03 ` Zhang, Qi Z
2018-04-06 14:24 ` Zhang, Qi Z
2018-04-11 11:50 ` Guo, Jia
2018-04-11 11:49 ` Guo, Jia
2018-04-09 17:42 ` Ananyev, Konstantin
2018-04-11 11:34 ` Guo, Jia
2018-04-06 10:56 ` [dpdk-dev] [PATCH V19 3/4] eal: add driver auto bind for hot insertion Jeff Guo
2018-04-06 10:56 ` [dpdk-dev] [PATCH V19 4/4] app/testpmd: use auto handle for hotplug Jeff Guo
2018-04-12 5:31 ` Matan Azrad
2018-04-13 10:48 ` Guo, Jia
2018-04-13 14:58 ` Matan Azrad
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=2601191342CEEE43887BDE71AB977258AE91269E@IRSMSX102.ger.corp.intel.com \
--to=konstantin.ananyev@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=gaetan.rivet@6wind.com \
--cc=harry.van.haaren@intel.com \
--cc=helin.zhang@intel.com \
--cc=jblunck@infradead.org \
--cc=jia.guo@intel.com \
--cc=jianfeng.tan@intel.com \
--cc=jingjing.wu@intel.com \
--cc=motih@mellanox.com \
--cc=shreyansh.jain@nxp.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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).