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.
Signed-off-by: Alex Elder <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
In gb_operation_put_active(), the wrong trace point is being called.
Fix that.
Signed-off-by: Alex Elder <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
The interface svc-resource helper are used to enable as well as disable
the corresponding SVC resources so make sure the error messages reflect
that.
Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
The numbering of gbphy devices is going to start from 1 and not 0.
Reflect the same in sysfs hierarchy.
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
These were left in the earlier renaming series, fix them as well.
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 6d94670 gpbridge: rename 'gpbridge' to 'gbphy' everywhere
missed renaming the loopback test app. So do it too.
Testing done: complie and run loopback test
Signed-off-by: Axel Haslam <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Tested-by: Michael Scott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Tested-by: Michael Scott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Make arche_platform_fw_flashing_seq() return error value, needed
later when we add clock enable support for FW flashing.
Testing Done: Tested on EVT1.5 platform.
Signed-off-by: Vaibhav Hiremath <[email protected]>
Tested-by: Michael Scott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This reverts commit 29fee8c55b59bb6ac59b99a0563c89c514cba42b.
This change and its companion NuttX changes seem to be triggering a
storm of POWERMODEIND switch interrupts on the SVC.
Signed-off-by: Jeffrey Carlyle <[email protected]>
Acked-by: Sandeep Patil <[email protected]>
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 <[email protected]>
Reviewed-by: Alex Elder <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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().
WARNING: at msm-ara-3.10/kernel/irq/manage.c:457 __enable_irq+0x74/0xc0()
Unbalanced enable for IRQ 687
Modules linked in: gb_arche(O+) gb_camera(O) gb_es2(O) gb_vibrator(O)
gb_raw(O) gb_power_supply(O) gb_loopback(O) gb_light(O) gb_hid(O)
greybus(O)
CPU: 0 PID: 415 Comm: insmod Tainted: G W O 3.10.78-g2a4dec8 #65
Call trace:
[<ffffffc000206adc>] dump_backtrace+0x0/0x248
[<ffffffc000206d34>] show_stack+0x10/0x1c
[<ffffffc000c6c698>] dump_stack+0x1c/0x28
[<ffffffc00021c95c>] warn_slowpath_common+0x74/0x9c
[<ffffffc00021c9d0>] warn_slowpath_fmt+0x4c/0x58
[<ffffffc000269d7c>] __enable_irq+0x70/0xc0
[<ffffffc000269e34>] enable_irq+0x68/0x7c
[<ffffffbffc0609b4>] arche_platform_probe+0x3b4/0x4f4 [gb_arche]
[<ffffffc0005ace30>] platform_drv_probe+0x14/0x20
[<ffffffc0005ab980>] driver_probe_device+0x160/0x374
[<ffffffc0005abc40>] __driver_attach+0x60/0x90
[<ffffffc0005aa768>] bus_for_each_dev+0x74/0x94
[<ffffffc0005ab2c4>] driver_attach+0x1c/0x28
[<ffffffc0005aae74>] bus_add_driver+0x124/0x248
[<ffffffc0005ac270>] driver_register+0x94/0x110
[<ffffffc0005ad3c4>] platform_driver_register+0x58/0x64
[<ffffffbffc065020>] $x+0x20/0x58 [gb_arche]
[<ffffffc0002007dc>] do_one_initcall+0xb0/0x14c
[<ffffffc00028252c>] load_module+0x19d0/0x1b18
[<ffffffc00028278c>] SyS_init_module+0x118/0x130
Signed-off-by: Bryan O'Donoghue <[email protected]>
Reviewed-by: Vaibhav Hiremath <[email protected]>
Tested-by: Rui Miguel Silva <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Topology data pointer was mistakenly set to NULL before freeing it. Fix
this.
Fixes: 64a86d9ba850 ("audio: Add module specific driver")
Signed-off-by: Vaibhav Agarwal <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
I believe that duplicating the tracepoint name in comments prior to
the tracepoint is redundant, and doesn't add a lot of value.
I also believe that we can provide a little more information about
what exactly an event means, or when exactly it is called.
I don't claim this is a huge improvement, but it's a proposal.
Signed-off-by: Alex Elder <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Reviewed-by: Jeffrey Carlyle <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Alex Elder <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Reviewed-by: Jeffrey Carlyle <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Alex Elder <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Reviewed-by: Jeffrey Carlyle <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Convert the legacy camera protocol driver to a bundle driver.
Modules now can (and must) declare the camera data cport in their
manifest as the data connection isn't hardcoded anymore.
Signed-off-by: Laurent Pinchart <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
In one of the error cases we aren't destroying the connections created
earlier. Fix it.
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Errno -ENOSYS is reserved for missing syscalls, replace it with
-EOPNOTSUPP for the the two stub operations that used it.
Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Testing Done: Tested on EVT1.5 platform.
Signed-off-by: Vaibhav Hiremath <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Vaibhav Hiremath <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Sandeep Patil <[email protected]>
Suggested-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Jeffrey Carlyle <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
module->id is used as an argument to ida_simple_remove(). Since module
is already dereferenced, module->id might contain invalid data. So fix
this.
Fixes: da4cc2d0b066 ("audio:gb_manager: Use proper locking around kobject_xxx")
Signed-off-by: Vaibhav Agarwal <[email protected]>
Reviewed-by: Mark Greer <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]>
Reviewed-by: Johan Hovold <[email protected]>
Reviewed-by: Bryan O'Donoghue <[email protected]>
Reviewed-by: Mitchell Tasman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Rui Miguel Silva <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
As more bits will be added to the field, let's make the field more
generic and name it accordingly. So, rename it from rdwr to xfer_flags.
Signed-off-by: Rui Miguel Silva <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Reported-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
The value passed to le64_to_cpu wants to be an __le64 not a u64.
Note to self - remember to run "make check"
Signed-off-by: Bryan O'Donoghue <[email protected]>
Reported-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Signed-off-by: Bryan O'Donoghue <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This patch adds a number of USB Vendor commands to es2.c to enable TimeSync
in the bridge.
Adds:
- es2.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
u32 refclk);
Commands APBx to enable timers and clocks to track a pulse-train of
incoming TIME_SYNC strobes with strobe_delay microseconds between each.
Provides the reference clock the AP is using to track FrameTime. It is
the responsibility of APBx to adequately track the FrameTime based on
the indicated AP refclk. Once this command has succeeded APBx may not
transition to a low-power state were FrameTime counters stop.
This function is initiated from the timesync worker thread logic when
re-synchronizing frame-time throughout the system.
TimeSync is at this time enabled for all APBx active in the system i.e.
currently APB2 will not receive TimeSync commands until it becomes a
registered host-device in Greybus.
- es2.c::timesync_disable(void)
Commands APBx to discontinue tracking of FrameTime. After this operation
completes APBx may transition to a low-power state where timer-clocks
stop operating.
- es2.c::timesync_authoritative(u64 *frame_time)
Provides an authoritative time for each TIME_SYNC strobe to APBx.
APBx must align its local FrameTime to the authoritative clock.
- es2.c::timesync_get_last_event(u64 *frame_time)
Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.
Signed-off-by: Bryan O'Donoghue <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This patch adds a new 'firmware' folder in Documentation, which contains
two files:
- firmware-management: This describes the userspace interface for
interacting with firmware-management bundle.
- firmware.c: Sample application to test firmware load for Interface
Firmware and firmware updates to Backend Interface Firmware.
Signed-off-by: Viresh Kumar <[email protected]>
Reviewed-by: Jun Li <[email protected]>
Tested-by: Karthik Ravi Shankar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This patch adds SPI Protocol support to firmware core, which allows the
AP to access an SPI flash memory present with an Interface.
Tested by using the API from fw-management driver and compiling it.
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
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.
Reported-by: Johan Hovold <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Once the interface firmware is loaded successfully to a module,
userspace can ask it to mode switch to the newly loaded firmware.
This patch provides a new ioctl to initiate mode switch.
Userspace can initiate a mode switch if it has previously loaded the
interface firmware successfully, otherwise the firmware core rejects it.
Also, once the mode-switch is initiated, disallow any more interactions
from the userspace.
Signed-off-by: Viresh Kumar <[email protected]>
Tested-by: Karthik Ravi Shankar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This patch adds Firmware Management Protocol support to firmware core,
which allows the AP to manage firmware on an Interface.
Signed-off-by: Viresh Kumar <[email protected]>
Reviewed-by: Jun Li <[email protected]>
Tested-by: Karthik Ravi Shankar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
'make check' correctly complains that this should be static, so make it
so.
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Viresh Kumar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>