History log of /freebsd/sys/kern/subr_bus.c (Results 1 – 25 of 864)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 06ec77a4 25-Jun-2025 Gleb Smirnoff <glebius@FreeBSD.org>

gone_in: initialize va before passing it to gone_panic()

Fixes: 01addd846c64fc2c8be610d83bfdc84ddb57f2ec


# 01addd84 25-Jun-2025 Gleb Smirnoff <glebius@FreeBSD.org>

gone_in: make it __printflike()

Provide flexibility to use format strings for gone_in(). As a side
effect, this removes hardcoded string "Obsolete code will be removed
soon:" from the message, so n

gone_in: make it __printflike()

Provide flexibility to use format strings for gone_in(). As a side
effect, this removes hardcoded string "Obsolete code will be removed
soon:" from the message, so now it is obligation of the deprecated code to
provide a meaningful message. This required a small adoption of the
existing users: midi, drm2 and le(4). Note that gone_in() is not a public
KPI as it has no sense to use it outside of the FreeBSD tree.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D50783

show more ...


# e453e498 11-Jun-2025 Brooks Davis <brooks@FreeBSD.org>

machine/stdarg.h -> sys/stdarg.h

Switch to using sys/stdarg.h for va_list type and va_* builtins.

Make an attempt to insert the include in a sensible place. Where
style(9) was followed this is eas

machine/stdarg.h -> sys/stdarg.h

Switch to using sys/stdarg.h for va_list type and va_* builtins.

