Commit Graph

95 Commits

Author SHA1 Message Date
Johan Hovold 3094f94773 greybus: connection: add support for high-priority connections
Add connection flag to indicate that a connection has high priority.

For the SVC and control connections this may be used by the host-device
driver as a hint to allocate dedicated DMA channels or to use polling to
avoid message congestion.

We also allow drivers to set this flag on their connections, even though
we currently have no use case for this (and the host-device driver is
again free to ignore it).

Note that this mechanism can be used to indicate also high-bandwidth
connections (e.g. wanting larger buffers or dedicated endpoints), but
that that should be done using a separate high-bandwidth flag rather
than overloading the high-priority flag.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-24 16:22:30 -07:00
Johan Hovold 1ba30c3309 greybus: connection: prevent drivers from specifying core flags
Prevent drivers from specifying core flags (currently only
GB_CONNECTION_FLAG_CONTROL) when creating connections.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-24 16:22:30 -07:00
Viresh Kumar 64060fe954 greybus: gbphy: Remove protocol specific version handling
We should be using the generic version handling at bundle level, instead
of at protocol level for bridged PHY devices as well.

The bundle version handling is already in place, though it is *not* used
today as we haven't bumped the version of control protocol yet.

Remove protocol specific handling for bridged PHY devices.

Tested on EVT 1.5 with gpbridge-test module. No nuttx changes are
required with this.

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>
2016-05-31 22:02:58 -07:00
Johan Hovold 55742d2a07 greybus: interface: implement generic mode-switch functionality
Add a generic interface for bundle drivers to use to request that a
mode switch is carried out on its behalf.

Mode switching involves tearing down all connections to an interface,
sending a unidirectional mode-switch request, and waiting for a mailbox
event that triggers deferred control connection reset and re-enumeration
of the interface. In case of a timeout waiting for the interface mailbox
event, or on other errors, the interface is powered off.

All of this needs to be done by core from work-queue context in order
not to block incoming SVC requests and bundle-device tear down. Care
must also be taken to serialise against concurrent module removal events
and eject requests.

Special handling of legacy mode-switching is also added in order to
continue to support the ES3 bootrom.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-27 12:24:17 -07:00
Johan Hovold 3de5acfafb greybus: connection: implement proper connection closure
Implement proper connection closure, which includes sending ping
requests on the connection being tore down while coordinating with the
remote interface as well as the SVC.

This specifically implements the new ping operation, which in case of
offloaded connections is handled by the host-device driver in an
implementation-defined manner through a new callback.

Note that the normal connection tear-down procedure is executed in case
of failed connection establishment due to failed connected operation.
Specifically, the disconnecting request is sent also in case the
connected operation never succeeded. This is needed since the interface
may have enabled FCT flow upon receiving the connected request.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-27 12:24:17 -07:00
Johan Hovold 1430cc920a greybus: connection: remove unused invalid state
Remove the unused legacy INVALID connection state.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-27 12:21:16 -07:00
Johan Hovold aca7aab39a greybus: connection: add control connection flag
Add control connection flag which will be set for control connections.

Also add a helper function to test if the flag is set.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-27 12:19:29 -07:00
Johan Hovold 7aefe7918f greybus: core: avoid I/O to disconnected interfaces
Add new helper to disable connections to interfaces that have already
been disconnected (e.g. forcibly removed).

The connection tear-down procedure differs enough depending on whether
the interface is still present or already gone to warrant a dedicated
helper. This will become more obvious with the new tear-down procedure,
which involves I/O on the connection being tore down.

This also simplifies handling of the legacy bootrom, which does not
support the new tear-down operations.

Specifically, this allows us to remove the early control-connection
tear down during interface disable, and also avoids some error messages
currently printed during legacy mode switch (i.e. bootrom
boot-over-UniPro) and forcible removal.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-27 12:19:29 -07:00
David Lin 428888a2b6 greybus: legacy: remove legacy driver support
This patch removes the greybus legacy driver support

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-20 16:47:30 -07:00
Johan Hovold 045d356114 greybus: es2: add support for CDSI1 allocation
Use the new CPort-allocation callbacks to allow for rudimentary resource
management of the CDSI CPorts.

How to manage offloaded resources in a generic fashion is yet to be
determined, but this minimal implementation will allow core to manage
the camera data connection so that the current camera-driver hacks can
be removed. This is specifically required to be able to implement proper
connection closing and for power management.

Note that the CDSI CPorts can not (currently) be reset through the
USB vendor request.

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>
2016-05-13 15:32:48 +02:00
Johan Hovold 781ac8662f greybus: connection: add helper for creating offloaded connection
Add helper for creating offloaded connection.

This can later be extended to support more elaborate resource
management.

Also fix a minor white space issue.

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>
2016-05-13 15:30:05 +02:00
Johan Hovold ca1f8f8090 greybus: connection: add offloaded connection flag
Add an offloaded connection flag, which is used to mark a connection as
offloaded and prevent drivers from initiating operation over it.

