summaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/src
Commit message (Collapse)AuthorAgeFilesLines
* Improve handling of alternate settings in the USB stack.Hans Petter Selasky2020-12-151-5/+0
| | | | | | | | | | | | | | | | | Allow setting the alternate interface number to fail when there is only one alternate setting present, to comply with the USB specification. Refactor how iface->num_altsetting is computed. Bump the __FreeBSD_version due to change of core USB structure. PR: 251856 MFC after: 1 week Submitted by: Ma, Horse <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368659
* linux_dma: Ensure proper flags pass to allocators.Bryan Drewery2020-12-101-3/+3
| | | | | | | | | | | | | Possibly fixes the wrong flags being passed to the kernel allocators in linux_dma_alloc_coherent() and linux_dma_pool_alloc(). Reviewed by: hps MFC after: 2 weeks Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27508 Notes: svn path=/head/; revision=368524
* LinuxKPI: Implement ACPI bits required by drm-kmod in base systemEmmanuel Vadot2020-11-091-0/+243
| | | | | | | | | | | | | | | It includes: ACPI_HANDLE() implementation. AC and VIDEO ACPI events notification support. Replacement of hand-rolled GPLed _DSM method evaluation helpers with in-base ones. Submitted by: wulf Differential Revision: https://reviews.freebsd.org/D26603 Notes: svn path=/head/; revision=367521
* kqueue: save space by using only one func pointer for assertionsMateusz Guzik2020-11-091-14/+6
| | | | Notes: svn path=/head/; revision=367498
* Populate the acquire context field of a ww_mutex in the LinuxKPI.Hans Petter Selasky2020-10-041-1/+6
| | | | | | | | | | | | Bump the FreeBSD version to force recompilation of external kernel modules. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26657 Submitted by: greg_unrelenting.technology (Greg V) Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=366432
* linuxkpi: Add dmi_* functionEmmanuel Vadot2020-10-021-0/+140
| | | | | | | | | | | | dmi function are used to get smbios values. The DRM subsystem and drivers use it to enabled (or not) quirks. Reviewed by: hselasky Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26046 Notes: svn path=/head/; revision=366373
* linuxkpi: Add backlight supportEmmanuel Vadot2020-10-022-0/+84
| | | | | | | | | | | | | Add backlight function to linuxkpi. Graphics drivers expose the backlight of the panel directly so allow them to use the backlight subsystem so user can use backlight(8) to configure them. Reviewed by: hselasky Relnotes: yes Differential Revision: The FreeBSD Foundation Notes: svn path=/head/; revision=366372
* compat: clean up empty lines in .c and .h filesMateusz Guzik2020-09-019-27/+1
| | | | Notes: svn path=/head/; revision=365080
* Implement extensible arrays API using the existing radix tree implementationHans Petter Selasky2020-08-271-0/+391
| | | | | | | | | | | | in the LinuxKPI. Differential Revision: https://reviews.freebsd.org/D25101 Reviewed by: kib @ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=364860
* linuxkpi: Add a few wait_bit functionsEmmanuel Vadot2020-08-141-0/+6
| | | | | | | | | | | | | | | | The linux function does a lot more than that as multiple waitqueue could be fetch from a static table based on the hash of the argument but since in DRM it's only used in one place just add a single variable. We will probably need to change that in the futur but it's ok with DRM even with current linux. Reviewed by: hselasky MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26054 Notes: svn path=/head/; revision=364232
* Need to clone the task struct fields related to RCU aswell in theHans Petter Selasky2020-08-111-7/+11
| | | | | | | | | | | | | | | | LinuxKPI after r359727. This fixes a minor regression issue. Else the priority tracking won't work properly when both sleepable and non-sleepable RCU is in use on the same thread. Bump the __FreeBSD_version to force recompilation of external kernel modules. PR: 242272 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=364109
* vfs: add VOP_STATMateusz Guzik2020-08-071-1/+1
| | | | | | | | | | | | | | The current scheme of calling VOP_GETATTR adds avoidable overhead. An example with tmpfs doing fstat (ops/s): before: 7488958 after: 7913833 Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D25910 Notes: svn path=/head/; revision=364044
* Implement radix_tree_store() in the LinuxKPI for use with the comingHans Petter Selasky2020-08-071-10/+133
| | | | | | | | | | | | | | | | | | | | | | extensible arrays implementation. While at it add some more comments explaining the current radix_tree_insert() function and make sure to clean the root node when the radix tree reaches the maximum height. This can happen if the index passed is too big when the tree is empty. The radix_tree_store() function is basically a copy of the radix_tree_insert() function with some added functionality. The radix_tree_store() function is local to FreeBSD and does not yet exist in Linux. Reviewed by: kib MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=364028
* usb(4): Stop checking for failures from malloc(M_WAITOK).Mark Johnston2020-07-221-13/+7
| | | | | | | | | | | | | | Handle the fact that parts of usb(4) can be compiled into the boot loader, where M_WAITOK does not guarantee a successful allocation. PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> (original version) Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25706 Notes: svn path=/head/; revision=363420
* linuxkpi: improvements for linux_pid_task() and linux_get_pid_task().Konstantin Belousov2020-07-021-46/+33
| | | | | | | | | | | | | | Unify functions bodies. Do not call tdfind() if pid is passed, and do not call pfind() if tid is supplied. Reviewed by: hselasky Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25534 Notes: svn path=/head/; revision=362886
* The "pid" field in the LinuxKPI task struct is typically set to the thread IDHans Petter Selasky2020-07-011-1/+11
| | | | | | | | | | | | | | | and not the process ID. Make sure the linux_task_exiting() function uses tdfind() to lookup the BSD procedure structure pointer by the "pid" field, and only fallback to pfind() when no match is found! This makes linux_task_exiting() in line with the rest of the code. Differential Revision: https://reviews.freebsd.org/D25509 Submitted by: Greg V <greg@unrelenting.technology> MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=362829
* Remove some redundant assignments and computations.Mark Johnston2020-06-281-3/+2
| | | | | | | | | | | Reported by: alc Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25400 Notes: svn path=/head/; revision=362739
* Add a helper function for validating VA ranges.Mark Johnston2020-06-191-1/+1
| | | | | | | | | | | | | | Functions which take untrusted user ranges must validate against the bounds of the map, and also check for wraparound. Instead of having the same logic duplicated in a number of places, add a function to check. Reviewed by: dougm, kib Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25328 Notes: svn path=/head/; revision=362361
* linuxkpi: Fix mod_timer and del_timer_syncEmmanuel Vadot2020-05-251-2/+16
| | | | | | | | | | | | | mod_timer is supposed to return 1 if the modified timer was pending, which is exactly what callout_reset does so return the value after checking that it's a correct one in case the api change. del_timer_sync returns int so add a function and handle that. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24983 Notes: svn path=/head/; revision=361452
* linuxkpi: Add rcu_work functionsEmmanuel Vadot2020-05-211-0/+48
| | | | | | | | | | | | | The rcu_work function helps to queue some work after waiting for a grace period. This is needed by DRM drivers. Sponsored-by: The FreeBSD Foundation Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24942 Notes: svn path=/head/; revision=361343
* linuxkpi: Add pci_iomap and pci_iounmapEmmanuel Vadot2020-05-071-0/+1
| | | | | | | | | | | | | | Those function are use to map/unmap io region of a pci device. Different resource can be mapped depending on the bar so use a tailq to store them all. Sponsored-by: The FreeBSD Foundation Reviewed by: emaste, hselasky Differential Revision: https://reviews.freebsd.org/D24696 Notes: svn path=/head/; revision=360787
* Fix warning about sleeping with non-sleepable lock when allocatingHans Petter Selasky2020-05-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | "current" from linux_cdev_pager_populate() in the LinuxKPI: Backtrace: witness_debugger() witness_warn() uma_zalloc_arg() malloc() linux_alloc_current() linux_cdev_pager_populate() vm_fault() vm_fault_trap() trap_pfault() trap() calltrap() Suggested by: avg@ MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360621
* Factor code in LinuxKPI to allow attach and detach using any BSD device.Hans Petter Selasky2020-04-221-14/+39
| | | | | | | | | | | | | | | This allows non-LinuxKPI based infiniband device drivers to attach correctly to ibcore. No functional change intended. Reviewed by: np @ Differential Revision: https://reviews.freebsd.org/D24514 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=360196
* Remove a vestigal reference to kmem_object.Mark Johnston2020-04-171-1/+1
| | | | | | | | | kmem_object has been an alias of kernel_object for a while. MFC after: 1 week Notes: svn path=/head/; revision=360052
* Clone the RCU interface into a sleepable and a non-sleepable partHans Petter Selasky2020-04-081-38/+57
| | | | | | | | | | | | | | | | in the LinuxKPI. This allows synchronize RCU to be used inside a SRCU read section. No functional change intended. Bump the __FreeBSD_version to force recompilation of external kernel modules. PR: 242272 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=359727
* Implement a workaround for kms-drm modulesWarner Losh2020-03-201-0/+5
| | | | | | | | | | | | pci_iov_if.h was added to pci.h, but none of the kms-drm branches have that. Rather than play whack a mole with the branches, move its inclusion to linux_pci.c which is the only part of the code that needs it now. Longer term, other solutions will be needed, but this gives us time to get those deployed on all the supported versions. Notes: svn path=/head/; revision=359165
* linuxkpi: Add infrastructure to pass FreeBSD IOV method calls intoKonstantin Belousov2020-03-181-0/+47
| | | | | | | | | | | pci_driver methods. Reviewed by: hselasky Sponsored by: Mellanox Technologies MFC after: 2 weeks Notes: svn path=/head/; revision=359096
* When closing a LinuxKPI file always use the real release function to avoidHans Petter Selasky2020-03-031-2/+8
| | | | | | | | | | | | | resource leakage when destroying a LinuxKPI character device. Submitted by: Andrew Boyer <aboyer@pensando.io> Reviewed by: kib@ PR: 244572 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=358586
* Extend the range of the return value from nsecs_to_jiffies64() to supportHans Petter Selasky2020-02-271-0/+50
| | | | | | | | | | | | | | | Mesa's drm_syncobj usage, in the LinuxKPI. While at it optimise the jiffies conversion functions to avoid repeated and constant calculations. Submitted by: Greg V <greg@unrelenting.technology> Differential Revision: https://reviews.freebsd.org/D23846 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=358387
* linuxkpi: Move shmem related functions in it's own fileEmmanuel Vadot2020-02-212-83/+129
| | | | | | | | | | | | | For drmkpi (D23085) we don't want the Linux struct file as we don't emulate everything. Also the prototypes should be in shmem_fs.h to have 100% compatibility with Linux. Reviewed by: hselasky MFC after: Maybe Differential Revision: https://reviews.freebsd.org/D23764 Notes: svn path=/head/; revision=358217
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)Pawel Biernacki2020-02-151-3/+4
| | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Reviewed by: hselasky, kib, zeising Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D23631 Notes: svn path=/head/; revision=357973
* Provide support for fdevname(3) on linuxkpi-backed devices.Konstantin Belousov2020-01-281-1/+20
| | | | | | | | | | | Reported and tested by: manu Reviewed by: hselasky, manu Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23386 Notes: svn path=/head/; revision=357198
* Handle a NULL thread pointer in linux_close_file().Mark Johnston2020-01-151-0/+3
| | | | | | | | | | | | | | | This can happen if a file is closed during unix socket GC. The same bug was fixed for devfs descriptors in r228361. PR: 242913 Reported and tested by: iz-rpi03@hs-karlsruhe.de Reviewed by: hselasky, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23178 Notes: svn path=/head/; revision=356760
* Code must not unlock a mutex while owning the thread lock.Konstantin Belousov2020-01-131-2/+1
| | | | | | | | | | Reviewed by: hselasky, markj Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23150 Notes: svn path=/head/; revision=356682
* vfs: drop the mostly unused flags argument from VOP_UNLOCKMateusz Guzik2020-01-031-1/+1
| | | | | | | | | | | Filesystems which want to use it in limited capacity can employ the VOP_UNLOCK_FLAGS macro. Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D21427 Notes: svn path=/head/; revision=356337
* Make page busy state deterministic on free. Pages must be xbusy whenJeff Roberson2019-12-221-4/+1
| | | | | | | | | | | | | | | | | | | removed from objects including calls to free. Pages must not be xbusy when freed and not on an object. Strengthen assertions to match these expectations. In practice very little code had to change busy handling to meet these rules but we can now make stronger guarantees to busy holders and avoid conditionally dropping busy in free. Refine vm_page_remove() and vm_page_replace() semantics now that we have stronger guarantees about busy state. This removes redundant and potentially problematic code that has proliferated. Discussed with: markj Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22822 Notes: svn path=/head/; revision=356002
* Restore important comment in RCU/EPOCH support in FreeBSD after r355784.Hans Petter Selasky2019-12-181-0/+9
| | | | | | | Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=355879
* schedlock 4/4Jeff Roberson2019-12-151-9/+1
| | | | | | | | | | | | | | | | | | | | | Don't hold the scheduler lock while doing context switches. Instead we unlock after selecting the new thread and switch within a spinlock section leaving interrupts and preemption disabled to prevent local concurrency. This means that mi_switch() is entered with the thread locked but returns without. This dramatically simplifies scheduler locking because we will not hold the schedlock while spinning on blocked lock in switch. This change has not been made to 4BSD but in principle it would be more straightforward. Discussed with: markj Reviewed by: kib Tested by: pho Differential Revision: https://reviews.freebsd.org/D22778 Notes: svn path=/head/; revision=355784
* schedlock 1/4Jeff Roberson2019-12-151-1/+0
| | | | | | | | | | | | | | | Eliminate recursion from most thread_lock consumers. Return from sched_add() without the thread_lock held. This eliminates unnecessary atomics and lock word loads as well as reducing the hold time for scheduler locks. This will eventually allow for lockless remote adds. Discussed with: kib Reviewed by: jhb Tested by: pho Differential Revision: https://reviews.freebsd.org/D22626 Notes: svn path=/head/; revision=355779
* Add missing M_NOWAIT flagRyan Stone2019-10-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | The LinuxKPI linux_dma code calls PCTRIE_INSERT with a mutex held, but does not set M_NOWAIT when allocating nodes, leading to a potential panic. All of this code can handle an allocation failure here, so prefer an allocation failure to sleeping on memory. Also fix a related case where NOWAIT/WAITOK was not specified. In this case it's not clear whether sleeping is allowed so be conservative and assume not. There are a lot of other paths in this code that can fail due to a lack of memory anyway. Differential Revision: https://reviews.freebsd.org/D22127 Reviewed by: imp Sponsored by: Dell EMC Isilon MFC After: 1 week Notes: svn path=/head/; revision=353938
* (4/6) Protect page valid with the busy lock.Jeff Roberson2019-10-151-1/+1
| | | | | | | | | | | | | | Atomics are used for page busy and valid state when the shared busy is held. The details of the locking protocol and valid and dirty synchronization are in the updated vm_page.h comments. Reviewed by: kib, markj Tested by: pho Sponsored by: Netflix, Intel Differential Revision: https://reviews.freebsd.org/D21594 Notes: svn path=/head/; revision=353539
* Use true and false when dealing with bool type in the LinuxKPI.Hans Petter Selasky2019-09-111-19/+19
| | | | | | | | | | No functional change. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=352207
* Fix synchronous work drain issue in the LinuxKPI.Hans Petter Selasky2019-09-111-10/+15
| | | | | | | | | | | A work callback may restart itself. Loop in the drain function to see if the work has been rescheduled and stop the subsequent reschedules, if any. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=352206
* Replace redundant code with a few new vm_page_grab facilities:Jeff Roberson2019-09-101-20/+4
| | | | | | | | | | | | | | - VM_ALLOC_NOCREAT will grab without creating a page. - vm_page_grab_valid() will grab and page in if necessary. - vm_page_busy_acquire() automates some busy acquire loops. Discussed with: alc, kib, markj Tested by: pho (part of larger branch) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21546 Notes: svn path=/head/; revision=352176
* Change synchonization rules for vm_page reference counting.Mark Johnston2019-09-092-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several mechanisms by which a vm_page reference is held, preventing the page from being freed back to the page allocator. In particular, holding the page's object lock is sufficient to prevent the page from being freed; holding the busy lock or a wiring is sufficent as well. These references are protected by the page lock, which must therefore be acquired for many per-page operations. This results in false sharing since the page locks are external to the vm_page structures themselves and each lock protects multiple structures. Transition to using an atomically updated per-page reference counter. The object's reference is counted using a flag bit in the counter. A second flag bit is used to atomically block new references via pmap_extract_and_hold() while removing managed mappings of a page. Thus, the reference count of a page is guaranteed not to increase if the page is unbusied, unmapped, and the object's write lock is held. As a consequence of this, the page lock no longer protects a page's identity; operations which move pages between objects are now synchronized solely by the objects' locks. The vm_page_wire() and vm_page_unwire() KPIs are changed. The former requires that either the object lock or the busy lock is held. The latter no longer has a return value and may free the page if it releases the last reference to that page. vm_page_unwire_noq() behaves the same as before; the caller is responsible for checking its return value and freeing or enqueuing the page as appropriate. vm_page_wire_mapped() is introduced for use in pmap_extract_and_hold(). It fails if the page is concurrently being unmapped, typically triggering a fallback to the fault handler. vm_page_wire() no longer requires the page lock and vm_page_unwire() now internally acquires the page lock when releasing the last wiring of a page (since the page lock still protects a page's queue state). In particular, synchronization details are no longer leaked into the caller. The change excises the page lock from several frequently executed code paths. In particular, vm_object_terminate() no longer bounces between page locks as it releases an object's pages, and direct I/O and sendfile(SF_NOCACHE) completions no longer require the page lock. In these latter cases we now get linear scalability in the common scenario where different threads are operating on different files. __FreeBSD_version is bumped. The DRM ports have been updated to accomodate the KPI changes. Reviewed by: jeff (earlier version) Tested by: gallatin (earlier version), pho Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20486 Notes: svn path=/head/; revision=352110
* Fix 32-bit build again, post r350570.Justin Hibbits2019-08-041-1/+1
| | | | | | | | Missed this part with my testing as well. Pass the right type to BUS_TRANSLATE_RESOURCE(). Notes: svn path=/head/; revision=350573
* Fix 32-bit build post-r350570Justin Hibbits2019-08-041-2/+2
| | | | | | | | The error message prints a rman_res_t, which is an uintmax_t. Explicitly cast, just for future-proofing, and use the correct format. Notes: svn path=/head/; revision=350572
* Add necessary bits for Linux KPI to work correctly on powerpcJustin Hibbits2019-08-041-3/+32
| | | | | | | | | | | | | | | | | | | | | PowerPC, and possibly other architectures, use different address ranges for PCI space vs physical address space, which is only mapped at resource activation time, when the BAR gets written. The DRM kernel modules do not activate the rman resources, soas not to waste KVA, instead only mapping parts of the PCI memory at a time. This introduces a BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI driver, to perform this necessary translation without activating the resource. In addition to system KPI changes, LinuxKPI is updated to handle a big-endian host, by adding proper endian swaps to the I/O functions. Submitted by: mmacy Reported by: hselasky Differential Revision: https://reviews.freebsd.org/D21096 Notes: svn path=/head/; revision=350570
* Merge the vm_page hold and wire mechanisms.Mark Johnston2019-07-081-18/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The hold_count and wire_count fields of struct vm_page are separate reference counters with similar semantics. The remaining essential differences are that holds are not counted as a reference with respect to LRU, and holds have an implicit free-on-last unhold semantic whereas vm_page_unwire() callers must explicitly determine whether to free the page once the last reference to the page is released. This change removes the KPIs which directly manipulate hold_count. Functions such as vm_fault_quick_hold_pages() now return wired pages instead. Since r328977 the overhead of maintaining LRU for wired pages is lower, and in many cases vm_fault_quick_hold_pages() callers would swap holds for wirings on the returned pages anyway, so with this change we remove a number of page lock acquisitions. No functional change is intended. __FreeBSD_version is bumped. Reviewed by: alc, kib Discussed with: jeff Discussed with: jhb, np (cxgbe) Tested by: pho (previous version) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D19247 Notes: svn path=/head/; revision=349846
* Remove dead code added after r348743 in the LinuxKPI. TheHans Petter Selasky2019-07-031-4/+0
| | | | | | | | | | | | | LINUXKPI_VERSION macro is not defined for any compiled LinuxKPI code which basically means __GFP_NOTWIRED is never checked when allocating pages. This should work fine with the existing external DRM code as long as the page wiring and unwiring is balanced. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=349645