get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42826,
    "url": "http://patchwork.dpdk.org/api/patches/42826/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1531305717-15504-8-git-send-email-jia.guo@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<1531305717-15504-8-git-send-email-jia.guo@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1531305717-15504-8-git-send-email-jia.guo@intel.com",
    "date": "2018-07-11T10:41:57",
    "name": "[v9,7/7] 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://patchwork.dpdk.org/api/people/507/?format=api",
        "name": "Guo, Jia",
        "email": "jia.guo@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1531305717-15504-8-git-send-email-jia.guo@intel.com/mbox/",
    "series": [
        {
            "id": 517,
            "url": "http://patchwork.dpdk.org/api/series/517/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=517",
            "date": "2018-07-11T10:41:50",
            "name": "hotplug failure handle mechanism",
            "version": 9,
            "mbox": "http://patchwork.dpdk.org/series/517/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/42826/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/42826/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 6D8701B590;\n\tWed, 11 Jul 2018 12:44:47 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id 2D6941B571\n\tfor <dev@dpdk.org>; Wed, 11 Jul 2018 12:44:45 +0200 (CEST)",
            "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Jul 2018 03:44:43 -0700",
            "from jeffguo-z170x-ud5.sh.intel.com (HELO localhost.localdomain)\n\t([10.67.104.10])\n\tby fmsmga008.fm.intel.com with ESMTP; 11 Jul 2018 03:44:32 -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,338,1526367600\"; d=\"scan'208\";a=\"54202548\"",
        "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": "Wed, 11 Jul 2018 18:41:57 +0800",
        "Message-Id": "<1531305717-15504-8-git-send-email-jia.guo@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1531305717-15504-1-git-send-email-jia.guo@intel.com>",
        "References": "<1498711073-42917-1-git-send-email-jia.guo@intel.com>\n\t<1531305717-15504-1-git-send-email-jia.guo@intel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v9 7/7] 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 device be hotplug out, the pci resource will be released in kernel,\nthe uio fd will disappear, and the irq will be released. At this time,\nif igb uio driver still try to access or release these resource, it will\ncause kernel crash.\n\nOn the other hand, uio_remove will be called unexpectedly before\nuio_release. The uio_remove procedure will free resources which are needed\nby uio_release. So there is no chance to disable interrupt which is defined\ninside uio_release procedure. This will affect later usage of interrupt.\n\nSo the case of unexpectedly removal by hot unplug should be identify and\ncorrespondingly processed.\n\nThis patch propose to add enum rte_udev_state in struct rte_uio_pci_dev,\nthat will keep the state of uio device as probed/opened/released/removed.\n\nThis patch also checks kobject’s remove_uevent_sent state to detect the\nunexpectedly removal status which means hot unplug. Once hot unplug be\ndetected, it will call uio_release as soon as possible and set the uio\nstatus to be “removed”. After that, uio will check this status in\nuio_release function, if uio have already been removed, it will only free\nthe dirty uio resource.\n\nSigned-off-by: Jeff Guo <jia.guo@intel.com>\n---\nv9->v8:\nrefine commit log to be more readable.\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": [
        "v9",
        "7/7"
    ]
}