History log of /linux-master/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
Revision Date Author Comments
# 93596ac3 07-Dec-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: vchiq_arm: Use %p to log pointer address

Solves the following Smatch warnings:
service_callback() warn: argument 7 to %lx specifier is cast from pointer
service_callback() warn: argument 11 to %lx specifier is cast from pointer
service_callback() warn: argument 12 to %lx specifier is cast from pointer
service_callback() warn: argument 13 to %lx specifier is cast from pointer

%p will print the hashed pointer to dynamic debug.
In order to print the unmodified pointer address, one can use the
`no_hash_pointers` via kernel parameters.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231207083837.153843-2-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 55e23aa9 05-Dec-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop vchiq_log_debug() in favour of dev_dbg

Drop vchiq_log_debug() macro which wraps dev_dbg(). Introduce the usage
of dev_dbg() directly.

Meanwhile at it, drop the usage of __func__ from the logs.
Dynamic debug supports this via the 'f' decorator flag.

Remove the entry from TODO regarding custom logging. VC04 is now
aligned according to the standard kernel logging mechanisms.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231205084157.73819-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 078666d7 05-Dec-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop vchiq_log_trace() in favour of dev_dbg

Drop vchiq_log_trace() macro which wraps dev_dbg(). Introduce the usage
of dev_dbg() directly.

Meanwhile at it, drop the usage of __func__ from the logs.
Dynamic debug supports this via the 'f' decorator flag.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231205084157.73819-4-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 085bb413 05-Dec-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop vchiq_log_warning() in favour of dev_warn

Drop vchiq_log_warning() macro which wraps dev_dbg(). Introduce the usage
of dev_warn() directly.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231205084157.73819-3-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e70f17ed 05-Dec-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop vchiq_log_error() in favour of dev_err

Drop vchiq_log_error() macro which wraps dev_dbg(). Introduce the usage
of dev_err() directly.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231205084157.73819-2-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b43d958f 29-Oct-2023 Stefan Wahren <wahrenst@gmx.net>

staging: vchiq_arm: move state dump to debugfs

Besides the IOCTL interface the VCHIQ character device also provides
a state dump of the whole VCHIQ driver via read. Moving the state dump
function to debugfs has a lot advantages:

- following changes on state dump doesn't break userspace ABI
- debug doesn't depend on VCHIQ_CDEV
- dump code simplifies a lot and reduce the chance of buffer overflows

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Tested-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20231029124837.119832-4-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3d69b023 25-Oct-2023 Ricardo B. Marliere <ricardo@marliere.net>

staging: vc04_services: use snprintf instead of sprintf

All the occurrences of sprintf usage under vc04_services can be safely
replaced by snprintf, so as to avoid any possible overflow.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Suggested-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231025122632.307385-4-ricardo@marliere.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ae094de3 25-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Use %p4cc format modifier to print FourCC codes

Drop VCHIQ_FOURCC_AS_4CHARS macro in favour of %p4cc format
modifier to print FourCC codes in the logs.

vchiq_use_internal() and vchiq_release_internal() uses entity
character-array to store a transient string that contains
a FourCC code. Increase the length of entity array(to 64 bytes)
since %p4cc requires more bytes to hold the output characters.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231025060717.71895-2-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b640e8f5 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop log level mechanisms

Drop the log level remnants since the logs are now ported to use
dynamic logging. Drop macros, externs and global variables which
were used in the log level mechanisms along with debugfs log entries.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-9-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9748de55 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04: Convert vchiq_log_trace() to use dynamic debug

Move vchiq_log_trace() custom logging wrapper based on printk
to use dynamic debug. The log category is dictated by enum
vchiq_log_category which will become the part of the trace
string format that will be logged to dynamic debug (for grep).

All the vchiq_log_trace() calls are adjusted to use the
modified wrapper.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-7-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f67af594 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04: Convert(and rename) vchiq_log_info() to use dynamic debug

Convert(and rename) vchiq_log_info() custom logging wrapping based on
printk to use dynamic debug. The wrapper is now renamed to
vchiq_log_debug() since most of the usage is around printing debug
information. The log category is dictated by enum vchiq_log_category
which will become the part of the debug string format that will be
logged to dynamic debug (for grep).

All the vchiq_log_info() calls are adjusted to use the
modified wrapper vchiq_log_debug().

The existing custom logging for vchiq_log_info() also tries
to log trace messages using SRVTRACE_LEVEL. This is simply
moved to use the vchiq_log_debug() directly.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-6-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0b120863 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04: Convert vchiq_log_warning() to use dynamic debug

Move vchiq_log_warning() custom logging wrapper based on printk to use
dynamic debug. The log category is dictated by vchiq_log_category
which will become the part of the warning string format that will be
logged to dynamic debug (for grep).

All the vchiq_log_warning() calls are adjusted to use the
modified wrapper.

While at that, remove the extraneous "----" from few of the
warning string text.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1d8915cf 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04: Convert vchiq_log_error() to use dynamic debug

Move vchiq_log_error() custom logging wrapper based on printk,
to use dynamic debug. To categorise, enum vchiq_log_category
has been introduced, which will become the part of the error
string format that will be logged to dynamic debug (for grep).

