History log of /linux-master/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
Revision Date Author Comments
# 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>


# f9c42898 28-Nov-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: vchiq_core: Log through struct vchiq_instance

The handle_to_service() helper can return NULL, so `service` pointer
can indeed be set to NULL. So, do not log through service pointer
(which can cause NULL-deference), instead, use the vchiq_instance
function argument to get access to the struct device.

Fixes: f67af5940d6d ("staging: vc04: Convert(and rename) vchiq_log_info() to use dynamic debug")
Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231128201845.489237-1-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>


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

staging: vchiq_core: Shorten bulk TX/RX pending dump

The calculation for the bulk TX/RX pending is complex and
reaches 99 chars per line. So move the size determination
below the pending calculation and get the rid of the
ternary operator.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20231029124837.119832-3-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: Make vchiq_dump_service_state static

The function vchiq_dump_service_state() is only used by vchiq_dump_state()
within vchiq_core.c. So move the definition of vchiq_dump_state() below
vchiq_dump_service_state() in order to make it static.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20231029124837.119832-2-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2a4033b2 31-Oct-2023 Dan Carpenter <dan.carpenter@linaro.org>

staging: vc04_services: remove unnecessary NULL check

We ensured that "service" as non-NULL in the previous if statement so
there is no need to check again here.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/1dff4d9b-d067-4525-95e0-ffdc1185cccd@moroto.mountain
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>


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

staging: vc04_services: Pass struct device to vchiq_log_dump_mem()

Pass struct device pointer to vchiq_log_dump_mem(). 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-2-umang.jain@ideasonboard.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>


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

staging: vc04_services: vchiq_arm: Drop VCHIQ_RETRY usage on disconnect

Drop the usage of VCHIQ_RETRY when the vchiq has connection status
VCHIQ_CONNSTATE_DISCONNECTED. Disconnected status will not be valid to
carry on a retry, hence replace the VCHIQ_RETRY with -ENOTCONN.

This patch removes the usage of vCHIQ_RETRY completely and act 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-6-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>


# c478aa12 22-Dec-2022 Phil Elwell <phil@raspberrypi.com>

staging: vchiq_core: Add comments to remote event parts

struct remote_event and the related functions remote_event_*() provides
a higher function between ARM core and VPU. It's very helpful for a
reviewer to have explaining comments about these parts.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20221222141553.138563-1-stefan.wahren@i2se.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>


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

staging: vchiq_arm: remove global 'vchiq_states' array

Remove global 'vchiq_states' array, which is not used anymore.

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"

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


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

staging: vchiq_arm: use state from vchiq instance

In 'handle_to_service', access the vchiq state from the vchiq instance
instead of the global 'vchiq_states' array. This will allow getting rid
of the global 'vchiq_states' 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-9-athierry@redhat.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>


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

staging: vchiq_arm: pass vchiq instance to 'vchiq_get_service_userdata'

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 'vchiq_get_service_userdata'.
Therefore, pass the vchiq instance reference to it.

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


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

staging: vchiq_arm: pass vchiq instance to 'vchiq_get_client_id'

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 'vchiq_get_client_id'. Therefore, pass
the vchiq instance reference to it.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Adrien Thierry <athierry@redhat.com>
Link: https://lore.kernel.org/r/20220518191126.60396-6-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>


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

staging: vchiq_core: handle NULL result of find_service_by_handle

In case of an invalid handle the function find_servive_by_handle
returns NULL. So take care of this and avoid a NULL pointer dereference.

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-18-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: use min_t macro

Don't try to open code min_t().

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-15-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: avoid ternary operator for set_service_state

There is already a check for service->sync, so use this instead of a
separate ternary operator to update the service state.

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-14-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: fix alignment

This fixes some alignment found by checkpatch.pl.

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-13-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: reduce multi-line statements

In order to improvement readability try to reduce the multi-line statements.

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-12-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: drop prefix of vchiq_set_service_state

The name of this static function is unnecessary longish. So drop the prefix.
This gives us the chance to avoid some multi-line statements or fix some
indentations later.

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-11-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: align return statements in msg_type_str

