get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 112310,
    "url": "http://patches.dpdk.org/api/patches/112310/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220603143601.230519-1-kevin.laatz@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": "<20220603143601.230519-1-kevin.laatz@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220603143601.230519-1-kevin.laatz@intel.com",
    "date": "2022-06-03T14:36:01",
    "name": "[v7] eal: add bus cleanup to eal cleanup",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1c6c5e1da1261dac16b49f972ee053663ae697a1",
    "submitter": {
        "id": 921,
        "url": "http://patches.dpdk.org/api/people/921/?format=api",
        "name": "Kevin Laatz",
        "email": "kevin.laatz@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220603143601.230519-1-kevin.laatz@intel.com/mbox/",
    "series": [
        {
            "id": 23321,
            "url": "http://patches.dpdk.org/api/series/23321/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=23321",
            "date": "2022-06-03T14:36:01",
            "name": "[v7] eal: add bus cleanup to eal cleanup",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/23321/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/112310/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/112310/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 36A84A055B;\n\tFri,  3 Jun 2022 16:34:09 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1CFF140694;\n\tFri,  3 Jun 2022 16:34:08 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by mails.dpdk.org (Postfix) with ESMTP id 11BE14021E\n for <dev@dpdk.org>; Fri,  3 Jun 2022 16:34:06 +0200 (CEST)",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 03 Jun 2022 07:34:05 -0700",
            "from silpixa00401122.ir.intel.com ([10.237.213.29])\n by orsmga006.jf.intel.com with ESMTP; 03 Jun 2022 07:34:04 -0700"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1654266847; x=1685802847;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=zEPYnyKib0pki7emptVYdrKxiZmEF92Khs+KSjPUXNs=;\n b=FPgNf7YiPs0v/5/8UwTxX6rhLbjlAYP1D9jt/TO2rWSdENrNxKc11siE\n bvdD3bRPolM1pNVBYRQ8o6M2NL7eK1364h+6p8iCFkzezVG0HSV5qQAvj\n HniuOJE2OOt4Gs4bvjSPAnsgP+klzu+eB+jjZ50qBj6LcG5KR+w3UpT8c\n CaNEXkSio91ZyYoqpSVWlgxZN7fE6qu1IGWzCJDQ7IcAsyHatFBReBqJl\n uI5rhTraQU7ijnRC82IDXE7AjYBjRmkoxYdYVxtPvfa0DHcSyvWZLVxH1\n N1sufpg71cs/iGH0p69dK4YJpIj0c5JqKqxvFNuDy1ctk3Mbp814HVRVJ Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6400,9594,10366\"; a=\"362631161\"",
            "E=Sophos;i=\"5.91,274,1647327600\"; d=\"scan'208\";a=\"362631161\"",
            "E=Sophos;i=\"5.91,274,1647327600\"; d=\"scan'208\";a=\"553349761\""
        ],
        "X-ExtLoop1": "1",
        "From": "Kevin Laatz <kevin.laatz@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Kevin Laatz <kevin.laatz@intel.com>,\n =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[PATCH v7] eal: add bus cleanup to eal cleanup",
        "Date": "Fri,  3 Jun 2022 15:36:01 +0100",
        "Message-Id": "<20220603143601.230519-1-kevin.laatz@intel.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20220419161438.1837860-1-kevin.laatz@intel.com>",
        "References": "<20220419161438.1837860-1-kevin.laatz@intel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "During EAL init, all buses are probed and the devices found are\ninitialized. On eal_cleanup(), the inverse does not happen, meaning any\nallocated memory and other configuration will not be cleaned up\nappropriately on exit.\n\nCurrently, in order for device cleanup to take place, applications must\ncall the driver-relevant functions to ensure proper cleanup is done before\nthe application exits. Since initialization occurs for all devices on the\nbus, not just the devices used by an application, it requires a)\napplication awareness of all bus devices that could have been probed on the\nsystem, and b) code duplication across applications to ensure cleanup is\nperformed. An example of this is rte_eth_dev_close() which is commonly used\nacross the example applications.\n\nThis patch proposes adding bus cleanup to the eal_cleanup() to make EAL's\ninit/exit more symmetrical, ensuring all bus devices are cleaned up\nappropriately without the application needing to be aware of all bus types\nthat may have been probed during initialization.\n\nContained in this patch are the changes required to perform cleanup for\ndevices on the PCI bus and VDEV bus during eal_cleanup(). There would be an\nask for bus maintainers to add the relevant cleanup for their buses since\nthey have the domain expertise.\n\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\nReviewed-by: Bruce Richardson <bruce.richardson@intel.com>\n\n---\nv7:\n* free rte_pci_device structs during cleanup\n* free rte_vdev_device structs during cleanup\n\nv6:\n* fix units in doc API descriptions\n\nv5:\n* add doc updates for new APIs\n\nv4:\n* fix return value when scaling_freq_max is not set\n* fix mismatching comments\n\nv3:\n* move setters from arg parse function to init\n* consider 0 as 'not set' for scaling_freq_max\n* other minor fixes\n\nv2:\n* add doc update for l3fwd-power\n* order version.map additions alphabetically\n---\n devtools/libabigail.abignore    |  9 +++++++++\n drivers/bus/pci/pci_common.c    | 26 ++++++++++++++++++++++++++\n drivers/bus/vdev/vdev.c         | 26 ++++++++++++++++++++++++++\n lib/eal/common/eal_common_bus.c | 17 +++++++++++++++++\n lib/eal/common/eal_private.h    | 10 ++++++++++\n lib/eal/freebsd/eal.c           |  1 +\n lib/eal/include/rte_bus.h       | 13 +++++++++++++\n lib/eal/linux/eal.c             |  1 +\n lib/eal/windows/eal.c           |  1 +\n 9 files changed, 104 insertions(+)",
    "diff": "diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore\nindex 79ff15dc4e..3e519ee42a 100644\n--- a/devtools/libabigail.abignore\n+++ b/devtools/libabigail.abignore\n@@ -56,3 +56,12 @@\n ; Ignore libabigail false-positive in clang builds, after moving code.\n [suppress_function]\n \tname = rte_eal_remote_launch\n+\n+; Ignore field inserted to rte_bus, adding cleanup function\n+[suppress_type]\n+        name = rte_bus\n+        has_data_member_inserted_at = end\n+\n+; Ignore changes to internally used structs containing rte_bus\n+[suppress_type]\n+        name = rte_pci_bus, rte_vmbus_bus, rte_vdev_bus\ndiff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c\nindex 37ab879779..75b312eef1 100644\n--- a/drivers/bus/pci/pci_common.c\n+++ b/drivers/bus/pci/pci_common.c\n@@ -25,6 +25,7 @@\n #include <rte_common.h>\n #include <rte_devargs.h>\n #include <rte_vfio.h>\n+#include <rte_tailq.h>\n \n #include \"private.h\"\n \n@@ -394,6 +395,30 @@ pci_probe(void)\n \treturn (probed && probed == failed) ? -1 : 0;\n }\n \n+static int\n+pci_cleanup(void)\n+{\n+\tstruct rte_pci_device *dev, *tmp_dev;\n+\tint error = 0;\n+\n+\tRTE_TAILQ_FOREACH_SAFE(dev, &rte_pci_bus.device_list, next, tmp_dev) {\n+\t\tstruct rte_pci_driver *drv = dev->driver;\n+\t\tint ret = 0;\n+\n+\t\tif (drv == NULL || drv->remove == NULL)\n+\t\t\tcontinue;\n+\n+\t\tret = drv->remove(dev);\n+\t\tif (ret < 0) {\n+\t\t\trte_errno = errno;\n+\t\t\terror = -1;\n+\t\t}\n+\t\tfree(dev);\n+\t}\n+\n+\treturn error;\n+}\n+\n /* dump one device */\n static int\n pci_dump_one_device(FILE *f, struct rte_pci_device *dev)\n@@ -813,6 +838,7 @@ struct rte_pci_bus rte_pci_bus = {\n \t.bus = {\n \t\t.scan = rte_pci_scan,\n \t\t.probe = pci_probe,\n+\t\t.cleanup = pci_cleanup,\n \t\t.find_device = pci_find_device,\n \t\t.plug = pci_plug,\n \t\t.unplug = pci_unplug,\ndiff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c\nindex a8d8b2327e..707ea1bbb5 100644\n--- a/drivers/bus/vdev/vdev.c\n+++ b/drivers/bus/vdev/vdev.c\n@@ -569,6 +569,31 @@ vdev_probe(void)\n \treturn ret;\n }\n \n+static int\n+vdev_cleanup(void)\n+{\n+\tstruct rte_vdev_device *dev, *tmp_dev;\n+\tint error = 0;\n+\n+\tRTE_TAILQ_FOREACH_SAFE(dev, &vdev_device_list, next, tmp_dev) {\n+\t\tconst struct rte_vdev_driver *drv;\n+\t\tint ret = 0;\n+\n+\t\tdrv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);\n+\n+\t\tif (drv == NULL || drv->remove == NULL)\n+\t\t\tcontinue;\n+\n+\t\tret = drv->remove(dev);\n+\t\tif (ret < 0)\n+\t\t\terror = -1;\n+\n+\t\tfree(dev);\n+\t}\n+\n+\treturn error;\n+}\n+\n struct rte_device *\n rte_vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,\n \t\t     const void *data)\n@@ -627,6 +652,7 @@ vdev_get_iommu_class(void)\n static struct rte_bus rte_vdev_bus = {\n \t.scan = vdev_scan,\n \t.probe = vdev_probe,\n+\t.cleanup = vdev_cleanup,\n \t.find_device = rte_vdev_find_device,\n \t.plug = vdev_plug,\n \t.unplug = vdev_unplug,\ndiff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c\nindex baa5b532af..3fe67af0ba 100644\n--- a/lib/eal/common/eal_common_bus.c\n+++ b/lib/eal/common/eal_common_bus.c\n@@ -85,6 +85,23 @@ rte_bus_probe(void)\n \treturn 0;\n }\n \n+/* Clean up all devices of all buses */\n+int\n+eal_bus_cleanup(void)\n+{\n+\tint ret = 0;\n+\tstruct rte_bus *bus;\n+\n+\tTAILQ_FOREACH(bus, &rte_bus_list, next) {\n+\t\tif (bus->cleanup == NULL)\n+\t\t\tcontinue;\n+\t\tif (bus->cleanup() != 0)\n+\t\t\tret = -1;\n+\t}\n+\n+\treturn ret;\n+}\n+\n /* Dump information of a single bus */\n static int\n bus_dump_one(FILE *f, struct rte_bus *bus)\ndiff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h\nindex 44d14241f0..eea4749af4 100644\n--- a/lib/eal/common/eal_private.h\n+++ b/lib/eal/common/eal_private.h\n@@ -441,6 +441,16 @@ int rte_eal_memory_detach(void);\n  */\n struct rte_bus *rte_bus_find_by_device_name(const char *str);\n \n+/**\n+ * For each device on the buses, call the driver-specific function for\n+ * device cleanup.\n+ *\n+ * @return\n+ * 0 for successful cleanup\n+ * !0 otherwise\n+ */\n+int eal_bus_cleanup(void);\n+\n /**\n  * Create the unix channel for primary/secondary communication.\n  *\ndiff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c\nindex a6b20960f2..97ed2c4678 100644\n--- a/lib/eal/freebsd/eal.c\n+++ b/lib/eal/freebsd/eal.c\n@@ -893,6 +893,7 @@ rte_eal_cleanup(void)\n \t\teal_get_internal_configuration();\n \trte_service_finalize();\n \trte_mp_channel_cleanup();\n+\teal_bus_cleanup();\n \t/* after this point, any DPDK pointers will become dangling */\n \trte_eal_memory_detach();\n \trte_eal_alarm_cleanup();\ndiff --git a/lib/eal/include/rte_bus.h b/lib/eal/include/rte_bus.h\nindex bbbb6efd28..9908a013f6 100644\n--- a/lib/eal/include/rte_bus.h\n+++ b/lib/eal/include/rte_bus.h\n@@ -66,6 +66,18 @@ typedef int (*rte_bus_scan_t)(void);\n  */\n typedef int (*rte_bus_probe_t)(void);\n \n+/**\n+ * Implementation specific cleanup function which is responsible for cleaning up\n+ * devices on that bus with applicable drivers.\n+ *\n+ * This is called while iterating over each registered bus.\n+ *\n+ * @return\n+ * 0 for successful cleanup\n+ * !0 for any error during cleanup\n+ */\n+typedef int (*rte_bus_cleanup_t)(void);\n+\n /**\n  * Device iterator to find a device on a bus.\n  *\n@@ -277,6 +289,7 @@ struct rte_bus {\n \t\t\t\t/**< handle hot-unplug failure on the bus */\n \trte_bus_sigbus_handler_t sigbus_handler;\n \t\t\t\t\t/**< handle sigbus error on the bus */\n+\trte_bus_cleanup_t cleanup;   /**< Cleanup devices on bus */\n \n };\n \ndiff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c\nindex 1ef263434a..9b32265ef5 100644\n--- a/lib/eal/linux/eal.c\n+++ b/lib/eal/linux/eal.c\n@@ -1266,6 +1266,7 @@ rte_eal_cleanup(void)\n \tvfio_mp_sync_cleanup();\n #endif\n \trte_mp_channel_cleanup();\n+\teal_bus_cleanup();\n \t/* after this point, any DPDK pointers will become dangling */\n \trte_eal_memory_detach();\n \teal_mp_dev_hotplug_cleanup();\ndiff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c\nindex 122de2a319..fedd6c971a 100644\n--- a/lib/eal/windows/eal.c\n+++ b/lib/eal/windows/eal.c\n@@ -262,6 +262,7 @@ rte_eal_cleanup(void)\n \n \teal_intr_thread_cancel();\n \teal_mem_virt2iova_cleanup();\n+\teal_bus_cleanup();\n \t/* after this point, any DPDK pointers will become dangling */\n \trte_eal_memory_detach();\n \teal_cleanup_config(internal_conf);\n",
    "prefixes": [
        "v7"
    ]
}