Commit graph

126 commits

Author SHA1 Message Date
Gioh Kim 563a8412c5 staging: greybus: fix symbolic permission coding style issues
Fix "Octal permissions are preffered than symbolic ones" issues.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:26:14 +01:00
Johan Hovold dbec27298b staging: greybus: operation: add generic timeout support
Add a struct timer_list to struct gb_operation and use that to implement
generic operation timeouts.

This simplifies the synchronous operation handling somewhat while also
providing a generic timeout mechanism that drivers can use for
asynchronous operations.

Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-09 11:58:56 +01:00
Johan Hovold 33b8807a6f staging: greybus: loopback: fix broken udelay
The loopback driver allows the user to set a minimum delay of up to one
second to be inserted between test iterations (i.e. request
submissions). The delay is currently specified in microseconds and is
implemented using udelay.

Busy looping for long periods is not just anti-social; udelay must not
be used for delays longer than a few milliseconds due to the risk of
integer overflow.

Replace the broken udelay with a usleep_range with a 100 us range for
short delays (< 20 ms) and otherwise revert to using msleep.

Fixes: b36f04fa94 ("greybus: loopback: Convert thread delay to microseconds")
Signed-off-by: Johan Hovold <johan@kernel.org>
Cc: stable <stable@vger.kernel.org> # 4.9+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-27 09:29:23 +01:00
Roman Sommer 1d3dfbd1dd staging: greybus: fix checkpatch unsigned warnings
Fix checkpatch warnings for parameter type unsigned in greybus.
Note that this patch does not fix all checkpatch warnings for the
affected files.

Signed-off-by: Christian Bewermeyer <christian.bewermeyer@fau.de>
Signed-off-by: Roman Sommer <roman.sommer@fau.de>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-16 18:08:56 +01:00
Abdul Rauf a1f10771ca staging: greybus: fix checkpatch braces not necessary warning
Fix the following warnings:
braces {} are not necessary for any arm of this statement

Signed-off-by: Abdul Rauf <abdulraufmujahid@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-16 18:08:56 +01:00
Bryan O'Donoghue a072a72da9 staging: greybus: loopback: use gb_loopback_async_wait_all don't spin
Currently the greybus-loopback thread logic spins around waiting for
send_count == iteration_max which on real hardware doesn't make a
difference to us but in simulation is excruciatingly slow, anti-social and
bad manners. Use the existing gb_loopback_async_wait_all() function to gate
continuing when the send_count == iteration_max and go to sleep until
there's something worthwhile to-do.

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-03 16:45:01 +01:00
sayli karnik 82af03f7b9 staging: greybus: Use setup_timer function
This patch uses setup_timer function instead of initializing timer with the
function and data fields.

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-23 19:00:43 +02:00
Axel Haslam e854ff58ed greybus: loopback: add runtime pm support
Add runtime pm to the loopback driver so that
the module wakes up from suspend while a test
is executed.

Testing Done: Let the module enter standby and
execute a loopback test.

Signed-off-by: Axel Haslam <haslam_axel@projectara.com>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
2016-07-14 16:53:55 -05:00
Sandeep Patil e54b106dd1 greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhere
The 'gpbridge' name didn't relaly reflect what the bus is; which
is a bus for bridged-phy devices. So, rename all instances
of 'gpbridge' to more appropriate 'gbphy'

Testing Done:
Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices
until I change the library to reflect this change.

Signed-off-by: Sandeep Patil <patil_sandeep@projectara.com>
Suggested-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-19 10:09:13 -07:00
Johan Hovold b1f8bfea65 greybus: loopback: remove unsupported version request
Remove the unsupported version request from the loopback-driver request
handler.