All the vchiq_log_error() calls are adjusted to use the
dynamic debug wrapper. vchiq_loud_error_*() has been removed
as a part of this patch and replaced with dev_err (so that
they directly end up in kernel log, even if dynamic debug
isn't enabled), which serves the purpose.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-4-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 33bdf010 24-Oct-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Pass struct device to vchiq_init_slots()

Pass struct device pointer to vchiq_init_slots(). In subsequent
commits, vchiq_log_* macros will be ported to use dynamic debug
(dev_dbg()), hence they need access to a struct device pointer.

No functional changes intended in this commit.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-3-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 06d0b811 23-Sep-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: bcm2835-audio: Register bcm2835-audio with vchiq_bus_type

Similar to how bcm2385-camera device is registered, register the
bcm2835-audio with vchiq_bus_type as well.

Since we moved away bcm2835-audio from platform driver/device,
we have to set the DMA mask explicitly. Set the DMA mask at probe
time.

Meanwhile at it, change the name and module alias from "bcm2835_audio"
to "bcm2835-audio" to be consistent with bcm2835-camera device. This
does not brings any functional change as '-' and '_' are
interchangeable as per modprobe man pages.

Also, drop vchiq_register_child() helper which is no longer
needed after this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20230923143200.268063-7-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 899038ae 23-Sep-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type

Register the bcm2835-camera with the vchiq_bus_type instead of using
platform driver/device.

Since we moved away bcm2835-camera from platform driver/device,
we have to set the DMA mask explicitly. Set the DMA mask at probe
time.

Also the VCHIQ firmware doesn't support device enumeration, hence
one has to maintain a list of devices to be registered in the interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20230923143200.268063-6-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 162bd0dd 23-Sep-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: vchiq_arm: Register vchiq_bus_type

Register the vchiq_bus_type bus with the vchiq interface.
The bcm2835-camera and bcm2835_audio will be registered to this bus type
going ahead.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Link: https://lore.kernel.org/r/20230923143200.268063-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e152c58d 16-May-2023 Arnd Bergmann <arnd@arndb.de>

staging: vchiq_arm: mark vchiq_platform_init() static

This function has no callers from other files, and the declaration
was removed a while ago, causing a W=1 warning:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for 'vchiq_platform_init'

Marking it static solves this problem but introduces a new warning
since gcc determines that 'g_fragments_base' is never initialized
in some kernel configurations:

In file included from include/linux/string.h:254,
from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/mm_types_task.h:14,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:8:
In function 'memcpy_to_page',
inlined from 'free_pagelist' at drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:433:4:
include/linux/fortify-string.h:57:33: error: argument 2 null where non-null expected [-Werror=nonnull]
include/linux/highmem.h:427:9: note: in expansion of macro 'memcpy'
427 | memcpy(to + offset, from, len);
| ^~~~~~

Add a NULL pointer check for this in addition to the static annotation
to avoid both.

Fixes: 89cc4218f640 ("staging: vchiq_arm: drop unnecessary declarations")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20230516202603.560554-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 48380368 28-Mar-2023 Peter Zijlstra <peterz@infradead.org>

Change DEFINE_SEMAPHORE() to take a number argument

Fundamentally semaphores are a counted primitive, but
DEFINE_SEMAPHORE() does not expose this and explicitly creates a
binary semaphore.

Change DEFINE_SEMAPHORE() to take a number argument and use that in the
few places that open-coded it using __SEMAPHORE_INITIALIZER().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
[mcgrof: add some tribal knowledge about why some folks prefer
binary sempahores over mutexes]
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>


# e3e1e149 03-Apr-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

staging: vc04_services: vchiq_arm: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230403154014.2564054-25-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f9a8a192 23-Jan-2023 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Improve error log for vchiq_platform_init

During sending the base address of the slots to the VideoCore
firmware via mailbox property, issues could happened on the ARM
and on the VideoCore side. So better separate the error handling
in order to provide more details. This should help to narrow
down the possible cause.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20230123191629.21019-1-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5eec0306 23-Dec-2022 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop enum vchiq_status remnants

Drop all references to enum vchiq_status as they are no longer in
use.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221223122404.170585-7-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 82a9eb4a 23-Dec-2022 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop VCHIQ_RETRY usage

Drop the usage of VCHIQ_RETRY vchiq_status enum type in most of the
places and replace it with -EAGAIN. The exception to this replacement
is vchiq_send_remote_use() and vchiq_send_remote_use_active() which will
be addressed in the subsequent commit.

This patch acts as intermediatory to address the TODO item:
* Get rid of custom function return values
for vc04_services/interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221223122404.170585-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ab73dc85 23-Dec-2022 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop VCHIQ_ERROR usage

Drop the usage of VCHIQ_ERROR vchiq_status enum type. Replace it with
-EINVAL to report the error in most cases, -ENOMEM for out-of-memory
errors and -EHOSTDOWN for service shutdown.

This patch acts as intermediatory to address the TODO item:
* Get rid of custom function return values
for vc04_services/interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221223122404.170585-4-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3414994b 23-Dec-2022 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Drop VCHIQ_SUCCESS usage

Drop the usage of VCHIQ_SUCCESS vchiq_status enum type. Replace it with
0 to report the success status.

This patch acts as intermediatory to address the TODO item:
* Get rid of custom function return values
for vc04_services/interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221223122404.170585-3-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3ba31722 23-Dec-2022 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: Replace vchiq_status return type to int

Modify the functions' signature using enum vchiq_status to return int.
Currently, this patch only touches the function signatures and
in subsequent patches each vchiq_status enumerated value will be
replaced by a integer value.

This patch acts as an initial point to address the TODO item:
* Get rid of custom function return values
for vc04_services/interface.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221223122404.170585-2-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f6c99d86 24-Jun-2022 Phil Elwell <phil@raspberrypi.com>

staging: vchiq_arm: Add missing memory barrier comments

One of points on the TODO list was to comment the memory barriers.
This patch addresses the missing ones in order to help reviewers.

Link: https://github.com/raspberrypi/linux/pull/5066
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20220624163902.6913-1-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6d02150c 18-May-2022 Adrien Thierry <athierry@redhat.com>

staging: vchiq_arm: pass vchiq instance to 'handle_to_service'

In order to remove the 'vchiq_states' global array, we need to pass the
vchiq_instance reference to the 'handle_to_service' function. This will
allow accessing the vchiq state through the vchiq instance instead of
through the global array.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-8-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 14780bb1 18-May-2022 Adrien Thierry <athierry@redhat.com>

staging: vchiq_arm: pass vchiq instance to 'find_service_by_handle'

In order to remove the 'vchiq_states' global array, we need to pass the
vchiq_instance reference to the 'handle_to_service' function, as well as
to all functions that call 'handle_to_service'. This will allow
accessing the vchiq state through the vchiq instance instead of through
the global array.

'handle_to_service' is called by 'find_service_by_handle'. Therefore,
pass the vchiq instance reference to 'find_service_by_handle' and to its
callers.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-5-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 726e79f8 18-May-2022 Adrien Thierry <athierry@redhat.com>

staging: vchiq_arm: pass vchiq instance to service callbacks

In order to remove the 'vchiq_states' global array, we need to pass the
vchiq_instance reference to the 'handle_to_service' function, as well as
to all functions that call 'handle_to_service'. This will allow
accessing the vchiq state through the vchiq instance instead of through
the global array.

'handle_to_service' is called by 'service_callback'. Therefore, pass the
vchiq instance reference to 'service_callback'. This also requires
adding the vchiq instance reference to the service callbacks prototype,
and update all other callbacks accordingly.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-4-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 813fa44c 18-May-2022 Adrien Thierry <athierry@redhat.com>

staging: vchiq_arm: get rid of global device structure

Get rid of the global g_dev structure.

This is part of an effort to address TODO item "Get rid of all non
essential global structures and create a proper per device structure"

I chose to pass the vchiq_instance around instead of the device
reference because in order to get rid of the 'vchiq_states' global array
in the future, we will need another way to access the vchiq_state in the
'handle_to_service' function. Therefore, we will need to pass the
vchiq_instance to it (or the vchiq_state), and also pass it to functions
higher up in the caller chain, such as 'vchiq_bulk_transmit' and friends
which are used in the bcm2835-audio consumer.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-3-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d8d307e6 18-May-2022 Adrien Thierry <athierry@redhat.com>

staging: vchiq_arm: add reference to vchiq device in vchiq_state

Add a reference to the vchiq device in the vchiq_state structure. This
allows the device structure to be passed around, which will be useful in
order to get rid of the global g_dev structure. This change will also
make it possible to use standard kernel logging macros instead of the
custom ones.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-2-athierry@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 47f46a87 30-Mar-2022 Fabio M. De Francesco <fmdefrancesco@gmail.com>

staging: vc04_services: Convert kmap() to kmap_local_page()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. In file interface/vchiq_arm/vchiq_arm.c,
function free_pagelist() calls kmap() / kunmap() from two places.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, free_pagelist() is a function where the
use of kmap_local_page() in place of kmap() is correctly suited.

Convert to kmap_local_page() but, instead of open coding it, use the
memcpy_to_page() helper.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20220330191414.23141-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 66f663a2 24-Mar-2022 Jakob Koschel <jakobkoschel@gmail.com>

staging: vchiq: replace usage of found with dedicated list iterator variable

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].

This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Link: https://lore.kernel.org/r/20220324073024.65943-1-jakobkoschel@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 56955aae 02-Mar-2022 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: make vchiq_platform_get_arm_state() static

Fix "no previous prototype" W=1 warning by making the function
vchiq_platform_get_arm_state() static.

While at it, realign the function declaration in one line and reposition
the asterisk symbol to fulfill the 'foo *bar' syntax.

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/216ad30d674b80e0051ecc233ac26ddb1d3e0e75.1646255044.git.gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# aa899e686 23-Jan-2022 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Avoid NULL ptr deref in vchiq_dump_platform_instances

vchiq_get_state() can return a NULL pointer. So handle this cases and
avoid a NULL pointer derefence in vchiq_dump_platform_instances.

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1642968143-19281-17-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 914813cc 23-Jan-2022 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: make vchiq_get_state return early

Make vchiq_get_state return early with NULL and improve the readability.

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1642968143-19281-16-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9c78a73a 23-Jan-2022 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: introduce is_adjacent_block

The check for an adjacent block is hard to read. So move it into a separate
inline function.

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1642968143-19281-4-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0cea730c 31-Dec-2021 Padmanabha Srinivasaiah <treasure4paddy@gmail.com>

staging: vc04_services: Fix RCU dereference check

In service_callback path RCU dereferenced pointer struct vchiq_service
need to be accessed inside rcu read-critical section.

Also userdata/user_service part of vchiq_service is accessed around
different synchronization mechanism, getting an extra reference to a
pointer keeps sematics simpler and avoids prolonged graceperiod.

Accessing vchiq_service with rcu_read_[lock/unlock] fixes below issue.

[ 32.201659] =============================
[ 32.201664] WARNING: suspicious RCU usage
[ 32.201670] 5.15.11-rt24-v8+ #3 Not tainted
[ 32.201680] -----------------------------
[ 32.201685] drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h:529 suspicious rcu_dereference_check() usage!
[ 32.201695]
[ 32.201695] other info that might help us debug this:
[ 32.201695]
[ 32.201700]
[ 32.201700] rcu_scheduler_active = 2, debug_locks = 1
[ 32.201708] no locks held by vchiq-slot/0/98.
[ 32.201715]
[ 32.201715] stack backtrace:
[ 32.201723] CPU: 1 PID: 98 Comm: vchiq-slot/0 Not tainted 5.15.11-rt24-v8+ #3
[ 32.201733] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT)
[ 32.201739] Call trace:
[ 32.201742] dump_backtrace+0x0/0x1b8
[ 32.201772] show_stack+0x20/0x30
[ 32.201784] dump_stack_lvl+0x8c/0xb8
[ 32.201799] dump_stack+0x18/0x34
[ 32.201808] lockdep_rcu_suspicious+0xe4/0xf8
[ 32.201817] service_callback+0x124/0x400
[ 32.201830] slot_handler_func+0xf60/0x1e20
[ 32.201839] kthread+0x19c/0x1a8
[ 32.201849] ret_from_fork+0x10/0x20

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Padmanabha Srinivasaiah <treasure4paddy@gmail.com>
Link: https://lore.kernel.org/r/20211231195406.5479-1-treasure4paddy@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6350e6f6 28-Dec-2021 Gautam Menghani <gautammenghani14@gmail.com>

staging: vc04_services: Remove repeated word in vchiq log warning

In a log warning in vhciq code, the word 'count' is repeated twice.
Remove repeated word 'count' from vhciq log warning.
This change has been suggested by checkpatch.pl

Signed-off-by: Gautam Menghani <gautammenghani14@gmail.com>
Link: https://lore.kernel.org/r/20211228101615.5073-1-gautammenghani14@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8dd56723 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq: drop trailing semicolon in macro definition

As reported by checkpatch.pl, macro definitions should not use a trailing
semicolon.

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20211024212524.370078-6-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6649335e 03-Oct-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: move platform structs to vchiq_arm.c

After merging vchiq_2835_arm.c into vchiq_arm.c some platform structs
doesn't need to exported anymore. So move them into the C file.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1633264369-998-4-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 631c5a53 03-Oct-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: re-order vchiq_arm_init_state

This moves vchiq_arm_init_state() above its caller, so we can drop the
now unnecessary forward declaration and make the function static.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1633264369-998-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bc1bd400 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: use __func__ to get function name in debug message

Avoid hardcoded function name using "%s", __func__. This prevents
potential naming conflict if the function is eventually renamed.

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-8-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 851d48d3 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: fix quoted strings split across lines

Quoted strings should not be split across lines. As put it in
Documentation/process/coding-style.rst: "never break user-visible
strings such as printk messages because that breaks the ability to grep
for them."

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-6-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 376bc13a 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: cleanup blank lines

Remove unnecessary blank lines after open braces and before close
braces.

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-5-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0b45b94d 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: clarify multiplication expressions

