diff options
author | Olof Johansson <olof@lixom.net> | 2012-03-07 18:21:12 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-03-07 18:21:12 -0500 |
commit | 6458acb5a31926dcc1295410221493544d628cf7 (patch) | |
tree | 15b5a855f73d52f95aeed2ab11e2e8028d82b746 /Documentation | |
parent | ab646a24bb9b6125f3c23ef908b7c5b44b1b4e69 (diff) | |
parent | 1e3e2c7c46b2e6e90f3a26ba9be6326c00ca31e4 (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.txt | 136 |
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 | |||
20 | handlers, and then all rpmsg drivers will then just work | 20 | handlers, 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, |
22 | please read Documentation/rpmsg.txt). | 22 | please read Documentation/rpmsg.txt). |
23 | Registration of other types of virtio devices is now also possible. Firmwares | ||
24 | just need to publish what kind of virtio devices do they support, and then | ||
25 | remoteproc will add those devices. This makes it possible to reuse the | ||
26 | existing virtio drivers with remote processor backends at a minimal development | ||
27 | cost. | ||
23 | 28 | ||
24 | 2. User API | 29 | 2. 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 | ||
176 | Every remoteproc implementation should at least provide the ->start and ->stop | 179 | Every remoteproc implementation should at least provide the ->start and ->stop |
177 | handlers. If rpmsg functionality is also desired, then the ->kick handler | 180 | handlers. If rpmsg/virtio functionality is also desired, then the ->kick handler |
178 | should be provided as well. | 181 | should be provided as well. |
179 | 182 | ||
180 | The ->start() handler takes an rproc handle and should then power on the | 183 | The ->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 | |||
221 | or configurations by the remote processor, such as trace buffers and | 224 | or configurations by the remote processor, such as trace buffers and |
222 | supported virtio devices (and their configurations). | 225 | supported virtio devices (and their configurations). |
223 | 226 | ||
224 | Currently the resource table is just an array of: | 227 | The 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 | */ | ||
241 | struct resource_table { | ||
242 | u32 ver; | ||
243 | u32 num; | ||
244 | u32 reserved[2]; | ||
245 | u32 offset[0]; | ||
246 | } __packed; | ||
247 | |||
248 | Immediately following this header are the resource entries themselves, | ||
249 | each 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 | */ |
237 | struct fw_resource { | 260 | struct 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 | ||
248 | Some resources entries are mere announcements, where the host is informed | 265 | Some resources entries are mere announcements, where the host is informed |
249 | of specific remoteproc configuration. Other entries require the host to | 266 | of specific remoteproc configuration. Other entries require the host to |
250 | do something (e.g. reserve a requested resource) and possibly also reply | 267 | do something (e.g. allocate a system resource). Sometimes a negotiation |
251 | by overwriting a member inside 'struct fw_resource' with info about the | 268 | is expected, where the firmware requests a resource, and once allocated, |
252 | allocated resource. | 269 | the host should provide back its details (e.g. address of an allocated |
253 | 270 | memory region). | |
254 | Different resource entries use different members of this struct, | ||
255 | with different meanings. This is pretty limiting and error-prone, | ||
256 | so the plan is to move to variable-length TLV-based resource entries, | ||
257 | where each resource will begin with a type and length fields, followed by | ||
258 | its own specific structure. | ||
259 | 271 | ||
260 | Here are the resource types that are currently being used: | 272 | Here 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 | */ |
282 | enum fw_resource_type { | 291 | enum 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 | ||
291 | Most of the resource entries share the basic idea of address/length | 299 | For more details regarding a specific resource type, please see its |
292 | negotiation with the host: the firmware usually asks for memory | 300 | dedicated structure in include/linux/remoteproc.h. |
293 | of size 'len' bytes, and the host needs to allocate it and provide | ||
294 | the device/physical address (when relevant) in 'da'/'pa' respectively. | ||
295 | |||
296 | If the firmware is compiled with hard coded device addresses, and | ||
297 | can't handle dynamically allocated 'da' values, then the 'da' field | ||
298 | will contain the expected device addresses (today we actually only support | ||
299 | this scheme, as there aren't yet any use cases for dynamically allocated | ||
300 | device addresses). | ||
301 | 301 | ||
302 | We also expect that platform-specific resource entries will show up | 302 | We also expect that platform-specific resource entries will show up |
303 | at some point. When that happens, we could easily add a new RSC_PLAFORM | 303 | at some point. When that happens, we could easily add a new RSC_PLATFORM |
304 | type, and hand those resources to the platform-specific rproc driver to handle. | 304 | type, and hand those resources to the platform-specific rproc driver to handle. |
305 | 305 | ||
306 | 7. Virtio and remoteproc | 306 | 7. Virtio and remoteproc |
307 | 307 | ||
308 | The firmware should provide remoteproc information about virtio devices | 308 | The firmware should provide remoteproc information about virtio devices |
309 | that it supports, and their configurations: a RSC_VIRTIO_DEV resource entry | 309 | that it supports, and their configurations: a RSC_VDEV resource entry |
310 | should specify the virtio device id, and subsequent RSC_VRING resource entries | 310 | should specify the virtio device id (as in virtio_ids.h), virtio features, |
311 | should indicate the vring size (i.e. how many buffers do they support) and | 311 | virtio config space, vrings information, etc. |
312 | where should they be mapped (i.e. which device address). Note: the alignment | 312 | |
313 | between the consumer and producer parts of the vring is assumed to be 4096. | 313 | When a new remote processor is registered, the remoteproc framework |
314 | 314 | will look for its resource table and will register the virtio devices | |
315 | At this point we only support a single virtio rpmsg device per remote | 315 | it supports. A firmware may support any number of virtio devices, and |
316 | processor, but the plan is to remove this limitation. In addition, once we | 316 | of any type (a single remote processor can also easily support several |
317 | move to TLV-based resource table, the plan is to have a single RSC_VIRTIO | 317 | rpmsg virtio devices this way, if desired). |
318 | entry per supported virtio device, which will include the virtio header, | 318 | |
319 | the vrings information and the virtio config space. | 319 | Of course, RSC_VDEV resource entries are only good enough for static |
320 | |||
321 | Of course, RSC_VIRTIO resource entries are only good enough for static | ||
322 | allocation of virtio devices. Dynamic allocations will also be made possible | 320 | allocation of virtio devices. Dynamic allocations will also be made possible |
323 | using the rpmsg bus (similar to how we already do dynamic allocations of | 321 | using the rpmsg bus (similar to how we already do dynamic allocations of |
324 | rpmsg channels; read more about it in rpmsg.txt). | 322 | rpmsg channels; read more about it in rpmsg.txt). |