Commit Graph

102 Commits

Author SHA1 Message Date
Bryan O'Donoghue c8a657ba3f greybus: hd: Add TimeSync APBridge commands
This patch adds a number of USB Vendor commands to es2.c to enable TimeSync
in the bridge.

Adds:
- es2.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
			 u32 refclk);
  Commands APBx to enable timers and clocks to track a pulse-train of
  incoming TIME_SYNC strobes with strobe_delay microseconds between each.
  Provides the reference clock the AP is using to track FrameTime. It is
  the responsibility of APBx to adequately track the FrameTime based on
  the indicated AP refclk. Once this command has succeeded APBx may not
  transition to a low-power state were FrameTime counters stop.

  This function is initiated from the timesync worker thread logic when
  re-synchronizing frame-time throughout the system.

  TimeSync is at this time enabled for all APBx active in the system i.e.
  currently APB2 will not receive TimeSync commands until it becomes a
  registered host-device in Greybus.

- es2.c::timesync_disable(void)
  Commands APBx to discontinue tracking of FrameTime. After this operation
  completes APBx may transition to a low-power state where timer-clocks
  stop operating.

- es2.c::timesync_authoritative(u64 *frame_time)
  Provides an authoritative time for each TIME_SYNC strobe to APBx.
  APBx must align its local FrameTime to the authoritative clock.

- es2.c::timesync_get_last_event(u64 *frame_time)
  Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 11:39:57 -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 e7b848c288 greybus: es2: clean up cport-reset handling
