aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/cardbus
Commit message (Collapse)AuthorAgeFilesLines
* subr_bus: restore bus_null_rescan()Mitchell Horne2022-06-231-0/+1
| | | | | | | | | | | | Partially revert the previous change; we need to keep this method as a specific override for pci_driver subclasses which should not use pci_rescan_method() -- cardbus and ofw_pcibus. However, change the return value to ENODEV for the same reasoning given in the original commit, and use this as the default rescan method in bus_if.m. Reported by: jhb Fixes: 36a8572ee8f5 ("bus_if: provide a default null rescan method") MFC with: 36a8572ee8f5
* bus_if: provide a default null rescan methodMitchell Horne2022-06-231-1/+0
| | | | | | | | | | | | | | | | There is an existing helper method in subr_bus.c, but almost no drivers know to use it. It also returns the same error as an empty method, making it not very useful. Move this to bus_if.m and return a more sensible error code. This gives a slightly more meaningful error message when attempting 'devctl rescan' on buses and devices alike: "Device not configured" --> "Operation not supported by device" Reviewed by: imp MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35501
* cardbus: Remove unused devclass argument to DRIVER_MODULE.John Baldwin2022-05-061-3/+1
|
* Create wrapper for Giant taken for newbusWarner Losh2021-12-101-4/+4
| | | | | | | | | | | Create a wrapper for newbus to take giant and for busses to take it too. bus_topo_lock() should be called before interacting with newbus routines and unlocked with bus_topo_unlock(). If you need the topology lock for some reason, bus_topo_mtx() will provide that. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D31831
* Fix "set but not used" in cardbusScott Long2021-12-051-2/+0
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* cardbus: move card_if.m to sys/dev/cardbusWarner Losh2021-07-141-0/+151
| | | | | | Move card_if.m to sys/dev/cardbus since pccard is disappearing. Sponsored by: Netflix
* cardbus: Be sure to acquire Giant when calling into newbusWarner Losh2021-02-271-3/+4
| | | | | | | | Acquire Giant in cardbus_detach_card. This used to be done above us, but no more. Tested by: kargl@ MFC After: 3 days
* pccard: Move power_if.m from pccard to cardbusWarner Losh2021-01-081-0/+45
| | | | power_if.m is used by both pccard and cardbus. Move it into cardbus.
* cardbus: clean up empty lines in .c and .h filesMateusz Guzik2020-09-012-2/+0
| | | | Notes: svn path=/head/; revision=365213
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Regularize my copyright noticeWarner Losh2019-12-044-10/+7
| | | | | | | | | | | | o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* Remove a few stray "All Rights Reserved." declarations on stuff I'veWarner Losh2019-02-051-1/+2
| | | | | | | written. Notes: svn path=/head/; revision=343810
* Push down Giant one layer. In the days of yore, back when PenitumsWarner Losh2018-03-201-0/+2
| | | | | | | | | | | | | | were the new kids on the block and F00F hacks were all the rage, one needed to take out Giant to do anything moderately complicated with the VM, mappings and such. So the pccard / cardbus code held Giant for the entire insertion or removal process. Today, the VM is MP safe. The lock is only needed for dealing with newbus things. Move locking and unlocking Giant to be only around adding and probing devices in pccard and cardbus. Notes: svn path=/head/; revision=331271
* 1k objects on the stack are a bad idea. While it's likely safe in thisWarner Losh2017-12-121-2/+8
| | | | | | | | | context, it's also safe to allocate the memory and free it instead. Noticed by: Eugene Grosbein's script Notes: svn path=/head/; revision=326809
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-276-0/+12
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Add a bus_null_rescan() method that always fails with an error.John Baldwin2016-04-271-1/+1
| | | | | | | | Use this in place of kobj_error_method to disable BUS_RESCAN() on PCI drivers that do not use the "standard" scanning algorithm. Notes: svn path=/head/; revision=298712
* Implement a PCI bus rescan method.John Baldwin2016-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Rescanning a PCI bus uses the following steps: - Fetch the current set of child devices and save it in the 'devlist' array. - Allocate a parallel array 'unchanged' initalized with NULL pointers. - Scan the bus checking each slot (and each function on slots with a multifunction device). - If a valid function is found, look for a matching device in the 'devlist' array. If a device is found, save the pointer in the 'unchanged' array. If a device is not found, add a new device. - After the scan has finished, walk the 'devlist' array deleting any devices that do not have a matching pointer in the 'unchanged' array. - Finally, fetch an updated set of child devices and explicitly attach any devices that are not present in the 'unchanged' array. This builds on the previous changes to move subclass data management into pci_alloc_devinfo(), pci_child_added(), and bus_child_deleted(). Subclasses of the PCI bus use custom rescan logic explicitly override the rescan method to disable rescans. Differential Revision: https://reviews.freebsd.org/D6018 Notes: svn path=/head/; revision=298708
* sys/dev: use our nitems() macro when it is avaliable through param.h.Pedro F. Giffuni2016-04-191-1/+1
| | | | | | | | | | No functional change, only trivial cases are done in this sweep, Drivers that can get further enhancements will be done independently. Discussed in: freebsd-current Notes: svn path=/head/; revision=298307
* Add a new PCI bus interface method to alloc the ivars (dinfo) for a device.John Baldwin2016-04-151-2/+13
| | | | | | | | | | | | | | | | | The ACPI and OFW PCI bus drivers as well as CardBus override this to allocate the larger ivars to hold additional info beyond the stock PCI ivars. This removes the need to pass the size to functions like pci_add_iov_child() and pci_read_device() simplifying IOV and bus rescanning implementations. As a result of this and earlier changes, the ACPI PCI bus driver no longer needs its own device_attach and pci_create_iov_child methods but can use the methods in the stock PCI bus driver instead. Differential Revision: https://reviews.freebsd.org/D5891 Notes: svn path=/head/; revision=298029
* Convert pci_delete_child() to a bus_child_deleted() method.John Baldwin2016-04-061-18/+18
| | | | | | | | | | | | | | | | | | | | | | | Instead of providing a wrapper around device_delete_child() that the PCI bus and child bus drivers must call explicitly, move the bulk of the logic from pci_delete_child() into a bus_child_deleted() method (pci_child_deleted()). This allows PCI devices to be safely deleted via device_delete_child(). - Add a bus_child_deleted method to the ACPI PCI bus which clears the device_t associated with the corresponding ACPI handle in addition to the normal PCI bus cleanup. - Change cardbus_detach_card to call device_delete_children() and move CardBus-specific delete logic into a new cardbus_child_deleted() method. - Use device_delete_child() instead of pci_delete_child() in the SRIOV code. - Add a bus_child_deleted method to the OpenFirmware PCI bus drivers which frees the OpenFirmware device info for each PCI device. Reviewed by: imp Tested on: amd64 (CardBus and PCI-e hotplug) Differential Revision: https://reviews.freebsd.org/D5831 Notes: svn path=/head/; revision=297608
* Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.Justin Hibbits2016-03-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some architectures, u_long isn't large enough for resource definitions. Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but type `long' is only 32-bit. This extends rman's resources to uintmax_t. With this change, any resource can feasibly be placed anywhere in physical memory (within the constraints of the driver). Why uintmax_t and not something machine dependent, or uint64_t? Though it's possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on 32-bit architectures. 64-bit architectures should have plenty of RAM to absorb the increase on resource sizes if and when this occurs, and the number of resources on memory-constrained systems should be sufficiently small as to not pose a drastic overhead. That being said, uintmax_t was chosen for source clarity. If it's specified as uint64_t, all printf()-like calls would either need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t aren't horrible, but it would also bake into the API for resource_list_print_type() either a hidden assumption that entries get cast to uintmax_t for printing, or these calls would need the PRI*64 macros. Since source code is meant to be read more often than written, I chose the clearest path of simply using uintmax_t. Tested on a PowerPC p5020-based board, which places all device resources in 0xfxxxxxxxx, and has 8GB RAM. Regression tested on qemu-system-i386 Regression tested on qemu-system-mips (malta profile) Tested PAE and devinfo on virtualbox (live CD) Special thanks to bz for his testing on ARM. Reviewed By: bz, jhb (previous) Relnotes: Yes Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D4544 Notes: svn path=/head/; revision=297000
* On my Lenovo T400, a Atheros 2413 has a problem powering upWarner Losh2015-02-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | sometimes. It will power up wrong and identify itself badly: cardbus0: <network, ethernet> at device 0.0 (no driver attached) cardbus0: <simple comms, UART> at device 0.1 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.2 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.3 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.4 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.5 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.6 (no driver attached) cardbus0: <old, non-VGA display device> at device 0.7 (no driver attached) All the higher numbered functions (.2 and above) have a config space of all 0's. This smells a bit like a special debug mode, but the current atheros driver doesn't cope. It is unclear if this card is just a flake, or if we're doing something wrong in the power-up sequence. Put a work around into the code that tests for this rather unusual condition. If we power a CardBus device up, and the device says it is multi-function, and any of the functions have a 0 device ID, try the power-up sequence again. Notes: svn path=/head/; revision=278936
* Add a rather obnoxious warning if you don't have NEW_PCIB definedWarner Losh2015-01-141-0/+2
| | | | | | | since it's a total crap shoot if things will work. Notes: svn path=/head/; revision=277163
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-8/+4
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-4/+8
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* Add support for managing PCI bus numbers. As with BARs and PCI-PCI bridgeJohn Baldwin2014-02-122-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | I/O windows, the default is to preserve the firmware-assigned resources. PCI bus numbers are only managed if NEW_PCIB is enabled and the architecture defines a PCI_RES_BUS resource type. - Add a helper API to create top-level PCI bus resource managers for each PCI domain/segment. Host-PCI bridge drivers use this API to allocate bus numbers from their associated domain. - Change the PCI bus and CardBus drivers to allocate a bus resource for their bus number from the parent PCI bridge device. - Change the PCI-PCI and PCI-CardBus bridge drivers to allocate the full range of bus numbers from secbus to subbus from their parent bridge. The drivers also always program their primary bus register. The bridge drivers also support growing their bus range by extending the bus resource and updating subbus to match the larger range. - Add support for managing PCI bus resources to the Host-PCI bridge drivers used for amd64 and i386 (acpi_pcib, mptable_pcib, legacy_pcib, and qpi_pcib). - Define a PCI_RES_BUS resource type for amd64 and i386. Reviewed by: imp MFC after: 1 month Notes: svn path=/head/; revision=261790
* - Add a bus_dma tag to each PCI bus that is a child of a Host-PCI bridge.John Baldwin2012-03-021-0/+1
| | | | | | | | | | | | | | | | | | The tag enforces a single restriction that all DMA transactions must not cross a 4GB boundary. Note that while this restriction technically only applies to PCI-express, this change applies it to all PCI devices as it is simpler to implement that way and errs on the side of caution. - Add a softc structure for PCI bus devices to hold the bus_dma tag and a new pci_attach_common() routine that performs actions common to the attach phase of all PCI bus drivers. Right now this only consists of a bootverbose printf and the allocate of a bus_dma tag if necessary. - Adjust all PCI bus drivers to allocate a PCI bus softc and to call pci_attach_common() from their attach routines. MFC after: 2 weeks Notes: svn path=/head/; revision=232403
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Partially revert 222753: If a CardBus card stores its CIS in a BAR, deleteJohn Baldwin2011-09-121-0/+1
| | | | | | | | | | | | the BAR after parsing the CIS. This forces the resource range to be reallocated if the BAR is reused by the device. Submitted by: deischen Reviewed by: imp Approved by: re (kib) Notes: svn path=/head/; revision=225515
* Minor cleanup:Warner Losh2011-06-211-5/+16
| | | | | | | | | | | o Consider No CIS a normal event and stop whining about it so much (too many cards are like this, espeically usb/firewire cards). o Add comments to the cis reading code. o Made the read from config space a smidge easier to read and eliminate a loop that can be done mathematically. Notes: svn path=/head/; revision=223386
* More properly handle Cardbus cards that that store their CIS in a BAR afterJohn Baldwin2011-06-061-3/+2
| | | | | | | | | | | | the recent changes to track BAR state explicitly. The code would now attempt to add the same BAR twice in this case. Instead, change this so that it recognizes this case and only adds it once and do not delete the BAR outright after parsing the CIS. Tested by: bschmidt Notes: svn path=/head/; revision=222753
* Don't explicitly list pci_write_ivar() for bus_write_ivar, the method isJohn Baldwin2011-05-021-1/+0
| | | | | | | already inherited from the PCI bus driver. Notes: svn path=/head/; revision=221327
* Move the PCI-specific logic of removing a cardbus device into aJohn Baldwin2010-01-051-30/+1
| | | | | | | | | | | | pci_delete_child() function called by the cardbus driver. The new function uses resource_list_unreserve() to release the BARs decoded by the device being removed. Reviewed by: imp Tested by: brooks Notes: svn path=/head/; revision=201609
* Fix an error case I missed in the previous change so that the CIS resourceJohn Baldwin2009-12-301-2/+2
| | | | | | | is fully cleaned up if we fail to find the CIS in the devices ROM. Notes: svn path=/head/; revision=201286
* Delete the CIS resource after releasing it. This is needed when the CIS isJohn Baldwin2009-12-301-2/+3
| | | | | | | | | stored in a BAR since the CIS BAR is mapped before the PCI bus driver enumerates all the BARs. Without this change, the PCI bus driver would attempt to initialize a BAR that was already allocated resulting in a panic. Notes: svn path=/head/; revision=201280
* Teach the PCI bus driver to handle PCIR_BIOS BARs properly and remove specialJohn Baldwin2009-12-301-6/+0
| | | | | | | | | | | | handling for the PCIR_BIOS decoding enable bit from the cardbus driver. The PCIR_BIOS BAR does include type bits like other BARs. Instead, it is always a 32-bit non-prefetchable memory BAR where the low bit is used as a flag to enable decoding. Reviewed by: imp Notes: svn path=/head/; revision=201279
* Use bus_*() rather than bus_space_*().John Baldwin2009-12-301-17/+7
| | | | Notes: svn path=/head/; revision=201278
* Minorly improved debugging. Use the DEVPRINTF macro and report theWarner Losh2009-03-131-13/+7
| | | | | | | offset for memory when mapping in the CIS. Notes: svn path=/head/; revision=189755
* Move the deactivation of the device's BAR to before the loop where weWarner Losh2009-03-121-5/+5
| | | | | | | | turn deactivate the resources. While this likely doesn't matter, it is likely to be safer. Notes: svn path=/head/; revision=189731
* Restore blank line removed when fixing my earlier botch. Never doWarner Losh2009-03-101-0/+1
| | | | | | | | | just one last change before bed... Pointy had to: imp Notes: svn path=/head/; revision=189653
* Complete removal of cardbus_write_ivar which was left hanging.George V. Neville-Neil2009-03-101-3/+0
| | | | Notes: svn path=/head/; revision=189636
* When freeing all the resources of the card, it is better to turn offWarner Losh2009-03-101-15/+11
| | | | | | | | | | | | | | | the PORTEN and MEMEN bits in the command register than to zero the bars. Use pci_write_ivar directly instead of a one-line wrapper that adds no value. Track verbosity changes in pci. Remove a stray blank line. Notes: svn path=/head/; revision=189619
* Remove unused variable.Wojciech A. Koszek2009-02-061-2/+0
| | | | | | | | Found with: Coverity Prevent(tm) CID: 4138 Notes: svn path=/head/; revision=188216
* Goof, catch up to constant rename (I renamed it to match the overall PCIJohn Baldwin2009-02-021-1/+1
| | | | | | | | | style of having register offsets start with PCIR_* rather than PCI_*). Submitted by: rss Notes: svn path=/head/; revision=188033
* When no driver attaches to a card, don't power down the card. We canWarner Losh2008-12-311-1/+2
| | | | | | | | | now read config registers of cardbus cards that are inserted, but aren't attached to a driver. Also, add a power related comment... Notes: svn path=/head/; revision=186642
* Don't call destroy_dev on the alias. This fixes half a dozen PRs I think.Warner Losh2008-12-022-7/+4
| | | | Notes: svn path=/head/; revision=185545
* Create a /dev/cardbus%d.cis, to be compatible with older versions ofWarner Losh2008-11-212-1/+6
| | | | | | | | the software. This is a trivial amount of code to keep wireless monitoring software working... I plan on removing it in 9.0. Notes: svn path=/head/; revision=185140