summaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
AgeCommit message (Collapse)Author
2018-12-17staging: vc04_services: Remove VCHIQ_SERVICE_PARAMS_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_QUEUE_MESSAGE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_QUEUE_BULK_TRANSFER_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_HEADER_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_GET_CONFIG_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_DEQUEUE_MESSAGE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_DEBUGFS_NODE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_CREATE_SERVICE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_CONFIG_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_COMPLETION_DATA_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_BULK_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_AWAIT_COMPLETION_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove VCHIQ_ARM_STATE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove USER_SERVICE_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vc04_services: Remove DUMP_CONTEXT_T typedefDominic Braun
Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun <inf.braun@fau.de> Signed-off-by: Tobias Büttner <tobias.buettner@fau.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vchiq: delete vchiq_killable.hNicolas Saenz Julienne
There are no users for that header file. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17staging: vchiq: switch to wait_for_completion_killableNicolas Saenz Julienne
This fixes f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") as it neglected the subtle down_interruptible() macro override in vchiq_killable.h. Hence all completions should be killable instead of interruptible. Fixes: f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-12staging: vchiq_arm: Register a platform device for audioStefan Wahren
Following Eric's commit 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") this register the audio driver as a platform device, too. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-12staging: vchiq_arm: Fix camera device registrationStefan Wahren
Since the camera driver isn't probed via DT, we need to properly setup DMA. Fixes: 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05staging: vchiq_arm: add __user pointer annotationsSzilveszter Székely
Add __user to pointers based on context and suggestions by sparse. Other sparse warnings still remain, in cases where more change would be required apart from adding __user. Signed-off-by: Szilveszter Székely <szekelyszilv@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-03Merge 4.20-rc5 into staging-nextGreg Kroah-Hartman
We need the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: fix open/release cdev functionsNicolas Saenz Julienne
Both functions checked the minor number of the cdev prior running the code. This was useless since the number of devices is already limited by alloc_chrdev_region. This removes the check and reindents the code where relevant. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: rework probe and init functionsNicolas Saenz Julienne
Moves the allocation of a chardev region and class creation to the init function of the driver since those functions are meant to be run on a per driver basis, as opposed to the code run in the probe function which is run in a per device basis. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq: use completions instead of semaphoresNicolas Saenz Julienne
It is preferred in the kernel to avoid using semaphores to wait for events, as they are optimised for the opposite situation; where the common case is that they are available and may block only occasionally. FYI see this thread: https://lkml.org/lkml/2008/4/11/323. Also completions are semantically more explicit in this case. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: rework vchiq_ioc_copy_element_dataNicolas Saenz Julienne
The function is passed to vchiq_core.c for it to go trough all the transfer elements (an array of pointers to data) and copy them into the actual transfer memory (contiguous memory). The logic in the function was "copy an element and return, except when the element is empty, in which case look for the next non-empty element and copy it. The function will be called as many times as necessary until all the elements are copied". Now, this approach already forces the function to loop around elements and felt convoluted, so it was changed to a more straightforward "Copy all the elements into memory as long as they fit". The resulting function is shorter and simpler. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: get rid of vchi_mh.hNicolas Saenz Julienne
The concept of VCHI_MEM_HANDLE_T is introduced by this header file and was meant to be used with bulk transfers. After a quick look in vchiq_core.c it is pretty clear that it actually accomplishes nothing nor alters the bulk transfers in any way. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_listNicolas Saenz Julienne
The resulting code is way more readeable and intuitive compared to plain list_for_each. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_arm: rework close/remove_service IOCTLSNicolas Saenz Julienne
The implementation of both IOCTLS was the same except for one function call. This joins both implementations and updates the code to avoid unneeded indentations. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: vchiq_core: rework vchiq_get_configNicolas Saenz Julienne
The function is overly complicated for what it's ultimately achieving. It's simply filling up a structure. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETIONBen Wolsieffer
The compatibility ioctl wrapper for VCHIQ_IOC_AWAIT_COMPLETION assumes that the native ioctl always uses a message buffer and decrements msgbufcount. Certain message types do not use a message buffer and in this case msgbufcount is not decremented, and completion->header for the message is NULL. Because the wrapper unconditionally decrements msgbufcount, the calling process may assume that a message buffer has been used even when it has not. This results in a memory leak in the userspace code that interfaces with this driver. When msgbufcount is decremented, the userspace code assumes that the buffer can be freed though the reference in completion->header, which cannot happen when the reference is NULL. This patch causes the wrapper to only decrement msgbufcount when the native ioctl decrements it. Note that we cannot simply copy the native ioctl's value of msgbufcount, because the wrapper only retrieves messages from the native ioctl one at a time, while userspace may request multiple messages. See https://github.com/raspberrypi/linux/pull/2703 for more discussion of this patch. Fixes: 5569a1260933 ("staging: vchiq_arm: Add compatibility wrappers for ioctls") Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-25staging/vc04_services: Use correct cache line sizePhil Elwell
Use the compatible string in the DTB to select the correct cache line size for the SoC - 32 for BCM2835, and 64 for BCM2836 and BCM2837. Signed-off-by: Phil Elwell <phil@raspberrypi.org> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: vc04_services: no need to check debugfs return valuesGreg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Clean up the vchiq_arm code by not caring about the value of debugfs calls. This ends up removing a number of lines of code that are not needed. Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Kees Cook <keescook@chromium.org> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Keerthi Reddy <keerthigd4990@gmail.com> Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging/vc04_services: Register a platform device for the camera driver.Eric Anholt
We had the camera driver set up in a module_init function, but that meant that the camera driver would fail to load if it was initialized before VCHI. By attaching to this platform_device, it can get a defined load order. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_arm: remove unnecessary returnStefan Wahren
This removing an unnecessary return which has been reported by checkpatch.pl. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_arm: Make index variable more self-explainingStefan Wahren
The chance to mixup i and j is very high. So rename variable j to a more explaining one. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_arm: Rework second abort criterionStefan Wahren
In order to make the code easier to review, move the second abort criterion into the loop and the incrementation into a separate line. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_arm: Clear VLA warningStefan Wahren
The kernel would like to have all stack VLA usage removed[1]. The array here is fixed (declared with a const variable) but it appears like a VLA to the compiler. Also, currently we are putting 768 bytes on the stack. This function is only called on the error path so performance is not critical, let's just allocate the memory instead of using the stack. This saves stack space and removes the VLA build warning. kmalloc a buffer for dumping state instead of using the stack. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_arm: print real dump limitStefan Wahren
We better use the real loop limit in the warning about "too many active services". Another benefit is than we don't have to care about the format string in the following change. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vchiq_arm: Avoid long udelayStefan Wahren
vchiq_initialise() is used in non-interrupt context, so we can replace udelay with usleep_range as suggested by timers-howto.txt. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vchiq_arm: Fix multiline dereferencesStefan Wahren
Multiline dereferences aren't nice to review. So fix this checkpatch warning. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vc04_services: Use __func__ macroStefan Wahren
It's better to use the __func__ macro instead of open-code the function name. This fixes the following checkpatch warning: WARNING: Prefer using '"%s...", __func__' to using 'x', this function's name, in a string Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14staging: vc04_services: Remove vchiq_queue_bulk_{transmit,receive}.Eric Anholt
These are dead code, including in the downstream Raspberry Pi tree. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14staging: vc04_services: Replace "firmware" node with a compatible lookup.Eric Anholt
This was requested by Rob Herring in DT bindings review. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-16staging: vc04_services: merge vchiq_kern_lib.c into vchiq_arm.cArnd Bergmann
There are two incompatible definitions of 'vchiq_instance_struct', so passing them through vchiq_initialise(), vchiq_connect() or another such interface is broken, as shown by building the driver with link-time optimizations: drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h:129:0: error: type of 'vchiq_initialise' does not match original declaration [-Werror=lto-type-mismatch] extern VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c:68:0: note: 'vchiq_initialise' was previously declared here VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c:68:0: note: code may be misoptimized unless -fno-strict-aliasing is used drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h:131:0: error: type of 'vchiq_connect' does not match original declaration [-Werror=lto-type-mismatch] extern VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance); drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c:168:0: note: 'vchiq_connect' was previously declared here VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) It's possible that only one of the two sides actually access the members, but it's clear that they need to agree on the layout. The easiest way to achieve this appears to be to merge the two files into one. I tried moving the structure definition into a shared header first, but ended up running into too many interdependencies that way. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: vc05_services: fix checkpatch.pl errorsSidong Yang
Fix some errors for wrong brace position reported by checkpatch. Signed-off-by: Sidong Yang <realwakka@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02staging: vc04_services: Convert timers to use timer_setup()Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Additionally removes invalid NULL check, as pointed out by Dan Carpenter. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Eric Anholt <eric@anholt.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Michael Zoran <mzoran@crowfest.net> Cc: Keerthi Reddy <keerthigd4990@gmail.com> Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: devel@driverdev.osuosl.org Signed-off-by: Kees Cook <keescook@chromium.org> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-29staging: vc04_services: please do not use multiple blank linesKeerthi Reddy
Blank lines use up extra space in file and makes the file larger. So do not use multiple blanklines Signed-off-by: Keerthi Reddy <keerthigd4990@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-22staging: vc04_services: remove BCM2835_VCHIQ_SUPPORT_MEMDUMPDan Carpenter
BCM2835_VCHIQ_SUPPORT_MEMDUMP lets you look through any user memory. That's too big of an information leak from a security perspective. The debugging dumps need to be more specific to this driver. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16staging: vchiq_arm: fix error codes in probeDan Carpenter
If vchiq_debugfs_init() fails, then we accidentally return a valid pointer casted to int on error. This code is simpler if we get rid of the "ptr_err" variable and just use "err" throughout. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-29staging: vchiq_arm: Avoid multiline dereferenceStefan Wahren
Reduce the indentation within vchiq_dump_service_use_state in order to avoid a multiline derefernce. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>