Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/pci.c
RevisionDateAuthorComments
 1.168  23-Jun-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.
 1.167  20-May-2024  riastradh Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.
 1.166  20-May-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
 1.165  24-Aug-2022  riastradh branches: 1.165.4;
pmf(9): *_child_register never fails. Make it return void.

No kernel bump because this isn't documented or used in any modules,
only in dev/pci/pci.c and dev/cardbus/cardbus.c which are as far as I
know always statically linked into the kernel.

The next change, however, will require a revbump -- to make
pmf_device_register return void so we can prune vast swaths of dead
error branches.
 1.164  21-Jan-2022  thorpej Replace devhandle_invalidate(), which invalidates a devhandle, with
devhandle_invalid(), which returns an invalid devhandle.
 1.163  10-Oct-2021  msaitoh Use PCI-SIG official acronyms:

- RP stands for Root Port.
- RC stands for Root Complex.
- RCIEP stands for Root Complex Integrated End Point.
 1.162  15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.161  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.160  12-May-2021  thorpej branches: 1.160.4;
- Define a device call for PCI bus instances to fetch a direct child's
device handle given the device's device/function #s (extracted from
a pcitag_t). Use it to associate the handle with the child device
at config_found() time.
- Implement this device call for ACPI and OpenFirmware.
- Enable the OpenFirmware variant for evbarm FDT, macppc, ofppc, sparc64.
- Obsolete acpi_device_register(); it is no longer needed.
- Obsolete setting the OpenFirmware handle in PCI devices in the
sparc64 device_register(); it is no longer needed.
 1.159  24-Apr-2021  thorpej branches: 1.159.2; 1.159.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.158  29-Jan-2021  skrll branches: 1.158.2;
Trailing whitespace
 1.157  02-Feb-2020  jmcneill branches: 1.157.6;
pci_probe_device: make sure PCI_ID_REG returns valid data before touching
any other registers
 1.156  15-Oct-2019  jmcneill branches: 1.156.2;
PCIe downstream ports only have a single child device, so limit probing to
dev 0.
 1.155  14-Oct-2019  jmcneill The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.
 1.154  15-Dec-2018  msaitoh branches: 1.154.4;
Clearing PCI_PMCSR_PME_STS(W1C) bit is required to stop asserting PME#.
This change would prevent unexpected rebooting from shutdown -p or
unexpected resuming from suspend.
 1.153  01-Dec-2018  msaitoh Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe cababilities register, it's
required to check the existence of each register to not to write the next area.

This chagnge fixes a stability of suspend/resume.
 1.152  05-Apr-2017  msaitoh branches: 1.152.6; 1.152.12; 1.152.14;
IF PCIe's Alternative Routing-ID Interpretation (ARI) is enabled in a bridge,
all area under the bus should be checked in pci_enumerate_bus() to enumerate
all existing devices.

The similar code also be required for "pcictl pciN list". (not yet)
 1.151  23-Jan-2016  macallan branches: 1.151.2; 1.151.4;
add another special case so SM50x's framebuffer gets mapped with prefetching /
write combining enabled.
This needs to be generalized somewhere...
 1.150  02-Nov-2015  knakahara Add verbose messages when the kernel disables MSI/MSI-X.
 1.149  02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.148  24-Aug-2015  pooka add some _KERNEL_OPT as the finishing touch
 1.147  13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.146  27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.145  05-Sep-2014  matt branches: 1.145.2;
Don't use class or typename as a variable name.
 1.144  15-Sep-2013  martin Comment out a currently unused variable, but leave it around for debug/
documentation purposes.
 1.143  20-Oct-2012  matt branches: 1.143.2;
Add a __PCI_DEV_FUNCORDER hook.
 1.142  29-Aug-2011  jmcneill branches: 1.142.2; 1.142.12;
have pci register itself as a module, and make PCI driver modules depend on it
 1.141  24-Aug-2011  dyoung Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.140  17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.139  10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.138  05-Apr-2011  dyoung Lightly KNF. Changes to the generated assembly language appeared to
correspond to line numbers in KASSERT() statements.
 1.137  05-Apr-2011  macallan fix a typo
 1.136  04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.135  02-Mar-2011  matt When probing the PCI bars, make sure to only probe BARS (PPBs and PCB has
fewer bars than type 0 devices).
 1.134  27-Feb-2011  jmcneill follow the lead of genfb_pci and call pci_mapreg_probe before pci_mapreg_info
 1.133  24-Feb-2011  macallan add a hack to allow mapping the video memory portions of a mach64's aperture
with BUS_SPACE_MAP_PREFETCHABLE
This probably needs to go in its own function to avoid more clutter when adding
more hacks.
tested on macppc
 1.132  10-Feb-2011  jmcneill pcimmap: if the requested page is marked prefetchable in a child device's
BAR, pass the BUS_SPACE_MAP_PREFETCHABLE flag down to bus_space_mmap
 1.131  01-Feb-2011  dyoung During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.130  13-Nov-2010  uebayasi branches: 1.130.2; 1.130.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.129  06-Jun-2010  pgoyette Update pciverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.128  24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.127  24-Feb-2010  dyoung branches: 1.127.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.126  23-Feb-2010  dyoung Remove unused functions pci_disable_retry() and cardbus_disable_retry().
 1.125  08-Jan-2010  dyoung branches: 1.125.2;
Expand PMF_FN_* macros.
 1.124  19-Aug-2009  dyoung Since the intention in capturing a device's PCI Configuration Space