The return statements aren't properly aligned. So fix this by using tabs.

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-10-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: simplify vchiq_add_service_internal

Better use kzalloc to properly init vchiq_service with zero. As a result
this saves us all the zero assignments.

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-9-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: fix type of parameter localport

The whole vchiq driver uses unsigned int for "localport" except of
find_service_by_port(). So fix this and get the rid of this suspicous
cast.

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-8-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: fix indentation in vchiq_log_dump_mem

This align the indentation in the var declaration of vchiq_log_dump_mem to
the other code.

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-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d8a36482 29-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: get rid of typedef

The typedef BITSET_T is acting as a synonym of u32. However, using the type u32
directly makes the code more readable. Furthermore, typedef should only be used
in some cases, [1]. Hence, get rid of it.

[1] Documentation/process/coding-style.rst

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


# 846bf13d 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: fix quoted strings split across lines

Quoted strings should not be split across lines. As put it in [1]:
"never break user-visible strings such as printk messages because that
breaks the ability to grep for them."

While at it, fix the alignment of the arguments in the sentence.

Note: this introduce a checkpatch CHECK: line length of 123 exceeds 100
columns, as the line now is:

vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)",

But now the string is grep-able and the whole function call more
clear.

Reported by checkpatch.pl

[1] Documentation/process/coding-style.rst

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


# 6ab92ea6 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: cleanup lines that end with '(' or '['

Fix lines that end with '(' or '['.

Reported by checkpatch.pl

Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20211024212524.370078-8-gascoar@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>


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

staging: vchiq_core: 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/20211024212524.370078-3-gascoar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1e1093ff 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: cleanup blank lines

Remove unnecessary blank lines.

Reported by checkpatch.pl

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


# e4c1935e 11-Sep-2021 Ojaswin Mujoo <ojaswin98@gmail.com>

staging: vchiq: Replace function typedefs with equivalent declaration

Replace function typedefs with the equivalent declarations to better
align with the linux kenel coding style

The following typedefs were changed:
* VCHIQ_CONNECTED_CALLBACK_T
* vchiq_userdata_term

Signed-off-by: Ojaswin Mujoo <ojaswin98@gmail.com>
Link: https://lore.kernel.org/r/a8e4e0457b5fcc88c7f297f9d669dfb7e7d91ed5.1631366317.git.ojaswin98@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7aaabc37 18-Jul-2021 Len Baker <len.baker@gmx.com>

staging/vc04_services: Remove all strcpy() uses in favor of strscpy()

strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy().

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210718131217.3806-1-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: introduce handle_poll

The function slot_handler_func() has very deep indentations. Moving the
poll handling into separate function could improve the readability.
Use the return value to keep the poll_needed handling at the same place.

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


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

staging: vchiq_core: store message id in local variable

Some queue_message() calls are still rather complex to read. So store
the message ids in a local variable in those cases.

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


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

staging: vchiq_core: reduce indentation in parse_open

The function parse_open() already has bail out sections like fail_open.
So use a goto for the other error cases like payload size is too small
and listening service cannot be found. This avoids two indentation levels.

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


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

staging: vchiq_core: introduce process_free_data_message

This moves the special handling for data messages from process_free_queue()
into a new function. After this process_free_queue() has less extreme
indentation and should be easier to read.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-13-git-send-email-stefan.wahren@i2se.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>


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

staging: vchiq_core: simplify WARN_ON conditions

During a recent review Dan Carpenter noticed a double negation in a WARN_ON.
But a quick search revealed more unnecessary complex WARN_ON conditions.
This change should simplify them.

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


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

staging: vchiq_core: introduce message specific make macros

VCHIQ_MAKE_MSG isn't optimal because a lot of message types doesn't need
a parameter. So better define a macro for every message type which is used.

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


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

staging: vchiq_core: use define for message type shift

Make it clear and use a define for shifting the message type.

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


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

staging: vchiq_core: avoid precedence issues

Add () around macro argument to avoid precedence issues

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


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

staging: vchiq_core: put spaces around operators

This fixes the checkpatch issues regarding missing spaces around operators.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-7-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>


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

staging: vchiq_core: get the rid of IS_POW2

