1
0
mirror of https://github.com/google/gasket-driver.git synced 2025-12-13 07:54:26 +00:00

236 Commits

Author SHA1 Message Date
Robert Zaage
5815ee3908 fixed eventfd_signal for kernels >= 6.8 2024-04-25 14:05:42 -07:00
Robert Zaage
09385d4858 Fixes #14 and #15 by replacing the version-based check for DMA_BUF necessity. Solves incompatibility with backports in 5.1x.x (RedHat/Debian) kernels. 2023-09-05 12:26:30 -07:00
Chris Bradbury
8aca235839 Amend use of class_create() for kernels >= 6.4
The function signature for `class_create()` was changed in kernels >= 6.4.x to only accept a single argument (see kernel commit #dcfbb67).

This change will conditionally modify how `class_create()` is called depending on the kernel version.
2023-08-14 18:03:32 -07:00
Michael Brooks
97aeba584e Update Changelog, bump version to 1.0-18 2022-02-24 11:41:03 -08:00
Jan Kiszka
5993718586 Import DMA_BUF symbol namespace for kernels >= 5.16
Needed since 16b0314aa746 upstream.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2022-02-21 21:48:42 -08:00
Waqar Hameed
f047773516 Fix DMA address truncation in gasket_coherent_buffer
`ulong` may not be sufficiently wide for addresses returned by the DMA
API. For example, a 32-bit platform can still have DMA addresses larger
than 32-bit. By using the correct type `dma_addr_t` we fix this
truncation.

Change-Id: Ibdf6456fdf12d889296e580de2acb910527ce0aa
Signed-off-by: Waqar Hameed <waqarh@axis.com>
2021-10-05 10:46:01 -07:00
Michael Brooks
a6a43f3c6a Add udev rule for apex permissions
* Adds a udev rule that will allow user access to the apex group (which
is what owns /dev/apex*).
* Also bumps compat from 9 to 10.
2021-07-01 15:10:22 -07:00
Michael Brooks
b0049c17dc More Makefile Fixes
The Makefile wasn't in the appropriate format for DKMS. While it did
work on the Coral Dev Board, it failed on other devices.

Tested:
Coral Dev Board, x86 Debian Machine
2021-06-14 14:40:53 -07:00
Michael Brooks
2faefe1e9f Fix makefile, bump versions of modules/deb
* The Makefile configuration was using kernel macros instead of obj-m,
so it wasn't building properly.
* Bump gasket and apex module versions for better DKMS installs.
* Bump Debian package version.
2021-06-11 07:54:18 -07:00
Michael Brooks
e1d5647f02 Add base documentation
Adds a simple README, LICENSE (GPLv2), and Contributing guidelines.
2021-06-08 10:11:52 -07:00
Michael Brooks
4cf92ba15b Update Debian files for a clean lintian run.
Change-Id: Ica46f546bb4ee20888f358ed569fda21546b7cd7
2021-06-03 10:09:40 -07:00
Jan Kiszka
4021786186 staging: gasket: Fix inclusion of spinlock.h
linux/rwlock.h is a no-no for direct inclusion. This remains unnoticed
when building against mainline due to prior inclusion of the correct
header, linux/spinlock.h, but breaks over the PREEMPT-RT kernel.

Would have likely been caught earlier by maintainer reviews if the
driver was developed upstream.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Change-Id: Ibc98c9017895e8991633ea4fe23171b507537525
2021-06-03 10:09:12 -07:00
Michael Brooks
1eeffd9635 Move source to src folder, add gitignore
Change-Id: Ie033078aa57e7cd7c7ce3c1d3d1f0057c8c2cf24
2021-06-03 10:03:45 -07:00
Alex Van Damme
85fc01f9a1 Update changelog
Change-Id: Iff44ca1b1322eac72a4990674f106d978cc35fe2
2021-06-03 10:03:45 -07:00
Leonid Lobachev
ee67565a59 Update changelog.
Change-Id: I1a3181db330bc5dff7580e6567c8ab1d35a49e05
2021-06-03 10:03:45 -07:00
Leonid Lobachev
1c1860e5dc Update changelog.
Change-Id: Ifb4b8f09357d13823394bf8e53faeed4b4eb4481
2021-06-03 10:03:45 -07:00
Leonid Lobachev
3c9a4aebdd gasket-dkms: fix linux-headers dependency
Signed-off-by: Leonid Lobachev <leonidl@google.com>
Change-Id: Ia6642ec2e8564c0471cad6d3111621609b5ae0ab
2021-06-03 10:03:45 -07:00
Leonid Lobachev
e2015cc3e2 Update changelog.
Change-Id: Ia4b5608d14361ca832d87d47917d855259f8a016
2021-06-03 10:03:45 -07:00
Leonid Lobachev
181157dec3 Update changelog.
Change-Id: Idf68ba4c96a599b778f5306b37527783f441dec3
2021-06-03 10:03:45 -07:00
Leonid Lobachev
015d8ec01b Update changelog
Change-Id: Icedbc872778e7169ede3bd650d9d2dad079223a4
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2021-06-03 10:03:45 -07:00
Leonid Lobachev
d5d95b5653 Update changelog.
Signed-off-by: Leonid Lobachev <leonidl@google.com>
Change-Id: I903cdfe6bf0880ec0f29003dafe48df997a5c4ad
2021-06-03 10:03:45 -07:00
Leonid Lobachev
5c5f4edba6 Add missing dkms file and update changelog.
Change-Id: Ideb1064b675824037e1287d0e753371980a57b5c
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2021-06-03 10:03:45 -07:00
Leonid Lobachev
9a7e1e3acf Add makefile, update changelog.
Change-Id: I1b85001572b1c1f3318e32309bb10fd5aea488dd
2021-06-03 10:03:45 -07:00
Leonid Lobachev
61bcd59bab Add dkms wrapper for gasket driver
Change-Id: If6cf050e0b88e8393926a251a2937d9ba4f6e1de
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2021-06-03 10:03:45 -07:00
Leonid Lobachev
3dfd0b697a Initial empty repository 2021-06-03 10:03:44 -07:00
Michael Brooks
d6ea0a3f26 Merge in original Gasket commits
Pulls in git history for drivers/staging/gasket from
https://coral.googlesource.com/linux-imx/+/refs/heads/dkms

Change-Id: I42a32b96657d72cca1c08198d52793cc73808f3b
2021-05-21 13:20:13 -07:00
Michael Brooks
ad8a531165 Initial empty repository 2021-05-20 21:42:03 +00:00
Alex Van Damme
c59797eba6 Unregister gasket IRQs on suspend
- Use the existing gasket_interrupt_msix_cleanup at suspend time to
remove our IRQs from the system. Without doing this, we leave 13 IRQs
per device registered, which can cause issues during suspend if many
devices are loaded in the system.
- Restore them at resume time, using the gasket_interrupt_reinit
functionality.
- This allows successful suspend without any errors taking the CPUs
down, and passing the multi-tpu stress test after resume.

Change-Id: Ied1aca8605c0cb3b64ba591d05312d10cf45343f
2020-10-12 15:18:28 -07:00
Leonid Lobachev
860ed615fa Change ioremap_nocache to ioremap.
ioremap defaults to ioremap_nocache since 2.6 and latter is removed in
5.6 kernel.
See 4bdc0d676a

Change-Id: Ifd9ff9db5937abf487d57861465cd58b4df18ac3
2020-08-07 22:18:51 +00:00
Jonas Larsson
64728f3114 staging: gasket: fix compilation on 5.1+
https://lore.kernel.org/patchwork/patch/1039724/

Bug: 158716452
Change-Id: I3c90a6524d3859e5518b7aece5a2817ed1f3efed
(cherry picked from commit 0aacc629f48459a1f8169120afc868cdb48f0593)
2020-06-11 19:47:07 +00:00
Leonid Lobachev
b20a2f21c3 staging: gasket: apex: restore thermal control registers
After host suspend/resume operation device is power cycled and
loses all custom register settings.
All settings are restored on first device open except thermal
monitoring related settings.

Signed-off-by: Leonid Lobachev <leonidl@google.com>
Change-Id: I3a7c69efd919da0992c585874d7fe906a7768ee7
2020-06-08 16:11:04 -07:00
Waqar Hameed
3b6740a1d4 staging: gasket: Remove unused local variables
The variables "mapping" and "tmp" are unused in
gasket_page_table_unmap_dmabuf().

Signed-off-by: Waqar Hameed <waqarh@axis.com>
Change-Id: I0da67e5e91fb8c8f34b13e7227afb8410bcbc138
2020-04-17 09:38:04 -07:00
Waqar Hameed
cf41759771 staging: gasket: Fix formatting
Add a space before the open parentheses in an if-statement, to follow
Linux kernel coding style.

Signed-off-by: Waqar Hameed <waqarh@axis.com>
Change-Id: Ic6658aecdde508762117364669872d69dcb0e8e6
2020-04-17 09:37:45 -07:00
Jonas Larsson
fa575cdad7 staging: gasket: don't require all pages to be writable
Buffers to be mapped as DMA_TO_DEVICE must be writable due to the
'write' argument to get_user_pages_fast being hard coded to 1.
This prevents userspace from passing in pointers returned from
mmap(fd, PROT_READ), instead mmap(fd, PROT_READ | PROT_WRITE)
must be used even if the buffer is supposed to be read only.

Instead set writable to non zero iff direction != DMA_TO_DEVICE,
ie only buffers with DMA_FROM_DEVICE or DMA_BIDIRECTIONAL are
required to be writable.

Change-Id: I21c97b2bb855e11ecaa6ae9e81cf8b463b4aedaa
Signed-off-by: Jonas Larsson <ljonas@google.com>
2020-04-17 09:36:21 -07:00
Jonas Larsson
0d361c0493 staging: gasket: support mapping of dma-bufs.
This allows userspace to pass in dma-buf file descriptors for
mapping in addition to userspace virtual memory pointers,
leaving cache maintenance to the dma-buf exporter and userspace
application.

Bug: 149764192
Change-Id: Iee8b581db0a461fe13ee8712d47d66f8fb16e7c9
Signed-off-by: Jonas Larsson <ljonas@google.com>
2020-04-17 09:22:48 -07:00
Leonid Lobachev
6535f9ada1 Update gasket framework version.
This is needed to avoid the need for manual dkms driver installation
with --force on systems where upstream staging kernel module is present
already.

Change-Id: Ifb3dc930757835888ae3e13d1607d5fd7bc710ed
2019-11-13 17:54:35 -08:00
Leonid Lobachev
a9b97c3f92 staging: gasket: add unique chip id sysfs node
Change-Id: I15ee278e212b76dfd649f03f256870b9872c3395
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-10-18 19:23:21 +00:00
Leonid Lobachev
f003a96909 staging: gasket: add dma_bit_mask module parameter.
This allows to force dma buffers to be located in 32bit low address
space to workaround issues with some pcie controllers.

Change-Id: I7f77081882b6dffb91f034f8491ad8ffa1375fe7
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-09-25 18:25:14 +00:00
Leonid Lobachev
ee04262273 staging: gasket: fix ISO C90 warnings
Change-Id: I0e114cf27e1f38830c04bdd0f5f705b9a795fe59
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-09-23 22:44:02 +00:00
Leonid Lobachev
067d10799a staging: gasket: remove unnecessary defines
Change-Id: I3c2a2c435671b6a41d9294d444e9200aae13b30b
Signed-off-by: Leonid Lobachev <leonidl@google.com>
2019-09-23 22:43:55 +00:00
Todd Poynor
4a701a4c31 staging: gasket: fix mmap of coherent buffer when IOMMU translation on
Coherent buffer mmap code assumes DMA addresses are physical addresses,
which is patently wrong when a downstream IOMMU allocates and
translates IOVAs for DMA mappings.  Use dma_mmap_coherent().

Bug: 140076240
Bug: 111709861
Change-Id: Ieaa052378844aaf126ea3bc9dba544e7edb37bc7
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:43:48 +00:00
Waqar Hameed
be43ad6a89 staging: gasket: Fix dev_addr truncation on 32-bit arch
The extended address bit is at position 63 (c.f. apex_driver.c:60). The
device address will thus not fit in a ulong on 32-bit ARM systems.
Use u64 instead.

[toddpoynor@google.com: more fixups, fix debug printk param order]
Bug: 137378503
Signed-off-by: Waqar Hameed <waqarh@axis.com>
Change-Id: If801b2b97d88c1329f3a359507e265837150571c
2019-09-23 22:43:36 +00:00
Leonid Lobachev
e2505d92c7 char: oscar: gasket: add interface to set a separate DMA device
In at least the case of an mfd_cell multi-function device child, the
child platform device does not inherit the DMA / IOMMU configuration
of the parent.  Copying that configuration is non-straightforward or
even likely impossible when the parent device is PCI and holds
pointers to IOMMU-related state only made available for PCI devices.

Add a gasket call to allow platform chip drivers to register their
PCI parent as the device to use for DMA API calls, such that the
chip drivers can workaround this.

Change-Id: I4a4b6de67f5d10197f8ea02d06522090b150d659
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2019-09-23 22:43:27 +00:00
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