in pci_probe_device() is for pcidevdetached() to restore the device's
original PCI Configuration Space after it is detached, let's capture
a device's PCI configuration before attaching a driver to it instead
of after. Capturing the configuration after attaching is too late,
because a driver such as ath(4) may put a device to sleep promptly
after attaching it, and putting a PCI device to sleep often entails
changing PCI configuration from defaults.
 1.123  04-Jul-2009  cegger remove useless parenthesis
 1.122  02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.121  16-Dec-2008  christos branches: 1.121.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.120  16-Nov-2008  bouyer Do not depend on physmem for pci_dma64_available(). On some systems (e.g. Xen,
or any system with non-contigous physical memory), physmem may not represent
the hightest physical address available.
Discussed on tech-kern@ some weeks ago.
 1.119  19-Sep-2008  joerg branches: 1.119.2; 1.119.4;
Complain about devices with misaligned PCI capability pointers instead
of panicing. Christoph Schug reported that such a device is made by
Nvidia.
 1.118  12-Jun-2008  cegger branches: 1.118.2;
use device_lookup_private to get softc
 1.117  05-May-2008  dyoung branches: 1.117.2; 1.117.4;
Restore PCI devices to a state that is closer to the state that
NetBSD finds them in: save and restore power management state
(D0..D3) and PCI Configuration Registers 0x0 through 0x40 during
device attachment and detachment, respectively. Among other things,
this will fix sip(4) detachment and re-attachment.
 1.116  09-Apr-2008  dyoung branches: 1.116.2; 1.116.4;
Export some PCI autoconf routines for use by elansc(4), for example.
 1.115  23-Mar-2008  cube Split device_t and softc for pci(4).
 1.114  21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.113  28-Feb-2008  drochner Extend the pmf suspend/resume hooks by a shutdown method, so drivers
can register a shutdown handler explicitely.
Install a pci bus shutdown handler which disables bus master accesses
for all childs, so the drivers don't need to care.
This will hopefully be sufficient to replace the shutdownhooks
(together with the powerhooks). (It has been suggested to use some
general event notification framework for shutdown handlers, but there
might be cases where shutdown handlers must be run in an order following
the device hierarchy, which wouldn't be easy with event handlers
not tied to drivers.)
approved by David Young
 1.112  23-Feb-2008  dyoung Simplify the switch-statement in pci_set_powerstate_int(), and fix
a couple of typos so that it will work as I think that it was
intended to: delay for 10000us or 200us on transitions to/from D3
or D2 state, respectively. Discussed this with jmcneill@.
 1.111  21-Feb-2008  drochner -fix the delay logics in "set powerstate" for the cases that D2 or D3
are switched to (was harmless because we don't do D2 yet and also
don't (hmm - shouldn't) access devices in D3 (which would only make
sense if we'd support D3hot)
-zero the io/mem/master enable bits before entering D3
(The special handling of PCI_CLASS_DISPLAY devices is questionable
here -- we can't care about the console if we are seriously follow
the spec, and upstream bridges aren't considered anyway.)
-add exact references to the PCI PM spec
 1.110  28-Jan-2008  jmcneill branches: 1.110.2; 1.110.6;
PCI Power Management 1.2 says that system software should wait 10ms after
transitioning a device to or from D3hot, 200us to or from D2, and no wait
for D1 transitions. Update pci_set_powerstate_int to match the spec,
rather than naively waiting 1ms after every state transition.
 1.109  03-Jan-2008  dyoung Disable pci_disable_retry() and cardbus_disable_retry(), with a
long comment on pci_disable_retry() (cross-referenced at
cardbus_disable_retry()) that explains why.
 1.108  16-Dec-2007  dyoung Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
elansc0 at pci0
gpio0 at elansc0
cbb0 at pci0
cardslot0 at cbb0
cardbus0 at cardslot0
pcmcia0 at cardslot0
cbb1 at pci0
cardslot1 at cbb1
cardbus1 at cardslot1
rtw0 at cardbus1
pcmcia1 at cardslot1
sip0 at pci0
nsphyter0 at sip0
sip1 at pci0
nsphyter1 at sip1

Whew!
 1.107  09-Dec-2007  jmcneill branches: 1.107.2;
Merge jmcneill-pm branch.
 1.106  01-Dec-2007  ad branches: 1.106.2; 1.106.4;
Empty vessels make the most noise
 1.105  12-Nov-2007  joerg Merge pci_disable_retry function from jmcneill-pm as it is found in
various drivers.
 1.104  16-Oct-2007  joerg branches: 1.104.2; 1.104.4;
Merge 1.103.22.4 from jmcneill-pm:
Decode capabilities for PCI-PCI bridges as well.
 1.103  16-Nov-2006  christos branches: 1.103.8; 1.103.22; 1.103.24; 1.103.26;
__unused removal on arguments; approved by core.
 1.102  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.101  02-Oct-2006  jmcneill Print error on powerhook_establish failure, not success. PR# 34698.
 1.100  25-Sep-2006  jmcneill Create a PCI bus powerhook to handle setting PCI D# power state transitions
on suspend/standby/resume.
 1.99  17-Jun-2006  christos branches: 1.99.4; 1.99.6;
re-factor the pci powestate api. reviewed by gimpy
 1.98  29-Mar-2006  thorpej branches: 1.98.2; 1.98.4;
Replace device_locators() with device_locator(), and use it.
 1.97  11-Dec-2005  christos branches: 1.97.4; 1.97.6; 1.97.8; 1.97.10; 1.97.12;
merge ktrace-lwp.
 1.96  26-Aug-2005  drochner use XXXCF_NLOCS constants instead of magic numbers
 1.95  25-Aug-2005  drochner kill a number of autoconf submatch functions which follow the
standard scheme:
if (<configured> != <wildcard> && <configured> != <real>)
then fail
else
ask device match function

This is handled by config_stdsubmatch() now.
 1.94  25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.93  28-Jun-2005  thorpej branches: 1.93.2;
Use ANSI function decls and static.
 1.92  27-Feb-2005  perry nuke trailing whitespace
 1.91  04-Feb-2005  perry de-__P
 1.90  26-Jan-2005  jmcneill Add support functions for capturing and restoring PCI configuration
registers for power management code.
 1.89  13-Sep-2004  drochner branches: 1.89.4; 1.89.6;
remove macros which just hide cfdata internals
(and are used at one place only)
 1.88  30-Aug-2004  drochner Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.87  17-Aug-2004  drochner make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)
 1.86  29-Jul-2004  drochner make the "generic" PCI bus enumeration code the standard case which
gets used if nothing else is defined in MD headers,
introduce a "PCI_MACHDEP_ENUMERATE_BUS" CPP definition which can
be used by MD headers (just 1 port atm) to plug in special code
 1.85  17-May-2004  kochi Fix typo (func8 -> func7)
 1.84  08-May-2004  christos GC pci_{g,s}et_powerstate into pci_powerstate(). Idea from mycroft and gimpy.
Nothing uses them yet.
 1.83  23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.82  18-Aug-2003  itojun support new quirk bits on debug output
 1.81  15-Aug-2003  itojun - check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.80  15-Jun-2003  fvdl branches: 1.80.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.79  03-May-2003  thorpej Fix inverted logic in pci_vpd_write(). From Jachym Holecek, PR kern/21440.
 1.78  29-Apr-2003  thorpej Use aprint*().
 1.77  25-Mar-2003  thorpej Add PCI VPD access routines. From psi.cz!freza, PR kern/20889.
 1.76  19-Mar-2003  christos It is not appropriate for pcivar.h to include "locators.h"
The two files that need it, should include it themselves.
 1.75  01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.74  23-Oct-2002  perry fix lint warnings about things being stringified under cpp -traditional
 1.73  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.72  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.71  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.70  27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.69  27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.68  05-Jul-2002  thorpej Return 0, not NULL, when we mean 0.
 1.67  20-Jun-2002  itojun minor KNF
 1.66  18-Jun-2002  tshiozak add support for the per-device power management capability.

int pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int newstate)
set power state of the device to newstate.
int pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
get current power state of the device.