Unsupported requests are already handled and logged using the default
case.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:27:05 -07:00
Bryan O'Donoghue fece9c87cb greybus: Ensure gb->mutex is held when adding timer
Currently in loopback on the async path we issue an operation and then add
a timer to time-out that operation should it fail to complete. Looking at a
backtrace given in its feasible op_async->pending can be true and
del_timer() can run before add_timer() has run. In the callback handler we
already hold gb->mutex. This patch fixes that potential race by ensuring we
hold gb->mutex both when we are adding and when we are removing the
relevant timer.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-and-tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-16 21:49:31 -07:00
Alexandre Bailon 1dc8d3d7c5 greybus: loopback: Fix broken loopback min values
Currently, when a loopback test completely fail,
loopback will return 4294967295 for every min value.
Return 0 instead of 4294967295 in such case.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-16 21:49:31 -07:00
Alexandre Bailon 01480ba336 greybus: loopback: Fix broken synchonous test
loopback driver use the send_count variable to know the test progress.
The test may be stopped or change but this variable is never cleaned.
Such situation may break the next run.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-09 22:31:32 -08:00
Alexandre Bailon 58a527afff greybus: loopback: round closest the sixth decimal
The original round was removed becaused it was rounding
the integer whereas we had decimals.
Round the sixth decimal.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-09 22:31:32 -08:00
Alexandre Bailon 89ec14ceae greybus: loopback: Fix warning on 32-bit build
gb_loopback_ro_avg_attr() is using "/" to divide two 64-bit integer,
causing a reference to __aeabi_uldivmod() that is not availalbe on 32-bit.
Instead, use do_div().

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-09 22:31:32 -08:00
Johan Hovold 41993cd54f greybus: loopback: fix double error count
Make sure not count errors during asynchronous tests twice (first in
the timeout handler then again in the completion handler) to avoid
obviously broken error stats such as:

$ loopback_test -i 1000 -t transfer -p -o 200000 -c 64 -x -s 2000

1970-1-1 1:3:35
 test:                  transfer
 path:                  gb_loopback0
 size:                  2000
 iterations:            1000
 errors:                1998
 async:                 Enabled
 requests per-sec:      min=0, max=0, average=0.310556, jitter=0
 ap-throughput B/s:     min=0 max=4026 average=1254.647461 jitter=4026
 ap-latency usec:       min=12803 max=12803 average=12803.000000 jitter=0
 apbridge-latency usec: min=89 max=89 average=89.000000 jitter=0
 gpbridge-latency usec: min=294 max=294 average=294.000000 jitter=0

where we supposedly have more errors than iterations (operations
initiated).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-03 10:02:48 -08:00
Axel Haslam 39c2787b12 greybus: Notify user space only when the test finished.
Currently, user space is notified for every message sent,
but this is not really needed and does not work in the async case
where all messages are sent from the start.

Instead, notify userspace only when all the transfers are complete.
This allows userspace to wait in a poll loop and wakeup only when
the test is finished.

Also, don't use the bundle kobj to send the notification it is
the loopback device that contains the loopback attributes.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-29 14:51:38 -08:00
Alexandre Bailon fb37f137b7 greybus: loopback: Fix averaging
Currently, we are adding 0.5 to the average to round the average.
But we are using the remainder to calculate the decimal, so we do not
need to round the average.
In addition, use a u64 type for the remainder to avoid overflow
that might happen when stats->sum value is too big,
usually for requests per seconds and the throughput.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 17:05:31 -08:00
Alexandre Bailon ab81bb9c68 greybus: loopback: Fix throughput calculations
Throughput and requests per second calculations are broken for
asynchronous request.
Instead of calculate the throughput for each iteration,
calculate it once at the end of the test.
In addition, update every seconds the min and the max
for throughput and requests per second.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 17:05:31 -08:00
Alexandre Bailon d9048d8c96 greybus: loopback: Fix incoherency in calculations in the case of error
Currently, in case the case of error, statistics are updated for
asynchronous but not for an asynchronous operation.
Do not update the statistics in the case of error.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 17:05:31 -08:00
Alexandre Bailon d97bbf3ed6 greybus: loopback: Fix calculations error for ping transfers
For the async ping transfer, statistics are counted twice,
once after the after the gb_loopback_async_operation() and
once in the callback.
Only keep the one in the callback.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 17:05:31 -08:00
Greg Kroah-Hartman 2422d36696 greybus: Revert "gb_loopback: Fix throughput calculations"
This reverts commit 9b9b046af237f5674c2f7ca991dc62332b2d4041