This will be used for the audio and camera data connections.

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>
2016-05-13 15:30:05 +02:00
Johan Hovold 0e9b41ab98 greybus: connection: add no-flow-control connection flag
Add a no-flow-control connection flag, which is set for connection that
should not have any flow-control feature enabled.

This flag is specifically set for all connections to the legacy ES3
bootrom, and will also be used by the camera driver eventually.

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>
2016-05-13 15:30:05 +02:00
Greg Kroah-Hartman 418f3dab84 greybus: connection: add functions to get/set private data
Add gb_connection_get_data() and gb_connection_set_data() to get and set
the private data of a connection, instead of "open coding" it
everywhere.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-22 16:47:28 -04:00
Johan Hovold 64a6d13884 greybus: connection: add CSD connection flag
Add CSD connection flag that can be specified when allocating a
connection to enable Controlled Segment Dropping in favour of E2EFC
which is enabled by default.

Note that most connections are expected to have E2EFC enabled.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-04 18:26:08 -08:00
Johan Hovold cb033188d8 greybus: connection: add connection-flag interface
Add interface for associating a flag bitmask with a connection when
creating it.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-04 18:26:08 -08:00
Johan Hovold f7ee081e31 greybus: connection: set request handlers at creation
Set the connection request handler at creation rather than when enabling
the connection.

This is possible now that connections are created by the drivers that
use them rather than by core at manifest parsing time.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:46:38 -08:00
Johan Hovold 63cf52f79b greybus: connection: remove legacy protocol id from core
Remove legacy protocol-id field that is only used by the legacy-protocol
driver from the connection structure.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:46:38 -08:00
Johan Hovold 96c2af5c6b greybus: connection: rename connection-create interface
Drop the _dynamic suffix from the exported interface that drivers use to
create connections.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:45:09 -08:00
Johan Hovold 8cff6c6473 greybus: connection: simplify connection-creation interface
Simplify the exported generic interface for creating dynamic
connections.

Since all driver connections will have a bundle we can drop the
redundant interface parameter.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:45:09 -08:00
Johan Hovold e4c16f8b03 greybus: connection: drop the legacy protocol-id parameter
The protocol-id parameter is only used by the legacy driver so remove
it from the generic interface and move it to the legacy driver until it
can be removed completely.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:45:09 -08:00
Johan Hovold 59507e2612 greybus: connection: add helper to create control connections
Add dedicated helper to create control connections.

This will allow us to simplify the generic (dynamic) interface.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:45:09 -08:00
Johan Hovold bafe3f6790 greybus: connection: drop protocol parameter from static interface
Drop legacy protocol parameter from static connection interface.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-21 22:45:09 -08:00
Johan Hovold 96a9b9b0eb greybus: connection: remove broken protocol-version handling
Remove the broken legacy protocol-version handling from core and move it
to the legacy driver instead.

Note that version handling has always been broken as legacy protocols
were looked up and bound to connections before the connections were
enabled and version negotiation could take place (over that very
connection). Document that in the legacy driver as well.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:17:13 -08:00
Johan Hovold 50dfb87865 greybus: connection: move legacy-protocol handling to legacy driver
Move legacy protocol and connection handling to the legacy driver.

Rename the former global functions using a common legacy_ prefix.

Note that all legacy protocols suffer from a connection initialisation
race in that the protocol-specific initialisation, which includes
allocation of protocol-specific state containers, can not happen until
*after* the connection has been enabled. This is a major flaw in the
original design that we can now finally address by converting the legacy
protocol drivers into proper bundle (class) drivers.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:17:13 -08:00
Johan Hovold beb6b7fede greybus: connection: add helper to disable incoming operations
Add helper to disable and flush incoming operations.

This is intended to be used by core to flush any incoming requests
before calling driver disconnect, but could potentially later be
exported for driver use as well.

Note that we currently flush all incoming operation and allow the
request handlers to run, but cancel any responses sent. This may need to
be refined later.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold 570dfa7c55 greybus: connection: add unidirectional enabled state
Add a new connection state ENABLED_TX in which only outgoing operations
are allowed.

This allows drivers to query the device during probe before allocating
their state containers without having to worry about racing incoming
requests.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold 23268785b2 greybus: connection: make connection enable/disable thread safe
Add connection mutex to protect connection enabling and disabling.

This is needed to eventually allow drivers to manage the state of their
connections during operation (i.e. post probe and pre disconnect).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold 81fba24969 greybus: connection: always cancel operations on connection disable
Always cancel all operations on connection disable and remove the now
unused DESTROYING state.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold bfa9a5e2d0 greybus: connection: add per-connection request handlers
Add a connection request-handler field to struct gb_connection that is
set when the connection is enabled.

This is a step towards removing the legacy protocol abstraction from
core, and will also be used to implement unidirectional connection
states (e.g. only outgoing operations are allowed).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold 6d3d95042e greybus: connection: rename legacy init and exit functions
Rename legacy connection init and exit functions.

