Commit graph

141 commits

Author SHA1 Message Date
Till Varoquaux
3b75d8bd3b staging: greybus: loopback: fix a spelling error.
Successed -> succeeded.

Signed-off-by: Till Varoquaux <till.varoquaux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20200518051314.1785567-1-till.varoquaux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-27 10:18:09 +02:00
Greg Kroah-Hartman
ec0ad86817 staging: greybus: move core include files to include/linux/greybus/
With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 19:02:59 +02:00
Greg Kroah-Hartman
9c31973907 staging: greybus: loopback: Fix up some alignment checkpatch issues
Some function prototypes do not match the expected alignment formatting
so fix that up so that checkpatch is happy.

Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Johan Hovold <johan@kernel.org>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-7-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 19:02:55 +02:00
Yangtao Li
0022290f1e staging: greybus: convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17 14:24:42 +01:00
Cristian Sicilia
0668d5b592 staging: greybus: Added space between string concatenated
Some concatenated strings are now spaced.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05 09:47:02 +01:00
Rasmus Villemoes
c49d3f3fa6 staging: greybus: loopback.c: remove unused lists
gb_loopback_device::list_op_async is never used except for the
LIST_INIT. The ::list field appears to have a few more uses, but on
closer inspection the linked list of struct gb_loopbacks that it heads
is never used for anything, so there's no reason to maintain it, much
less to keep it sorted.

Reviewed-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05 15:32:45 +01:00
Rasmus Villemoes
b4fc4e8340 staging: greybus: loopback.c: remove unused gb_loopback::lbid
It's not obvious how the code prevents adding more than 31 elements to
the list and thus invoking undefined behaviour in the 1 << new_lbid
expression, and in practice causing ->lbid values to repeat every 32
elements.

But the definition of struct gb_loopback is local to loopback.c, and the
lbid field is entirely unused outside of this function, so it seems we
can just drop it entirely.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-11 12:10:32 +02:00
Greg Kroah-Hartman
863dbc52e7 staging: greybus: Remove redundant license text
Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:21 +01:00
Greg Kroah-Hartman
eb50fd3a22 staging: greybus: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:20 +01:00
Bryan O'Donoghue
262edc359d staging: greybus: loopback: convert loopback to use generic async operations
Loopback has its own internal method for tracking and timing out
asynchronous operations however previous patches make it possible to use
functionality provided by operation.c to do this instead. Using the code in
operation.c means we can completely subtract the timer, the work-queue, the
kref and the cringe-worthy 'pending' flag. The completion callback
triggered by operation.c will provide an authoritative result code -
including -ETIMEDOUT for asynchronous operations.

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reviewed-by: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Mitch Tasman <tasman@leaflabs.com>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:41:22 +01:00
Bryan O'Donoghue
44b02da392 staging: greybus: loopback: Fix iteration count on async path
Commit 12927835d2 ("greybus: loopback: Add asynchronous bi-directional
support") does what it says on the tin - namely, adds support for
asynchronous bi-directional loopback operations.

What it neglects to do though is increment the per-connection
gb->iteration_count on an asynchronous operation error. This patch fixes
that omission.

Fixes: 12927835d2 ("greybus: loopback: Add asynchronous bi-directional support")

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reported-by: Mitch Tasman <tasman@leaflabs.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Mitch Tasman <tasman@leaflabs.com>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:41:22 +01:00
Bryan O'Donoghue
5a70524bbf staging: greybus: loopback: Hold per-connection mutex across operations
Commit d9fb3754ec ("greybus: loopback: Relax locking during loopback
operations") changes the holding of the per-connection mutex to be less
restrictive because at the time of that commit per-connection mutexes were
encapsulated by a per-driver level gb_dev.mutex.

Commit 8e1d6c336d ("greybus: loopback: drop bus aggregate calculation")
on the other hand subtracts the driver level gb_dev.mutex but neglects to
move the mutex back to the place it was prior to commit d9fb3754ec
("greybus: loopback: Relax locking during loopback operations"), as a
result several members of the per connection struct gb_loopback are racy.

The solution is restoring the old location of mutex_unlock(&gb->mutex) as
it was in commit d9fb3754ec ("greybus: loopback: Relax locking during
loopback operations").

Fixes: 8e1d6c336d ("greybus: loopback: drop bus aggregate calculation")

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reviewed-by: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Mitch Tasman <tasman@leaflabs.com>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:41:22 +01:00
Arnd Bergmann
31408d16c2 staging: greybus/loopback: use ktime_get() for time intervals
This driver is the only one using the deprecated timeval_to_ns()
helper. Changing it from do_gettimeofday() to ktime_get() makes
the code more efficient, more robust against concurrent
settimeofday(), more accurate and lets us get rid of that helper
in the future.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:41:22 +01:00
Arnd Bergmann
8563a49c43 staging: greybus: remove unused kfifo_ts
As of commit 8e1d6c336d ("greybus: loopback: drop bus aggregate
calculation"), nothing ever reads from kfifo_ts, so there is no
reason to write to it or even allocate it any more.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-03 13:30:58 +01:00
Arushi Singhal
5c14312332 staging: greybus: compress return logic
Simplify function returns by merging assignment and return.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-27 14:24:49 +02:00
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