Make an attempt to insert the include in a sensible place. Where
style(9) was followed this is easy, where it was ignored, aim for the
first block of sys/*.h headers and don't get too fussy or try to fix
other style bugs.

Reviewed by: imp
Exp-run by: antoine (PR 286274)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1595

show more ...


Revision tags: release/14.3.0, release/13.4.0-p5, release/13.5.0-p1, release/14.2.0-p3
# b8b5cc33 10-Mar-2025 John Baldwin <jhb@FreeBSD.org>

new-bus: Use M_WAITOK in more places

M_NOWAIT is now only used for devclass_get_devices,
devclass_get_drivers, and device_get_children. Other functions are
generally called from sleepable contexts

new-bus: Use M_WAITOK in more places

M_NOWAIT is now only used for devclass_get_devices,
devclass_get_drivers, and device_get_children. Other functions are
generally called from sleepable contexts such as module event
handlers, attach/detach routines, and the ioctl handler for
/dev/devctl2.

Suggested by: mjg (devclass_add_device)
Differential Revision: https://reviews.freebsd.org/D49274

show more ...


# 78cd83e4 10-Mar-2025 John Baldwin <jhb@FreeBSD.org>

devclass_alloc_unit: Go back to using M_WAITOK

This restores a change made earlier in f3d3c63442fff.

This reverts commit 234683726708cf5212d672d676d30056d4133859.

Reviewed by: imp
Differential Rev

devclass_alloc_unit: Go back to using M_WAITOK

This restores a change made earlier in f3d3c63442fff.

This reverts commit 234683726708cf5212d672d676d30056d4133859.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D49273

show more ...


# 44d5f5ed 10-Mar-2025 John Baldwin <jhb@FreeBSD.org>

new-bus: Add taskqueue_bus to process hot-plug device events

Use a system-wide taskqueue for hot-plug events. This avoids possibly
blocking unrelated events on the thread taskqueue without requirin

new-bus: Add taskqueue_bus to process hot-plug device events

Use a system-wide taskqueue for hot-plug events. This avoids possibly
blocking unrelated events on the thread taskqueue without requiring
multiple driver-specific taskqueues.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D49268

show more ...


Revision tags: release/13.5.0
# 23468372 06-Mar-2025 Mateusz Guzik <mjg@FreeBSD.org>

devclass: make devclass_alloc_unit use M_NOWAIT

The only caller already does this.

The routine can be called with a mutex held making M_WAITOK illegal.

Sponsored by: Rubicon Communications, LLC ("

devclass: make devclass_alloc_unit use M_NOWAIT

The only caller already does this.

The routine can be called with a mutex held making M_WAITOK illegal.

Sponsored by: Rubicon Communications, LLC ("Netgate")

show more ...


Revision tags: release/14.2.0-p2, release/14.1.0-p8, release/13.4.0-p4
# 7979205e 05-Feb-2025 John Baldwin <jhb@FreeBSD.org>

new-bus: Rename bus_generic_get_resource_list to null_get_resource_list

Make it static to bus_if.c similar to other null bus methods used as
the default implementation of a bus method.

Differential

new-bus: Rename bus_generic_get_resource_list to null_get_resource_list

Make it static to bus_if.c similar to other null bus methods used as
the default implementation of a bus method.

Differential Revision: https://reviews.freebsd.org/D48362

show more ...


Revision tags: release/14.1.0-p7, release/14.2.0-p1, release/13.4.0-p3
# b196276c 02-Jan-2025 John Baldwin <jhb@FreeBSD.org>

bus_generic_detach: Delete children after detaching them

This provides better semantics as a standalone DEVMETHOD for
device_attach as bus drivers should remove child devices they created
as part of

bus_generic_detach: Delete children after detaching them

This provides better semantics as a standalone DEVMETHOD for
device_attach as bus drivers should remove child devices they created
as part of detach cleanup. The implementation calls
bus_detach_children() first to permit child devices an opportunity to
veto the detach operation. If that succeeds, device_delete_children()
is used to delete the child devices.

This requires fixing various drivers that were deleting devices
explicitly (via a device_t pointer cached in the softc) after calling
bus_generic_detach to stop doing that and just rely on
bus_generic_detach to remove child devices.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47959

show more ...


# 34f5de82 06-Dec-2024 John Baldwin <jhb@FreeBSD.org>

bus_delayed_attach_children: Switch return type to void

This function never fails similar to bus_attach_children.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47677


# 46297859 06-Dec-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Add bus_(identify|attach|detach)_children

These correspond to the current implementations of
bus_generic_(probe|attach|detach) but with more accurate names and
semantics. The intention is

new-bus: Add bus_(identify|attach|detach)_children

These correspond to the current implementations of
bus_generic_(probe|attach|detach) but with more accurate names and
semantics. The intention is to deprecate bus_generic_(probe|attach)
and reimplement bus_generic_detach in a future commit.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47673

show more ...


Revision tags: release/14.2.0
# b4c700fa 23-Nov-2024 John Baldwin <jhb@FreeBSD.org>

new-bus: Fix some shortcomings in disabling devices via hints

A device can be disabled via a hint after it is probed (but before it
is attached). The initial version of this marked the device disab

new-bus: Fix some shortcomings in disabling devices via hints

A device can be disabled via a hint after it is probed (but before it
is attached). The initial version of this marked the device disabled,
but left the device "alive" meaning that dev->driver and dev->desc
were untouched and still pointed into the driver that probed the
device. If that driver lives in a kernel module that is later
unloaded, device_detach() called from devclass_delete_driver() doesn't
do anything (the device's state is DS_ALIVE). In particular, it
doesn't call device_set_driver(dev, NULL) to disassociate the device
from the driver that is being unloaded.

There are several places where these stale pointers can be tripped
over. After kldunload, invoking the sysctl to fetch device info can
dereference dev->desc and dev->driver causing panics. Even without
kldunload, a system suspend request will call the device_suspend and
device_resume DEVMETHODs of the driver in question even though the
device is not attached which can cause some excitement.

To clean this up, more fully detach a device that is disabled by a
hint by clearing the driver and setting the state to DS_NOTPRESENT.
However, to keep the device name+unit combination reserved, leave the
device attached to its devclass.

This requires a change to 'devctl enable' handling to deal with this
updated state. It now checks for a non-NULL devclass to determine if
a disabled device is in this state and if so it clears the hint.
However, it also now clears the devclass before attaching the device.
This gives all drivers an opportunity to attach to the now-enabled
device.

Reported by: adrian
Discussed with: imp
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47691

show more ...


# 3514f989 06-Oct-2024 Elliott Mitchell <ehem+freebsd@m5p.com>

newbus: Introduce bus_get_pass() and hide bus_current_pass

There's no reason to write to bus_current_pass outside of the controlled
times subr_bus.c does it, so move to an accessor and make
bus_curr

newbus: Introduce bus_get_pass() and hide bus_current_pass

There's no reason to write to bus_current_pass outside of the controlled
times subr_bus.c does it, so move to an accessor and make
bus_current_pass private to newbus.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1457

show more ...


# 055b4105 31-Oct-2024 Warner Losh <imp@FreeBSD.org>

newbus: Limit units to [0, INT_MAX)

Limit the number of units a newbus device can have to be a positive
number. Reserve and reject the unit INT_MAX so that we can set maxunit
to INT_MAX without ill

newbus: Limit units to [0, INT_MAX)

Limit the number of units a newbus device can have to be a positive
number. Reserve and reject the unit INT_MAX so that we can set maxunit
to INT_MAX without ill effect and so the normal signed int math
works. Add sanity checks to make sure we don't get negative unit numbers
from bus routines that can set the unit. Remove now-redundant check for
unit >=0 since it must be after an earlier check.

This should be largely a nop, since we'll likely run out of memory
before we have 2^31 devices. Also, finding unit number is O(n^2) since
we do linear searches for the next unit number, which even on very fast
machines will grind to a halt well before we reach this limit...

Add note to device_find_free_unit that says it can return INT_MAX when
all the unit numbers are in use. The one user in the tree
(ata_pci_attach) will then add a child with this unit and it will fail
and that failure will be handled properly. Hardware limitations, though
mean there will never be more than tens of units, let alone billions.

Update docs to document that EINVAL can be returned for bogus unit
numbers, or when we run out.

Sponsored-by: Netflix
Reviewed-by: jhb
Differential-Revision: https://reviews.freebsd.org/D47359
Co-Authored-by: Elliott Mitchell <ehem+freebsd@m5p.com>

show more ...


# f3d3c634 31-Oct-2024 Warner Losh <imp@FreeBSD.org>

newbus: Simplify reallocation of devices array

Simplify the complex expression down to what it is on 64-bit systems.
32-bit kernels would allocate 2 at a time. Replace all that with
reallocf which w

newbus: Simplify reallocation of devices array

Simplify the complex expression down to what it is on 64-bit systems.
32-bit kernels would allocate 2 at a time. Replace all that with
reallocf which will eliminate a bunch of copies. This should be faster
and simpler on both types of kernels. In addition, transition to
M_WAITOK since this is a sleepable context.

Suggested by: jhb
Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D47362

show more ...


# d6528015 29-Oct-2024 Andrew Turner <andrew@FreeBSD.org>

bus: Fix the non-debug build

We read the rman type twice. Replace the second call to rman_get_type
with the value we already have.

Reported by: bapt, Herbert J. Skuhra <herbert@gojira.at>
Sponsored

bus: Fix the non-debug build

We read the rman type twice. Replace the second call to rman_get_type
with the value we already have.

Reported by: bapt, Herbert J. Skuhra <herbert@gojira.at>
Sponsored by: Arm Ltd

show more ...


# c85855a7 29-Oct-2024 Andrew Turner <andrew@FreeBSD.org>

bus: Activate INTRNG interrupts in common code

We need to call into INTRNG to activate all interrupts on platforms that
use it. Currently, interrupts are only activated in the nexus drivers for
INT

bus: Activate INTRNG interrupts in common code

We need to call into INTRNG to activate all interrupts on platforms that
use it. Currently, interrupts are only activated in the nexus drivers for
INTRNG platforms, but this does not handle other bus devices such as
gpiobus that manage their own IRQ space.

Reported by: cperciva
Reviewed by: cperciva, jhb
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D47282

show more ...


# f4e35c04 19-Oct-2024 Mark Johnston <markj@FreeBSD.org>

bus: Set the current VNET in device_attach()

Some drivers, in particular anything which creates an ifnet during
attach, need to have the current VNET set, as if_attach_internal() and
its callees acc

bus: Set the current VNET in device_attach()

Some drivers, in particular anything which creates an ifnet during
attach, need to have the current VNET set, as if_attach_internal() and
its callees access VNET-global variables.

device_probe_and_attach() handles this, but this is not the only way to
arrive in DEVICE_ATTACH. In particular, bus drivers may invoke
device_attach() directly, as does devctl2's DEV_ENABLE ioctl handler.
So, set the current VNET in device_attach() instead.

I believe it is always safe to use vnet0, as devctl2 ioctls are not
permitted within a jail.

PR: 282168
Reviewed by: zlei, kevans, bz, imp, glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47174

show more ...


# b08d332d 13-Oct-2024 Konstantin Belousov <kib@FreeBSD.org>

devices: report iommu data for the device in the dev. sysctl tree

Show the iommu unit' device name/unit which translates the device'
requests, if any, as parsed out from the BIOS tables.
Also show t

devices: report iommu data for the device in the dev. sysctl tree

Show the iommu unit' device name/unit which translates the device'
requests, if any, as parsed out from the BIOS tables.
Also show the rid value for the device.

Sponsored by: Advanced Micro Devices (AMD)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D47098

show more ...


Revision tags: release/13.4.0
# cb83af64 08-Sep-2024 Konstantin Belousov <kib@FreeBSD.org>

device: add generic named per-device property

The KPI allows to store arbitrary data within struct device, retrieve it
back by name, and update the value. The data is automatically destroyed
on the

device: add generic named per-device property

The KPI allows to store arbitrary data within struct device, retrieve it
back by name, and update the value. The data is automatically destroyed
on the device deletion. Also, the user can request to clear the named
property from all devices.

My need for this interface is due to IOMMU needing to save some
indicator on device, which must survive the re-creation of the domain
context.

Reviewed by: imp
Discussed with: emaste
Sponsored by: Advanced Micro Devices (AMD)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D46605

show more ...


# 3342afcb 16-Oct-2024 John Baldwin <jhb@FreeBSD.org>

bus_generic_detach: Remove redundant check

device_detach() checks the device state and only calls a driver's
DEVICE_DETACH method if the device is attached but not busy.

Reviewed by: imp
Differenti

bus_generic_detach: Remove redundant check

device_detach() checks the device state and only calls a driver's
DEVICE_DETACH method if the device is attached but not busy.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47156

show more ...


# 42078dfb 16-Oct-2024 John Baldwin <jhb@FreeBSD.org>

device_attach: Invoke BUS_CHILD_DETACHED if an attach routine fails

This gives the parent bus driver the opportunity to cleanup any
allocated resources, etc. left behind by a failed attach attempt.

device_attach: Invoke BUS_CHILD_DETACHED if an attach routine fails

This gives the parent bus driver the opportunity to cleanup any
allocated resources, etc. left behind by a failed attach attempt.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47155

show more ...


# 1ad33519 16-Oct-2024 John Baldwin <jhb@FreeBSD.org>

device_delete_child: Update comments

This better matches the variable names and the function comment as
well as clarifying the reason for the order of operations.

Reviewed by: imp
Differential Revi

device_delete_child: Update comments

This better matches the variable names and the function comment as
well as clarifying the reason for the order of operations.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47154

show more ...


# 42b7e9c4 16-Oct-2024 Warner Losh <imp@FreeBSD.org>

newbus: Remove redundant check for 0

We already checked to see if the return code is 0 above. This code is
redundant. However, it's here so we can break out two layers, which a
simple goto fixes. A

newbus: Remove redundant check for 0

We already checked to see if the return code is 0 above. This code is
redundant. However, it's here so we can break out two layers, which a
simple goto fixes. A subsequent change makes the pri < 0 condition no
longer hold. This allows us to simplify a few things.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D44269

show more ...


# fdd100a7 07-Oct-2024 Mark Johnston <markj@FreeBSD.org>

devctl: Add missing validation to DEV_RESET

As in other ioctls which access the parent bus, we need to check for a
NULL parent here. Otherwise it's possible to trigger a null pointer
dereference by

devctl: Add missing validation to DEV_RESET

As in other ioctls which access the parent bus, we need to check for a
NULL parent here. Otherwise it's possible to trigger a null pointer
dereference by resetting the root device.

Reported by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D46965

show more ...


12345678910>>...35