path: root/sys/sys/bus.h
Commit message (Collapse)AuthorAgeFilesLines
* Add NetBSD compatible bus_space_peek_N() and bus_space_poke_N() functions.Michal Meloun2020-09-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | One problem with the bus_space_read_N() and bus_space_write_N() family of functions is that they provide no protection against exceptions which can occur when no physical hardware or device responds to the read or write cycles. In such a situation, the system typically would panic due to a kernel-mode bus error. The bus_space_peek_N() and bus_space_poke_N() family of functions provide a mechanism to handle these exceptions gracefully without the risk of crashing the system. Typical example is access to PCI(e) configuration space in bus enumeration function on badly implemented PCI(e) root complexes (RK3399 or Neoverse N1 N1SDP and/or access to PCI(e) register when device is in deep sleep state. This commit adds a real implementation for arm64 only. The remaining architectures have bus_space_peek()/bus_space_poke() emulated by using bus_space_read()/bus_space_write() (without exception handling). MFC after: 1 month Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D25371 Notes: svn path=/head/; revision=365899
* sys: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+1
| | | | Notes: svn path=/head/; revision=365223
* Move devctl_notify* to devctl.h.Warner Losh2020-08-201-12/+1
| | | | Notes: svn path=/head/; revision=364428
* Make devctl_queue_data_f and devctl_queue_data private.Warner Losh2020-08-201-4/+1
| | | | | | | | I thought we'd need them, but nobody is using them. Narrow the interface. This will facilitate changes in the future. Notes: svn path=/head/; revision=364427
* Create new wrapper function: bus_delayed_attach_children()Warner Losh2019-12-131-0/+1
| | | | | | | | | | | | | Delay the attachment of children, when requested, until after interrutps are running. This is often needed to allow children to run transactions on i2c or spi busses. It's a common enough idiom that it will be useful to have its own wrapper. Reviewed by: ian Differential Revision: https://reviews.freebsd.org/D21465 Notes: svn path=/head/; revision=355727
* Add necessary bits for Linux KPI to work correctly on powerpcJustin Hibbits2019-08-041-0/+2
| | | | | | | | | | | | | | | | | | | | | PowerPC, and possibly other architectures, use different address ranges for PCI space vs physical address space, which is only mapped at resource activation time, when the BAR gets written. The DRM kernel modules do not activate the rman resources, soas not to waste KVA, instead only mapping parts of the PCI memory at a time. This introduces a BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI driver, to perform this necessary translation without activating the resource. In addition to system KPI changes, LinuxKPI is updated to handle a big-endian host, by adding proper endian swaps to the I/O functions. Submitted by: mmacy Reported by: hselasky Differential Revision: https://reviews.freebsd.org/D21096 Notes: svn path=/head/; revision=350570
* upgrade the warning printf-s in bus accessors to KASSERT-s, take 2Andriy Gapon2019-07-011-12/+7
| | | | | | | | | | | After this change sys/bus.h includes sys/systm.h when _KERNEL is defined. This brings back r349459 but with systm.h hidden from userland. MFC after: 2 weeks Notes: svn path=/head/; revision=349571
* revert r349460, printf -> KASSERT in bus.h, until I can fix itAndriy Gapon2019-06-271-7/+12
| | | | | | | | | | I tested only kernel builds naively assuming that sys/bus.h cannot affect userland builds. Pointyhat to: me Notes: svn path=/head/; revision=349461
* upgrade the warning printf-s in bus accessors to KASSERT-sAndriy Gapon2019-06-271-12/+7
| | | | | | | | | | After this change sys/bus.h includes sys/systm.h. Discussed with: cem, imp MFC after: 2 weeks Notes: svn path=/head/; revision=349459
* first step towards enforcing must-succeed semantics for bus accessorsAndriy Gapon2019-06-051-2/+16
| | | | | | | | | | | | | | | | | | | | | | | Unlike BUS_READ_IVAR / BUS_WRITE_IVAR, bus accessors do not have a return code. It is assumed that there is a tight coupling between a bus driver and a driver for a device on the bus with respect to instance variables that the bus defines for its children. So, the driver is supposed to have only valid accesses to the variables and, thus, the accessors must always succeed. Of course, programming errors sometimes happen. At present, such errors go completely unnoticed. The idea of this change is to start catching them. As a first step, there will be a warning about a failed accessor call. This is to give developers a heads-up. I plan to replace the printf with a KASSERT a week later, so that the warning is harder to ignore. Reviewed by: cem, imp, ian MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20458 Notes: svn path=/head/; revision=348688
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add DEV_RESET /dev/devctl2 ioctl.Konstantin Belousov2019-04-051-0/+1
| | | | | | | | | | | | | It performs BUS_RESET_CHILD() on the parental bus and the specified device. Reviewed by: imp (previous version), jhb (previous version) Sponsored by: Mellanox Technologies MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19646 Notes: svn path=/head/; revision=345965
* Provide newbus infrastructure for initiating device reset.Konstantin Belousov2019-04-051-0/+6
| | | | | | | | | | | | | | | | | | | The methods BUS_RESET_PREPARE(), BUS_RESET(), and BUS_RESET_POST() should be implemented by bus which can provide reset to a device. The methods are described in inline doxygen comments. Code only provides BUS_RESET_PREPARE() and BUS_RESET_POST() helpers instead of default implementation, because actual bus needs to handle device state around reset, while helpers provide the other half of typical prepare/post code. Reviewed by: imp (previous version), jhb (previous version) Sponsored by: Mellanox Technologies MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19646 Notes: svn path=/head/; revision=345960
* add support for marking interrupt handlers as suspendedAndriy Gapon2018-12-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this change is to fix a problem with PCI shared interrupts during suspend and resume. I have observed a couple of variations of the following scenario. Devices A and B are on the same PCI bus and share the same interrupt. Device A's driver is suspended first and the device is powered down. Device B generates an interrupt. Interrupt handlers of both drivers are called. Device A's interrupt handler accesses registers of the powered down device and gets back bogus values (I assume all 0xff). That data is interpreted as interrupt status bits, etc. So, the interrupt handler gets confused and may produce some noise or enter an infinite loop, etc. This change affects only PCI devices. The pci(4) bus driver marks a child's interrupt handler as suspended after the child's suspend method is called and before the device is powered down. This is done only for traditional PCI interrupts, because only they can be shared. At the moment the change is only for x86. Notable changes in core subsystems / interfaces: - BUS_SUSPEND_INTR and BUS_RESUME_INTR methods are added to bus interface along with convenience functions bus_suspend_intr and bus_resume_intr; - rman_set_irq_cookie and rman_get_irq_cookie functions are added to provide a way to associate an interrupt resource with an interrupt cookie; - intr_event_suspend_handler and intr_event_resume_handler functions are added to the MI interrupt handler interface. I added two new interrupt handler flags, IH_SUSP and IH_CHANGED, to implement the new intr_event functions. IH_SUSP marks a suspended interrupt handler. IH_CHANGED is used to implement a barrier that ensures that a change to the interrupt handler's state is visible to future interrupts. While there, I fixed some whitespace issues in comments and changed a couple of logically boolean variables to be bool. MFC after: 1 month (maybe) Differential Revision: https://reviews.freebsd.org/D15755 Notes: svn path=/head/; revision=342170
* acpi: fix acpi_ec_probe to only check EC devicesBen Widawsky2018-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch utilizes the fixed_devclass attribute in order to make sure other acpi devices with params don't get confused for an EC device. The existing code assumes that acpi_ec_probe is only ever called with a dereferencable acpi param. Aside from being incorrect because other devices of ACPI_TYPE_DEVICE may be probed here which aren't ec devices, (and they may have set acpi private data), it is even more nefarious if another ACPI driver uses private data which is not dereferancable. This will result in a pointer deref during boot and therefore boot failure. On X86, as it stands today, no other devices actually do this (acpi_cpu checks for PROCESSOR type devices) and so there is no issue. I ran into this because I am adding such a device which gets probed before acpi_ec_probe and sets private data. If ARM ever has an EC, I think they'd run into this issue as well. There have been several iterations of this patch. Earlier iterations had ECDT enumerated ECs not call into the probe/attach functions of this driver. This change was Suggested by: jhb@. Reviewed by: jhb Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D16635 Notes: svn path=/head/; revision=340644
* Add a new device flag: DF_ATTACHED_ONCEWarner Losh2018-08-231-0/+1
| | | | | | | | | | | | | | This flag is set once the device has been successfully attached. When set, it inhibits devmatch from trying to match the device. This in turn allows kldunload to work as expected. Prior to the change, the driver would immediately reload because devmatch had no notion that the driver had once been attached, and therefore shouldn't participate in further matching. Differential Revision: https://reviews.freebsd.org/D16735 Notes: svn path=/head/; revision=338236
* Create devctl freeze/thaw.Warner Losh2018-08-231-1/+4
| | | | | | | | | | | | This adds it to devctl, libdevctl, defines the two IOCTLs and implements the kernel bits. causes any new drivers that are added via kldload to be deferred until a 'thaw' comes in. These do not stack: it is an error to freeze while frozen, or thaw while thawed. Differential Revision: https://reviews.freebsd.org/D16735 Notes: svn path=/head/; revision=338233
* Remove devctl_safe_quote since it's now unused.Warner Losh2018-06-271-1/+0
| | | | | | | | Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D16026 Notes: svn path=/head/; revision=335692
* Create new devctl_safe_quote_sb to copy a source string into a structWarner Losh2018-06-271-1/+3
| | | | | | | | | | | sbuf to make it safe. Callers are expected to add the " " around it, if needed. Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D16026 Notes: svn path=/head/; revision=335689
* Make the data returned by devinfo harder to overflow.Warner Losh2018-05-311-8/+11
| | | | | | | | | | | | | | Rather than using fixed-length strings, pack them into a string table to return. Also expand the buffer from ~300 charaters to 3k. This should be enough, even for USB. This fixes a problem where USB pnp info is truncated on return to userland. Differential Revision: https://reviews.freebsd.org/D15629 Notes: svn path=/head/; revision=334414
* Add device_quiet_children() and device_has_quiet_children()Warner Losh2018-05-071-0/+3
| | | | | | | | | | | | If you add a child to a device that has quiet children, we'll automatically set the quiet flag on the children, and its children. This is indended for things like CPU that have a large amount of repetition in booting that adds nothing. Notes: svn path=/head/; revision=333333
* Introduce BUS_PASS_SUPPORTDEVEmmanuel Vadot2018-03-031-0/+1
| | | | | | | | | | | | | | | | | | The reason for this new pass is : The earlier pass names are really specific (interrupt, timer, scheduler etc ..) and making a driver that other device driver (that attach at DEFAULT pass) needs probe at earlier pass can be confiusing. We can live with GPIO driver at INTERRUPT pass because they are often an interrupt controller too but having a usb phy driver probed at RESOURCES (or SCHEDULER for example) is silly. The number was choosen to have a lot of margin if we want to introduce other pass in the futur. Reviewed by: ian, imp, kevans Differential Revision: https://reviews.freebsd.org/D14568 Notes: svn path=/head/; revision=330335
* sys/sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | 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=326256
* Add a #define RESOURCE_SPEC_END. Similar to DEVMETHOD_END andIan Lepore2017-10-281-0/+1
| | | | | | | | KOBJMETHOD_END, this is to serve as the end marker in an array of resource_spec structures. Notes: svn path=/head/; revision=325060
* Remove resource_set_*() declarations from sys/bus.h.Mark Johnston2017-10-231-7/+0
| | | | | | | | | | | The corresponding definitions were removed in r78135. PR: 223189 Submitted by: marc.priggemeyer@gmail.com MFC after: 1 week Notes: svn path=/head/; revision=324923
* Add a INTR_TRIG_INVALID, and use it in the powerpc interrupt code.Justin Hibbits2017-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: Clang throws the following warning in powerpc intr_machdep: /usr/src/sys/powerpc/powerpc/intr_machdep.c:454:15: warning: comparison of constant -1 with expression of type 'enum intr_trigger' is always false [-Wtautological-constant-out-of-range-compare] if (i->trig == -1) ~~~~~~~ ^ ~~ This may lead to legitimate problems with aggressive optimizations, if not now then in the future. To avoid this, add a new enum, INTR_TRIG_INVALID, set to -1, and use this new enumeration in these checks. Test Plan: Compile test. Reviewed By: jhb, kib Differential Revision: https://reviews.freebsd.org/D9300 Notes: svn path=/head/; revision=312974
* Fix a variety of cosmetic typos and misspellingsConrad Meyer2017-01-151-2/+2
| | | | | | | | | | | No functional change. PR: 216096, 216097, 216098, 216101, 216102, 216106, 216109, 216110 Reported by: Bulat <bltsrc at mail.ru> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312235
* "Buses" is the preferred plural of "bus"Conrad Meyer2017-01-151-5/+5
| | | | | | | | | | | | | | | | | | | | Replace archaic "busses" with modern form "buses." Intentionally excluded: * Old/random drivers I didn't recognize * Old hardware in general * Use of "busses" in code as identifiers No functional change. http://grammarist.com/spelling/buses-busses/ PR: 216099 Reported by: bltsrc at mail.ru Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312234
* Implement 'devctl clear driver' to undo a previous 'devctl set driver'.John Baldwin2016-08-291-0/+4
| | | | | | | | | | | | | | | Add a new 'clear driver' command for devctl along with the accompanying ioctl and devctl_clear_driver() library routine to reset a device to use a wildcard devclass instead of a fixed devclass. This can be used to undo a previous 'set driver' command. After the device's name has been reset to permit wildcard names, it is reprobed so that it can attach to newly-available (to it) device drivers. MFC after: 1 month Sponsored by: Chelsio Communications Notes: svn path=/head/; revision=305034
* INTRNG: Rework handling with resources. Partially revert r301453.Michal Meloun2016-08-191-14/+0
| | | | | | | | | | | | | | | | | | | | - Read interrupt properties at bus enumeration time and store it into global mapping table. - At bus_activate_resource() time, given mapping entry is resolved and connected to real interrupt source. A copy of mapping entry is attached to given resource. - At bus_setup_intr() time, mapping entry stored in resource is used for delivery of requested interrupt configuration. - For MSI/MSIX interrupts, mapping entry is created within pci_alloc_msi()/pci_alloc_msix() call. - For legacy PCI interrupts, mapping entry must be created within pcib_route_interrupt() by pcib driver itself. Reviewed by: nwhitehorn, andrew Differential Revision: https://reviews.freebsd.org/D7493 Notes: svn path=/head/; revision=304459
* Add __printflike() to bus_describe_intr() to enable -Wformat checks.John Baldwin2016-08-041-1/+1
| | | | | | | | | | Fix a few places that were passing a raw string as the format to use a "%s" format string instead. MFC after: 2 months Notes: svn path=/head/; revision=303754
* (1) Add a new bus method to get a mapping data for an interrupt.Svatopluk Kraus2016-06-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BUS_MAP_INTR() is used to get an interrupt mapping data according to provided hints. The hints could be modified afterwards, but only if mapping data was allocated. This method is intended to be called before BUS_ALLOC_RESOURCE(). An interrupt mapping data describes an interrupt - hardware number, type, configuration, cpu binding, and whatever is needed to setup it. (2) Introduce a method which allows storing of an additional data in struct resource to be available for bus drivers. This method is convenient in two ways: - there is no need to rework existing bus drivers as they can simply be extended to provide an additional data, - there is no need to modify any existing bus methods as struct resource is already passed to them as argument and thus stored data is simply accessible by other bus drivers. For now, implement this method only for INTRNG. This is motivated by needs of modern SOCs where hardware initialization is not straightforward and resources descriptions are complex, opaque for everyone but provider, and may vary from SOC to SOC. Typical situation is that one bus driver can fetch a resource description for its child device, but it's opaque for this driver. Another bus driver knows a provider for this kind of resource and can pass this resource description to it. In fact, something like device IVARS would be perfect for that if implemented generally enough. Unfortunatelly, IVARS are usable only by their owners now. Only owner knows its IVARS layout, thus other bus drivers are not able to use them. Differential Revision: https://reviews.freebsd.org/D6632 Notes: svn path=/head/; revision=301451
* Add new bus methods for mapping resources.John Baldwin2016-05-201-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a pair of bus methods that can be used to "map" resources for direct CPU access using bus_space(9). bus_map_resource() creates a mapping and bus_unmap_resource() releases a previously created mapping. Mappings are described by 'struct resource_map' object. Pointers to these objects can be passed as the first argument to the bus_space wrapper API used for bus resources. Drivers that wish to map all of a resource using default settings (for example, using uncacheable memory attributes) do not need to change. However, drivers that wish to use non-default settings can now do so without jumping through hoops. First, an RF_UNMAPPED flag is added to request that a resource is not implicitly mapped with the default settings when it is activated. This permits other activation steps (such as enabling I/O or memory decoding in a device's PCI command register) to be taken without creating a mapping. Right now the AGP drivers don't set RF_ACTIVE to avoid using up a large amount of KVA to map the AGP aperture on 32-bit platforms. Once RF_UNMAPPED is supported on all platforms that support AGP this can be changed to using RF_UNMAPPED with RF_ACTIVE instead. Second, bus_map_resource accepts an optional structure that defines additional settings for a given mapping. For example, a driver can now request to map only a subset of a resource instead of the entire range. The AGP driver could also use this to only map the first page of the aperture (IIRC, it calls pmap_mapdev() directly to map the first page currently). I will also eventually change the PCI-PCI bridge driver to request mappings of the subset of the I/O window resource on its parent side to create mappings for child devices rather than passing child resources directly up to nexus to be mapped. This also permits bridges that do address translation to request suitable mappings from a resource on the "upper" side of the bus when mapping resources on the "lower" side of the bus. Another attribute that can be specified is an alternate memory attribute for memory-mapped resources. This can be used to request a Write-Combining mapping of a PCI BAR in an MI fashion. (Currently the drivers that do this call pmap_change_attr() directly for x86 only.) Note that this commit only adds the MI framework. Each platform needs to add support for handling RF_UNMAPPED and thew new bus_map/unmap_resource methods. Generally speaking, any drivers that are calling rman_set_bustag() and rman_set_bushandle() need to be updated. Discussed on: arch Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D5237 Notes: svn path=/head/; revision=300317
* Add a new bus method to fetch device-specific CPU sets.John Baldwin2016-05-091-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bus_get_cpus() returns a specified set of CPUs for a device. It accepts an enum for the second parameter that indicates the type of cpuset to request. Currently two valus are supported: - LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to the device when DEVICE_NUMA is enabled) - INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core) For systems that do not support NUMA (or if it is not enabled in the kernel config), LOCAL_CPUS fails with EINVAL. INTR_CPUS is mapped to 'all_cpus' by default. The idea is that INTR_CPUS should always return a valid set. Device drivers which want to use per-CPU interrupts should start using INTR_CPUS instead of simply assigning interrupts to all available CPUs. In the future we may wish to add tunables to control the policy of INTR_CPUS (e.g. should it be local-only or global, should it ignore SMT threads or not). The x86 nexus driver exposes the internal set of interrupt CPUs from the the x86 interrupt code via INTR_CPUS. The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled. They also and the global INTR_CPUS set from the nexus driver with the per-domain set from _PXM to generate a local INTR_CPUS set for child devices. Compared to the r298933, this version uses 'struct _cpuset' in <sys/bus.h> instead of 'cpuset_t' to avoid requiring <sys/param.h> (<sys/_cpuset.h> still requires <sys/param.h> for MAXCPU even though <sys/_bitset.h> does not after recent changes). Notes: svn path=/head/; revision=299286
* Revert bus_get_cpus() for now.John Baldwin2016-05-031-15/+0
| | | | | | | | I really thought I had run this through the tinderbox before committing, but many places need <sys/types.h> -> <sys/param.h> for <sys/bus.h> now. Notes: svn path=/head/; revision=298951
* Add a new bus method to fetch device-specific CPU sets.John Baldwin2016-05-021-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bus_get_cpus() returns a specified set of CPUs for a device. It accepts an enum for the second parameter that indicates the type of cpuset to request. Currently two valus are supported: - LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to the device when DEVICE_NUMA is enabled) - INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core) For systems that do not support NUMA (or if it is not enabled in the kernel config), LOCAL_CPUS fails with EINVAL. INTR_CPUS is mapped to 'all_cpus' by default. The idea is that INTR_CPUS should always return a valid set. Device drivers which want to use per-CPU interrupts should start using INTR_CPUS instead of simply assigning interrupts to all available CPUs. In the future we may wish to add tunables to control the policy of INTR_CPUS (e.g. should it be local-only or global, should it ignore SMT threads or not). The x86 nexus driver exposes the internal set of interrupt CPUs from the the x86 interrupt code via INTR_CPUS. The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled. They also and the global INTR_CPUS set from the nexus driver with the per-domain set from _PXM to generate a local INTR_CPUS set for child devices. Reviewed by: wblock (manpage) Differential Revision: https://reviews.freebsd.org/D5519 Notes: svn path=/head/; revision=298933
* Add a bus_null_rescan() method that always fails with an error.John Baldwin2016-04-271-0/+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
* Add 'devctl delete' that calls device_delete_child().John Baldwin2016-04-271-0/+4
| | | | | | | | | | | | | | | | 'devctl delete' can be used to delete a device that is no longer present. As an anti-foot-shooting measure, 'delete' will not delete a device unless it's parent bus says it is no longer present. This can be overridden by passing the force ('-f') flag. Note that this command should be used with care. If a device is deleted that is actually present it can't be resurrected unless the parent bus device's driver supports rescans. Differential Revision: https://reviews.freebsd.org/D6019 Notes: svn path=/head/; revision=298709
* Add a new rescan method to the bus interface.John Baldwin2016-04-271-0/+1
| | | | | | | | | | | The BUS_RESCAN() method rescans a single bus device checking for devices that have been added or removed from the bus. A new 'rescan' command is added to devctl(8) to trigger a rescan. Differential Revision: https://reviews.freebsd.org/D6016 Notes: svn path=/head/; revision=298707
* Add a function to lookup a device_t object by name.John Baldwin2016-04-101-0/+1
| | | | | | | | | This just walks the global list of devices looking for one with the requested name. The one use case outside of devctl2's implementation is for DDB commands that wish to lookup devices by name. Notes: svn path=/head/; revision=297776
* Move pccard_safe_quote() up to subr_bus.c and rename toWarner Losh2016-03-281-0/+1
| | | | | | | devctl_safe_quote() so it can be used more generally. Notes: svn path=/head/; revision=297365
* Replace all resource occurrences of '0UL/~0UL' with '0/~0'.Justin Hibbits2016-03-031-2/+2
| | | | | | | | | | | | | | | | Summary: The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a 32-bit platform, will leave the upper 32 bits as 0. The maximum range of a resource is 0xFFF.... (all bits of the full type set). By dropping the 'ul' suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit platforms gets it to a type-independent 'unsigned max'. Reviewed By: cem Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5255 Notes: svn path=/head/; revision=296336
* Add the bus_alloc_resource_anywhere() convenience function.Justin Hibbits2016-02-271-0/+7
| | | | | | | | | | | | | | | Summary: Many instances of bus_alloc_resource() simply use 0 and ~0 for start and end to denote 'anywhere' with a given count. To clean this up, introduce a bus_alloc_resource_anywhere() convenience function. Bump __FreeBSD_version for the new API. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D5370 Notes: svn path=/head/; revision=296136
* Introduce bus_get_bus_tag() methodZbigniew Bodek2016-02-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | Provide bus_get_bus_tag() for sparc64, powerpc, arm, arm64 and mips nexus and its children in order to return a platform specific default tag. This is required to ensure generic correctness of the bus_space tag. It is especially needed for arches where child bus tag does not match the parent bus tag. This solves the problem with ppc architecture where the PCI bus tag differs from parent bus tag which is big-endian. This commit is a part of the following patch: https://reviews.freebsd.org/D4879 Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Reviewed by: jhibbits, mmel Differential Revision: https://reviews.freebsd.org/D4879 Notes: svn path=/head/; revision=295755
* Convert rman to use rman_res_t instead of u_longJustin Hibbits2016-01-271-25/+25
| | | | | | | | | | | | | | | | | | | | | | | Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075 Notes: svn path=/head/; revision=294883
* Change BUS_PROBE_HOOVER from -500 to -1000000. We have PCI bus driversMarcel Moolenaar2015-06-061-1/+1
| | | | | | | | | | | return -1000 and -10000 to establish a pecking order and we don't want catch-all or match-all drivers to attach instead of them. With this change poto(4) can be compiled into the kernel (or preloaded from the loader), without impact. Notes: svn path=/head/; revision=284088
* Fix SR-IOV passthrough devices to allow ppt to attachRyan Stone2015-03-101-0/+1
| | | | | | | | | | | | | | | | | | A late change to the SR-IOV infrastructure broke passthrough of VFs. device_set_devclass() was being used to try to force the ppt driver to attach to the device, but this didn't work because the DF_FIXEDCLASS flag wasn't being set on the device, so the ppt driver probe routine would not match when it returned BUS_NOWILDCARD. Fix this by adding a new device function that both sets the devclass and sets the DF_FIXEDCLASS flag, and use that to force the ppt driver to attach to VFs. Differential Revision: https://reviews.freebsd.org/D2041 Reviewed by: jhb MFC after: 3 weeks Notes: svn path=/head/; revision=279868
* Add a new device control utility for new-bus devices called devctl. ThisJohn Baldwin2015-02-061-1/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | allows the user to request administrative changes to individual devices such as attach or detaching drivers or disabling and re-enabling devices. - Add a new /dev/devctl2 character device which uses ioctls for device requests. The ioctls use a common 'struct devreq' which is somewhat similar to 'struct ifreq'. - The ioctls identify the device to operate on via a string. This string can either by the device's name, or it can be a bus-specific address. (For unattached devices, a bus address is the only way to locate a device.) Bus drivers register an eventhandler to claim unrecognized device names that the driver recognizes as a valid address. Two buses currently support addresses: ACPI recognizes any device in the ACPI namespace via its full path starting with "\" and the PCI bus driver recognizes an address specification of 'pci[<domain>:]<bus>:<slot>:<func>' (identical to the PCI selector strings supported by pciconf). - To make it easier to cut and paste, change the PnP location string in the PCI bus driver to output a full PCI selector string rather than 'slot=<slot> function=<func>'. - Add a devctl(3) interface in libdevctl which provides a wrapper around the ioctls and is the preferred interface for other userland code. - Add a devctl(8) program which is a simple wrapper around the requests supported by devctl(3). - Add a device_is_suspended() function to check DF_SUSPENDED. - Add a resource_unset_value() function that can be used to remove a hint from the kernel environment. This is used to clear a hint.<driver>.<unit>.disabled hint when re-enabling a boot-time disabled device. Reviewed by: imp (parts) Requested by: imp (changing PCI location string) Relnotes: yes Notes: svn path=/head/; revision=278320
* Expose the constants for internal new-bus device flags to userland. TheJohn Baldwin2015-02-051-1/+12
| | | | | | | | | flag value is already exposed via dv_flags, just not the meaning of the flags themselves. Use these constants to annotate devices that are disabled or suspended in devinfo output. Notes: svn path=/head/; revision=278299
* Revert device_getenv_int() for now as it duplicates resource_int_value().John Baldwin2014-12-031-1/+0
| | | | | | | | We should perhaps implement a device_getenv_*() and device_setenv_*() API as a convenience wrapper on top of resource_*_value() and resource_set_*(). Notes: svn path=/head/; revision=275460