Commit Graph

40 Commits

Author SHA1 Message Date
Alex Van Damme
237454b288 Apex performance ioctl
Change-Id: Id3ae759f748b3f8c6f6a5320a5088c43fad0e812
2018-07-23 16:11:16 -07:00
Alex Van Damme
d737e80b17 Enable Apex on ARM64, fix compile issue
- Change from X86 only to X86 or ARM64 in Kconfig
- refcount_read doesn't exist in 4.11, so use atomic_read instead. This
is the same call that refcount_read in 4.12+ would make.

Change-Id: I48c97dd8c14136dcccaa8378b3a931a7872e1289
2018-07-23 16:11:14 -07:00
Todd Poynor
883c9a9fa9 staging: gasket: drop gasket_cdev_get_info, use container_of
Remove gasket_cdev_get_info(), use container_of() directly instead,
drop unnecessary NULL checks.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
e7cddbb9bd staging: gasket: bail out of reset sequence on device callback error
If device reset callback returns an error, error out at the gasket
level.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
d7ea69e8a4 staging: gasket: gasket_wait_with_reschedule use 32 bits of retry count
Don't need a 64-bit retry counter.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
bb0f4d4a3f staging: gasket: gasket_wait_with_reschedule simplify logic
gasket_wait_with_reschedule() is a little more clear if we just return
directly when the waited-for condition is hit.  This also allows the
following condition check to be removed and identation of the
conditionally-executed code to be reduced.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
11eb4eb149 staging: gasket: gasket_wait_with_reschedule use msleep
Replace schedule_timeout() call with msleep() for simplicity.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
c850f2c77e staging: gasket: fix gasket_wait_with_reschedule timeout return code
Return -ETIMEDOUT, not -EINVAL, on timeout, including callers.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
dd69b60312 staging: gasket: convert gasket_mmap_has_permissions to bool return
gasket_mmap_has_permissions() should return a boolean value.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
04f5568b57 staging: gasket: Remove stale pointers on error allocating attr array
If gasket_sysfs_create_mapping() hits errors allocating the attribute
array, remove stale pointers to device info from the mapping object.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:22 -07:00
Todd Poynor
a7546cc34c staging: gasket: Return EBUSY on mapping create when already in use
gasket_sysfs_create_mapping() return EBUSY if sysfs mapping already in
use, as a more appropriate error code than the current return of EINVAL,
which would indicate invalid parameters.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Todd Poynor
d57203b516 staging: gasket: hold mutex on gasket driver unregistration
Take the global mutex on driver unregistration updates for proper
ordering of updates and consistent access procedures.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Todd Poynor
dc5522d1dc staging: gasket: remove driver registration on class creation failure
If class_create() fails, remove the gasket driver from the global
registration table.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Todd Poynor
1563830458 staging: gasket: whitespace fix in gasket_page_table_init
Tab replaced with space.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Todd Poynor
cc9c05a0c8 staging: gasket: fix typo in gasket_core.h comments
Grammar fixup in gasket_core.h comments describing struct
gasket_interrupt_desc.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Todd Poynor
ef0319c4c4 staging: gasket: fix typo in apex_enter_reset
Fix typo in log message.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
39bdbb8951 staging: gasket: remove gasket_wait_sync()
This function is not called anywhere, so just remove it.

Also, as an added benifit, Arnd points out that it doesn't even work
properly:
	This code won't work correct during leap seconds or a concurrent
	settimeofday() call, and it probably doesn't do what the author intended
	even for the normal case, as it passes a timeout in nanoseconds but
	reads the time using a jiffies-granularity accessor.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
1ba805dba8 staging: gasket: sysfs: remove legacy_device field
This field is only ever checked, never actually set, and looks to be
left-over from some old interface of some sort.  As it's not being used
at all here, and is just adding to the complexity, delete it.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
1180baae6b staging: gasket: remove gasket_sysfs_register_show()
In an attempt to start to clean up the monstrosity of the sysfs abuse in
the gasket driver, let's remove code that is not used at all.  The
gasket_sysfs_register_show() function is never used, so delete it.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
e5fd02987e staging: gasket: remove GASKET_SYSFS_REG()
In an attempt to start to clean up the monstrosity of the sysfs abuse in
the gasket driver, let's remove code that is not used at all.  The
GASKET_SYSFS_REG() macro is never used, so delete it.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
8ab2804fad staging: gasket: remove gasket_page_table_num_extended_entries()
It is exported, yet no one calls it so just remove the dead code.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
2343ad2d61 staging: gasket: remove gasket_interrupt_get_msix_entries()
No one calls it, it is claimed to be "legacy", whatever that means, so
just remove the dead code.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
97ca040342 staging: gasket: remove gasket_interrupt_trigger_eventfd()
No one calls it, so just remove the dead code.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
e7d963fa61 staging: gasket: remove gasket_interrupt_get_eventfd_ctxs()
It is exported, yet no one calls it so just remove the dead code.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:21 -07:00
Greg Kroah-Hartman
5335078357 staging: gasket: remove pointless gasket_interrupt_pause()
gasket_interrupt_pause() does nothing, and no one calls it, so remove it
as it is dead-weight.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Felix Siegel
b27f5c2e98 staging: gasket: Use __func__ instead of hardcoded string - Style
Changed logging statements to use %s and __func__ instead of hard coding
the function name in a string.