The macro IS_POW2 is only used to ensure some size are powers of 2.
Better use BUILD_BUG_ON_NOT_POWER_OF_2 for this. Since this must be done
in a function, merge all these checks in a new function.

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


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

staging: vchiq_core: move internals to C source

There is no need to export those definitions, so keep them in the
source file.

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


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

staging: vchiq_core: fix logic in poll_services_of_group

Commit "staging: vchiq_core: avoid indention in poll_services_of_group"
tries to reduce the indention, but the parts regarding the third if statement
breaks the logic. So restore them and prevent vchiq_test from hanging during
the ping test.

Fixes: 2f440843a7d4 ("staging: vchiq_core: avoid indention in poll_services_of_group")
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1622735405-9980-2-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: introduce defines for retry_poll

Use descriptive defines instead of a number with a comment.

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


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

staging: vchiq_core: introduce defines for close_recvd

Use descriptive defines instead of a number with a comment.

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


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

staging: vchiq_core: introduce parse_message

The function parse_rx_slots is very longer. So move at least the message
parsing into a separate function to improve readability. In good case
the function returns the message payload length which is necessary to
move to the next message.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-19-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>


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

staging: vchiq_core: fix comment in vchiq_shutdown_internal

The comment seems to be copied from vchiq_connect_internal(). So change
it to match the actual behavior.

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


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

staging: vchiq_core: reduce indention in release_service_messages

It's possible to convert the if statement into a continue early and
save an indention level.

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


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

staging: vchiq_core: avoid indention in poll_services_of_group

By converting the first and the third if statement into continue early
the function poll_services_of_group() can avoid 2 indention levels.

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


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

staging: vchiq_core: introduce poll_services_of_group

The function poll_services() has too many indention levels. So keep only
the group iteration loop and move the rest into a new function
poll_services_of_group().

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-7-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>


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

staging: vchiq_core: separate postfix increment

Postfix increment within a complexer statement doesn't improve readability.
So separate them.

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


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

staging: vchiq_core: drop unnecessary release_count

There is no benefit of the variable release_count, so drop it.

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


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

staging: vchiq_core: fix return type of vchiq_init_state

Recent commit "staging: vchiq_core: drop vchiq_status from vchiq_init_state"
missed to change the return type in the definition. Let's fix this now.

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


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

staging: vchiq_core: drop vchiq_status from vchiq_init_state

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

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-12-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>


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

staging: vchiq_2835_arm: drop enum vchiq_status

Replace the custom set of return values with proper Linux error codes.
As a result we need to initialize vchiq_status in vchiq_init_state.

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-8-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: Drop unnecessary check in notify_bulks

There is no modification to the vchiq_status before the first if, so drop
this unnecessary check.

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-6-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: introduce get_bulk_reason

Nesting multiple ternary operators over multiple lines isn't easy to
read. Move this logic 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/1619347863-16080-5-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: return early in do_abort_bulks

Avoid the multiline statement for notify_bulks by return early in
error case.

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-4-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: break early in vchiq_close_service_internal

The logic in VCHIQ_SRVSTATE_OPEN* is unnecessary complex. Handle the error
case of queue_message() first makes it easier to read.

Btw we get the rid of the checkpatch warning:
WARNING: else is not generally useful after a break or return

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-3-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f2f560e1 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: split exit conditions

Some exit conditions are rather complex. So better split them up.

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


# fa80183c 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: fix if alignments

This fixes the alignment of some if statements.

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


# a8def503 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: introduce SLOT_QUEUE_INDEX_FROM_POS_MASKED

Define a macro which already masked the result of SLOT_QUEUE_INDEX_FROM_POS.

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


# 7a4da84c 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: use BITSET_WORD macro

Use this macro to make the index retrieval less opaque.

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


# 0e345d97 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: improve readability of request_poll

Storing the index for poll services in a local var will increase the
readability of the second loop. Also we get the rid off the checkpatch
issue about the line ending with a square bracket.

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


# 63276d45 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: introduce service skip

In case there is no service pointer provided, we can skip these polling.
Use a goto to reduce the indentation, which is necessary for the following
patches. Btw fix the brace alignment of the loops.

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


