From 924b1f5db0c8c6dfd9326a25e057ff6bee4c5e65 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 22 Jan 2014 07:48:39 +0000 Subject: [PATCH] Ensure that the DMA delay does not get rounded down to zero ticks when a timeout value of a single tick is given. With FreeBSD-10 and newer the current system time is used as a starting point, and the minimum callout time of a single tick will be guaranteed. This patch mostly affect the DMA delay timeouts, which are typically in the range from 0.125 to 2ms. MFC after: 1 week --- sys/dev/usb/usb_freebsd.h | 7 +++++++ sys/dev/usb/usb_freebsd_loader.h | 2 ++ sys/dev/usb/usb_transfer.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h index 0ae453381454..8c806e76f99a 100644 --- a/sys/dev/usb/usb_freebsd.h +++ b/sys/dev/usb/usb_freebsd.h @@ -50,6 +50,13 @@ #define USB_HAVE_FIXED_CONFIG 0 #define USB_HAVE_FIXED_PORT 0 +/* define zero ticks callout value */ +#if (__FreeBSD_version >= 1000029) +#define USB_CALLOUT_ZERO_TICKS 0 +#else +#define USB_CALLOUT_ZERO_TICKS 1 +#endif + #define USB_TD_GET_PROC(td) (td)->td_proc #define USB_PROC_GET_GID(td) (td)->p_pgid diff --git a/sys/dev/usb/usb_freebsd_loader.h b/sys/dev/usb/usb_freebsd_loader.h index 2a1e1044bcfb..68343d229517 100644 --- a/sys/dev/usb/usb_freebsd_loader.h +++ b/sys/dev/usb/usb_freebsd_loader.h @@ -50,6 +50,8 @@ #define USB_HAVE_FIXED_CONFIG 0 #define USB_HAVE_FIXED_PORT 0 +#define USB_CALLOUT_ZERO_TICKS 1 + #define USB_TD_GET_PROC(td) (td)->td_proc #define USB_PROC_GET_GID(td) (td)->p_pgid diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 0a3a78235ea5..dccac403eaba 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2723,7 +2723,7 @@ usbd_transfer_timeout_ms(struct usb_xfer *xfer, /* defer delay */ usb_callout_reset(&xfer->timeout_handle, - USB_MS_TO_TICKS(ms), cb, xfer); + USB_MS_TO_TICKS(ms) + USB_CALLOUT_ZERO_TICKS, cb, xfer); } /*------------------------------------------------------------------------*