Bryan wants more feedback first.

Reported-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-17 16:30:38 -08:00
Alexandre Bailon c53b0b27d5 greybus: gb_loopback: Fix throughput calculations
Throughput and requests per second calculations are broken for
asynchronous request.
Instead of calculate the throughput for each iteration,
calculate it once at the end of the test.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-17 15:16:42 -08:00
Viresh Kumar e82a11dcbd greybus: loopback: convert to bundle driver
Convert the legacy loopback protocol driver to a bundle 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>
2016-02-15 14:53:43 -08:00
Johan Hovold 8d46ec4981 greybus: bundle: remove private data field
Remove the private data field from the bundle structure as it is no
longer needed. Bundle drivers can use the driver data field in the
bundle device.

Update the only current user to use the connection private data until it
has been converted to a bundle driver.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-11 21:46:03 -08:00
Johan Hovold 8923c5b59f greybus: loopback: add missing pr_fmt
Add missing pr_fmt so we can at least tell what module the sole
remaining pr_err was from.

Testing Done:
Tested on DB3.5 with the generic bridge firmware on APB2.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-11 21:44:17 -08:00
Bryan O'Donoghue 8e3fba55d3 greybus: loopback: Add asynchronous backoff
A specific request from the firmware people is the ability to back-off from
sending more asynchronous operations once a specific number of operations
are in-flight.

This patch adds that ability - with a new sysfs parameter
'outstanding_operations_max' which controls the maximum number of
operations that can be outstanding/in-flight at any time.

When outstanding_operations_max contains a non-zero value and asynchronous
operations are being used - we will back-off until the completion counter
is < outstanding_operations_max. Tested in both synchronous and
asynchronous mode and with gb_loopback_connection_exit() interrupting
in-flight operations.

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-11 16:18:40 -08:00
Bryan O'Donoghue 36f241fff4 greybus: loopback: Wait for all async operations to complete on exit
On gb_loopback_connection_exit() we should ensure every issued asynchronous
operation completes before exiting connection_exit(). This patch introduces
a waitqueue with a counter which represents the number of incomplete
asynchronous operations. When the counter reaches zero connection_exit()
will complete. At the point which we wait for outstanding operations to
complete the connection-specific loopback thread will have ceased to issue
new operations. Tested with both synchronous and asynchronous operations.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-11 16:18:34 -08:00
Bryan O'Donoghue c7aae4e613 greybus: loopback: Retrun -ENOMEM if operation allocation fails
If operation allocation fails we should return -ENOMEM in the asynchronous
operation send routine. If we don't return here then the
gb_loopback_async_operation_put() later can dereference a NULL pointer if
the previous gb_operation_create() failed.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-11 16:16:01 -08:00
Bryan O'Donoghue 578a0ab8dd greybus: loopback: Drop NULL check on container_of pointer
container_of cannot return NULL and the pointer passed to this context uses
reference counter bumped inside a spinlock, so the base pointer will be
valid at this point.

Suggested-by: Johan Hovold <johan@hovoldconstulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-11 16:16:01 -08:00
Axel Haslam 079fa32ba5 greybus: loopback: register a struct device.
Instead of having the loopback attributes in the bundle device,
Add a struct device to the gb_loopback struct and register it on
connection_init, deregister it at connection_exit, and move the
loopback attribute group over to the new device.

Use device_create_with_groups to create sysfs attributes
together with device.

Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-11 16:04:40 -08:00
Axel Haslam 3647a313de greybus: loopback: remove mask attribute
The mask attribute is not used on the driver anymore and can be
removed.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-10 11:21:02 -05:00
Bryan O'Donoghue f42a6891d1 greybus: loopback: Ensure we reset stats once and once only
9445c54c ('greybus/loopback: drop bus aggregate calculation') removed the
aggregation of data in-kernel but instead of dropping the reset of
aggregate stastics, converted that reset into a second reset of the
connection-level stats. While this doesn't result in anything bad it's
also definitely a dumb thing to be doing, so, drop it now.