# b3582ed4 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Exit early in 2 functions

Exit early allow us to reduce the indention in vchiq_open_service_internal()
and vchiq_set_service_option(). Btw we can avoid the multi-line assignments
of quota.

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


# 32129ec0 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Get the rid off curly braces around cases

Additional curly braces around cases are a bit harder to read. So
change the scope of service quota to get the rid off those braces.

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


# e04e9008 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Shorten var name for service quota

Readibility and following clean-ups will benefit from the shorter name.

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


# acdb1d90 11-Apr-2021 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Simplify vchiq_send_remote_use*

There is no need for variable status. So drop it and improve readability.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1618164700-21150-2-git-send-email-stefan.wahren@i2se.com
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>


# 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>


# 9038c6ac 27-Jul-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

staging: vc04_services: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200727183734.GA28824@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1e5f7325 13-Jul-2020 Baidyanath Kundu <kundubaidya99@gmail.com>

Staging: vc04_services: Fix unsigned int warnings

This patch fixes the checkpatch.pl warning:

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Baidyanath Kundu <kundubaidya99@gmail.com>
Link: https://lore.kernel.org/r/20200713143653.32332-1-kundubaidya99@gmail.com
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>


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

staging: vchi: Move vchi_queue_kernel_message() into vchiq

We can't really merge it with vchiq_queue_message() as it has internal
users that will not benefit from the retry mechanism
vchiq_queue_kernel_message() uses. So, for the sake of getting rid of
vchi, move it into vchiq.

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


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

staging: vchiq: Export vchiq_get_service_userdata()

This is for service's callbacks to get their private data.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-27-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>


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

staging: vchiq: Move message queue into struct vchiq_service

This has historically been handled by vchi, but there is no reason why
this couldn't be handled directly in vchiq.

The patch tries to avoid altering any behavior, with the exception of
the msg_queue size, which is now fixed to VCHIQ_MAX_SLOTS (it was set to
VCHIQ_MAX_SLOTS / 2). This is done to match vchiq's user_service message
queue, which could be merged with this one in the future.

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


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

staging: vchiq: Introduce vchiq_validate_params()

When adding a new service validate the configuration parameters
provided, and remove unnecessary checks in vchi, now that we have
validated service's config.

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


# 9666e8f8 25-Jun-2020 Garrit Franke <garritfranke@gmail.com>

trivial: staging: vc04_services: replace bitshift with BIT macro

Cleans up some bitshifts by using the BIT macro.

Signed-off-by: Garrit Franke <garritfranke@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200625093237.2640-1-garritfranke@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 36cf583e 27-May-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: Get rid of VCHIQ_SERVICE_OPENEND callback reason

Nobody uses it and it's routinely discarded in vchi.

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


# 05147c15 27-May-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: move vchiq_release_message() into vchiq

For messages with a reason different from VCHIQ_MESSAGE_AVAILABLE the
responsibility for releasing them is kept in vchi, in other words,
services don't need to worry about it. As we're trying to unify vchi and
vchiq, move the release code into vchiq.

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


# a224f284 27-May-2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: Move copy callback handling into vchiq

All vchi users use the kernel variant of the copy callback. The only
user for the user space variant of the copy callback is in the ioctl
implementation. So move all this copying logic into vchiq, and expose a
new function that explicitly passes kernel messages.

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


# e2327678 13-Feb-2020 Marcelo Diop-Gonzalez <marcgonzalez@google.com>

staging: vc04_services: Fix wrong early return in next_service_by_instance()

If kref_get_unless_zero() fails, we should keep looking for the
next service, since the callers of this function expect that a NULL
return value means there are no more.

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/20200213194001.130110-1-marcgonzalez@google.com
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>


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

staging: vc04_services: fix indentation alignment in a few places

This fixes some checkpatch warnings about incorrect indentation levels

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


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

staging: vc04_services: remove unneeded parentheses

there are extra parentheses around many conditional statements
that make things a little harder to read

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


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

staging: vc04_services: remove unused function