Signed-off-by: Felix Siegel <felix.siegel@posteo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Felix Siegel
dbd32599d2 staging: gasket: remove "function entered" log messages
Remove log messages that solely print the function's name
everytime it is called.

Signed-off-by: Felix Siegel <felix.siegel@posteo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Felix Siegel
c2b4e1cb8d staging: gasket: fix multi line comments style
This patch fixes checkpatch.pl warnings:

WARNING: Block comments should align the * on each line

Signed-off-by: Felix Siegel <felix.siegel@posteo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Felix Siegel
4ec0581576 staging: gasket: Move open-curly brace to match kernel code style
Move open open-curly brace to the next line following function
definition to match the kernel's coding style

Signed-off-by: Felix Siegel <felix.siegel@posteo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Greg Kroah-Hartman
57bc89e0ef staging: gasket: remove TODO item about SPDX usage
Now that the files are all properly tagged with SPDX lines, and the
boilerplate license text is gone, remove the TODO item.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Greg Kroah-Hartman
653a5901f5 staging: gasket: remove redundant license information
Now that the SPDX tag is in all gasket files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL 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 GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Greg Kroah-Hartman
8ff3da62cb staging: gasket: add SPDX identifiers to all files.
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging gasket files to have a proper SPDX
identifier, based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

Cc: Rob Springer <rspringer@google.com>
Cc: John Joseph <jnjoseph@google.com>
Cc: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Ivan Bornyakov
cc8a3327da staging: gasket: fix plain integer as NULL pointer warning
Trivial fix to remove sparse warnings:

  drivers/staging/gasket/gasket_page_table.c:884:40: warning: Using plain integer as NULL pointer
  drivers/staging/gasket/gasket_page_table.c:1743:57: warning: Using plain integer as NULL pointer
  drivers/staging/gasket/gasket_page_table.c:1768:57: warning: Using plain integer as NULL pointer

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Colin Ian King
dffd7b4359 staging: gasket: remove redundant pointer bar_data
Pointer bar_data is being assigned but is never used hence it is redundant
and can be removed.

Cleans up clang warning:
warning: variable 'bar_data' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Todd Poynor
392480bf3f drivers/staging/gasket: Use refcount_read()
Use the refcount_read accessor function, avoid reaching into refcount
and atomic struct fields.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Dan Carpenter
14da0230d8 Staging: Gasket: shift wrapping bug in gasket_read_modify_write_64()
This function only has one caller so mask_width is 1 and mask_shift is
32.  Shifting an int by 32 bits is undefined, but I guess on GCC it
wraps to 0x1?  Anyway it's supposed to be 0x100000000.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:20 -07:00
Dan Carpenter
85a2ab89f4 Staging: Gasket: fix a couple off by one bugs
The > should be >= or we end up writing one element beyond the end of
the interrupt_data->eventfd_ctxs[] array.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:19 -07:00
Dan Carpenter
c8bfb85d08 Staging: Gasket: uninitialized return in gasket_mmap()
We forgot to set the error code on this error path so ret can be
uninitialized.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:19 -07:00
Kees Cook
e1c8e7a804 drivers/staging/gasket: Use 2-factor allocator calls
As already done treewide, switch from open-coded multiplication to using
2-factor allocator helpers.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:19 -07:00
Simon Que
0305c1f77f drivers/staging: Gasket driver framework + Apex driver
The Gasket (Google ASIC Software, Kernel Extensions, and Tools) kernel
framework is a generic, flexible system that supports thin kernel
drivers. Gasket kernel drivers are expected to handle opening and
closing devices, mmap'ing BAR space as requested, a small selection of
ioctls, and handling page table translation (covered below). Any other
functions should be handled by userspace code.

The Gasket common module is not enough to run a device. In order to
customize the Gasket code for a given piece of hardware, a device
specific module must be created. At a minimum, this module must define a
struct gasket_driver_desc containing the device-specific data for use by
the framework; in addition, the module must declare an __init function
that calls gasket_register_device with the module's gasket_driver_desc
struct. Finally, the driver must define an exit function that calls
gasket_unregister_device with the module's gasket_driver_desc struct.

One of the core assumptions of the Gasket framework is that precisely
one process is allowed to have an open write handle to the device node
at any given time. (That process may, once it has one write handle, open
any number of additional write handles.) This is accomplished by
tracking open and close data for each driver instance.

Change-Id: I0ce1dc1dc9c533026adbc3aacaefb830ecdbc3e9
Signed-off-by: Rob Springer <rspringer@google.com>
Signed-off-by: John Joseph <jnjoseph@google.com>
Signed-off-by: Simon Que <sque@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-23 16:08:19 -07:00