aboutsummaryrefslogtreecommitdiff
path: root/lib/libdevctl
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-04-05 19:32:26 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-04-05 19:32:26 +0000
commit4fbf8e1c2efb16431c174d7a77c23e700af1160b (patch)
treeba86d2ae70d50d38cd895227ea65600ee173de6a /lib/libdevctl
parent1d1a5c2b02674c66cc305c465e3ae86dc1e526a1 (diff)
downloadsrc-4fbf8e1c2efb16431c174d7a77c23e700af1160b.tar.gz
src-4fbf8e1c2efb16431c174d7a77c23e700af1160b.zip
Notes
Diffstat (limited to 'lib/libdevctl')
-rw-r--r--lib/libdevctl/devctl.346
-rw-r--r--lib/libdevctl/devctl.c8
-rw-r--r--lib/libdevctl/devctl.h1
3 files changed, 54 insertions, 1 deletions
diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3
index 55fdd712ab99..34d1c03c2840 100644
--- a/lib/libdevctl/devctl.3
+++ b/lib/libdevctl/devctl.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 22, 2018
+.Dd April 4, 2019
.Dt DEVCTL 3
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Nm devctl_enable ,
.Nm devctl_freeze ,
.Nm devctl_rescan ,
+.Nm devctl_reset ,
.Nm devctl_resume ,
.Nm devctl_set_driver ,
.Nm devctl_suspend ,
@@ -63,6 +64,8 @@
.Ft int
.Fn devctl_rescan "const char *device"
.Ft int
+.Fn devctl_reset "const char *device" "bool detach"
+.Ft int
.Fn devctl_resume "const char *device"
.Ft int
.Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
@@ -204,6 +207,15 @@ The
.Fn devctl_thaw
function resumes (thaws the freeze) probe and attach processing
initiated in response to drivers being loaded.
+.Pp
+The
+.Fn devctl_reset
+function resets the specified device using bus-specific reset method.
+The
+.Fa detach
+argument, if true, specifies that the device driver is detached before
+the reset, and re-attached afterwards.
+If false, the device is suspended before the reset, and resumed after.
.Sh RETURN VALUES
.Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
@@ -377,6 +389,21 @@ is false.
.Fa dev
is the root device of the device tree.
.El
+.Pp
+The
+.Fn devctl_reset
+function may fail if:
+.Bl -tag -width Er
+.It Bq Er ENXIO
+The bus does not implement the reset method.
+.It Bq Er ETIMEDOUT
+The device failed to respond after the reset in the time limits
+specific to the bus.
+.El
+The
+.Fn devctl_reset
+function may also return errors caused by the attach, detach, suspend,
+and resume methods of the device driver.
.Sh SEE ALSO
.Xr devinfo 3 ,
.Xr devstat 3 ,
@@ -391,3 +418,20 @@ If a device is suspended individually via
.Fn devctl_suspend
and the entire machine is subsequently suspended,
the device will be resumed when the machine resumes.
+.Pp
+Similarly, if the device is suspended, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va false ,
+the device is resumed by the
+.Fn devctl_reset
+call.
+Or, if the driver for the device is detached manually, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va true ,
+device reset re-attaches the driver.
diff --git a/lib/libdevctl/devctl.c b/lib/libdevctl/devctl.c
index 34ced3c5da65..528e3a3c407a 100644
--- a/lib/libdevctl/devctl.c
+++ b/lib/libdevctl/devctl.c
@@ -158,3 +158,11 @@ devctl_thaw(void)
return (devctl_simple_request(DEV_THAW, "", 0));
}
+
+int
+devctl_reset(const char *device, bool detach)
+{
+
+ return (devctl_simple_request(DEV_RESET, device, detach ?
+ DEVF_RESET_DETACH : 0));
+}
diff --git a/lib/libdevctl/devctl.h b/lib/libdevctl/devctl.h
index e30576b14702..c6af8c480d47 100644
--- a/lib/libdevctl/devctl.h
+++ b/lib/libdevctl/devctl.h
@@ -43,6 +43,7 @@ int devctl_rescan(const char *device);
int devctl_delete(const char *device, bool force);
int devctl_freeze(void);
int devctl_thaw(void);
+int devctl_reset(const char *device, bool detach);
__END_DECLS
#endif /* !__DEVCTL_H__ */