get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42300,
    "url": "http://patchwork.dpdk.org/api/patches/42300/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1530778903-31160-2-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": "<1530778903-31160-2-git-send-email-jia.guo@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1530778903-31160-2-git-send-email-jia.guo@intel.com",
    "date": "2018-07-05T08:21:43",
    "name": "[V5,7/7] igb_uio: fix uio release issue when hot unplug",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2f4b4c03016d47672299d5e4fb6b0823ec84e9f8",
    "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/1530778903-31160-2-git-send-email-jia.guo@intel.com/mbox/",
    "series": [
        {
            "id": 245,
            "url": "http://patchwork.dpdk.org/api/series/245/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=245",
            "date": "2018-06-26T15:36:09",
            "name": "[V3,1/4] bus/pci: handle device hot unplug",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/245/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/42300/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/42300/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 9063B1BEB0;\n\tThu,  5 Jul 2018 10:23:59 +0200 (CEST)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 1E02E1BEA6\n\tfor <dev@dpdk.org>; Thu,  5 Jul 2018 10:23:57 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Jul 2018 01:23:57 -0700",
            "from jeffguo-z170x-ud5.sh.intel.com (HELO localhost.localdomain)\n\t([10.67.104.10])\n\tby orsmga003.jf.intel.com with ESMTP; 05 Jul 2018 01:23:54 -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,311,1526367600\"; d=\"scan'208\";a=\"64577766\"",
        "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, bernard.iremonger@intel.com",
        "Cc": "jblunck@infradead.org, shreyansh.jain@nxp.com, dev@dpdk.org,\n\tjia.guo@intel.com, helin.zhang@intel.com",
        "Date": "Thu,  5 Jul 2018 16:21:43 +0800",
        "Message-Id": "<1530778903-31160-2-git-send-email-jia.guo@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1530778903-31160-1-git-send-email-jia.guo@intel.com>",
        "References": "<1498711073-42917-1-git-send-email-jia.guo@intel.com>\n\t<1530778903-31160-1-git-send-email-jia.guo@intel.com>",
        "Subject": "[dpdk-dev] [PATCH V5 7/7] igb_uio: fix uio release issue when hot\n\tunplug",
        "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 kernel will release the device resource in the\nkernel side, such as the fd sys file will disappear, and the irq will be\nreleased. At this time, if igb uio driver still try to release this\nresource, it will cause kernel crash. On the other hand, something like\ninterrupt disabling do not automatically process in kernel side. If not\nhandler it, this redundancy and dirty thing will affect the interrupt\nresource be used by other device. So the igb_uio driver have to check the\nhotplug status, and the corresponding process should be taken in igb uio\ndriver.\n\nThis patch propose to add structure of rte_udev_state into rte_uio_pci_dev\nof igb_uio kernel driver, which will record the state of uio device, such\nas probed/opened/released/removed/unplug. When detect the unexpected\nremoval which cause of hotplug out behavior, it will corresponding disable\ninterrupt resource, while for the part of releasement which kernel have\nalready handle, just skip it to avoid double free or null pointer kernel\ncrash issue.\n\nSigned-off-by: Jeff Guo <jia.guo@intel.com>\n---\nv5->v4:\nadd lock for udev state\n---\n kernel/linux/igb_uio/igb_uio.c | 51 +++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 48 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c\nindex 3398eac..adc8cea 100644\n--- a/kernel/linux/igb_uio/igb_uio.c\n+++ b/kernel/linux/igb_uio/igb_uio.c\n@@ -19,6 +19,15 @@\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+\tRTE_UDEV_UNPLUG\n+};\n+\n /**\n  * A structure describing the private information for a uio device.\n  */\n@@ -28,6 +37,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@@ -195,12 +205,22 @@ igbuio_pci_irqhandler(int irq, void *dev_id)\n {\n \tstruct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id;\n \tstruct uio_info *info = &udev->info;\n+\tstruct pci_dev *pdev = udev->pdev;\n \n \t/* Legacy mode need to mask in hardware */\n \tif (udev->mode == RTE_INTR_MODE_LEGACY &&\n \t    !pci_check_and_mask_intx(udev->pdev))\n \t\treturn IRQ_NONE;\n \n+\tmutex_lock(&udev->lock);\n+\t/* check the uevent of the kobj */\n+\tif ((&pdev->dev.kobj)->state_remove_uevent_sent == 1) {\n+\t\tdev_notice(&pdev->dev, \"device:%s, sent remove uevent!\\n\",\n+\t\t\t   (&pdev->dev.kobj)->name);\n+\t\tudev->state = RTE_UDEV_UNPLUG;\n+\t}\n+\tmutex_unlock(&udev->lock);\n+\n \tuio_event_notify(info);\n \n \t/* Message signal mode, no share IRQ and automasked */\n@@ -309,7 +329,6 @@ igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev)\n #endif\n }\n \n-\n /**\n  * This gets called while opening uio device file.\n  */\n@@ -331,20 +350,29 @@ 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\treturn 0;\n+\n \tmutex_lock(&udev->lock);\n \tif (--udev->refcnt > 0) {\n \t\tmutex_unlock(&udev->lock);\n@@ -356,7 +384,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@@ -562,6 +590,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 +610,20 @@ static void\n igbuio_pci_remove(struct pci_dev *dev)\n {\n \tstruct rte_uio_pci_dev *udev = pci_get_drvdata(dev);\n+\tint ret;\n+\n+\t/* handler hot unplug */\n+\tif (udev->state == RTE_UDEV_OPENNED ||\n+\t\tudev->state == RTE_UDEV_UNPLUG) {\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": [
        "V5",
        "7/7"
    ]
}