164de8019SJohn Baldwin.\" 264de8019SJohn Baldwin.\" Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org> 364de8019SJohn Baldwin.\" 464de8019SJohn Baldwin.\" Redistribution and use in source and binary forms, with or without 564de8019SJohn Baldwin.\" modification, are permitted provided that the following conditions 664de8019SJohn Baldwin.\" are met: 764de8019SJohn Baldwin.\" 1. Redistributions of source code must retain the above copyright 864de8019SJohn Baldwin.\" notice, this list of conditions and the following disclaimer. 964de8019SJohn Baldwin.\" 2. Redistributions in binary form must reproduce the above copyright 1064de8019SJohn Baldwin.\" notice, this list of conditions and the following disclaimer in the 1164de8019SJohn Baldwin.\" documentation and/or other materials provided with the distribution. 1264de8019SJohn Baldwin.\" 1364de8019SJohn Baldwin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1464de8019SJohn Baldwin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1564de8019SJohn Baldwin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1664de8019SJohn Baldwin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1764de8019SJohn Baldwin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1864de8019SJohn Baldwin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1964de8019SJohn Baldwin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2064de8019SJohn Baldwin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2164de8019SJohn Baldwin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2264de8019SJohn Baldwin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2364de8019SJohn Baldwin.\" SUCH DAMAGE. 2464de8019SJohn Baldwin.\" 25f5366026SWarner Losh.Dd October 31, 2021 2664de8019SJohn Baldwin.Dt DEVCTL 8 2764de8019SJohn Baldwin.Os 2864de8019SJohn Baldwin.Sh NAME 2964de8019SJohn Baldwin.Nm devctl 3064de8019SJohn Baldwin.Nd device control utility 3164de8019SJohn Baldwin.Sh SYNOPSIS 3264de8019SJohn Baldwin.Nm 3364de8019SJohn Baldwin.Cm attach 3464de8019SJohn Baldwin.Ar device 3564de8019SJohn Baldwin.Nm 36e05ec081SJohn Baldwin.Cm clear driver 37e05ec081SJohn Baldwin.Op Fl f 38e05ec081SJohn Baldwin.Ar device 39e05ec081SJohn Baldwin.Nm 4064de8019SJohn Baldwin.Cm detach 4164de8019SJohn Baldwin.Op Fl f 4264de8019SJohn Baldwin.Ar device 4364de8019SJohn Baldwin.Nm 4464de8019SJohn Baldwin.Cm disable 4564de8019SJohn Baldwin.Op Fl f 4664de8019SJohn Baldwin.Ar device 4764de8019SJohn Baldwin.Nm 4864de8019SJohn Baldwin.Cm enable 4964de8019SJohn Baldwin.Ar device 5064de8019SJohn Baldwin.Nm 5164de8019SJohn Baldwin.Cm suspend 5264de8019SJohn Baldwin.Ar device 5364de8019SJohn Baldwin.Nm 5464de8019SJohn Baldwin.Cm resume 5564de8019SJohn Baldwin.Ar device 5664de8019SJohn Baldwin.Nm 5764de8019SJohn Baldwin.Cm set driver 5864de8019SJohn Baldwin.Op Fl f 5964de8019SJohn Baldwin.Ar device driver 60a907c691SJohn Baldwin.Nm 61a907c691SJohn Baldwin.Cm rescan 62a907c691SJohn Baldwin.Ar device 6388eb5c50SJohn Baldwin.Nm 6488eb5c50SJohn Baldwin.Cm delete 6588eb5c50SJohn Baldwin.Op Fl f 6688eb5c50SJohn Baldwin.Ar device 674fbf8e1cSKonstantin Belousov.Nm 68315674fbSLi-Wen Hsu.Cm freeze 69315674fbSLi-Wen Hsu.Nm 70315674fbSLi-Wen Hsu.Cm thaw 71315674fbSLi-Wen Hsu.Nm 724fbf8e1cSKonstantin Belousov.Cm reset 734fbf8e1cSKonstantin Belousov.Op Fl d 744fbf8e1cSKonstantin Belousov.Ar device 75f5366026SWarner Losh.Nm 76f5366026SWarner Losh.Cm getpath 77f5366026SWarner Losh.Ar locator 78f5366026SWarner Losh.Ar device 7964de8019SJohn Baldwin.Sh DESCRIPTION 8064de8019SJohn BaldwinThe 8164de8019SJohn Baldwin.Nm 8264de8019SJohn Baldwinutility adjusts the state of individual devices in the kernel's 8364de8019SJohn Baldwininternal device hierarchy. 8464de8019SJohn BaldwinEach invocation of 8564de8019SJohn Baldwin.Nm 8664de8019SJohn Baldwinconsists of a single command followed by command-specific arguments. 8764de8019SJohn BaldwinEach command operates on a single device specified via the 8864de8019SJohn Baldwin.Ar device 8964de8019SJohn Baldwinargument. 9064de8019SJohn BaldwinThe 9164de8019SJohn Baldwin.Ar device 9264de8019SJohn Baldwinmay be specified either as the name of an existing device or as a 9364de8019SJohn Baldwinbus-specific address. 9464de8019SJohn BaldwinMore details on supported address formats can be found in 9564de8019SJohn Baldwin.Xr devctl 3 . 9664de8019SJohn Baldwin.Pp 9764de8019SJohn BaldwinThe following commands are supported: 9864de8019SJohn Baldwin.Bl -tag -width indent 9964de8019SJohn Baldwin.It Cm attach Ar device 10064de8019SJohn BaldwinForce the kernel to re-probe the device. 10164de8019SJohn BaldwinIf a suitable driver is found, 10264de8019SJohn Baldwinit is attached to the device. 10364de8019SJohn Baldwin.It Xo Cm detach 10464de8019SJohn Baldwin.Op Fl f 10564de8019SJohn Baldwin.Ar device 10664de8019SJohn Baldwin.Xc 10764de8019SJohn BaldwinDetach the device from its current device driver. 10864de8019SJohn BaldwinIf the 10964de8019SJohn Baldwin.Fl f 11064de8019SJohn Baldwinflag is specified, 11164de8019SJohn Baldwinthe device driver will be detached even if the device is busy. 11264de8019SJohn Baldwin.It Xo Cm disable 11364de8019SJohn Baldwin.Op Fl f 11464de8019SJohn Baldwin.Ar device 11564de8019SJohn Baldwin.Xc 11664de8019SJohn BaldwinDisable a device. 11764de8019SJohn BaldwinIf the device is currently attached to a device driver, 11864de8019SJohn Baldwinthe device driver will be detached from the device, 11964de8019SJohn Baldwinbut the device will retain its current name. 12064de8019SJohn BaldwinIf the 12164de8019SJohn Baldwin.Fl f 12264de8019SJohn Baldwinflag is specified, 12364de8019SJohn Baldwinthe device driver will be detached even if the device is busy. 12464de8019SJohn Baldwin.It Cm enable Ar device 12564de8019SJohn BaldwinEnable a device. 12664de8019SJohn BaldwinThe device will probe and attach if a suitable device driver is found. 12764de8019SJohn BaldwinNote that this can re-enable a device disabled at boot time via a 12864de8019SJohn Baldwinloader tunable. 12964de8019SJohn Baldwin.It Cm suspend Ar device 13064de8019SJohn BaldwinSuspend a device. 13164de8019SJohn BaldwinThis may include placing the device in a reduced power state. 1328947c298SJustin Hibbits.It Cm resume Ar device 13364de8019SJohn BaldwinResume a suspended device to a fully working state. 13464de8019SJohn Baldwin.It Xo Cm set driver 13564de8019SJohn Baldwin.Op Fl f 13664de8019SJohn Baldwin.Ar device driver 13764de8019SJohn Baldwin.Xc 13864de8019SJohn BaldwinForce the device to use a device driver named 13964de8019SJohn Baldwin.Ar driver . 14064de8019SJohn BaldwinIf the device is already attached to a device driver and the 14164de8019SJohn Baldwin.Fl f 14264de8019SJohn Baldwinflag is specified, 14364de8019SJohn Baldwinthe device will be detached from its current device driver before it is 14464de8019SJohn Baldwinattached to the new device driver. 14564de8019SJohn BaldwinIf the device is already attached to a device driver and the 14664de8019SJohn Baldwin.Fl f 14764de8019SJohn Baldwinflag is not specified, 14864de8019SJohn Baldwinthe device will not be changed. 149e05ec081SJohn Baldwin.It Xo Cm clear driver 150e05ec081SJohn Baldwin.Op Fl f 151e05ec081SJohn Baldwin.Ar device 152e05ec081SJohn Baldwin.Xc 153e05ec081SJohn BaldwinClear a previously-forced driver name so that the device is able to use any 154e05ec081SJohn Baldwinvalid device driver. 155e05ec081SJohn BaldwinAfter the previous name has been cleared, 156e05ec081SJohn Baldwinthe device is reprobed so that other device drivers may attach to it. 157e05ec081SJohn BaldwinThis can be used to undo an earlier 158e05ec081SJohn Baldwin.Cm set driver 159e05ec081SJohn Baldwincommand. 160e05ec081SJohn BaldwinIf the device is currently attached to a device driver and the 161e05ec081SJohn Baldwin.Fl f 162e05ec081SJohn Baldwinflag is not specified, 163e05ec081SJohn Baldwinthe device will not be changed. 164a907c691SJohn Baldwin.It Cm rescan Ar device 165a907c691SJohn BaldwinRescan a bus device checking for devices that have been added or 166a907c691SJohn Baldwinremoved. 16788eb5c50SJohn Baldwin.It Xo Cm delete 1686dce7e99SMaxim Konovalov.Op Fl f 16988eb5c50SJohn Baldwin.Ar device 17088eb5c50SJohn Baldwin.Xc 17188eb5c50SJohn BaldwinDelete the device from the device tree. 17288eb5c50SJohn BaldwinIf the 17388eb5c50SJohn Baldwin.Fl f 17488eb5c50SJohn Baldwinflag is specified, 17588eb5c50SJohn Baldwinthe device will be deleted even if it is physically present. 17688eb5c50SJohn BaldwinThis command should be used with care as a device that is deleted but present 17788eb5c50SJohn Baldwincan no longer be used unless the parent bus device rediscovers the device via 17888eb5c50SJohn Baldwina rescan request. 179315674fbSLi-Wen Hsu.It Cm freeze 180315674fbSLi-Wen HsuFreeze probe and attach processing initiated in response to drivers being 181315674fbSLi-Wen Hsuloaded. 182315674fbSLi-Wen HsuDrivers are placed on a 183315674fbSLi-Wen Hsu.Do 184315674fbSLi-Wen Hsufrozen list 185315674fbSLi-Wen Hsu.Dc 186315674fbSLi-Wen Hsuand processed when a later 187315674fbSLi-Wen Hsu.Do 188315674fbSLi-Wen Hsuthaw 189315674fbSLi-Wen Hsu.Dc 190315674fbSLi-Wen Hsuoccurs. 191315674fbSLi-Wen Hsu.It Cm thaw 192315674fbSLi-Wen HsuResume (thaw the freeze) probe and attach initiated in response to drivers 193315674fbSLi-Wen Hsubeing loaded. 194315674fbSLi-Wen HsuIn addition to resuming, all pending actions that were frozen during the freeze 195315674fbSLi-Wen Hsuare performed. 1964fbf8e1cSKonstantin Belousov.It Xo Cm reset 1974fbf8e1cSKonstantin Belousov.Op Fl d 1984fbf8e1cSKonstantin Belousov.Ar device 1994fbf8e1cSKonstantin Belousov.Xc 2004fbf8e1cSKonstantin BelousovReset the device, using bus-specific reset method. 2014fbf8e1cSKonstantin BelousovDrivers for the devices being reset are suspended around the reset. 2024fbf8e1cSKonstantin BelousovIf the 2034fbf8e1cSKonstantin Belousov.Fl d 2044fbf8e1cSKonstantin Belousovoption is specified, drivers are detached instead. 2054fbf8e1cSKonstantin Belousov.Pp 2064fbf8e1cSKonstantin BelousovCurrently, resets are implemented for PCIe buses and PCI devices. 2074fbf8e1cSKonstantin BelousovFor PCIe bus, the link is disabled and then re-trained, causing all 2084fbf8e1cSKonstantin Belousovchildren of the bus to reset. 2094fbf8e1cSKonstantin BelousovUse 2104fbf8e1cSKonstantin Belousov.Fl p 2114fbf8e1cSKonstantin Belousovoption of 2124fbf8e1cSKonstantin Belousov.Xr devinfo 8 2134fbf8e1cSKonstantin Belousovtool to report parent bus for the device. 2144fbf8e1cSKonstantin BelousovFor PCI device, if Function-Level Reset is implemented by it, FLR is 2154fbf8e1cSKonstantin Belousovtried first; if failed or not implemented, power reset is tried. 2164fbf8e1cSKonstantin Belousov.Pp 2174fbf8e1cSKonstantin BelousovIf you have detached or suspended a child device explicitly and then 2184fbf8e1cSKonstantin Belousovdo a reset, the child device will end up attached. 219f5366026SWarner Losh.It Xo Cm getpath 220f5366026SWarner Losh.Ar locator 221f5366026SWarner Losh.Ar device 222f5366026SWarner Losh.Xc 223f5366026SWarner LoshPrints the full path to the 224f5366026SWarner Losh.Ar device 225f5366026SWarner Loshusing the 226f5366026SWarner Losh.Ar locator 227f5366026SWarner Loshmethod to get the path name. 228f5366026SWarner LoshCurrently, only the 229f5366026SWarner Losh.Dq UEFI 230f5366026SWarner Loshand 231f5366026SWarner Losh.Dq FreeBSD 232f5366026SWarner Loshlocators are implemented. 233f5366026SWarner LoshThe UEFI locator constructs a path to the device using the rules 234f5366026SWarner Loshoutlines for DEVICE_PATH in the UEFI standard. 235f5366026SWarner LoshThe FreeBSD locator constructs a path back to the root of the tree 236f5366026SWarner Loshwith the nodes separated by slashes. 23764de8019SJohn Baldwin.El 23864de8019SJohn Baldwin.Sh SEE ALSO 23964de8019SJohn Baldwin.Xr devctl 3 , 24064de8019SJohn Baldwin.Xr devinfo 8 24164de8019SJohn Baldwin.Sh HISTORY 24264de8019SJohn BaldwinThe 24364de8019SJohn Baldwin.Nm 24464de8019SJohn Baldwinutility first appeared in 2450fd00e0cSJohn Baldwin.Fx 10.3 . 246267d86e1SGordon Bergling.Sh BUGS 247267d86e1SGordon BerglingCurrently there is no administrative flag to prevent re-attach or resume 248267d86e1SGordon Berglingof the manually detached or suspended devices after reset. 249*81d1214eSChristian WeisgerberSimilarly, there is no flag to prevent un-suspending of the manually 250267d86e1SGordon Berglingsuspended devices after system resume. 251