Alex Elder [Tue, 24 May 2016 18:34:49 +0000 (13:34 -0500)]
greybus: eliminate unneeded null check
Coccinelle points out that debugfs_remove_recursive() handles a null
argument properly, so there's no need to check for NULL before
making the call. I have verified this is true of the kernel we're
now working with (arche-6.0).
Alex Elder [Tue, 24 May 2016 18:34:48 +0000 (13:34 -0500)]
greybus: fix unbalanced mutex
Running "make coccicheck" on the Greybus code reports that
gb_mmc_get_ro() and gb_mmc_get_cd() can return without releasing
the mutex it acquired if there's an error. Fix this.
Alex Elder [Tue, 24 May 2016 18:34:47 +0000 (13:34 -0500)]
greybus: report right error value
Running "make coccicheck" on the Greybus code discovered that
an error message in gb_camera_debugfs_init() was interpreting
the wrong value in reporting the error code. Fix that.
Vaibhav Agarwal [Fri, 27 May 2016 05:19:24 +0000 (10:49 +0530)]
greybus: es2: Release reserved cports CDSI0 and CDSI1
Unique ids were reserved for CDSI0 and CDSI1 during _probe, however
missed to release those ids during disconnect. This causes a memory leak
of 128 bytes for each iteration of unipro_reset. Fix this.
Vaibhav Agarwal [Fri, 27 May 2016 05:19:23 +0000 (10:49 +0530)]
greybus: hd: Add API to release reserved CPorts
It is required to release all unique ids registered via ida_get_simple
to avoid any possible memory leak. cport_release() already exists with
special handling for ES2_CPORT_CDSI1, i.e. updating in_use flag without
removing associated ida.
So, added another API to release reserved cports CDSI0 and CDSI1. This
is intended to be used only during es2_destroy().
Alex Elder [Tue, 24 May 2016 04:05:32 +0000 (23:05 -0500)]
greybus: tracing: define interface traces
Define a new gb_module trace point event class, used to trace events
associated with the interface abstraction. Define four basic trace
points for this--creation time, drop of last reference, before
registring interfaces and after de-registering them. In addition,
define traces for activating and deactivating, and enabling and
disabling an interface.
Alex Elder [Tue, 24 May 2016 04:05:31 +0000 (23:05 -0500)]
greybus: tracing: add module traces
Define a new gb_module trace point event class, used to trace events
associated with the module abstraction. Define four basic trace
points for this--creation time, drop of last reference, before
registring interfaces and after de-registering them.
Alex Elder [Tue, 24 May 2016 04:05:30 +0000 (23:05 -0500)]
greybus: tracing: fix hd traces
Currently there are two trace points defined for the Greybus host
device structure. One records information when a message gets sent,
and another when it gets received. Neither of these is really a
host device event.
We have trace points defined for messages that dump information
about all sent and received messages. As a result, the information
about sending messages over a host is redundant, and can go away.
(Note that the message traces may need a little refinement so they
produce all desired information.)
Instead of these trace points, define some that are directly
related to the host device abstraction: when one is created,
added, deleted, or released (destroyed). These do not require
a CPort ID or payload size, so eliminate those two parameters
from the host device trace point prototype. Change the trace
information recorded for a host device to be just a subset of
interesting fields in a host device.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Core will never call host-device callbacks with invalid arguments (and
that would still need to be verified in bridge firmware anyway), so
remove the redundant and insufficient sanity check from the callbacks.
Vaibhav Hiremath [Tue, 24 May 2016 13:02:04 +0000 (18:32 +0530)]
greybus: arche-platform: Enable SVC clock during FW_FLASHING state
The issue is, as part of kernel-only build we started seeing
failures in SVC FW flashing. It was reproducible easily in kernel-only
build, but never observed on Android build.
During debugging, there were couple of observations,
1. If SVC clock enabled and disables (which is REFCLK_MAIN), then SVC FW
flashing works.
2. If we do not switch SVC to HSE (external clock source) it works.
Recently, SVC code has been updated to switch HSE clock, so removing
it (remove/skip rcc_switch_ara_pll() fn) would use internal clock only.
As per STM32 spec, for flashing through USART we do not need
to enable HSE, but the above observation contradicts with it.
There is still something missing in terms of understanding of how STM32
device functions as far as Flashing is concerned. There is something
hidden in HW, which probably still need to identify.
So as a interim solution we will enable clock for FW_FLASHING state,
which seems to be fixing the issue here.
Testing Done: Tested on EVT1.5 with arche6.0 and kernel-only build.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: Michael Scott <michael.scott@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Hiremath [Tue, 24 May 2016 13:02:03 +0000 (18:32 +0530)]
greybus: arche-platform: Enter ACTIVE state only from OFF state
Make sure that, transition to active state happens only from OFF state.
Instead of imposing the restriction to user-space, driver internally
switches to OFF state and then to ACTIVE state.
Testing Done: Tested on EVT1.5 platform.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: Michael Scott <michael.scott@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Eli Sennesh [Mon, 16 May 2016 18:55:17 +0000 (14:55 -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.
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.
Associated Firmware Changes: 6810-6812 on Gerrit for SW-1239, 6870 and
5612-5613 on Gerrit for SW-2945
Signed-off-by: Eli Sennesh <esennesh@leaflabs.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Bryan O'Donoghue [Mon, 23 May 2016 14:01:08 +0000 (15:01 +0100)]
greybus: Fix unbalanced irq_enable() backtrace
Tip-of-tree is exhibiting a backtrace when loading-up the set of greybus
kernel modules due to calling arche_platform_wd_irq_en() directly after a
call to devm_request_threaded_irq().
At the point we call arch_platform_wd_irq_en() the relevant IRQ will
already be enabled. What we want to do in this situation is configure the
GPIO line as an input. This patch fixes the backtrace by supplanting
arche_platform_wd_irq_en() with
gpio_direction_input(arche_pdata->wake_detect_gpio) in
arche_platform_probe().
David Lin [Sat, 21 May 2016 01:37:02 +0000 (18:37 -0700)]
greybus: legacy: remove protocol.o from the makefile
Commit 0917cba11 ("legacy: remove legacy driver support")
removed protocol.c, however, the corresponding target in the Makefile
was not removed therefore broken the build.
Testing Done:
- Build & boot on EVT1.5
Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alex Elder [Fri, 20 May 2016 16:44:56 +0000 (11:44 -0500)]
greybus: tracing: eliminate "location" comments
Each message event has a set of comments preceeding its definition.
One of them, "location", indicates where that event is used. I
am certain that this comment will become out of date very easily.
Hopefully just the name of the event is a good enough suggestion
about where it will be used.
Alex Elder [Fri, 20 May 2016 16:44:55 +0000 (11:44 -0500)]
greybus: tracing: define events using macros
A tracepoint event is defined with TP_PROTO() and TP_ARGS macros
that match that of the event's class. A lot of repetition (and
opportunity for inadvertent errors) in tracepoint event definitions
can be eliminated by using a macro. Define and use class-specific
event definition macros for gb_message and gb_host_device class
events.
Alex Elder [Fri, 20 May 2016 16:59:57 +0000 (11:59 -0500)]
greybus: add operation traces
Define a new gb_operation event class, and define and use trace
events that record when an operation is created, finally destroyed,
and when its active count changes.
Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Now, since AP module does not send any signal to SVC, so it
automatically restricts the wake/detect gpio to input.
So rename assert_wakedetect() fn to arche_platform_wd_irq_en(),
as per implementation.
Vaibhav Hiremath [Tue, 17 May 2016 17:09:46 +0000 (22:39 +0530)]
greybus: arche-platform: Do not assert wake/detect signal to SVC
With new definition of AP module boot flow (from HotPlug camp),
AP is not supposed to send any wake/detect signal to SVC, instead,
during boot SVC would straight away send wake_out pulse on wake/detect
line.
Note that, pin configuration of wake/detect line would be set to
active-high by default, so wake/detect line would always stay high,
unless SVC drives it. AP module uses wake/detect line strictly in input
mode.
Testing Done: Tested on EVT1.5 platform.
Note: We are yet to decide on PM support for APBx, so we may need to
generate/handshake with SVC over wake/detect line in the future. As of
now, follow the implementation and add stuff as and when they come.
Sandeep Patil [Thu, 19 May 2016 15:52:39 +0000 (08:52 -0700)]
greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhere
The 'gpbridge' name didn't relaly reflect what the bus is; which
is a bus for bridged-phy devices. So, rename all instances
of 'gpbridge' to more appropriate 'gbphy'
Testing Done:
Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices
until I change the library to reflect this change.
Jeffrey Carlyle [Thu, 19 May 2016 01:55:13 +0000 (18:55 -0700)]
greybus: interface: retry enumeration of UniPro-only modules
Greybus modules will sometimes fail to send the mailbox poke and
erroneously be enumerated as UniPro-only modules. The root cause for
this on the module side is not fully understand, but it seems that this
may be due to "the bootrom bug:" a known problem with the bootrom where
linkup will occasionally fail because of a race condition.
Before the new hotplug code was implemented in the firmware, the SVC
would retry enumeration of modules that did not send the mailbox poke;
this patch ports that functionality to the AP.
Alex Elder [Tue, 17 May 2016 14:13:16 +0000 (09:13 -0500)]
greybus: connection: verify disabled when destroyed
A connection must be in DISABLED state before it gets destroyed.
Warn if this is ever not the case (and do the disconnect) before
proceeding with connection destruction.
Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 18 May 2016 13:47:48 +0000 (15:47 +0200)]
greybus: operation: fix broken activation logic
An operation should only be added to the connection active list if the
connection is in the enabled state, or if it is in the enabled_tx state
and the operation is not incoming.
This fixes a race where an early or late incoming request could be added
to the active list while the connection is being enabled or disabled,
something which could lead to use-after-free issues or worse.
Note that the early connection-state checks in the receive path
limited the impact of this bug.
Fixes: e903a2ce7379 ("connection: add unidirectional enabled state") Reported-by: Alex Elder <elder@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Eli Sennesh [Fri, 13 May 2016 17:27:40 +0000 (13:27 -0400)]
greybus: operation: rate-limit dev_err printing on the receive path
When we receive Greybus operations we don't recognize, requests or responses,
en masse, we can pile up a lot of dev_err() printk messages. Doing so along
the gb_connection_recv() code path can delay receive processing by up to seven
milliseconds, starving the system of bulk-IN urbs. Rate limit those printk
messages, ensuring that after too many repeated errors at the same place in
the code-path, we'll stop printing to the console at all and let the urbs get
returned.
This will help prevent denial-of-service attacks on the AP through the UniPro
network from malicious or malfunctioning modules.
Testing Done: 7 msec recv-to-resubmit-urb processing times go down to <20
usecs
Signed-off-by: Eli Sennesh <esennesh@leaflabs.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Mitchell Tasman <tasman@leaflabs.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rui Miguel Silva [Mon, 16 May 2016 09:33:21 +0000 (10:33 +0100)]
greybus: spi: add inprogress bit to xfer_flags
When a SPI transfer needs to be split by more than one greybus spi
transfer operation, we need to indicate it so the controller can handle
the chip select lines correctly.
Add a new bit to indicate it, GB_SPI_XFER_INPROGRESS, and create an
helper function to calculate when the transfer is done. As we need this
information also in other places.
Viresh Kumar [Mon, 16 May 2016 15:24:53 +0000 (20:54 +0530)]
greybus: fw-management: Update header's license
The header should include both BSD and GPLv2 licenses and so should have
been a copy of greybus_protocols.h. This file had only the GPLv2 bits
earlier, update it to include BSD bits as well.
Viresh Kumar [Mon, 16 May 2016 02:19:43 +0000 (07:49 +0530)]
greybus: fw-management: Fix 'make check' warnings
Fix below warnings observed with 'make check'.
~/ara/greybus/fw-management.c:438:33: warning: incorrect type in assignment (different base types)
~/ara/greybus/fw-management.c:438:33: expected unsigned short [unsigned] [addressable] [assigned] [usertype] major
~/ara/greybus/fw-management.c:438:33: got restricted __le16 [usertype] <noident>
~/ara/greybus/fw-management.c:439:33: warning: incorrect type in assignment (different base types)
~/ara/greybus/fw-management.c:439:33: expected unsigned short [unsigned] [addressable] [assigned] [usertype] minor
~/ara/greybus/fw-management.c:439:33: got restricted __le16 [usertype] <noident>
Bryan O'Donoghue [Sun, 15 May 2016 18:37:49 +0000 (19:37 +0100)]
greybus: interface: Extract and store Interface feature byte
The Interface description in the Greybus specification contains a
'features' field which is currently not implemented on the AP side. The
Interface features field provides information on optional attributes of an
Interface as a bitmask. Currently only GREYBUS_INTERFACE_FEATURE_TIMESYNC
is implemented in the specification but, the expectation is that other
feature flags will be added over time.
This patch adds support to extract the feature byte communicated in the
features field of the Interface Descriptor header and extends struct
interface to contain a features field through which any user with a pointer
to struct interface may interrogate the features of an Interface.
This is a necessary pre-cursor for TimeSync to ensure only Interfaces which
declare GREYBUS_INTERFACE_FEATURE_TIMESYNC will be included when we go
through the process of FrameTime synchronization.
Bryan O'Donoghue [Sun, 15 May 2016 18:37:48 +0000 (19:37 +0100)]
greybus: hd: Add TimeSync APBridge commands
This patch adds a number of USB Vendor commands to es2.c to enable TimeSync
in the bridge.
Adds:
- es2.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
u32 refclk);
Commands APBx to enable timers and clocks to track a pulse-train of
incoming TIME_SYNC strobes with strobe_delay microseconds between each.
Provides the reference clock the AP is using to track FrameTime. It is
the responsibility of APBx to adequately track the FrameTime based on
the indicated AP refclk. Once this command has succeeded APBx may not
transition to a low-power state were FrameTime counters stop.
This function is initiated from the timesync worker thread logic when
re-synchronizing frame-time throughout the system.
TimeSync is at this time enabled for all APBx active in the system i.e.
currently APB2 will not receive TimeSync commands until it becomes a
registered host-device in Greybus.
- es2.c::timesync_disable(void)
Commands APBx to discontinue tracking of FrameTime. After this operation
completes APBx may transition to a low-power state where timer-clocks
stop operating.
- es2.c::timesync_authoritative(u64 *frame_time)
Provides an authoritative time for each TIME_SYNC strobe to APBx.
APBx must align its local FrameTime to the authoritative clock.
- es2.c::timesync_get_last_event(u64 *frame_time)
Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.
Viresh Kumar [Sat, 14 May 2016 18:12:23 +0000 (23:42 +0530)]
greybus: fw-management: Free fw-mgmt only after all users are gone
The fw-management driver rightly destroys the char device on
connection-exit, but that doesn't guarantee that all of the users of the
device are gone.
Userspace may still be holding file-descriptor of the char device and
can initiate new ioctl operations. And that *will* lead to kernel crash.
To avoid this issue, manage struct users with kref, manage a list of
'struct fw-mgmt' and start using the structure only after getting its
kref incremented.
The important part is the routine get_fw_mgmt(), which increments the
reference to the struct before returning it to the caller. The list of
fw-mgmt structs in protected with a mutex to avoid any races around
that.
The kref is incremented once the char device is opened and dropped only
when it is closed.
Viresh Kumar [Sat, 14 May 2016 18:12:19 +0000 (23:42 +0530)]
greybus: spi: Restructure spi.c to share it with other bundle drivers
This patch restructures spi.c as spilib core, so that the same logic can
be reused for SPI connections implemented as part of different bundle
types. This is required for Firmware Management Bundle.
Note that the 'struct gb_protocol' and its callback aren't moved to
a separate file in this commit to make its reviews easier. That will be
done by a following patch.
gb_control_timesync_get_last_event() sends a request asking for the
FrameTime at the last SVC strobe event. The responding entity returns the
FrameTime in the response phase of the request. Performing this operation
to an Interface after previously:
1. Synchronizing time using timesync-enable/timesync-authoritative
2. Sending an SVC_TIMESYNC_PING
will return the FrameTime of the responding entity at the SVC-ping. If
this command is sent before synchronization has been initiated or
successfully completed the responding entity should return an error
code.
- control.c::gb_control_timesync_get_last_event(u64 *frame_time)
Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.
Bryan O'Donoghue [Thu, 12 May 2016 11:43:50 +0000 (12:43 +0100)]
greybus: svc: Add TimeSync SVC commands
Simple addition of the TimeSync commands defined in the specification.
Adds:
- svc.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
u32 refclk)
Commands the SVC to initiate count TimeSync strobe pulses with
strobe_delay microseconds delay between each strobe to the specified
bit-mask of Interface IDs indicated in a previous
timesync_wake_pins_acquire command. The frame_time parameter indicates
the initial time the SVC should base the first strobe from. The refclk
parameter indicates the APs clock rate, the SVC should ensure its own
clock ticks at this rate. Once enabled the SVC may not enter a low-power
mode which will result in the reference timer used to track time
switching off. The SVC will capture the authoritative FrameTime at each
strobe and store these values for later propagation to the AP with the
timesync_authoritative request.
- svc.c::timesync_disable(void)
Commands the SVC to immediately halt TimeSync logic. This will allow
the SVC to transition into low-power modes where the reference timer
being used for TimeSync may switch off.
- svc.c::timesync_authoritative(u64 *frame_time)
Used by the AP Module to ask the SVC for the authoritative FrameTime
as captured at each TimeSync strobe.
- svc.c::timesync_ping(u64 *frame_time)
Used by the AP Module to command the SVC to initiate a single strobe on
a specified bit-mask of Interface IDs communicated in a previous
timesync_wake_pins_acquire command. SVC will latch the FrameTime on the
rising edge of the outbound pulse and will return the FrameTime to the
AP Module in the response phase of the greybus transaction.
- svc::timesync_wake_pins_acquire(u32 strobe_mask)
Used by the AP to tell the SVC to set a bit-mask of wake lines associated
with a bit-mask of Interface IDs to a known initial state prior to the
SVC generating a TimeSync related pulse such as timesync-enable or
timesync-ping.
- svc::timesync_wake_pins_release(void)
Used by the AP to tell the SVC to release all wake-detect lines in the
timesync active state as previously specified in the
timesync_wake_pins_acquire operation.
Johan Hovold [Wed, 11 May 2016 08:18:06 +0000 (10:18 +0200)]
greybus: camera: fix data-connection handling
Now that core supports offloaded connections, we can remove the hack
that was used to setup the data connection.
Note that offloaded-resource management may need to be refined later,
but the current minimal implementation is enough to allow core to manage
the connections (e.g. needed for proper connection tear down and power
management).
This will also allow the camera driver to be converted to a bundle
driver.
Johan Hovold [Wed, 11 May 2016 08:18:04 +0000 (10:18 +0200)]
greybus: es2: add support for CDSI1 allocation
Use the new CPort-allocation callbacks to allow for rudimentary resource
management of the CDSI CPorts.
How to manage offloaded resources in a generic fashion is yet to be
determined, but this minimal implementation will allow core to manage
the camera data connection so that the current camera-driver hacks can
be removed. This is specifically required to be able to implement proper
connection closing and for power management.
Note that the CDSI CPorts can not (currently) be reset through the
USB vendor request.
Johan Hovold [Wed, 11 May 2016 08:18:02 +0000 (10:18 +0200)]
greybus: hd: generalise cport allocation
Generalise CPort allocation by allowing host-device drivers to override
the default implementation.
Also pass the connection flags down the stack as such information is
needed for proper CPort allocation. Specifically, this will initially be
used to allow the camera driver to allocate the dedicated CDSI CPorts.
Johan Hovold [Wed, 11 May 2016 08:17:59 +0000 (10:17 +0200)]
greybus: hd: move CPort allocation to host-device code
Move host-device CPort allocation to the host-device code.
Proper CPort allocation requires knowledge of the hardware and must be
handled by the host-device driver. This is an intermediate step that
moves the generic CPort-allocation code to the host-device code.
Viresh Kumar [Thu, 12 May 2016 05:56:48 +0000 (11:26 +0530)]
greybus: Fix probing of gpbridge devices
The gpbridge core tries to match the driver's id-table against all
CPorts available within the bundle for which the gpbridge bus was
created. The gpbdev here is unique for a cport_desc and only a single
cport_desc->protocol_id should be matched with the driver's id-table.
Fix it.
Tested on EVT 1.5 with a special manifest for GP module, where multiple
CPorts are part of the same Bridged PHY bundle.
Viresh Kumar [Thu, 12 May 2016 06:50:02 +0000 (12:20 +0530)]
greybus: gpbridge: Expose protocol_id in sysfs
Right now, userspace doesn't have any way to find what protocol does a
gpbridge device implement. And this is essential for the scripts to
know, to expect what kind of device will be present inside the gpbN
directory.
Expose 'protocol_id' in sysfs to fix that.
Tested by checking that the field appears with GP module on EVT 1.5.
Jeffrey Carlyle [Wed, 11 May 2016 17:08:55 +0000 (10:08 -0700)]
greybus: svc: support status in svc_intf_activate response
Update per Greybus spec. Status attribute added to activate
response to return more detailed information about errors during
activate. If the Greybus response is GB_OP_SUCCESS, the caller
must also check the status attribute in the response to determine
if any other errors occurred.
Testing done: along with matchine firmware change, verified that modules
were detected and enumerated as expected.
Viresh Kumar [Mon, 9 May 2016 05:29:01 +0000 (10:59 +0530)]
greybus: fw-download: Replace timer with delayed-work
The timeout-handlers need to call routines that can sleep and those
can't be called from interrupt context. The timer-handler is called in
interrupt context and so will hit a BUG() in vmalloc.c.
This patch moves away from timers to delayed-work, whose timeout handler
gets called in process context and can call the sleep-able routines
safely.
Note that this issue wasn't hit earlier when the initial patch for
timeouts was implemented due to some issues in the build arche_420. But
with the new build arche_440, the BUG started crashing the phone on
timeouts and so this fix is required.
Tested on EVT 1.5 by triggering fake timeouts, by not sending
release-firmware request for example. This is tested with build
arche_440.
Viresh Kumar [Mon, 9 May 2016 05:29:00 +0000 (10:59 +0530)]
greybus: bootrom: Implement timeouts to detect Module failures
Its possible that the Module may fail to download the next stage
firmware, or to jump into it and boot into the new personality.
We have already seen examples of both of these cases on EVT 1.5.
This patch implements timeouts in the bootrom bundle driver, which now
expects the next request from the Module to be received at the AP within
1 second of the previous request/response. The time interval can be
increased later if required.
The timeouts are added between:
- AP_READY and FIRMWARE_SIZE operations
- FIRMWARE_SIZE and GET_FIRMWARE operations
- Two GET_FIRMWARE operations
- GET_FIRMWARE and READY_TO_BOOT operations
- READY_TO_BOOT operation and the call to the ->disconnect() event of
the bootrom bundle (once the new hotplug request is received).
The timeout for the last case is kept at 5 seconds right now (random
value), as it may take a bit longer.
Because 'bootrom->fw' can be accessed simultaneously (from timeout
handler and incoming requests) and one of them can potentially free the
'->fw' structure, a mutex is also added to take care of such races while
accessing 'bootrom->fw' structure.
Also note that the '!bootrom->fw' check is moved to free_firmware()
routine.
Note that this version uses delayed-work (instead of timers used in
earlier attempt), as we need to call routines that can sleep from the
timeout handler.
Tested on EVT 1.5, by faking errors on certain requests, so that the
bootrom doesn't send any more requests. Normal case is working just fine
for audio and GP modules. This is tested with build arche_440.
Jeffrey Carlyle [Fri, 6 May 2016 19:43:53 +0000 (12:43 -0700)]
greybus: svc: implement svc_intf_activate
With upcoming firmware changes we will switch from an SVC-driven module
boot sequence to an AP-driven module sequence. This operation allows the
AP to request the SVC to boot a module to which the AP has previouslt
requested power be applied. This operation will also determine if the
remote interface is a dummy module, UniPro-only module, or full Greybus
module.
Testing done: Tested together with "new" firmware boot sequence to
verify that modules are detected and booted as expected.