Commit graph

34 commits

Author SHA1 Message Date
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 799baa24db greybus: es1.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
Alex Elder 190241a362 greybus: drop some unnecessary headers
There's no need to include anything other than "greybus.h" in
"connection.c".  Same thing in "core.c" and "manifest.c" and
"svc.c".  Some files need headers included, but most come along
with "greybus.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Greg Kroah-Hartman cce3103676 greybus: es?: decrease buffer size to 2k
The firmware is having a hard time with 4k buffers and memory
allocation, so decrease the size on the host side to 2k.  Also move away
from using PAGE_SIZE to denote 4k as that's not the case on all
architectures, and someone, someday, might get a rude surprise.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:35:03 -07:00
Alex Elder 4441f4759c greybus: update copyrights
Update the copyright statements for recently-modified source files.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:47:56 -07:00
Alex Elder eb765e4e91 greybus: core: don't set up endo until host device is initialized
Currently, the data structure representing an Endo is set up at the
time a host device gets created.  This is too early.

Once the control infrastructure is in place, there's no sense in
setting up the Endo utnil after we have heard from the SVC via a
probe operation on our control CPort.  And even then, there's
no real point until we've successfully authenticated with the SVC,
which will be indicated by the arrival of the Control protocol
"connected" operation request notifying us that our SVC CPort
is operational.

In addition to this logical argument, we also can't actually
receive any messages on the Control CPort until the host device
is set up and ready to receive messages.  At the point we're
currently setting up the Endo data structure, that has not yet
been done.

Define a new exported function greybus_endo_setup(), which will
be used (for now) as the entry point for setting up the Endo
data structure.  Arrange to call it in the host USB driver
probe method, *after* we are set up for handling messages.

Note: Once the control protocol has been implemented, this function
may no longer need to be exported.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:45:42 -07:00
Alex Elder 8ea70fe049 greybus: core: return error code when creating host device
Return a pointer-coded error from greybus_create_hd() rather
than NULL in the event an error occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:31:42 -07:00
Johan Hovold d933667a1e greybus: fix host-device buffer constraints
Host devices impose buffer-size constraints on Greybus core which are
taken into account when allocating messages.

Make sure to verify these constraints when the host device is allocated,
rather than when the first message is allocated.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-20 22:51:05 -07:00
Greg Kroah-Hartman 6cf42a447d greybus: MODULE_LICENSE cleanup
These are all GPLv2-only kernel modules, so properly set the correct
MODULE_LICENSE string to make static checkers happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-17 16:12:49 +02:00
Johan Hovold 24ef485398 greybus: drop host-driver buffer headroom
Drop the host-driver buffer headroom that was used to transfer the cport
id on ES1 and ES2.

Rather than transferring additional bytes on the wire and having to deal
with buffer-alignment issues (e.g. requiring the headroom to be a
multiple of 8 bytes) simply drop the headroom functionality.

Host drivers are expected set up their transfer descriptors separately
from the data buffers and any intermediate drivers (e.g. for Greybus
over USB) can (ab)use the operation message pad bytes for now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold a9cf7da195 greybus: es1: fix transfer-buffer alignment
Fix transfer-buffer alignment of outgoing transfers which are currently
byte aligned.

Some USB host drivers cannot handle byte-aligned buffers and will
allocate temporary buffers, which the data is copied to or from on every
transfer. This affects for example musb (e.g. Beaglebone Black) and
ehci-tegra (e.g. Jetson).

Instead of transferring pad bytes on the wire, let's (ab)use the pad
bytes of the operation message header to transfer the cport id. This
gives us properly aligned buffers and more efficient transfers in both
directions.

By using both pad bytes, we can also remove the arbitrary limitation of
256 cports.

Note that the protocol between the host driver and the UniPro bridge is
not necessarily Greybus. As long as the firmware clears the pad bytes
before forwarding the data, and the host driver does the same before
passing received data up the stack, this should be considered "legal"
use.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold 7cf7bca9ec greybus: pass messages to host drivers
Pass structured greybus messages rather than buffers to the host
drivers.

This will allow us to separate the transfer buffers from the message
structures.

Rename the related functions to reflect the new interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold bfd9a94d1a greybus: es1: fix buffer-size limit
The maximum buffer size does not include the headroom, so subtract the
headroom size from the actual buffer size.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00
Johan Hovold 79940cf875 greybus: es1: fix DMA-buffer on stack
A stack-allocated buffer is not generally DMA-able and must not be used
for USB control transfers.

