Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Mar 2009 16:38:59 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        cvs-src-old@freebsd.org
Subject:   cvs commit: src/sys/dev/pci pci.c pci_private.h
Message-ID:  <200903031734.n23HYLRe095264@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
jhb         2009-03-03 16:38:59 UTC

  FreeBSD src repository

  Modified files:
    sys/dev/pci          pci.c pci_private.h 
  Log:
  SVN rev 189306 on 2009-03-03 16:38:59Z by jhb
  
  Further refine the handling of resources for BARs in the PCI bus driver.
  
  A while back, Warner changed the PCI bus code to reserve resources when
  enumerating devices and simply give devices the previously allocated
  resources when they call bus_alloc_resource().  This ensures that address
  ranges being decoded by a BAR are always allocated in the nexus0 device
  (or whatever device the PCI bus gets its address space from) even if a
  device driver is not attached to the device.  This patch extends this
  behavior further:
  - To let the PCI bus distinguish between a resource being allocated by
    a device driver vs. merely being allocated by the bus, use
    rman_set_device() to assign the device to the bus when it is owned
    by the bus and to the child device when it is allocated by the child
    device's driver.  We can now prevent a device driver from allocating
    the same device twice.  Doing so could result in odd things like
    allocating duplicate virtual memory to map the resource on some
    archs and leaking the original mapping.
  - When a PCI device driver releases a resource, don't pass the request
    all the way up the tree and release it in the nexus (or similar device)
    since the BAR is still active and decoding.  Otherwise, another device
    could later allocate the same range even though it is still in use.
    Instead, deactivate the resource and assign it back to the PCI bus
    using rman_set_device().
  - pci_delete_resource() will actually completely free a BAR including
    attemping to disable it.
  - Disable BAR decoding via the command register when sizing a BAR in
    pci_alloc_map() which is used to allocate resources for a BAR when
    the BIOS/firmware did not assign a usable resource range during boot.
    This mirrors an earlier fix to pci_add_map() which is used when to
    size BARs during boot.
  - Move the activation of I/O decoding in the PCI command register into
    pci_activate_resource() instead of doing it in pci_alloc_resource().
    Previously we could actually enable decoding before a BAR was
    initialized via pci_alloc_map().
  
  Glanced at by:  bsdimp
  
  Revision  Changes    Path
  1.371     +163 -82   src/sys/dev/pci/pci.c
  1.26      +4 -0      src/sys/dev/pci/pci_private.h



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903031734.n23HYLRe095264>