History log of /linux-master/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
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>


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


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


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


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

staging: vc04_services: Drop VCHIQ_LOG_PREFIX macro

The macro is not used anymore, so drop it.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231024114428.443528-8-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>


# 2529ca21 20-Jan-2023 Umang Jain <umang.jain@ideasonboard.com>

staging: vc04_services: interface: Drop include Makefile directive

Drop the include directive. They can break the build, when one only
wants to build a subdirectory. Replace with "../" for the includes,
in the interface/ files instead.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20230120201104.606876-6-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>


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


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


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


# 63ab9060 16-May-2022 Gaston Gonzalez <gascoar@gmail.com>

staging: vc04_services: remove unused macro

BITSET_CLR is not used. Remove the define.

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


# b0e160f0 22-Nov-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: remove superfluous static_assert statement

After removing the BITSET_T typedef in commit d8a364820e01 ("staging:
vchiq_core: get rid of typedef") the static_assert statement becomes superfluous
as now we are checking if the size of the u32 type is 4 bytes. Hence, just
remove the static_assert statement.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
Link: https://lore.kernel.org/r/20211122130926.342128-1-gascoar@gmail.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>


# 9393b3bb 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core: drop extern prefix in function declarations

Remove unnecessary extern prefix in function declarations.

While at it, remove a now outdated comment and realign the function
declarations in order to improve readability.

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


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

staging: vchiq_core.h: use preferred kernel types

Change types from uint32_t and uint64_t to the preferred ones u32 and
u64.

Reported by checkpatch.pl, with the exception of the one in function
vchiq_log_dump_mem().

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


# 9dcc5f1c 24-Oct-2021 Gaston Gonzalez <gascoar@gmail.com>

staging: vchiq_core.h: fix CamelCase in function declaration

Renaming function declaration to avoid CamelCase use.

As this was already fixed in the function definition in commit
801b1aa002d3 ("staging: vc04_services: fix CamelCase"), the current
change make the names of the variables in the function definition and
declartion match.

Reported by checkpatch.pl

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


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

staging: vchiq_arm: tidy up service function naming

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

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


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

staging: vchiq_core: get the rid of vchiq_static_assert

Use static_assert from the kernel instead of opencode it.

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


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


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


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


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

staging: vchiq_arm: drop enum vchiq_status from vchiq_*_internal

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

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

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

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


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


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


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

staging: vchiq: Move vchiq.h into include directory

To make the separation clear between vchiq's header files and vchiq.h,
which is to be used by services and is the 'public' API, move it into a
dedicated includes directory.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

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


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

staging: vchiq: Move defines into core header

Those are only used in the core vchiq code, while present in vchiq's
'public' API header. Move them into the right place.

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


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

staging: vchiq: Move conditional barrier definition into vchiq_core.h

The barrier is only used by core code. So keep the barrier definition in
the core header.

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


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

staging: vchiq: Move definitions only used by core into core header

vchiq_if.h is used by service consumers and only the exported API should
be present. Move the rest of definitions, which were not exported by the
way, to vchiq_core.h where they belong.

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


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


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


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


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


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

staging: vc04_services: Replace VCHIQ_PLATFORM_STATE_T typedef with struct opaque_platform_state

Replace VCHIQ_PLATFORM_STATE_T typedef with struct opaque_platform_state
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/ed1a877637a53881ed65dc232da04dc40fbd9fc3.1572994235.git.jamal.k.shareef@gmail.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>


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


# 388fa43d 13-Oct-2019 Wambui Karuga <wambui.karugax@gmail.com>

staging: vc04_services: use DIV_ROUND_UP helper macro

Replace open-coded division calculation with the DIV_ROUND_UP
helper macro for better readability.
Issue found using coccinelle:
@@
expression n,d;
@@
(
- ((n + d - 1) / d)
+ DIV_ROUND_UP(n,d)
|
- ((n + (d - 1)) / d)
+ DIV_ROUND_UP(n,d)
)

Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Link: https://lore.kernel.org/r/20191013184750.32766-1-wambui.karugax@gmail.com
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>


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


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


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

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


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


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


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


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

staging: vchiq_core: remove BITSET_ZERO

Hiding memset behind a macro isn't the best, because it relies on that
the parameter is not a pointer. Luckily all user has been removed, so
we can remove BITSET_ZERO too.

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


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


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


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


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