summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci/pcivar.h
Commit message (Collapse)AuthorAgeFilesLines
* Make the PCI code aware of PCI domains (aka PCI segments) so we canmarius2007-09-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | support machines having multiple independently numbered PCI domains and don't support reenumeration without ambiguity amongst the devices as seen by the OS and represented by PCI location strings. This includes introducing a function pci_find_dbsf(9) which works like pci_find_bsf(9) but additionally takes a domain number argument and limiting pci_find_bsf(9) to only search devices in domain 0 (the only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order to no longer report false positives when searching for siblings and dupe devices in the same domain respectively. Along with this change the sole host-PCI bridge driver converted to actually make use of PCI domain support is uninorth(4), the others continue to use domain 0 only for now and need to be converted as appropriate later on. Note that this means that the format of the location strings as used by pciconf(8) has been changed and that consumers of <sys/pciio.h> potentially need to be recompiled. Suggested by: jhb Reviewed by: grehan, jhb, marcel Approved by: re (kensmith), jhb (PCI maintainer hat)
* Revamp the MSI/MSI-X code a bit to achieve two main goals:jhb2007-05-021-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Simplify the amount of work that has be done for each architecture by pushing more of the truly MI code down into the PCI bus driver. - Don't bind MSI-X indicies to IRQs so that we can allow a driver to map multiple MSI-X messages into a single IRQ when handling a message shortage. The changes include: - Add a new pcib_if method: PCIB_MAP_MSI() which is called by the PCI bus to calculate the address and data values for a given MSI/MSI-X IRQ. The x86 nexus drivers map this into a call to a new 'msi_map()' function in msi.c that does the mapping. - Retire the pcib_if method PCIB_REMAP_MSIX() and remove the 'index' parameter from PCIB_ALLOC_MSIX(). MD code no longer has any knowledge of the MSI-X index for a given MSI-X IRQ. - The PCI bus driver now stores more MSI-X state in a child's ivars. Specifically, it now stores an array of IRQs (called "message vectors" in the code) that have associated address and data values, and a small virtual version of the MSI-X table that specifies the message vector that a given MSI-X table entry uses. Sparse mappings are permitted in the virtual table. - The PCI bus driver now configures the MSI and MSI-X address/data registers directly via custom bus_setup_intr() and bus_teardown_intr() methods. pci_setup_intr() invokes PCIB_MAP_MSI() to determine the address and data values for a given message as needed. The MD code no longer has to call back down into the PCI bus code to set these values from the nexus' bus_setup_intr() handler. - The PCI bus code provides a callout (pci_remap_msi_irq()) that the MD code can call to force the PCI bus to re-invoke PCIB_MAP_MSI() to get new values of the address and data fields for a given IRQ. The x86 MSI code uses this when an MSI IRQ is moved to a different CPU, requiring a new value of the 'address' field. - The x86 MSI psuedo-driver loses a lot of code, and in fact the separate MSI/MSI-X pseudo-PICs are collapsed down into a single MSI PIC driver since the only remaining diff between the two is a substring in a bootverbose printf. - The PCI bus driver will now restore MSI-X state (including programming entries in the MSI-X table) on device resume. - The interface for pci_remap_msix() has changed. Instead of accepting indices for the allocated vectors, it accepts a mini-virtual table (with a new length parameter). This table is an array of u_ints, where each value specifies which allocated message vector to use for the corresponding MSI-X message. A vector of 0 forces a message to not have an associated IRQ. The device may choose to only use some of the IRQs assigned, in which case the unused IRQs must be at the "end" and will be released back to the system. This allows a driver to use the same remap table for different shortage values. For example, if a driver wants 4 messages, it can use the same remap table (which only uses the first two messages) for the cases when it only gets 2 or 3 messages and in the latter case the PCI bus will release the 3rd IRQ back to the system. MFC after: 1 month
* Change the VPD code to read the VPD data on-demand when a driver asks forjhb2007-03-261-0/+1
| | | | | | | | | | | | it via pci_get_vpd_*() rather than always reading it for each device during boot. I've left the tunable so that it can still be turned off if a device driver causes a lockup via a query to a broken device, but devices whose drivers do not use VPD (the vast majority) should no longer result in lockups during boot, and most folks should not need to tweak the tunable now. Tested on: bge(4) Silence from: jmg
* Expand the MSI/MSI-X API to address some deficiencies in the MSI-X support.jhb2007-01-221-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - First off, device drivers really do need to know if they are allocating MSI or MSI-X messages. MSI requires allocating powerof2() messages for example where MSI-X does not. To address this, split out the MSI-X support from pci_msi_count() and pci_alloc_msi() into new driver-visible functions pci_msix_count() and pci_alloc_msix(). As a result, pci_msi_count() now just returns a count of the max supported MSI messages for the device, and pci_alloc_msi() only tries to allocate MSI messages. To get a count of the max supported MSI-X messages, use pci_msix_count(). To allocate MSI-X messages, use pci_alloc_msix(). pci_release_msi() still handles both MSI and MSI-X messages, however. As a result of this change, drivers using the existing API will only use MSI messages and will no longer try to use MSI-X messages. - Because MSI-X allows for each message to have its own data and address values (and thus does not require all of the messages to have their MD vectors allocated as a group), some devices allow for "sparse" use of MSI-X message slots. For example, if a device supports 8 messages but the OS is only able to allocate 2 messages, the device may make the best use of 2 IRQs if it enables the messages at slots 1 and 4 rather than default of using the first N slots (or indicies) at 1 and 2. To support this, add a new pci_remap_msix() function that a driver may call after a successful pci_alloc_msix() (but before allocating any of the SYS_RES_IRQ resources) to allow the allocated IRQ resources to be assigned to different message indices. For example, from the earlier example, after pci_alloc_msix() returned a value of 2, the driver would call pci_remap_msix() passing in array of integers { 1, 4 } as the new message indices to use. The rid's for the SYS_RES_IRQ resources will always match the message indices. Thus, after the call to pci_remap_msix() the driver would be able to access the first message in slot 1 at SYS_RES_IRQ rid 1, and the second message at slot 4 at SYS_RES_IRQ rid 4. Note that the message slots/indices are 1-based rather than 0-based so that they will always correspond to the rid values (SYS_RES_IRQ rid 0 is reserved for the legacy INTx interrupt). To support this API, a new PCIB_REMAP_MSIX() method was added to the pcib interface to change the message index for a single IRQ. Tested by: scottl
* Add a first pass at a way to blacklist MSI on systems where it doesn'tjhb2006-12-141-0/+1
| | | | | | | | | | | | work: - A new PCI quirk (PCI_QUIRK_DISABLE_MSI) is added to the quirk table. - A new pci_msi_device_blacklisted() determines if a passed in device matches an MSI quirk in the quirk table. This can be overridden (all quirks ignored) by setting the hw.pci.honor_msi_blacklist to 0. - A global blacklist check is performed in the MI PCI bus code by checking to see if the device at 0:0:0 is blacklisted. Tested by: jdp
* Replace #define<space> with #define<tab> so the code is consistent withjhb2006-12-141-23/+23
| | | | style(9) and avoids mixing the two formats.
* Fix a couple of comment typos.jhb2006-11-141-2/+2
| | | | Reported by: ru
* First cut at MI support for PCI Message Signalled Interrupts (MSI):jhb2006-11-131-1/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add 3 new functions to the pci_if interface along with suitable wrappers to provide the device driver visible API: - pci_alloc_msi(dev, int *count) backed by PCI_ALLOC_MSI(). '*count' here is an in and out parameter. The driver stores the desired number of messages in '*count' before calling the function. On success, '*count' holds the number of messages allocated to the device. Also on success, the driver can access the messages as SYS_RES_IRQ resources starting at rid 1. Note that the legacy INTx interrupt resource will not be available when using MSI. Note that this function will allocate either MSI or MSI-X messages depending on the devices capabilities and the 'hw.pci.enable_msix' and 'hw.pci.enable_msi' tunables. Also note that the driver should activate the memory resource that holds the MSI-X table and pending bit array (PBA) before calling this function if the device supports MSI-X. - pci_release_msi(dev) backed by PCI_RELEASE_MSI(). This function releases the messages allocated for this device. All of the SYS_RES_IRQ resources need to be released for this function to succeed. - pci_msi_count(dev) backed by PCI_MSI_COUNT(). This function returns the maximum number of MSI or MSI-X messages supported by this device. MSI-X is preferred if present, but this function will honor the 'hw.pci.enable_msix' and 'hw.pci.enable_msi' tunables. This function should return the largest value that pci_alloc_msi() can return (assuming the MD code is able to allocate sufficient backing resources for all of the messages). - Add default implementations for these 3 methods to the pci_driver generic PCI bus driver. (The various other PCI bus drivers such as for ACPI and OFW will inherit these default implementations.) This default implementation depends on 4 new pcib_if methods that bubble up through the PCI bridges to the MD code to allocate IRQ values and perform any needed MD setup code needed: - PCIB_ALLOC_MSI() attempts to allocate a group of MSI messages. - PCIB_RELEASE_MSI() releases a group of MSI messages. - PCIB_ALLOC_MSIX() attempts to allocate a single MSI-X message. - PCIB_RELEASE_MSIX() releases a single MSI-X message. - Add default implementations for these 4 methods that just pass the request up to the parent bus's parent bridge driver and use the default implementation in the various MI PCI bridge drivers. - Add MI functions for use by MD code when managing MSI and MSI-X interrupts: - pci_enable_msi(dev, address, data) programs the MSI capability address and data registers for a group of MSI messages - pci_enable_msix(dev, index, address, data) initializes a single MSI-X message in the MSI-X table - pci_mask_msix(dev, index) masks a single MSI-X message - pci_unmask_msix(dev, index) unmasks a single MSI-X message - pci_pending_msix(dev, index) returns true if the specified MSI-X message is currently pending - Save the MSI capability address and data registers in the pci_cfgreg block in a PCI devices ivars and restore the values when a device is resumed. Note that the MSI-X table is not currently restored during resume. - Add constants for MSI-X register offsets and fields. - Record interesting data about any MSI-X capability blocks we come across in the pci_cfgreg block in the ivars for PCI devices. Tested on: em (i386, MSI), bce (amd64/i386, MSI), mpt (amd64, MSI-X) Reviewed by: scottl, grehan, jfv MFC after: 2 months
* More fully support 64-bit bars. Prior to this commit, we supportedimp2006-10-301-13/+1
| | | | | | | | | | | | | | | | | | | | | only those bars that had addresses assigned by the BIOS and where the bridges were properly programmed. Now even unprogrammed ones work. This was needed for sun4v. We still only implement up to 2GB memory ranges, even for 64-bit bars. PCI standards at least through 2.2 say that this is the max (or 1GB is, I only know it is < 32bits). o Always define pci_addr_t as uint64_t. A pci address is always 64-bits, but some hosts can't address all of them. o Preserve the upper half of the 64-bit word during resource probing. o Test to make sure that 64-bit values can fit in a u_long (true on some platforms, but not others). Don't use those that can't. o minor pedantry about data sizes. o Better bridge resource reporting in bootverbose case. o Minor formatting changes to cope with different data types on different platforms. Submitted by: jmg, with many changes by me to fully support 64-bit addresses.
* provide routines to access VPD data at the PCI layer...jmg2006-10-091-0/+34
| | | | | | remove sk's own implementation, and use the new calls to get the data... Reviewed by: -arch
* Commit the results of the typo hunt by Darren Pilgrim.yar2006-08-041-2/+2
| | | | | | | | | | This change affects documentation and comments only, no real code involved. PR: misc/101245 Submitted by: Darren Pilgrim <darren pilgrim bitfreak org> Tested by: md5(1) MFC after: 1 week
* Remove left-over #ifdef alpha routines. They aren't used by any ofimp2006-01-011-5/+0
| | | | | our drivers, and don't appear to be necessary for GENERIC and LINT on the alpha. They don't belong in a MI header anyway...
* Add a new method PCI_FIND_EXTCAP() to the pci bus interface that is usedjhb2005-12-201-0/+6
| | | | | | | to search for a specific extended capability. If the specified capability is found for the given device, then the function returns success and optionally returns the offset of that capability. If the capability is not found, the function returns an error.
* Allow one to access the cached values for CMDREG, CACHELNSZ, MINGNT,imp2005-09-111-0/+10
| | | | | | MAXLAT and LATTIMER. Improve error message when a bogus RID type is requested for a bar.
* Add pci_is_vga_ioport_range() and pci_is_vga_memory_range() as inlinemarcel2005-04-291-0/+18
| | | | | | | functions. These functions centralize the details of which I/O port and memory ranges belong to VGA. Reviewed by: imp@, jhb@
* Start each of the license/copyright comments with /*-, minor shuffle of linesimp2005-01-061-1/+1
|
* Remove advertising clause from University of California Regent'simp2004-04-071-1/+3
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
* Teach the PCI code to parse MSI extended capabilities. Re-arrange thescottl2003-09-141-5/+17
| | | | pcicfg struct a bit to hold extcap structures instead of structure members.
* Prefer the uintXX_t to the u_intXX_t names.imp2003-08-221-69/+69
|
* Return status for PCI methods '{enable,disable}_{io,busmaster}'.mdodd2003-04-161-8/+8
| | | | Reviewed by: imp
* Add a new cardbus specific ivar: PCI_IVAR_ETHADDR. Some pci-likeimp2002-11-271-0/+2
| | | | | | | | buses support querying the MAC address in a standard-for-that-bus way. The base pci bus returns NULL for this IVAR always. Submitted by: sam Approved by: re (blanket for NEWCARD)
* style(9) nit.mux2002-08-191-1/+1
|
* Use the __BUS_ACCESSOR macro for PCIB_ACCESSOR instead ofmux2002-08-191-14/+2
| | | | | | reimplementing it. Reviewed by: tmm
* 0 is not an invalid interrupt in the PCI world (just in the ia32imp2002-06-071-2/+4
| | | | | | world), do not treat it as such. This fixes the alpha boot problem. Reviewed by: drew, des
* Define a PCI_INVALID_IRQ to augment PCI_INTERRUPT_VALIDimp2002-06-011-1/+2
|
* Don't claim to have routed an interrupt when the method actually returned anmsmith2002-02-121-0/+5
| | | | error.
* Implement 2 small helper functions:mdodd2002-01-101-0/+2
| | | | | pci_find_bsf() - Find a device_t by bus/slot/function. pci_find_device() - Find a device_t by vendor/device ID.
* Use the new resource_list_print_type() function to print resource listtmm2001-12-211-14/+2
| | | | | contents, and the new __BUS_ACCESSOR macro to construct the accessor functions.
* Don't put variable declarations in header files, put prototypes.mdodd2001-12-191-2/+4
| | | | 'pci_devq' provides useful information now.
* Slightly reimplement some recently added helper functions as methods, sopeter2001-02-271-6/+34
| | | | | that drivers are not reaching into the internals of the pci bus. There are no driver changes, the public interface is the same.
* Next round of PCI subsystem updates:msmith2000-12-131-91/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Break out the /dev/pci driver into a separate file. - Kill the COMPAT_OLDPCI support. - Make the EISA bridge attach a bit more like the old code; explicitly check for the existence of eisa0/isa0 and only attach if they don't already exist. Only make one bus_generic_attach() pass over the bridge, once both busses are attached. Note that the stupid Intel bridge's class is entirely unpredictable. - Add prototypes and re-layout the core PCI modules in line with current coding standards (not a major whitespace change, just moving the module data to the top of the file). - Remove redundant type-2 bridge support from the core PCI code; the PCI-CardBus code does this itself internally. Remove the now entirely redundant header-class-specific support, as well as the secondary and subordinate bus number fields. These are bridge attributes now. - Add support for PCI Extended Capabilities. - Add support for PCI Power Management. The interface currently allows a driver to query and set the power state of a device. - Add helper functions to allow drivers to enable/disable busmastering and the decoding of I/O and memory ranges. - Use PCI_SLOTMAX and PCI_FUNCMAX rather than magic numbers in some places. - Make the PCI-PCI bridge code a little more paranoid about valid I/O and memory decodes. - Add some more PCI register definitions for the command and status registers. Correct another bogus definition for type-1 bridges.
* Next phase in the PCI subsystem cleanup.msmith2000-12-081-7/+0
| | | | | | | | | | | | | | | | | | | | - Move PCI core code to dev/pci. - Split bridge code out into separate modules. - Remove the descriptive strings from the bridge drivers. If you want to know what a device is, use pciconf. Add support for broadly identifying devices based on class/subclass, and for parsing a preloaded device identification database so that if you want to waste the memory, you can identify *anything* we know about. - Remove machine-dependant code from the core PCI code. APIC interrupt mapping is performed by shadowing the intline register in machine- dependant code. - Bring interrupt routing support to the Alpha (although many platforms don't yet support routing or mapping interrupts entirely correctly). This resulted in spamming <sys/bus.h> into more places than it really should have gone. - Put sys/dev on the kernel/modules include path. This avoids having to change *all* the pci*.h includes.
* Get out the roto-rooter and clean up the abuse of nexus ivars by thepeter2000-09-281-2/+6
| | | | | | | | | | | | i386/isa/pcibus.c. This gets -current running again on multiple host->pci machines after the most recent nexus commits. I had discussed this with Mike Smith, but ended up doing it slightly differently to what we discussed as it turned out cleaner this way. Mike was suggesting creating a new resource (SYS_RES_PCIBUS) or something and using *_[gs]et_resource(), but IMHO that wasn't ideal as SYS_RES_* is meant to be a global platform property, not a quirk of a given implementation. This does use the ivar methods but does so properly. It also now prints the physical pci bus that a host->pci bridge (pcib) corresponds to.
* * Completely rewrite the alpha busspace to hide the implementation fromdfr2000-08-281-5/+3
| | | | | | | | | | | | the drivers. * Remove legacy inx/outx support from chipset and replace with macros which call busspace. * Rework pci config accesses to route through the pcib device instead of calling a MD function directly. With these changes it is possible to cleanly support machines which have more than one independantly numbered PCI busses. As a bonus, the new busspace implementation should be measurably faster than the old one.
* Nuke the useless chip driver. It gets in the way when you want to loaddfr2000-06-091-0/+1
| | | | a functional driver for the device.
* Encapsulate the old PCI compatability support and APIs completely underpeter2000-05-281-13/+13
| | | | | | "options COMPAT_OLDPCI". This option already existed, but now also tidies up the declarations in #include <pci/pci*.h>. It is amazing how much stuff was using the old pre-FreeBSD 3.x names and going silently undetected.
* Unused definitions.peter2000-03-201-10/+0
|
* Bandaid for src/sys/modules which broke worldpeter2000-03-201-1/+1
|
* Connect the ISA and PCI compatability shims to an option. In this casepeter2000-03-191-0/+12
| | | | | | | | it's options COMPAT_OLDISA and COMPAT_OLDPCI. This is meant to be a fairly strong incentive to update the older drivers to newbus, but doesn't (quite) leave anybody hanging with no hardware support. I was talking with a few folks and I was encouraged to simply break or disable the shims but that was a bit too drastic for my liking.
* Remove the vga-pci driver. It serves no purpose and it hides the hardwaredfr2000-02-191-0/+1
| | | | | | | | from useful drivers such as the 3D DRI drivers I will be porting for hardware accelerated OpenGL. The hardware will still be reported during boot using the nomatch system. Approved by: jkh
* Clean up the cfgmech/pci_mechanism debris. The reason for the existancepeter2000-01-081-2/+0
| | | | | | | of this is no longer an issue as we have a replacement driver for the one that needed it. Reviewed by: dfr
* Zap pci_map_dense() and pci_map_bwx() - they were for compatability butpeter2000-01-051-2/+0
| | | | | are not used. All the drivers that use memory mapped IO on the Alpha have been ported already.
* Make the usb and ide/ata device identification a little saner. Rather thanpeter1999-12-101-1/+2
| | | | | | attaching to the device via chip*, use the newbus nomatch method to report the device. This leaves them unattached so that a driver can be easily loaded to grab them later.
* [ repository copy of sys/pci/pci_ioctl.h to sys/sys/pciio.h happened in theken1999-12-081-1/+0
| | | | | | | | | | | | | | | | | background ] Rename sys/pci/pci_ioctl.h to sys/sys/pciio.h to make it easier for userland programs to use this interface. Reformat the file, and add a BSD-style copyright to it. Add a new man page for pci(4). The PCIOCGETCONF, PCIOCREAD, and PCIOCWRITE ioctls are documented, but the PCIOCATTACHED ioctl is not documented because it is not implemented. Change includes of <pci/pci_ioctl.h> to <sys/pciio.h> or remove them altogether. In many cases, pci_ioctl.h was unused. Reviewed by: steve
* * Implement bus_set/get/delete_resource for pci.dfr1999-10-141-23/+7
| | | | | | | * Change the hack used on the alpha for mapping devices into DENSE or BWX memory spaces to a simpler one. Its still a hack and should be a seperate api to explicitly map the resource. * Add $FreeBSD$ as necessary.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* On the new Meteor cards, the Philips SAA 7116 is connected to the PCI busroger1999-05-311-1/+7
| | | | | | | | | | | | | | | | | | | | via an IBM PCI-PCI bridge (82351 or 82352 or 82353) The driver must identify if it is on a secondary PCI bus, which is created via the IBM PCI-PCI bridge. If it is, then it must initialise the IBM PCI-PCI bridge correctly. To do this, the following new functions are added. Because they use the pcici_t tag, they are considered 2.2 compatibility APIs pcici_t * pci_get_parent_from_tag(pcici_t tag); int pci_get_bus_from_tag(pcici_t tag); (The _from_tag suffix is used to prevent clashes with similarly named newbus PCI API functions) Submitted by: Anton Berezin <tobez@plab.ku.dk> Reviewed by: Doug Rabson <dfr@nlsystems.com> Reworked by: Me (roger)
* Add support for multiple PCI "hoses" used on various alpha platforms.gallatin1999-05-201-1/+30
| | | | | | | | | The specific intent of this commit is to pave the way for importing Compaq XP1000 support. These changes should not affect the i386 port. Reviewed by: Doug Rabson <dfr@nlsystems.com> (actually, he walked me through most of it & deserves more than reviewd-by credit )
* Move pcibus (host -> pci bus) probe/attach routines from nexuspeter1999-05-181-2/+1
| | | | | to pcibus.c. pci_cfgopen() becomes static and there are no more bus #ifdef's in nexus.c.
* Use the probe priority mechanism to make sure the chip* probes do notpeter1999-05-111-3/+2
| | | | | | | | | | | | | displace a real driver. Revert rev 1.109. Pick up a few things from elsewhere (a couple of SiS id's). As an *experiment*, have the chip* driver claim (for reporting purposes) IDE controllers if there isn't another PCI-aware ide or ata driver to grab them. I've exported the match function since it could be used from the ata-all.c code replacing ata_pcimatch() - but I have not touched the ata code. I'd like to catch a few more devices this way, including USB and other bridges etc.
OpenPOWER on IntegriCloud