X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Fhotplug_mp.c;h=070e2e0c2796f3bebc9fb91b5395f44ec3966914;hb=29bf7e93baa3d53e1773f2cfdade8706da2bde51;hp=7c9fcc46c2544a40b85ad22212b9387c55846979;hpb=95781f4c64419a126b864f76dd1f00f9c01e0f43;p=dpdk.git diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 7c9fcc46c2..070e2e0c27 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; } }