From a4f0fa29488e582ab8b5ef9db475b3d26ded690c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 27 Nov 2018 10:44:39 +0000 Subject: New upstream version 18.11 Change-Id: I6c63198045de1e34fda8a7b4665d89d5f4a20d20 Signed-off-by: Luca Boccassi --- lib/librte_eal/common/hotplug_mp.c | 43 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'lib/librte_eal/common/hotplug_mp.c') diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 7c9fcc46..070e2e0c 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -87,7 +87,7 @@ __handle_secondary_request(void *param) const struct eal_dev_mp_req *req = (const struct eal_dev_mp_req *)msg->param; struct eal_dev_mp_req tmp_req; - struct rte_devargs *da; + struct rte_devargs da; struct rte_device *dev; struct rte_bus *bus; int ret = 0; @@ -114,15 +114,11 @@ __handle_secondary_request(void *param) goto rollback; } } else if (req->t == EAL_DEV_REQ_TYPE_DETACH) { - da = calloc(1, sizeof(*da)); - if (da == NULL) { - ret = -ENOMEM; - goto finish; - } - - ret = rte_devargs_parse(da, req->devargs); + ret = rte_devargs_parse(&da, req->devargs); if (ret != 0) goto finish; + free(da.args); /* we don't need those */ + da.args = NULL; ret = eal_dev_hotplug_request_to_secondary(&tmp_req); if (ret != 0) { @@ -131,16 +127,16 @@ __handle_secondary_request(void *param) goto rollback; } - bus = rte_bus_find_by_name(da->bus->name); + bus = rte_bus_find_by_name(da.bus->name); if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da->bus->name); + RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da.bus->name); ret = -ENOENT; goto finish; } - dev = bus->find_device(NULL, cmp_dev_name, da->name); + dev = bus->find_device(NULL, cmp_dev_name, da.name); if (dev == NULL) { - RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da->name); + RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da.name); ret = -ENOENT; goto finish; } @@ -264,6 +260,19 @@ static void __handle_primary_request(void *param) goto quit; } + if (!rte_dev_is_probed(dev)) { + if (req->t == EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK) { + /** + * Don't fail the rollback just because there's + * nothing to do. + */ + ret = 0; + } else + ret = -ENODEV; + + goto quit; + } + ret = local_dev_remove(dev); quit: free(da->args); @@ -391,13 +400,13 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) struct eal_dev_mp_req *resp = (struct eal_dev_mp_req *)mp_reply.msgs[i].param; if (resp->result != 0) { - req->result = resp->result; if (req->t == EAL_DEV_REQ_TYPE_ATTACH && - req->result != -EEXIST) - break; + resp->result == -EEXIST) + continue; if (req->t == EAL_DEV_REQ_TYPE_DETACH && - req->result != -ENOENT) - break; + resp->result == -ENOENT) + continue; + req->result = resp->result; } } -- cgit 1.2.3-korg