Commit Graph

37 Commits

Author SHA1 Message Date
Leonid Lobachev
83d87f28f8 staging: gasket: Enable DFS and thermal shutdown by default
Change-Id: I6f9f910f3fa7fdefa1ed3a9d81bb35fb69b68fbb
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-06-11 11:40:27 -07:00
Leonid Lobachev
4856195932 staging: gasket: Add default values for HW temperature monitor
Add module parameters to control default values for HW temperature
monitoring module.

Signed-off-by: Leonid Lobachev <leonidl@google.com>
Change-Id: I69f7cd9c3c0f55a3a36efba35f48a5da37b3b89e
2019-06-10 17:45:38 -07:00
Leonid Lobachev
fbe01658e7 staging: gasket: Add performance scaling based on temperature
Perform periodic polling of apex temperature and scale down
its frequency if temperature is above one of defined trip points.
Added sysfs nodes to control related settings on per device basis.
Added module parameters to set allow setting default value for all
devices in system.

Signed-off-by: Leonid Lobachev <leonidl@google.com>
Change-Id: I5065282cba9f0888abd4086601bda89174f24705
2019-06-10 15:16:39 -07:00
Leonid Lobachev
56f0b552fe staging: gasket: Add thermal sysfs nodes.
Add node to read current temperature and nodes
to set and enable/disable thermal warnings.

Change-Id: I8a12f6e33679573107686fe32be2e4a8bb0f9cc7
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-04-30 22:07:14 +00:00
Leonid Lobachev
c4a2c4870a staging: gasket: Fix pci remove/rescan for kernel module build.
For driver build as module pci_fixup_header approach doesn't work.
This causes apex pci class to remain 0xff and BARs remain
unclaimed. Adding a retry with explicit fixup function call
workarounds the problem.

Bug: 129287752
Change-Id: Id5ff85ef427d3740706a214d3beb1c9bbf42ab5a
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-04-30 22:02:25 +00:00
Leonid Lobachev
e02a554826 Add sysfs node with temperature sensor reading.
Change-Id: Ic9a71f1b1aaee64b68224cdc20dcfe2980b9c7d8
2019-02-11 13:26:44 -08:00
Nick Ewalt
068cb76fc5 staging: gasket: apex: fix sysfs_show
sysfs_show was incorrectly extracting the sysfs_attribute_type from the
gasket_sysfs_attribute. This prevented dispatch from working properly.

Change-Id: Ib962a10cf24bd4be416708e0a6294b6db431c76f
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
2019-02-11 13:12:49 -08:00
Leonid Lobachev
641f4139f4 Address b/117119472
Change-Id: I88c018628768b56e5904d89db2bd1d767078c4d1
2019-01-15 14:45:45 -08:00
Alex Van Damme
dd3fb175c5 Cleanup apex performance patch
Change-Id: I9a419ef63cee937b7b4c183c9070be011555f8d4
2018-09-04 12:31:36 -07:00
Colin Ian King
6cf5526355 staging: gasket: apex: remove unused array cm_mappable_regions
Array cm_mappable_regions is defined but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: 'cm_mappable_regions' defined but not used [-Wunused-const-variable=]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:18:26 -07:00
Todd Poynor
b9ded2cf72 staging: gasket: apex: place in low power reset until opened
The apex device is left out of reset mode at the end of device
probe/initialize processing.  Add a call to enter reset at the end of
the sequence, triggering power gating and other low power features.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:15:28 -07:00
Todd Poynor
9117159d16 staging: gasket: apex: move sysfs setup code to probe function
The gasket framework no longer provides callbacks to the device driver
for sysfs setup and teardown.  Move the sysfs setup code to the device
probe function.  Apex does not implement sysfs cleanup code.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:14:14 -07:00
Todd Poynor
18beeae8aa staging: gasket: apex: fold device add/remove logic inline
Gasket device drivers are now in charge of the device add and remove
sequences; the framework callbacks for these are deleted.  Move the
apex device add callback code to the probe function.  Apex did not
implement the removal callback.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:13:00 -07:00
Todd Poynor
1c34a962b3 staging: gasket: apex: enable/disable gasket device from apex
Gasket framework now places device drivers in charge of calling APIs to
enable and disable gasket device operations.  Make the appropriate calls
from the apex driver.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:11:50 -07:00
Todd Poynor
a1fc286eef staging: gasket: apex: remove device enable and disable callbacks
These are not implemented for apex, and are now being removed from the
gasket framework.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:10:40 -07:00
Todd Poynor
ea7e508c0d staging: gasket: apex: move PCI core calls to apex driver
Apex driver moves PCI core calls like probe, enable, and remove from
gasket to apex.  Call new functions in gasket to register apex as a PCI
device to the gasket framework.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:08:52 -07:00
Todd Poynor
7ec73c69e1 staging: gasket: apex: drop reset type param
Apex doesn't implement different types of resets based on the reset type
param passed through the gasket layer or from userspace via the
gasket_reset ioctl.  The reset type is dropped from the gasket framework
in a previous patch due to a lack of present need and non-conforming use
of this parameter by the framework.  Drop the parameter from the apex
driver as well.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:03:31 -07:00
Todd Poynor
39f2709991 staging: gasket: apex: move driver-private defines out of apex.h
apex.h is supposed to contain kernel-userspace interface definitions,
but has a number of defines that are only used by apex_driver.c or are
not used at all.  Move driver implementation defines not shared with
userspace to the driver source.  Remove unused defines.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:59:50 -07:00
Todd Poynor
c538a3d634 staging: gasket: apex: fix function param line continuation style
Fix multi-line alignment formatting to look like:
      int ret = long_function_name(device, VARIABLE1, VARIABLE2,
                                   VARIABLE3, VARIABLE4);

