Commit Graph

193 Commits

Author SHA1 Message Date
Nick Ewalt
975c81ef1d staging: gasket: cleanup extended page table map/unmap
Make sure to use dma_sync_single_for_device whenever updating the
contents of an extended page table. This performs the cache flush using
the correct function from the DMA-API. Also move this call outside of
the inner loop to improve performance.

Tested: Ran run_tests with inception, testfullyconnected with parameter
caching, and rnntransducerdecoderpie107m on AT Enterprise.

Change-Id: Ie3c63113dde8cafe448d515e8970810afc9564ac
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
2019-09-23 22:43:21 +00:00
Leonid Lobachev
0dc5779dd7 staging: gasket: Update device virtual address comment
Add that number of page table entries and extended address bit offset
are configurable. Update example virtual address format to be more
consistent with typical usage.

Change-Id: I73f9674df74b6d8ee5ed6e5d95ab12dcc56e29cc
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-23 22:43:12 +00:00
Leonid Lobachev
4dca661727 staging: gasket: Kconfig: describe Apex as an Edge TPU device
Add a brief description and URL for more information on the Apex device,
an Edge TPU (Tensorflow Processing Unit) machine learning accelerator.

Change-Id: Ia7b40414e9f0745feb8ced2cb3aa7e9c6baa0c3d
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-09-23 22:43:06 +00:00
Leonid Lobachev
35f51b913e staging: gasket: core: add platform device add and remove functions
Add support for platform devices in the gasket framework.

Change-Id: I1e3625f9222b37925a2a672c9ea6eed31aefa35f
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:59 +00:00
Leonid Lobachev
2a20ff1172 staging: gasket: interrupt: allow device driver to manage interrupts
Add interrupt type DEVICE_MANAGED, indicating that the device driver
manages interrupt setup and handling.  Future non-PCI wire interrupts
will use this type, calling gasket_handle_interrupt(), which is now made
non-static, to call into the gasket framework in order to update sysfs
files for interrupt counts and other framework interfaces.

Change-Id: Ie0be3d950ed2706f7ada848c19ddf7017e9623b2
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:52 +00:00
Leonid Lobachev
35113ccbb5 staging: gasket: page_table: handle failed dma_map_page
Handle dma_map_page failing in gasket_alloc_extended_subtable.

Change-Id: I082b0d1a44a9a7c749683cda8daea7e0920d55fc
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:44 +00:00
Leonid Lobachev
85c7608274 staging: gasket: page_table: simplify gasket_components_to_dev_address
Refactor gasket_components_to_dev_address to be faster and easier to
understand. The old implementation was unnecessarily complex and masked
the page_index for simple addresses but not extended ones. It makes the
most sense for this function to perform no such masking.

Change-Id: If5f68cb6f1bf3000a5d5b77aab89cb8e391c3cf4
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:36 +00:00
Leonid Lobachev
0963c2f012 staging: gasket: page_table: fix comment in components_to_dev_address
Change-Id: Id343101cfdcad2354adb1fc03699e826b14192bb
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:29 +00:00
Leonid Lobachev
79b8ea00a1 staging: gasket: page_table: use total_entries for max ext lvl0 page idx
The maximum number of entries in the page table is configurable at
initialization time and should be used in gasket_extended_lvl0_page_idx.

Change-Id: I39f2dba48083a3eef3951ecd9659ee9f4901275e
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:21 +00:00
Leonid Lobachev
39d3974ac0 staging: gasket: page_table: fix debug log in gasket_perform_mapping
Change-Id: I841914a6d5362073d0b85732b38f52f93a3a51b3
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:14 +00:00
Leonid Lobachev
b2c7368909 staging: gasket: cleanup if dma_map_page fails in gasket_perform_mapping
Previously pages would have never been unmapped in this case.

Change-Id: I71b6447267933865ab23a3ba3830e7ce3d3e0e57
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:42:06 +00:00
Leonid Lobachev
355e45e64b staging: gasket: page table: fixup error path allocating coherent mem
Correctly clean up data structure state in gasket_alloc_coherent_memory
error path, to ensure no double free on the stale pointer value.

Change-Id: Ifbc426e857d6bd05a13a725f2c2fdb07dedc098c
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:41:57 +00:00
Leonid Lobachev
3ef19e3777 staging: gasket: page_table: don't unmap coherent pages
Only call dma_unmap_page if there was an associated dma_map_page.

