Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions
remoteproc_core.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/dma-mapping.h>
#include <linux/firmware.h>
#include <linux/string.h>
#include <linux/debugfs.h>
#include <linux/remoteproc.h>
#include <linux/iommu.h>
#include <linux/idr.h>
#include <linux/elf.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_ring.h>
#include <asm/byteorder.h>
#include "remoteproc_internal.h"

Go to the source code of this file.

Macros

#define pr_fmt(fmt)   "%s: " fmt, __func__
 

Typedefs

typedef int(* rproc_handle_resources_t )(struct rproc *rproc, struct resource_table *table, int len)
 
typedef int(* rproc_handle_resource_t )(struct rproc *rproc, void *, int avail)
 

Functions

voidrproc_da_to_va (struct rproc *rproc, u64 da, int len)
 
 EXPORT_SYMBOL (rproc_da_to_va)
 
int rproc_alloc_vring (struct rproc_vdev *rvdev, int i)
 
void rproc_free_vring (struct rproc_vring *rvring)
 
int rproc_trigger_recovery (struct rproc *rproc)
 
int rproc_boot (struct rproc *rproc)
 
 EXPORT_SYMBOL (rproc_boot)
 
void rproc_shutdown (struct rproc *rproc)
 
 EXPORT_SYMBOL (rproc_shutdown)
 
int rproc_add (struct rproc *rproc)
 
 EXPORT_SYMBOL (rproc_add)
 
: name of this remote processor

rproc_alloc() - allocate a remote processor handle : the underlying device

: platform-specific handlers (mainly start/stop) : name of firmware file to load : length of private data needed by the rproc driver (in bytes)

Allocates a new remote processor handle, but does not register it yet.

This function should be used by rproc implementations during initialization of the remote processor.

After creating an rproc handle using this function, and when ready, implementations should then call rproc_add() to complete the registration of the remote processor.

On success the new rproc is returned, and on failure, NULL.

Note: never directly deallocate , even if it was not registered yet. Instead, when you need to unroll rproc_alloc(), use rproc_put().

struct rprocrproc_alloc (struct device *dev, const char *name, const struct rproc_ops *ops, const char *firmware, int len)
 
 EXPORT_SYMBOL (rproc_alloc)
 
void rproc_put (struct rproc *rproc)
 
 EXPORT_SYMBOL (rproc_put)
 
int rproc_del (struct rproc *rproc)
 
 EXPORT_SYMBOL (rproc_del)
 
void rproc_report_crash (struct rproc *rproc, enum rproc_crash_type type)
 
 EXPORT_SYMBOL (rproc_report_crash)
 
 module_init (remoteproc_init)
 
 module_exit (remoteproc_exit)
 
 MODULE_LICENSE ("GPL v2")
 
 MODULE_DESCRIPTION ("Generic Remote Processor Framework")
 

Macro Definition Documentation

#define pr_fmt (   fmt)    "%s: " fmt, __func__

Definition at line 25 of file remoteproc_core.c.

Typedef Documentation

typedef int(* rproc_handle_resource_t)(struct rproc *rproc, void *, int avail)

Definition at line 48 of file remoteproc_core.c.

typedef int(* rproc_handle_resources_t)(struct rproc *rproc, struct resource_table *table, int len)

Definition at line 46 of file remoteproc_core.c.

Function Documentation

EXPORT_SYMBOL ( rproc_da_to_va  )
EXPORT_SYMBOL ( rproc_boot  )
EXPORT_SYMBOL ( rproc_shutdown  )
EXPORT_SYMBOL ( rproc_add  )
EXPORT_SYMBOL ( rproc_alloc  )
EXPORT_SYMBOL ( rproc_put  )
EXPORT_SYMBOL ( rproc_del  )
EXPORT_SYMBOL ( rproc_report_crash  )
MODULE_DESCRIPTION ( "Generic Remote Processor Framework"  )
module_exit ( remoteproc_exit  )
module_init ( remoteproc_init  )
MODULE_LICENSE ( "GPL v2 )
int rproc_add ( struct rproc rproc)

rproc_add() - register a remote processor : the remote processor handle to register

Registers with the remoteproc framework, after it has been allocated with rproc_alloc().

This is called by the platform-specific rproc implementation, whenever a new remote processor device is probed.

Returns 0 on success and an appropriate error code otherwise.

Note: this function initiates an asynchronous firmware loading context, which will look for virtio devices supported by the rproc's firmware.

If found, those virtio devices will be created and added, so as a result of registering this remote processor, additional virtio drivers might be probed.

Definition at line 1145 of file remoteproc_core.c.

struct rproc* rproc_alloc ( struct device dev,
const char name,
const struct rproc_ops ops,
const char firmware,
int  len 
)
read

Definition at line 1220 of file remoteproc_core.c.

int rproc_alloc_vring ( struct rproc_vdev rvdev,
int  i 
)

Definition at line 190 of file remoteproc_core.c.

int rproc_boot ( struct rproc rproc)

rproc_boot() - boot a remote processor : handle of a remote processor

Boot a remote processor (i.e. load its firmware, power it on, ...).

If the remote processor is already powered on, this function immediately returns (successfully).

Returns 0 on success, and an appropriate error value otherwise.

Definition at line 1000 of file remoteproc_core.c.

void* rproc_da_to_va ( struct rproc rproc,
u64  da,
int  len 
)

Definition at line 165 of file remoteproc_core.c.

int rproc_del ( struct rproc rproc)

rproc_del() - unregister a remote processor : rproc handle to unregister

This function should be called when the platform specific rproc implementation decides to remove the rproc device. it should only be called if a previous invocation of rproc_add() has completed successfully.

After rproc_del() returns, isn't freed yet, because of the outstanding reference created by rproc_alloc. To decrement that one last refcount, one still needs to call rproc_put().

Returns 0 on success and -EINVAL if isn't valid.

Definition at line 1307 of file remoteproc_core.c.

void rproc_free_vring ( struct rproc_vring rvring)

Definition at line 282 of file remoteproc_core.c.

void rproc_put ( struct rproc rproc)

rproc_put() - unroll rproc_alloc() : the remote processor handle

This function decrements the rproc dev refcount.

If no one holds any reference to rproc anymore, then its refcount would now drop to zero, and it would be freed.

Definition at line 1286 of file remoteproc_core.c.

void rproc_report_crash ( struct rproc rproc,
enum rproc_crash_type  type 
)

rproc_report_crash() - rproc crash reporter function : remote processor : crash type

This function must be called every time a crash is detected by the low-level drivers implementing a specific remoteproc. This should not be called from a non-remoteproc driver.

This function can be called from atomic/interrupt context.

Definition at line 1338 of file remoteproc_core.c.

void rproc_shutdown ( struct rproc rproc)

rproc_shutdown() - power off the remote processor : the remote processor

Power off a remote processor (previously booted with rproc_boot()).

In case is still being used by an additional user(s), then this function will just decrement the power refcount and exit, without really powering off the device.

Every call to rproc_boot() must (eventually) be accompanied by a call to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.

Notes:

  • we're not decrementing the rproc's refcount, only the power refcount. which means that the handle stays valid even after rproc_shutdown() returns, and users can still use it with a subsequent rproc_boot(), if needed.

Definition at line 1082 of file remoteproc_core.c.

int rproc_trigger_recovery ( struct rproc rproc)

rproc_trigger_recovery() - recover a remoteproc : the remote processor

The recovery is done by reseting all the virtio devices, that way all the rpmsg drivers will be reseted along with the remote processor making the remoteproc functional again.

This function can sleep, so it cannot be called from atomic context.

Definition at line 940 of file remoteproc_core.c.