Also ensure we reset the bridge-specific tracking variables at least once.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-07 14:32:20 -05:00
Bryan O'Donoghue b36f04fa94 greybus: loopback: Convert thread delay to microseconds
Currently the loopback code allows a delay between operations specified in
milliseconds. Having added asynchronous bi-directional support to loopback
its obvious that the delay value would be far more useful specified in
microseconds than milliseconds. So, this patch makes the necessary
conversion.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-07 14:32:20 -05:00
Bryan O'Donoghue 12927835d2 greybus: loopback: Add asynchronous bi-directional support
A particular ask from the firmware people for some time now has been the
ability to drive multiple outstanding bi-directional operations from
loopback to loopback Interfaces. This patch implments that change.

The approach taken is to make a call to gb_operation_send() and have
loopback capture the completion callback itself, with a parallel timer to
timeout completion callbacks that take too long. The calling thread will
issue each gb_operation_send() as fast as it can within the constraints of
thread-safety.

In order to support this addition the following new sysfs entries are
created on a per-connection basis.

- async
  Zero indicates loopback should use the traditional synchronous model
  i.e. gb_operation_request_send_sync().

  Non-zero indicates loopback should use the new asynchronous model i.e.
  gb_operation_send()

- requests_completed
  This value indicates the number of requests successfully completed.

- requests_timedout
  This value indicates the number of requests which timed out.

- timeout
  The number of microseconds to give an individual asynchronous request
  before timing that request out.

- timeout_min
  Read-only attribute informs user-space of the minimum allowed timeout.

- timeout_max
  Read-only attribute informs user-space of the maximum allowed timeout.

Note requests_completed + requests_timedout should always equal
iteration_max, once iteration_count == iteration_max. Also, at this time we
support either synchronous or asynchronous operations in one set of
transactions.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-07 14:32:20 -05:00
Bryan O'Donoghue 2e238d71ed greybus: loopback: Convert cross-thread mutex to spinlock while relaxing connect locks
This patch converts the cross-thread mutex used to synchronize threads with
respect to each other to a spinlock. This is done to enable taking of locks
in the following patches while in atomic context. A small re-order of
locking in connection setup/tear-down is done to minimize the amount of
time spent in spinlock_irqsave().

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-07 14:32:20 -05:00
Viresh Kumar 2f3db927cd greybus: don't use %h and %hh for printing short and char variables
Because the width of our fields is already known, we can use %0Nx (for
hex) to print N bytes and %u (for unsigned decimal), instead of using %h
and %hh, which isn't that readable.

This patch makes following changes:
- s/%hx/%04x
- s/%04hx/%04x
- s/%hhx/%02x
- s/%02hhx/%02x
- s/%hhu/%u
- s/%hu/%u
- s/%x/%02x for u8 value (only at a single place)

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
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>
2015-12-04 16:23:36 -08:00
Bryan O'Donoghue 8e1d6c336d greybus: loopback: drop bus aggregate calculation
At some point we had a statement in a Jira work item to pull out 'bus
level' data from greybus and to have messages to different interfaces be
synchronized with respect to each other. Synchronizing threads with respect
to each other is slow and it turns out we can get the same 'bus level'
stastics by making the user-space test application smarter.

That's great news for the in-kernel code since it means we can cut out a
whole lot of code to-do with calculating 'bus level' aggregate data and we
can stop forcing threads to hit a rendezvous before sending out another
loopback operation.

