1. 19 Jun, 2021 30 commits
  2. 18 Jun, 2021 10 commits
    • Bjoern A. Zeeb's avatar
      LinuxKPI: fix build after d4a4960c pci: "pcim" (managed) support · 5f88df77
      Bjoern A. Zeeb authored
      Fix a last minute change from d4a4960c
      based on review feedback in where a function now gets called before
      it is declared which did not fully get merged back to my commit branch.
      
      Noticed by:	CI, jkim
      MFC after:	10 days
      X-MFC with:	d4a4960c
      Sponsored-by:	The FreeBSD Foundation
      5f88df77
    • Bjoern A. Zeeb's avatar
      41dfd8bd
    • Bjoern A. Zeeb's avatar
      LinuxKPI: avoid userret: Returning with with pinned thread · 46ae23a4
      Bjoern A. Zeeb authored
      Some code manually calls local_bh_disable() and spin_lock() but
      then calls spin_unlock_bh() (or vice versa).
      Our code then calls local_bh_disable() again from spin_lock()
      which means we have the thread pin count increased twice and that
      means we get out of synch and are still pinned when returning to
      user space.
      
      Avoid this by adding the explicit local_bh_{enable,disable}() to
      the spin_[un]lock_bh() versions.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	2 weeks
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30711
      46ae23a4
    • Bjoern A. Zeeb's avatar
      LinuxKPI: fix sg_pcopy_from_buffer() · edfcdffe
      Bjoern A. Zeeb authored
      In sg_pcopy_from_buffer() is an error in that skip can underflow
      and lead to bogus page arithmetics which may lead to memory corruption
      or more likely panics.  Once we found a s/g page to copy into there
      is nothing to skip anymore so simply set skip to 0.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	5 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30676
      edfcdffe
    • Bjoern A. Zeeb's avatar
      LinuxKPI: pci: cleanup some code and add support for "pcim" (managed) · d4a4960c
      Bjoern A. Zeeb authored
      Restructure some code and add support for various "managed" versions
      for PCI resource management.
      This is beyond of what iwlwifi needs but some was found with other
      wireless drivers and it mostly all goes together.
      Add one FreeBSD sepcific feature returning the resource rather than
      the handle to allow us to use bus_*() functions in drivers directly.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	10 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30558
      d4a4960c
    • Bjoern A. Zeeb's avatar
      LinuxKPI: fix pci device devres initialisation · c3518147
      Bjoern A. Zeeb authored
      Given we are manually setting up the "device" in PCI in some cases,
      we need to initialise the list and lock for device devres here as well
      as otherwise we will panic on the uninitialised lock.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	5 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30681
      c3518147
    • Bjoern A. Zeeb's avatar
      LinuxKPI: enhance the irq KPI for managed and threaded operations. · d16b6cb1
      Bjoern A. Zeeb authored
      Move request_irq() to an internal function which serves request_irq()
      and the newly added request_threaded_irq() and devm_request_threaded_irq().
      Likewise factor out parts of free_irq() to also be used with
      devm_free_irq().  Add the storage and call to a thread_handler in case
      of IRQ_WAKE_THREAD.
      This is needed for the iwlwifi driver.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	10 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30549
      d16b6cb1
    • Bjoern A. Zeeb's avatar
      LinuxKPI: extend pci.h by various functions for wireless driver · 8e106c52
      Bjoern A. Zeeb authored
      Add dummy functions for dealing with "HotPlug" events which we currently
      do not support.
      
      Add pci_dev_get(), pci_find_ext_capability() and pci_pme_capable().
      
      The added pcie_find_root_port() is a bit special as we need to create
      another linux pci device;  for that make lkpinew_pci_dev() public
      which is also helpful for other cases when we want to use the Linux
      routines to check for device identifiers only and need a container
      for the "bsddev" to use natively.  This has proven to avoid basic
      checking code for the sake of rewriting it to native field names
      elsewhere.  Given we cache the newly created "root" we also need to
      make sure we clean it up.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	10 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30521
      8e106c52
    • Bjoern A. Zeeb's avatar
      LinuxKPI: add dmam_pool_create() support · 2afeed13
      Bjoern A. Zeeb authored
      dmam_pool_create() is a "managed" version of dma_pool_create() which
      will cleanup everything left when the device goes away using the
      devres framework.  For that add an internal cleanup function to be
      called from devres release.
      This is used by at least one wireless driver.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	10 days
      Reviewed by:	hselasky
      Differential Revision: https://reviews.freebsd.org/D30520
      2afeed13
    • Bjoern A. Zeeb's avatar
      LinuxKPI: add device_reprobe() and device_release_driver() · 644b4f11
      Bjoern A. Zeeb authored
      Add two new (though untested) functions to linux/device.h which are
      dealing with manually managing the device/driver and are used by
      at least one wireless driver.  We may have to re-fine them in the
      future.
      Move the devres declarations further up so they can be used earlier
      in the file.
      
      Sponsored by:	The FreeBSD Foundation
      MFC after:	10 days
      Reviewed by:	imp
      Differential Revision: https://reviews.freebsd.org/D30519
      644b4f11