Note that the memset and extra buffer byte were redundant as no more
than the bytes actually transferred was ever added to the fifo.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00
Johan Hovold b7744b7f97 greybus: es1: drop unnecessary casts
Drop unnecessary explicit casts.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00
Alex Elder e4c4b4dce6 greybus: reduce the ranting
Cut out some comments that are no longer operative.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-04-02 11:29:58 +02:00
Alex Elder dada3b02a3 greybus: es1: test apb1_log_task safely
When usb_log_enable() is called, the global apb1_log_task is used to
hold the result of kthread_run().  It is possible for kthread_run()
to return an error pointer, so tests of apb_log_task against NULL
are insufficient to determine its validity.

Note that kthread_run() never returns NULL so we don't have to check
for that.  But apb1_log_task is initially NULL, so that global must
be both non-null and not an error in order to be considered valid.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:28:13 +02:00
Alex Elder 142f8ddf71 greybus: get rid of {conceal,reveal}_urb()
These clever macros were fine for early development, but they're
more of a distraction now.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-27 11:16:35 +01:00
Greg Kroah-Hartman 25d1c37798 greybus: es1: allow the debug log to be stopped
If you write 0 to the debugfs file, the log will stop being updated.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:47:24 +01:00
Greg Kroah-Hartman 0c264c6fc2 greybus: es1: separate usb_log enable/disable logic into different functions
One function shouldn't do two different things depending on a parameter
passed to it, so split usb_log_enable() into usb_log_disable()

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:45:31 +01:00
Greg Kroah-Hartman efdc43130c greybus: es1: fix checkpatch warning about blank lines needed
Add a blank line in apb1_log_enable_read() to make checkpatch happy.

Oh, and it makes the code more readable too...

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:34:02 +01:00
Greg Kroah-Hartman 64b8a16f44 greybus: es1: move debugfs function to use kstrotoint_from_user()
No need to duplicate built-in functions that the kernel has, so have the
core kernel parse the userspace string.  Saves us an allocation and
makes the logic simpler.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:32:40 +01:00
Greg Kroah-Hartman d52f9973e2 greybus: es1: decimal modes are not what are wanted for debugfs
decimal is not octal, so use the proper mode settings for the debugfs
files.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:10:58 +01:00
Greg Kroah-Hartman 4600d03f80 greybus: es1: struct file_operations needs to be const
We aren't changing these pointers, so mark them read-only as that is the
preferred way.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:08:12 +01:00
Greg Kroah-Hartman 26164edb8f greybus: es1: no need to check for NULL on debugfs_remove()
The function can, and even expects NULL, so don't check.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:06:41 +01:00
Greg Kroah-Hartman cd674c8d4c greybus: es1: use <linux/uaccess.h> and not <asm/uaccess.h>
Asm is only for when you are doing arch-specific stuff, which we aren't
doing here.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:04:49 +01:00
Greg Kroah-Hartman 2f4e236648 greybus: es1: fix tiny whitespace issues
No trailing spaces or spaces before tabs are allowed.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 20:03:39 +01:00
Greg Kroah-Hartman 6c28f09658 greybus: es1: fix build warning for apb1_log_enable_write
It's "const char __user *buf", not "char __user *buf".

'make check' is your friend.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-24 19:57:53 +01:00
Alexandre Bailon 59e3344461 greybus: Dump log from APB1
On AP module (form factor), we don't have access to APBridge JTAG or UART.
But sometime, we still need to get log from APBridge. Add a new request in control endpoint
to get APBridge logs.
Logs can be accessed using debugfs (greybus/apb1_log).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-24 19:49:47 +01:00
Greg Kroah-Hartman 45a706368d greybus: es1.c: wait until the last possible minute to start the svc messages
When initializing the USB device, we were starting up the svc message
queue before the cport urbs were allocated.  This might not be an issue
for "slower" machines, but not having any allocated urbs for a cport
might be an issue if we were to handle svc messages.

So wait until everything is properly initialized and allocated before
starting the svc urb.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-23 22:55:57 +08:00
Viresh Kumar 98abb4146e greybus: Remove "gb-" prefix from .c files
Some files are still prefixed with "gb-" with the reasoning that the modules
would be named so, i.e.  gb-*.ko. But this can be done by playing a bit in
Makefile instead and keep uniform naming of .c files.

Lets try it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22 11:27:20 +08:00
Renamed from drivers/staging/greybus/gb-es1.c (Browse further)