Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/43769/?format=api
http://patches.dpdk.org/api/patches/43769/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1534502916-31636-9-git-send-email-jia.guo@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1534502916-31636-9-git-send-email-jia.guo@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1534502916-31636-9-git-send-email-jia.guo@intel.com", "date": "2018-08-17T10:48:35", "name": "[v10,7/8] igb_uio: fix unexpected remove issue for hotplug", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "75ca0dba619cbb7c6221e3cc55460a31d2d5ce48", "submitter": { "id": 507, "url": "http://patches.dpdk.org/api/people/507/?format=api", "name": "Guo, Jia", "email": "jia.guo@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1534502916-31636-9-git-send-email-jia.guo@intel.com/mbox/", "series": [ { "id": 1007, "url": "http://patches.dpdk.org/api/series/1007/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1007", "date": "2018-08-17T10:48:27", "name": "hotplug failure handle mechanism", "version": 10, "mbox": "http://patches.dpdk.org/series/1007/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/43769/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/43769/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 4B99B5323;\n\tFri, 17 Aug 2018 12:51:47 +0200 (CEST)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id ADCCB4CE4\n\tfor <dev@dpdk.org>; Fri, 17 Aug 2018 12:51:43 +0200 (CEST)", "from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t17 Aug 2018 03:51:43 -0700", "from jeffguo-z170x-ud5.sh.intel.com (HELO localhost.localdomain)\n\t([10.67.104.10])\n\tby fmsmga007.fm.intel.com with ESMTP; 17 Aug 2018 03:51:40 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.53,250,1531810800\"; d=\"scan'208\";a=\"63131882\"", "From": "Jeff Guo <jia.guo@intel.com>", "To": "stephen@networkplumber.org, bruce.richardson@intel.com,\n\tferruh.yigit@intel.com, konstantin.ananyev@intel.com,\n\tgaetan.rivet@6wind.com, jingjing.wu@intel.com, thomas@monjalon.net,\n\tmotih@mellanox.com, matan@mellanox.com, harry.van.haaren@intel.com,\n\tqi.z.zhang@intel.com, shaopeng.he@intel.com,\n\tbernard.iremonger@intel.com, \n\tarybchenko@solarflare.com, wenzhuo.lu@intel.com", "Cc": "jblunck@infradead.org, shreyansh.jain@nxp.com, dev@dpdk.org,\n\tjia.guo@intel.com, helin.zhang@intel.com", "Date": "Fri, 17 Aug 2018 18:48:35 +0800", "Message-Id": "<1534502916-31636-9-git-send-email-jia.guo@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1534502916-31636-1-git-send-email-jia.guo@intel.com>", "References": "<1498711073-42917-1-git-send-email-jia.guo@intel.com>\n\t<1534502916-31636-1-git-send-email-jia.guo@intel.com>", "Subject": "[dpdk-dev] [PATCH v10 7/8] igb_uio: fix unexpected remove issue for\n\thotplug", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "When a device is hotplugged out, the PCI resource is released in the\nkernel, the UIO file descriptor will disappear and the irq will be\nreleased. After this, a kernel crash will be caused if the igb uio driver\ntries to access or release these resources.\n\nAnd more, uio_remove will be called unexpectedly before uio_release\nwhen device be hotpluggged out, the uio_remove procedure will\nfree resources that are required by uio_release. This will later affect the\nusage of interrupt as there is no way to disable the interrupt which is\ndefined in uio_release.\n\nTo prevent this, the hotplug removal needs to be identified and processed\naccordingly in igb uio driver.\n\nThis patch proposes the addition of enum rte_udev_state in the\nrte_uio_pci_dev struct. This will store the state of the uio device as one\nof the following: probed/opened/released/removed.\n\nThis patch also checks the kobject's remove_uevent_sent state to detect if\nthe removal status is hotplug-out. Once a hotplug-out is detected, it will\ncall uio_release and set the uio status to \"removed\". After that, uio will\ncheck the status in the uio_release function. If uio has already been\nremoved, it will only free the dirty uio resource.\n\nSigned-off-by: Jeff Guo <jia.guo@intel.com>\nAcked-by: Shaopeng He <shaopeng.he@intel.com>\n---\nv10->v9:\nrefine commmit log.\n---\n kernel/linux/igb_uio/igb_uio.c | 69 +++++++++++++++++++++++++++++++++---------\n 1 file changed, 55 insertions(+), 14 deletions(-)", "diff": "diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c\nindex 3398eac..d126371 100644\n--- a/kernel/linux/igb_uio/igb_uio.c\n+++ b/kernel/linux/igb_uio/igb_uio.c\n@@ -19,6 +19,14 @@\n \n #include \"compat.h\"\n \n+/* uio pci device state */\n+enum rte_udev_state {\n+\tRTE_UDEV_PROBED,\n+\tRTE_UDEV_OPENNED,\n+\tRTE_UDEV_RELEASED,\n+\tRTE_UDEV_REMOVED,\n+};\n+\n /**\n * A structure describing the private information for a uio device.\n */\n@@ -28,6 +36,7 @@ struct rte_uio_pci_dev {\n \tenum rte_intr_mode mode;\n \tstruct mutex lock;\n \tint refcnt;\n+\tenum rte_udev_state state;\n };\n \n static int wc_activate;\n@@ -309,6 +318,17 @@ igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)\n #endif\n }\n \n+/* Unmap previously ioremap'd resources */\n+static void\n+igbuio_pci_release_iomem(struct uio_info *info)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_UIO_MAPS; i++) {\n+\t\tif (info->mem[i].internal_addr)\n+\t\t\tiounmap(info->mem[i].internal_addr);\n+\t}\n+}\n \n /**\n * This gets called while opening uio device file.\n@@ -331,20 +351,35 @@ igbuio_pci_open(struct uio_info *info, struct inode *inode)\n \n \t/* enable interrupts */\n \terr = igbuio_pci_enable_interrupts(udev);\n-\tmutex_unlock(&udev->lock);\n \tif (err) {\n \t\tdev_err(&dev->dev, \"Enable interrupt fails\\n\");\n+\t\tpci_clear_master(dev);\n+\t\tmutex_unlock(&udev->lock);\n \t\treturn err;\n \t}\n+\tudev->state = RTE_UDEV_OPENNED;\n+\tmutex_unlock(&udev->lock);\n \treturn 0;\n }\n \n+/**\n+ * This gets called while closing uio device file.\n+ */\n static int\n igbuio_pci_release(struct uio_info *info, struct inode *inode)\n {\n \tstruct rte_uio_pci_dev *udev = info->priv;\n \tstruct pci_dev *dev = udev->pdev;\n \n+\tif (udev->state == RTE_UDEV_REMOVED) {\n+\t\tmutex_destroy(&udev->lock);\n+\t\tigbuio_pci_release_iomem(&udev->info);\n+\t\tpci_disable_device(dev);\n+\t\tpci_set_drvdata(dev, NULL);\n+\t\tkfree(udev);\n+\t\treturn 0;\n+\t}\n+\n \tmutex_lock(&udev->lock);\n \tif (--udev->refcnt > 0) {\n \t\tmutex_unlock(&udev->lock);\n@@ -356,7 +391,7 @@ igbuio_pci_release(struct uio_info *info, struct inode *inode)\n \n \t/* stop the device from further DMA */\n \tpci_clear_master(dev);\n-\n+\tudev->state = RTE_UDEV_RELEASED;\n \tmutex_unlock(&udev->lock);\n \treturn 0;\n }\n@@ -414,18 +449,6 @@ igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info,\n \treturn 0;\n }\n \n-/* Unmap previously ioremap'd resources */\n-static void\n-igbuio_pci_release_iomem(struct uio_info *info)\n-{\n-\tint i;\n-\n-\tfor (i = 0; i < MAX_UIO_MAPS; i++) {\n-\t\tif (info->mem[i].internal_addr)\n-\t\t\tiounmap(info->mem[i].internal_addr);\n-\t}\n-}\n-\n static int\n igbuio_setup_bars(struct pci_dev *dev, struct uio_info *info)\n {\n@@ -562,6 +585,9 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)\n \t\t\t (unsigned long long)map_dma_addr, map_addr);\n \t}\n \n+\tmutex_lock(&udev->lock);\n+\tudev->state = RTE_UDEV_PROBED;\n+\tmutex_unlock(&udev->lock);\n \treturn 0;\n \n fail_remove_group:\n@@ -579,6 +605,21 @@ static void\n igbuio_pci_remove(struct pci_dev *dev)\n {\n \tstruct rte_uio_pci_dev *udev = pci_get_drvdata(dev);\n+\tstruct pci_dev *pdev = udev->pdev;\n+\tint ret;\n+\n+\t/* handle unexpected removal */\n+\tif (udev->state == RTE_UDEV_OPENNED ||\n+\t (&pdev->dev.kobj)->state_remove_uevent_sent == 1) {\n+\t\tdev_notice(&dev->dev, \"Unexpected removal!\\n\");\n+\t\tret = igbuio_pci_release(&udev->info, NULL);\n+\t\tif (ret)\n+\t\t\treturn;\n+\t\tmutex_lock(&udev->lock);\n+\t\tudev->state = RTE_UDEV_REMOVED;\n+\t\tmutex_unlock(&udev->lock);\n+\t\treturn;\n+\t}\n \n \tmutex_destroy(&udev->lock);\n \tsysfs_remove_group(&dev->dev.kobj, &dev_attr_grp);\n", "prefixes": [ "v10", "7/8" ] }{ "id": 43769, "url": "