Commit Graph

67 Commits

Author SHA1 Message Date
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
Greg Kroah-Hartman 608f6619a2 greybus: es2: comment out unused functions
The Qualcomm kernel builds with -Werror so the existing es2.c driver
breaks the build due to unused static functions.  As we are still
hashing out exactly how to implement this logic at the moment, just
comment out the functions to make the build be clean, no logic changes
happen here at all.

Reported-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-22 10:56:28 -07:00
Fabien Parent ced6007a6d greybus: es{1,2}: remove obselete define
The SVC Control request is obsolete and not used anymore. Remove the related
define.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-17 12:40:45 -07:00
Alexandre Bailon e5acf736ca greybus: es2: add some documentation about endpoints mapping
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-14 22:09:32 -07:00
Alexandre Bailon 64c9cabcac greybus: es2: change (un)map methods to static
Endpoints pair will only be managed by es2 driver.
map_cport_to_ep() and unmap_cport() should be static.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-14 22:09:32 -07:00
Alexandre Bailon 1ff3dc9205 greybus: es2: rename misnamed variables and methods
Some methods and variables name were a lot confusing.
Replace it or add ep_pair in methods or varaibles name
to make sources less confusing.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-14 22:02:00 -07:00
Alexandre Bailon 566830fdb1 greybus: es2: update the bulk_ep_set value accepted by map_to_cpor_ep()
The endpoint set 0 is currently considered as invalid.
But 0 mean muxed cports on ep1 and ep2,
then it must not return -EINVAL.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-04 14:49:09 -07:00
Fabien Parent f470ead894 greybus: es{1,2}: remove control endpoint field
There is no need to store the endpoint number of the control requests since
the default control endpoint is used and the USB standard defines for it a fixed
endpoint number of 0.

Remove every instance of the field control_endpoint and replace it with a
hardcoded 0 value.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-02 16:28:11 +02:00
Fabien Parent 24a6112fa5 greybus: es2: get cport count from apb1 usb device
Use the control request REQUEST_CPORT_COUNT in order to get the number of
CPorts supported by the UniPro IP.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-02 16:25:24 +02:00
Fabien Parent c011d558e1 greybus: es2: dynamically allocate array for cport <-> ep mapping
In order to be able to dynamically determine the number of CPorts supported
by the UniPro IP instead of hardcoding the value we need to dynamically
allocate the array that is doing the cport-ep mapping.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-02 16:24:49 +02:00
Fabien Parent 144670c2ae greybus: add num_cports field to greybus hd
This commit is doing the preparation work in order to get the number of cports
supported from the UniPro IP instead of using a constant defined in a Kconfig
file.