In the future, these functions will be used for ACPI support.
 1.65  18-May-2002  sommerfeld branches: 1.65.2;
Add "pa_rawintrpin" containing unswizzled interrupt pin to pci_attach_args.
 1.64  18-May-2002  sommerfeld In pci_probe_device(), correct test for whether the device is behind a
pci-pci bridge (and thus needs its interrupts "swizzled").

Formerly, pci_probe_device() assumed pci busses other than bus zero
were bridged; however, much recent x86 hardware supports multiple
primary pci busses differently -- there is a system-wide bus numbering
scheme. Now, we instead look at the (newly introduced) sc_bridgetag
value in the parent bus to figure out if there's a ppb or equivalent
in the way.

This fixed at least one case where the i386 MP branch gets interrupt
mapping wrong.
 1.63  16-May-2002  thorpej branches: 1.63.2;
Make sure pa.pa_bus is initialized. (Thanks, uwe!)
 1.62  16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.61  15-May-2002  thorpej Let machine-dependent code specify how to enumerate the bus.
Currently, everyone uses pci_enumerate_bus_generic().
 1.60  15-May-2002  thorpej Put back __PCI_BUS_DEVORDER for now.
 1.59  15-May-2002  thorpej Split the code that enumerates the PCI bus and that actually probes
for a device into two functions:

* pci_probe_device() actually probes/attaches the device specified
by the provide pcitag_t.

* pci_enumerate_bus() enumerates the bus, and calls pci_probe_device()
for each device on the bus. A pci_enumerate_bus_generic() is provided
which implements the old method of doing this: If something found at
dev0/func0, determine number of functions and probe each one.

Machine-dependent code will be able to specify the bus enumeration
routine in the future.
 1.58  13-Nov-2001  lukem add RCSID
 1.57  17-Oct-2001  thorpej Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)
 1.56  13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.55  10-Sep-2001  fvdl Add a pci_find_device function, to find a PCI device using a match
function on all (probed) PCI buses:

int pci_find_device(struct pci_attach_args *pa,
int (*match)(struct pci_attach_args *));

The pci_attach_args structure pointed to by pa is filled in if the
device is found, and 1 is returned. Otherwise 0 is returned.

This function is, unfortunately, needed by the i810 agp code. It's
also of use for LKMs.

Also frob pci_probe_bus to take 2 extra args when used by pci_find_device.
 1.54  11-Jul-2001  mrg branches: 1.54.2;
don't try to print pcitag_t values; these are opaque values that should not
be interpreted by MI code.
 1.53  22-May-2001  thorpej branches: 1.53.2;
If the cache line size in the BHLC register is not configured,
then clear the MRL/MRM/MWI command-ok flags when attaching a
device.
 1.52  04-May-2001  bouyer Add pci bus number to pci_attach_args, as suggested by Jason on tech-kern
(needed for pciide)
 1.51  02-Mar-2001  mrg branches: 1.51.2;
allow pci_bus_maxdevs() to be replaced with pci_bus_devorder() and
pci_dev_funcorder() that have the following signatures:

int pci_bus_devorder(pci_chipset_tag_t pc, int bus, char list[32]);
int pci_dev_funcorder(pci_chipset_tag_t pc, int bus, int device, char list[8]);

