Johan Hovold [Wed, 22 Jun 2016 09:42:05 +0000 (11:42 +0200)]
greybus: es2: add support for greybus cport flags
Add support for Greybus CPort flags that are sent to the bridge through
a new USB vendor request when enabling a CPort as part of connection
establishment.
Currently the Greybus control and high-priority connection flags are
recognised and forwarded to APBA.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 22 Jun 2016 09:42:04 +0000 (11:42 +0200)]
greybus: connection: add support for high-priority connections
Add connection flag to indicate that a connection has high priority.
For the SVC and control connections this may be used by the host-device
driver as a hint to allocate dedicated DMA channels or to use polling to
avoid message congestion.
We also allow drivers to set this flag on their connections, even though
we currently have no use case for this (and the host-device driver is
again free to ignore it).
Note that this mechanism can be used to indicate also high-bandwidth
connections (e.g. wanting larger buffers or dedicated endpoints), but
that that should be done using a separate high-bandwidth flag rather
than overloading the high-priority flag.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 22 Jun 2016 09:42:03 +0000 (11:42 +0200)]
greybus: connection: prevent drivers from specifying core flags
Prevent drivers from specifying core flags (currently only
GB_CONNECTION_FLAG_CONTROL) when creating connections.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 22 Jun 2016 09:42:02 +0000 (11:42 +0200)]
greybus: hd: add flag argument to cport_enable callback
Add a flag argument to the host-device cport_enable callback that can be
used to provide hints about the connection being created (e.g.
connection priority).
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Evgeniy Borisov [Thu, 23 Jun 2016 09:39:18 +0000 (12:39 +0300)]
greybus: camera: Add RAW data format
Add support for greybus RAW data format.
Greybus RAW data formats starts from 0x80.
Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
David Lin [Fri, 24 Jun 2016 20:52:43 +0000 (13:52 -0700)]
greybus: audio: remove the unnecessary return statement
The return statement immediately after the BUG_ON of the gbcodec_write()
call is added by mistake. It's not causing any errors right now due to
that gbcodec_reg is currently not being used.
Testing Done:
- Audio playback on EVT2
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Jeffrey Carlyle [Fri, 24 Jun 2016 03:28:56 +0000 (08:58 +0530)]
greybus: connection: switch to using spin_lock_irqsave/spin_lock_irqrestore excluisvely
We know that it is a bad idea to explicitly enable IRQs when we don't
don't know if they were already off before we disabled, so switch to the
save _irqsave and _irqrestore functions.
Ultimately, we need to review places in the Greybus drivers where IRQs
are disabled and remove unnecessary instances. This is only an interim
step.
This code will never run from hard irq context, as it is already taking
mutex in the path.
Testing done: booted EVT2.0, ran suspend/resume test app with a period
of 20s for a few dozen cycles.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Wed, 22 Jun 2016 09:16:41 +0000 (14:46 +0530)]
greybus: bootrom: Wait for 10 seconds for mode-switch
The greybus SVC core handles events from the SVC serially today. In some
cases the SVC operations may take too long, for example trying to
activate a dummy interface. If another interface receives a mode-switch
mailbox event in that time, the SVC core wouldn't be able to process it
in quickly enough and bootrom driver will print following error:
bootrom 1-3.3.1: Timed out waiting for Interface Mode Switch from the Module
This can be reproduced easily by attaching a 2x2 module along with any
other normal module like camera or speaker, and doing a unipro_reset
from userspace.
The logs suggest this time to be around 6-7 seconds in most of the
cases. Attaching multiple modules with dummy interfaces may make this
worst.
Lets increase the timeout from 5 to 10 seconds for now, also add a FIXME
for the same.
Testing Done: Tested on EVT 2.0 with camera and a 2x2 module.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Wed, 22 Jun 2016 09:16:40 +0000 (14:46 +0530)]
greybus: bootrom: send timeout in milliseconds to gb_bootrom_set_timeout()
Rename NEXT_REQ_TIMEOUT_J to NEXT_REQ_TIMEOUT_MS and store the timeout
in milliseconds instead of jiffies.
Suggested-by: Alex Elder <alex.elder@linaro.org>
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>
Viresh Kumar [Wed, 22 Jun 2016 09:16:39 +0000 (14:46 +0530)]
greybus: bootrom: Enhance timeout error message
The timeout message is very generic today and there are several requests
we can be timing out waiting for.
Update bootrom driver to also track the next expected request and
enhance the error message based on that to confirm the request we timed
out waiting for.
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>
Bryan O'Donoghue [Wed, 22 Jun 2016 13:58:44 +0000 (14:58 +0100)]
greybus: timesync: Make printout consitent with other greybus messages
The current printout on a TimeSync ping doesn't actually contain the word
greybus and uses the word ping-time in the print string, something that
appears nowhere in our official documentation on this feature. This patch
changes the format string to contain 'greybus' and 'frametime' to bring the
TimeSync printout more in-line with other greybus kernel log strings.
before:
timesync ping-time: ap=8632564 1-svc=8630712 greybus1=8633031 1-8.8=8633026
after:
greybus frametime: ap=8632564 1-svc=8630712 greybus1=8633031 1-8.8=8633026
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Wed, 22 Jun 2016 13:58:43 +0000 (14:58 +0100)]
greybus: timesync: Initialize the timesync ping fields to zero
Remember to initialize the TimeSync ping fields to zero so that if a
timesync_get_last_event() returns an error - we display a FrameTime that is
obviously incorrect.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Joel Porquet [Fri, 24 Jun 2016 21:41:36 +0000 (14:41 -0700)]
greybus: add support for the log protocol
Add support for the new Log class/protocol. This protocol allows modules
to send their internal logging messages to the AP in order to make
module debugging easier.
The protocol is, for now, composed a single module-initiated request.
This request contains a message and associated length. The message is
integrated in the kernel log with dev_dbg(). In order to be displayed
with 'dmesg', the following command needs to be entered first:
$ echo "file log.c +p" > /sys/kernel/debug/dynamic_debug/control
The major portion of this file was initially written by Greg KH.
Signed-off-by: Joel Porquet <porquet_joel@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 23 Jun 2016 17:53:06 +0000 (23:23 +0530)]
greybus: gb_connections_lock: don't use spin_lock_irq()
spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.
The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.
This may not work well, if some other code was relying on interrupts
being disabled.
Use spin_lock_irqsave() and spin_unlock_restore() instead.
This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.
Tested on EVT 2.0 with lots of debug patches to kernel and greybus.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 23 Jun 2016 17:53:06 +0000 (23:23 +0530)]
greybus: es2.c: don't use spin_lock_irq()
spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.
The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.
This may not work well, if some other code was relying on interrupts
being disabled.
Use spin_lock_irqsave() and spin_unlock_restore() instead.
This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.
Tested on EVT 2.0 with lots of debug patches to kernel and greybus.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 23 Jun 2016 17:53:06 +0000 (23:23 +0530)]
greybus: uart: don't use spin_lock_irq()
spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.
The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.
This may not work well, if some other code was relying on interrupts
being disabled.
Use spin_lock_irqsave() and spin_unlock_restore() instead.
This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.
Tested on EVT 2.0 with lots of debug patches to kernel and greybus.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Greg Kroah-Hartman [Thu, 23 Jun 2016 21:20:02 +0000 (14:20 -0700)]
greybus: Revert "greybus: don't use spin_lock_irq()"
This reverts commit
469fbe5da0229edcb42aa08bef8e10feaa37e6d7.
It isn't correct in places.
Reported-by: Gjorgji Rosikopulos <rosikopulos_gjorgji@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Thu, 23 Jun 2016 15:26:00 +0000 (16:26 +0100)]
greybus: timesync: Enforce TimeSync locks as subordinate to Interface locks
gb_timesync_svc_teardown() is called from gb_timesync_svc_del() and issues a
command to a remote Interface to switch off its timers. The lock ordering
is TimeSync => Interface in this case. However gb_module_del() takes an
Interface lock then calls gb_interface_del() => gb_timesync_svc_del() in
this case the lock ordering is Interface => TimeSync.
This patch fixes by removing the taking of the Interface mutex in
gb_interface_timesync_do_something(). If an Interface is present in the
TimeSync linked-list - it is by definition intf->enabled.
Reported-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 23 Jun 2016 17:53:06 +0000 (23:23 +0530)]
greybus: don't use spin_lock_irq()
spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.
The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.
This may not work well, if some other code was relying on interrupts
being disabled.
Use spin_lock_irqsave() and spin_unlock_restore() instead.
This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.
Tested on EVT 2.0 with lots of debug patches to kernel and greybus.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 23 Jun 2016 17:52:15 +0000 (23:22 +0530)]
greybus: Revert "greybus: ratelimit errors usually seen on unipro_reset"
This reverts commit
9b891f4fda8dfd6c1d8dc16479c5f6d418a9ccc7.
We discussed this over the other thread,
[PATCH 0/2] Improve watchdog's implementation a bit,
and decided that we shouldn't be trying to hide the watchdog reboot
problem by using such patches, rather we should make sure they occur
consistently so that the real problem can be fixed.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Michael Scott [Tue, 21 Jun 2016 23:41:46 +0000 (16:41 -0700)]
greybus: adjust kernel version check for led_sysfs_is_disabled
When building greybus against a 3.18 kernel the following error is generated:
light.c:205:9: error: implicit declaration of function 'led_sysfs_is_disabled'
[-Werror=implicit-function-declaration]
led_sysfs_is_disabled was not added until 3.19 kernel cycle
Verification:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/include/linux/leds.h?h=linux-3.18.y
(no function led_sysfs_is_disabled defined here)
Testing Done:
- Successfully built greybus for 3.18 kernel
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Hiremath [Tue, 21 Jun 2016 17:58:02 +0000 (23:28 +0530)]
greybus: ratelimit errors usually seen on unipro_reset
It is believed that excessive serial messages from greybus
on suspend/resume is leading to watchdog bite.
There is still discussion going on whether ratelimiting
prints would really fix anything, except it may reduce
traffic on serial console and probably bring out real issues
in the front.
So in order to meet the alpha requirement, we all decided to
get ratelimit change "as a TEMP fix" and decide later whether
we should revert back once we get proper suspend/resume implementation.
Please follow the discussion on Jira card SW-6261.
Testing Done: Build tested against ara/main branch.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Konstantin Buhchev <buhchev_konstantin@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rui Miguel Silva [Tue, 21 Jun 2016 15:56:16 +0000 (16:56 +0100)]
greybus: sdio: avoid extra memory operation at data transfer
Right now greybus sdio uses the greybus operation_sync to transfer data,
this will imply an extra memcpy at greybus core that we can avoid.
Also with this change we remove the need for an extra buffer to store
intermediate copy.
So, let us create the operation and do the memory operations in the sdio
driver.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Wed, 15 Jun 2016 02:55:56 +0000 (08:25 +0530)]
greybus: connection: add trace events before disabling connection
This is what we are doing elsewhere:
- Send enable/create trace events after enabling/creating stuff.
- Send disable/remove trace events before disabling/removing stuff.
This wasn't followed in a same way while disabling connections. Fix it.
Compile tested.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Wed, 15 Jun 2016 10:28:22 +0000 (15:58 +0530)]
greybus: firmware: prefix char-device with 'gb-'
This will make it consistent with any other character devices we have
for greybus and let us identify greybus character devices easily.
Compiled tested only.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Thu, 16 Jun 2016 12:42:16 +0000 (13:42 +0100)]
greybus: timesync: Rework timesync removal serialization logic
We need to make sure we adequately cancel and quiesce any scheduled
TimeSync synchronization operations in the case of greybus.ko being yanked
out of memory i.e. when doing an EHCI runtime suspend or just a plain
rmmod. The scenario is a new TimeSync sync operation has been scheduled.
Next gb_timesync_svc_remove() runs. In this case we should terminate any
scheduled work, terminate our ktime tracking timer and state transition to
GB_TIMESYNC_STATE_INVALID to ensure no other context may schedule any new
TimeSync operations.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Thu, 16 Jun 2016 12:42:15 +0000 (13:42 +0100)]
greybus: timesync: Fix transitions to the INACTIVE state
Analysing a backtrace associated with the current EHCI runtime suspend code
has highlighted several places where its perfectly valid to make a
transition to GB_TIMESYNC_STATE_INACTIVE when not already in the
GB_TIMESYNC_STATE_INIT state, for example failure to issue a TimeSync
enable command to the SVC can and should legitimately call
gb_timesync_teardown() - at this point the state will be
GB_TIMESYNC_STATE_WAIT_SVC and it's legitimate and desirable to transition
to the INACTIVE state in this case. This patch fixes by removing the
restrictive and incorrect restriction on the transition to INACTIVE only
being valid when state == GB_TIMESYNC_STATE_INIT.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Thu, 16 Jun 2016 12:42:14 +0000 (13:42 +0100)]
greybus: timesync: Do not hold mutex on cancel_delayed_work_sync
There is a scenario where gb_timesync_svc_remove() can run, attain a mutex
and call cancel_delayed_work_sync(). In the meantime a worker may already
be running and trying to attain the same mutex but will never do so as the
gb_timesync_svc_remove() path is holding the mutex and waiting on the
delayed_work_sync() to complete - leading to deadlock. This patch addresses
by calling the cancel_delayed_work_sync() before locking the relevant
mutex.
Reported-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 16 Jun 2016 04:33:57 +0000 (10:03 +0530)]
greybus: firmware: Add license and copyright header to application
Add license and copyright header to the firmware.c test application.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Sat, 11 Jun 2016 02:31:01 +0000 (08:01 +0530)]
greybus: manifest: Disallow reuse of control cport
We should be checking if any of the bundles contains a CPort with its id
set to the special value of '0', which is reserved for control CPort.
Discard the bundle in that case.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Hiremath [Wed, 15 Jun 2016 04:53:23 +0000 (10:23 +0530)]
greybus: svc: Pass the correct pointer to input_free_device()
In gb_svc_input_create() fn, on failure, wrong pointer
was being passed to input_free_device(). Correct it.
svc->input gets initialized only on successful return of this fn,
so it is absolutely wrong to pass svc->input to input_free_device().
Testing Done: Tested on EVT2.0 platform.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Laurent Pinchart [Tue, 14 Jun 2016 12:59:25 +0000 (15:59 +0300)]
greybus: camera: Create and destroy data connection on demand
Creating the data connection at probe time makes it impossible to
support multiple inserted camera modules as they would all try to
establish a data connection to the same CPort on the AP side. Create and
destroy the data connection when configuring the streams instead, as a
single module can be streaming at a time.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Laurent Pinchart [Tue, 14 Jun 2016 12:59:24 +0000 (15:59 +0300)]
greybus: camera: Fix data connection setup
When the module is in the configured state, an attempt to change the
configuration must first tear down the data connection to update its
parameters, as the APB1 bridge doesn't support modifying the CSI
transmitter configuration when it is already started.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Laurent Pinchart [Tue, 14 Jun 2016 12:59:23 +0000 (15:59 +0300)]
greybus: camera: Clean up on stream configuration failure
When the camera pipeline can't be configured due to a failure of one of
the components (failure to start the CSI transmitter for instance),
components that have already been setup for video streaming need to be
set back to a quiescient state. This is especially important to ensure
that a stream configuration failure won't keep the UniPro links in high
speed mode forever.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 13 Jun 2016 16:18:28 +0000 (21:48 +0530)]
greybus: svc: disable connection after all its users are gone
gb_svc_del() can be called during removal of gb-es2.ko module as well,
and in that case we would like to properly shutdown all modules and
interfaces as USB is still alive.
This requires that we don't disable the svc connection, at least for tx,
as that will be used while removing modules and interfaces.
Disable only rx to begin with, as we shouldn't be handling any requests
from the SVC. Disable tx only after all the users of svc connection are
gone.
Tested on EVT 2.0 by remove gb-es2.ko module. There are still few
errors, specially while quiescing the connections (-22), but not that
many.
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>
Viresh Kumar [Mon, 13 Jun 2016 09:38:01 +0000 (15:08 +0530)]
greybus: camera: Initialize mutex before using it
We are using the mutex from gb_camera_cleanup(), which can get called
even before the mutex is initialized.
Fix it by initializing the mutex early enough.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Fri, 10 Jun 2016 09:29:09 +0000 (14:59 +0530)]
greybus: connection: Return bool from gb_connection_intf_find()
This is used only to check if an existing connection already uses the
cport_id or not and doesn't really need to return pointer to the
connection.
While at it, also rename it to suit its purpose.
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>
Viresh Kumar [Fri, 10 Jun 2016 09:29:07 +0000 (14:59 +0530)]
greybus: Remove extra blank lines
This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.
Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Fri, 10 Jun 2016 06:07:54 +0000 (11:37 +0530)]
greybus: firmware: Fix spelling mistake
s/directly/directory :)
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Fri, 10 Jun 2016 15:10:12 +0000 (16:10 +0100)]
greybus: timesync: Do 64 bit divisions in a 32 friendly way
We need to use 'do_div()' when doing 64 bit division or modulo division
since the kernel will not pull in the gcc builtins __aeabi_ldivmod and
__aeabi_uldivmod on 32 bit builds.
Reported-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>
Bryan O'Donoghue [Fri, 10 Jun 2016 16:33:03 +0000 (17:33 +0100)]
greybus: uart: Fix minor number leak
On the gb_uart_remove() path we are forgetting to do a release_minor()
leading to a minor number leak. This is a simple one-line fix.
Tested on EVT 2.0
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Fri, 10 Jun 2016 07:29:11 +0000 (12:59 +0530)]
greybus: audio: Ratelimit err messages in bundle, topology driver
Earlier I have shared a patch to rate limit err messages in audio_codec
driver. However, missed to include suggestion from Mark to do similar
changes in audio bundle & topology parser as well. Doing it now.
Testing Done: Compile tested
Fixes:
4cb3d109e5fc ("audio: Ratelimit err messages")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Thu, 9 Jun 2016 04:00:40 +0000 (09:30 +0530)]
greybus: Remove apbridgea_shutdown_xx sequence if already done
While reordering gb_deactivate sequence to avoid protocol error this was
mistakenly added even during shutdown_tx/rx. It is supposed to be done
immediately after stop_tx and only once.
Fixes:
739f25d5f490 ("audio: Reorder gb_deactivate sequence to avoid protocol error")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Thu, 9 Jun 2016 04:00:39 +0000 (09:30 +0530)]
greybus: Use mute_stream callback to initiate GB data xfer
Currently trigger callback is used to start/stop greybus tx/rx
path. This works well for almost all scenario except few
specially handled usecases by Android Audio subsystem.
In case of Music playback followed by Incoming ringtone, above
layer tries to trigger_pause from one FE dailink and start a
fresh playback via different FE dailink. Since, same BE dailink
is used for both cases, an invalid state transition is requested
i.e. from PAUSE->START. This fails & thus causes ringtone playback
failure. With built-in codec, trigger callback is not required to
initiate data xfer unlike gb-codec driver.
This state transition should be handled in Android layer, but
since it can lead to multiple side effects for various usecase
we are trying to avoid trigger callback in gbcodec driver as well.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Eli Sennesh [Fri, 3 Jun 2016 15:24:44 +0000 (11:24 -0400)]
greybus: update UniPro Set Interface Power Mode operation to match spec
Bring the gb_svc_intf_set_power_mode() up-to-date with the current Greybus
specification. This largely involves adding more members to the structure
sent across the wire. Also change the camera code to use the new
operation properly, with default values passed for the new necessary
arguments. The correctness of these default values is confirmed via testing
and by asking Rob Johnson.
We must make sure to zero the request structure sent across the wire, lest
bite us most cruelly, and we fix by changing the Set Power Mode
Response structure to use a __u8 rather than a __le16.
Testing Done: Took a picture with a camera module, received error code
when passing deliberately incorrect values for new parameters, got proper
-EIO and Greybus result code printed when operation stopped halfway
through. Could induce error by initializing request struct with random
nonsense, and can stop it by initializing request struct with zeroes.
Associated Firmware Changes: 1669-1671 on Android N Gerrit for SW-2945
Signed-off-by: Eli Sennesh <esennesh@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:42 +0000 (16:34 +0530)]
greybus: connection: Avoid unnecessary line breaks
Some line breaks weren't required as we never crossed 80 columns, remove
them.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:40 +0000 (16:34 +0530)]
greybus: hd: Export host device tracepoint from hd.c
There is no point keeping this code in core.c, while its only used by
hd.c. Relocate it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:39 +0000 (16:34 +0530)]
greybus: Remove legacy suspend/resume callbacks
We should be using the PM hooks available within the 'struct
device_driver', instead of adding legacy suspend/resume callbacks.
Remove them.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:38 +0000 (16:34 +0530)]
greybus: Use BIT(2) for GREYBUS_ID_MATCH_CLASS
Bit 2 was left unused, use it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:36 +0000 (16:34 +0530)]
greybus: core: Make greybus_match_one_id() return bool
This routine always returns 0 or 1 and a return type of 'bool' suits it
the best. Update it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:35 +0000 (16:34 +0530)]
greybus: bootrom: Compile as a separate module
User space doesn't break anymore with new greybus modules and its time
to make bootrom a separate module.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Marti Bolivar [Thu, 9 Jun 2016 21:46:47 +0000 (17:46 -0400)]
greybus: remove obsolete SVC result codes
The "busy" SVC result codes are gone from the spec. Delete them.
Testing Done: compile.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Thu, 9 Jun 2016 11:04:34 +0000 (16:34 +0530)]
greybus: pwm: Fix compilation with v4.3 kernel
pwm_is_enabled() wasn't enabled by v4.2-rc1, but it was based of
v4.2-rc1. It was actually first included in v4.3.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Gjorgji Rosikopulos [Thu, 9 Jun 2016 08:53:15 +0000 (11:53 +0300)]
greybus: camera: Add debug data format
Add support for greybus debug data format.
Greybus debug data format id is 0x42.
Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Thu, 9 Jun 2016 16:42:19 +0000 (18:42 +0200)]
greybus: fix forced disable of offloaded connections
Core disables all connections for bundles whose interface is already
gone in order to avoid unnecessary operation timeouts during driver
disconnect.
This isn't needed for offloaded connections (as the AP can not send
requests over such connections), and in fact must not be done since only
the bundle driver currently knows how to disable I/O on such connections
in a class-specific way (this may eventually be handled by core though).
Also add comment about why connection are disabled early on forced
disconnect.
Testing Done: Tested on EVT2.
Reported-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Wed, 8 Jun 2016 21:54:01 +0000 (16:54 -0500)]
greybus: tracing: drop "greybus" prefix
I posted this once before but it got rejected for fear it would
not be clear which messages were related to Greybus.
Every trace event currently defined for Greybus is recorded in a
function whose name begins with "gb_". Every trace event reported
in /sys/kernel/debug/tracing/trace includes the name of the function
in which the event was recorded.
Get rid of the "greybus: " prefix in all of the Greybus trace
events. It just takes up precious space and is not actually
helpful. Anyone actually enabling individual trace events should
know enough about what they're doing to recognize which ones
are being enabled.
Signed-off-by: Alex Elder <elder@linaro.org>
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>
Alex Elder [Wed, 8 Jun 2016 19:44:22 +0000 (12:44 -0700)]
greybus: don't key on an enumerated constant
The symbol PWMF_ENABLED is defined via an enum, which is not defined
at the time the preprocessor passes through "kernel_ver.h". So we
can't use it in an #if statement expression.
Use the Linux kernel version instead.
Change-Id: Id427224b1dfecfd886fcdae89c4bcf711b616439
Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Wed, 8 Jun 2016 07:39:00 +0000 (09:39 +0200)]
greybus: svc: pwrmon: validate svc protocol op status when getting rail names
AP should check for Greybus SVC Protocol Operation Status to determine if the
operation was successfully completed by the SVC
Testing Done:
- Successfully getting the rail names in the pwrmon_dummy sandbox branch
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Greg Kroah-Hartman [Wed, 8 Jun 2016 04:33:54 +0000 (21:33 -0700)]
greybus: kernel_ver.h: provide pwm_is_enabled()
In the 4.7-rc1 kernel release, PWMF_ENABLED is removed and
pwm_is_enabled() is the correct way to test if a pwm device is enabled,
so provide a version of that function that will work on all older
kernels and change the pwm.c driver to use it so that it will work on
newer kernels as well.
Tested:
Tree now builds successfully against 3.14.y, 4.4.y, 4.5.y,
4.6.y, and 4.7-rc2 kernels
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Wed, 8 Jun 2016 15:03:26 +0000 (20:33 +0530)]
greybus: audio: Ratelimit err messages
In case of audio mgmt connection failure, GB requests would fail giving
an error message within the driver and reporting error. However there is
no error handling in above HAL and it'll keep on triggering similar
request via GB codec driver. This may overflood serial console. In one
of the instance it locked CPU for >10sec and caused a watchdog bite.
Thus ratelimit those error messages.
Testing Done: compile tested
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Jeffrey Carlyle [Tue, 7 Jun 2016 15:22:22 +0000 (08:22 -0700)]
greybus: svc: implement connection_quiescing call
Implement Greybus remote call to connection_quiescing operation. This
operation disables flow contorl for the connection and resets associated
attributes.
Testing done: tested along with required NuttX firmware changes, booted
EVT2, inserted module, removed module, inserted module. Verified module
was functioning as expected.
Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Sun, 5 Jun 2016 13:03:30 +0000 (14:03 +0100)]
greybus: timesync: Add debugfs entry to display frame-ping in ktime
This patch makes a debugfs entry in
/sys/kernel/debug/greybus/X-svc/frame-ktime that generates a TimeSync ping
event to the system and then subsequently presents that data to user-space
as a ktime/timespec clock-monotonic value rather than as a raw frame-time,
to aid humans in debugging and understanding frame-time and to provide an
example of the converting a frame-time to timespec/ktime to other
developers.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Sun, 5 Jun 2016 13:03:29 +0000 (14:03 +0100)]
greybus: timesync: Add gb_timesync_frame_time_to_timespec()
This patch adds gb_timesync_to_timespec_by_svc() and
gb_timesync_to_timespec_by_interface() respectively. These routines will
convert from a given FrameTime to a ktime/timespec within an envelope of
about 17 seconds. The purpose of this routine is to enable reporting of a
FrameTime from a Module such as a Camera Module and to allow the AP to
then convert this timestamp into a Linux-native timestamp such as ktime.
This is useful and required in the v4l layer.
At 19.2MHz the accuracy of this conversion is about .3 femtoseconds per
count, which means at a 1 second offset from the reference the cumulative
error is about 1.59 nanoseconds. 1.59 nanoseconds is still less than 1
clock's worth of error @ 19.2MHz where each clock is 52.0833~ nanoseconds.
We're aiming for a maximum error rate of 30 nanoseconds which means at the
clock rate we are running at, the conversion from a FrameTime to a Linux
ktime/timespec can be plus-or-minus about 17 seconds from the reference
FrameTime/ktime pair before the routine will refuse to convert.
A realistic use-case for this routine is envisaged to be
- Greybus message received
- Some processing takes place - taking milliseconds
- Call into this routine is made
- Actual time between event in Module and conversion in AP < 1 second
- Error rate in conversion at 1.59 nanoseconds is less than 1 clock
@ 19.2MHz
This routine is not designed to allow for conversions for events with
large gaps between the event time and the current reference time for
conversion. Since FrameTime can be a very large integer we cannot convert
an arbitrarily large FrameTime to ktime, the feeling and objective here is
to make an over-provisioned envelope that in practical terms can never be
exceeded by expected use-cases. To convert longer gaps more work would have
to be done but ultimately some limit needs to be imposed and right now 0.3
femotseconds per clock on MSM8994 is both accurate and generous.
Adds:
- timesync.c::gb_timesync_frame_time_to_timespec_by_svc(
struct gb_svc *,
u64 frame_time,
struct timespec *ts)
- gb_svc is a pointer to a standard greybus SVC data structure
- frame_time is a system FrameTime.
- ts is an output parameter which represents the converted FrameTime
as a CLOCK_MONOTONIC timespec value.
- Returns 0 on success or a negative number indicating the type of
error on failure.
- timesync.c::gb_timesync_frame_time_to_timespec_by_interface(
struct gb_interface *,
u64 frame_time,
struct timespec *ts)
- gb_svc is a pointer to a standard greybus Interface data structure
- frame_time is a system FrameTime.
- ts is an output parameter which represents the converted FrameTime
as a CLOCK_MONOTONIC timespec value.
- Returns 0 on success or a negative number indicating the type of
error on failure.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Sun, 5 Jun 2016 13:03:28 +0000 (14:03 +0100)]
greybus: tracepoints: Add standard Linux tracepoint for TimeSync event
This patch adds a tracepoint to the TimeSync ISR, the purpose of which is
to indicate a TimeSync event has happened. This tracepoint can be enabled
by issuing the following command:
echo 1 > /sys/kernel/debug/tracing/events/greybus/gb_timesync_irq/enable
Synchronization looks like this:
TIMESTAMP FUNCTION
| |
147.865788: gb_timesync_irq: strobe 1/4 frame-time
2910076529
147.866781: gb_timesync_irq: strobe 2/4 frame-time
2910095689
147.867777: gb_timesync_irq: strobe 3/4 frame-time
2910114820
147.868791: gb_timesync_irq: strobe 4/4 frame-time
2910134038
A ping can be triggered like this:
cat /sys/kernel/debug/greybus/frame-time
And that ping looks like this:
TIMESTAMP FUNCTION
| |
147.934678: gb_timesync_irq: ping 4/4 frame-time
2911380356
169.280551: gb_timesync_irq: ping 4/4 frame-time
3321221069
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Sun, 5 Jun 2016 13:03:27 +0000 (14:03 +0100)]
greybus: timesync: Bind TimeSync into Greybus
TimeSync needs to bind into Greybus in a few places.
- core.c
To initialize its internal state and tear-down its internal state.
To schedule a timesync to a newly added Bundle after probe() completes.
- svc.c
To get access to the SVC and enable/disable timesync as well as
extracting the authoritative time from the SVC to subsequently
disseminate to other entities in the system.
- interface.c
To get access to an Interface in order to inform APBx of timesync
enable/disable and authoritative operations.
This patch adds those bindings into Greybus core.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Sun, 5 Jun 2016 13:03:26 +0000 (14:03 +0100)]
greybus: timesync: Add timesync core driver
This patch adds the core timesync functionality.
0. arche-platform.c/arche-apb-ctrl.c
Modifies the platform layer to hook the incoming TIME_SYNC signal up to
the timesync strobe IRQ handler. If the arche-platform driver can't
satisfy the request for the wake-detect line, it will return -EAGAIN and
the calling work-queue must reschedule the attempt to get exclusive
access to the wake-detect pin logic. A private data field is added to
the arche-platform driver to enable passing of a timesync pointer to the
ISR responsible for synchronizing time.
1. timesync.c
A new file added which contains all of the logic associated with sending
greybus commands to SVC, APBx or Interfaces to enable, disable and
disseminate timing information.
2. timesync_platform.c
Any platform/arch specific code goes into timesync_platform.c.
Originally the idea was to keep the x86 and ARM arch dependencies in a
timesync_platform_arch.c file - however with further refinement that's
currently not necessary however just-in-case it becomes necessary to
resuscitate arch or platform specific methods for accessing timer
resources that access shouldn't be part of the core timesync.c logic and
so for the moment we access these timer resources through a thin access
layer in timesync_platform.c. Expect this to go away long term ideally.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Fri, 3 Jun 2016 12:15:30 +0000 (17:45 +0530)]
greybus: audio: Report DISCONNECT event after resource cleanup.
Reporting DISCONNECT event immediately on module removal causes
race condition while re-populating mixer controls by above HAL. The
original intent was to avoid any (invalid) mixer control modification
request from above layer.
Ideally, it should report 'MODULE_NOT_READY' on module plug-out and
DISCONNECT after resource cleanup. This would involve changes in GB
Audio manager and HAL layer.
Since we already have a plan to remove GB Audio manager, I'm making this
change in GB codec driver to avoid any race condition. Also, codec
driver already ensures mixer control modifcations for disconnected
modules are not triggered to AP Bridge audio FW & reported invalid.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Fri, 3 Jun 2016 12:15:29 +0000 (17:45 +0530)]
greybus: audio: Report warning in case module is already removed
Added warning message in find_gb_module(). This will help to identify
invalid mixer control/widget modification triggered from above layer.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:39 +0000 (15:55 -0500)]
greybus: tracing: fix message traces
The original message trace events were defined long before the
recent tracing updates. It records information that's not
really directly related to a message. Change the information
recorded and reported for message events to just be the content
of the message header.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:38 +0000 (15:55 -0500)]
greybus: tracing: add timing traces
Bryan reports he used certain message traces to determine when time
sync messages transit the boundary between the Greybus core and the
host device. This patch adds two trace events--one a message event
for outbound messages (because it indicates its operation and its
destination), and one host device event for incoming messages
(because message information isn't available as early as desired).
These events are being created to allow the same sort of analysis
of messages without having to store extra information for every
message trace. (The next patch changes the information a message
trace records.)
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:37 +0000 (15:55 -0500)]
greybus: tracing: define connection traces
Define a new gb_connection trace point event class, used to trace
events associated with the connection abstraction. Define four basic
trace events for this--creation, drop of last reference, and when
adding or dropping any other reference. There are certainly
more events that we might want to add, but aim is to just get the
basic framework in place.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:36 +0000 (15:55 -0500)]
greybus: tracing: define bundle traces
Define a new gb_bundle trace point event class, used to trace events
associated with the bundle abstraction. Define four basic trace
points for this--creation time, drop of last reference, before
adding it to its interface and when removed when its interface
is destroyed.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:35 +0000 (15:55 -0500)]
greybus: tracing: add interface mode_switch
Add the value of an interface's mode_switch field to the information
tracked and reported for tracing.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:34 +0000 (15:55 -0500)]
greybus: tracing: assign "parent" id first
Most abstractions to be traced will have a sort of "parent" object
it is associated with, and an identifier for that parent is stored
with the as trace event data. For example, the parent of a message
is the operation it's a part of, and the parent of an operation is
the connection it uses.
We'll arrange to define that parent id first in all events. Most
abstractions already do this. Move an interface's module id so it's
defined and assigned first. The message traces are going to be
changed soon, so leave that one alone.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:33 +0000 (15:55 -0500)]
greybus: tracing: fix module num_interfaces
A module's num_interfaces field is included in the data to be
recorded for tracing, but it's never assigned or reported. Fix
its type to be size_t, to match its definition in the gb_module
structure.
Also correct a format length modifier used for a host device's
num_cports field.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:32 +0000 (15:55 -0500)]
greybus: tracing: reorder trace definitions
Move the definition of the module trace events below those for the
interface. We'll define them in an order that represents a sort of
layering of the abstractions (note not all of these are defined yet):
message
operation
connection
bundle
interface
module
host device
Other tracepoints (like perhaps some tied to timesync) will go at the
beginning or end.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:31 +0000 (15:55 -0500)]
greybus: tracing: fix host device num_cports
The type of the gb_host_device num_cports field is size_t. Correct
the num_cports data recorded with a host device event so its type
matches that; fix the format length modifier used for it as well.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:30 +0000 (15:55 -0500)]
greybus: define BUNDLE_ID_NONE
Define a bundle ID that means "no bundle". This will be used for
tracing connection events during the portion of a connection's
lifetime when it has no bundle associated with it. Don't allow
any bundle to be created using that ID.
Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 3 Jun 2016 20:55:29 +0000 (15:55 -0500)]
greybus: tracing: fix "make check" warnings
Some of the trace buffer fields were defined as Booleans. This
leads to two problems reported by "make check":
- the __field() macro (or some descendent macro) performs
a sizeof(bool) operation, which results in a warning
- The TP_printk() macro, which specifies a printf() style
format string, produces a warning when one attempts to
format a Boolean as an integer.
Fix both problems implicitly converting Boolean values from the data
structures into integers in the trace buffer.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Evgeniy Borisov [Tue, 31 May 2016 08:33:11 +0000 (11:33 +0300)]
greybus: camera-gb: Implement camera module reference counting as subject.
In explanation:
The main idea for implementing reference counting is to not block exit
until any other modules are in use. Camera responsibility is to handle
properly any additional calls after camera exit and that what this
patch is doing:
1. Free camera module when reference count is zero.
2. After camera cleanup handle properly any additional ongoing
transaction. Return error if connection is destroyed.
Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Evgeniy Borisov [Tue, 31 May 2016 08:33:10 +0000 (11:33 +0300)]
greybus: camera-gb: Extend gb camera module structure
Add additional information in gb camera module.
- interface ID
- reference count
- release handle
Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Evgeniy Borisov [Tue, 31 May 2016 08:33:09 +0000 (11:33 +0300)]
greybus: camera-gb: Add description of interface header
Add description for all interface structures in
gb-camera.h.
Signed-off-by: Evgeniy Borisov <eborisov@mm-sol.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 30 May 2016 09:02:09 +0000 (14:32 +0530)]
greybus: Add comment about the mode_switch_started flag
Add a comment to describe the purpose of the flag.
Suggested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 30 May 2016 07:35:10 +0000 (13:05 +0530)]
greybus: interface: Mode switch takes over a second
Mode switch takes just over a second to complete and the current timeout
of one second isn't sufficient.
Mode-switch logs from EVT 1.5:
[ 56.709082] gb-firmware 1-3.3.1: Requested firmware package 'ara_00000126_00001002_fffe0001_ff980067_03.tftf'
[ 57.003968] gb_control_mode_switch_operation: 176
[ 58.041616] greybus 1-3.3: mode switch detected
Increase the timeout to two seconds.
Tested with EVT 1.5 with gpbridge-test module.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Karthik Ravi Shankar <karthikrs@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 30 May 2016 07:35:09 +0000 (13:05 +0530)]
greybus: control: Mode-switch is a 'core' operation
The operation layer allows only the 'core' operations on a connection,
which is in its 'disconnecting' state.
Mode switch is sent at the very end of interface-disable sequence, and
the control connection is already in its 'disconnecting' state at that
time. And so gb_operation_get_active() always fail with error -ENOTCONN.
The operation core already has support for such 'core' operations, just
that we were missing the needed flag while creating the mode switch
operation.
Fix that.
Tested on EVT 1.5 with gpbridge-test module.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Karthik Ravi Shankar <karthikrs@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 30 May 2016 07:35:08 +0000 (13:05 +0530)]
greybus: fw-mgmt: Add hooks to do mode-switch
This is the last step to required to finish the mode switch story. That
is, call the hook provided by Interface layer to accomplish mode switch.
Tested on EVT 1.5 with gpbridge-test module.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Karthik Ravi Shankar <karthikrs@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Mon, 30 May 2016 06:01:53 +0000 (11:31 +0530)]
greybus: gbphy: Remove protocol specific version handling
We should be using the generic version handling at bundle level, instead
of at protocol level for bridged PHY devices as well.
The bundle version handling is already in place, though it is *not* used
today as we haven't bumped the version of control protocol yet.
Remove protocol specific handling for bridged PHY devices.
Tested on EVT 1.5 with gpbridge-test module. No nuttx changes are
required with this.
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>
Viresh Kumar [Mon, 30 May 2016 06:01:52 +0000 (11:31 +0530)]
greybus: Remove unused VERSION specific macros
We don't use these anymore. Drop them.
Note that some macro's specific to bridged PHY devices aren't removed in
the patch, as gbsim will break otherwise. They will be removed
separately.
Compile tested.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:13 +0000 (14:36 +0200)]
greybus: uart: wait for credits on shutdown
We should try to wait until all credits are accounted
for before returning from shutdown.
For this purpose add a helper function that will
wait on completion, and call it form the shutdown.
This helper will also be useful when "wait until sent" is
implemented.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:12 +0000 (14:36 +0200)]
greybus: uart: Implement flush_buffer
Data may be held pening in the hardware because of flow
control mechanisms. When the port is closed, we need to flush
all data that was not sent.
For this, use the greybus message GB_UART_TYPE_FLUSH_FIFOS
which will flush all data queued on the module but not
yet sent on the data line.
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:11 +0000 (14:36 +0200)]
greybus: uart: Add credits based tracking for transmit path
To avoid polling the firmware for space, a credit based system
is implemented.
The host will keep track of how many credits (bytes) it has
sent to the firmware, and stop sending data when the quota
is filled.
The host will be informed that the firmware has more
room for data when it handles the receive_credits request
message from the firmware, and will continue to write data
as credits become available.
The firmware and the host may implement an algorithm to aggregate
credits, and avoid extra greybus traffic.
Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:10 +0000 (14:36 +0200)]
greybus: uart: Use a fifo to send data to the modules
The firmware now buffers data instead of blocking while the transfer
is sent, and the write operation cannot sleep.
Instead of using gb_transfer_sync (which sleeps) in the write callback,
buffer data in a fifo and send it from from a work queue.
The write_room callback will will report 1 byte less that what is really
available in the fifo, to leave space for extra characters that may
be added by the tty layer.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:09 +0000 (14:36 +0200)]
greybus: uart: Implement dtr_rts callback.
Dtr_dts allows the tty layer to set the flow control lines
to the correct state during open and close.
Note that locking for newctrl is missing throughout the
driver and will be addressed on a separate patch.
Suggested-and-reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Tue, 31 May 2016 12:36:08 +0000 (14:36 +0200)]
greybus: uart: Handle CRTSCTS flag in termios
Handle the CRTSCTS flag in set_termios, so that auto
flow control can be turned off. For this, add a new flag
in the line coding request specifically for this purpose.
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 16:23:01 +0000 (18:23 +0200)]
greybus: hd: fix gb_hd_release tracepoint
The recently added gb_hd_release tracepoint was added to the wrong
function.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 16:23:02 +0000 (18:23 +0200)]
greybus: fix tracepoint-related whitespace issues
Fix some whitespace issues introduced by the recent tracepoint changes.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 15:26:41 +0000 (17:26 +0200)]
greybus: svc: remove deprecated hotplug operations
Now that firmware has made the switch to the new interface boot
sequence, we can remove support for the deprecated hotplug and
hot-unplug operations.
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 15:26:40 +0000 (17:26 +0200)]
greybus: interface: implement generic mode-switch functionality
Add a generic interface for bundle drivers to use to request that a
mode switch is carried out on its behalf.
Mode switching involves tearing down all connections to an interface,
sending a unidirectional mode-switch request, and waiting for a mailbox
event that triggers deferred control connection reset and re-enumeration
of the interface. In case of a timeout waiting for the interface mailbox
event, or on other errors, the interface is powered off.
All of this needs to be done by core from work-queue context in order
not to block incoming SVC requests and bundle-device tear down. Care
must also be taken to serialise against concurrent module removal events
and eject requests.
Special handling of legacy mode-switching is also added in order to
continue to support the ES3 bootrom.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 15:26:39 +0000 (17:26 +0200)]
greybus: control: add error message to mode-switch helper
Print an informative error message in case sending the mode-switch
request fails.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Fri, 27 May 2016 15:26:38 +0000 (17:26 +0200)]
greybus: kernel_ver: backport reinit_completion to pre-3.13
Backport upstream reinit_completion() to pre-3.13 kernels.
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>