Greybus host device is now holding the cport count, and all the code will now
use this value instead of the constant CPORT_ID_MAX when referring to an AP's
CPort ID.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
[johan: es1 supports 256 cports, minor style changes ]
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-02 16:21:54 +02:00
Fabien Parent e074a2e287 greybus: es2: rename misnamed CPORT_MAX into CPORT_COUNT
Rename the misnamed macro CPORT_MAX into CPORT_COUNT. CPORT_MAX could let
people think that the macro is holding the value of the last CPort ID
usable.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-02 16:11:11 +02:00
Alexandre Bailon 977e209ab4 greybus: es1/es2: set transfer flag to send a zero-length packet
Greybus messages with a multiple size of 512B generate timeouts
(any other message size doesn't).
512B is exactly the packet size of a bulk out endpoint.
Hence USB device is expecting a short (< 512B)
or zero-length packet to finish the transfer,
which is never generated and causes the timeout.

Set the transfer flag to send a zero-length packet in this situation.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
2015-09-01 14:36:52 +02:00
Greg Kroah-Hartman d706ef8f1b greybus: Merge branch 'master' into branch 'svc'.
This drags in the firmware driver, and the start of some loopback
changes.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 22:14:06 -07:00
Bryan O'Donoghue 3f2a809e8b greybus: es-drivers: add outbound timestamp to connection
In order to facilitate grabbing a timestamp that doesn't include greybus
overhead, this patch adds a timestamp right before usb_submit_urb() for
both es1.c and es2.c. Long term the timestmaping of messages like this
probably wants to go away but, for the moment it may have some use to the
firmware people instrumenting the performance of the system.

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 e75b82bfc7 greybus: initialize svc connection while creating hd
Its really part of initializing the host device and is required for
every 'hd' that is created. Lets move the call to do basic
initialization of svc connection to greybus_create_hd().

Also add a comment to specify why we need to do it that early.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:06:21 -07:00
Viresh Kumar 0b161d0a92 greybus: es1: create svc connection early enough
The svc connection needs to be ready before creating the URBs, otherwise
the svc version request might come in before the AP was ready to parse
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:06:18 -07:00
Greg Kroah-Hartman 260998ebc6 greybus: remove submit_svc from the host driver
The callback is never used anymore, so remove it from struct
greybus_host_driver as well as from the es1 and es2 drivers.

Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:06:18 -07:00
Greg Kroah-Hartman b767ee4020 greybus: es2: remove svc endpoint message handling
We have switched over to use the "new" svc messages, no more need to
have a special USB endpoint to handle them, they come through the normal
CPort messages.

Based on a patch from Viresh.

Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:06:18 -07:00
Viresh Kumar 619dccd27b greybus: es1/2: Lets start using svc protocol
All bits and pieces are in place now. Lets start using svc protocol
instead of stuff present in ap.c.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:06:17 -07:00
Greg Kroah-Hartman 3eac885de2 greybus: svc: revert svc changes to keep things working for a while.
The firmware for the svc changes isn't quite ready, so revert the whole
set of patches in one hunk to get things back to a working state for the
other firmware developers.  The svc patches will be added back in a
separate branch.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-29 10:05:09 -07:00
Viresh Kumar 9612f2bcd4 greybus: initialize svc connection while creating hd
Its really part of initializing the host device and is required for
every 'hd' that is created. Lets move the call to do basic
initialization of svc connection to greybus_create_hd().

Also add a comment to specify why we need to do it that early.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-28 14:47:03 -07:00
Viresh Kumar 5a202efe63 greybus: es1: create svc connection early enough
The svc connection needs to be ready before creating the URBs, otherwise
the svc version request might come in before the AP was ready to parse
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-27 14:13:20 -07:00
Greg Kroah-Hartman d187576fbe greybus: remove submit_svc from the host driver
The callback is never used anymore, so remove it from struct
greybus_host_driver as well as from the es1 and es2 drivers.

Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-27 14:13:16 -07:00
Greg Kroah-Hartman 939799057e greybus: es2: remove svc endpoint message handling
We have switched over to use the "new" svc messages, no more need to
have a special USB endpoint to handle them, they come through the normal
CPort messages.

Based on a patch from Viresh.

Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-27 14:12:55 -07:00
Viresh Kumar 8aa013526e greybus: es1/2: Lets start using svc protocol
All bits and pieces are in place now. Lets start using svc protocol
instead of stuff present in ap.c.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-27 14:12:24 -07:00
Johan Hovold 3e136cc9e0 greybus: operation/esx: fix message-cancellation lifetime bugs
The current host-controller message-cancellation implementation suffer
from a lifetime bug as dynamically allocated URBs would complete and be
deallocated while being unlinked as part of cancellation.

The current locking is also insufficient to prevent the related race
where the URB is deallocated before being unlinked.

Fix this by pushing the cancellation implementation from greybus core
down to the host-controller drivers, and replace the "cookie" pointer
with a hcpriv field that those drivers can use to maintain their state
with the required locking and reference counting in place.

Specifically the drivers need to acquire a reference to the URB under a
lock before calling usb_kill_urb as part of cancellation.

Note that this also removes the insufficient gb_message_mutex, which
also effectively prevented us from implementing support for submissions
from atomic context.

Instead the host-controller drivers must now explicitly make sure that
the pre-allocated URBs are not reused while cancellation is in progress.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:43:02 -07:00
Johan Hovold 86f918ee7f greybus: esx: fix null-deref on hotplug events
We must be prepared to receive hotplug events as soon as we submit the
SVC URB. Since commit 2eb8a6a947d7 ("core: don't set up endo until host
device is initialized") this is no longer the case as the endo would not
have been setup, something which may lead to a null-pointer dereference
in endo_get_module_id() when the interface is created (see oops below
with an added dev_dbg for hd->endo).

Fix this by setting up the endo before submitting the SVC URB.

[   28.810610] gb_interface_create - hd->endo =   (null)
[   28.816020] Unable to handle kernel NULL pointer dereference at virtual address 0000022b
[   28.824952] pgd = c0004000
[   28.827880] [0000022b] *pgd=00000000
[   28.831913] Internal error: Oops: 17 [#1] PREEMPT ARM
[   28.837183] Modules linked in: gb_es1(O+) greybus(O) netconsole
[   28.843419] CPU: 0 PID: 21 Comm: kworker/u2:1 Tainted: G           O    4.1.0-rc7 #12
[   28.851576] Hardware name: Generic AM33XX (Flattened Device Tree)
[   28.857978] Workqueue: greybus_ap ap_process_event [greybus]
[   28.863890] task: cf2961c0 ti: cf29c000 task.ti: cf29c000
[   28.869529] PC is at endo_get_module_id+0x18/0x88 [greybus]
[   28.875355] LR is at gb_interface_add+0x88/0x204 [greybus]
[   28.881070] pc : [<bf0052d4>]    lr : [<bf005dac>]    psr: 20070013
[   28.881070] sp : cf29de08  ip : cf29de18  fp : cf29de14
[   28.893021] r10: 00000001  r9 : 0000005a  r8 : cd813ec6
[   28.898461] r7 : 00000058  r6 : cf7fa200  r5 : 00000001  r4 : cf7fa20c
[   28.905261] r3 : 00000000  r2 : cf2961c0  r1 : 00000001  r0 : 00000000
[   28.912067] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[   28.919677] Control: 10c5387d  Table: 8f508019  DAC: 00000015
[   28.925663] Process kworker/u2:1 (pid: 21, stack limit = 0xcf29c210)
[   28.932279] Stack: (0xcf29de08 to 0xcf29e000)
[   28.936823] de00:                   cf29de44 cf29de18 bf005dac bf0052c8 00000058 cd813ec0
[   28.945349] de20: cf58b60c bf00afe0 cf7fa200 cf58b600 0000005a 00000001 cf29de84 cf29de48
[   28.953865] de40: bf004844 bf005d30 00000000 cf02d800 cf29de6c cf29de60 c00759a0 cf58b60c
[   28.962389] de60: cf2742c0 cf02d800 cf0c6000 cf29dea8 c07b745c 00000000 cf29dee4 cf29de88
[   28.970908] de80: c005943c bf004560 00000001 00000000 c0059354 cf02d800 c0059c0c 00000001
[   28.979426] dea0: 00000000 00000000 bf00b314 00000000 00000000 bf009144 c04e3710 cf02d800
[   28.987945] dec0: cf2742d8 cf02d830 00000088 c0059bd0 00000000 cf2742c0 cf29df24 cf29dee8
[   28.996464] dee0: c0059b78 c0059248 cf29c000 cf245d40 c0776890 c07b6bf3 00000000 00000000
[   29.004983] df00: cf245d40 cf2742c0 c0059b20 00000000 00000000 00000000 cf29dfac cf29df28
[   29.013502] df20: c005fe90 c0059b2c c07812d0 00000000 cf29df4c cf2742c0 00000000 00000001
[   29.022025] df40: dead4ead ffffffff ffffffff c07c86b0 00000000 00000000 c05fd8e8 cf29df5c
[   29.030542] df60: cf29df5c 00000000 00000001 dead4ead ffffffff ffffffff c07c86b0 00000000
[   29.039062] df80: 00000000 c05fd8e8 cf29df88 cf29df88 cf245d40 c005fd98 00000000 00000000
[   29.047581] dfa0: 00000000 cf29dfb0 c00108f8 c005fda4 00000000 00000000 00000000 00000000
[   29.056105] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   29.064623] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 ffff0000 ffff0000
[   29.073178] [<bf0052d4>] (endo_get_module_id [greybus]) from [<bf005dac>] (gb_interface_add+0x88/0x204 [greybus])
[   29.083887] [<bf005dac>] (gb_interface_add [greybus]) from [<bf004844>] (ap_process_event+0x2f0/0x4d8 [greybus])
[   29.094527] [<bf004844>] (ap_process_event [greybus]) from [<c005943c>] (process_one_work+0x200/0x8e4)
[   29.104228] [<c005943c>] (process_one_work) from [<c0059b78>] (worker_thread+0x58/0x500)
[   29.112668] [<c0059b78>] (worker_thread) from [<c005fe90>] (kthread+0xf8/0x110)
[   29.120295] [<c005fe90>] (kthread) from [<c00108f8>] (ret_from_fork+0x14/0x3c)
[   29.127825] Code: e24cb004 e52de004 e8bd4000 e3510000 (e5d0c22b)
[   29.137481] ---[ end trace ad95c3c26bdc98ce ]---

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-24 17:34:47 -07:00
Greg Kroah-Hartman 9df94499c4 greybus: Merge branch alex into Alexandre
This resolves a conflict with es2.c that I fixed up.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:53:23 -07:00
Alexandre Bailon fc1a536e60 greybus: es2.c: add a control request for endpoints mapping
ES2 give us more endpoints. Use them to map one cport to two endpoints
(in and out). Because there is more cports than endpoints, we still
need to mux other cports traffic on 2 endpoints.
Firmware currently assumes these endpoints are 2 and 3.

By default, all cports are muxed.
To map one cport to 2 endpoints, use map_cport_to_ep().

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon 606addd284 greybus: es2.c: Increase the number of bulk endpoints
ES2 support 16 endpoints. Update es2.c to allocate endpoints, urbs
and buffers for these new endpoints.

Currently, they are not yet used and es2.c is working in legacy mode
(only original endpoints are used).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon ddc09acd46 greybus: es2.c: create dedicated struct for cport_in and cport_out
Instead of keep cport buffers, urbs and endpoints in es1_ap_dev,
move them in two dedicated struct (es1_cport_in and es1_cport_out),
in order to ease the migration to es2 (increase the number of endpoint).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon 611c17390e greybus: es2.c: Don't use magic value for USB control request
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alex Elder 4bc1389de9 greybus: esX: use one byte to encode cport ids in header
We now limit the maximum value for both host and module CPort ids,
and we know they can always be represented in a single byte.

Make use of this by using only one of the two pad bytes for encoding
the CPort id in a message header.

(Note that we have never used a CPort higher than 255.  Encoding
such a small CPort id in little endian 2-byte format has the same
result as what is done here.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder d29b3d631e greybus: esX: encapsulate packing cport id into header
For the ES1 and ES2 host interfaces we encode the CPort ID over
which the message should be sent within the message itself.  The
CPort ID is recorded in unused pad bytes found in the operation
message header in order to avoid introducing misaligned messages.

This patch defines some helper routines to abstract this activity.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder 821c620afa greybus: introduce cport_id_valid()
Define a public predicate that defines whether a CPort ID is valid.

Use it in the message_send() routine, and make the message reported
more accurately reflect the error.  Also use it to check whether the
CPort ID in a received message is valid; if it is not, just drop the
message.

Get rid of local variable "buffer" in message_send(); it adds no
value.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00