Change-Id: I6234719f8ab6b1e5e069c21e2f639eee4f22b039
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:41:48 +00:00
Leonid Lobachev
bcf565dc81 staging: gasket: page_table: add mapping flags
This allows for more precise dma_direction in the dma_map_page requests.
Also leaves room for adding more flags later.

Change-Id: I46feecc2638b7ad0d34548cc10837549a3928011
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:41:39 +00:00
Leonid Lobachev
513c6336ef staging: gasket: page_table: remove unnecessary PTE status set to free
Remove unnecessary ptes[i].status update in gasket_perform_unmapping.
The vlaue will be cleared in the following memset.

Change-Id: I5aeafa1085203b5dc24b3303037ece1f37acd6c6
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:41:30 +00:00
Leonid Lobachev
7e99cc991a staging: gasket: page_table: rearrange gasket_page_table_entry
Rearrange gasket_page_table entry to reduce padding slop.

Change-Id: I1dab69344bb1974de0d67028e6f638ec5a849374
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:41:03 +00:00
Leonid Lobachev
06938d183c staging: gasket: page_table: fix dma_data_direction
Extended page tables can be mapped as DMA_TO_DEVICE.
Calls to dma_unmap_page should match corresponding dma_map_page.

Change-Id: I2d09fd5d66c364e190b073fabe089ce5eaf426f6
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:40:08 +00:00
Leonid Lobachev
3e21ff65d6 staging: gasket: page table: remove dead code in coherent mem alloc
gasket_alloc_coherent_memory() has some unnecessary code related to out
of memory checking that will never hit the condition checked, remove.

Change-Id: Ifb09e7ff31d8ae41a486639a2abc6ce26c4d85ef
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 11:50:56 -07:00
Leonid Lobachev
71591a83ad staging: gasket: page table: return valid error code on map fail
Return -EINVAL on mapping failures, instead of -1, which triggers a
checkpatch error.

Change-Id: I91a62a72caa5ca09e07bd4897e72f4919495c040
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 11:49:33 -07:00
Leonid Lobachev
bc67c21fb1 staging: gasket: core: debug log updates
Add debug logs for device enable/disable events, remove logs for
callbacks (the called functions can generate their own logs if needed).

Change-Id: I861077c3210452d9ac6606e973bac5c14eeef859
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 11:47:33 -07:00
Leonid Lobachev
7d66238c08 staging: gasket: interrupt: remove PCI-MSIX-specific status check
Devices not using MSIX don't use the msix_initialized field, don't
require it to be set in the interrupt system status check. The general
check for interrupts configured that follows can cover both MSIX and
device-managed interrupts.

Change-Id: I83a86cb4db7cea30c30377dd82b033ef372d69c0
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 11:44:07 -07:00
Todd Poynor
5862a44ee2 staging: gasket: page table: use GFP_KERNEL for dma_alloc_coherent
Flags should be specified for dma_alloc_coherent() call.  Use
GFP_KERNEL, it's fine to sleep here.

Change-Id: Iec4ad9550e8829b67e99b22246e40e0b21600c54
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 11:30:36 -07:00
Nick Ewalt
ad4c9a5893 staging: gasket: fix free in gasket_free_coherent_memory_all
Actually free gasket_coherent_page_entries and just call
gasket_free_coherent_memory_all from gasket_free_coherent_memory.

Change-Id: I1d016abd5f66e0620a37f6851e43fcfd6c96868a
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
2019-09-23 11:28:33 -07:00
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
Rob Springer
83ce758fc4 staging: gasket: release taken eventfd contexts
Port of change by Rob Springer to fix leak of eventfd context objects in
gasket framework interrupt code.

Bug: 131928433
Bug: 80495595
Reported-by: Jann Horn <jannh@google.com>
Reported-by: Neel Natu <neelnatu@google.com>
Test: Resnet50PB, PortraitSegmentation
Change-Id: I6bdea5ab4d3a7435e7f51c96817f0542d185b22c
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-05-29 13:47:52 -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
Jae Yoo
75b8025f7e Add arm32 compatibility into gasket driver
Add a compat_ioctl handler for arm32 and replace ulong to u64.

