aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-03-07 18:21:12 -0500
committerOlof Johansson <olof@lixom.net>2012-03-07 18:21:12 -0500
commit6458acb5a31926dcc1295410221493544d628cf7 (patch)
tree15b5a855f73d52f95aeed2ab11e2e8028d82b746 /Documentation
parentab646a24bb9b6125f3c23ef908b7c5b44b1b4e69 (diff)
parent1e3e2c7c46b2e6e90f3a26ba9be6326c00ca31e4 (diff)
Merge tag 'rpmsg-fixes-and-more-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/remoteproc into next/rpmsg
Fixing and cleaning up several remoteproc and rpmsg issues. In addition, remoteproc's resource table is converted to a collection of type-value members, instead of a rigid array of homogeneous structs. This enables remoteproc to support registration of generic virtio devices, and not only a single VIRTIO_ID_RPMSG virtio device. But perhaps more importantly, the resource table overhaul makes it possible to easily extend it in the future without breaking older images (simply by defining a new member type, while continuing to support older types). * tag 'rpmsg-fixes-and-more-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad/remoteproc: remoteproc: cleanup resource table parsing paths remoteproc: remove the hardcoded vring alignment remoteproc/omap: remove the mbox_callback limitation remoteproc: remove the single rpmsg vdev limitation remoteproc: safer boot/shutdown order remoteproc: remoteproc_rpmsg -> remoteproc_virtio remoteproc: resource table overhaul rpmsg: fix build warning when dma_addr_t is 64-bit rpmsg: fix published buffer length in rpmsg_recv_done rpmsg: validate incoming message length before propagating rpmsg: fix name service endpoint leak remoteproc/omap: two Kconfig fixes remoteproc: make sure we're parsing a 32bit firmware
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/remoteproc.txt136
1 files changed, 67 insertions, 69 deletions
diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt
index 23ff7349ffe..70a048cd3fa 100644
--- a/Documentation/remoteproc.txt
+++ b/Documentation/remoteproc.txt
@@ -20,6 +20,11 @@ platform-specific remoteproc drivers only need to provide a few low-level
20handlers, and then all rpmsg drivers will then just work 20handlers, and then all rpmsg drivers will then just work
21(for more information about the virtio-based rpmsg bus and its drivers, 21(for more information about the virtio-based rpmsg bus and its drivers,
22please read Documentation/rpmsg.txt). 22please read Documentation/rpmsg.txt).
23Registration of other types of virtio devices is now also possible. Firmwares
24just need to publish what kind of virtio devices do they support, and then
25remoteproc will add those devices. This makes it possible to reuse the
26existing virtio drivers with remote processor backends at a minimal development
27cost.
23 28
242. User API 292. User API
25 30
@@ -136,8 +141,6 @@ int dummy_rproc_example(struct rproc *my_rproc)
136 If found, those virtio devices will be created and added, so as a result 141 If found, those virtio devices will be created and added, so as a result
137 of registering this remote processor, additional virtio drivers might get 142 of registering this remote processor, additional virtio drivers might get
138 probed. 143 probed.
139 Currently, though, we only support a single RPMSG virtio vdev per remote
140 processor.
141 144
142 int rproc_unregister(struct rproc *rproc) 145 int rproc_unregister(struct rproc *rproc)
143 - Unregister a remote processor, and decrement its refcount. 146 - Unregister a remote processor, and decrement its refcount.
@@ -174,7 +177,7 @@ struct rproc_ops {
174}; 177};
175 178
176Every remoteproc implementation should at least provide the ->start and ->stop 179Every remoteproc implementation should at least provide the ->start and ->stop
177handlers. If rpmsg functionality is also desired, then the ->kick handler 180handlers. If rpmsg/virtio functionality is also desired, then the ->kick handler
178should be provided as well. 181should be provided as well.
179 182
180The ->start() handler takes an rproc handle and should then power on the 183The ->start() handler takes an rproc handle and should then power on the
@@ -221,43 +224,52 @@ resource entries that publish the existence of supported features
221or configurations by the remote processor, such as trace buffers and 224or configurations by the remote processor, such as trace buffers and
222supported virtio devices (and their configurations). 225supported virtio devices (and their configurations).
223 226
224Currently the resource table is just an array of: 227The resource table begins with this header:
225 228
226/** 229/**
227 * struct fw_resource - describes an entry from the resource section 230 * struct resource_table - firmware resource table header
231 * @ver: version number
232 * @num: number of resource entries
233 * @reserved: reserved (must be zero)
234 * @offset: array of offsets pointing at the various resource entries
235 *
236 * The header of the resource table, as expressed by this structure,
237 * contains a version number (should we need to change this format in the
238 * future), the number of available resource entries, and their offsets
239 * in the table.
240 */
241struct resource_table {
242 u32 ver;
243 u32 num;
244 u32 reserved[2];
245 u32 offset[0];
246} __packed;
247
248Immediately following this header are the resource entries themselves,
249each of which begins with the following resource entry header:
250
251/**
252 * struct fw_rsc_hdr - firmware resource entry header
228 * @type: resource type 253 * @type: resource type
229 * @id: index number of the resource 254 * @data: resource data
230 * @da: device address of the resource 255 *
231 * @pa: physical address of the resource 256 * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
232 * @len: size, in bytes, of the resource 257 * its @type. The content of the entry itself will immediately follow
233 * @flags: properties of the resource, e.g. iommu protection required 258 * this header, and it should be parsed according to the resource type.
234 * @reserved: must be 0 atm
235 * @name: name of resource
236 */ 259 */
237struct fw_resource { 260struct fw_rsc_hdr {
238 u32 type; 261 u32 type;
239 u32 id; 262 u8 data[0];
240 u64 da;
241 u64 pa;
242 u32 len;
243 u32 flags;
244 u8 reserved[16];
245 u8 name[48];
246} __packed; 263} __packed;
247 264
248Some resources entries are mere announcements, where the host is informed 265Some resources entries are mere announcements, where the host is informed
249of specific remoteproc configuration. Other entries require the host to 266of specific remoteproc configuration. Other entries require the host to
250do something (e.g. reserve a requested resource) and possibly also reply 267do something (e.g. allocate a system resource). Sometimes a negotiation
251by overwriting a member inside 'struct fw_resource' with info about the 268is expected, where the firmware requests a resource, and once allocated,
252allocated resource. 269the host should provide back its details (e.g. address of an allocated
253 270memory region).
254Different resource entries use different members of this struct,
255with different meanings. This is pretty limiting and error-prone,
256so the plan is to move to variable-length TLV-based resource entries,
257where each resource will begin with a type and length fields, followed by
258its own specific structure.
259 271
260Here are the resource types that are currently being used: 272Here are the various resource types that are currently supported:
261 273
262/** 274/**
263 * enum fw_resource_type - types of resource entries 275 * enum fw_resource_type - types of resource entries
@@ -266,59 +278,45 @@ Here are the resource types that are currently being used:
266 * memory region. 278 * memory region.
267 * @RSC_DEVMEM: request to iommu_map a memory-based peripheral. 279 * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
268 * @RSC_TRACE: announces the availability of a trace buffer into which 280 * @RSC_TRACE: announces the availability of a trace buffer into which
269 * the remote processor will be writing logs. In this case, 281 * the remote processor will be writing logs.
270 * 'da' indicates the device address where logs are written to, 282 * @RSC_VDEV: declare support for a virtio device, and serve as its
271 * and 'len' is the size of the trace buffer. 283 * virtio header.
272 * @RSC_VRING: request for allocation of a virtio vring (address should 284 * @RSC_LAST: just keep this one at the end
273 * be indicated in 'da', and 'len' should contain the number 285 *
274 * of buffers supported by the vring). 286 * Please note that these values are used as indices to the rproc_handle_rsc
275 * @RSC_VIRTIO_DEV: announces support for a virtio device, and serves as 287 * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
276 * the virtio header. 'da' contains the virtio device 288 * check the validity of an index before the lookup table is accessed, so
277 * features, 'pa' holds the virtio guest features (host 289 * please update it as needed.
278 * will write them here after they're negotiated), 'len'
279 * holds the virtio status, and 'flags' holds the virtio
280 * device id (currently only VIRTIO_ID_RPMSG is supported).
281 */ 290 */
282enum fw_resource_type { 291enum fw_resource_type {
283 RSC_CARVEOUT = 0, 292 RSC_CARVEOUT = 0,
284 RSC_DEVMEM = 1, 293 RSC_DEVMEM = 1,
285 RSC_TRACE = 2, 294 RSC_TRACE = 2,
286 RSC_VRING = 3, 295 RSC_VDEV = 3,
287 RSC_VIRTIO_DEV = 4, 296 RSC_LAST = 4,
288 RSC_VIRTIO_CFG = 5,
289}; 297};
290 298
291Most of the resource entries share the basic idea of address/length 299For more details regarding a specific resource type, please see its
292negotiation with the host: the firmware usually asks for memory 300dedicated structure in include/linux/remoteproc.h.
293of size 'len' bytes, and the host needs to allocate it and provide
294the device/physical address (when relevant) in 'da'/'pa' respectively.
295
296If the firmware is compiled with hard coded device addresses, and
297can't handle dynamically allocated 'da' values, then the 'da' field
298will contain the expected device addresses (today we actually only support
299this scheme, as there aren't yet any use cases for dynamically allocated
300device addresses).
301 301
302We also expect that platform-specific resource entries will show up 302We also expect that platform-specific resource entries will show up
303at some point. When that happens, we could easily add a new RSC_PLAFORM 303at some point. When that happens, we could easily add a new RSC_PLATFORM
304type, and hand those resources to the platform-specific rproc driver to handle. 304type, and hand those resources to the platform-specific rproc driver to handle.
305 305
3067. Virtio and remoteproc 3067. Virtio and remoteproc
307 307
308The firmware should provide remoteproc information about virtio devices 308The firmware should provide remoteproc information about virtio devices
309that it supports, and their configurations: a RSC_VIRTIO_DEV resource entry 309that it supports, and their configurations: a RSC_VDEV resource entry
310should specify the virtio device id, and subsequent RSC_VRING resource entries 310should specify the virtio device id (as in virtio_ids.h), virtio features,
311should indicate the vring size (i.e. how many buffers do they support) and 311virtio config space, vrings information, etc.
312where should they be mapped (i.e. which device address). Note: the alignment 312
313between the consumer and producer parts of the vring is assumed to be 4096. 313When a new remote processor is registered, the remoteproc framework
314 314will look for its resource table and will register the virtio devices
315At this point we only support a single virtio rpmsg device per remote 315it supports. A firmware may support any number of virtio devices, and
316processor, but the plan is to remove this limitation. In addition, once we 316of any type (a single remote processor can also easily support several
317move to TLV-based resource table, the plan is to have a single RSC_VIRTIO 317rpmsg virtio devices this way, if desired).
318entry per supported virtio device, which will include the virtio header, 318
319the vrings information and the virtio config space. 319Of course, RSC_VDEV resource entries are only good enough for static
320
321Of course, RSC_VIRTIO resource entries are only good enough for static
322allocation of virtio devices. Dynamic allocations will also be made possible 320allocation of virtio devices. Dynamic allocations will also be made possible
323using the rpmsg bus (similar to how we already do dynamic allocations of 321using the rpmsg bus (similar to how we already do dynamic allocations of
324rpmsg channels; read more about it in rpmsg.txt). 322rpmsg channels; read more about it in rpmsg.txt).