Many of these TODO items were previously cleaned up during the conversion
to standard logging functions.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:50:16 -07:00
Todd Poynor
1694500340 staging: gasket: apex: remove static function forward declarations
Remove forward declarations of static functions, move code to avoid
forward references, for kernel style.

Change-Id: I1078c4840860c5c1cf06a12bfd0409c6db7303ff
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:49:38 -07:00
Todd Poynor
5193ebb0e4 staging: gasket: apex: simplify comments for static functions
Static functions don't need kernel doc formatting, can be simplified.
Reformat comments that can be single-line.  Remove extraneous text.

Change-Id: Ia29594eeb2dd6cea38665d26e130237f5f90c94a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:42:43 -07:00
Todd Poynor
f10af4ee11 staging: gasket: apex: fixup undefined PCI class
Apex chips with class 0 (PCI_CLASS_NOT_DEFINED) fixed up to
PCI_CLASS_SYSTEM_OTHER to enable PCI resource assignments.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:36:39 -07:00
Todd Poynor
57a55b53ab staging: gasket: apex: convert to standard logging
Drop gasket logging calls in favor of standard logging.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:33:20 -07:00
Todd Poynor
b04dc30709 staging: gasket: apex: convert various logs to debug level
Debugging information is improperly logged at non-debug log level in a
number of places, and some logs regarding error conditions may be
generated too frequently, such that these could cause performance
problems and/or obscure other logs.  Convert these to debug log level.

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-09-04 11:27:29 -07:00
Todd Poynor
8127031234 staging: gasket: apex return error on sysfs show of missing attribute
Apex sysfs show function return -ENODEV if the attribute is not present,
rather than silently failing from the standpoint of the userspace
accessor.

Reported-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:24:01 -07:00
Todd Poynor
53f54339d7 staging: gasket: apex ioctl add __user annotations
Add __user annotation to ioctl pointer argument, for sparse checking.

Change-Id: I677aa0a2eed9a34b799273e0a3a7cb45ced14c8e
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-09-04 11:18:20 -07:00
Todd Poynor
c4e2ac2703 staging: gasket: always allow root open for write
Always allow root to open device for writing.

Drop special-casing of ioctl permissions for root vs. owner.

Convert to bool types as appropriate.

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-09-04 11:11:40 -07:00
Todd Poynor
5f5275b6c8 staging: gasket: apex_clock_gating simplify logic, reduce indentation
Collapse together two checks and return immediately, avoid conditional
indentation for most of function code.

Reported-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Simon Que <sque@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 11:07:01 -07:00
Leonid Lobachev
378d57f04e Keep apex in reset mode unless it's used.
Change-Id: I56eb88a1a138290f6939a19e8b973fb78d2e3c40
2018-07-23 17:27:43 -07:00
Alex Van Damme
237454b288 Apex performance ioctl
Change-Id: Id3ae759f748b3f8c6f6a5320a5088c43fad0e812
2018-07-23 16:11:16 -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
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
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
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
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