Up to [DragonFly] / src / sys / bus / pci
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Fix some typos in user visible messages.
Add pcie_set_max_readrq() to avoid code duplication between various network device drivers.
Turn power off for detached (module unloaded) PCI devices. No power down is done by default, you have to use hw.pci.do_power_nodriver sysctl.
Sync pci_[gs]et_powerstate_method with FreeBSD which makes things a little bit more friendly to devices. Obtained-from: FreeBSD
Quite minimal patchset to help to save some more power - put unused PCI devices (devices with no drivers) into D3 state. Device has to support it of course. Obtained-from: FreeBSD
Create an #include layer for bus/pci and bus/isa so source files do not have to dive into bus/xxx/i386 to access header files.
* Fix some cases where NULL was used but 0 was meant (and vice versa). * Remove some bogus casts of NULL to (void *).
Remove bogus checks after kmalloc(M_WAITOK) which never returns NULL. Reviewed-by: hasso
- Factor out pcie_slotimpl() to check whether PCI Express slot is implemented. - Add external function to test whether PCI Express slot is implemented; this external function is sheer wrapper of pcie_slotimpl(). - Rename port type macros. - Add some comment. - Disable all hot-plug related interrupts on PCI Express root/downstream port. Add XXX comment about it. Reminded-by: joerg@
- Cache PCI-X capability PTR. - Add IVARs to read PCI Express and PCI-X capability PTR. - Add convenient functions to test whether a device is PCI Express based or is PCI-X based.
Cache following information for PCI Express capability: - Capability PTR - PCI Express Capabilities register - Slot Capabilities register Print them if 'bootverbose'. Above information should be enough for identifying PCI Express hot-plug support, e.g. ExpressCard
Factor out a function to read power management capability
Rename pci_read_extcap() to pci_read_capabilities() to avoid possible confusion between PCI "capability" and PCI Express "extended capability".
- Factor out pci_fixup_nextptr(). - The checking about whether 'data' register of power management capability exists or not is incorrect, according to PCI local bus spec: 1) Next capability is not necessarily at a higher location than the current capability. 2) Two capabilities are not necessarily consecutive. Set it to 0 for now (it is not used at all) and add comment about a possible way to test the existence of this register in power management capability. - Clean up pci_read_extcap() a little bit.
- Push PCI status "capability list bit" checking down into pci_read_extcap(). - Mask bottom two bits of "next pointer", add comment about it. - If "next pointer" is not 0 and is less than 0x40 (standard PCI configuration space size), then it is illegal, bark out loudly and terminate the capability iteration.
Create structure to group PCI power management configuration Obtained-from: FreeBSD
- Add CAP_PTR macro for type 2 devices (cardbus) - Less magic values in pci_read_extcap() Obtained-from: FreeBSD
Update cardbus/pccard support. The original patch was done by joerg@; I seemed to "maintain" it for quite a long time :P Obtained-from: FreeBSD Tested-by: many (intermittently tho)
Bring in 1.343 from FreeBSD. FreeBSD commit message: "Add support for chipsets that has NULL'd BAR's for legacy ports. This allows DMA to be used on a fine little geode system I got here and most like on lots of older systems like that." Obtained-from: FreeBSD / sos
pci_get_resource_list() was returning an illegal pointer instead of NULL in cases where no resource list is present. Reported-by: Martin <email@example.com>
Remove ancient SimOS support.
Rename printf -> kprintf in sys/ and add some defines where necessary (files which are used in userland, too).
Add the PCI_MAP_FIXUP code as proposed two weeks ago. The code is only enabled with options PCI_MAP_FIXUP in your kernel, and should only be used when using nata.
Rename sprintf -> ksprintf Rename snprintf -> knsprintf Make allowances for source files that are compiled for both userland and the kernel.
Do a major clean-up of the BUSDMA architecture. A large number of essentially machine-independant drivers use the structures and definitions in machine-dependant directories that are really machine-independant in nature. Split <machine/bus_dma.h> into machine-depdendant and machine-independant parts and make the primary access run through <sys/bus_dma.h>. Remove <machine/bus.h>, <machine/bus_memio.h> and <machine/bus_pio.h>. The optimizations related to bus_memio.h and bus_pio.h made a huge mess, introduced machine-specific knowledge into essentially machine-independant drivers, and required specific #include file orderings to do their job. They may be reintroduced in some other form later on. Move <machine/resource.h> to <sys/bus_resource.h>. The contents of the file is machine-independant or can be made a superset across many platforms. Make <sys/bus.h> include <sys/bus_dma.h> and <sys/bus_resource.h> and include <sys/bus.h> where necessary. Remove all #include's of <machine/resource.h> and <machine/bus.h>. That is, make the BUSDMA infrastructure integral to I/O-mapped and memory-mapped accesses to devices and remove a large chunk of machine-specific dependancies from drivers. bus_if.h and device_if.h are now required to be present when using <sys/bus.h>.
Rename malloc->kmalloc, free->kfree, and realloc->krealloc. Pass 1
Remove more DEC Alpha support.
MASSIVE reorganization of the device operations vector. Change cdevsw to dev_ops. dev_ops is a syslink-compatible operations vector structure similar to the vop_ops structure used by vnodes. Remove a huge number of instances where a thread pointer is still being passed as an argument to various device ops and other related routines. The device OPEN and IOCTL calls now take a ucred instead of a thread pointer, and the CLOSE call no longer takes a thread pointer.
Allow 'options SMP' *WITHOUT* 'options APIC_IO'. That is, an ability to produce an SMP-capable kernel that uses the PIC/ICU instead of the IO APICs for interrupt routing. SMP boxes with broken BIOSes (namely my Shuttle XPC SN95G5) could very well have serious interrupt routing problems when operating in IO APIC mode. One solution is to not use the IO APICs. That is, to run only the Local APICs for the SMP management. * Don't conditionalize NIDT. Just set it to 256 * Make the ICU interrupt code MP SAFE. This primarily means using the imen_spinlock to protect accesses to icu_imen. * When running SMP without APIC_IO, set the LAPIC TPR to prevent unintentional interrupts. Leave LINT0 enabled (normally with APIC_IO LINT0 is disabled when the IO APICs are activated). LINT0 is the virtual wire between the 8259 and LAPIC 0. * Get rid of NRSVIDT. Just use IDT_OFFSET instead. * Clean up all the APIC_IO tests which should have been SMP tests, and all the SMP tests which should have been APIC_IO tests. Explicitly #ifdef out all code related to the IO APICs when APIC_IO is not set.
Add another parameter to BUS_ADD_CHILD to allow children to inherit code from grandparents. Formalize and document the IDENTIFY mechanism and actually use it properly to add PCI busses rather then the severe hacks that existed before. Instead of attaching PCI busses (pcib) directly to nexus, create a pass-through bus layer under nexus called 'legacypci' and attach the PCI busses to that. Use the new BUS_ADD_CHILD and IVARS recursion capability to still allow the pcib's under legacypci to get nexus generated IVARS. NOTE ON IVARS: These can be utterly confusing because a BUS device may manage and control the IVARS attached to its children. In addition, if the BUS method for the device accessing the IVARs does not properly match up with or recurse to the device that actually created the ivars, mass confusion can result. I have attempted to document the issue but XXX it needs some sanity check code. Add a 'pcib_owner' global that is used to determine which of the several possible PCI mainbus subsystems actually own the PCI mainbus. This is not yet tied into ACPI but will be soon. No longer add legacy "pcib" busses if it is detected that another subsystem controls the mainbus. Before the busses were added but then simply not scanned later on, creating confusing pcibX designations. Now the busses aren't added... legacypci stops cold if it doesn't own the PCI mainbus. Get rid of the twisted checks for "pci" devices that used to handle this job. Document many aspects of the PCI code and redo some of the APIs slightly to make them more obvious. In particular, document the odd fact that pci_*() accessor function actually operate on a pci function code based sub-device of the "pci" driver and call device_get_parent() to get to the pci" driver layer. This sub layer really needs its own formal designation. Change "pciX" attachments to "pcibY" busses. Use the secondary bus id for 'X' and require it to be unique. Also reorder "pcibY" attachments so the physical bus number tends to (but is not guarenteed to be) the same 'Y' in pcibY. Change IVARS access for bridges. Require that the device representing the "pcib" device be passed to pcib_get/set_*() routines instead of children of said device. Add a function devclass_find_unit() to shortcut the more complex operation of locating the devclass by name and then getting the device relative to the devclass. Add numerous bus_generic_*() BUS methods which now recurse through the parent instead of terminate with an error.
Add missing breaks.
Enable port and memory-mapped IO in the PCI layer when the associated resources are allocated. Obtained-from: FreeBSD
Remove DEC Alpha support.
Add support for ServerWorks chipsets. Obtained-from: FreeBSD
Annotate the class byte with a class name in the bootverbose pci "found->" bus logging code. Numbers are fine, but when there are thousands of them on the screen you need a bit of human readable context.
Add MODULE_VERSION(pci, 1), e.g. agp(4) can't be loaded as module otherwise. Suggested-by: corecode While at it, de-static pci_alloc_resource to match the prototyp. ACPI5 depends on it.
Device layer rollup commit. * cdevsw_add() is now required. cdevsw_add() and cdevsw_remove() may specify a mask/match indicating the range of supported minor numbers. Multiple cdevsw_add()'s using the same major number, but distinctly different ranges, may be issued. All devices that failed to call cdevsw_add() before now do. * cdevsw_remove() now automatically marks all devices within its supported range as being destroyed. * vnode->v_rdev is no longer resolved when the vnode is created. Instead, only v_udev (a newly added field) is resolved. v_rdev is resolved when the vnode is opened and cleared on the last close. * A great deal of code was making rather dubious assumptions with regards to the validity of devices associated with vnodes, primarily due to the persistence of a device structure due to being indexed by (major, minor) instead of by (cdevsw, major, minor). In particular, if you run a program which connects to a USB device and then you pull the USB device and plug it back in, the vnode subsystem will continue to believe that the device is open when, in fact, it isn't (because it was destroyed and recreated). In particular, note that all the VFS mount procedures now check devices via v_udev instead of v_rdev prior to calling VOP_OPEN(), since v_rdev is NULL prior to the first open. * The disk layer's device interaction has been rewritten. The disk layer (i.e. the slice and disklabel management layer) no longer overloads its data onto the device structure representing the underlying physical disk. Instead, the disk layer uses the new cdevsw_add() functionality to register its own cdevsw using the underlying device's major number, and simply does NOT register the underlying device's cdevsw. No confusion is created because the device hash is now based on (cdevsw,major,minor) rather then (major,minor). NOTE: This also means that underlying raw disk devices may use the entire device minor number instead of having to reserve the bits used by the disk layer, and also means that can we (theoretically) stack a fully disklabel-supported 'disk' on top of any block device. * The new reference counting scheme prevents this by associating a device with a cdevsw and disconnecting the device from its cdevsw when the cdevsw is removed. Additionally, all udev2dev() lookups run through the cdevsw mask/match and only successfully find devices still associated with an active cdevsw. * Major work on MFS: MFS no longer shortcuts vnode and device creation. It now creates a real vnode and a real device and implements real open and close VOPs. Additionally, due to the disk layer changes, MFS is no longer limited to 255 mounts. The new limit is 16 million. Since MFS creates a real device node, mount_mfs will now create a real /dev/mfs<PID> device that can be read from userland (e.g. so you can dump an MFS filesystem). * BUF AND DEVICE STRATEGY changes. The struct buf contains a b_dev field. In order to properly handle stacked devices we now require that the b_dev field be initialized before the device strategy routine is called. This required some additional work in various VFS implementations. To enforce this requirement, biodone() now sets b_dev to NODEV. The new disk layer will adjust b_dev before forwarding a request to the actual physical device. * A bug in the ISO CD boot sequence which resulted in a panic has been fixed. Testing by: lots of people, but David Rhodus found the most aggregious bugs.
device switch 1/many: Remove d_autoq, add d_clone (where d_autoq was). d_autoq was used to allow the device port dispatch to mix old-style synchronous calls with new style messaging calls within a particular device. It was never used for that purpose. d_clone will be more fully implemented as work continues. We are going to install d_port in the dev_t (struct specinfo) structure itself and d_clone will be needed to allow devices to 'revector' the port on a minor-number by minor-number basis, in particular allowing minor numbers to be directly dispatched to distinct threads. This is something we will be needing later on.
Add missing make_dev
Fix a bug in the last commit. 4.x improperly tries to add the children of a PCI bus during the probe phase. This doesn't mix well with 5.x's bus code which adds the children in the attach phase. Clean up pci_probe(). The code, unfortunately, is still quite fragile. Cleanup pci_read_device(). Bring in pcib_*() routines from 5.x into pcisupport.c. Add support for bridges which do not support particular PCI mapping types (from FreeBSD 5.x). Fix a bug in the pcib_route_interrupt() method.
Synchronize a bunch of things from FreeBSD-5 in preparation for the new ACPICA driver support. * Bring in a lot of new bus and pci DEV_METHODs from FreeBSD-5 * split apic.h into apicreg.h and apicio.h * rename INTR_TYPE_FAST -> INTR_FAST and move the #define * rename INTR_TYPE_EXCL -> INTR_EXCL and move the #define * rename some PCIR_ registers and add additional macros from FreeBSD-5 * note: new pcib bus call, host_pcib_get_busno() imported. * kern/subr_power.c no longer optional. Other changes: * machine/smp.h machine smp/smptests.h can now be #included unconditionally, and some APIC_IO vs SMP separation has been done as well. * gd_acpi_id and gd_apic_id added to machine/globaldata.h prep for new ACPI code. Despite all the changes, the generated code should be virtually the same. These were mostly additions which the pre-existing code does not (yet) use.
Add pci_get_ether and pci_set_ether for FreeBSD 5 compatibility
Adjust infrastructure for NEWCARD
Fix PCI deadlock on boot
Fix compile errors introduced with last commit
Replace pci_cfgread and pci_cfgwrite with PCIB_READ_CONFIG and PCIB_WRITE_CONFIG. Merged in FreeBSD rev 1.167, without 1.162 and 1.166.
Remove HOSE support which should be implemented in the bus function when Alpha support is re-enabled. Add BUS pcib ivar. Add pcib interface functions.
Sync pci_cfgreg.c with FreeBSD 5, rev. 1.101. This makes the PCI interrupt routing code more robust. Also copied pci_cfgreg.h into bus/pci/i386, the other instance in machine/pci_cfgreg.h will go later.
Drop chip driver and merge the functionality into pci_probe_nomatch. Adjust return value of pcib_probe to -1000 for conformance to other default matches. Do some general cleanup.
Spell 'weird' the way English expects it.
Move the FreeBSD 2.2 and 3.x PCI compatibility code into pci_compat.c and let it depend on COMPAT_OLDPCI. Adjust LINT to accordingly.
Factor out the object system from new-bus so that it can be used by non-device code. Re-implement the method dispatch to improve efficiency. The new system takes about 40ns for a method dispatch on a 300Mhz PII which is only 10ns slower than a direct function call on the same hardware. This is all based on Doug Rabson's work in April and May of 2000.
kernel tree reorganization stage 1: Major cvs repository work (not logged as commits) plus a major reworking of the #include's to accomodate the relocations. * CVS repository files manually moved. Old directories left intact and empty (temporary). * Reorganize all filesystems into vfs/, most devices into dev/, sub-divide devices by function. * Begin to move device-specific architecture files to the device subdirs rather then throwing them all into, e.g. i386/include * Reorganize files related to system busses, placing the related code in a new bus/ directory. Also move cam to bus/cam though this may not have been the best idea in retrospect. * Reorganize emulation code and place it in a new emulation/ directory. * Remove the -I- compiler option in order to allow #include file localization, rename all config generated X.h files to use_X.h to clean up the conflicts. * Remove /usr/src/include (or /usr/include) dependancies during the kernel build, beyond what is normally needed to compile helper programs. * Make config create 'machine' softlinks for architecture specific directories outside of the standard <arch>/include. * Bump the config rev. WARNING! after this commit /usr/include and /usr/src/sys/compile/* should be regenerated from scratch.
DEV messaging stage 1/4: Rearrange struct cdevsw and add a message port and auto-queueing mask. The mask will tell us which message functions can be safely queued to another thread and which still need to run in the context of the caller. Primary configuration fields (name, cmaj, flags, port, autoq mask) are now at the head of the structure. Function vectors, which may eventually go away, are at the end. The port and autoq fields are non-functional in this stage. The old BDEV device major number support has also been removed from cdevsw, and code has been added to translate the bootdev passed from the boot code (the boot code has always passed the now defunct block device major numbers and we obviously need to keep that compatibility intact).
proc->thread stage 2: MAJOR revamping of system calls, ucred, jail API, and some work on the low level device interface (proc arg -> thread arg). As -current did, I have removed p_cred and incorporated its functions into p_ucred. p_prison has also been moved into p_ucred and adjusted accordingly. The jail interface tests now uses ucreds rather then processes. The syscall(p,uap) interface has been changed to just (uap). This is inclusive of the emulation code. It makes little sense to pass a proc pointer around which confuses the MP readability of the code, because most system call code will only work with the current process anyway. Note that eventually *ALL* syscall emulation code will be moved to a kernel-protected userland layer because it really makes no sense whatsoever to implement these emulations in the kernel. suser() now takes no arguments and only operates with the current process. The process argument has been removed from suser_xxx() so it now just takes a ucred and flags. The sysctl interface was adjusted somewhat.
Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most ids have been removed from !lint sections and moved into comment sections.
import from FreeBSD RELENG_4 126.96.36.199