vchiq_get_service_fourcc() doesn't seem to be used anywhere

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/ed8b0034e316b2a81b621e9fca43f8368334b191.1581532523.git.marcgonzalez@google.com
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>


# 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>


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

staging: vc04_services: Get rid of vchiq_platform_handle_timeout()

The function does nothing.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-11-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>


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

staging: vc04_services: Get rid of vchiq_platform_paused/resumed()

vchiq_platform_paused() and vchiq_platform_resumed() do nothing.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200131103836.14312-8-nsaenzjulienne@suse.de
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>


# 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>


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

staging: vc04_services: Rename callback VCHIQ_USERDATA_TERM_T to vchiq_userdata_term

Renames callback VCHIQ_USERDATA_TERM_T to vchiq_userdata_term to match kernel code style.

Signed-off-by: Jamal Shareef <jamal.k.shareef@gmail.com>
Link: https://lore.kernel.org/r/478914a1e756f78c3277acb3852c1ccdcb2d5750.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>


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

staging: vc04_services: Replace VCHIQ_SERVICE_OPTION_T enum typedef with enum vchiq_service_option

Replaces VCHIQ_SERVICE_OPTION_T enum typedef with enum vchiq_service_option 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/f8e9c9170ed008043186dda99d40b60fb16c1d85.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>


# 82d20bc5 08-Oct-2019 Matteo Croce <mcroce@redhat.com>

staging: vchiq: don't print pointless kernel address

Since commit ad67b74d2469d9b8 ("printk: hash addresses printed with %p"),
an obfuscated kernel pointer is printed at boot:

vchiq: vchiq_init_state: slot_zero = (____ptrval____)

Remove the the print completely, as it's useless without the address.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Link: https://lore.kernel.org/r/20191008123346.3931-1-mcroce@redhat.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>


# 63350bdb 11-Sep-2019 Rohit Sarkar <rohitsarkar5398@gmail.com>

staging: vhciq_core: replace snprintf with scnprintf

When the number of bytes to be printed exceeds the limit snprintf
returns the number of bytes that would have been printed (if there was
no truncation). This might cause issues, hence use scnprintf which
returns the actual number of bytes printed to buffer always

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190911135112.GA5569@SARKAR
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vc04_services: Remove vchiq_send_remote_release()

Remove unused function vchiq_send_remote_release.
Issue found with Coccinelle.

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


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

staging: vc04_services: Remove vchiq_resume_internal()

Remove unused function vchiq_resume_internal.
Issue found with Coccinelle.

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


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

staging: vc04_services: Remove vchiq_pause_internal()

Remove unused function vchiq_pause_internal.
Issue found with Coccinelle.

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


# 7bce3551 06-Jun-2019 Maxime Desroches <desroches.maxime@gmail.com>

Staging: vc04_services : vchiq_core: Fix a brace issue

Remove braces in a single line if statement in the vchiq_core.c file

Signed-off-by: Maxime Desroches <desroches.maxime@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>


# 77cf3f5d 09-May-2019 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

staging: vchiq: make wait events interruptible

The killable version of wait_event() 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. Wait events in VCHIQ doesn't
fit this criteria, as it's mainly used as an interface to V4L2 and ALSA
devices.

Fixes: 852b2876a8a8 ("staging: vchiq: rework remove_event handling")
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>


# a5112277 18-Apr-2019 Nicholas Mc Guire <hofrat@osadl.org>

staging: vc04_services: handle kzalloc failure

The kzalloc here was being used without checking the return - if the
kzalloc fails return VCHIQ_ERROR. The call-site of
vchiq_platform_init_state() vchiq_init_state() was not responding
to an allocation failure so checks for != VCHIQ_SUCCESS
and pass VCHIQ_ERROR up to vchiq_platform_init() which then
will fail with -EINVAL.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reported-by: kbuild test robot <lkp@intel.com>
Acked-By: Stefan Wahren <stefan.wahren@i2se.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>


# 07f9ef04 01-Apr-2019 Sanjana Sanikommu <sanjana99reddy99@gmail.com>

staging: vc04_services: Remove unnecessary casts.

Explicit type casting of variable, with same type as
that of variable, is not required.
Issue found using coccinelle.