they control the order of PCI bus probe at the device and function level,
by filling in a value from 0 to 31 for pci_bus_devorder() or 0 to 7 for
pci_dev_funcorder, with a value of -1 to signify no more entries.


when device properties arrive, these will be replaced with some facility
based on properties (design/implementation unknown currently.)
 1.50  12-Feb-2001  mrg backout the parts of the previous change (7 months ago) that were *not* part
of the sys/vm removal, but some (fortunately disabled) work-in-progress.
 1.49  28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.48  10-May-2000  kleink branches: 1.48.4;
Add a comment describing the previous change.
 1.47  08-May-2000  kleink Make pci_get_capability() work correctly on both header type 0 and type 2
devices; both have different Capability List Pointer registers.
 1.46  30-Mar-2000  augustss Remove register declarations.
 1.45  22-Mar-2000  cgd if the PCI_CONFIG_DUMP option is defined, set the patchable
pci_config_dump variable to 1. otherwise, it gets set to 0. If
that's set, when configuring PCI devices spew the very verbose
configuration space header dump that was previously "#if 0"'d.
If you use this option, or patch the variable to 1, it's strongly
encouraged that you have used the MSGBUFSIZE option to enlarge the
kernel message buffer.
 1.44  04-Nov-1999  thorpej Make sure devices are told they can use rd/line, rd/mult, and wr/inval.
 1.43  04-Nov-1999  thorpej Print out if the read {line,multiple} and write/invalidate commands are
okay to use.
 1.42  06-May-1999  thorpej branches: 1.42.2; 1.42.4; 1.42.8;