So this patch drops bus level aggregates in favour of doing that in
user-space. It subtracts a lot of code and cycles that in practice nobody
cares about anyway.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-03 15:37:24 -08:00
Bryan O'Donoghue 9673dcebe4 greybus: loopback: Drop unused timeval variables
start and end aren't used and should be dropped.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-03 15:37:24 -08:00
Bryan O'Donoghue d6a1a3b5ea greybus: loopback: Move latency_ts initialization to transfer routine
Initializing the bridge specific latency variables is only relevant to the
transfer operation, so make it loopback-transfer specific.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-03 15:37:24 -08:00
Bryan O'Donoghue d9fb3754ec greybus: loopback: Relax locking during loopback operations
Currently a per-connection mutex is held during calls to
gb_operation_send_sync. It is not necessary to hold this lock and later
patches supporting multiple-outstanding bi-directional operations need to
take the per-connection lock and the gb_dev level lock. Since gb_dev must
always be taken before per-connection locks, it is both desirable and safe
to drop the lock now.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-03 15:37:24 -08:00
Johan Hovold dc3da5db28 greybus: loopback: remove endo reference
Replace reference to "endo0" and generate the raw-latency filename based
on the host-device bus id instead.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Johan Hovold 8b0df4b2ea greybus: interface: make interfaces children of host devices
Make interfaces child devices of host devices.

The new interface device name is "<bus_id>-<intf_id>", where bus_id is
the dynamically allocated bus id for the host device and intf_id is the
svc-allocated interface id.

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
Bartosz Golaszewski 81ad699461 greybus: loopback: allocate a response even for a 0-byte request
If payload length of a transfer packet is 0, no response is allocated.
Send a well-formed response even in that case.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:02:41 -08:00
Alexandre Bailon 9864756be7 greybus: loopback: fix invalid response size
The size of timestamps is not taken into account, which makes the
loopback driver in the firmware drop invalid packages.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:02:41 -08:00
Johan Hovold 0d1d6ee209 greybus: loopback: fix layer violation
A bundle (protocol) driver has no business creating sysfs entries for an
ancestor device.

Move the sysfs entries to the bundle device for now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Greg Kroah-Hartman d9a9ea1b88 greybus: loopback: use the bundle struct device instead of the connector
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 loopback driver to use the bundle pointer instead
of the connection pointer.

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 1ec5843ee9 greybus: loopback: capture and present firmware supplied latencies
In order to provide deep inspection of the greybus/UniPro system
instrumentation of

1. APBridge's view of UniPro latency
2. GPBridge's view of internal firmware-only latency

have both been added and reported to the AP in the transfer loopback
response header. When this data are present we latch and average it over
the number of requested cycles, presenting it to user-space via sysfs.

This patch adds the following sysfs entries for each loopback CPort

- apbridge_unipro_latency_avg_con
- apbridge_unipro_latency_max_con
- apbridge_unipro_latency_min_con
- gpbridge_firmware_latency_avg_con
- gpbridge_firmware_latency_max_con
- gpbridge_firmware_latency_min_con

and the following sysfs entries representing the average values across all
available CPorts

- apbridge_unipro_latency_avg_dev
- apbridge_unipro_latency_max_dev
- apbridge_unipro_latency_min_dev
- gpbridge_firmware_latency_avg_dev
- gpbridge_firmware_latency_max_dev
- gpbridge_firmware_latency_min_dev

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-15 11:32:07 -07:00
Bryan O'Donoghue e6227ee647 greybus: loopback: add tracker variables to hold firmware timestamps
This patch adds tracker variables to hold the incoming firmware derived
timestamps where apbridge_latency_ts will contain the APBridge's view of
the UniPro turn-around time and gpbridge_latency_ts will contain the
GPBridge's view of it's own internal latency. Both values are reported
in microseconds.

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 fd58926ebe greybus: loopback: send command to APBridge to tag throughput
A USB vendor command has been added to APBridge to allow for tagging of
specific CPort identifiers with internal timing data, specifically geared
towards capturing and understanding latencies in the UniPro fabric. This
patch sends a command to APBridge for each known loopback CPort to tag data
as appropriate. Subsequent patches will present this data to user-space for
ongoing integration analysis.

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