aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/remoteproc.txt27
-rw-r--r--drivers/remoteproc/remoteproc_core.c130
-rw-r--r--include/linux/remoteproc.h3
3 files changed, 1 insertions, 159 deletions
diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt
index ad6ded4bca5..f33c3bbbc86 100644
--- a/Documentation/remoteproc.txt
+++ b/Documentation/remoteproc.txt
@@ -36,8 +36,7 @@ cost.
36 Note: to use this function you should already have a valid rproc 36 Note: to use this function you should already have a valid rproc
37 handle. There are several ways to achieve that cleanly (devres, pdata, 37 handle. There are several ways to achieve that cleanly (devres, pdata,
38 the way remoteproc_rpmsg.c does this, or, if this becomes prevalent, we 38 the way remoteproc_rpmsg.c does this, or, if this becomes prevalent, we
39 might also consider using dev_archdata for this). See also 39 might also consider using dev_archdata for this).
40 rproc_get_by_name() below.
41 40
42 void rproc_shutdown(struct rproc *rproc) 41 void rproc_shutdown(struct rproc *rproc)
43 - Power off a remote processor (previously booted with rproc_boot()). 42 - Power off a remote processor (previously booted with rproc_boot()).
@@ -51,30 +50,6 @@ cost.
51 which means that the @rproc handle stays valid even after 50 which means that the @rproc handle stays valid even after
52 rproc_shutdown() returns, and users can still use it with a subsequent 51 rproc_shutdown() returns, and users can still use it with a subsequent
53 rproc_boot(), if needed. 52 rproc_boot(), if needed.
54 - don't call rproc_shutdown() to unroll rproc_get_by_name(), exactly
55 because rproc_shutdown() _does not_ decrement the refcount of @rproc.
56 To decrement the refcount of @rproc, use rproc_put() (but _only_ if
57 you acquired @rproc using rproc_get_by_name()).
58
59 struct rproc *rproc_get_by_name(const char *name)
60 - Find an rproc handle using the remote processor's name, and then
61 boot it. If it's already powered on, then just immediately return
62 (successfully). Returns the rproc handle on success, and NULL on failure.
63 This function increments the remote processor's refcount, so always
64 use rproc_put() to decrement it back once rproc isn't needed anymore.
65 Note: currently rproc_get_by_name() and rproc_put() are not used anymore
66 by the rpmsg bus and its drivers. We need to scrutinize the use cases
67 that still need them, and see if we can migrate them to use the non
68 name-based boot/shutdown interface.
69
70 void rproc_put(struct rproc *rproc)
71 - Decrement @rproc's power refcount and shut it down if it reaches zero
72 (essentially by just calling rproc_shutdown), and then decrement @rproc's
73 validity refcount too.
74 After this function returns, @rproc may _not_ be used anymore, and its
75 handle should be considered invalid.
76 This function should be called _iff_ the @rproc handle was grabbed by
77 calling rproc_get_by_name().
78 53
793. Typical usage 543. Typical usage
80 55
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;
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index cbe8a51a21d..b88d6af5ba5 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -449,9 +449,6 @@ struct rproc_vdev {
449 unsigned long gfeatures; 449 unsigned long gfeatures;
450}; 450};
451 451
452struct rproc *rproc_get_by_name(const char *name);
453void rproc_put(struct rproc *rproc);
454
455struct rproc *rproc_alloc(struct device *dev, const char *name, 452struct rproc *rproc_alloc(struct device *dev, const char *name,
456 const struct rproc_ops *ops, 453 const struct rproc_ops *ops,
457 const char *firmware, int len); 454 const char *firmware, int len);