summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/fw-download.c
AgeCommit message (Collapse)Author
2016-08-12greybus: firmware: s/should/mustViresh Kumar
Replace 'should' with 'must' to clear the expectation a bit more. Reported-by: Alex Elder <alex.elder@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-12greybus: firmware: s/_LEN/_SIZEViresh Kumar
Alex Elder pointed out that the macros also count the trailing NULL ('\0') character and so it should be using SIZE instead of LEN. This patch makes that change. Reported-by: Alex Elder <alex.elder@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-12greybus: firmware: Remove extra parenthesisViresh Kumar
Remove the unnecessary parenthesis. Reported-by: Alex Elder <alex.elder@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-11greybus: firmware: use 'tag' instead of 'firmware_tag'Viresh Kumar
We already have another direct pointer for this, use that instead. Testing Done: Compiled. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20greybus: move all firmware prefix strings to one placeGreg Kroah-Hartman
The firmware prefix is hard-coded in a few different places. Put it all in one handy #define, for when/if we ever decide to change it in the future... Testing: 'strings gb-firmware.ko gb-bootrom.ko | grep ara_' produced the same output before and after this patch. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09greybus: fw-download: Replace timer with delayed-workViresh Kumar
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. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05greybus: fw-download: Introduce timeouts for firmware downloadsViresh Kumar
As per greybus specification, the AP can apply, implementation dependent, timeouts for: - The time interval between the Find Firmware Response and the first Fetch Firmware Request. - The time interval between a Fetch Firmware Response and the next Fetch Firmware Request. - The time interval between a Fetch Firmware Response and the Release Firmware Request. - The time interval between the Find Firmware Response and the Release Firmware Request. This patch implements those timeouts. The timeout period for the first three cases is fixed to one-second and the timeout for the last one is finalized at runtime, dependent on the total size of the firmware. There can be two possible paths now, which may race for freeing or getting the 'struct fw_request'. They are: - Request handler: initiated from the Module side. - Timeout handler: initiated on timeout of the programmed timer. And so a mutex is added to avoid races. Every caller which needs to access the 'struct fw_request' increments the reference count, so that the structure doesn't get freed in parallel. Once the structure is freed and reference is put by all the users, the structure is freed. If we timeout while waiting for a request from the Module, the AP frees the 'struct fw_request', but does *not* free the request-id. This is done to guarantee that a delayed request from the Module for the expired id, doesn't get access to a new 'struct fw_request' allocated later with the same id. Tested with gbsim by hacking its code to delay the release request and indefinitely fetch the same section of the firmware package. Both timed out on the AP side and the 'struct fw_request' is free properly. Further requests work fine after few are timed out. And rmmod (followed by more similar testing) works just fine. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05greybus: fw-download: Manage firmware requests with krefViresh Kumar
This patch updates the fw-download core to manage firmware requests with kref. This is required for the next patch, which will introduce timeouts for firmware downloads. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-04greybus: fw-download: Create a macro for length of firmware file's nameViresh Kumar
Create a macro representing the length of the firmware file's name and use that instead of using magic number in the code. Suggested-by: Greg Kroah-Hartman <gregkh@google.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29greybus: firmware: Add firmware-download protocol driverViresh Kumar
This patch adds Firmware Download Protocol support to firmware core, which allows an Interface to download a firmware package over Unipro. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Jun Li <li_jun@projectara.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>