diff options
| author | Radion Mirchevsky <radion.mirchevsky@intel.com> | 2017-10-04 07:53:54 -0400 |
|---|---|---|
| committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2018-03-09 04:54:10 -0500 |
| commit | 484cb153fe5ffcd0b7cf423cf29aaeadd0e862b1 (patch) | |
| tree | a4b3edd4af00e2f615fc38966b7eaecc6c163f86 /drivers | |
| parent | 8e9267bb3559065fddecf344cb54501704fcb68e (diff) | |
thunderbolt: Add tb_xdomain_find_by_route()
This is needed by the new ICM interface to find xdomains by route string
instead of link and depth.
While there update existing tb_xdomain_find_* functions to use
tb_xdomain_get() instead of open-coding the same.
Signed-off-by: Radion Mirchevsky <radion.mirchevsky@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/thunderbolt/xdomain.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c index f25d88d4552b..8abb4e843085 100644 --- a/drivers/thunderbolt/xdomain.c +++ b/drivers/thunderbolt/xdomain.c | |||
| @@ -1255,6 +1255,7 @@ struct tb_xdomain_lookup { | |||
| 1255 | const uuid_t *uuid; | 1255 | const uuid_t *uuid; |
| 1256 | u8 link; | 1256 | u8 link; |
| 1257 | u8 depth; | 1257 | u8 depth; |
| 1258 | u64 route; | ||
| 1258 | }; | 1259 | }; |
| 1259 | 1260 | ||
| 1260 | static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw, | 1261 | static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw, |
| @@ -1275,9 +1276,13 @@ static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw, | |||
| 1275 | if (lookup->uuid) { | 1276 | if (lookup->uuid) { |
| 1276 | if (uuid_equal(xd->remote_uuid, lookup->uuid)) | 1277 | if (uuid_equal(xd->remote_uuid, lookup->uuid)) |
| 1277 | return xd; | 1278 | return xd; |
| 1278 | } else if (lookup->link == xd->link && | 1279 | } else if (lookup->link && |
| 1280 | lookup->link == xd->link && | ||
| 1279 | lookup->depth == xd->depth) { | 1281 | lookup->depth == xd->depth) { |
| 1280 | return xd; | 1282 | return xd; |
| 1283 | } else if (lookup->route && | ||
| 1284 | lookup->route == xd->route) { | ||
| 1285 | return xd; | ||
| 1281 | } | 1286 | } |
| 1282 | } else if (port->remote) { | 1287 | } else if (port->remote) { |
| 1283 | xd = switch_find_xdomain(port->remote->sw, lookup); | 1288 | xd = switch_find_xdomain(port->remote->sw, lookup); |
| @@ -1313,12 +1318,7 @@ struct tb_xdomain *tb_xdomain_find_by_uuid(struct tb *tb, const uuid_t *uuid) | |||
| 1313 | lookup.uuid = uuid; | 1318 | lookup.uuid = uuid; |
| 1314 | 1319 | ||
| 1315 | xd = switch_find_xdomain(tb->root_switch, &lookup); | 1320 | xd = switch_find_xdomain(tb->root_switch, &lookup); |
| 1316 | if (xd) { | 1321 | return tb_xdomain_get(xd); |
| 1317 | get_device(&xd->dev); | ||
| 1318 | return xd; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | return NULL; | ||
| 1322 | } | 1322 | } |
| 1323 | EXPORT_SYMBOL_GPL(tb_xdomain_find_by_uuid); | 1323 | EXPORT_SYMBOL_GPL(tb_xdomain_find_by_uuid); |
| 1324 | 1324 | ||
| @@ -1349,13 +1349,36 @@ struct tb_xdomain *tb_xdomain_find_by_link_depth(struct tb *tb, u8 link, | |||
| 1349 | lookup.depth = depth; | 1349 | lookup.depth = depth; |
| 1350 | 1350 | ||
| 1351 | xd = switch_find_xdomain(tb->root_switch, &lookup); | 1351 | xd = switch_find_xdomain(tb->root_switch, &lookup); |
| 1352 | if (xd) { | 1352 | return tb_xdomain_get(xd); |
| 1353 | get_device(&xd->dev); | 1353 | } |
| 1354 | return xd; | ||
| 1355 | } | ||
| 1356 | 1354 | ||
| 1357 | return NULL; | 1355 | /** |
| 1356 | * tb_xdomain_find_by_route() - Find an XDomain by route string | ||
| 1357 | * @tb: Domain where the XDomain belongs to | ||
| 1358 | * @route: XDomain route string | ||
| 1359 | * | ||
| 1360 | * Finds XDomain by walking through the Thunderbolt topology below @tb. | ||
| 1361 | * The returned XDomain will have its reference count increased so the | ||
| 1362 | * caller needs to call tb_xdomain_put() when it is done with the | ||
| 1363 | * object. | ||
| 1364 | * | ||
| 1365 | * This will find all XDomains including the ones that are not yet added | ||
| 1366 | * to the bus (handshake is still in progress). | ||
| 1367 | * | ||
| 1368 | * The caller needs to hold @tb->lock. | ||
| 1369 | */ | ||
| 1370 | struct tb_xdomain *tb_xdomain_find_by_route(struct tb *tb, u64 route) | ||
| 1371 | { | ||
| 1372 | struct tb_xdomain_lookup lookup; | ||
| 1373 | struct tb_xdomain *xd; | ||
| 1374 | |||
| 1375 | memset(&lookup, 0, sizeof(lookup)); | ||
| 1376 | lookup.route = route; | ||
| 1377 | |||
| 1378 | xd = switch_find_xdomain(tb->root_switch, &lookup); | ||
| 1379 | return tb_xdomain_get(xd); | ||
| 1358 | } | 1380 | } |
| 1381 | EXPORT_SYMBOL_GPL(tb_xdomain_find_by_route); | ||
| 1359 | 1382 | ||
| 1360 | bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type, | 1383 | bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type, |
| 1361 | const void *buf, size_t size) | 1384 | const void *buf, size_t size) |