This is a step towards removing the legacy-protocol handling from core.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:12:40 -08:00
Johan Hovold 4d0bee1125 greybus: connection: fix connection-state handling
Set connection state to ENABLE before sending the control connected
message, and set state DISABLE after sending the control disconnected
event.

Remove the now unused ERROR connection state.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-12 18:17:35 -08:00
Johan Hovold 2c848944c1 greybus: hd: make svc-connection life time coincide with host-device
Create the svc-connection as part of the host device, and destroy it in
the host-device destructor.

The svc-connection is enabled when registering the host device, and
disabled when the host device is deregistered.

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>
2015-12-08 15:31:14 -05:00
Johan Hovold 0bf1f24419 greybus: connection: separate connection creation and enabling
Separate connection creation from enabling.

This will ultimately allow connection structures to be created while
parsing manifests, but the connections to not be enabled until a driver
is bound.

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>
2015-12-08 15:31:14 -05:00
Johan Hovold 2d54e4db4e greybus: bundle: kill gb_bundle_bind_protocols
Remove gb_bundle_bind_protocols() that was used to iterate over all
registered bundles and bind protocols to them should a protocol become
available post bundle creation.

The protocol abstraction as a generic construct is going away in favour
of class drivers. Connections will be setup when a class driver is
probed, and driver modules can be loaded on-demand by user space based
on uevents and modalias.

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>
2015-12-08 15:31:14 -05:00
Johan Hovold 5ef323846f greybus: hd: fix svc-connection handling
Create the svc connection when registering the host-device and
remove the current svc connection hacks that "upgraded" the svc
connection once the endo id and ap interface id was known.

Note that the old implementation was partly based on a misunderstanding
as it was the remote interface id, rather than the local AP interface id,
that used to define a connection (but we also needed the endo_id).

The remote interface is no longer needed as static connections, such as
the svc connection, are now simply defined by the host-device and host
cport id.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Johan Hovold 729b260a67 greybus: connection: add name field
Add a name field to connections that can be used in log messages.

A connection always belongs to a host-device (bus) and can be uniquely
identified by its host-device cport id, but include remote interface and
cport id nonetheless on the following format:

	<hd_cport_id>/<intf_id>:<cport_id>

The remote interface and cport id will be zero for static connections.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Johan Hovold 4ec1574ae9 greybus: connection: kill GB_PROTOCOL_SKIP_SVC_CONNECTION
Add helper to determine whether a connection is static, and remove the
protocol flag GB_PROTOCOL_SKIP_SVC_CONNECTION.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Johan Hovold 2566fae6a5 greybus: connection: clean up connection-creation interface
Clean up the connection-creation interface by clearly separating our two
types of connections: static and dynamic.

Add two convenience functions for creating static and dynamic connections.

A static connection is a pre-setup connection that is defined by a host
device and a host-device cport id. Specifically, the remote interface or
cport id need not be known. The SVC connection is a static connection.

A dynamic connection is defined by a host device and a remote interface
and cport id. This is our normal connections where the host-device cport
is (generally) allocated dynamically.

Note that the new generic interface is marked static, but can be
exported later to allow dynamic connections to be created also from
fixed host-device cports (e.g. for CSI).

Also note that a connection of either type is uniquely identified by its
host-device and host-device cport id once created.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Johan Hovold 582b3a1392 greybus: connection: drop parent parameter from connection create
The parent parameter was only used for debug messages and to name the
connection workqueue. Use the host-device device for this instead.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:27:06 -08:00
Johan Hovold 2537636aba greybus: hd: rename host-device structure
Rename host-device structure gb_host_device to match our other
structures.

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>
2015-11-04 20:25:57 -08:00
Johan Hovold fcfc762f17 greybus: connection: kill gb_hd_connections_exit
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>
2015-11-04 20:20:23 -08:00
Greg Kroah-Hartman b750fa3370 greybus: connection: remove 'struct device' from 'struct gb_connection'
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>
2015-10-19 12:09:10 -07:00
Bryan O'Donoghue e7e2efc438 greybus: connection: add latency tag enable/disable callbacks
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>
2015-10-15 11:31:08 -07:00
Bryan O'Donoghue d090446a91 greybus: loopback: drop dependency on internal timestamps
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>
2015-09-23 12:39:24 -07:00
Fabien Parent 50bb9ccaa0 greybus: connection: fail to bind if connection init fails
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>
2015-09-03 14:46:52 +02:00
Viresh Kumar fda2381bd2 greybus: connection: call gb_connection_exit() from gb_connection_destroy()
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>
2015-09-03 14:45:09 +02:00
Viresh Kumar 6300968991 greybus: connection: staticize gb_connection_init()
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>
2015-09-03 14:36:31 +02:00
Bryan O'Donoghue a1a4a29cb9 greybus: connection: add a timestamp kfifo to track connection handoff
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>
2015-08-11 20:00:40 -07:00
Viresh Kumar d653f4b191 greybus: connection: Save major/minor supported by module
Save major/minor number supported by the module inside connection
structure, as this can be used later.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 17:53:43 -07:00