aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/remoteproc.txt
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2012-02-01 14:56:16 -0500
committerOhad Ben-Cohen <ohad@wizery.com>2012-03-06 12:13:39 -0500
commitfd2c15ec1dd3c2fdfc6ff03bb9644da9d530e3b9 (patch)
tree29e38853a3fac9e547a20fcb9f857c53ca7019b9 /Documentation/remoteproc.txt
parent9d8ae5c22b73852e9b23ba4e520a64c29bbfc939 (diff)
remoteproc: resource table overhaul
The resource table is an array of 'struct fw_resource' members, where each resource entry is expressed as a single member of that array. This approach got us this far, but it has a few drawbacks: 1. Different resource entries end up overloading the same members of 'struct fw_resource' with different meanings. The resulting code is error prone and hard to read and maintain. 2. It's impossible to extend 'struct fw_resource' without breaking the existing firmware images (and we already want to: we can't introduce the new virito device resource entry with the current scheme). 3. It doesn't scale: 'struct fw_resource' must be as big as the largest resource entry type. As a result, smaller resource entries end up utilizing only small part of it. This is fixed by defining a dedicated structure for every resource type, and then converting the resource table to a list of type-value members. Instead of a rigid array of homogeneous structs, the resource table is turned into a collection of heterogeneous structures. This way: 1. Resource entries consume exactly the amount of bytes they need. 2. It's easy to extend: just create a new resource entry structure, and assign it a new type. 3. The code is easier to read and maintain: the structures' members names are meaningful. While we're at it, this patch has several other resource table changes: 1. The resource table gains a simple header which contains the number of entries in the table and their offsets within the table. This makes the parsing code simpler and easier to read. 2. A version member is added to the resource table. Should we change the format again, we'll bump up this version to prevent breakage with existing firmware images. 3. The VRING and VIRTIO_DEV resource entries are combined to a single VDEV entry. This paves the way to supporting multiple VDEV entries. 4. Since we don't really support 64-bit rprocs yet, convert two stray u64 members to u32. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Cc: Brian Swetland <swetland@google.com> Cc: Iliyan Malchev <malchev@google.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Mark Grosen <mgrosen@ti.com> Cc: John Williams <john.williams@petalogix.com> Cc: Michal Simek <monstr@monstr.eu> Cc: Loic PALLARDY <loic.pallardy@stericsson.com> Cc: Ludovic BARRE <ludovic.barre@stericsson.com> Cc: Omar Ramirez Luna <omar.luna@linaro.org> Cc: Guzman Lugo Fernando <fernando.lugo@ti.com> Cc: Anna Suman <s-anna@ti.com> Cc: Clark Rob <rob@ti.com> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Saravana Kannan <skannan@codeaurora.org> Cc: David Brown <davidb@codeaurora.org> Cc: Kieran Bingham <kieranbingham@gmail.com> Cc: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'Documentation/remoteproc.txt')
-rw-r--r--Documentation/remoteproc.txt127
1 files changed, 61 insertions, 66 deletions
diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt
index 23ff7349ffe7..07057cacfeae 100644
--- a/Documentation/remoteproc.txt
+++ b/Documentation/remoteproc.txt
@@ -221,43 +221,52 @@ resource entries that publish the existence of supported features
221or configurations by the remote processor, such as trace buffers and 221or configurations by the remote processor, such as trace buffers and
222supported virtio devices (and their configurations). 222supported virtio devices (and their configurations).
223 223
224Currently the resource table is just an array of: 224The resource table begins with this header:
225 225
226/** 226/**
227 * struct fw_resource - describes an entry from the resource section 227 * struct resource_table - firmware resource table header
228 * @ver: version number
229 * @num: number of resource entries
230 * @reserved: reserved (must be zero)
231 * @offset: array of offsets pointing at the various resource entries
232 *
233 * The header of the resource table, as expressed by this structure,
234 * contains a version number (should we need to change this format in the
235 * future), the number of available resource entries, and their offsets
236 * in the table.
237 */
238struct resource_table {
239 u32 ver;
240 u32 num;
241 u32 reserved[2];
242 u32 offset[0];
243} __packed;
244
245Immediately following this header are the resource entries themselves,
246each of which begins with the following resource entry header:
247
248/**
249 * struct fw_rsc_hdr - firmware resource entry header
228 * @type: resource type 250 * @type: resource type
229 * @id: index number of the resource 251 * @data: resource data
230 * @da: device address of the resource 252 *
231 * @pa: physical address of the resource 253 * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
232 * @len: size, in bytes, of the resource 254 * its @type. The content of the entry itself will immediately follow
233 * @flags: properties of the resource, e.g. iommu protection required 255 * this header, and it should be parsed according to the resource type.
234 * @reserved: must be 0 atm
235 * @name: name of resource
236 */ 256 */
237struct fw_resource { 257struct fw_rsc_hdr {
238 u32 type; 258 u32 type;
239 u32 id; 259 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; 260} __packed;
247 261
248Some resources entries are mere announcements, where the host is informed 262Some resources entries are mere announcements, where the host is informed
249of specific remoteproc configuration. Other entries require the host to 263of specific remoteproc configuration. Other entries require the host to
250do something (e.g. reserve a requested resource) and possibly also reply 264do something (e.g. allocate a system resource). Sometimes a negotiation
251by overwriting a member inside 'struct fw_resource' with info about the 265is expected, where the firmware requests a resource, and once allocated,
252allocated resource. 266the host should provide back its details (e.g. address of an allocated
253 267memory 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 268
260Here are the resource types that are currently being used: 269Here are the various resource types that are currently supported:
261 270
262/** 271/**
263 * enum fw_resource_type - types of resource entries 272 * enum fw_resource_type - types of resource entries
@@ -266,59 +275,45 @@ Here are the resource types that are currently being used:
266 * memory region. 275 * memory region.
267 * @RSC_DEVMEM: request to iommu_map a memory-based peripheral. 276 * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
268 * @RSC_TRACE: announces the availability of a trace buffer into which 277 * @RSC_TRACE: announces the availability of a trace buffer into which
269 * the remote processor will be writing logs. In this case, 278 * the remote processor will be writing logs.
270 * 'da' indicates the device address where logs are written to, 279 * @RSC_VDEV: declare support for a virtio device, and serve as its
271 * and 'len' is the size of the trace buffer. 280 * virtio header.
272 * @RSC_VRING: request for allocation of a virtio vring (address should 281 * @RSC_LAST: just keep this one at the end
273 * be indicated in 'da', and 'len' should contain the number 282 *
274 * of buffers supported by the vring). 283 * 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 284 * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
276 * the virtio header. 'da' contains the virtio device 285 * check the validity of an index before the lookup table is accessed, so
277 * features, 'pa' holds the virtio guest features (host 286 * 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 */ 287 */
282enum fw_resource_type { 288enum fw_resource_type {
283 RSC_CARVEOUT = 0, 289 RSC_CARVEOUT = 0,
284 RSC_DEVMEM = 1, 290 RSC_DEVMEM = 1,
285 RSC_TRACE = 2, 291 RSC_TRACE = 2,
286 RSC_VRING = 3, 292 RSC_VDEV = 3,
287 RSC_VIRTIO_DEV = 4, 293 RSC_LAST = 4,
288 RSC_VIRTIO_CFG = 5,
289}; 294};
290 295
291Most of the resource entries share the basic idea of address/length 296For more details regarding a specific resource type, please see its
292negotiation with the host: the firmware usually asks for memory 297dedicated 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 298
302We also expect that platform-specific resource entries will show up 299We also expect that platform-specific resource entries will show up
303at some point. When that happens, we could easily add a new RSC_PLAFORM 300at 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. 301type, and hand those resources to the platform-specific rproc driver to handle.
305 302
3067. Virtio and remoteproc 3037. Virtio and remoteproc
307 304
308The firmware should provide remoteproc information about virtio devices 305The firmware should provide remoteproc information about virtio devices
309that it supports, and their configurations: a RSC_VIRTIO_DEV resource entry 306that it supports, and their configurations: a RSC_VDEV resource entry
310should specify the virtio device id, and subsequent RSC_VRING resource entries 307should 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 308virtio config space, vrings information, etc.
312where should they be mapped (i.e. which device address). Note: the alignment 309
313between the consumer and producer parts of the vring is assumed to be 4096. 310When a new remote processor is registered, the remoteproc framework
314 311will look for its resource table and will register the virtio devices
315At this point we only support a single virtio rpmsg device per remote 312it supports. A firmware may support any number of virtio devices, and
316processor, but the plan is to remove this limitation. In addition, once we 313of 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 314rpmsg virtio devices this way, if desired).
318entry per supported virtio device, which will include the virtio header, 315
319the vrings information and the virtio config space. 316Of 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 317allocation of virtio devices. Dynamic allocations will also be made possible
323using the rpmsg bus (similar to how we already do dynamic allocations of 318using the rpmsg bus (similar to how we already do dynamic allocations of
324rpmsg channels; read more about it in rpmsg.txt). 319rpmsg channels; read more about it in rpmsg.txt).