Signed-off-by: Sanjana Sanikommu <sanjana99reddy99@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a50c4c9a 11-Jan-2019 Phil Elwell <phil@raspberrypi.org>

staging: vchiq: Fix local event signalling

Prior to the recent event reworking (see Fixes), thread synchronisation
was implemented using completions, the worker thread being woken with
a call to complete(). The replacement uses waitqueues, which are more
like condition variables in that the waiting thread is only woken if
the condition is true.

When the VPU signals the ARM, it first sets the event's fired flag to
indicate which event is being signalled, but the places in the
ARM-side code where the worker thread is being woken -
remote_event_signal_local via request_poll - did not do so as it
wasn't previously necessary, and since the armed flag was being
cleared this lead to a deadlock.

Fixes: 852b2876a8a8 ("staging: vchiq: rework remove_event handling")
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>


# 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>


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

staging: vc04_services: Remove VCHIQ_SLOT_ZERO_T

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>


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

staging: vc04_services: Remove VCHIQ_SLOT_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>


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

staging: vc04_services: Remove VCHIQ_SLOT_INFO_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>


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

staging: vc04_services: Remove VCHIQ_SHARED_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>


# 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>


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

staging: vc04_services: Remove VCHIQ_SERVICE_QUOTA_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>


# 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>


# 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>


# 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>


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

staging: vc04_services: Remove VCHIQ_BULK_QUEUE_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>


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

staging: vc04_services: Remove REMOTE_EVENT_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>


# 852b2876 10-Dec-2018 Arnd Bergmann <arnd@arndb.de>

staging: vchiq: rework remove_event handling

I had started the removal of semaphores in this driver without knowing
that Nicolas Saenz Julienne also worked on this. In case of the "remote
event" infrastructure, my solution seemed significantly better, so I'm
proposing this as a change on top.

The problem with using either semaphores or completions here is that
it's an overly complex way of waking up a thread, and it looks like the
'count' of the semaphore can easily get out of sync, even though I found
it hard to come up with a specific example.

Changing it to a 'wait_queue_head_t' instead of a completion simplifies
this by letting us wait directly on the 'event->fired' variable that is
set by the videocore.

Another simplification is passing the wait queue directly into the helper
functions instead of going through the fragile logic of recording the
offset inside of a structure as part of a shared memory variable. This
also avoids one uncached memory read and should be faster.

Note that I'm changing it back to 'killable' after the previous patch
changed 'killable' to 'interruptible', apparently based on a misunderstanding
of the subtle down_interruptible() macro override in vchiq_killable.h.

Fixes: f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: fix logic redundancy in parse_open

We update sync to reflect that the firmware version is compatible with
that option. We don't need to check both of them again further down the
code.

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>


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

staging: vchiq_core: don't add a wmb() before remote_event_signal()

It's the first thing remote_event_signal() does.

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>


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

staging: vchiq_core: do not initialize semaphores twice

vchiq_init_state() initialises a series of semaphores to then call
remote_event_create() on the same semaphores, which initializes them
again. We get rid of the second initialization.

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>


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

staging: vchiq_core: remove unnecessary safety checks in vchiq_init_state

vchiq_init_state() checks the initial contents of slot_zero are correct.
These are set in vchiq_init_slots(), using the same hard-coded defaults
as the checks. Both functions are called sequentially and Video Core
isn't yet aware of the slot's address. There is no way the contents of
slot_zero changed in between functions, making the checks useless.

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>


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

staging: vchiq-core: get rid of is_master distinction

VCHIQ bulk transfers are what most people call DMA transfers. The CPU
sends a list of physical addresses to the VideoCore which then access
the memory directly without the need for CPU interaction. With this
setup we call the CPU the "slave" and the VideoCore the "master".

There seems to be an option to switch roles in vchiq. Which nobody is
using nor is properly implemented. So we get rid of the "is_master == 1"
option, and all the related code.

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>


# 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>


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

staging: vchiq_core: Free kthreads in error case

We need to free the kthreads in error case before leaving
vchiq_init_state() otherwise we leak resources.

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


