get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/42704/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 42704,
    "url": "http://patches.dpdk.org/api/patches/42704/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1531220607-2977-8-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": "<1531220607-2977-8-git-send-email-jia.guo@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1531220607-2977-8-git-send-email-jia.guo@intel.com",
    "date": "2018-07-10T11:03:27",
    "name": "[v8,7/7] igb_uio: fix uio release 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/1531220607-2977-8-git-send-email-jia.guo@intel.com/mbox/",
    "series": [
        {
            "id": 491,
            "url": "http://patches.dpdk.org/api/series/491/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=491",
            "date": "2018-07-10T11:03:20",
            "name": "hotplug failure handle mechanism",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/491/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42704/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/42704/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 69A8F1B488;\n\tTue, 10 Jul 2018 13:06:05 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 3C6A61B485\n\tfor <dev@dpdk.org>; Tue, 10 Jul 2018 13:06:03 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t10 Jul 2018 04:06:02 -0700",
            "from jeffguo-z170x-ud5.sh.intel.com (HELO localhost.localdomain)\n\t([10.67.104.10])\n\tby fmsmga001.fm.intel.com with ESMTP; 10 Jul 2018 04:06:00 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,334,1526367600\"; d=\"scan'208\";a=\"71076453\"",
        "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": "Tue, 10 Jul 2018 19:03:27 +0800",
        "Message-Id": "<1531220607-2977-8-git-send-email-jia.guo@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1531220607-2977-1-git-send-email-jia.guo@intel.com>",
        "References": "<1498711073-42917-1-git-send-email-jia.guo@intel.com>\n\t<1531220607-2977-1-git-send-email-jia.guo@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v8 7/7] igb_uio: fix uio release issue for hotplug",
        "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 hotplug out device, the device resource will be released in kernel.\nThe fd sys file will disappear, and the irq will be released. At this time,\nif igb uio driver still try to release this resource, it will cause kernel\ncrash. On the other hand, interrupt disabling do not automatically be\nprocessed in kernel. If not handle it, this redundancy and dirty thing will\naffect the interrupt resource be used by other device. So the igb_uio\ndriver have to check the hotplug status, and the corresponding process\nshould be taken in igb uio driver.\n\nThis patch propose to add enum rte_udev_state into struct rte_uio_pci_dev\nof igb uio driver, which will record the state of uio device, such as\nprobed/opened/released/removed. When detect the unexpected removal which\ncause of hotplug out behavior, it will corresponding disable interrupt\nresource. For the part of releasement which kernel have already handle,\njust skip it to avoid double free or null pointer crash issue.\n\nSigned-off-by: Jeff Guo <jia.guo@intel.com>\n---\nv8->v7:\nchange enum of udev state, refine code to release udev resource\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": [
        "v8",
        "7/7"
    ]
}