1. 30 Nov, 2021 1 commit
    • Warner Losh's avatar
      Make device_busy/unbusy work w/o Giant held · 08e78191
      Warner Losh authored
      The vast majority of the busy/unbusy users in the tree don't acquire Giant
      before calling device_busy/unbusy. However, if multiple threads are opening a
      file, say, that causes the device to busy/unbusy, then we can race to the root
      marking things busy. Create a new device_busy_locked and device_unbusy_locked
      that are the current implemntations of device_busy and device_unbusy. Make
      device_busy and unbusy acquire Giant before calling the _locked versrions. Since
      we never sleep in the busy/unbusy path, Giant's single threaded semantics
      suffice to keep this safe.
      
      Sponsored by:		Netflix
      Reviewed by:		hselasky, jhb
      Differential Revision:	https://reviews.freebsd.org/D26284
      08e78191
  2. 15 Nov, 2021 1 commit
    • Mark Johnston's avatar
      bus: Make BUS_TRANSLATE_RESOURCE behave more like other bus methods · 1fb99e97
      Mark Johnston authored
      - Return an errno value upon failure, instead of 1.
      - Provide a bus_translate_resource() wrapper.
      - Implement the generic version, which traverses the hierarchy until a
        bus driver with a non-trivial implementation is found, in subr_bus.c
        like other similar default implementations.
      - Make ofw_pcib_translate_resource() return an error if a matching PCI
        address range is not found.
      - Make generic_pcie_translate_resource_common() return an int instead of
        a bool.  Fix up callers.
      
      No functional change intended.
      
      Reviewed by:	imp, jhb
      MFC after:	2 weeks
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D32855
      1fb99e97
  3. 25 Sep, 2021 1 commit
    • Alexander Motin's avatar
      bus: Cleanup device_probe_child() · f73c2bbf
      Alexander Motin authored
      When device driver probe method returns 0, i.e. absolute priority, do
      not remove its class from the device just to set it back few lines
      later, that may change the device unit number, etc. and after which
      we'd better call the probe again.
      
      If during search we found some driver with absolute priority, we do
      not need to set device driver and class since we haven't removed them
      before.
      
      It should not happen, but if second probe method call failed, remove
      the driver and possibly the class from the device as it was when we
      started.
      
      Reviewed by:	imp, jhb
      Differential Revision:	https://reviews.freebsd.org/D32125
      f73c2bbf
  4. 24 Sep, 2021 2 commits
    • Warner Losh's avatar
      bus: Fix LINT / BUS_DEBUG build · 67a9e76d
      Warner Losh authored
      Fix 0389e9be for LINT built. Removed an arg only from code
      under BUS_DEBUG w/o rebuilding LINT...
      
      Sponsored by:		Netflix
      Fixes: 0389e9be
      67a9e76d
    • Warner Losh's avatar
      bus: retire DF_REBID · 0389e9be
      Warner Losh authored
      I did DF_REBID to allow for 'hoover' drivers that would attach to
      otherwise unattached devices in the tree. This notion didn't catch on as
      it was tricky to make work well and it was easier to just publish a /dev
      node of some flavor by the parent device. It's been nothing but dead
      weight for a long time.
      
      Reviewed by:		mav
      Sponsored by:		Netflix
      Differential Revision:	https://reviews.freebsd.org/D32056
      0389e9be
  5. 22 Sep, 2021 1 commit
  6. 20 Sep, 2021 1 commit
  7. 02 Aug, 2021 1 commit
  8. 23 Jun, 2021 1 commit
    • Warner Losh's avatar
      newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf · ddfc9c4c
      Warner Losh authored
      Now that the upper layers all go through a layer to tie into these
      information functions that translates an sbuf into char * and len. The
      current interface suffers issues of what to do in cases of truncation,
      etc. Instead, migrate all these functions to using struct sbuf and these
      issues go away. The caller is also in charge of any memory allocation
      and/or expansion that's needed during this process.
      
      Create a bus_generic_child_{pnpinfo,location} and make it default. It
      just returns success. This is for those busses that have no information
      for these items. Migrate the now-empty routines to using this as
      appropriate.
      
      Document these new interfaces with man pages, and oversight from before.
      
      Reviewed by:		jhb, bcr
      Sponsored by:		Netflix
      Differential Revision:	https://reviews.freebsd.org/D29937
      ddfc9c4c
  9. 21 Apr, 2021 1 commit
  10. 12 Apr, 2021 2 commits
    • Mark Johnston's avatar
      Rename struct device to struct _device · dfff3776
      Mark Johnston authored
      types.h defines device_t as a typedef of struct device *.  struct device
      is defined in subr_bus.c and almost all of the kernel uses device_t.
      The LinuxKPI also defines a struct device, so type confusion can occur.
      
      This causes bugs and ambiguity for debugging tools.  Rename the FreeBSD
      struct device to struct _device.
      
      Reviewed by:	gbe (man pages)
      Reviewed by:	rpokala, imp, jhb
      MFC after:	1 week
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D29676
      dfff3776
    • Andrew Turner's avatar
      Create VM_MEMATTR_DEVICE on all architectures · 5d2d599d
      Andrew Turner authored
      This is intended to be used with memory mapped IO, e.g. from
      bus_space_map with no flags, or pmap_mapdev.
      
      Use this new memory type in the map request configured by
      resource_init_map_request, and in pciconf.
      
      Reviewed by:	kib
      Differential Revision:	https://reviews.freebsd.org/D29692
      5d2d599d
  11. 22 Mar, 2021 1 commit
  12. 20 Jan, 2021 1 commit
  13. 12 Oct, 2020 1 commit
    • Warner Losh's avatar
      newbus: use ssize_t to match sb's len and size, fix ordering of space check · e59db468
      Warner Losh authored
      Both s_len and s_size are ssize_t, so their differece is also more
      properly a ssize_t not a size_t. Also, assert that len is <= size when
      we enter. This should always be the case. Ensure that we have that one
      byte that we write to the end of the buffer before we do so, though
      the error should already be set on the buffer if not, and the only
      times we supply 'partial' buffers they should be plenty large.
      
      Reviewed by: cem, jhb (prior version, I did cem's suggestion)
      Differential Revsion: https://reviews.freebsd.org/D26752
      e59db468
  14. 17 Sep, 2020 1 commit
    • Warner Losh's avatar
      Move to a more robust and conservative alloation scheme for devctl messages · fd0a41d2
      Warner Losh authored
      Change the zone setup:
      - Allow slabs to be returned to the OS
      - Set the number of slots to the max devctl will queue before discarding
      - Reserve 2% of the max (capped at 100) for low memory allocations
      - Disable per-cpu caching since we don't need it and we avoid some pathologies
      
      Change the alloation strategiy a bit:
      - If a normal allocation fails, try to get the reserve
      - If a reserve allocation fails, re-use the oldest-queued entry for storage
      - If there's a weird race/failure and nothing on the queue to steal, return NULL
      
      This addresses two main issues in the old code:
      - If devd had died, and we're generating a lot of messages, we have an
        unbounded leak. This new scheme avoids the issue that lead to this.
      - The MPASS that was 'sure' the allocation couldn't have failed turned out
        to be wrong in some rare cases. The new code doesn't make this assumption.
      
      Since we reserve only 2% of the space, we go from about 1MB of
      allocation all the time to more like 50kB for the reserve.
      
      Reviewed by: markj@
      Differential Revision: https://reviews.freebsd.org/D26448
      fd0a41d2
  15. 16 Sep, 2020 1 commit
  16. 01 Sep, 2020 1 commit
  17. 29 Aug, 2020 6 commits
    • Warner Losh's avatar
      We don't need to INCLUDENUL, so turn it off to avoid assertion... · f6c941f3
      Warner Losh authored
      sbuf_new_for_sysctl turns on INCLUDENUL, but we don't need it. And we assert for
      it in the new bus_pnpinfo_sb and bus_location_sb strings.
      f6c941f3
    • Warner Losh's avatar
      Use sbuf_cat instead of sbuf_cpy · 6dd5b77a
      Warner Losh authored
      sbuf_cpy doesn't work with sysctl sbufs because of the drain function.
      6dd5b77a
    • Warner Losh's avatar
      Avoid NULL pointer dereferences · 5eade881
      Warner Losh authored
      Add back NULL pointer checks accidentally dropped in r364946. We need
      to append a NUL character when that happens.
      5eade881
    • Warner Losh's avatar
      Move to using sbuf for some sysctl in newbus · 17c219fd
      Warner Losh authored
      Convert two different sysctl to using sbuf. First, for all the default
      sysctls we implement for each device driver that's attached. This is a
      pure sbuf conversion.
      
      Second, convert sysctl_devices to fill its buffer with sbuf rather
      than a hand-rolled crappy thing I wrote years ago.
      
      Reviewed by: cem, markj
      Differential Revision: https://reviews.freebsd.org/D26206
      17c219fd
    • Warner Losh's avatar
      Retire devctl_notify_f() · 887611b1
      Warner Losh authored
      devctl_notify_f isn't needed, so retire it. The flags argument is now
      unused, so rather than keep it around, retire it. Convert all old
      users of it to devctl_notify(). This path no longer sleeps, so is safe
      to call from any context. Since it doesn't sleep, it doesn't need to
      know if it is OK to sleep or not.
      
      Reviewed by: markj@
      Differential Revision: https://reviews.freebsd.org/D26140
      887611b1
    • Warner Losh's avatar
      devctl: move to using a uma zone · bca8f35f
      Warner Losh authored
      Convert the memory management of devctl.  Rewrite if to make better
      use of memory. This eliminates several mallocs (5? worse case) needed
      to send a message. It's now possible to always send a message, though
      if things are really backed up the oldest message will be dropped to
      free up space for the newest.
      
      Add a static bus_child_{location,pnpinfo}_sb to start migrating to
      sbuf instead of buffer + length. Use it in the new code.  Other code
      will be converted later (bus_child_*_str is only used inside of
      subr_bus.c, though implemented in ~100 places in the tree).
      
      Reviewed by: markj@
      Differential Revision: https://reviews.freebsd.org/D26140
      bca8f35f
  18. 24 Aug, 2020 1 commit
    • Warner Losh's avatar
      Change the resume notification event from 'kern' to 'kernel' · f87655ec
      Warner Losh authored
      We have both a system of 'kern' and of 'kernel'. Prefer the latter and
      convert this notification to use 'kernel' instead of 'kern'. As a
      transition period, continue to also generate the 'kern' notification
      until sometime after FreeBSD 13 is branched.
      
      MFC After: 3 days
      f87655ec
  19. 23 Aug, 2020 1 commit
  20. 22 Aug, 2020 2 commits
  21. 20 Aug, 2020 2 commits
  22. 07 Aug, 2020 1 commit
  23. 04 Aug, 2020 1 commit
    • Mark Johnston's avatar
      Remove free_domain() and uma_zfree_domain(). · 96ad26ee
      Mark Johnston authored
      These functions were introduced before UMA started ensuring that freed
      memory gets placed in domain-local caches.  They no longer serve any
      purpose since UMA now provides their functionality by default.  Remove
      them to simplyify the kernel memory allocator interfaces a bit.
      
      Reviewed by:	cem, kib
      Sponsored by:	The FreeBSD Foundation
      Differential Revision:	https://reviews.freebsd.org/D25937
      96ad26ee
  24. 03 Aug, 2020 1 commit
  25. 18 Jun, 2020 1 commit
    • Pawel Biernacki's avatar
      hw.bus.info: rework handler · 049264c5
      Pawel Biernacki authored
      hw.bus.info was added in r68522 as a node, but there was never anything
      connected "behind" it.  Its only purpose is to return a struct u_businfo.
      The only in-base consumer are devinfo(3)/devinfo(8).
      Rewrite the handler as SYSCTL_PROC and mark it as MPSAFE and read-only
      as there never was a writable path.
      
      Reviewed by:	kib
      Approved by:	kib (mentor)
      Sponsored by:	Mysterious Code Ltd.
      Differential Revision:	https://reviews.freebsd.org/D25321
      049264c5
  26. 26 Feb, 2020 1 commit
    • Pawel Biernacki's avatar
      Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) · 7029da5c
      Pawel Biernacki authored
      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.
      
      Mark all obvious cases as MPSAFE.  All entries that haven't been marked
      as MPSAFE before are by default marked as NEEDGIANT
      
      Approved by:	kib (mentor, blanket)
      Commented by:	kib, gallatin, melifaro
      Differential Revision:	https://reviews.freebsd.org/D23718
      7029da5c
  27. 30 Jan, 2020 1 commit
  28. 14 Jan, 2020 1 commit
    • Ryan Libby's avatar
      malloc: remove assumptions about MINALLOCSIZE · 51871224
      Ryan Libby authored
      Remove assumptions about the minimum MINALLOCSIZE, in order to allow
      testing of smaller MINALLOCSIZE.  A following patch will lower the
      MINALLOCSIZE, but not so much that the present patch is required for
      correctness at these sites.
      
      Reviewed by:	jeff, markj
      Sponsored by:	Dell EMC Isilon
      51871224
  29. 26 Dec, 2019 1 commit
  30. 13 Dec, 2019 1 commit
  31. 12 Oct, 2019 1 commit
    • Alexander Motin's avatar
      Allocate device softc from the device domain. · a89a562b
      Alexander Motin authored
      Since we are trying to bind device interrupt threads to the device domain,
      it should have sense to make memory often accessed by them local. If domain
      is not known, fall back to round-robin.
      
      MFC after:	2 weeks
      Sponsored by:	iXsystems, Inc.
      a89a562b