Add spaces around '*' in multiplication expressions to enhance
readability.

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-4-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 410caae5 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: remove unnecessary space in cast

As reported by checkpatch.pl, no space is necessary after a cast.

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-3-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 146707c3 19-Sep-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_arm: cleanup code alignment issues

Fix code alignment issues.

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20210919215914.539805-2-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7ff4034e 27-Sep-2021 Arnd Bergmann <arnd@arndb.de>

staging: vc04_services: shut up out-of-range warning

The comparison against SIZE_MAX produces a harmless warning on 64-bit
architectures:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:185:16: error: result of comparison of constant 419244183493398898 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (num_pages > (SIZE_MAX - sizeof(struct pagelist) -
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Shut up that warning by adding a cast to a longer type.

Fixes: ca641bae6da9 ("staging: vc04_services: prevent integer overflow in create_pagelist()")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210927113702.3866843-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7b9148dc 21-Jul-2021 Ojaswin Mujoo <ojaswin98@gmail.com>

staging: vchiq: Combine vchiq platform code into single file

Combine the vchiq platform initialization code into a single file by
merging vchiq_2835_arm.c into vchiq_arm.c

Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Ojaswin Mujoo <ojaswin98@gmail.com>
Link: https://lore.kernel.org/r/647cad50aa3306d1a49bacff76eaa3130fb363f4.1626882325.git.ojaswin98@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f0591628 21-Jul-2021 Ojaswin Mujoo <ojaswin98@gmail.com>

staging: vchiq: Move vchiq char driver to its own file

Split the initialization code of vchiq char driver and device files from
that of vchiq platform. The char driver code now resides in vchiq_dev.c
and the platform code resides in the original vchiq_arm.c file.

This commit focuses on separating the code into different files while
maintaining the same functionality. It does not completely decouple them
as the cdev init code is still called from the platform's vchiq_probe()
function.

Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Ojaswin Mujoo <ojaswin98@gmail.com>
Link: https://lore.kernel.org/r/ed53690e217f631b746aad0585fccaa6fb1453c1.1626882325.git.ojaswin98@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c405028f 21-Jul-2021 Ojaswin Mujoo <ojaswin98@gmail.com>

staging: vchiq: Move certain declarations to vchiq_arm.h

Move certain declarations from vchiq_arm.c to vchiq_arm.h to allow
code sharing. This will be useful when we eventually separate the vchiq
char driver code from platform code, into its own file.

Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Ojaswin Mujoo <ojaswin98@gmail.com>
Link: https://lore.kernel.org/r/8abcbd9fb3227e2a78ccc4a1186c8c0801061a68.1626882325.git.ojaswin98@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2a4d15a4 21-Jul-2021 Ojaswin Mujoo <ojaswin98@gmail.com>

staging: vchiq: Refactor vchiq cdev code

Move the vchiq cdev initialization code to its own function for better
code organization. Call the initialization function during probe, thus
shifting the whole cdev creation logic (which was earlier split in
vchiq_probe() and vchiq_driver_init()) to vchiq_probe().

Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Ojaswin Mujoo <ojaswin98@gmail.com>
Link: https://lore.kernel.org/r/c0e538eb0644292a52267d39edd85ab2af9f9a4e.1626882325.git.ojaswin98@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 68a48596 03-Jun-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: tidy up service function naming

During a recent review Dan Carpenter reported that the function naming of
(un)lock_service is misleading. They are like wrapper around kref_get /
kref_put and don't have anything to do with locking. So use a name which
represent more the actual behavior. Btw add the vchiq prefix to avoid
possible name conflicts.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-12-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 15618b35 03-Jun-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: get the rid of vchiq_static_assert

Use static_assert from the kernel instead of opencode it.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-6-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb928dad 03-Jun-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: introduce free_bulk_waiter

Avoid the copy & paste of freeing the bulk waiter and move it into a
separate function. Found by CPD.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-3-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1a64ab34 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Avoid unnecessary line breaks

There are a few statements which are unnecessary broken into multiple lines.
Let's join them into a single line to improve readability.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-18-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e39ff0e4 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: make vchiq_shutdown_internal return void

The function vchiq_shutdown_internal always returns VCHIQ_SUCCESS. So change
the return type to void and simplify the logic in vchiq_shutdown.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-17-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7040e9d7 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: re-arrange function header

This makes the function headers look more consistent.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-14-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f299b34e 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: add blank line after declarations

Improve the readability by add a blank line after declarations. This
was found with checkpatch.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-13-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fd3e03d7 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: drop non-beneficial comments

Those comments doesn't provide any benefit, so drop them.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-12-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a140f3a0 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Prefer kzalloc(sizeof(*waiter)...)

It's shorter and easier to maintain. This has been found with checkpatch.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-11-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 618150c1 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: drop ftrace-like logging

This addresses the warnings reported by checkpatch:
WARNING: Unnecessary ftrace-like logging - prefer using ftrace

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-10-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0705a939 15-May-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: balance braces for if-else statements

This fixes the following checkpatch notices in vchiq_arm:
CHECK: braces {} should be used on all arms of this statement

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-6-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 56a1c5cc 12-May-2021 Nguyen Dinh Phi <phind.uet@gmail.com>

Staging: vchiq_arm: Using pr_err and pr_notice instead of printk

This patch fixes the following checkpatch.pl warning:
fix Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then
dev_info(dev, ... then pr_info(... to printk(KERN_INFO ...

Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Link: https://lore.kernel.org/r/20210512184440.550116-1-phind.uet@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# abf2836a 24-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: drop vchiq_status from vchiq_initialise

Replace the custom set of return values with proper Linux error codes for
vchiq_initialise().

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1619347863-16080-11-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a2161d1d 24-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: drop vchiq_status from vchiq_set_service_option

Replace the custom set of return values with proper Linux error codes for
vchiq_set_service_option(). Now we can use the result directly as return
value for vchiq_ioctl().

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1619347863-16080-10-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a9fbd828 24-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: drop enum vchiq_status from vchiq_*_internal

Replace the custom set of return values with proper Linux error codes
for the following functions:

vchiq_use_internal()
vchiq_release_internal()
vchiq_use_service_internal()
vchiq_release_service_internal()

Now we can use the result directly as return value for vchiq_ioctl().

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1619347863-16080-9-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c74541f7 24-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: drop return value of vchiq_arm_init_state

The function vchiq_arm_init_state() cannot fail. So drop the return
value and the unnecessary code.

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1619347863-16080-7-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bdf2b26d 24-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: avoid crashing the kernel

Using BUG_ON in a non-essential driver isn't recommend. So better
trigger a stacktrace and bailout.

Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1619347863-16080-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d6139dec 18-Jan-2021 Nicolas Saenz Julienne <nsaenz@kernel.org>

staging: vchiq: Release firmware handle on unbind

Use devm_rpi_firmware_get() so as to make sure we release RPi's firmware
interface when unbinding the device.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5866bce0 06-Mar-2021 Jia-Ju Bai <baijiaju1990@gmail.com>

staging: vc04_services: vchiq_arm: fix error return code of vchiq_release_internal() and vchiq_use_internal()

When arm_state is NULL, no error return code of vchiq_release_internal()
and vchiq_use_internal() is assigned.
To fix this bug, ret is assigned with VCHIQ_ERROR.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Link: https://lore.kernel.org/r/20210306132245.16811-1-baijiaju1990@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 662d82cf 05-Jan-2021 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: fix uninitialized variable copy

Smatch found a local variable that can get copied to another
local variable without an initializion in the error case:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:1056 vchiq_get_user_ptr() error: uninitialized symbol 'ptr'.

This seems harmless, as the function should normally get inlined, with
the output directly written or not. In any case, the uninitialized data
is never used after get_user() fails.

As Dan mentions, it could still trigger an UBSAN runtime error, and it
is of course a bad idea to copy uninitialized variables, so just
bail out early.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210105135256.1810337-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 88753cc1 05-Jan-2021 Phil Elwell <phil@raspberrypi.com>

staging: vchiq: Fix bulk transfers on 64-bit builds

The recent change to the bulk transfer compat function missed the fact
the relevant ioctl command is VCHIQ_IOC_QUEUE_BULK_TRANSMIT32, not
VCHIQ_IOC_QUEUE_BULK_TRANSMIT, as any attempt to send a bulk block
to the VPU would have shown.

Fixes: a4367cd2b231 ("staging: vchiq: convert compat bulk transfer")
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Link: https://lore.kernel.org/r/20210105162030.1415213-3-phil@raspberrypi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 96ae3276 05-Jan-2021 Phil Elwell <phil@raspberrypi.com>

staging: vchiq: Fix bulk userdata handling

The addition of the local 'userdata' pointer to
vchiq_irq_queue_bulk_tx_rx omitted the case where neither BLOCKING nor
WAITING modes are used, in which case the value provided by the
caller is not returned to them as expected, but instead it is replaced
with a NULL. This lack of a suitable context may cause the application
to crash or otherwise malfunction.

Fixes: 4184da4f316a ("staging: vchiq: fix __user annotations")
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Link: https://lore.kernel.org/r/20210105162030.1415213-2-phil@raspberrypi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 27f7fcae 05-Jan-2021 Dan Carpenter <dan.carpenter@oracle.com>

staging: vchiq: delete obselete comment

This comment describes a security problem which was fixed in commit
1c954540c0eb ("staging: vchiq: avoid mixing kernel and user pointers").
The bug is fixed now so the FIXME can be removed.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/RnUjY3XkZohk7w@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c2ec4a6e 27-Oct-2020 Amarjargal Gundjalam <amarjargal16@gmail.com>

staging: vc04_services: fix quoted string split across lines

Fix checkpatch warning "fix quoted string split across lines".

Signed-off-by: Amarjargal Gundjalam <amarjargal16@gmail.com>
Link: https://lore.kernel.org/r/20201027175117.32826-3-amarjargal16@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3da87575 27-Oct-2020 Amarjargal Gundjalam <amarjargal16@gmail.com>

staging: vc04_services: fix block comment style

Fix block comments to adhere to the kernel coding style.

Signed-off-by: Amarjargal Gundjalam <amarjargal16@gmail.com>
Link: https://lore.kernel.org/r/20201027175117.32826-2-amarjargal16@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8750de90 06-Oct-2020 Dan Carpenter <dan.carpenter@oracle.com>

staging: vchiq: Fix list_for_each exit tests

After a list_for_each_entry() loop, the list iterator is always non-NULL
so these conditions don't work. If the "waiter" is not found then this
results in an out of bounds access.

I have fixed it by introducing a new "found" variable. In one case, I
used an else statement for readability.

Fixes: 46e4b9ec4fa4 ("staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20201006134748.GA2076872@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c1981671 30-Sep-2020 Dan Carpenter <dan.carpenter@oracle.com>

staging: vchiq: Fix an uninitialized variable

Smatch complains that "userdata" can be passed to vchiq_bulk_transfer()
without being initialized. This leads to a potential information leak
later on.

Fixes: a4367cd2b231 ("staging: vchiq: convert compat bulk transfer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200930123036.GC4282@kadam
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1c954540 25-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: avoid mixing kernel and user pointers

As found earlier, there is a problem in the create_pagelist() function
that takes a pointer argument that either points into vmalloc space or
into user space, with the pointer value controlled by user space allowing
a malicious user to trick the driver into accessing the kernel instead.

Avoid this problem by adding another function argument and passing
kernel pointers separately from user pointers. This makes it possible
to rely on sparse to point out invalid conversions, and it prevents
user space from faking a kernel pointer.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200925114424.2647144-2-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4184da4f 25-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: fix __user annotations

My earlier patches caused some new sparse warnings, but it turns out
that a number of those are actual bugs, or at least suspicous code.

Adding __user annotations to the data structures that are defined in
uapi headers helps avoid the new warnings, but that causes a different
set of warnings to show up, as some of these structures are used both
inside of the kernel and at the user interface but storing pointers to
different things there.

Duplicating the vchiq_service_params and vchiq_completion_data structures
in turn takes care of most of those, and then it turns out that there
is a 'data' pointer that can be any of a __user address, a dmd_addr_t
and a kernel pointer in vmalloc space at times.

I'm trying to annotate these as best I can without changing behavior,
but there still seems to be a serious bug when user space passes
a valid vmalloc space address instead of a user pointer. Adding
comments in the code there, and leaving the warnings in place that
seem to correspond to actual bugs.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200925114424.2647144-1-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5d240a54 18-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: convert compat await_completion

Split out the ioctl implementation for VCHIQ_IOC_QUEUE_BULK_TRANSMIT
into a separate function so it can be shared with the compat
implementation.

This one is the trickiest conversion, as the compat implementation
is already quite different from the native one. By using a common
handler, the behavior is changed to be the same again: The
indirect __user pointer accesses are now handled through helper
functions that check for compat mode internally.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-6-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a4367cd2 18-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: convert compat bulk transfer

Split out the ioctl implementation for VCHIQ_IOC_QUEUE_BULK_TRANSMIT
into a separate function so it can be shared with the compat
implementation.

Here, the input data is converted separately in the compat
handler, while the output data is passed as a __user pointer
to thec vchiq_queue_bulk_transfer->mode word that is
compatible.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-5-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f618affa 18-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: convert compat dequeue_message

Split out the ioctl implementation for VCHIQ_IOC_DEQUEUE_MESSAGE
into a separate function so it can be shared with the compat
implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-4-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f9caab9 18-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: convert compat create_service

Split out the ioctl implementation for VCHIQ_IOC_CREATE_SERVICE
into a separate function so it can be shared with the compat
implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-3-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 06c78d4e 18-Sep-2020 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: rework compat handling

The compat handlers for VCHIQ_IOC_QUEUE_MESSAGE32 and
VCHIQ_IOC_GET_CONFIG32 can simply call the underlying implementations
that are already separate functions rather than using copy_in_user to
simulate the native 64-bit interface for the full ioctl handler.

vchiq_ioc_queue_message gets a small update to the calling
conventions to simplify the compat version by directly
returning a normal errno value.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-2-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9d523111 29-Jun-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: Get rid of vchi

All the functions that vchi currently provides are a 1:1 mapping to its
vchiq counterparts. Get rid of vchi altogether and use vchiq's on all
services.

In the process also get rid of the vchi directory, as the only remaining
file was a TODO file, which now lives in the parent directory.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-44-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0bda14fd 29-Jun-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchi: Get rid of vchi_bulk_queue_transmit()

Its vchiq counterpart, vchiq_bulk_transmit() is only used by vchi. We
can then merge both functions by moving vchi_bulk_queue_transmit()'s
retry mechanism into vchiq_bulk_transmit() and let services call the
later.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-42-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b2bbe3dc 29-Jun-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchi: Get rid of vchi_bulk_queue_receive()

Its vchiq counterpart, vchiq_bulk_receive() is only used by vchi. We can
then merge both functions by moving vchi_bulk_queue_receive()'s retry
mechanism into vchiq_bulk_receive() and let services call the later.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-41-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f10ddbd 29-Jun-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: Make vchiq_add_service() local

The function is being exported although there is no use for it outside
of vchiq's core code. Keep it local then.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-39-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 460165c6 29-Jun-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: Get rid of vchiq_util.h

The header file only provides other includes. Move the relevant includes
to their respective C files and delete it for good.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-25-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5d9272e2 29-Jun-2020 Phil Elwell <phil@raspberrypi.com>

staging: vchiq_arm: Add a matching unregister call

All the registered children of vchiq have a corresponding call to
platform_device_unregister except bcm2835_audio. Fix that.

Fixes: 25c7597af20d ("staging: vchiq_arm: Register a platform device for audio")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-9-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 728774f7 18-May-2020 Mitchell Tasman <tasman@leaflabs.com>

staging: vchiq_arm: cast with __force as needed

In several cases where a pointer marked as __user is
(intentionally) assigned or passed to a non-marked target,
cast to the target pointer type with a __force directive
to quiet warnings from sparse.

Signed-off-by: Mitchell Tasman <tasman@leaflabs.com>
Link: https://lore.kernel.org/r/20200519004531.33158-1-tasman@leaflabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a6a002fd 09-Apr-2020 Jason Yan <yanaijie@huawei.com>

staging: vc04_services: remove set but not used 'local_entity_uc'

Fix the following gcc warning:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:2356:16:
warning: variable ‘local_entity_uc’ set but not used
[-Wunused-but-set-variable]
int local_uc, local_entity_uc;
^~~~~~~~~~~~~~~

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Link: https://lore.kernel.org/r/20200409085339.47255-1-yanaijie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 190c8f72 19-Mar-2020 Takashi Iwai <tiwai@suse.de>

staging: vc04_services: Use scnprintf() for avoiding potential buffer overflow

Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit. Fix it by replacing with scnprintf().

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-rpi-kernel@lists.infradead.org
Cc: devel@driverdev.osuosl.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200319161300.25967-1-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a2203cfe 12-Feb-2020 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vc04_services: don't increment service refcount when it's not needed

There are a few places where a service's reference count is incremented,
something quick is done, and the refcount is dropped. This can be made
a little simpler/faster by not grabbing a reference in these cases.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/ac6186ac888f1acf489b5b504efcba8b0d6a8b25.1581532523.git.marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3c27a36f 12-Feb-2020 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vc04_services: use kref + RCU to reference count services

Currently reference counts are implemented by locking service_spinlock
and then incrementing the service's ->ref_count field, calling
kfree() when the last reference has been dropped. But at the same
time, there's code in multiple places that dereferences pointers
to services without having a reference, so there could be a race there.

It should be possible to avoid taking any lock in unlock_service()
or service_release() because we are setting a single array element
to NULL, and on service creation, a mutex is locked before looking
for a NULL spot to put the new service in.

Using a struct kref and RCU-delaying the freeing of services fixes
this race condition while still making it possible to skip
grabbing a reference in many places. Also it avoids the need to
acquire a single spinlock when e.g. taking a reference on
state->services[i] when somebody else is in the middle of taking
a reference on state->services[j].

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/3bf6f1ec6ace64d7072025505e165b8dd18b25ca.1581532523.git.marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 12396526 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: vchiq_arm: Get rid of unused defines

They aren't used anywhere. Get rid of them.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-22-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# aca055ed 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Delete vchiq_platform_check_suspend()

The function does nothing.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-20-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ed151829 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of the rest of suspend/resume state handling

The only remaining state doesn't provide any information anymore nor the
completion that depends on it, which is set to complete_all() before any
user may wait on it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-18-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bd8aa285 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get of even more suspend/resume states

After the first states cleanup pass some set_suspend/resume_state()
calls disappeared which opened up even more opportunities for deletions.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-17-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 65479809 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of unused suspend/resume states

It's impossible to get into them, so simply delete them.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-16-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 26a65975 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Delete vc_suspend_complete completion

Nobody is waiting on it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-15-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6d044eac 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of vchiq_check_resume()

Nobody calls this function.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-14-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# af908f39 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of vchiq_arm_vcsuspend()

It's not used.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-13-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c9b361cc 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of vchiq_on_remote_use_active()

Function does nothing.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-12-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 004e890d 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of vchiq_platform_videocore_wanted()

The function always returns true, which makes a whole bunch of code
useless.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-10-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 88084848 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of vchiq_platform_suspend/resume()

vchiq_platform_suspend() and vchiq_platform_resume() do nothing, get rid
of them.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-9-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# be7fbad6 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: get rid of vchiq_platform_use_suspend_timer()

The function always returns 0, delete the function and all code
conditional to it, namely the suspend timer.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-7-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dcbcbfa4 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Delete blocked_count in struct vchiq_arm_state

The variable is always 0. So delete it an all the code conditional to
it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-6-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9af64167 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: get rid of blocked_blocker completion in struct vchiq_arm_state

Nobody is waiting on it, so delete it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-5-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d91f500a 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of resume_blocker completion in struct vchiq_arm_state

Nobody is waiting on it, so delete all relevant code.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-4-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7d153fcc 31-Jan-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vc04_services: Get rid of resume_blocked in struct vchiq_arm_state

The boolean value is never set to true, hence remove it and all the code that
depends on it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-3-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d2cdb205 03-Dec-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq: call unregister_chrdev_region() when driver registration fails

This undoes the previous call to alloc_chrdev_region() on failure,
and is probably what was meant originally given the label name.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Cc: stable <stable@vger.kernel.org>
Fixes: 187ac53e590c ("staging: vchiq_arm: rework probe and init functions")
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20191203153921.70540-1-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0f6f8749 20-Nov-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq: Have vchiq_dump_* functions return an error code

These functions currently modify the struct dump_context passed
to them, and set context->actual to -EFAULT in case of error.
The issue is that this is never returned to the user (except
accidentally when things align so that that happens). So, have
these functions return 0 on success and the appropriate error
code otherwise, and return nonzero errors to the user.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20191120202102.249121-5-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0046b33c 20-Nov-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq: Refactor indentation in vchiq_dump_* functions

Doing this helps with readability, and makes
the logic easier to follow.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20191120202102.249121-4-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 96a8b291 20-Nov-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq_dump: Replace min with min_t

Replacing this fixes checkpatch warnings.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/20191120202102.249121-3-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eacb77aa 20-Nov-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq: Fix block comment format in vchiq_dump()

This fixes a checkpatch warning.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/20191120202102.249121-2-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2611045e 14-Nov-2019 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vchiq: Refactor indentation in vchiq_platform_conn_state_changed()

Reducing the indentation level helps a bit with
the readability of this function. There's also a checkpatch
fix here, moving the first argument to kthread_create() onto
the same line, as well as a relocation of the statement
"char threadname[16];" to the top of the function to avoid
a declaration in the middle of code.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/20191114232801.71458-1-marcgonzalez@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4ddf9a25 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_INSTANCE_T typedef with struct vchiq_instance

Replaces VCHIQ_INSTANCE_T typedef with struct vchiq_instance to match
kernel code style. Issue found by checkpatch.

Additionally, as part of the process renames "struct vchiq_instance_struct" to "struct vchiq_instance".

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/ed2b3076f93a920149716687b48e0c5e3ddf0569.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9ce46d55 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_SERVICE_HANDLE_T typedef with unsigned int

Replaces VCHIQ_SERVICE_HANDLE_T typedef with unsigned int to match kernel code style. Issue found by checkpatch.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/9d35b9fea684d18cc1e989621808d77eef3081c6.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d2684ce8 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_BULK_DIR_T enum typedef with enum vchiq_bulk_dir

Replaces VCHIQ_BULK_DIR_T enum typedef with enum vchiq_bulk_dir to match
kernel code style. Issue found by checkpatch.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/344e01e371aa7fbf670ba118be174e391e078e6a.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 051fbf47 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_CONNSTATE_T enum typedef with enum vchiq_connstate

Replaces VCHIQ_CONNSTATE_T enum typedef with enum vchiq_connstate to
match kernel code style. Issue found by checkpatch.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/7e64765a55193413e9668dc53f751c435369ed80.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c6ac64b1 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_BULK_MODE_T enum typedef with enum vchiq_bulk_mode

Replaces VCHIQ_BULK_MODE_T enum typedef with enum vchiq_bulk_mode to
match kernel code style. Issue found by checkpatch.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/667037e1810921e30371dbeb52c1ae489bf31f8c.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 00d36494 05-Nov-2019 Jamal Shareef <jamal.k.shareef@gmail.com>

staging: vc04_services: Replace VCHIQ_STATUS_T enum typedef with enum vchiq_status

Replaces VCHIQ_STATUS_T enum typedef with enum vchiq_status to match
kernel code style. Issue found by checkpatch.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/7509cfa679c6d383ad979282f3d33b227d4d7f87.1572994235.git.jamal.k.shareef@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 161ca4c0 08-Oct-2019 Nachammai Karuppiah <nachukannan@gmail.com>

staging: vc04_services: Avoid NULL comparison

Remove NULL comparison. Issue found using checkpatch.pl

Signed-off-by: Nachammai Karuppiah <nachukannan@gmail.com>
Link: https://lore.kernel.org/r/1570589056-14386-1-git-send-email-nachukannan@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f8fcbb6b 03-Oct-2019 Nachammai Karuppiah <nachukannan@gmail.com>

staging: vc04_services: Avoid typedef

Avoid typedefs to maintain kernel coding style. Issue found by
checkpatch.pl

Replace the enum typedef VCHIQ_REASON_T with vchiq_reason.

Signed-off-by: Nachammai Karuppiah <nachukannan@gmail.com>
Link: https://lore.kernel.org/r/1570125797-24410-1-git-send-email-nachukannan@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# db0e6a57 26-Jul-2019 YueHaibing <yuehaibing@huawei.com>

staging: vc04_services: fix unused-but-set-variable warning

Fix gcc used-but-set-variable warning:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c: In function vchiq_release_internal:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:2827:16: warning:
variable local_entity_uc set but not used [-Wunused-but-set-variable]
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:2827:6: warning:
variable local_uc set but not used [-Wunused-but-set-variable]

Remove the unused variables 'local_entity_uc' and 'local_uc'

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20190727013524.33168-1-yuehaibing@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4a808fa3 25-Jun-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: vc04_services: Remove function block_resume()

Remove function block_resume as it was only called by
vchiq_arm_force_suspend, which was removed in a previous patch.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# efe06b23 25-Jun-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: vc04_services: Remove function output_timeout_error()

Remove function output_timeout_error as it was only called by
vchiq_arm_force_suspend, which was deleted in a previous patch.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6795dbb8 25-Jun-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: vc04_services: Remove vchiq_use_service_no_resume()

Remove unused function vchiq_use_service_no_resume.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 248a58a3 25-Jun-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: vc04_services: Remove vchiq_arm_force_suspend()

Remove unused function vchiq_arm_force_suspend.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 49bc1452 25-Jun-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: vc04_services: Remove function vchiq_arm_allow_resume()

Remove unused function vchiq_arm_allow_resume.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 023dbe17 09-May-2019 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: stop explicitly comparing with zero to catch errors

The vchiq code tends to follow a coding pattern that's not accepted as
per the Linux kernel coding style

We have this:
if (expression != 0)

We want this:
if (expression)

We make an exception if the expression refers to a size, in which case
it's accepted for the sake of clarity.

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>


# 086efbab 09-May-2019 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: revert "switch to wait_for_completion_killable"

The killable version of wait_for_completion() is meant to be used on
situations where it should not fail at all costs, but still have the
convenience of being able to kill it if really necessary. VCHIQ doesn't
fit this criteria, as it's mainly used as an interface to V4L2 and ALSA
devices.

Fixes: a772f116702e ("staging: vchiq: switch to wait_for_completion_killable")
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>


# e9f1040f 22-Apr-2019 Fuqian Huang <huangfq.daxian@gmail.com>

staging: vchiq_arm: Fix misuse of %x

Pointers should be printed with %p or %px rather than
cast to unsigned long type and printed with %lx.
Change %lx to %pK to print the pointers.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3baad68a 01-Apr-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: vc04_services: remove remaining redundant license text

Now that the SPDX tag is in all vc04_services files, that identifies the
license in a specific and legally-defined manner. So the extra GPL and
BSD text wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the license text.

No copyright headers or other non-license-description text was removed.

Cc: Eric Anholt <eric@anholt.net>
Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Cc: Aymen Qader <qader.aymen@gmail.com>
Cc: "Tobias Büttner" <tobias.buettner@fau.de>
Cc: Dominic Braun <inf.braun@fau.de>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Alejandro Ismael Silva <silva.alejandro.ismael@gmail.com>
Cc: Phil Elwell <phil@raspberrypi.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 371ebdbe 01-Apr-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: vc04_services: add proper SPDX identifier for dual licensed files

There are a number of vc04_services files that are dual licensed under
the GPL2 and BSD-3 licenses. They currently do not have a SPDX
identifier on them, so fix that up and add the proper identifier so that
tools can pick it up easily.

Cc: Eric Anholt <eric@anholt.net>
Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Cc: Aymen Qader <qader.aymen@gmail.com>
Cc: "Tobias Büttner" <tobias.buettner@fau.de>
Cc: Dominic Braun <inf.braun@fau.de>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Alejandro Ismael Silva <silva.alejandro.ismael@gmail.com>
Cc: Phil Elwell <phil@raspberrypi.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9fc6eeb7 02-Apr-2019 Mario Balan <mario.balan@gmail.com>

staging: vchiq_arm: remove space after open '('

Fix checkpatch error "ERROR: space prohibited after that open
parenthesis '('" in vchiq_arm.c:563.

Signed-off-by: Mario Balan <mario.balan@gmail.com>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ffb99752 24-Mar-2019 Jasminko Dedic <betelge@gmail.com>

staging: vc04_services: add missing __user annotations

This patch fixes the following sparse warnings by adding missing __user
annotations. It also cleans up two related unnecessary casts by reuseing
casts already made a few lines up. Remaining sparse warnings are of a
different type.

vchiq_arm.c:1606:14: warning: incorrect type in assignment (different address spaces)
vchiq_arm.c:1606:14: expected struct vchiq_queue_message *args
vchiq_arm.c:1606:14: got void [noderef] <asn:1> *

vchiq_arm.c:1612:13: warning: incorrect type in argument 1 (different address spaces)
vchiq_arm.c:1612:13: expected void const volatile [noderef] <asn:1> *
vchiq_arm.c:1612:13: got unsigned int *

vchiq_arm.c:1613:13: warning: incorrect type in argument 1 (different address spaces)
vchiq_arm.c:1613:13: expected void const volatile [noderef] <asn:1> *
vchiq_arm.c:1613:13: got unsigned int *

vchiq_arm.c:1614:13: warning: incorrect type in argument 1 (different address spaces)
vchiq_arm.c:1614:13: expected void const volatile [noderef] <asn:1> *
vchiq_arm.c:1614:13: got struct vchiq_element const [noderef] <asn:1> **

vchiq_arm.c:1638:21: warning: incorrect type in argument 1 (different address spaces)
vchiq_arm.c:1638:21: expected void const volatile [noderef] <asn:1> *
vchiq_arm.c:1638:21: got struct vchiq_element const [noderef] <asn:1> **

Signed-off-by: Jasminko Dedic <betelge@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9b9c87cf 25-Mar-2019 Dan Carpenter <dan.carpenter@oracle.com>

staging: vc04_services: Fix an error code in vchiq_probe()

We need to set "err" on this error path.

Fixes: 187ac53e590c ("staging: vchiq_arm: rework probe and init functions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2d0a0291 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_STATE_T typedef

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>


# 4f0922c8 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_SET_SERVICE_OPTION_T typedef

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>


# 7926c328 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_SERVICE_T typedef

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>


# 0b53ca31 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_SERVICE_PARAMS_T typedef

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>


# 87c091aa 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_QUEUE_MESSAGE_T typedef

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>


# 4040a7ee 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_QUEUE_BULK_TRANSFER_T typedef

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>


# e8968525 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_HEADER_T typedef

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>


# 3515279e 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_GET_CONFIG_T typedef

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>


# 8ca743a1 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_DEQUEUE_MESSAGE_T typedef

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>


# aa987e55 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_DEBUGFS_NODE_T typedef

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>


# 56294328 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_CREATE_SERVICE_T typedef

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>


# 8b867447 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_CONFIG_T typedef

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>


# e69106e5 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_COMPLETION_DATA_T typedef

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>


# bc96a5f0 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_BULK_T typedef

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>


# cf69fc52 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_AWAIT_COMPLETION_T typedef

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>


# e376ef35 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove VCHIQ_ARM_STATE_T typedef

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>


# 4dfc415f 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove USER_SERVICE_T typedef

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>


# 4eef62d6 14-Dec-2018 Dominic Braun <inf.braun@fau.de>

staging: vc04_services: Remove DUMP_CONTEXT_T typedef

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>


# 2da56630 12-Dec-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: delete vchiq_killable.h

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>


# a772f116 12-Dec-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: switch to wait_for_completion_killable

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>


# 25c7597a 06-Dec-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Register a platform device for audio

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>


# 405e2f98 06-Dec-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Fix camera device registration

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>


# 0ff8c980 28-Nov-2018 Szilveszter Székely <szekelyszilv@gmail.com>

staging: vchiq_arm: add __user pointer annotations

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>


# 4ab0f5ce 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: fix open/release cdev functions

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>


# 187ac53e 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: rework probe and init functions

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>


# f27e47bc 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: use completions instead of semaphores

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>


# 44c1e1bc 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: rework vchiq_ioc_copy_element_data

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>


# ee43f745 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: get rid of vchi_mh.h

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>


# 46e4b9ec 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list

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>


# ddd7536a 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_arm: rework close/remove_service IOCTLS

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>


# 49fa9157 20-Nov-2018 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq_core: rework vchiq_get_config

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>


# 5a96b2d3 03-Nov-2018 Ben Wolsieffer <benwolsieffer@gmail.com>

staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETION

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>


# c683db88 17-Sep-2018 Phil Elwell <phil@raspberrypi.org>

staging/vc04_services: Use correct cache line size

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>


# 0723103f 01-Jun-2018 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: vc04_services: no need to check debugfs return values

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>


# 37b7b308 10-May-2018 Eric Anholt <eric@anholt.net>

staging/vc04_services: Register a platform device for the camera driver.

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>


# 8ba7d1e3 28-Apr-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: remove unnecessary return

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>


# b0ae3f55 28-Apr-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Make index variable more self-explaining

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>


# 0b134c5d 28-Apr-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Rework second abort criterion

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>


# 028fa9d0 28-Apr-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Clear VLA warning

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>


# d3534660 28-Apr-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: print real dump limit

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>


# 81244ba0 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Avoid long udelay

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>


# 77f89692 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Fix multiline dereferences

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>


# 4486174c 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vc04_services: Use __func__ macro

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>


# 474e1dc5 09-Mar-2018 Eric Anholt <eric@anholt.net>

staging: vc04_services: Remove vchiq_queue_bulk_{transmit,receive}.

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>


# 45b7c732 09-Mar-2018 Eric Anholt <eric@anholt.net>

staging: vc04_services: Replace "firmware" node with a compatible lookup.

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>


# 5c5e6ef6 02-Feb-2018 Arnd Bergmann <arnd@arndb.de>

staging: vc04_services: merge vchiq_kern_lib.c into vchiq_arm.c

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>


# ab308053 25-Dec-2017 Sidong Yang <realwakka@gmail.com>

staging: vc05_services: fix checkpatch.pl errors

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>


# dbc0f572 30-Oct-2017 Kees Cook <keescook@chromium.org>

staging: vc04_services: Convert timers to use timer_setup()

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>


# 7ab1197d 27-Sep-2017 Keerthi Reddy <keerthigd4990@gmail.com>

staging: vc04_services: please do not use multiple blank lines

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>


# cbf83fb8 21-Sep-2017 Dan Carpenter <dan.carpenter@oracle.com>

staging: vc04_services: remove BCM2835_VCHIQ_SUPPORT_MEMDUMP

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>


# 397fcd12 11-Jul-2017 Dan Carpenter <dan.carpenter@oracle.com>

staging: vchiq_arm: fix error codes in probe

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>


# b322396c 25-May-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Avoid multiline dereference

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>


# 42a6bd8f 25-May-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Fix variable names in comment

This comment was apparently forgotten in the correction of CamelCase.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2ea91ce5 18-Mar-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Fix MODULE_LICENSE

Regarding to the header the driver is licensed under BSD and GPL.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 702d8d0f 15-Mar-2017 Gargi Sharma <gs051095@gmail.com>

staging: vc04_services: Replace typedef with struct

Using typedef for a structure type and upper case struct names is not
suggested in Linux kernel coding style guidelines. Hence, occurences
of typedefs have been removed and struct names converted to lowercase
in the file. Grep was also used to ensure that all occurence of the
typedefs have been removed. The module compiles without any warnings
or errors.

Script 1:
@r1@
type T;
@@

typedef struct { ... } T;

@script:python c1@
T2;
T << r1.T;
@@
if T[-2:] =="_T":
coccinelle.T2 = T[:-2].lower();
print T
else:
coccinelle.T2=T.lower();

@r2@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;

@r3@
type r1.T;
identifier c1.T2;
@@
- T
+ struct T2

Script 2:
@@
typedef VCHIQ_ELEMENT_T;
@@

(
- VCHIQ_ELEMENT_T
+ struct vchiq_element
)

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 12ab1659 07-Mar-2017 Michael Zoran <mzoran@crowfest.net>

staging: vchiq_arm: Disable ability to dump memory by default

vc04_services has an ioctl interface to dump arbitrary memory
to a custom debug log. This is typically only needed by
diagnostic tools, and can potentially be a security issue
if the devtmpfs node doesn't have adequate permissions set.

Since the ability to dump memory still has debugging value,
create a new build configuration and disable the feature
by default.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5569a126 07-Mar-2017 Michael Zoran <mzoran@crowfest.net>

staging: vchiq_arm: Add compatibility wrappers for ioctls

This patch adds compatibility wrappers for the ioctls
exposed by vchiq/vc04_services. The compat ioctls are
completely implemented on top of the native ioctls. No
existing lines are modified.

While the ideal approach would be to cleanup the existing
code, this path is simplier and easier to review. While
it does have a small runtime performance penality vs
seperating the existing code into wrapper+worker functions,
the penality is small since only the metadata is copied
back onto the 32 bit user mode stack.

The on top of approach is the approach used by several
existing performance critical subsystems of Linux such
as the DRM 3D graphics subsystem.

Testing:

1. A 32 bit chroot was created on a RPI 3 and vchiq_test
was built for armhf. The usual tests were run such as
vchiq_test -f 10 and vchiq_test -p.

2. This patch was copied onto the shipping version of
the Linux kernel used for the RPI and that kernel was
built for arm64. That kernel was used to boot Raspbian.
Many of the builtin features are now functional such
as the "hello_pi" examples, and minecraft_pi.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 47db0f6c 23-Feb-2017 Gargi Sharma <gs051095@gmail.com>

staging: vc04_services: Remove explicit NULL comparison

Replace explicit NULL comparison with ! operator to
simplify code.

Found with Coccinelle script:
@@
expression ptr;
position p;
statement s0, s1;
@@

ptr@p =
\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|usb_alloc_urb\|
alloc_netdev\|dev_alloc_skb\)(...)
... when != ptr

if (
(
+ !
ptr
- == NULL
)
) s0 else s1

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0169acae 21-Feb-2017 simran singhal <singhalsimran0@gmail.com>

staging: vc04_services: Using macro DIV_ROUND_UP

The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
It clarifies the divisor calculations. This occurence was detected using
the coccinelle script:

@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1)) / (e2)
+ DIV_ROUND_UP(e1,e2)
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6e475350 21-Feb-2017 Yamanappagouda Patil <goudapatilk@gmail.com>

staging: vc04_services: Fixed 'missing a blank line' warnings.

Fixed checkpatch.pl "missing a blank line after declarations" warning
messages in vc04_services module.

Signed-off-by: Yamanappagouda Patil <goudapatilk@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3f07c014 08-Feb-2017 Ingo Molnar <mingo@kernel.org>

sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h>

We are going to split <linux/sched/signal.h> out of <linux/sched.h>, which
will have to be picked up from other headers and a couple of .c files.

Create a trivial placeholder <linux/sched/signal.h> file that just
maps to <linux/sched.h> to make this patch obviously correct and
bisectable.

Include the new header in the files that are going to need it.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 608595ed 27-Feb-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

scripts/spelling.txt: add "therfore" pattern and fix typo instances

Fix typos and add the following to the scripts/spelling.txt:

therfore||therefore

Besides, tidy up comment blocks for 80-col wrapping.

Link: http://lkml.kernel.org/r/1481573103-11329-31-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a2db578b 17-Jan-2017 Phil Elwell <phil@raspberrypi.org>

staging: vchiq_arm: Avoid premature message stalls

The constants MAX_COMPLETIONS and MSG_QUEUE_SIZE control
the number of messages that can be outstanding to each client
before the system as a whole stalls. If the numbers are too
small then unnecessary thread switching will occur while
waiting for a (potentially low priority) client thread to
consume some data; badly written clients can even lead to
deadlock.

For services that carry many short messages, 16 messages can
represent a very small amount of data. Since the resources
are small - 16 bytes for a completion, 4 bytes for a message
pointer - increase the limits so they are unlikely to be hit
except in exceptional circumstances.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ca3df03b 17-Jan-2017 Phil Elwell <phil@raspberrypi.org>

staging: vc04_services: Fix messages appearing twice

An issue was observed when flushing openmax components
which generate a large number of messages returning
buffers to host.

We occasionally found a duplicate message from 16
messages prior, resulting in a buffer returned twice.

So fix the issue by adding more memory barriers.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5069c86ac 17-Jan-2017 Phil Elwell <phil@raspberrypi.org>

staging: vchiq_arm: Service callbacks must not fail

Service callbacks are not allowed to return an error. The internal
callback that delivers events and messages to user tasks does not
enqueue them if the service is closing, but this is not an error
and should not be reported as such.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 72ed1db4 17-Jan-2017 Phil Elwell <phil@raspberrypi.org>

staging: vchiq_arm: Fix unlocked access to dequeue_pending

The dequeue_pending flag wasn't protected by a spinlock in the
service_callback. So fix this to make it safe.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b33050d0 08-Jan-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vc04_services: Fix space issues

This fixes the space coding styles issues complained by checkpatch.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f306ed07 08-Jan-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vc04_services: Fix indentation

This should fix the indentation issues found by checkpatch.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 698c4eba 08-Jan-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vc04_services: Improve readability of kthread names

This patch tries to make the kernel thread names of vchiq a little
bit more self explaining and look closer to the existing ones:

slot handler: VCHIQ-%d -> vchiq-slot/%d
recycle thread: VCHIQr-%d -> vchiq-recy/%d
sync thread: VCHIQs-%d -> vhciq-sync/%d
keep-alive thread: VCHIQka-%d -> vchiq-keep/%d

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 364d26f1 08-Jan-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vc04_services: Use preferred kernel types

This patch fixes issues reported by checkpatch.pl about preferred
kernel types.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c98a5a0f 08-Jan-2017 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: remove vchiq_platform_check_resume

This function is never used, so we could remove it.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b826d73b 16-Nov-2016 Arnd Bergmann <arnd@arndb.de>

staging: vc04_services: remove duplicate mutex_lock_interruptible

The driver tries to redefine mutex_lock_interruptible as an open-coded
mutex_lock_killable, but that definition clashes with the normal
mutex_lock_interruptible definition when CONFIG_DEBUG_LOCK_ALLOC
is set:

staging/vc04_services/interface/vchiq_arm/vchiq_killable.h:67:0: error: "mutex_lock_interruptible" redefined [-Werror]
#define mutex_lock_interruptible mutex_lock_interruptible_killable
include/linux/mutex.h:161:0: note: this is the location of the previous definition

This simply removes the private implementation and uses the
normal mutex_lock_killable directly.

We could do the same for the down_interruptible_killable here, but
it's better to just remove the semaphores entirely from the driver,
which also takes care of that.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5209f93b 11-Nov-2016 kbuild test robot <fengguang.wu@intel.com>

staging: vc04_services: fix array_size.cocci warnings

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:193:39-40: WARNING: Use ARRAY_SIZE

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element

Semantic patch information:
This makes an effort to find cases where ARRAY_SIZE can be used such as
where there is a division of sizeof the array by the sizeof its first
element or by any indexed element or the element type. It replaces the
division of the two sizeofs by ARRAY_SIZE.

Generated by: scripts/coccinelle/misc/array_size.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 30d84860 11-Nov-2016 kbuild test robot <fengguang.wu@intel.com>

staging: vc04_services: fix returnvar.cocci warnings

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:1788:16-22: Unneeded variable: "status". Return "VCHIQ_SUCCESS" on line 1824

Remove unneeded variable used to store return value.

Generated by: scripts/coccinelle/misc/returnvar.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53a6e71f 11-Nov-2016 kbuild test robot <fengguang.wu@intel.com>

staging: vc04_services: fix setup_timer.cocci warnings

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:1817:2-12: Use setup_timer function for function on line 1818.

Use setup_timer function instead of initializing timer with the function
and data fields
Generated by: scripts/coccinelle/api/setup_timer.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9224c15c 31-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: change order during module probe

The current order during module probe is prone to race conditions:

* debugfs entries, sysfs entries, platform code

So fix this by swapping the steps debugfs entries and platform code.
As a benefit this saves us a clean up step in the error path.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0ece01c6 31-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: remove debugfs entries on module unload

This removes the debugfs entries on module unload and fix one
of the many kernel oops after loading the module again.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0feb1ed5 31-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: handle error case of get_user_pages

It's possible that get_user_pages() could fail. So evaluate its
return code and handle this error case properly.

This issue has been found by Cppcheck.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6d5f49a9 31-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: remove hardcoded buffer length

We better use sizeof instead of hardcoding buffer length multiple
times. This make it easier to increase the buffer in the future.
In order to keep below 80 chars limit make the variable name shorter.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d10543ec 31-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: add missing of_node_put

After device_node usage the refcount must be decremented with
of_node_put().

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 49bec49f 30-Oct-2016 Michael Zoran <mzoran@crowfest.net>

staging: vc04_services: remove vchiq_copy_from_user

The vchiq_copy_from_user function is not portable
and is consider "bad practice." Replace this function
with a callback based mechanism that is passed downward
on the stack. When it is actually time to copy the data,
the callback is called to copy the data into the message.

This callback is provided internally for userland calls
through ioctls on the device.

NOTE: Internal clients will need to be modified to work
with the new internal API.

Test Run:
vchiq_test -p 1
vchiq_test -f 10

Both tests pass.

Internal API Changes:

Change vchi_msg_queue to:
int32_t
vchi_msg_queue(VCHI_SERVICE_HANDLE_T handle,
ssize_t (*copy_callback)(void *context, void *dest,
size_t offset, size_t maxsize),
void *context,
uint32_t data_size );

Remove:
vchi_msg_queuev_ex
vchi_msg_queuev

These functions were not implemented anyway so no need to fix them. It's
easier to just remove them.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bea845af 26-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: Make DT firmware node mandatory

In Linux Mainline there wasn't a chance to boot the RPi without DT.
So we can make the firmware node mandatory.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8f8a3402 26-Oct-2016 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_arm: add MODULE_DESCRIPTION

This patch adds the missing module description for the driver.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b04451d7 17-Oct-2016 Wei Yongjun <weiyongjun1@huawei.com>

staging: bcm2708_vchiq: fix return value check in vchiq_platform_conn_state_changed()

In case of error, the function kthread_create() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cf8e732b 17-Oct-2016 Wei Yongjun <weiyongjun1@huawei.com>

staging: bcm2708_vchiq: remove .owner field for driver

Remove .owner field if calls are used which set it automatically.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 768ae309 12-Oct-2016 Lorenzo Stoakes <lstoakes@gmail.com>

mm: replace get_user_pages() write/force parameters with gup_flags

This removes the 'write' and 'force' from get_user_pages() and replaces
them with 'gup_flags' to make the use of FOLL_FORCE explicit in callers
as use of this flag can result in surprising behaviour (and hence bugs)
within the mm subsystem.

Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# df044ebf 10-Oct-2016 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: vc04_services: don't print pointers directly

kernel pointers should be printed with %pK and are not unsigned int big
on all architectures. So fix this up to get rid of a bunch of warning
messages.

Note, there are other assumptions in this code that a pointer fits into
an int that need to be fixed up later.

Cc: Daniel Stone <daniels@collabora.com>
Cc: "Noralf Trønnes" <noralf@tronnes.org>
Cc: Pranith Kumar <bobby.prani@gmail.com>
Cc: popcornmix <popcornmix@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 232664b3 03-Oct-2016 Eric Anholt <eric@anholt.net>

staging/vchi: Update for rename of page_cache_release() to put_page().

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 166beccd 03-Oct-2016 Eric Anholt <eric@anholt.net>

staging/vchi: Convert to current get_user_pages() arguments.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 71bad7f0 02-Jul-2013 popcornmix <popcornmix@gmail.com>

staging: add bcm2708 vchiq driver

Signed-off-by: popcornmix <popcornmix@gmail.com>

vchiq: create_pagelist copes with vmalloc memory

Signed-off-by: Daniel Stone <daniels@collabora.com>

vchiq: fix the shim message release

Signed-off-by: Daniel Stone <daniels@collabora.com>

vchiq: export additional symbols

Signed-off-by: Daniel Stone <daniels@collabora.com>

VCHIQ: Make service closure fully synchronous (drv)

This is one half of a two-part patch, the other half of which is to
the vchiq_lib user library. With these patches, calls to
vchiq_close_service and vchiq_remove_service won't return until any
associated callbacks have been delivered to the callback thread.

VCHIQ: Add per-service tracing

The new service option VCHIQ_SERVICE_OPTION_TRACE is a boolean that
toggles tracing for the specified service.

This commit also introduces vchi_service_set_option and the associated
option VCHI_SERVICE_OPTION_TRACE.

vchiq: Make the synchronous-CLOSE logic more tolerant

vchiq: Move logging control into debugfs

vchiq: Take care of a corner case tickled by VCSM

Closing a connection that isn't fully open requires care, since one
side does not know the other side's port number. Code was present to
handle the case where a CLOSE is sent immediately after an OPEN, i.e.
before the OPENACK has been received, but this was incorrectly being
used when an OPEN from a client using port 0 was rejected.

(In the observed failure, the host was attempting to use the VCSM
service, which isn't present in the 'cutdown' firmware. The failure
was intermittent because sometimes the keepalive service would
grab port 0.)

This case can be distinguished because the client's remoteport will
still be VCHIQ_PORT_FREE, and the srvstate will be OPENING. Either
condition is sufficient to differentiate it from the special case
described above.

vchiq: Avoid high load when blocked and unkillable

vchiq: Include SIGSTOP and SIGCONT in list of signals not-masked by vchiq to allow gdb to work

vchiq_arm: Complete support for SYNCHRONOUS mode

vchiq: Remove inline from suspend/resume

vchiq: Allocation does not need to be atomic

vchiq: Fix wrong condition check

The log level is checked from within the log call. Remove the check in the call.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>

BCM270x: Add vchiq device to platform file and Device Tree

Prepare to turn the vchiq module into a driver.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

bcm2708: vchiq: Add Device Tree support

Turn vchiq into a driver and stop hardcoding resources.
Use devm_* functions in probe path to simplify cleanup.
A global variable is used to hold the register address. This is done
to keep this patch as small as possible.
Also make available on ARCH_BCM2835.
Based on work by Lubomir Rintel.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

vchiq: Change logging level for inbound data

vchiq_arm: Two cacheing fixes

1) Make fragment size vary with cache line size
Without this patch, non-cache-line-aligned transfers may corrupt
(or be corrupted by) adjacent data structures.

Both ARM and VC need to be updated to enable this feature. This is
ensured by having the loader apply a new DT parameter -
cache-line-size. The existence of this parameter guarantees that the
kernel is capable, and the parameter will only be modified from the
safe default if the loader is capable.

2) Flush/invalidate vmalloc'd memory, and invalidate after reads

vchiq: fix NULL pointer dereference when closing driver

The following code run as root will cause a null pointer dereference oops:

int fd = open("/dev/vc-cma", O_RDONLY);
if (fd < 0)
err(1, "open failed");
(void)close(fd);

[ 1704.877721] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 1704.877725] pgd = b899c000
[ 1704.877736] [00000000] *pgd=37fab831, *pte=00000000, *ppte=00000000
[ 1704.877748] Internal error: Oops: 817 [#1] PREEMPT SMP ARM
[ 1704.877765] Modules linked in: evdev i2c_bcm2708 uio_pdrv_genirq uio
[ 1704.877774] CPU: 2 PID: 3656 Comm: stress-ng-fstat Not tainted 3.19.1-12-generic-bcm2709 #12-Ubuntu
[ 1704.877777] Hardware name: BCM2709
[ 1704.877783] task: b8ab9b00 ti: b7e68000 task.ti: b7e68000
[ 1704.877798] PC is at __down_interruptible+0x50/0xec
[ 1704.877806] LR is at down_interruptible+0x5c/0x68
[ 1704.877813] pc : [<80630ee8>] lr : [<800704b0>] psr: 60080093
sp : b7e69e50 ip : b7e69e88 fp : b7e69e84
[ 1704.877817] r10: b88123c8 r9 : 00000010 r8 : 00000001
[ 1704.877822] r7 : b8ab9b00 r6 : 7fffffff r5 : 80a1cc34 r4 : 80a1cc34
[ 1704.877826] r3 : b7e69e50 r2 : 00000000 r1 : 00000000 r0 : 80a1cc34
[ 1704.877833] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user
[ 1704.877838] Control: 10c5387d Table: 3899c06a DAC: 00000015
[ 1704.877843] Process do-oops (pid: 3656, stack limit = 0xb7e68238)
[ 1704.877848] Stack: (0xb7e69e50 to 0xb7e6a000)
[ 1704.877856] 9e40: 80a1cc3c 00000000 00000010 b88123c8
[ 1704.877865] 9e60: b7e69e84 80a1cc34 fff9fee9 ffffffff b7e68000 00000009 b7e69ea4 b7e69e88
[ 1704.877874] 9e80: 800704b0 80630ea4 fff9fee9 60080013 80a1cc28 fff9fee9 b7e69edc b7e69ea8
[ 1704.877884] 9ea0: 8040f558 80070460 fff9fee9 ffffffff 00000000 00000000 00000009 80a1cb7c
[ 1704.877893] 9ec0: 00000000 80a1cb7c 00000000 00000010 b7e69ef4 b7e69ee0 803e1ba4 8040f514
[ 1704.877902] 9ee0: 00000e48 80a1cb7c b7e69f14 b7e69ef8 803e1c9c 803e1b74 b88123c0 b92acb18
[ 1704.877911] 9f00: b8812790 b8d815d8 b7e69f24 b7e69f18 803e2250 803e1bc8 b7e69f5c b7e69f28
[ 1704.877921] 9f20: 80167bac 803e222c 00000000 00000000 b7e69f54 b8ab9ffc 00000000 8098c794
[ 1704.877930] 9f40: b8ab9b00 8000efc4 b7e68000 00000000 b7e69f6c b7e69f60 80167d6c 80167b28
[ 1704.877939] 9f60: b7e69f8c b7e69f70 80047d38 80167d60 b7e68000 b7e68010 8000efc4 b7e69fb0
[ 1704.877949] 9f80: b7e69fac b7e69f90 80012820 80047c84 01155490 011549a8 00000001 00000006
[ 1704.877957] 9fa0: 00000000 b7e69fb0 8000ee5c 80012790 00000000 353d8c0f 7efc4308 00000000
[ 1704.877966] 9fc0: 01155490 011549a8 00000001 00000006 00000000 00000000 76cf3ba0 00000003
[ 1704.877975] 9fe0: 00000000 7efc42e4 0002272f 76e2ed66 60080030 00000003 00000000 00000000
[ 1704.877998] [<80630ee8>] (__down_interruptible) from [<800704b0>] (down_interruptible+0x5c/0x68)
[ 1704.878015] [<800704b0>] (down_interruptible) from [<8040f558>] (vchiu_queue_push+0x50/0xd8)
[ 1704.878032] [<8040f558>] (vchiu_queue_push) from [<803e1ba4>] (send_worker_msg+0x3c/0x54)
[ 1704.878045] [<803e1ba4>] (send_worker_msg) from [<803e1c9c>] (vc_cma_set_reserve+0xe0/0x1c4)
[ 1704.878057] [<803e1c9c>] (vc_cma_set_reserve) from [<803e2250>] (vc_cma_release+0x30/0x38)
[ 1704.878069] [<803e2250>] (vc_cma_release) from [<80167bac>] (__fput+0x90/0x1e0)
[ 1704.878082] [<80167bac>] (__fput) from [<80167d6c>] (____fput+0x18/0x1c)
[ 1704.878094] [<80167d6c>] (____fput) from [<80047d38>] (task_work_run+0xc0/0xf8)
[ 1704.878109] [<80047d38>] (task_work_run) from [<80012820>] (do_work_pending+0x9c/0xc4)
[ 1704.878123] [<80012820>] (do_work_pending) from [<8000ee5c>] (work_pending+0xc/0x20)
[ 1704.878133] Code: e50b1034 e3a01000 e50b2030 e580300c (e5823000)

..the fix is to ensure that we have actually initialized the queue before we attempt
to push any items onto it. This occurs if we do an open() followed by a close() without
any activity in between.

Signed-off-by: Colin Ian King <colin.king@canonical.com>

vchiq_arm: Sort out the vmalloc case

See: https://github.com/raspberrypi/linux/issues/1055

vchiq: hack: Add include depecated dma include file

[gregkh] added dependancy on CONFIG_BROKEN to make things sane for now.

Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>