aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c130
1 files changed, 0 insertions, 130 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c85db123ba0..0c77c4fcf43 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -36,7 +36,6 @@
36#include <linux/remoteproc.h> 36#include <linux/remoteproc.h>
37#include <linux/iommu.h> 37#include <linux/iommu.h>
38#include <linux/idr.h> 38#include <linux/idr.h>
39#include <linux/klist.h>
40#include <linux/elf.h> 39#include <linux/elf.h>
41#include <linux/virtio_ids.h> 40#include <linux/virtio_ids.h>
42#include <linux/virtio_ring.h> 41#include <linux/virtio_ring.h>
@@ -44,25 +43,6 @@
44 43
45#include "remoteproc_internal.h" 44#include "remoteproc_internal.h"
46 45
47static void klist_rproc_get(struct klist_node *n);
48static void klist_rproc_put(struct klist_node *n);
49
50/*
51 * klist of the available remote processors.
52 *
53 * We need this in order to support name-based lookups (needed by the
54 * rproc_get_by_name()).
55 *
56 * That said, we don't use rproc_get_by_name() at this point.
57 * The use cases that do require its existence should be
58 * scrutinized, and hopefully migrated to rproc_boot() using device-based
59 * binding.
60 *
61 * If/when this materializes, we could drop the klist (and the by_name
62 * API).
63 */
64static DEFINE_KLIST(rprocs, klist_rproc_get, klist_rproc_put);
65
66typedef int (*rproc_handle_resources_t)(struct rproc *rproc, 46typedef int (*rproc_handle_resources_t)(struct rproc *rproc,
67 struct resource_table *table, int len); 47 struct resource_table *table, int len);
68typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int avail); 48typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int avail);
@@ -1217,10 +1197,6 @@ EXPORT_SYMBOL(rproc_boot);
1217 * which means that the @rproc handle stays valid even after rproc_shutdown() 1197 * which means that the @rproc handle stays valid even after rproc_shutdown()
1218 * returns, and users can still use it with a subsequent rproc_boot(), if 1198 * returns, and users can still use it with a subsequent rproc_boot(), if
1219 * needed. 1199 * needed.
1220 * - don't call rproc_shutdown() to unroll rproc_get_by_name(), exactly
1221 * because rproc_shutdown() _does not_ decrement the refcount of @rproc.
1222 * To decrement the refcount of @rproc, use rproc_put() (but _only_ if
1223 * you acquired @rproc using rproc_get_by_name()).
1224 */ 1200 */
1225void rproc_shutdown(struct rproc *rproc) 1201void rproc_shutdown(struct rproc *rproc)
1226{ 1202{
@@ -1261,105 +1237,6 @@ out:
1261} 1237}
1262EXPORT_SYMBOL(rproc_shutdown); 1238EXPORT_SYMBOL(rproc_shutdown);
1263 1239
1264/* will be called when an rproc is added to the rprocs klist */
1265static void klist_rproc_get(struct klist_node *n)
1266{
1267 struct rproc *rproc = container_of(n, struct rproc, node);
1268
1269 get_device(&rproc->dev);
1270}
1271
1272/* will be called when an rproc is removed from the rprocs klist */
1273static void klist_rproc_put(struct klist_node *n)
1274{
1275 struct rproc *rproc = container_of(n, struct rproc, node);
1276
1277 put_device(&rproc->dev);
1278}
1279
1280static struct rproc *next_rproc(struct klist_iter *i)
1281{
1282 struct klist_node *n;
1283
1284 n = klist_next(i);
1285 if (!n)
1286 return NULL;
1287
1288 return container_of(n, struct rproc, node);
1289}
1290
1291/**
1292 * rproc_get_by_name() - find a remote processor by name and boot it
1293 * @name: name of the remote processor
1294 *
1295 * Finds an rproc handle using the remote processor's name, and then
1296 * boot it. If it's already powered on, then just immediately return
1297 * (successfully).
1298 *
1299 * Returns the rproc handle on success, and NULL on failure.
1300 *
1301 * This function increments the remote processor's refcount, so always
1302 * use rproc_put() to decrement it back once rproc isn't needed anymore.
1303 *
1304 * Note: currently this function (and its counterpart rproc_put()) are not
1305 * being used. We need to scrutinize the use cases
1306 * that still need them, and see if we can migrate them to use the non
1307 * name-based boot/shutdown interface.
1308 */
1309struct rproc *rproc_get_by_name(const char *name)
1310{
1311 struct rproc *rproc;
1312 struct klist_iter i;
1313 int ret;
1314
1315 /* find the remote processor, and upref its refcount */
1316 klist_iter_init(&rprocs, &i);
1317 while ((rproc = next_rproc(&i)) != NULL)
1318 if (!strcmp(rproc->name, name)) {
1319 get_device(&rproc->dev);
1320 break;
1321 }
1322 klist_iter_exit(&i);
1323
1324 /* can't find this rproc ? */
1325 if (!rproc) {
1326 pr_err("can't find remote processor %s\n", name);
1327 return NULL;
1328 }
1329
1330 ret = rproc_boot(rproc);
1331 if (ret < 0) {
1332 put_device(&rproc->dev);
1333 return NULL;
1334 }
1335
1336 return rproc;
1337}
1338EXPORT_SYMBOL(rproc_get_by_name);
1339
1340/**
1341 * rproc_put() - decrement the refcount of a remote processor, and shut it down
1342 * @rproc: the remote processor
1343 *
1344 * This function tries to shutdown @rproc, and it then decrements its
1345 * refcount.
1346 *
1347 * After this function returns, @rproc may _not_ be used anymore, and its
1348 * handle should be considered invalid.
1349 *
1350 * This function should be called _iff_ the @rproc handle was grabbed by
1351 * calling rproc_get_by_name().
1352 */
1353void rproc_put(struct rproc *rproc)
1354{
1355 /* try to power off the remote processor */
1356 rproc_shutdown(rproc);
1357
1358 /* downref rproc's refcount */
1359 put_device(&rproc->dev);
1360}
1361EXPORT_SYMBOL(rproc_put);
1362
1363/** 1240/**
1364 * rproc_register() - register a remote processor 1241 * rproc_register() - register a remote processor
1365 * @rproc: the remote processor handle to register 1242 * @rproc: the remote processor handle to register
@@ -1389,9 +1266,6 @@ int rproc_register(struct rproc *rproc)
1389 if (ret < 0) 1266 if (ret < 0)
1390 return ret; 1267 return ret;
1391 1268
1392 /* expose to rproc_get_by_name users */
1393 klist_add_tail(&rproc->node, &rprocs);
1394
1395 dev_info(dev, "%s is available\n", rproc->name); 1269 dev_info(dev, "%s is available\n", rproc->name);
1396 1270
1397 dev_info(dev, "Note: remoteproc is still under development and considered experimental.\n"); 1271 dev_info(dev, "Note: remoteproc is still under development and considered experimental.\n");
@@ -1417,7 +1291,6 @@ int rproc_register(struct rproc *rproc)
1417 if (ret < 0) { 1291 if (ret < 0) {
1418 dev_err(dev, "request_firmware_nowait failed: %d\n", ret); 1292 dev_err(dev, "request_firmware_nowait failed: %d\n", ret);
1419 complete_all(&rproc->firmware_loading_complete); 1293 complete_all(&rproc->firmware_loading_complete);
1420 klist_remove(&rproc->node);
1421 } 1294 }
1422 1295
1423 return ret; 1296 return ret;
@@ -1573,9 +1446,6 @@ int rproc_unregister(struct rproc *rproc)
1573 list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node) 1446 list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node)
1574 rproc_remove_virtio_dev(rvdev); 1447 rproc_remove_virtio_dev(rvdev);
1575 1448
1576 /* the rproc is downref'ed as soon as it's removed from the klist */
1577 klist_del(&rproc->node);
1578
1579 device_del(&rproc->dev); 1449 device_del(&rproc->dev);
1580 1450
1581 return 0; 1451 return 0;