summaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services
AgeCommit message (Collapse)Author
2018-12-05staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETIONBen Wolsieffer
commit 5a96b2d38dc054c0bbcbcd585b116566cbd877fe upstream. 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-08-18Merge tag 'staging-4.19-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging and IIO updates from Greg KH: "Here are the big staging/iio patches for 4.19-rc1. Lots of churn here, with tons of cleanups happening in staging drivers, a removal of an old crypto driver that no one was using (skein), and the addition of some new IIO drivers. Also added was a "gasket" driver from Google that needs loads of work and the erofs filesystem. Even with adding all of the new drivers and a new filesystem, we are only adding about 1000 lines overall to the kernel linecount, which shows just how much cleanup happened, and how big the unused crypto driver was. All of these have been in the linux-next tree for a while now with no reported issues" * tag 'staging-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (903 commits) staging:rtl8192u: Remove unused macro definitions - Style staging:rtl8192u: Add spaces around '+' operator - Style staging:rtl8192u: Remove stale comment - Style staging: rtl8188eu: remove unused mp_custom_oid.h staging: fbtft: Add spaces around / - Style staging: fbtft: Erases some repetitive usage of function name - Style staging: fbtft: Adjust some empty-line problems - Style staging: fbtft: Removes one nesting level to help readability - Style staging: fbtft: Changes gamma table to define. staging: fbtft: A bit more information on dev_err. staging: fbtft: Fixes some alignment issues - Style staging: fbtft: Puts macro arguments in parenthesis to avoid precedence issues - Style staging: rtl8188eu: remove unused array dB_Invert_Table staging: rtl8188eu: remove whitespace, add missing blank line staging: rtl8188eu: use is_multicast_ether_addr in rtw_sta_mgt.c staging: rtl8188eu: remove whitespace - style staging: rtl8188eu: cleanup block comment - style staging: rtl8188eu: use is_multicast_ether_addr in rtl8188eu_xmit.c staging: rtl8188eu: use is_multicast_ether_addr in recv_linux.c staging: rtlwifi: refactor rtl_get_tcb_desc ...
2018-07-24staging: bcm2835-camera: fix timeout handling in wait_for_completion_timeoutNicholas Mc Guire
wait_for_completion_timeout returns unsigned long not int so a variable of proper type is introduced. Further the check for <= 0 is ambiguous and should be == 0 here indicating timeout which is the only error case so no additional check needed here. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-24staging: bcm2835-camera: handle wait_for_completion_timeout return properlyNicholas Mc Guire
wait_for_completion_timeout returns unsigned long not int so a variable of proper type is introduced. Further the check for <= 0 is ambiguous and should be == 0 here indicating timeout. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-13staging: bcm2835-audio: Don't leak workqueue if open failsTuomas Tynkkynen
Currently, if bcm2835_audio_open() fails partway, the allocated workqueue is leaked. Avoid that. While at it, propagate the return value of bcm2835_audio_open_connection() on failure instead of returning -1. Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-13staging: bcm2835-audio: Check if workqueue allocation failedTuomas Tynkkynen
Currently, if allocating a workqueue fails, the driver will probe successfully but it will silently do nothing, which is rather silly. So instead bail out with -ENOMEM in bcm2835_audio_open() if alloc_workqueue() fails, and remove the now pointless checks for a NULL workqueue. While at it, get rid of the rather pointless one-line function my_workqueue_init(). Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-04media: staging: bcm2835-camera: Provide lock for vb2_queueEzequiel Garcia
Use the device mutex to protect the vb2_queue. This allows to replace the ad-hoc wait_{prepare, finish} with vb2_ops_wait_{prepare, finish}. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-17staging: vc04_services: make a couple of pointers staticColin Ian King
The pointers vchiq_dbg_dir and vchiq_dbg_clients are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: warning: symbol 'vchiq_dbg_dir' was not declared. Should it be static? warning: symbol 'vchiq_dbg_clients' was not declared. Should it be static? Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: vc04_services: no need to save the log debufs dentriesGreg Kroah-Hartman
The log entry dentries are only set, never referenced, so no need to keep them around. Remove the pointer from struct vchiq_debugfs_log_entry as it is not needed anymore and get rid of the separate vchiq_debugfs_create_log_entries() function as it is only used in one place. Suggested-by: Eric Anholt <eric@anholt.net> 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-06-01staging: vc04_services: vchiq_debugfs_log_entry can be a void *Greg Kroah-Hartman
There's no need to set this to be int * when it is only used as a void *. This lets us remove the unneeded cast, and unneeded temporary variable the one place it is referenced in the code. Suggested-by: Eric Anholt <eric@anholt.net> 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-06-01staging: vc04_services: remove struct vchiq_debugfs_infoGreg Kroah-Hartman
This structure, and the one static variable that was declared with it, were not being used for anything. The log_categories field was being set, but never used again. So just remove it entirely as it is not needed at all. Suggested-by: Eric Anholt <eric@anholt.net> 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-06-01staging: vc04_services: move client dbg directory into static variableGreg Kroah-Hartman
This does not need to be part of a wrapper function, or in a structure, just properly reference it directly as a single variable. The whole variable will be going away soon anyway, this is just a step toward that direction. Suggested-by: Eric Anholt <eric@anholt.net> 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-06-01staging: vc04_services: remove odd vchiq_debugfs_top() wrapperGreg Kroah-Hartman
vchiq_debugfs_top() is only a wrapper around a pointer to a dentry, so just use the dentry directly instead, making it a static variable instead of part of a static structure. This also removes the pointless BUG_ON() when checking that dentry as no one should ever care if debugfs is working or not, and the kernel should really not panic over something as trivial as that. Suggested-by: Eric Anholt <eric@anholt.net> 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-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-14staging: bcm2835: Use BIT_ULL macroKilian Köppchen
This patch fixes the checkpatch.pl check hint: CHECK: Prefer using the BIT_ULL macro Signed-off-by: Kilian Köppchen <kiliankoeppchen@googlemail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-14staging: bcm2835-camera: Replace open-coded idr with a struct idr.Eric Anholt
We just need some integer handles that can map back to our message struct when we're handling a reply, which struct idr is perfect for. v2: Fix error check to look at the right variable. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-14staging: bcm2835-camera: Fix module section mismatch warnings.Eric Anholt
Noticed by Stephen Rothwell in -next. Signed-off-by: Eric Anholt <eric@anholt.net> Fixes: 4bebb0312ea9 ("staging/bcm2835-camera: Set ourselves up as a platform driver.") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835: Fix mmal_port_parameter_get() signed/unsigned warnings.Eric Anholt
The arg is a u32 *, so switch over to that in our declarations. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835: Remove dead code related to framerate.Eric Anholt
Fixes a compiler warning about a set-but-not-used variable. I think this was just leftover dead code from before set_framerate_params(), since that also sets up some mmal_parameter_rational structs for fps. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Fix warnings about string ops on v4l2 uapi.Eric Anholt
The v4l2 uapi uses u8[] for strings, so cast those to char * to avoid compiler warnings about unsigned vs signed with sprintf() and friends. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Fix indentation of tablesDave Stevenson
As requested by Mauro Carvalho Chehab in review. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Fix comment typos.Dave Stevenson
Fix a typo flagged by checkpatch, and another in the same line. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Replace BUG_ON with return errorDave Stevenson
The error conditions don't warrant taking the kernel down, so remove BUG_ON. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Move struct vchiq_mmal_rectDave Stevenson
struct vchiq_mmal_rect is only referenced from mmal-parameters.h, yet was defined in mmal-vchiq.h. Move it to avoid having to include multiple headers for no reason. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Add multiple include protectionDave Stevenson
mmal-parameters.h didn't have the normal ... protection to stop it being included multiple times. Add it. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Remove V4L2/MMAL buffer remappingDave Stevenson
The MMAL and V4L2 buffers had been disassociated, and linked on demand. Seeing as both are finite and low in number, and we now have the same number of each, link them for the duration. This removes the complexity of maintaining lists as the struct mmal_buffer context comes back from the VPU, so we can directly link back to the relevant V4L2 buffer. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Match MMAL buffer count to V4L2.Dave Stevenson
For historical reasons, the number of buffers passed to the VPU over MMAL did not match that passed from V4L2. That is a silly situation as the driver has to duplicate serialisation and other functions that have already been implemented in V4L2/videobuf2. As we had more V4L2 buffers than MMAL ones, the MMAL buffer headers were returned to the VPU immediately on being filled, which is now invalid. Match the number of buffers notified in queue_setup with that used in MMAL. Return buffers only when we get them from V4L2. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Remove bulk_mutex as it is not requiredDave Stevenson
There is no requirement to serialise bulk transfers as that is all done in VCHI, and if a second MMAL_MSG_TYPE_BUFFER_TO_HOST happened before the VCHI_CALLBACK_BULK_RECEIVED, then the service_callback thread is deadlocked. Remove the bulk_mutex so that multiple receives can be scheduled at a time. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Allocate context once per bufferDave Stevenson
The struct mmal_msg_context was being allocated for every message being sent to the VPU, and freed when it came back. Whilst that is required behaviour for some messages (mainly the synchronous ones), it is wasteful for the video buffers that make up the majority of the traffic. Add to the buffer_init/cleanup hooks that it allocates/frees the msg_context required. v2: changes by anholt from the downstream tree: clean up indentation, pass an error value through, forward-declare the struct so we have less void * Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Skip ISP pass to eliminate padding.Dave Stevenson
Interleaved RGB and single plane YUV formats can be delivered by the GPU without the secondary step of removing padding, as the bytesperline field can be set appropriately. Planar YUV needs the GPU to still remove padding, as there is no way to report that there is padding between the planes (ie on the height). The multi-planar formats are NOT applicable, as there is no easy way to make them contiguous in memory (ie one large allocation that gets broken up). The whole task is passed across to videobuf2 which has no notion of that requirement. v2: Changes by anholt from the downstream driver: Flag two more planar formats as needing padding removal, and remove broken userspace workaround. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging/bcm2835-camera: Set ourselves up as a platform driver.Eric Anholt
This allows bcm2835-camera to automatically probe after VCHI has loaded, rather than only successfully probing if the arbitrary probe order chooses us after VCHI. Signed-off-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: vc04_services: Remove stack hog issue from TODOStefan Wahren
Since there is no vchiq function listed by "make checkstack" anymore, we can remove the stack hog issue from the TODO. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vchiq_shim: Remove unnecessary breakStefan Wahren
This removes an unnecessary break 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: 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_2835_arm: Fix whitespace issue in create_pagelistStefan Wahren
This fixes a whitespace issue reported by checkpatch: ERROR: code indent should use tabs where possible Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-06staging: vc04_services: Remove defines from MakefileStefan Wahren
The definition of USE_VCHIQ_ARM and VCOS_VERIFY_BKPTS isn't really necessary so remove them. 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-29staging: bcm2835-audio: Disconnect and free vchi_instance on module_exit()Kirill Marinushkin
In the current implementation, vchi_instance is inited during the first call of bcm2835_audio_open_connection(), and is never freed. It causes a memory leak when the module `snd_bcm2835` is removed. Here is how this commit fixes it: * the VCHI context (including vchi_instance) is created once in the platform's devres * the VCHI context is allocated and connected once during module_init() * all created bcm2835_chips have a pointer to this VCHI context * bcm2835_audio_open_connection() can access the VCHI context through the associated bcm2835_chip * the VCHI context is disconnected and freed once during module_exit() After this commit is applied, I don't see other issues with the module's init/exit, so I also remove the associated TODO task. Steps to reproduce the memory leak before this commit: ~~~~ root@raspberrypi:/home/pi# aplay test0.wav Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster ^CAborted by signal Interrupt... root@raspberrypi:/home/pi# rmmod snd_bcm2835 root@raspberrypi:/home/pi# modprobe snd_bcm2835 root@raspberrypi:/home/pi# aplay test0.wav Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster ^CAborted by signal Interrupt... root@raspberrypi:/home/pi# echo scan > /sys/kernel/debug/kmemleak root@raspberrypi:/home/pi# cat /sys/kernel/debug/kmemleak unreferenced object 0xb6794c00 (size 128): comm "aplay", pid 406, jiffies 36870 (age 116.650s) hex dump (first 32 bytes): 08 a5 82 81 01 00 00 00 08 4c 79 b6 08 4c 79 b6 .........Ly..Ly. 00 00 00 00 00 00 00 00 ad 4e ad de ff ff ff ff .........N...... backtrace: [<802af5e0>] kmem_cache_alloc_trace+0x294/0x3d0 [<806ce620>] vchiq_initialise+0x98/0x1b0 [<806d0b34>] vchi_initialise+0x24/0x34 [<7f1311ec>] 0x7f1311ec [<7f1303bc>] 0x7f1303bc [<7f130590>] 0x7f130590 [<7f111fd8>] snd_pcm_open_substream+0x68/0xc4 [snd_pcm] [<7f112108>] snd_pcm_open+0xd4/0x248 [snd_pcm] [<7f112334>] snd_pcm_playback_open+0x4c/0x6c [snd_pcm] [<7f0e250c>] snd_open+0xa8/0x14c [snd] [<802ce590>] chrdev_open+0xac/0x188 [<802c57b4>] do_dentry_open+0x10c/0x314 [<802c6ba8>] vfs_open+0x5c/0x88 [<802d9a68>] path_openat+0x368/0x944 [<802dacd4>] do_filp_open+0x70/0xc4 [<802c6f70>] do_sys_open+0x110/0x1d4 ~~~~ Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com> Cc: Eric Anholt <eric@anholt.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ray Jui <rjui@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: bcm-kernel-feedback-list@broadcom.com Cc: linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vc04_services: Remove depends on HAS_DMA in case of platform dependencyGeert Uytterhoeven
Remove dependencies on HAS_DMA where a Kconfig symbol depends on another symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST". In most cases this other symbol is an architecture or platform specific symbol, or PCI. Generic symbols and drivers without platform dependencies keep their dependencies on HAS_DMA, to prevent compiling subsystems or drivers that cannot work anyway. This simplifies the dependencies, and allows to improve compile-testing. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Mark Brown <broonie@kernel.org> Acked-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vchiq_core: Free kthreads in error caseStefan Wahren
We need to free the kthreads in error case before leaving vchiq_init_state() otherwise we leak resources. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vchiq_core: Move all wake-ups to one pointStefan Wahren
Move all calls of wake_up_process to one point, whichs makes the following implementation of clean-up code easier. 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-04-23staging: vchiq_core: remove BITSET_ZEROStefan Wahren
Hiding memset behind a macro isn't the best, because it relies on that the parameter is not a pointer. Luckily all user has been removed, so we can remove BITSET_ZERO too. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: vchiq_core: Remove stackhog in process_free_queueStefan Wahren
This removes the stackhog in process_free_queue by allocating the necessary memory within the recycle thread main function instead of the stack. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>