Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rpmsg.txt: standardize document format

Each text file under Documentation follows a different
format. Some doesn't even have titles!

Change its representation to follow the adopted standard,
using ReST markups for it to be parseable by Sphinx:

- mark document and chapter titles;
- mark notes;
- mark literal blocks;
- adjust identation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
af3137f1 773810d3

+194 -134
+194 -134
Documentation/rpmsg.txt
··· 1 + ============================================ 1 2 Remote Processor Messaging (rpmsg) Framework 3 + ============================================ 2 4 3 - Note: this document describes the rpmsg bus and how to write rpmsg drivers. 4 - To learn how to add rpmsg support for new platforms, check out remoteproc.txt 5 - (also a resident of Documentation/). 5 + .. note:: 6 6 7 - 1. Introduction 7 + This document describes the rpmsg bus and how to write rpmsg drivers. 8 + To learn how to add rpmsg support for new platforms, check out remoteproc.txt 9 + (also a resident of Documentation/). 10 + 11 + Introduction 12 + ============ 8 13 9 14 Modern SoCs typically employ heterogeneous remote processor devices in 10 15 asymmetric multiprocessing (AMP) configurations, which may be running ··· 63 58 with the payload of the inbound message). 64 59 65 60 66 - 2. User API 61 + User API 62 + ======== 63 + 64 + :: 67 65 68 66 int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len); 69 - - sends a message across to the remote processor on a given channel. 70 - The caller should specify the channel, the data it wants to send, 71 - and its length (in bytes). The message will be sent on the specified 72 - channel, i.e. its source and destination address fields will be 73 - set to the channel's src and dst addresses. 74 67 75 - In case there are no TX buffers available, the function will block until 76 - one becomes available (i.e. until the remote processor consumes 77 - a tx buffer and puts it back on virtio's used descriptor ring), 78 - or a timeout of 15 seconds elapses. When the latter happens, 79 - -ERESTARTSYS is returned. 80 - The function can only be called from a process context (for now). 81 - Returns 0 on success and an appropriate error value on failure. 68 + sends a message across to the remote processor on a given channel. 69 + The caller should specify the channel, the data it wants to send, 70 + and its length (in bytes). The message will be sent on the specified 71 + channel, i.e. its source and destination address fields will be 72 + set to the channel's src and dst addresses. 73 + 74 + In case there are no TX buffers available, the function will block until 75 + one becomes available (i.e. until the remote processor consumes 76 + a tx buffer and puts it back on virtio's used descriptor ring), 77 + or a timeout of 15 seconds elapses. When the latter happens, 78 + -ERESTARTSYS is returned. 79 + 80 + The function can only be called from a process context (for now). 81 + Returns 0 on success and an appropriate error value on failure. 82 + 83 + :: 82 84 83 85 int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst); 84 - - sends a message across to the remote processor on a given channel, 85 - to a destination address provided by the caller. 86 - The caller should specify the channel, the data it wants to send, 87 - its length (in bytes), and an explicit destination address. 88 - The message will then be sent to the remote processor to which the 89 - channel belongs, using the channel's src address, and the user-provided 90 - dst address (thus the channel's dst address will be ignored). 91 86 92 - In case there are no TX buffers available, the function will block until 93 - one becomes available (i.e. until the remote processor consumes 94 - a tx buffer and puts it back on virtio's used descriptor ring), 95 - or a timeout of 15 seconds elapses. When the latter happens, 96 - -ERESTARTSYS is returned. 97 - The function can only be called from a process context (for now). 98 - Returns 0 on success and an appropriate error value on failure. 87 + sends a message across to the remote processor on a given channel, 88 + to a destination address provided by the caller. 89 + 90 + The caller should specify the channel, the data it wants to send, 91 + its length (in bytes), and an explicit destination address. 92 + 93 + The message will then be sent to the remote processor to which the 94 + channel belongs, using the channel's src address, and the user-provided 95 + dst address (thus the channel's dst address will be ignored). 96 + 97 + In case there are no TX buffers available, the function will block until 98 + one becomes available (i.e. until the remote processor consumes 99 + a tx buffer and puts it back on virtio's used descriptor ring), 100 + or a timeout of 15 seconds elapses. When the latter happens, 101 + -ERESTARTSYS is returned. 102 + 103 + The function can only be called from a process context (for now). 104 + Returns 0 on success and an appropriate error value on failure. 105 + 106 + :: 99 107 100 108 int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, 101 109 void *data, int len); 102 - - sends a message across to the remote processor, using the src and dst 103 - addresses provided by the user. 104 - The caller should specify the channel, the data it wants to send, 105 - its length (in bytes), and explicit source and destination addresses. 106 - The message will then be sent to the remote processor to which the 107 - channel belongs, but the channel's src and dst addresses will be 108 - ignored (and the user-provided addresses will be used instead). 109 110 110 - In case there are no TX buffers available, the function will block until 111 - one becomes available (i.e. until the remote processor consumes 112 - a tx buffer and puts it back on virtio's used descriptor ring), 113 - or a timeout of 15 seconds elapses. When the latter happens, 114 - -ERESTARTSYS is returned. 115 - The function can only be called from a process context (for now). 116 - Returns 0 on success and an appropriate error value on failure. 111 + 112 + sends a message across to the remote processor, using the src and dst 113 + addresses provided by the user. 114 + 115 + The caller should specify the channel, the data it wants to send, 116 + its length (in bytes), and explicit source and destination addresses. 117 + The message will then be sent to the remote processor to which the 118 + channel belongs, but the channel's src and dst addresses will be 119 + ignored (and the user-provided addresses will be used instead). 120 + 121 + In case there are no TX buffers available, the function will block until 122 + one becomes available (i.e. until the remote processor consumes 123 + a tx buffer and puts it back on virtio's used descriptor ring), 124 + or a timeout of 15 seconds elapses. When the latter happens, 125 + -ERESTARTSYS is returned. 126 + 127 + The function can only be called from a process context (for now). 128 + Returns 0 on success and an appropriate error value on failure. 129 + 130 + :: 117 131 118 132 int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len); 119 - - sends a message across to the remote processor on a given channel. 120 - The caller should specify the channel, the data it wants to send, 121 - and its length (in bytes). The message will be sent on the specified 122 - channel, i.e. its source and destination address fields will be 123 - set to the channel's src and dst addresses. 124 133 125 - In case there are no TX buffers available, the function will immediately 126 - return -ENOMEM without waiting until one becomes available. 127 - The function can only be called from a process context (for now). 128 - Returns 0 on success and an appropriate error value on failure. 134 + sends a message across to the remote processor on a given channel. 135 + The caller should specify the channel, the data it wants to send, 136 + and its length (in bytes). The message will be sent on the specified 137 + channel, i.e. its source and destination address fields will be 138 + set to the channel's src and dst addresses. 139 + 140 + In case there are no TX buffers available, the function will immediately 141 + return -ENOMEM without waiting until one becomes available. 142 + 143 + The function can only be called from a process context (for now). 144 + Returns 0 on success and an appropriate error value on failure. 145 + 146 + :: 129 147 130 148 int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, u32 dst) 131 - - sends a message across to the remote processor on a given channel, 132 - to a destination address provided by the user. 133 - The user should specify the channel, the data it wants to send, 134 - its length (in bytes), and an explicit destination address. 135 - The message will then be sent to the remote processor to which the 136 - channel belongs, using the channel's src address, and the user-provided 137 - dst address (thus the channel's dst address will be ignored). 138 149 139 - In case there are no TX buffers available, the function will immediately 140 - return -ENOMEM without waiting until one becomes available. 141 - The function can only be called from a process context (for now). 142 - Returns 0 on success and an appropriate error value on failure. 150 + 151 + sends a message across to the remote processor on a given channel, 152 + to a destination address provided by the user. 153 + 154 + The user should specify the channel, the data it wants to send, 155 + its length (in bytes), and an explicit destination address. 156 + 157 + The message will then be sent to the remote processor to which the 158 + channel belongs, using the channel's src address, and the user-provided 159 + dst address (thus the channel's dst address will be ignored). 160 + 161 + In case there are no TX buffers available, the function will immediately 162 + return -ENOMEM without waiting until one becomes available. 163 + 164 + The function can only be called from a process context (for now). 165 + Returns 0 on success and an appropriate error value on failure. 166 + 167 + :: 143 168 144 169 int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, u32 src, u32 dst, 145 170 void *data, int len); 146 - - sends a message across to the remote processor, using source and 147 - destination addresses provided by the user. 148 - The user should specify the channel, the data it wants to send, 149 - its length (in bytes), and explicit source and destination addresses. 150 - The message will then be sent to the remote processor to which the 151 - channel belongs, but the channel's src and dst addresses will be 152 - ignored (and the user-provided addresses will be used instead). 153 171 154 - In case there are no TX buffers available, the function will immediately 155 - return -ENOMEM without waiting until one becomes available. 156 - The function can only be called from a process context (for now). 157 - Returns 0 on success and an appropriate error value on failure. 172 + 173 + sends a message across to the remote processor, using source and 174 + destination addresses provided by the user. 175 + 176 + The user should specify the channel, the data it wants to send, 177 + its length (in bytes), and explicit source and destination addresses. 178 + The message will then be sent to the remote processor to which the 179 + channel belongs, but the channel's src and dst addresses will be 180 + ignored (and the user-provided addresses will be used instead). 181 + 182 + In case there are no TX buffers available, the function will immediately 183 + return -ENOMEM without waiting until one becomes available. 184 + 185 + The function can only be called from a process context (for now). 186 + Returns 0 on success and an appropriate error value on failure. 187 + 188 + :: 158 189 159 190 struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rpdev, 160 191 void (*cb)(struct rpmsg_channel *, void *, int, void *, u32), 161 192 void *priv, u32 addr); 162 - - every rpmsg address in the system is bound to an rx callback (so when 163 - inbound messages arrive, they are dispatched by the rpmsg bus using the 164 - appropriate callback handler) by means of an rpmsg_endpoint struct. 165 193 166 - This function allows drivers to create such an endpoint, and by that, 167 - bind a callback, and possibly some private data too, to an rpmsg address 168 - (either one that is known in advance, or one that will be dynamically 169 - assigned for them). 194 + every rpmsg address in the system is bound to an rx callback (so when 195 + inbound messages arrive, they are dispatched by the rpmsg bus using the 196 + appropriate callback handler) by means of an rpmsg_endpoint struct. 170 197 171 - Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint 172 - is already created for them when they are probed by the rpmsg bus 173 - (using the rx callback they provide when they registered to the rpmsg bus). 198 + This function allows drivers to create such an endpoint, and by that, 199 + bind a callback, and possibly some private data too, to an rpmsg address 200 + (either one that is known in advance, or one that will be dynamically 201 + assigned for them). 174 202 175 - So things should just work for simple drivers: they already have an 176 - endpoint, their rx callback is bound to their rpmsg address, and when 177 - relevant inbound messages arrive (i.e. messages which their dst address 178 - equals to the src address of their rpmsg channel), the driver's handler 179 - is invoked to process it. 203 + Simple rpmsg drivers need not call rpmsg_create_ept, because an endpoint 204 + is already created for them when they are probed by the rpmsg bus 205 + (using the rx callback they provide when they registered to the rpmsg bus). 180 206 181 - That said, more complicated drivers might do need to allocate 182 - additional rpmsg addresses, and bind them to different rx callbacks. 183 - To accomplish that, those drivers need to call this function. 184 - Drivers should provide their channel (so the new endpoint would bind 185 - to the same remote processor their channel belongs to), an rx callback 186 - function, an optional private data (which is provided back when the 187 - rx callback is invoked), and an address they want to bind with the 188 - callback. If addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will 189 - dynamically assign them an available rpmsg address (drivers should have 190 - a very good reason why not to always use RPMSG_ADDR_ANY here). 207 + So things should just work for simple drivers: they already have an 208 + endpoint, their rx callback is bound to their rpmsg address, and when 209 + relevant inbound messages arrive (i.e. messages which their dst address 210 + equals to the src address of their rpmsg channel), the driver's handler 211 + is invoked to process it. 191 212 192 - Returns a pointer to the endpoint on success, or NULL on error. 213 + That said, more complicated drivers might do need to allocate 214 + additional rpmsg addresses, and bind them to different rx callbacks. 215 + To accomplish that, those drivers need to call this function. 216 + Drivers should provide their channel (so the new endpoint would bind 217 + to the same remote processor their channel belongs to), an rx callback 218 + function, an optional private data (which is provided back when the 219 + rx callback is invoked), and an address they want to bind with the 220 + callback. If addr is RPMSG_ADDR_ANY, then rpmsg_create_ept will 221 + dynamically assign them an available rpmsg address (drivers should have 222 + a very good reason why not to always use RPMSG_ADDR_ANY here). 223 + 224 + Returns a pointer to the endpoint on success, or NULL on error. 225 + 226 + :: 193 227 194 228 void rpmsg_destroy_ept(struct rpmsg_endpoint *ept); 195 - - destroys an existing rpmsg endpoint. user should provide a pointer 196 - to an rpmsg endpoint that was previously created with rpmsg_create_ept(). 229 + 230 + 231 + destroys an existing rpmsg endpoint. user should provide a pointer 232 + to an rpmsg endpoint that was previously created with rpmsg_create_ept(). 233 + 234 + :: 197 235 198 236 int register_rpmsg_driver(struct rpmsg_driver *rpdrv); 199 - - registers an rpmsg driver with the rpmsg bus. user should provide 200 - a pointer to an rpmsg_driver struct, which contains the driver's 201 - ->probe() and ->remove() functions, an rx callback, and an id_table 202 - specifying the names of the channels this driver is interested to 203 - be probed with. 237 + 238 + 239 + registers an rpmsg driver with the rpmsg bus. user should provide 240 + a pointer to an rpmsg_driver struct, which contains the driver's 241 + ->probe() and ->remove() functions, an rx callback, and an id_table 242 + specifying the names of the channels this driver is interested to 243 + be probed with. 244 + 245 + :: 204 246 205 247 void unregister_rpmsg_driver(struct rpmsg_driver *rpdrv); 206 - - unregisters an rpmsg driver from the rpmsg bus. user should provide 207 - a pointer to a previously-registered rpmsg_driver struct. 208 - Returns 0 on success, and an appropriate error value on failure. 209 248 210 249 211 - 3. Typical usage 250 + unregisters an rpmsg driver from the rpmsg bus. user should provide 251 + a pointer to a previously-registered rpmsg_driver struct. 252 + Returns 0 on success, and an appropriate error value on failure. 253 + 254 + 255 + Typical usage 256 + ============= 212 257 213 258 The following is a simple rpmsg driver, that sends an "hello!" message 214 259 on probe(), and whenever it receives an incoming message, it dumps its 215 260 content to the console. 216 261 217 - #include <linux/kernel.h> 218 - #include <linux/module.h> 219 - #include <linux/rpmsg.h> 262 + :: 220 263 221 - static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, 264 + #include <linux/kernel.h> 265 + #include <linux/module.h> 266 + #include <linux/rpmsg.h> 267 + 268 + static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, 222 269 void *priv, u32 src) 223 - { 270 + { 224 271 print_hex_dump(KERN_INFO, "incoming message:", DUMP_PREFIX_NONE, 225 272 16, 1, data, len, true); 226 - } 273 + } 227 274 228 - static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) 229 - { 275 + static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) 276 + { 230 277 int err; 231 278 232 279 dev_info(&rpdev->dev, "chnl: 0x%x -> 0x%x\n", rpdev->src, rpdev->dst); ··· 291 234 } 292 235 293 236 return 0; 294 - } 237 + } 295 238 296 - static void rpmsg_sample_remove(struct rpmsg_channel *rpdev) 297 - { 239 + static void rpmsg_sample_remove(struct rpmsg_channel *rpdev) 240 + { 298 241 dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); 299 - } 242 + } 300 243 301 - static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = { 244 + static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = { 302 245 { .name = "rpmsg-client-sample" }, 303 246 { }, 304 - }; 305 - MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table); 247 + }; 248 + MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table); 306 249 307 - static struct rpmsg_driver rpmsg_sample_client = { 250 + static struct rpmsg_driver rpmsg_sample_client = { 308 251 .drv.name = KBUILD_MODNAME, 309 252 .id_table = rpmsg_driver_sample_id_table, 310 253 .probe = rpmsg_sample_probe, 311 254 .callback = rpmsg_sample_cb, 312 255 .remove = rpmsg_sample_remove, 313 - }; 314 - module_rpmsg_driver(rpmsg_sample_client); 256 + }; 257 + module_rpmsg_driver(rpmsg_sample_client); 315 258 316 - Note: a similar sample which can be built and loaded can be found 317 - in samples/rpmsg/. 259 + .. note:: 318 260 319 - 4. Allocations of rpmsg channels: 261 + a similar sample which can be built and loaded can be found 262 + in samples/rpmsg/. 263 + 264 + Allocations of rpmsg channels 265 + ============================= 320 266 321 267 At this point we only support dynamic allocations of rpmsg channels. 322 268