# 8dd60f7d 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Move all wake-ups to one point

Move all calls of wake_up_process to one point, whichs makes the
following implementation of clean-up code easier.

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


# 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>


# 6dca544e 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Remove stackhog in process_free_queue

This removes the stackhog in process_free_queue by allocating the
necessary memory within the recycle thread main function instead
of the stack.

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


# 8113b89f 31-Mar-2018 Stefan Wahren <stefan.wahren@i2se.com>

staging: vchiq_core: Fix missing semaphore release in error case

The bail out branch in case of a invalid tx_pos missed a semaphore
release. Dan Carpenter found this with a static checker.

Fixes: d1eab9dec610 ("staging: vchiq_core: Bail out in case of invalid tx_pos")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0badff9a 17-Dec-2017 Tara Null <tn@fastmail.net>

staging: vchiq_arm: fix open brace placement errors

Fix checkpatch errors relating to open brace placement for enums and
function definitions.

Signed-off-by: Tara Null <tn@fastmail.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 95f539b6 12-Oct-2017 Gustavo A. R. Silva <garsilva@embeddedor.com>

staging: vc04_services: vchiq_core: mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-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>


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

staging: vchiq_core: Replace remaining BUG_ON with WARN_ON

This replaces all remaining BUG_ON with WARN_ON. So in case of
a VCHIQ bug the system is still usable.

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


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

staging: vchiq_core: Bail out in case of invalid tx_pos

Properly handle the error case in case of an invalid tx_pos.

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


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

staging: vchiq_core: Don't BUG if process is unexpected

Bail out properly if the process index doesn't match the remote insert.
We also drop the BUG in case the process index is at local insert,
so we can trigger the WARN_ON again some steps later.

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


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

staging: vchiq_core: Bail out if ref_count is unexpected

If the ref counter of service has an unexpected value then we better
bail out.

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


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

staging: vchiq_core: Bail out if service is NULL

In the unlikely case that service is NULL we should bail out instead
of calling BUG_ON(). The other BUG_ON calls will be fixed in separate
patches.

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


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

staging: vchiq_core: Don't BUG if sending RESUME fails

VCHIQ suspend and resume isn't implemented, but even it was
there is no need to call BUG().

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


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

staging: vchiq_core: Bailout if VCHIQ state is already initialized

In case VCHIQ state is already initialized we need to bailout
in order to aovid a memory leak.

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


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

staging: vchiq_core: Simplify VCHIQ init

Since the ARM side of VCHIQ support only 1 state, we could simplify
the init code. This makes it possible to avoid BUG_ON and a theoretical
overflow of id.

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


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

staging: vchiq_core: Use return value of mutex_lock_killable directly

Instead of saving the return value of mutex_lock_killable in a
local variable we could use the value directly.

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


# 35060a22 20-Mar-2017 Colin Ian King <colin.king@canonical.com>

staging: vc04_services: fix NULL pointer dereference on pointer 'service'

Currently, if pservice is null then service is set to NULL and immediately
afterwards service is dereferenced causing a null pointer dereference. Fix
this by bailing out early of the function with a null return.

Detected by CoverityScan, CID#1419681 ("Explicit null dereferenced")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 001943e8e 04-Mar-2017 Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>

staging: vc04_services: Refactor conditionals

Refactor conditionals to reduce one level of indentation and improve
code readability.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 41831482 04-Mar-2017 Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>

staging: vc04_services: Remove error message on kmalloc() failure

Remove 'Out of memory' message because kmalloc already prints a message
in case of error.

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 372499b5 28-Feb-2017 Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>

staging: vc04_services: Removed unnecessary variable

Removed unnecessary variable and used instead the parameter
that was already defined

Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
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>


# 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>


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

staging: vchiq_core: Reduce the memdump size

This reduces the memory dump size to a sufficient value of 16 bytes.

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>


# 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>


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

staging: vchiq_core: make local spinlock static

The quota_spinlock is only local. So make it static.

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


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

staging: vchiq_core: remove unused variable type

This variable is assigned a value, but never used. So remove it.

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


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

staging: vc04_services: make local functions static