Bug: 115850337, 117133232
Test: label_image runs correctly.
Change-Id: Ie17244faff2aa1461397e740fba4581c6b112f30
2018-10-23 10:40:30 +09:00
Alex Van Damme
dd3fb175c5 Cleanup apex performance patch
Change-Id: I9a419ef63cee937b7b4c183c9070be011555f8d4
2018-09-04 12:31:36 -07:00
Todd Poynor
c1f31b7544 staging: gasket: interrupt: remove unimplemented interrupt types
Interrupt types PCI_MSI and PLATFORM_WIRE are unused and unimplemented.
Remove these.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:27:23 -07:00
Todd Poynor
a6aafca18b staging: gasket: interrupt: simplify interrupt init parameters
Pass the gasket driver descriptor to the interrupt init function, rather
than exploding out separate parameters from various fields of that
structure.  This allows us to make more localized changes to the types
of interrupts supported (MSIX vs. wire, etc.) without affecting the
calling sequence, and seems nicer for simplification purposes.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:26:44 -07:00
Todd Poynor
ffa037c047 staging: gasket: interrupt: refactor PCI MSIX-specific handler code
Split interrupt handler into PCI MSIX-specific and generic functions,
for adding non-MSIX handlers in the future.  Move MSIX init code
together,, out of generic init path.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:26:05 -07:00
Todd Poynor
29182ff7cb staging: gasket: core: rename lookup_internal_desc to be PCI-specific
Rename lookup_internal_desc() to lookup_pci_internal_desc() to reflect
use for PCI devices only, in prep for non-PCI devices in the future.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:25:26 -07:00
Todd Poynor
a74e602f32 staging: gasket: core: factor out generic device remove code from PCI
Separate code for generic parts of gasket device removal sequence from
the PCI device removal code, in prep for non-PCI devices later.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:24:46 -07:00
Todd Poynor
16c146bc73 staging: gasket: core: factor out generic device add code from PCI code
Split out generic gasket device add code from the code for adding a PCI
gasket device, in prep for other gasket device types in the future.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:24:08 -07:00
Todd Poynor
e14033cdb6 staging: gasket: page table: remove extraneous memory barriers
Some explicit memory barriers in the page table code are not necessary,
either because:

(a) The barrier follows a non-relaxed MMIO access that already performs
a read or write memory barrier.

(b) The barrier follows DMA API calls for which the device-visible
effects of IOMMU programming are guaranteed to be flushed to the IOMMU
prior to the call returning, and doesn't need to sync with normal memory
access.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:23:30 -07:00
Todd Poynor
4d13cb937f staging: gasket: core: switch to relaxed memory-mapped I/O
Use of readl() is deprecated; readl_relaxed() with appropriate memory
barriers is preferred.  Switch to relaxed reads and writes for better
performance as well.  Memory barriers required for I/O vs. normal
memory access on Apex devices have already been explicitly coded in the
page table routines.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:22:51 -07:00
Todd Poynor
72caabea8c staging: gasket: page table: use dma_mapping_error for error detection
gasket_perform_mapping() call dma_mapping_error() to determine if
mapping failed.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:22:12 -07:00
Todd Poynor
89ff180f96 staging: gasket: remove gasket_exit()
Remove now-empty gasket_exit() function.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:21:33 -07:00
Todd Poynor
a6a8491235 staging: gasket: core: remove ftrace-style debug logs
Remove debug logs that only indicate the name of the entered function,
in favor of using ftrace for function tracing style logs.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:20:54 -07:00
Todd Poynor
c64522af66 staging: gasket: core: remove kobj_name param from gasket_alloc_dev
gasket_alloc_dev can retrieve the device name from the parent parameter,
a separate parameter isn't needed for this.  Rename the variable to
better reflect its meaning, as the name of the parent device for which a
gasket device is being allocated.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:20:15 -07:00
Todd Poynor
68a1cca7c6 staging: gasket: core: fix line continuation indent in gasket_alloc_dev
Previous cleanups missed a case of multi-line function call with line
continuation parameters not aligned per kernel style.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:19:39 -07:00
Todd Poynor
ceca0c9cb3 staging: gasket: core: remove debug log that could crash
A debug log in gasket_alloc_dev() is issued regardless of whether the
device pointer used returned success or error.  The log isn't that
useful anyway, remove it.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Reviewed-by: Rob Springer <rspringer@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:19:02 -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
Sumit Kumar
1fa1af899a staging: gasket: remove null ptr check before kfree
Remove null ptr check before kfree because kfree is null ptr safe.
Issue found by checkpatch.

Signed-off-by: Sumit Kumar <sumit686215@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-04 12:17:50 -07:00