Back out previous. Thanks to cgd for pointing out another way to do this.
 1.41  06-May-1999  thorpej Add a `bus' member to the pci_attach_args. This is not normally used,
but some child drivers might need to know this information.
 1.40  07-Nov-1998  drochner branches: 1.40.6; 1.40.8;
add support for "extended capabilities" (new in PCI spec 2.2)
 1.39  15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.38  09-Jun-1998  thorpej Remove the PCI-ISA bridge callback mechanism; it's no longer needed.
 1.37  31-May-1998  cgd use the new PCI 'quirks' mechanism to help determine the number
of functions on a given device. Also, clean up the #if 0'd
major-debugging-spew code so that it's all one piece, so that
it's a bit prettier, and so that it prints out quirk information.
 1.36  18-May-1998  cgd add an #if 0'd chunk which will pci_conf_print() every device (spews
lots of data, e.g. ~18k on a PCI system with few add-in devices; use
with MSGBUFSIZE=...). Useful to have here so that people who want as
much data about the PCI configuration in a machine can get it without
having to craft their own code. Also, clean up a few of the other
#if 0'd printfs.
 1.35  05-May-1998  mjacob more info (in heavy debugging cases) to print
 1.34  17-Apr-1998  drochner Keep all relevant state information in a "pci_softc" so that it is
accessible at runtime (for LKMs in particular).
Remove BROKEN_INDIRECT_CONFIG.
 1.33  28-Mar-1998  cgd check vendor against PCI_VENDOR_INVALID instead of 0xffff.
Suggested by Soren S. Jorvang.
 1.32  20-Mar-1998  cgd check only the Vendor ID (rather than both the Vendor ID and the Product
ID) when determining if the Vendor ID is invalid. The spec says that
Vendor ID of 0xffff is invalid, so, it doesn't _matter_ what the product
ID is in that case. Treat Vendor ID 0 as invalid because we always have.
 1.31  31-Jan-1998  thorpej branches: 1.31.2;
When a PCI bus is attached, print out which bus spaces were enabled
by the parent.
 1.30  12-Jan-1998  thorpej branches: 1.30.2;
Update for config changes.
 1.29  30-Aug-1997  mycroft branches: 1.29.2;
Pass down bus_dma_tag_t's as appropriate (per Jason's bus_dma code).
 1.28  30-Aug-1997  mycroft Remove pci_*_find() from here.
 1.27  10-Apr-1997  cgd pass memory- and i/o-enabled flags down via the PCI bus and device attach
arguments, so that a device can tell if its memory and I/O spaces are
enabled. The flags are cleared, depending on the contents of devices CSR
registers, in the machine-independent PCI bus code.
 1.26  05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.25  23-Nov-1996  cgd Provide a routine so that ISA/EISA bridges can set up a callback so
that their child busses can be attached after the PCI bus
autoconfiguration for their parent bus is done.

This works because:
(1) there can be at most one ISA/EISA bridge per PCI bus, and
(2) any ISA/EISA bridges must be attached to primary PCI
busses (i.e. bus zero).

That boils down to: there can only be one of these outstanding
at a time, it is cleared when configuring PCI bus 0 before any
subdevices have been found, and it is run after all subdevices
of PCI bus 0 have been found.

This (or something like it) is needed because there are some (legacy)
PCI devices which can show up as ISA/EISA devices as well (the prime
example of which are VGA controllers). If you attach ISA from a
PCI-ISA/EISA bridge, and the bridge is seen before the video board is,
the board can show up as an ISA device, and that can (bogusly)
complicate the PCI device's attach code, or make the PCI device not be
properly attached at all.

This could be done with machine-dependent code, but as more ports
add support for PCI (and PCI-ISA/EISA bridges) more will need it.
The i386 port could (perhaps should) be converted to use it as well.
 1.24  21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.23  13-Oct-1996  christos backout kprintf changes
 1.22  10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21  27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.20  26-Jul-1996  mycroft Add PCI_MAPREG_{IO,MEM}_SIZE(), and use them.
 1.19  03-May-1996  christos branches: 1.19.4;
remove unused variables
 1.18  27-Mar-1996  cgd modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.17  27-Mar-1996  cgd add definitions for the BIST/Header Type/Latency Timer/Cache Line Size
configuration space register, and use it to determine whether or not
a given PCI device uses multiple functions.
 1.16  17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.15  14-Mar-1996  cgd These devices don't actually need softc's that are supersets of 'struct
device.' No point in adding that complexity + space if they're not needed,
so axe them.
 1.14  14-Mar-1996  cgd (1) provide #defines for cf_loc[] entries for devices that attach to
pcibus and pci.
(2) remove the #ifdef i386 from pci.c, and provide a machine-dependent
hook (pci_md_attach_hook()) to do any machine-dependent attachment
gunk, e.g. on the i386 printing out the configuration mode (if bus 0)
(3) don't pass max device number for a given bus in, use
PCI_MAX_DEVICE_NUMBER, which can be defined on a per-machine basis.
(defaults to 32. on i386, it's 32 if pci conf mode == 1, 16 if 2.)
 1.13  08-Mar-1996  cgd remember the bus_chipset_tag_t given by our parent, and pass it on to
children.
 1.12  04-Mar-1996  cgd the i386 port no longer attaches isa, eisa, and pci at root.
 1.11  02-Mar-1996  cgd fix uninitialized variable; it shouldn't have been a variable at all.
(when probing to see if a device is there, always probe function 0.)
 1.10  28-Feb-1996  cgd make PCI bus match/attach and sub-device attachment machine-independent.
 1.9  17-Jun-1995  cgd oops; forgot this in last commit
 1.8  23-May-1995  cgd split single-subdevice lookup & attachment into a subroutine
(pci_attach_subdev()). remove pciattach() function and the pcicd cfdriver
struct, the former because thre are a lot of attachment actions which really
are machine-dependent (perhaps even "most"), and the latter because now that
both pcimatch() and pciattach() are machine-dependent it's bad style to
declare them here and it gains nothing.
 1.7  27-Jan-1995  cgd include files from the correct places.
 1.6  04-Nov-1994  mycroft Make a wrapper match function to check the bus and device numbers, rather
than insisting that every driver do it.
 1.5  03-Nov-1994  mycroft Rename pciprobe() to pcimatch(), and move it to pci_machdep.c.
 1.4  03-Nov-1994  mycroft Always use direct configuration.
 1.3  27-Oct-1994  cgd new RCS ID format.
 1.2  10-Aug-1994  mycroft Update some comments.
 1.1  09-Aug-1994  mycroft branches: 1.1.2;
Add PCI autoconfiguration support.
 1.1.2.1  10-Aug-1994  mycroft update from trunk
 1.19.4.1  10-Dec-1996  mycroft From trunk:
Deal with devices that do not allow allow of the I/O address bits to be set.
 1.29.2.2  01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.29.2.1  30-Aug-1997  thorpej file pci.c was added on branch marc-pcmcia on 1997-09-01 20:29:42 +0000
 1.30.2.2  12-Jan-1998  thorpej Update for config changes.
 1.30.2.1  12-Jan-1998  thorpej file pci.c was added on branch thorpej-bus-dma on 1998-01-12 09:40:12 +0000
 1.31.2.2  31-Jan-1998  thorpej When a PCI bus is attached, print out which bus spaces were enabled
by the parent.
 1.31.2.1  31-Jan-1998  thorpej file pci.c was added on branch bouyer-scsipi on 1998-01-31 00:37:40 +0000
 1.40.8.1  21-Jun-1999  thorpej Sync w/ -current.
 1.40.6.1  27-Jun-2000  he Pull up revision 1.45 (via patch, requested by cgd):
If the 'PCI_CONFIG_DUMP' option is defined, print a verbose dump
of all PCI devices' configuration space.
 1.42.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.42.4.1  15-Nov-1999  fvdl Sync with -current
 1.42.2.2  12-Mar-2001  bouyer Sync with HEAD.
 1.42.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.48.4.1  15-May-2001  he Pull up revision 1.52 (requested by bouyer):
Add a pa_bus member to pci_attach_args, so that the PCI bus number
can be used in pci device drivers.
 1.51.2.10  03-Jan-2003  thorpej Sync with HEAD.
 1.51.2.9  11-Nov-2002  nathanw Catch up to -current
 1.51.2.8  18-Oct-2002  nathanw Catch up to -current.
 1.51.2.7  01-Aug-2002  nathanw Catch up to -current.
 1.51.2.6  20-Jun-2002  nathanw Catch up to -current.
 1.51.2.5  14-Nov-2001  nathanw Catch up to -current.
 1.51.2.4  22-Oct-2001  nathanw Catch up to -current.
 1.51.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.51.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.51.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.53.2.6  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.53.2.5  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.53.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.53.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.53.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.53.2.1  03-Aug-2001  lukem update to -current
 1.54.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.63.2.3  15-Jul-2002  gehenna catch up with -current.
 1.63.2.2  30-May-2002  gehenna Catch up with -current.
 1.63.2.1  16-May-2002  gehenna file pci.c was added on branch gehenna-devsw on 2002-05-30 14:46:11 +0000
 1.65.2.1  15-Aug-2003  tron Pull up revision 1.81 (requested by itojun in ticket #1412):
- check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.80.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.80.2.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.80.2.6  04-Feb-2005  skrll Sync with HEAD.
 1.80.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.80.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.80.2.3  03-Sep-2004  skrll Sync with HEAD
 1.80.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.80.2.1  03-Aug-2004  skrll Sync with HEAD
 1.89.6.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.89.6.1  12-Feb-2005  yamt sync with head.
 1.89.4.1  29-Apr-2005  kent sync with -current
 1.93.2.10  24-Mar-2008  yamt sync with head.
 1.93.2.9  17-Mar-2008  yamt sync with head.
 1.93.2.8  27-Feb-2008  yamt sync with head.
 1.93.2.7  04-Feb-2008  yamt sync with head.
 1.93.2.6  21-Jan-2008  yamt sync with head
 1.93.2.5  07-Dec-2007  yamt sync with head
 1.93.2.4  15-Nov-2007  yamt sync with head.
 1.93.2.3  27-Oct-2007  yamt sync with head.
 1.93.2.2  30-Dec-2006  yamt sync with head.
 1.93.2.1  21-Jun-2006  yamt sync with head.
 1.97.12.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.97.10.1  19-Apr-2006  elad sync with head.
 1.97.8.2  26-Jun-2006  yamt sync with head.
 1.97.8.1  01-Apr-2006  yamt sync with head.
 1.97.6.1  22-Apr-2006  simonb Sync with head.
 1.97.4.1  09-Sep-2006  rpaulo sync with head
 1.98.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.98.2.1  19-Jun-2006  chap Sync with head.
 1.99.6.2  10-Dec-2006  yamt sync with head.
 1.99.6.1  22-Oct-2006  yamt sync with head
 1.99.4.1  18-Nov-2006  ad Sync with head.
 1.103.26.1  18-Oct-2007  yamt sync with head.
 1.103.24.3  23-Mar-2008  matt sync with HEAD
 1.103.24.2  09-Jan-2008  matt sync with HEAD
 1.103.24.1  06-Nov-2007  matt sync with HEAD
 1.103.22.13  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.103.22.12  04-Dec-2007  jmcneill Don't neglect to install a power handler in the event of no spaces being
available.
 1.103.22.11  03-Dec-2007  joerg Sync with HEAD.
 1.103.22.10  01-Dec-2007  jmcneill It seems that a hack to force PCI bridges to enable i/o and mem space
snuck in with the previous commit. Revert that piece.
 1.103.22.9  01-Dec-2007  jmcneill Don't actually power off vga in the PCI pnp bus handler, as it may be the
console device and it's nice to be able to figure out why we have crashed
if we fail to sleep.
 1.103.22.8  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.103.22.7  01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.103.22.6  11-Sep-2007  jmcneill Missing break after PNP_REQUEST_SET_STATE.
 1.103.22.5  23-Aug-2007  joerg Introduce pci_net_generic_power, which should be enough for most
network drivers and be a good foundation for C&P for the rest.

For iwi(4), don't reset the PCI retry register again, pci_conf_restore
should take care of that already.

For bge(4), add a NetBSD style if_stop.
 1.103.22.4  21-Aug-2007  joerg Decode capabilities for PCI-PCI bridges as well.
 1.103.22.3  06-Aug-2007  jmcneill Fix compilation with DIAGNOSTIC.
 1.103.22.2  05-Aug-2007  jmcneill In pci_conf_restore, don't bother updating a register if the current value
matches the new value.
 1.103.22.1  03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.103.8.1  23-Oct-2007  ad Sync with head.
 1.104.4.4  18-Feb-2008  mjf Sync with HEAD.
 1.104.4.3  27-Dec-2007  mjf Sync with HEAD.
 1.104.4.2  08-Dec-2007  mjf Sync with HEAD.
 1.104.4.1  19-Nov-2007  mjf Sync with HEAD.
 1.104.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.106.4.1  11-Dec-2007  yamt sync with head.
 1.106.2.1  26-Dec-2007  ad Sync with head.
 1.107.2.2  08-Jan-2008  bouyer Sync with HEAD
 1.107.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.110.6.5  17-Jan-2009  mjf Sync with HEAD.
 1.110.6.4  28-Sep-2008  mjf Sync with HEAD.
 1.110.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.110.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.110.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.110.2.1  24-Mar-2008  keiichi sync with head.
 1.116.4.6  11-Aug-2010  yamt sync with head.
 1.116.4.5  11-Mar-2010  yamt sync with head
 1.116.4.4  16-Sep-2009  yamt sync with head
 1.116.4.3  18-Jul-2009  yamt sync with head.
 1.116.4.2  04-May-2009  yamt sync with head.
 1.116.4.1  16-May-2008  yamt sync with head.
 1.116.2.2  17-Jun-2008  yamt sync with head.
 1.116.2.1  18-May-2008  yamt sync with head.
 1.117.4.1  18-Jun-2008  simonb Sync with head.
 1.117.2.2  10-Oct-2008  skrll Sync with HEAD.
 1.117.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.118.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.118.2.1  19-Oct-2008  haad Sync with HEAD.
 1.119.4.2  16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.4.1  20-Nov-2008  snj branches: 1.119.4.1.2; 1.119.4.1.4; 1.119.4.1.6;
Pull up following revision(s) (requested by bouyer in ticket #66):
sys/dev/pci/pci.c: revision 1.120
Do not depend on physmem for pci_dma64_available(). On some systems (e.g. Xen,
or any system with non-contigous physical memory), physmem may not represent
the hightest physical address available.
Discussed on tech-kern@ some weeks ago.
 1.119.4.1.6.1  16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.4.1.4.1  24-Dec-2011  matt Add support for __PCI_DEV_FUNCORDER
 1.119.4.1.2.1  16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.119.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.121.2.2  23-Jul-2009  jym Sync with HEAD.
 1.121.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.125.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.125.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.127.2.5  31-May-2011  rmind sync with head
 1.127.2.4  21-Apr-2011  rmind sync with head
 1.127.2.3  05-Mar-2011  rmind sync with head
 1.127.2.2  03-Jul-2010  rmind sync with head
 1.127.2.1  30-May-2010  rmind sync with head
 1.130.4.3  05-Mar-2011  bouyer Sync with HEAD
 1.130.4.2  17-Feb-2011  bouyer Sync with HEAD
 1.130.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.130.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.142.12.4  03-Dec-2017  jdolecek update from HEAD
 1.142.12.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.142.12.2  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.142.12.1  12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.142.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.142.2.1  30-Oct-2012  yamt sync with head
 1.143.2.1  18-May-2014  rmind sync with head
 1.145.2.5  28-Aug-2017  skrll Sync with HEAD
 1.145.2.4  19-Mar-2016  skrll Sync with HEAD
 1.145.2.3  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.145.2.2  22-Sep-2015  skrll Sync with HEAD
 1.145.2.1  06-Jun-2015  skrll Sync with HEAD
 1.151.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.151.2.1  26-Apr-2017  pgoyette Sync with HEAD
 1.152.14.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.152.14.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.152.14.1  10-Jun-2019  christos Sync with HEAD
 1.152.12.1  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.152.6.2  31-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1178):

sys/dev/pci/pci.c: revision 1.154

Clearing PCI_PMCSR_PME_STS(W1C) bit is required to stop asserting PME#.

This change would prevent unexpected rebooting from shutdown -p or
unexpected resuming from suspend.
 1.152.6.1  07-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1128):

sys/dev/pci/pcivar.h: revision 1.113
sys/dev/pci/pci.c: revision 1.153

Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe capabilities register, it's
required to check the existence of each register to not to write the next area.

This change fixes a stability of suspend/resume.
 1.154.4.3  03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.154.4.2  06-Nov-2019  martin Pull up following revision(s) (requested by mrg in ticket #401):

sys/dev/pci/pci.c: revision 1.156

PCIe downstream ports only have a single child device, so limit probing to
dev 0.
 1.154.4.1  15-Oct-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #331):

sys/dev/pci/pci.c: revision 1.155

The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.
 1.156.2.1  29-Feb-2020  ad Sync with head.
 1.157.6.1  03-Apr-2021  thorpej Sync with HEAD.
 1.158.2.2  22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.158.2.1  22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.159.4.1  31-May-2021  cjep sync with head
 1.159.2.1  13-May-2021  thorpej Sync with HEAD.
 1.160.4.1  04-Aug-2021  thorpej Adapt to CFARGS().
 1.165.4.1  04-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #928):

sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.25
sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h: revision 1.6
sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.49
sys/external/bsd/drm2/include/linux/mxm-wmi.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c: revision 1.13
sys/external/bsd/common/include/linux/bitops.h: revision 1.17
sys/external/bsd/drm2/nouveau/files.nouveau: revision 1.40
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.30
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.12
sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_sorgm200.c: revision 1.3
sys/external/bsd/common/include/linux/printk.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_gk20a.c: revision 1.10
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c: revision 1.4
sys/external/bsd/drm2/include/linux/acpi.h: revision 1.11
sys/external/bsd/drm2/drm/drm_cdevsw.c: revision 1.31
sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h: revision 1.5
sys/external/bsd/drm2/include/acpi/video.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h: revision 1.4
sys/arch/sparc64/include/pci_machdep.h: revision 1.31
sys/arch/sparc64/dev/pci_machdep.c: revision 1.83
sys/external/bsd/drm2/include/linux/kref.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c: revision 1.12
sys/external/bsd/drm2/linux/linux_dma_buf.c: revision 1.17
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c: revision 1.4
sys/external/bsd/drm2/drm/drm_module.c: revision 1.32
sys/external/bsd/drm2/dist/drm/i915/i915_gem.h: revision 1.8
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c: revision 1.7
sys/external/bsd/drm2/include/linux/smp.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.20
sys/arch/x86/x86/bus_dma.c: revision 1.91
sys/external/bsd/drm2/radeon/files.radeon: revision 1.40
sys/external/bsd/drm2/include/acpi/acpi_bus.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.21
sys/external/bsd/common/include/asm/barrier.h: revision 1.20
sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h: revision 1.2
sys/external/bsd/common/include/asm/barrier.h: revision 1.21
sys/modules/drmkms/drmkms_pci.h: revision 1.1
sys/external/bsd/drm2/dist/drm/drm_dp_helper.c: revision 1.17
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.23
sys/external/bsd/drm2/linux/linux_xa.c: revision 1.4
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.23
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.25
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.26
sys/dev/pci/pcivar.h: revision 1.120
sys/arch/xen/include/pci_machdep.h: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.26
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.27
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.27
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.28
sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c: revision 1.8
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.28
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.29
sys/external/bsd/drm2/include/linux/pci.h: revision 1.57
sys/external/bsd/drm2/include/linux/pci.h: revision 1.58
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c: revision 1.6
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c: revision 1.3
sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c: revision 1.3
share/man/man9/bus_dma.9: revision 1.69
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c: revision 1.15
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon.h: revision 1.12
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c: revision 1.7
sys/dev/acpi/acpi_mcfg.c: revision 1.29
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c: revision 1.7
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.13
sys/modules/amdgpu/Makefile: revision 1.9
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.14
sys/external/bsd/common/linux/linux_tasklet.c: revision 1.12
sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h: revision 1.10
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.23
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h: revision 1.9
sys/external/bsd/drm2/include/linux/interval_tree.h: revision 1.14
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.26
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c: revision 1.5
sys/dev/pci/pci.c: revision 1.168
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.27
sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c: revision 1.9
sys/external/bsd/drm2/pci/files.drmkms_pci: revision 1.18
sys/external/bsd/drm2/linux/linux_sync_file.c: revision 1.3
sys/external/bsd/drm2/amdgpu/files.amdgpu: revision 1.31
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c: revision 1.4
sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.24
sys/arch/xen/xen/xpci_xenbus.c: revision 1.29

drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

linux asm/barrier.h: Fix !MULTIPROCESSOR build.

remove "nouveau" from a comment. noted by jmcneill.

drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.

nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.
found by GCC 12.

avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical. as these indexes will always both
be 0, the only valid index, the condition is always false. GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.
amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
470 | stream->writeback_info[j] = stream->writeback_info[i];

convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.

drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled. (Might not be very useful, but it'll
build. Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)

drmkms: Fix module build.
avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.

drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.
this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed". for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus. add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)
tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].
this still does not quite work on nvidia cards. there are two problems
that remain:
- the call to set the link speed is skipped because the speed is set
to the default value of "-1". nvkm_pcie_set_link() will actually
determine the right value for this and for some cards, calling this
function if the current speed is -1 helps set the link speed. it
may be that on linux other paths we don't have enabled properly
would set this (there's one via debugfs, and a jetson specific one,
though perhaps setting either AC or DC speed values as boot options
(after hooking up these for netbsd) would currently work.
- worse, cards newer than kepler - geforce 900, 1000, and newer, are
all lacking the backing support to set pcie link speed. the GT 1030
card i have been testing with remains at pcie 1.0.

radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)
XXX amdgpu should get the same treatment.

drm: put_cpu() should enable preemption, not disable it again

drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).

drm: Set CONFIG_ACPI in linux/acpi.h and make it build.

Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.

radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.

drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.
PR kern/58180

linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.
PR kern/58210

ttm: Sync ttm_bo_uvm_fault_idle better with Linux.
PR xsrc/58133
ttm: Undo mistake in previous.

PR xsrc/58133
linux: Add a few more cases to pci_get_class.
Should fix crash on boot with amdgpu now that the ACPI business is
enabled.

i915: Fix dmabuf mmap object.

drm: Fix missing bounds checks in dma buf mmap.

drm_gem.c: Fix sense of assertion.
This is the opposite of WARN_ON.
Noted by rjs@.

drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.

i915_gem_mman.c: Apply mmap types via pmap flags.
This way, userland gets buffers mapped write-combining or uncached as
needed.
PR xsrc/58307

x86: Teach bus_dmamem_map about BUS_DMA_PREFETCHABLE.
PR port-amd64/58308

bus_dma(9): Document BUS_DMA_PREFETCHABLE.
Like BUS_DMA_NOCACHE. Doesn't absolve you of the need for
bus_dmamap_sync, but if you later pass the vaddr to bus_dmamap_load,
the DMA map might notice the mapping is write-combining and use this
to make bus_dmamap_sync cheaper.
PR kern/58309

nouveau_nvkm_subdev_instmem_gk20a.c: Use BUS_DMA_PREFETCHABLE.
Matches Linux's pgprot_writecombine.
Unclear where the appropriate bus_dmamap_sync happens, or is supposed
to happen -- not using it would be wrong, but asking for a
prefetchable mapping may paper over symptoms, at least!

ttm: Sync more with Linux.
Add the original copyright and attribution since this is now,
intentionally, a modified copy of the original and not just roughly
the same algorithm.

ttm: Respect PGO_ALLPAGES.
Not sure this is useful but it reduces XXX's and makes this match
udv_fault better so it's easier to understand.

ttm: Sync cacheability flag logic with Linux.

ttm: Add XXX about readahead fault failures.

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.
New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.
This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).
This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
Take 2: Make sure to handle NULL match function.
linux_pci: Nix pci enumeration kludges.
Now that we can pass a cookie through, this stuff will be a little
less fragile.

i915: Omit needless i915_gem_object_pin/unpin_pages cycle in fault.
vm_fault_cpu and vm_fault_gtt, called by i915_gem_fault, already do
the pinning and unpinning internally, so there is no need for
i915_gem_fault to do it.
No functional change intended, except that the transient pin count
will be one lower than before during the fault routine (but it will
still be positive).

i915: Match Linux fault routine return code actions.
Omit needless EINTR interception -- this is now handled by
i915_error_to_vmf_fault.
Earlier revert was over a false alarm -- bisection shows the new
warnings arose from linux_pci.c 1.29 here:
https://mail-index.netbsd.org/source-changes/2024/06/23/msg151929.html

linux_pci: Fix shifto in pci_get_class.
It looks like Linux's pci_get_class also matches the interface part
of the PCI class register (but not the revision part), and I hadn't
noticed that in the previous shim structured differently.

With GCC12 kernel ALL/amd64 triggers "'sor' may be used uninitialized".
If "sublinks & 3" is zero GCC is right and sor[1] may be returned unitialized.
Fix by initializing "sor" to zero to return -1 instead of uninitialized value.
Ok: Taylor R Campbell <riastradh@>

amdgpu: Map BAR 2, not BAR 5, on pre-bonaire chips.
PR kern/58384

amdgpu: Map consecutive pages, not the same one over and over again.
PR kern/58385

linux/bitops: Fix overestimate for BITS_TO_LONGS(9)
Fortunately, this seems harmless except for allocating
excessive buffer memory.
Pointed out by nonaka@, OK riastradh@.

RSS XML Feed