Move handling of CPort-reset exceptions to the reset handler.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 15:30:05 +02:00
Johan Hovold 0506150766 greybus: es2: clean up CDSI CPort reservation
Clean up the CDSI CPort reservation by adding a host-device helper and
CPort defines.

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 be5d01f10b greybus: es2: fix probe error handling
Make sure to return -ENODEV when the expected endpoints are missing and
stop relying on a default error.

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
Viresh Kumar 2437f1c6b5 greybus: es2: move ap_disconnect() below ap_probe()
This makes it more readable, as the functions are present in this order
in the structure as well. Also keeping these two makes more sense.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar 62de6e0a72 greybus: es2: don't protest when getting -ENOENT/ESHUTDOWN USB errors
-ENOENT or -ESHUTDOWN happens when the urbs are being killed from
->disconnect() callback.  Don't complain to userspace about this, as the
user will see this on es2 module removal.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The driver doesn't throw anymore errors like:
"urb cport in error -2 (dropped)".

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar ecdd3a2d59 greybus: es2: disable cport-in after remove greybus host device
This allows greybus to do operations before being removed.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The driver removes the greybus host device successfully before
disabling the urbs. The errors are still coming ("urb cport in error -2
(dropped)"), but with an error value -2 (ENOENT) instead of -108. And
that happens while the urbs are disabled, not while doing greybus
operations.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
Viresh Kumar a0f997bd5d greybus: es2: Allow proper release of greybus host device
The usb core disables the Interface prior to calling ->disconnect() for
the usb driver. That disallows the es2 driver to remove the greybus host
device and every entity below it in a clean way, as the greybus core may
want to do few operations over the usb connection before getting
removed.

And so we see bunch of errors while we remove the es2 module, like:
"urb cport in error -108 (dropped)"

The usb core has a special per-driver flag, 'soft_unbind', for such usb
drivers. If this flag is set by a driver, the usb core doesn't disable
the Interface prior to calling ->disconnect().

Set that flag for es2.

Tested by removing the gb-es2.ko module on both EVT1.5 and qemu with
gbsim. The interface isn't disabled by the core and the driver is still
able initiate greybus operations over the Interface. This can be
properly tested only after the next patch which removes the greybus host
device before disabling the urbs.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 16:11:15 +09:00
David Lin 05a849191f greybus: es2: Fix apb_log null pointer exception
Read on apb_log causes null pointer exception due to the missing es2
device pointer passing to the debugfs.

Testing done:
- Enable apb_log and cat it

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:41:08 +09:00
Johan Hovold aa2a5459aa greybus: hd: rename CPort-features callbacks
Rename the CPort-features callbacks, that are not just used to enable
FCT flow, to the more descriptive cport_features_enable/disable.

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
Fabien Parent e70055b3fb greybus: es2: implement the fct flow control requests
Implement the control requests enabling/disabling the flow of FCT on APBA.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-24 17:21:58 -08:00
Johan Hovold 478ce7203c greybus: es2: fix cport-count error handling
Make sure to check for short transfers when retrieving the bridge cport
count.

Also clear the request buffer when allocating it.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-17 15:16:42 -08:00
Greg Kroah-Hartman e527338104 greybus: APBridge: move APBridge request protocol to a common .h file
This moves all of the APBridge request protocol commands that are
currently used to a common .h file for everyone to be able to use them
in the future, where needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
2016-01-12 11:12:25 -08:00
Greg Kroah-Hartman ed4596e9b1 greybus: host: provide "generic" apbridge output calls
Provide a new function, gb_hd_output() to send data to the apbridge.
This is useful for the camera and audio drivers that need to do this
type of messaging.

The camera driver is converted to use this new function, the audio
driver can use it when it gets merged later.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
2016-01-12 11:11:49 -08:00
Johan Hovold a5a7723a0d greybus: es2: clean up csi-config request
Use __packed and __u8 for csi-config request that is going out on the
wire.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-22 12:59:02 -08:00
Laurent Pinchart ccb5803591 greybus: es2: Don't use stack memory as USB request data
USB request data must be DMAble memory, allocate it with kzalloc()
instead of declaring it as a local variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-21 18:22:43 -08:00
Laurent Pinchart e715a54f4b greybus: es2: Fix endian conversion issues
Convert all USB request fields between CPU and protocol endianness.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-21 18:22:43 -08:00
Laurent Pinchart 8e2b7daa23 greybus: es2: Add support for CSI transmitter configuration
Export a function from the es2 driver to configure the CSI transmitter
through the corresponding USB vendor control request.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-21 16:35:27 -08:00
Johan Hovold ed972e3a36 greybus: es2: demote dynamic-urb error message
Demote error message when needing to dynamically allocate an URB to
debug level.

This isn't really an error as much as a reminder of how the current es2
implementation works: It uses a fixed number of pre-allocated URBs, but
allocates URBs dynamically when enough messages are sent in rapid
succession to exhaust the URB pool.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-15 14:23:37 -08:00
Laurent Pinchart a75fd8ba5c greybus: es2: Reserve CPorts 16 and 17
CPorts 16 and 17 are reserved for CDSI0 and CDSI1 by the ES2 APB, make
sure they won't be allocated dynamically.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-09 17:05:48 -05:00
Johan Hovold 100e900008 greybus: use decimal notation for interfaces, bundles and cports
Fix up the last few places where hexadecimal rather than decimal
notation was used for interface, bundle and cport ids.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-08 15:31:14 -05:00
Viresh Kumar b933fa4a40 greybus: Prefix hexadecimal values with 0x while printing them
To clearly specify the base for printed values, prefix hexadecimal
values with 0x.

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
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
Viresh Kumar bf6a61bd2f greybus: es2: remove fake vendor/product ids
These aren't used anymore, remove them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-16 22:18:52 -08:00
Viresh Kumar 69166d2525 greybus: es2: Send cport-id in wValue field to usb_control_msg()
wIndex field has a special meaning, as that can be used by the core to
index into the possible USB interfaces. And that specifically broke with
gbsim, as it has a single USB interface.

Other similar requests (REQUEST_LATENCY_TAG_{EN|DIS}) are already using
wValue field for passing cport-id.

Fix cport_reset() by sending the cport-id in wValue field instead of
wIndex.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 15:49:12 -08:00
Johan Hovold a52028626a greybus: es2: clean up es2 destructor
Now that the host-device is deregistered separately from deallocation,
we can simplify the cport_to_ep-array deallocation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold c170047984 greybus: hd: fix host-device life time issues
Fix host-device life time issues by separating host-device allocation
from registration.

This is needed both to make sure that all host-device resources are
available before registering the device and to prevent such resources
from being deallocated while the device is still in use during device
removal.

This specifically fixes the following warnings during es1 and es2
disconnect:

usb 1-1.1: No free CPort OUT urbs, having to dynamically allocate one!

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 57bc17ffc5 greybus: es2: add more structure to probe error handling
Add more structure to probe error handling rather than use the big
hammer and call disconnect directly.

This is needed to fix some host-device life-time issues.

Note that there was never any need to clear the USB interface data as
this will be done by driver core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 74cd6503e5 greybus: es2: fix debugfs dentry leak
Fix dentry leak due to failure to remove debugfs file.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold f6624ca77c greybus: es2: separate stopping and deallocating urbs
Separate stopping and deallocating our in-urbs.

This will facilitate implementing proper host-device life-time management.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 0ce68ce417 greybus: es2: separate urb allocation and submission
Refactor in-urb submission, and make sure to separate allocation and
submission.

Eventually we'll be submitting the urbs at cport enable rather than at
probe, and this is also needed for the driver-model rework.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold b6d808525a greybus: es2: fix endpoint requirement check
The current es2 implementation only checks for no IN or OUT bulk
endpoints, but still assumes there are precisely NUM_BULKS of each.

Specifically, urbs could be allocated and initialised to default values,
which amounts to bulk urbs being submitted to the control endpoint.

We should be able to handle any number of endpoints, but for now let's
just require NUM_BULKS of each.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold a51e8551e2 greybus: es2: fix use-after-free at disconnect
The interface private data is released as part of host-device removal
and must not be accessed afterwards.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold d6e139bc15 greybus: hd: use common prefix for exported functions
Rename the exported functions using the common gb_-prefix.

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 a8cc020f3f greybus: hd: rename host-driver structure
Rename host-driver structure to gb_hd_driver to more clearly separate it
from the host-device structure.

Also remove an outdated description of the struct.

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 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 4d5c446b53 greybus: es2: update obsolete bridge-device comments
Update obsolete bridge-device comments to better describe our current
ES2 endpoint layout.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 11:28:59 -08:00
Alex Elder 3be0e17d62 greybus: es2: don't assume just one AP bridge
Previously we had only one AP bridge connected to the AP.  We will
now have two.  Now that the have moved the logging related symbols
into the AP device, we can stop assuming there's only on of them.

Specifically, rename symbols like "apb1_*" to be just "apb_*",
because the "1" is no longer meaningful.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 10:38:36 -08:00
Alex Elder cbec7e2919 greybus: es2: move logging dentries into es2 struct
Finish moving the logging data structures into the es2 AP data
structure rather than having it be a single global.  This patch
moves the two dentries related to logging.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 10:38:36 -08:00
Alex Elder 8995a39d6d greybus: es2: move logging fifo into es2 struct
Continue moving the logging data structures into the es2 AP data
structure rather than having it be a single global.  This patch
moves the fifo.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 10:38:36 -08:00
Alex Elder 1482b3e1a8 greybus: es2: move APB log task into the es2_ap_dev struct
If an APB has a logging task it is associated with that APB.  Move
the task pointer into the es2_ap_dev structure rather than having it
be a single global.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 10:38:36 -08:00
Alex Elder 4b1d82047e greybus: es2: rename es2 data structures
I tried this once before and Greg NAK'd it because at that point the
es2 code was nearly identical to the es1 code.  This is no longer
the case, and we need to diverge further, so I think it's time to go
down that path.

The ap_dev structure changed significantly for ES2 versus ES1 as of
this commit:
    667f8d3 es2.c: create dedicated struct for cport_in and cport_out
Since the structures are no longer the same, they should not have
the same name.

This patch renames three data structures so the "1" is replaced with
a "2", to reflect the Toshiba AP bridge chip revision we are working
with.  The structures are:
    es1_ap_dev -> es2_ap_dev
    es1_cport_in -> es2_cport_in
    es1_cport_out -> es2_cport_out

It changes names of symbols having this type as well.  To finish the
job, all references "ES1" (in comments and in symbol names) have
been switched to use "ES2" instead.

The result is a lot of changes, but they amount to a global search
and replace of "es1" with "es2" (and "ES1" with "ES2"), and the
result has been compile tested.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-02 10:38:36 -08:00
Greg Kroah-Hartman 8f0a654f38 greybus: es2: use official USB vendor/device id
We now have an officially assigned Google USB device id for the
APBridge, so add in support for it in the es2 driver.  The old entry can
be removed once the firmware has caught up and uses the new number.

We should use the version field to determine ES1/ES2/ES3, but that will
come later, for now, grab anything with this device id.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-22 17:51:10 -07:00
Bryan O'Donoghue 608ab2fe99 greybus: es1,es2: add USB vendor command to timestamp
As part of an effort to get deep inspection of latencies throughout the
greybus network including HSIC, UniPro and firmware incurred latencies a
new command to the APBridge to tag a known offset with timestamping data
has been introduced. This patch adds that code to the es1 and es2 drivers.

- latency_tag_enable
- latency_tag_disable

Respectively send the enable/disable command to APBridge on a per-CPort
basis. This allows only specified cports to have timestamping data added by
APBridge, leaving any CPort not specifically enabled untouched.

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
Johan Hovold 305a031e1a greybus: es1/es2: clean up error messages
Replace the remaining pr_err with dev_err, and drop redundant function
prefixes.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-14 12:00:09 -07:00
Fabien Parent 82ee1e6cde greybus: es2: implement cport reset control request
Toshiba UniPro IP requires to reset the CPort that has been used in a previous
connection. This commit implement a new control request in order to
reset CPorts on an APBridgeA.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-14 11:54:51 -07:00
Johan Hovold 58c85123d9 greybus: es1/2: fix use-after-free in completion callback
Reset the hcpriv field before returning the message to greybus core in
the OUT-URB completion callback.

This fixes a use-after-free bug when sending responses to incoming
requests as the final reference is then dropped when the message is
returned.

Reported-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-29 19:09:06 +02:00
Bryan O'Donoghue 6872c46129 greybus: es1, es2: hook tracepoints to hardware send/recv operations
This patch hooks tracepoints for the handoff point to/from hardware. With
these tracepoints in place we can view the time between gb_message_send and
usb_submit_urb and similarly we can view the time between cport_in_callback
and gb_message_recv_response/gb_message_recv_request

- trace_gb_host_device_send
- trace_gb_host_device_recv

It provides standard tracepoints at

/sys/kernel/debug/tracing/events/greybus/gb_host_device_send
/sys/kernel/debug/tracing/events/greybus/gb_host_device_recv

Giving outputs like

gb_host_device_recv: greybus:2-1 if_id=0000 l=10
gb_host_device_send: greybus:2-1 if_id=0000 l=10

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
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