1. 23 Mar, 2021 2 commits
    • Hans Petter Selasky's avatar
      MFC dfb33cb0: · af3a80bc
      Hans Petter Selasky authored
      Allocating the LinuxKPI current structure from a software interrupt thread
      must be done using the M_NOWAIT flag after 1ae20f7c .
      
      Sponsored by:	Mellanox Technologies // NVIDIA Networking
      
      (cherry picked from commit dfb33cb0)
      af3a80bc
    • Hans Petter Selasky's avatar
      MFC d1cbe790: · eab581fa
      Hans Petter Selasky authored
      Allocating the LinuxKPI current structure from an interrupt thread must be
      done using the M_NOWAIT flag after 1ae20f7c .
      
      Sponsored by:	Mellanox Technologies // NVIDIA Networking
      
      (cherry picked from commit d1cbe790)
      eab581fa
  2. 24 Aug, 2020 2 commits
    • Emmanuel Vadot's avatar
      MFC r363564-r363567, r363575, r363835-r363837, r363842-r363843, r364232 · d7675392
      Emmanuel Vadot authored
      r363564:
      linuxkpi: Include linux/sizes.h in dma-mapping.h
      
      Linux does the same, this avoids ifdef or extra includes in ported drivers.
      
      Reviewed by:	emaste, hselasky
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D25701
      
      r363565:
      linuxkpi: Include hardirq.h in preempt.h and lockdep.h in hardirq.h
      
      Linux does the same, this avoids ifdef or extra includes in ported drivers.
      
      Reviewed by:	emaste, hselasky
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D25702
      
      r363566:
      linuxkpi: Add taint* defines
      
      This isn't used for us but allow us to port drivers more easily.
      
      Reviewed by:	hselasky
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D25703
      
      r363567:
      Revert r363564
      
      linux/sizes.h doesn't exists in base ... sorry.
      
      r363575:
      Fix r363565
      
      lockdep.h needs sys/lock.h for LOCK_CLASS
      
      r363835:
      linuxkpi: Add linux/sizes.h
      
      This file contain some defines for common sizes.
      
      Sponsored-by: The FreeBSD Foundation
      Reviewed by:	hselasky, emaste
      Differential Revision:	https://reviews.freebsd.org/D25941
      
      r363836:
      linuxkpi: Add kref_put_lock
      
      Same as kref_put but in addition to calling the rel function it will
      acquire the lock first.
      
      Sponsored by: The FreeBSD Foundation
      Reviewed by:	hselasky, emaste
      Differential Revision:	https://reviews.freebsd.org/D25942
      
      r363837:
      linuxkpi: Add nested variant of mutex_lock_interruptible
      
      We don't do anything with the _nesteds variant so just call mutex_lock_interruptible
      
      Sponsoredby: The FreeBSD Foundation
      Reviewed by:	hselasky
      Differential Revision:	https://reviews.freebsd.org/D25944
      
      r363842:
      linuxkpi: Add clear_bit_unlock
      
      This calls clear_bit and adds a memory barrier.
      
      Sponsored by: The FreeBSD Foundation
      
      Reviewed by:	hselasky
      Differential Revision:	https://reviews.freebsd.org/D25943
      
      r363843:
      linuxkpi: Add time_after32 and time_before32
      
      This compare two 32 bits times
      
      Sponsored by: The FreeBSD Foundation
      Reviewed by:	kib, hselasky
      Differential Revision:	https://reviews.freebsd.org/D25700
      
      r364232:
      linuxkpi: Add a few wait_bit functions
      
      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
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D26054
      d7675392
    • Emmanuel Vadot's avatar
      MFC r361450, r361452, r361550-r361551 · e9a73cd8
      Emmanuel Vadot authored
      r361450:
      linuxkpi: Add refcount.h
      
      Implement some refcount functions needed by drm.
      Just use the atomic_t struct and functions from linuxkpi for simplicity.
      
      Sponsored-by: The FreeBSD Foundation
      
      Reviewed by:	hselsasky
      Differential Revision:	https://reviews.freebsd.org/D24985
      
      r361452:
      linuxkpi: Fix mod_timer and del_timer_sync
      
      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
      
      r361550:
      linuxkpi: Add rcu_swap_protected
      
      This macros swap an rcu pointer with a normal pointer.
      The condition only seems to be used for debug/warning under linux, ignore
      for now.
      
      Sponsored-by: The FreeBSD Foundation
      Reviewed by:	hselasky
      Differential Revision:	https://reviews.freebsd.org/D24954
      
      r361551:
      linuxkpi: Add kstrtou16
      
      This function convert a char * to a u16.
      Simply use strtoul and cast to compare for ERANGE
      
      Sponsored-by: The FreeBSD Foundation
      Reviewed by:	hselasky
      Differential Revision:	https://reviews.freebsd.org/D24996
      e9a73cd8
  3. 18 May, 2020 1 commit
    • Hans Petter Selasky's avatar
      MFC r360621: · da4f635a
      Hans Petter Selasky authored
      Fix warning about sleeping with non-sleepable lock when allocating
      "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@
      Sponsored by:	Mellanox Technologies
      da4f635a
  4. 11 Mar, 2020 1 commit
    • Hans Petter Selasky's avatar
      MFC r358586: · 2ba6df8f
      Hans Petter Selasky authored
      When closing a LinuxKPI file always use the real release function to avoid
      resource leakage when destroying a LinuxKPI character device.
      
      Submitted by:	Andrew Boyer <aboyer@pensando.io>
      Reviewed by:	kib@
      PR:		244572
      Sponsored by:	Mellanox Technologies
      2ba6df8f
  5. 06 Mar, 2020 1 commit
    • Hans Petter Selasky's avatar
      MFC r358387: · d0884c91
      Hans Petter Selasky authored
      Extend the range of the return value from nsecs_to_jiffies64() to support
      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
      Sponsored by:	Mellanox Technologies
      d0884c91
  6. 04 Feb, 2020 1 commit
    • Konstantin Belousov's avatar
      MFC r357198: · 41a1e965
      Konstantin Belousov authored
      Provide support for fdevname(3) on linuxkpi-backed devices.
      
      For merge, compat32 support was left out.  It is not yet present for
      FIODGNAME over native cdevs yet.
      
      Sponsored by:	Mellanox Technologies
      41a1e965
  7. 22 Jan, 2020 1 commit
    • Mark Johnston's avatar
      MFC r356760: · af5fc972
      Mark Johnston authored
      Handle a NULL thread pointer in linux_close_file().
      
      PR:	242913
      af5fc972
  8. 16 Sep, 2019 1 commit
  9. 24 May, 2019 1 commit
    • Johannes Lundberg's avatar
      MFC r347837: · b41edba3
      Johannes Lundberg authored
      LinuxKPI: Update access_ok macro for v5.0.
      
      Check LINUXKPI_VERSION macro for backwards compatibility.
      It's recommended to update any drivers that depend on the older KPI
      so we can deprecate < 5.0 code as we update to newer Linux version.
      This patch is part of D19565
      
      Reviewed by:	hps
      Approved by:	imp (mentor), hps
      b41edba3
  10. 21 May, 2019 1 commit
  11. 16 May, 2019 1 commit
    • Hans Petter Selasky's avatar
      MFC r347185: · 19219230
      Hans Petter Selasky authored
      Allow controlling pr_debug at runtime in the LinuxKPI.
      
      Turning on pr_debug at compile time make it non-optional at runtime.
      This often means that the amount of the debugging is unbearable.
      Allow developer to turn on pr_debug output only when needed.
      
      Build tested drm-current-kmod prior to commit.
      
      Submitted by:		kib@
      Sponsored by:		Mellanox Technologies
      19219230
  12. 02 May, 2019 1 commit
    • Johannes Lundberg's avatar
      MFC r346712: · 5a96a3e6
      Johannes Lundberg authored
      Don't call cdev_init where cdev_alloc is called. cdev_alloc already
      handles initialization.
      
      Reviewed by:	hps
      Approved by:	imp (mentor)
      5a96a3e6
  13. 06 Jan, 2019 3 commits
  14. 12 Dec, 2018 1 commit
    • Hans Petter Selasky's avatar
      MFC r341518: · 113c9572
      Hans Petter Selasky authored
      linuxkpi: Fix for use-after-free when tearing down character devices.
      
      Make sure we hold a reference on the character device for every opened file
      to prevent the character device to be freed prematurely.
      
      Sponsored by:   Mellanox Technologies
      113c9572
  15. 10 Dec, 2018 1 commit
  16. 01 Nov, 2018 1 commit
    • Hans Petter Selasky's avatar
      MFC r339924: · 711db39f
      Hans Petter Selasky authored
      Implement the dump_stack() function in the LinuxKPI.
      
      Approved by:		re (gjb)
      Submitted by:		Johannes Lundberg <johalun0@gmail.com>
      Sponsored by:		Mellanox Technologies
      711db39f
  17. 30 Mar, 2018 1 commit
    • Hans Petter Selasky's avatar
      Optimise use of Giant in the LinuxKPI. · 4b706099
      Hans Petter Selasky authored
      - Make sure Giant is locked when calling PCI device methods.
      Newbus currently requires this.
      
      - Avoid unlocking Giant right before aquiring the sleepqueue lock.
      This can save a task switch.
      
      MFC after:	1 week
      Sponsored by:	Mellanox Technologies
      4b706099
  18. 23 Mar, 2018 1 commit
  19. 09 Mar, 2018 1 commit
    • Hans Petter Selasky's avatar
      Implement proper support for complete_all() in the LinuxKPI. · be15e133
      Hans Petter Selasky authored
      When complete_all() is called there might be multiple waiters. The
      current implementation could only handle one waiter. Make sure the
      completion is sticky when complete_all() is called to be compatible
      with Linux.
      
      Found by:	Johannes Lundberg <johalun0@gmail.com>
      MFC after:	1 week
      Sponsored by:	Mellanox Technologies
      Sponsored by:	Limelight Networks
      be15e133
  20. 02 Mar, 2018 1 commit
  21. 22 Feb, 2018 1 commit
    • Hans Petter Selasky's avatar
      Return correct error code to user-space when a system call receives a · 94944062
      Hans Petter Selasky authored
      signal in the LinuxKPI.
      
      The read(), write() and mmap() system calls can return either EINTR or
      ERESTART upon receiving a signal. Add code to figure out the correct
      return value by temporarily storing the return code from the relevant
      FreeBSD kernel APIs in the Linux task structure.
      
      MFC after:	3 days
      Sponsored by:	Mellanox Technologies
      94944062
  22. 18 Feb, 2018 1 commit
  23. 01 Feb, 2018 2 commits
  24. 26 Jan, 2018 1 commit
    • Hans Petter Selasky's avatar
      Decouple Linux files from the belonging character device right after open · e23ae408
      Hans Petter Selasky authored
      in the LinuxKPI. This is done by calling finit() just before returning a magic
      value of ENXIO in the "linux_dev_fdopen" function.
      
      The Linux file structure should mimic the BSD file structure as much as
      possible. This patch decouples the Linux file structure from the belonging
      character device right after the "linux_dev_fdopen" function has returned.
      This fixes an issue which allows a Linux file handle to exist after a
      character device has been destroyed and removed from the directory index
      of /dev. Only when the reference count of the BSD file handle reaches zero,
      the Linux file handle is destroyed. This fixes use-after-free issues related
      to accessing the Linux file structure after the character device has been
      destroyed.
      
      While at it add a missing NULL check for non-present file operation.
      Calling a NULL pointer will result in a segmentation fault.
      
      Reviewed by:	kib @
      MFC after:	1 week
      Sponsored by:	Mellanox Technologies
      e23ae408
  25. 13 Nov, 2017 1 commit
  26. 03 Nov, 2017 1 commit
    • Hans Petter Selasky's avatar
      Remove redundant dev->si_drv1 NULL checks in the LinuxKPI. · 8ead3a99
      Hans Petter Selasky authored
      This pointer is checked during the linux_dev_open() callback and does
      not need to be NULL checked again. It should always be set for
      character devices belonging to the "linuxcdevsw" and technically
      there is no need to NULL check this pointer at all.
      
      Suggested by:	kib @
      MFC after:	1 week
      Sponsored by:	Mellanox Technologies
      8ead3a99
  27. 13 Oct, 2017 1 commit
  28. 22 Sep, 2017 1 commit
  29. 09 Sep, 2017 1 commit
    • Hans Petter Selasky's avatar
      Properly implement poll_wait() in the LinuxKPI. This prevents direct · 6dec7efa
      Hans Petter Selasky authored
      use of the linux_poll_wakeup() function from unsafe contexts, which
      can lead to use-after-free issues.
      
      Instead of calling linux_poll_wakeup() directly use the wake_up()
      family of functions in the LinuxKPI to do this.
      
      Bump the FreeBSD version to force recompilation of external kernel modules.
      
      MFC after:		1 week
      Sponsored by:		Mellanox Technologies
      6dec7efa
  30. 11 Aug, 2017 1 commit
  31. 10 Aug, 2017 1 commit
  32. 02 Aug, 2017 1 commit
  33. 08 Jul, 2017 1 commit
  34. 07 Jul, 2017 1 commit
    • Hans Petter Selasky's avatar
      Complete r320189 which allows a NULL VM fault handler in the LinuxKPI. · 61157228
      Hans Petter Selasky authored
      Instead of mapping a dummy page upon a page fault, map the page
      pointed to by the physical address given by IDX_TO_OFF(vmap->vm_pfn).
      To simplify the implementation use OBJT_DEVICE to implement our own
      linux_cdev_pager_fault() instead of using the existing
      linux_cdev_pager_populate().
      
      Some minor code factoring while at it.
      
      Reviewed by:	markj @
      MFC after:	1 week
      Sponsored by:	Mellanox Technologies
      61157228
  35. 21 Jun, 2017 1 commit