summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
Commit message (Collapse)AuthorAgeFilesLines
...
* greybus: connection: kill gb_hd_connections_exitJohan Hovold2015-11-041-8/+0
| | | | | | | | | | Connections are destroyed as part of interface tear down. If we fail to do that properly it's a bug that should be fixed rather than papered over by a fall-back clean up function. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: fix potential null-deref when binding protocolJohan Hovold2015-11-041-1/+1
| | | | | | | | | We can have connections without bundles so we must not use the bundle device for error messages when failing to look up a protocol. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: fix potential null-deref in connection createJohan Hovold2015-11-041-1/+1
| | | | | | | | | We allow connections without bundles so we must not use the bundle device for error messages after binding the protocol. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: fix potential null-deref in hd_cport_enableJohan Hovold2015-11-041-1/+1
| | | | | | | | | Use parent of host device for error messages as the connections bundle may be NULL. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: use bundle device for bundle error messagesJohan Hovold2015-11-041-1/+2
| | | | | | | | | It is safe to use the bundle device for error messages when we know we have a bundle. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: remove unused time-stamp definesJohan Hovold2015-11-021-4/+0
| | | | | | | | | Remove unused time-stamp defines, that were left in when the time-stamp fifo was removed. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: use the bundle struct device instead of the connectorGreg Kroah-Hartman2015-10-191-15/+15
| | | | | | | | | | | | | | We are removing struct device from the gb_connection structure in the near future. The gb_bundle structure's struct device should be used as a replacement. This patch moves the connection code to use the bundle pointer instead of the connection pointer for some error messages. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: remove 'struct device' from 'struct gb_connection'Greg Kroah-Hartman2015-10-191-75/+8
| | | | | | | | | | | | | | | | | | We don't want this in the driver core, as nothing will be binding to it, that's the job of a bundle. So remove the struct device and use a kref to handle reference counting instead. Note, I don't think we really need a kref, but it keeps the lifetime the same as before, and is the simplest change for now. In the future it might be easier to just attach all connections to the bundle and clean them up when the bundle is removed. Also remove the cport sysfs documentation as it's no longer relevant. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: add latency tag enable/disable callbacksBryan O'Donoghue2015-10-151-0/+32
| | | | | | | | | | | This patch adds a layered wrapper around optional latency tag enable/disable commands to APBridge. When set APBridge and GPBridge will insert timing information into reserved fields in the loopback response header. Correspondingly when unset no timing information will be included in the response payload. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: remove duplicate protocol lookup error messageJohan Hovold2015-10-141-4/+0
| | | | | | | | Remove duplicate protocol lookup error message, which has already been logged. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: protocol: make protocol-lookup error message more informativeJohan Hovold2015-10-141-1/+6
| | | | | | | | | | | Make protocol lookup error more informative, by moving it to gb_connection_bind_protocol and using dev_err. Also make sure to use hex format for the protocol id as that is what is used everywhere else. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: replace pr_err with dev_errJohan Hovold2015-10-141-3/+3
| | | | | | | | Replace a couple of pr_err with more informative dev_err and clean up the messages somewhat. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: destroy connection on failing to bind itFabien Parent2015-10-141-1/+8
| | | | | | | | | | | | gb_connection_bind_protocol() returns proper error codes now and we should destroy the connection on failures. This change also fixes a NULL deref on hotplug when the control connection fails to initialize. Signed-off-by: Fabien Parent <fparent@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: svc: skip setting flags for boot over uniproViresh Kumar2015-10-091-2/+5
| | | | | | | | | | | | | We need to skip setting E2EFC and other flags to the SVC connection create request, for all cports, on an interface that need to boot over unipro, i.e. interfaces required to download firmware. This also adds a FIXME as we need to do it differently for ES3. Tested-by: Eli Sennesh <esennesh@leaflabs.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off by: Eli Sennesh <esennesh@leaflabs.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: loopback: drop dependency on internal timestampsBryan O'Donoghue2015-09-231-30/+0
| | | | | | | | | | | This patch drops tracking of internal latencies, it's possible to derive these times via kernel tracepoints and some user-space scripting. Since there's no other use of the internal timestamp than the loopback driver we remove the connection.c, connection.h, es1.c, es2.c and loopback.c inter-dependency in one go. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: hd: remove connection-create/destroy callbacksJohan Hovold2015-09-171-6/+0
| | | | | | | | | | | | | | | | | | | | | | These host-driver callbacks were intended to allow host drivers to prepare a cport, something which can now be handled by the cport enable/disable callbacks instead. The current create/destroy are somewhat confusingly named as they were not supposed to create or destroy connections. They were however called from the unrelated helper functions that do create and destroy SVC connections. Furthermore, no errors were returned should the create callback fail, which should have caused the connection initialisation to fail. Remove these unused callbacks for now, and let us use the cport enable/disable callbacks that should be able handle all host cport initialisation (possibly after also adding an interface to provide information for endpoint-cport mapping). Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: hd: add optional cport enable and disable callbacksJohan Hovold2015-09-171-1/+36
| | | | | | | | | | Add optional cport enable and disable callbacks to the greybus host drivers, that can be used to initialise and allocate/release resources associated with a cport during connection setup/teardown (e.g. software queues and hardware state). Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: add protocol-version helperJohan Hovold2015-09-171-14/+25
| | | | | | | Add protocol-version to improve readability. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: add control-connected helperJohan Hovold2015-09-171-12/+26
| | | | | | | Add control-connected helper to improve readability. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: clean up control-disconnected helperJohan Hovold2015-09-171-8/+11
| | | | | | | | | | | Rename helper to the more descriptive gb_connection_control_disconnected(). Use u16 for cport number, remove redundant cport number from warning message, and shorten a long line. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: clean up init error pathsJohan Hovold2015-09-171-6/+8
| | | | | | | Clearly mark error-path labels as such and clean up control flow. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: clean up svc-connection creationJohan Hovold2015-09-171-19/+34
| | | | | | | | | | | | Move SVC-connection creation to its own helper. Note that the connection_create host-driver callback is really unrelated to the SVC connection, and will be removed by a later patch. It is is included for now as the connection_destroy callback is currently made from the SVC-connection-destroy helper. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: Add sysfs 'ap_cport_id' file for connectionsViresh Kumar2015-09-141-0/+9
| | | | | | | | | | | | Its a very useful piece of information, i.e. the cport id of the AP to which the cport of the module is connected, and is required lots of times. It isn't known in advance as it is allocated at runtime. This patch creates another file 'ap_cport_id', only for the connection directories, which will give the cport id of the AP. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Add flags to struct gb_protocolViresh Kumar2015-09-141-18/+10
| | | | | | | | | This helps in removing special per-protocol code, with the help of generic flags passed by protocol drivers. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: Call connection_destroy() from ↵Viresh Kumar2015-09-141-3/+3
| | | | | | | | | | | | | | | | | | gb_connection_svc_connection_destroy() connection_create() is called right after svc is requested to create the connection and so connection_destroy() must be called just before we request the SVC to destroy the connection. Over that, this fixes the inconsistency where connection_create() is called for all connections except SVC connection, but connection_destroy() is called always. Acked-by: Alexandre Bailon <abailon@baylibre.com> Fixes: 5313ca607afb ("Greybus driver: add a new callbacks to driver") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: destroy svc connection on connection exit or errorsViresh Kumar2015-09-141-1/+18
| | | | | | | | | | | | While initializing a connection, the AP requests the SVC to create a connection between a cport on AP and a cport on the Module. The opposite of that is missing, when connection is destroyed or if errors occur after creating the connection. Fix it. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: call gb_svc_connection_create() from gb_connection_init()Viresh Kumar2015-09-141-8/+21
| | | | | | | | | | | | | | | There are two operations which very much work together: - AP asks the SVC to create a connection between a cport of AP and a cport of module. - AP tells the module that the connection is created. Its better (logically) to do these two operations together and so call gb_svc_connection_create() from gb_connection_init() instead. Also check its return value properly. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Greybus driver: add a new callbacks to driverAlexandre Bailon2015-09-041-0/+5
| | | | | | | | | | | | | Add connection_create and connection_destroy callbacks. ES2 can map a cport to a pair of endpoints. Because ES2 have only a few pair of endpoints, ES2 need to have access to some high level connection information such as protocol id to effectively map the cports. These callback will provide these information and help ES2 to map cports. Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: protocol can be NULL in gb_connection_exit()Viresh Kumar2015-09-031-3/+1
| | | | | | | | | | | | gb_connection_exit() is getting called from gb_connection_destroy() now, which will get called from failure path of gb_connection_create_range() (in a later commit). And at that point connection->protocol will be NULL. Don't print an error message if this happens in gb_connection_exit(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: fail to bind if connection init failsFabien Parent2015-09-031-5/+14
| | | | | | | | | | | | gb_connection_init() can fail and will return proper error code in that case, but the caller is ignoring it currently. Fix that by properly handling errors returned from gb_connection_init() and propagating them to callers of gb_connection_bind_protocol(). Signed-off-by: Fabien Parent <fparent@baylibre.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: call gb_connection_exit() from gb_connection_destroy()Viresh Kumar2015-09-031-30/+30
| | | | | | | | | | | | | Both the routines are always called together and in the same sequence. Rather than duplicating this at different places, make gb_connection_destroy() call gb_connection_exit(). This also makes it more sensible, as gb_connection_init() is never called directly by the users and so its its counterpart shouldn't be called directly as well. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: Propagate error properlyViresh Kumar2015-09-031-1/+1
| | | | | | | | | We just got an error, propagate the exact return value instead of 0. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: no need to verify connection->protocolViresh Kumar2015-09-031-5/+0
| | | | | | | | | | | | | connection->protocol will always be valid in gb_connection_init() as it is called only from a single routine, after initializing the 'protocol' field. No need to check it again. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: convert connected dev_warn() to dev_err()Viresh Kumar2015-09-031-3/+3
| | | | | | | | | | | | Failures from control-connected operations are fatal errors and must be reported with dev_err() instead of dev_warn(). Fix it. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> [ johan: do not promote disconnected warnings, update summary ] Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: staticize gb_connection_init()Viresh Kumar2015-09-031-26/+26
| | | | | | | | | | Its not used by external users, mark it static. This required some shuffling of the code. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: add num_cports field to greybus hdFabien Parent2015-09-021-1/+1
| | | | | | | | | | | | | | This commit is doing the preparation work in order to get the number of cports supported from the UniPro IP instead of using a constant defined in a Kconfig file. Greybus host device is now holding the cport count, and all the code will now use this value instead of the constant CPORT_ID_MAX when referring to an AP's CPort ID. Signed-off-by: Fabien Parent <fparent@baylibre.com> [johan: es1 supports 256 cports, minor style changes ] Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: connection: Don't free resources freed by gb_connection_release()Viresh Kumar2015-08-131-3/+1
| | | | | | | | | We are already doing put_device() here and so don't need to free resources directly, except ida. Fixes: afde17fe0b61 ("greybus/connection: fix jump label on device_add failure") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: connection: Destroy wq on failureViresh Kumar2015-08-131-1/+3
| | | | | | | | Need to destroy the wq created earlier, do it. Fixes: d0f1778a6b67 ("greybus/connection: add a timestamp kfifo to track connection handoff") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: protocol: send own protocol version while requesting itViresh Kumar2015-08-121-13/+1
| | | | | | | | | | | | | | | | | The greybus specifications clearly say (for all protocols) that the sender is responsible for sending the highest version of protocol it supports, while it requests the same from the receiver. But the greybus code never followed that. Fix, this by always sending AP's version of the protocol, while requesting the same from svc/module. This also renames 'response' to 'version' in gb_protocol_get_version() as it is used for both request/response. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Merge branch 'master' into branch 'svc'.Greg Kroah-Hartman2015-08-111-2/+48
|\ | | | | | | | | | | | | This drags in the firmware driver, and the start of some loopback changes. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: connection: Send protocol version for firmware protocolViresh Kumar2015-08-111-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As per greybus specs, we need to send the protocol version for firmware protocol and so this special case Hack. Probably we should always send the protocol version AP supports and kill this hack completely. But then it requires updates to specs as well, and that should be done after some discussion. For now, add a FIXME for that and a special case for firmware protocol. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: protocol: Create request structure from within ↵Viresh Kumar2015-08-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gb_protocol_get_version() The version request can only send the version of protocol for which it is initiated and gb_protocol_get_version() has all the information to create the request structure. Replace the 'request' and 'request_size' arguments to gb_protocol_get_version() with a bool to know if the version information of the protocol should be sent or not. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: connection: add a timestamp kfifo to track connection handoffBryan O'Donoghue2015-08-111-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For the ES2 test activity it may be beneficial to have a performance metric that doesn't include any of the greybus stack malloc, workqueues etc. In order to faciltate, this patch adds a simple kfifo structure to hold two timestamp values. One timestamp will represent the last reasonable point a greybus outbound timestamp can be taken, the other timestamp will represent the first reasonable point an inbound timestamp can be taken. In order to facilitate this model, tracking the timestamps in the connection structure appears to be the best place to keep store of this data. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: connection: fix jump label on device_add failureBryan O'Donoghue2015-08-111-1/+1
| | | | | | | | | | | | | | | | | | On device_add() failure in gb_connection_create_range() we jump to err_remove_ida. Instead we should be jumping to err_free_connection, so change the flow to accomodate. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* | greybus: Merge branch 'master' into branch 'svc'.Greg Kroah-Hartman2015-08-111-23/+45
|\| | | | | | | | | | | | | This required some hand-tweaking in connection.c, hopefully I got it all correct... Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: protocol: Remove unnecessary params of gb_protocol_get_version()Viresh Kumar2015-08-111-6/+1
| | | | | | | | | | | | | | Some of the parameters are not really required, drop them. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: connection: request protocol version before initializing connectionViresh Kumar2015-08-111-7/+24
| | | | | | | | | | | | | | | | This can (should) be done from a common place as its required for most of the protocols. Do it. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
| * greybus: connection: disconnect connection on failures during initializationViresh Kumar2015-08-111-17/+27
| | | | | | | | | | | | | | | | | | | | Its possible for connection_init() to fail, in such cases the disconnected event must be sent to the module. It is missing currently, fix it. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* | greybus: Revert "connection: remove special check for svc cport id"Greg Kroah-Hartman2015-07-301-2/+4
| | | | | | | | | | | | | | This reverts commit 60b1d71fdfc2c5266051a1297df01ea0b1f3ba99 as we want the port number to be correct in the svc branch. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* | greybus: Merge branch 'master' into svc to keep it up to date.Greg Kroah-Hartman2015-07-301-4/+2
|\| | | | | | | Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>