The functions vchiq_dump_shared_state() and vchiq_is_connected() are only
used locally. So make them static.

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


# c322160a 09-Dec-2016 Mike Kofron <mpkofron@gmail.com>

staging: vc04_services: Fix NULL ptr sparse warnings

In calls to queue_message() in vchiq_core.c, the "void *context"
parameter is set as 0 rather than NULL. This patch amends each call to
use the proper NULL pointer. The following sparse warnings are fixed:

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:1623:23: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:1976:47: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:2075:47: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:2095:47: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:2907:39: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:2929:39: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:3059:72: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:3860:31: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:3870:31: warning: Using plain integer as NULL pointer
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:3880:31: warning: Using plain integer as NULL pointer

Signed-off-by: Mike Kofron <mpkofron@gmail.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>


# 48157007 07-Nov-2016 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: vc04_services: fix up some printk warnings

Some more printk warnings snuck in recently, no one seems to be building
this on 64bit machines...

Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Lee Jones <lee@kernel.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Michael Zoran <mzoran@crowfest.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


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

staging: vchiq_core: fix format strings in vchiq_dump_service_state

The member localport and remoteport are unsigned. So fix the format
string accordingly.

The issue has been found by Cppcheck.

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


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

staging: vchiq_core: fix service dereference in unlock_service

The service state is dereferenced before BUG_ON and outside of the
spin lock. So in order to avoid possible NULL pointer dereferences or
races move the whole scope at a safer place.

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>


# 2ea15699 01-Nov-2016 Michael Zoran <mzoran@crowfest.net>

staging: vc04_services: parse_rx_slots() - Fix compiler warning

vc04_services contains a debug logging mechanism. The log is
maintained in a shared memory area between the kernel and the
firmware. Changing the sizes of the data in this area would
require a firmware change which is distributed independently
from the kernel binary.

One of the items logged is the address of received messages.
This address is a pointer, but the debugging slot used to store
the information is a 32 bit integer.

Luckily, this value is never interpreted by anything other
then debug tools and it is expected that a human debugging
the kernel interpret it.

This change adds a cast to long before the original cast
to int to silence the warning.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
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>


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

staging: vc04_services: fix CamelCase

This fixes the CamelCase of some variables.

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>


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

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

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>


# f9bee6dd 19-Oct-2016 Michael Zoran <mzoran@crowfest.net>

staging: vc04_services: Add casts to remove warnings in vchiq_core.c

When compiling vchiq_core.c for 64 bit, the compiler
emits a few warnings that are not actual issues. This
change adds a few casts to remove the extra unnecessary
warnings.

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


# 24a4262a 19-Oct-2016 Michael Zoran <mzoran@crowfest.net>

staging: vc04_services: Convert pointers in shared state to offsets

The arm processor core and the GPU have a shared data structure.
This structure contains pointers to base linux kernel objects such as
events. The size of the pointer changes between 32 bit and 64 bit,
so it is necessary to convert these pointers to offsets from the
beginning of the state structure.

Luckly, the GPU does not interpret these pointers/offsets,
but this change is necessary to keep the structure the same since
the GPU code is outside the scope of the linux kernel
and can't be easily changed.

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


# 35b7ebda 19-Oct-2016 Michael Zoran <mzoran@crowfest.net>

staging: vc04_services: Convert dsb() to dsb(sy)

The dsb() macro for 32 arm compiles to dsb(sy) in the binary file.
This macro is no longer supported on arm64, so instead use dsb(sy)
which is completely binary compatible.

Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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>


# 43ff7f53 06-Oct-2016 Bhumika Goyal <bhumirks@gmail.com>

Staging: vc04_services: vchiq_arm: Remove unused function remote_event_destroy

Remove function remote_event_destroy as it is not used anywhere in the
kernel. Function detected using Coccinelle but changes done by hand.
Script:

@initialize:python@
@@
def display(name,p):
print(name,p[0].file)

@r1@
identifier func;
type T;
position p;
@@
static T func@p(...)
{
...
}

@r@
identifier r1.func;
@@
func

@script:python depends on !r@
func << r1.func;
p << r1.p;
@@
display(func,p)

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
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>