svn commit: r361989 - stable/9/sys/dev/usb

2020-06-09 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Jun  9 22:15:45 2020
New Revision: 361989
URL: https://svnweb.freebsd.org/changeset/base/361989

Log:
  Adapt merge of r361581 to 9-stable to unbreak kernel compilation.
  
  This is a direct commit.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_transfer.c

Modified: stable/9/sys/dev/usb/usb_transfer.c
==
--- stable/9/sys/dev/usb/usb_transfer.c Tue Jun  9 21:59:13 2020
(r361988)
+++ stable/9/sys/dev/usb/usb_transfer.c Tue Jun  9 22:15:45 2020
(r361989)
@@ -354,8 +354,7 @@ usbd_get_max_frame_length(const struct usb_endpoint_de
if (ecomp != NULL) {
uint8_t mult;
 
-   mult = UE_GET_SS_ISO_MULT(
-   ecomp->bmAttributes) + 1;
+   mult = (ecomp->bmAttributes & 3) + 1;
if (mult > 3)
mult = 3;
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r361922 - in stable/9: lib/libusbhid sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:35:32 2020
New Revision: 361922
URL: https://svnweb.freebsd.org/changeset/base/361922

Log:
  MFC r361827:
  USB HID descriptors may push/pop the current state to allow
  description of items residing in a so-called union. FreeBSD currently
  only supports 4 such push levels.
  
  If the push level is not restored within the processing of the same
  HID item, an invalid memory location may be used for subsequent HID
  item processing.
  
  Verify that the push level is always valid when processing HID items.
  
  Reported by:  Andy Nguyen (Google)
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusbhid/parse.c
  stable/9/sys/dev/usb/usb_hid.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusbhid/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/lib/libusbhid/parse.c
==
--- stable/9/lib/libusbhid/parse.c  Mon Jun  8 09:34:16 2020
(r361921)
+++ stable/9/lib/libusbhid/parse.c  Mon Jun  8 09:35:32 2020
(r361922)
@@ -401,26 +401,28 @@ hid_get_item_raw(hid_data_t s, hid_item_t *h)
s->loc_count = dval & mask;
break;
case 10:/* Push */
+   /* stop parsing, if invalid push level */
+   if ((s->pushlevel + 1) >= MAXPUSH)
+   return (0);
s->pushlevel ++;
-   if (s->pushlevel < MAXPUSH) {
-   s->cur[s->pushlevel] = *c;
-   /* store size and count */
-   c->report_size = s->loc_size;
-   c->report_count = s->loc_count;
-   /* update current item pointer */
-   c = >cur[s->pushlevel];
-   }
+   s->cur[s->pushlevel] = *c;
+   /* store size and count */
+   c->report_size = s->loc_size;
+   c->report_count = s->loc_count;
+   /* update current item pointer */
+   c = >cur[s->pushlevel];
break;
case 11:/* Pop */
+   /* stop parsing, if invalid push level */
+   if (s->pushlevel == 0)
+   return (0);
s->pushlevel --;
-   if (s->pushlevel < MAXPUSH) {
-   c = >cur[s->pushlevel];
-   /* restore size and count */
-   s->loc_size = c->report_size;
-   s->loc_count = c->report_count;
-   c->report_size = 0;
-   c->report_count = 0;
-   }
+   c = >cur[s->pushlevel];
+   /* restore size and count */
+   s->loc_size = c->report_size;
+   s->loc_count = c->report_count;
+   c->report_size = 0;
+   c->report_count = 0;
break;
default:
break;

Modified: stable/9/sys/dev/usb/usb_hid.c
==
--- stable/9/sys/dev/usb/usb_hid.c  Mon Jun  8 09:34:16 2020
(r361921)
+++ stable/9/sys/dev/usb/usb_hid.c  Mon Jun  8 09:35:32 2020
(r361922)
@@ -433,36 +433,36 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
s->loc_count = dval & mask;
break;
case 10:/* Push */
-   s->pushlevel ++;
-   if (s->pushlevel < MAXPUSH) {
-   s->cur[s->pushlevel] = *c;
-   /* store size and count */
-   c->loc.size = s->loc_size;
-   c->loc.count = s->loc_count;
-   /* update current item pointer */
-   c = >cur[s->pushlevel];
-   } else {
-   DPRINTFN(0, "Cannot push "
-   "item @ %d\n", s->pushlevel);
+   /* stop parsing, if 

svn commit: r361917 - stable/9/sys/netgraph/bluetooth/drivers/ubt

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:31:52 2020
New Revision: 361917
URL: https://svnweb.freebsd.org/changeset/base/361917

Log:
  MFC r361582:
  Fix check for wMaxPacketSize in USB bluetooth driver,
  in case device is not FULL speed.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
==
--- stable/9/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cMon Jun  8 
09:31:14 2020(r361916)
+++ stable/9/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cMon Jun  8 
09:31:52 2020(r361917)
@@ -506,7 +506,7 @@ ubt_attach(device_t dev)
struct ubt_softc*sc = device_get_softc(dev);
struct usb_endpoint_descriptor  *ed;
struct usb_interface_descriptor *id;
-   uint16_twMaxPacketSize;
+   uint32_twMaxPacketSize;
uint8_t alt_index, i, j;
uint8_t iface_index[2] = { 0, 1 };
 
@@ -596,9 +596,10 @@ ubt_attach(device_t dev)
if ((ed->bDescriptorType == UDESC_ENDPOINT) &&
(ed->bLength >= sizeof(*ed)) &&
(i == 1)) {
-   uint16_t temp;
+   uint32_t temp;
 
-   temp = UGETW(ed->wMaxPacketSize);
+   temp = usbd_get_max_frame_length(
+   ed, NULL, usbd_get_speed(uaa->device));
if (temp > wMaxPacketSize) {
wMaxPacketSize = temp;
alt_index = j;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r361913 - stable/9/sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:29:08 2020
New Revision: 361913
URL: https://svnweb.freebsd.org/changeset/base/361913

Log:
  MFC r361581:
  Implement helper function, usbd_get_max_frame_length(), which allows kernel
  device drivers to correctly predict the default USB transfer frame length.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_transfer.c
  stable/9/sys/dev/usb/usbdi.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb_transfer.c
==
--- stable/9/sys/dev/usb/usb_transfer.c Mon Jun  8 09:28:26 2020
(r361912)
+++ stable/9/sys/dev/usb/usb_transfer.c Mon Jun  8 09:29:08 2020
(r361913)
@@ -299,6 +299,81 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params
 #endif
 
 /**
+ * usbd_get_max_frame_length
+ *
+ * This function returns the maximum single frame length as computed by
+ * usbd_transfer_setup(). It is useful when computing buffer sizes for
+ * devices having multiple alternate settings. The SuperSpeed endpoint
+ * companion pointer is allowed to be NULL.
+ **/
+uint32_t
+usbd_get_max_frame_length(const struct usb_endpoint_descriptor *edesc,
+const struct usb_endpoint_ss_comp_descriptor *ecomp,
+enum usb_dev_speed speed)
+{
+   uint32_t max_packet_size;
+   uint32_t max_packet_count;
+   uint8_t type;
+
+   max_packet_size = UGETW(edesc->wMaxPacketSize);
+   max_packet_count = 1;
+   type = (edesc->bmAttributes & UE_XFERTYPE);
+
+   switch (speed) {
+   case USB_SPEED_HIGH:
+   switch (type) {
+   case UE_ISOCHRONOUS:
+   case UE_INTERRUPT:
+   max_packet_count +=
+   (max_packet_size >> 11) & 3;
+
+   /* check for invalid max packet count */
+   if (max_packet_count > 3)
+   max_packet_count = 3;
+   break;
+   default:
+   break;
+   }
+   max_packet_size &= 0x7FF;
+   break;
+   case USB_SPEED_SUPER:
+   max_packet_count += (max_packet_size >> 11) & 3;
+
+   if (ecomp != NULL)
+   max_packet_count += ecomp->bMaxBurst;
+
+   if ((max_packet_count == 0) || 
+   (max_packet_count > 16))
+   max_packet_count = 16;
+
+   switch (type) {
+   case UE_CONTROL:
+   max_packet_count = 1;
+   break;
+   case UE_ISOCHRONOUS:
+   if (ecomp != NULL) {
+   uint8_t mult;
+
+   mult = UE_GET_SS_ISO_MULT(
+   ecomp->bmAttributes) + 1;
+   if (mult > 3)
+   mult = 3;
+
+   max_packet_count *= mult;
+   }
+   break;
+   default:
+   break;
+   }
+   max_packet_size &= 0x7FF;
+   break;
+   default:
+   break;
+   }
+   return (max_packet_size * max_packet_count);
+}
+
+/**
  * usbd_transfer_setup_sub - transfer setup subroutine
  *
  * This function must be called from the "xfer_setup" callback of the

Modified: stable/9/sys/dev/usb/usbdi.h
==
--- stable/9/sys/dev/usb/usbdi.hMon Jun  8 09:28:26 2020
(r361912)
+++ stable/9/sys/dev/usb/usbdi.hMon Jun  8 09:29:08 2020
(r361913)
@@ -496,6 +496,9 @@ uint8_t usbd_get_interface_altindex(struct usb_interfa
 usb_error_t usbd_set_alt_interface_index(struct usb_device *udev,
uint8_t iface_index, uint8_t alt_index);
 uint32_t usbd_get_isoc_fps(struct usb_device *udev);
+uint32_t usbd_get_max_frame_length(const struct usb_endpoint_descriptor *,
+const struct usb_endpoint_ss_comp_descriptor *,
+enum usb_dev_speed);
 usb_error_t usbd_transfer_setup(struct usb_device *udev,
const uint8_t *ifaces, struct usb_xfer **pxfer,
const struct usb_config *setup_start, uint16_t n_setup,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r361909 - stable/9/sys/dev/usb

2020-06-08 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun  8 09:25:40 2020
New Revision: 361909
URL: https://svnweb.freebsd.org/changeset/base/361909

Log:
  MFC r361577:
  Don't allow USB device drivers to parent own interface.
  It will prevent proper USB device detach.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_device.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb_device.c
==
--- stable/9/sys/dev/usb/usb_device.c   Mon Jun  8 09:25:01 2020
(r361908)
+++ stable/9/sys/dev/usb/usb_device.c   Mon Jun  8 09:25:40 2020
(r361909)
@@ -1241,7 +1241,7 @@ usbd_set_parent_iface(struct usb_device *udev, uint8_t
 {
struct usb_interface *iface;
 
-   if (udev == NULL) {
+   if (udev == NULL || iface_index == parent_index) {
/* nothing to do */
return;
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r361359 - stable/9/sys/kern

2020-05-22 Thread Hans Petter Selasky
Author: hselasky
Date: Fri May 22 09:02:40 2020
New Revision: 361359
URL: https://svnweb.freebsd.org/changeset/base/361359

Log:
  MFC r361075:
  Assign process group of the TTY under the "proctree_lock".
  
  This fixes a race where concurrent calls to doenterpgrp() and
  leavepgrp() while TIOCSCTTY is executing may result in tp->t_pgrp
  changing value so that tty_rel_pgrp() misses clearing it to NULL. For
  more details refer to the use of pgdelete() in the kernel.
  
  No functional change intended.
  
  Panic backtrace:
  __mtx_lock_sleep() # page fault due to using destroyed mutex
  tty_signal_pgrp()
  tty_ioctl()
  ptsdev_ioctl()
  kern_ioctl()
  sys_ioctl()
  amd64_syscall()
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/kern/tty.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/tty.c
==
--- stable/9/sys/kern/tty.c Fri May 22 09:01:26 2020(r361358)
+++ stable/9/sys/kern/tty.c Fri May 22 09:02:40 2020(r361359)
@@ -1611,7 +1611,6 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *da
tp->t_session = p->p_session;
tp->t_session->s_ttyp = tp;
tp->t_sessioncnt++;
-   sx_xunlock(_lock);
 
/* Assign foreground process group. */
tp->t_pgrp = p->p_pgrp;
@@ -1619,6 +1618,7 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *da
p->p_flag |= P_CONTROLT;
PROC_UNLOCK(p);
 
+   sx_xunlock(_lock);
return (0);
}
case TIOCSPGRP: {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r360336 - stable/9/sys/dev/usb/controller

2020-04-26 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Apr 26 08:38:53 2020
New Revision: 360336
URL: https://svnweb.freebsd.org/changeset/base/360336

Log:
  MFC r360075:
  Set the maximum exit latency to 0 for XHCI USB 3.0 devices, because we
  don't implement link power management, LPM.
  
  This fixes error code XHCI_TRB_ERROR_BANDWIDTH for isochronous USB 3.0
  transactions.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Sun Apr 26 08:38:10 2020
(r360335)
+++ stable/9/sys/dev/usb/controller/xhci.c  Sun Apr 26 08:38:53 2020
(r360336)
@@ -2599,23 +2599,6 @@ xhci_configure_device(struct usb_device *udev)
sc->sc_hw.devs[index].nports);
}
 
-   switch (udev->speed) {
-   case USB_SPEED_SUPER:
-   switch (sc->sc_hw.devs[index].state) {
-   case XHCI_ST_ADDRESSED:
-   case XHCI_ST_CONFIGURED:
-   /* enable power save */
-   temp |= XHCI_SCTX_1_MAX_EL_SET(sc->sc_exit_lat_max);
-   break;
-   default:
-   /* disable power save */
-   break;
-   }
-   break;
-   default:
-   break;
-   }
-
xhci_ctx_set_le32(sc, >ctx_slot.dwSctx1, temp);
 
temp = XHCI_SCTX_2_IRQ_TARGET_SET(0);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r359319 - stable/9/sys/dev/usb

2020-03-25 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 26 05:39:20 2020
New Revision: 359319
URL: https://svnweb.freebsd.org/changeset/base/359319

Log:
  MFC r359120:
  Correctly implement support for remote wakeup for USB 3.0 device.
  
  Submitted by: Horse Ma 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb.h
  stable/9/sys/dev/usb/usb_hub.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb.h
==
--- stable/9/sys/dev/usb/usb.h  Thu Mar 26 05:38:33 2020(r359318)
+++ stable/9/sys/dev/usb/usb.h  Thu Mar 26 05:39:20 2020(r359319)
@@ -267,6 +267,11 @@ typedef struct usb_device_request usb_device_request_t
 #defineUHF_C_BH_PORT_RESET 29
 #defineUHF_FORCE_LINKPM_ACCEPT 30
 
+/* SuperSpeed suspend support */
+#defineUSB_INTERFACE_FUNC_SUSPEND 0
+#defineUSB_INTERFACE_FUNC_SUSPEND_LP   (1 << 8)
+#defineUSB_INTERFACE_FUNC_SUSPEND_RW   (1 << 9)
+
 struct usb_descriptor {
uByte   bLength;
uByte   bDescriptorType;

Modified: stable/9/sys/dev/usb/usb_hub.c
==
--- stable/9/sys/dev/usb/usb_hub.c  Thu Mar 26 05:38:33 2020
(r359318)
+++ stable/9/sys/dev/usb/usb_hub.c  Thu Mar 26 05:39:20 2020
(r359319)
@@ -2483,6 +2483,50 @@ usb_bus_powerd(struct usb_bus *bus)
 }
 #endif
 
+static usb_error_t
+usbd_device_30_remote_wakeup(struct usb_device *udev, uint8_t bRequest)
+{
+   struct usb_device_request req = {};
+
+   req.bmRequestType = UT_WRITE_INTERFACE;
+   req.bRequest = bRequest;
+   USETW(req.wValue, USB_INTERFACE_FUNC_SUSPEND);
+   USETW(req.wIndex, USB_INTERFACE_FUNC_SUSPEND_LP |
+   USB_INTERFACE_FUNC_SUSPEND_RW);
+
+   return (usbd_do_request(udev, NULL, , 0));
+}
+
+static usb_error_t
+usbd_clear_dev_wakeup(struct usb_device *udev)
+{
+   usb_error_t err;
+
+   if (usb_device_20_compatible(udev)) {
+   err = usbd_req_clear_device_feature(udev,
+   NULL, UF_DEVICE_REMOTE_WAKEUP);
+   } else {
+   err = usbd_device_30_remote_wakeup(udev,
+   UR_CLEAR_FEATURE);
+   }
+   return (err);
+}
+
+static usb_error_t
+usbd_set_dev_wakeup(struct usb_device *udev)
+{
+   usb_error_t err;
+
+   if (usb_device_20_compatible(udev)) {
+   err = usbd_req_set_device_feature(udev,
+   NULL, UF_DEVICE_REMOTE_WAKEUP);
+   } else {
+   err = usbd_device_30_remote_wakeup(udev,
+   UR_SET_FEATURE);
+   }
+   return (err);
+}
+
 /**
  * usb_dev_resume_peer
  *
@@ -2586,8 +2630,7 @@ usb_dev_resume_peer(struct usb_device *udev)
/* check if peer has wakeup capability */
if (usb_peer_can_wakeup(udev)) {
/* clear remote wakeup */
-   err = usbd_req_clear_device_feature(udev,
-   NULL, UF_DEVICE_REMOTE_WAKEUP);
+   err = usbd_clear_dev_wakeup(udev);
if (err) {
DPRINTFN(0, "Clearing device "
"remote wakeup failed: %s\n",
@@ -2652,8 +2695,7 @@ repeat:
 */
 
/* allow device to do remote wakeup */
-   err = usbd_req_set_device_feature(udev,
-   NULL, UF_DEVICE_REMOTE_WAKEUP);
+   err = usbd_set_dev_wakeup(udev);
if (err) {
DPRINTFN(0, "Setting device "
"remote wakeup failed\n");
@@ -2679,8 +2721,7 @@ repeat:
if (err != 0) {
if (usb_peer_can_wakeup(udev)) {
/* allow device to do remote wakeup */
-   err = usbd_req_clear_device_feature(udev,
-   NULL, UF_DEVICE_REMOTE_WAKEUP);
+   err = usbd_clear_dev_wakeup(udev);
if (err) {
DPRINTFN(0, "Setting device "
"remote wakeup failed\n");
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r359124 - stable/9/sys/ofed/drivers/infiniband/ulp/ipoib

2020-03-19 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 19 09:21:27 2020
New Revision: 359124
URL: https://svnweb.freebsd.org/changeset/base/359124

Log:
  MFC r359014:
  Fix for double unlock in ipoib.
  
  The ipoib_unicast_send() function is not supposed to unlock the priv lock.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
==
--- stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Thu Mar 19 
09:20:41 2020(r359123)
+++ stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Thu Mar 19 
09:21:27 2020(r359124)
@@ -662,7 +662,6 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_p
if (path) {
_IF_ENQUEUE(>queue, mb);
if (!path->query && path_rec_start(priv, path)) {
-   spin_unlock_irqrestore(>lock, flags);
if (new_path)
ipoib_path_free(priv, path);
return;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r358946 - stable/9/sys/compat/linux

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 09:15:13 2020
New Revision: 358946
URL: https://svnweb.freebsd.org/changeset/base/358946

Log:
  MFC r358838:
  Add support for the device statistics IOCTL, needed by the coming
  linux_libusb upgrade.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/compat/linux/linux_ioctl.c
  stable/9/sys/compat/linux/linux_ioctl.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/compat/linux/linux_ioctl.c
==
--- stable/9/sys/compat/linux/linux_ioctl.c Fri Mar 13 09:14:05 2020
(r358945)
+++ stable/9/sys/compat/linux/linux_ioctl.c Fri Mar 13 09:15:13 2020
(r358946)
@@ -3408,6 +3408,9 @@ linux_ioctl_fbsd_usb(struct thread *td, struct linux_i
case FBSD_LUSB_GET_POWER_USAGE:
args->cmd = USB_GET_POWER_USAGE;
break;
+   case FBSD_LUSB_DEVICESTATS:
+   args->cmd = USB_DEVICESTATS;
+   break;
default:
error = ENOIOCTL;
}

Modified: stable/9/sys/compat/linux/linux_ioctl.h
==
--- stable/9/sys/compat/linux/linux_ioctl.h Fri Mar 13 09:14:05 2020
(r358945)
+++ stable/9/sys/compat/linux/linux_ioctl.h Fri Mar 13 09:15:13 2020
(r358946)
@@ -747,8 +747,9 @@ int  linux_ifname(struct ifnet *, char *, size_t);
 #defineFBSD_LUSB_FS_OPEN_STREAM0xffdf
 #defineFBSD_LUSB_GET_DEV_PORT_PATH 0xffde
 #defineFBSD_LUSB_GET_POWER_USAGE   0xffdd
+#defineFBSD_LUSB_DEVICESTATS   0xffdc
 
 #defineFBSD_LUSB_MAX   0x
-#defineFBSD_LUSB_MIN   0xffdd
+#defineFBSD_LUSB_MIN   0xffdc
 
 #endif /* !_LINUX_IOCTL_H_ */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r358945 - stable/9/sys/compat/linux

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 09:14:05 2020
New Revision: 358945
URL: https://svnweb.freebsd.org/changeset/base/358945

Log:
  MFC r253338:
  Add some missing LIBUSB IOCTL conversion codes.

Modified:
  stable/9/sys/compat/linux/linux_ioctl.c
  stable/9/sys/compat/linux/linux_ioctl.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/compat/linux/linux_ioctl.c
==
--- stable/9/sys/compat/linux/linux_ioctl.c Fri Mar 13 09:10:44 2020
(r358944)
+++ stable/9/sys/compat/linux/linux_ioctl.c Fri Mar 13 09:14:05 2020
(r358945)
@@ -3399,6 +3399,15 @@ linux_ioctl_fbsd_usb(struct thread *td, struct linux_i
case FBSD_LUSB_SET_TEMPLATE:
args->cmd = USB_SET_TEMPLATE;
break;
+   case FBSD_LUSB_FS_OPEN_STREAM:
+   args->cmd = USB_FS_OPEN_STREAM;
+   break;
+   case FBSD_LUSB_GET_DEV_PORT_PATH:
+   args->cmd = USB_GET_DEV_PORT_PATH;
+   break;
+   case FBSD_LUSB_GET_POWER_USAGE:
+   args->cmd = USB_GET_POWER_USAGE;
+   break;
default:
error = ENOIOCTL;
}

Modified: stable/9/sys/compat/linux/linux_ioctl.h
==
--- stable/9/sys/compat/linux/linux_ioctl.h Fri Mar 13 09:10:44 2020
(r358944)
+++ stable/9/sys/compat/linux/linux_ioctl.h Fri Mar 13 09:14:05 2020
(r358945)
@@ -744,8 +744,11 @@ int linux_ifname(struct ifnet *, char *, 
size_t);
 #defineFBSD_LUSB_SET_IMMED 0xffe2
 #defineFBSD_LUSB_SET_POWER_MODE0xffe1
 #defineFBSD_LUSB_SET_TEMPLATE  0xffe0
+#defineFBSD_LUSB_FS_OPEN_STREAM0xffdf
+#defineFBSD_LUSB_GET_DEV_PORT_PATH 0xffde
+#defineFBSD_LUSB_GET_POWER_USAGE   0xffdd
 
 #defineFBSD_LUSB_MAX   0x
-#defineFBSD_LUSB_MIN   0xffe0
+#defineFBSD_LUSB_MIN   0xffdd
 
 #endif /* !_LINUX_IOCTL_H_ */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r358944 - stable/9/sys/dev/usb

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 09:10:44 2020
New Revision: 358944
URL: https://svnweb.freebsd.org/changeset/base/358944

Log:
  Define USB_FS_OPEN_STREAM, even if not supported.
  This is a direct commit.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_ioctl.h

Modified: stable/9/sys/dev/usb/usb_ioctl.h
==
--- stable/9/sys/dev/usb/usb_ioctl.hFri Mar 13 09:07:02 2020
(r358943)
+++ stable/9/sys/dev/usb/usb_ioctl.hFri Mar 13 09:10:44 2020
(r358944)
@@ -329,6 +329,7 @@ struct usb_gen_quirk {
 #defineUSB_FS_OPEN _IOWR('U', 197, struct usb_fs_open)
 #defineUSB_FS_CLOSE_IOW ('U', 198, struct usb_fs_close)
 #defineUSB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct 
usb_fs_clear_stall_sync)
+#defineUSB_FS_OPEN_STREAM  _IOWR('U', 200, struct 
usb_fs_open_stream)
 
 /* USB quirk system interface */
 #defineUSB_DEV_QUIRK_GET   _IOWR('Q', 0, struct usb_gen_quirk)
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r358938 - stable/9/sys/sys

2020-03-13 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Mar 13 08:54:57 2020
New Revision: 358938
URL: https://svnweb.freebsd.org/changeset/base/358938

Log:
  MFC r358695:
  Define more subsystem orders.
  Intended for use with module_init_order() in the LinuxKPI.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/sys/kernel.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/sys/kernel.h
==
--- stable/9/sys/sys/kernel.h   Fri Mar 13 08:53:59 2020(r358937)
+++ stable/9/sys/sys/kernel.h   Fri Mar 13 08:54:57 2020(r358938)
@@ -177,6 +177,10 @@ enum sysinit_elem_order {
SI_ORDER_SECOND = 0x001,/* second*/
SI_ORDER_THIRD  = 0x002,/* third*/
SI_ORDER_FOURTH = 0x003,/* fourth*/
+   SI_ORDER_FIFTH  = 0x004,/* fifth*/
+   SI_ORDER_SIXTH  = 0x005,/* sixth*/
+   SI_ORDER_SEVENTH= 0x006,/* seventh*/
+   SI_ORDER_EIGHTH = 0x007,/* eighth*/
SI_ORDER_MIDDLE = 0x100,/* somewhere in the middle */
SI_ORDER_ANY= 0xfff /* last*/
 };
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r358880 - stable/9/sys/dev/sound/pcm

2020-03-11 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Mar 11 08:26:52 2020
New Revision: 358880
URL: https://svnweb.freebsd.org/changeset/base/358880

Log:
  MFC r358629:
  Implement a detaching flag for the sound(4) subsystem to take
  appropriate actions when we are trying to detach an audio device,
  but cannot because someone is using it.
  
  This avoids applications having to wait for the DSP read data
  timeout before they receive any error indication.
  Tested with virtual_oss(8).
  
  Remove some unused definitions while at it.
  
  PR:   194727
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/sound/pcm/dsp.c
  stable/9/sys/dev/sound/pcm/mixer.c
  stable/9/sys/dev/sound/pcm/sound.c
  stable/9/sys/dev/sound/pcm/sound.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/pcm/dsp.c
==
--- stable/9/sys/dev/sound/pcm/dsp.cWed Mar 11 08:26:11 2020
(r358879)
+++ stable/9/sys/dev/sound/pcm/dsp.cWed Mar 11 08:26:52 2020
(r358880)
@@ -457,7 +457,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, stru
return (ENODEV);
 
d = dsp_get_info(i_dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -827,7 +827,7 @@ dsp_io_ops(struct cdev *i_dev, struct uio *buf)
("%s(): io train wreck!", __func__));
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -1072,7 +1072,7 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg,
int *arg_i, ret, tmp;
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -2167,9 +2167,11 @@ dsp_poll(struct cdev *i_dev, int events, struct thread
int ret, e;
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
-   return (EBADF);
-
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev)) {
+   /* XXX many clients don't understand POLLNVAL */
+   return (events & (POLLHUP | POLLPRI | POLLIN |
+   POLLRDNORM | POLLOUT | POLLWRNORM));
+   }
PCM_GIANT_ENTER(d);
 
wrch = NULL;
@@ -2240,7 +2242,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offs
return (EINVAL);
 
d = dsp_get_info(i_dev);
-   if (!DSP_REGISTERED(d, i_dev))
+   if (PCM_DETACHING(d) || !DSP_REGISTERED(d, i_dev))
return (EINVAL);
 
PCM_GIANT_ENTER(d);

Modified: stable/9/sys/dev/sound/pcm/mixer.c
==
--- stable/9/sys/dev/sound/pcm/mixer.c  Wed Mar 11 08:26:11 2020
(r358879)
+++ stable/9/sys/dev/sound/pcm/mixer.c  Wed Mar 11 08:26:52 2020
(r358880)
@@ -152,7 +152,7 @@ mixer_set_softpcmvol(struct snd_mixer *m, struct sndde
struct pcm_channel *c;
int dropmtx, acquiremtx;
 
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EINVAL);
 
if (mtx_owned(m->lock))
@@ -205,7 +205,7 @@ mixer_set_eq(struct snd_mixer *m, struct snddev_info *
else
return (EINVAL);
 
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EINVAL);
 
if (mtx_owned(m->lock))
@@ -1045,7 +1045,7 @@ mixer_open(struct cdev *i_dev, int flags, int mode, st
 
m = i_dev->si_drv1;
d = device_get_softc(m->dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
/* XXX Need Giant magic entry ??? */
@@ -1201,7 +1201,7 @@ mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t ar
return (EBADF);
 
d = device_get_softc(((struct snd_mixer *)i_dev->si_drv1)->dev);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
return (EBADF);
 
PCM_GIANT_ENTER(d);
@@ -1412,7 +1412,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo 
for (i = 0; pcm_devclass != NULL &&
i < devclass_get_maxunit(pcm_devclass); i++) {
d = devclass_get_softc(pcm_devclass, i);
-   if (!PCM_REGISTERED(d))
+   if (PCM_DETACHING(d) || !PCM_REGISTERED(d))
continue;
 
/* XXX Need Giant magic entry */

Modified: stable/9/sys/dev/sound/pcm/sound.c
==
--- stable/9/sys/dev/sound/pcm/sound.c  Wed Mar 11 08:26:11 2020
(r358879)
+++ stable/9/sys/dev/sound/pcm/sound.c  Wed Mar 11 08:26:52 2020 

svn commit: r358876 - in stable/9/sys/dev/usb: . controller

2020-03-11 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Mar 11 08:23:14 2020
New Revision: 358876
URL: https://svnweb.freebsd.org/changeset/base/358876

Log:
  MFC r358738:
  Remove the power bit from the super speed root hub port status register
  because it clobbers the super speed link status when a device is in super
  speed mode. Currently the power bit is not needed for anything in the USB
  hub driver.
  
  This fixes USB warm reset for super speed devices.
  
  Tested by:shichun...@dell.com
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
  stable/9/sys/dev/usb/usb_hub.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Wed Mar 11 08:21:48 2020
(r358875)
+++ stable/9/sys/dev/usb/controller/xhci.c  Wed Mar 11 08:23:14 2020
(r358876)
@@ -3514,13 +3514,10 @@ xhci_roothub_exec(struct usb_device *udev,
i |= UPS_OVERCURRENT_INDICATOR;
if (v & XHCI_PS_PR)
i |= UPS_RESET;
-   if (v & XHCI_PS_PP) {
-   /*
-* The USB 3.0 RH is using the
-* USB 2.0's power bit
-*/
-   i |= UPS_PORT_POWER;
-   }
+#if 0
+   if (v & XHCI_PS_PP)
+   /* XXX undefined */
+#endif
USETW(sc->sc_hub_desc.ps.wPortStatus, i);
 
i = 0;

Modified: stable/9/sys/dev/usb/usb_hub.c
==
--- stable/9/sys/dev/usb/usb_hub.c  Wed Mar 11 08:21:48 2020
(r358875)
+++ stable/9/sys/dev/usb/usb_hub.c  Wed Mar 11 08:23:14 2020
(r358876)
@@ -646,7 +646,7 @@ repeat:
break;
case USB_SPEED_SUPER:
if (udev->parent_hub == NULL)
-   power_mask = UPS_PORT_POWER;
+   power_mask = 0; /* XXX undefined */
else
power_mask = UPS_PORT_POWER_SS;
break;
@@ -654,7 +654,7 @@ repeat:
power_mask = 0;
break;
}
-   if (!(sc->sc_st.port_status & power_mask)) {
+   if ((sc->sc_st.port_status & power_mask) != power_mask) {
DPRINTF("WARNING: strange, connected port %d "
"has no power\n", portno);
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r357440 - stable/9/lib/libusb

2020-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb  3 11:17:34 2020
New Revision: 357440
URL: https://svnweb.freebsd.org/changeset/base/357440

Log:
  MFC r349409 and r349410:
  Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
  devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
  flag. Make sure when the flag is not specified no arrival events are
  generated for currently enumerated devices.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusb/libusb10.h
  stable/9/lib/libusb/libusb10_hotplug.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10.h
==
--- stable/9/lib/libusb/libusb10.h  Mon Feb  3 11:05:59 2020
(r357439)
+++ stable/9/lib/libusb/libusb10.h  Mon Feb  3 11:17:34 2020
(r357440)
@@ -85,6 +85,8 @@ struct libusb_hotplug_callback_handle_struct {
void *user_data;
 };
 
+TAILQ_HEAD(libusb_device_head, libusb_device);
+
 struct libusb_context {
int debug;
int debug_fixed;
@@ -102,7 +104,7 @@ struct libusb_context {
TAILQ_HEAD(, libusb_super_pollfd) pollfds;
TAILQ_HEAD(, libusb_super_transfer) tr_done;
TAILQ_HEAD(, libusb_hotplug_callback_handle_struct) hotplug_cbh;
-   TAILQ_HEAD(, libusb_device) hotplug_devs;
+   struct libusb_device_head hotplug_devs;
 
struct libusb_super_pollfd ctx_poll;
 

Modified: stable/9/lib/libusb/libusb10_hotplug.c
==
--- stable/9/lib/libusb/libusb10_hotplug.c  Mon Feb  3 11:05:59 2020
(r357439)
+++ stable/9/lib/libusb/libusb10_hotplug.c  Mon Feb  3 11:17:34 2020
(r357440)
@@ -1,6 +1,6 @@
 /* $FreeBSD$ */
 /*-
- * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2016-2019 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -85,20 +85,35 @@ libusb_hotplug_filter(libusb_context *ctx, libusb_hotp
return (pcbh->fn(ctx, dev, event, pcbh->user_data));
 }
 
+static int
+libusb_hotplug_enumerate(libusb_context *ctx, struct libusb_device_head *phead)
+{
+   libusb_device **ppdev;
+   ssize_t count;
+   ssize_t x;
+
+   count = libusb_get_device_list(ctx, );
+   if (count < 0)
+   return (-1);
+
+   for (x = 0; x != count; x++)
+   TAILQ_INSERT_TAIL(phead, ppdev[x], hotplug_entry);
+
+   libusb_free_device_list(ppdev, 0);
+   return (0);
+}
+
 static void *
 libusb_hotplug_scan(void *arg)
 {
-   TAILQ_HEAD(, libusb_device) hotplug_devs;
+   struct libusb_device_head hotplug_devs;
libusb_hotplug_callback_handle acbh;
libusb_hotplug_callback_handle bcbh;
libusb_context *ctx = arg;
-   libusb_device **ppdev;
libusb_device *temp;
libusb_device *adev;
libusb_device *bdev;
unsigned do_loop = 1;
-   ssize_t count;
-   ssize_t x;
 
while (do_loop) {
usleep(400);
@@ -108,14 +123,8 @@ libusb_hotplug_scan(void *arg)
TAILQ_INIT(_devs);
 
if (ctx->hotplug_handler != NO_THREAD) {
-   count = libusb_get_device_list(ctx, );
-   if (count < 0)
+   if (libusb_hotplug_enumerate(ctx, _devs) < 0)
continue;
-   for (x = 0; x != count; x++) {
-   TAILQ_INSERT_TAIL(_devs, ppdev[x],
-   hotplug_entry);
-   }
-   libusb_free_device_list(ppdev, 0);
} else {
do_loop = 0;
}
@@ -191,6 +200,8 @@ int libusb_hotplug_register_callback(libusb_context *c
 
HOTPLUG_LOCK(ctx);
if (ctx->hotplug_handler == NO_THREAD) {
+   libusb_hotplug_enumerate(ctx, >hotplug_devs);
+
if (pthread_create(>hotplug_handler, NULL,
_hotplug_scan, ctx) != 0)
ctx->hotplug_handler = NO_THREAD;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r357441 - stable/9/lib/libusb

2020-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Feb  3 11:18:07 2020
New Revision: 357441
URL: https://svnweb.freebsd.org/changeset/base/357441

Log:
  MFC r357298:
  Add missing mutex unlock in failure case.
  
  Differential Revision:https://reviews.freebsd.org/D23430
  Submitted by: cem
  Reported by:  Coverity
  Coverity CID: 1368773
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusb/libusb10_hotplug.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10_hotplug.c
==
--- stable/9/lib/libusb/libusb10_hotplug.c  Mon Feb  3 11:17:34 2020
(r357440)
+++ stable/9/lib/libusb/libusb10_hotplug.c  Mon Feb  3 11:18:07 2020
(r357441)
@@ -123,8 +123,10 @@ libusb_hotplug_scan(void *arg)
TAILQ_INIT(_devs);
 
if (ctx->hotplug_handler != NO_THREAD) {
-   if (libusb_hotplug_enumerate(ctx, _devs) < 0)
+   if (libusb_hotplug_enumerate(ctx, _devs) < 0) {
+   HOTPLUG_UNLOCK(ctx);
continue;
+   }
} else {
do_loop = 0;
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r348896 - stable/9/lib/libusb

2019-06-11 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Jun 11 08:54:21 2019
New Revision: 348896
URL: https://svnweb.freebsd.org/changeset/base/348896

Log:
  MFC r348797:
  Fix for reading the configuration descriptor in libusb. Catch invalid
  configuration descriptor reads early on to avoid issues with devices
  that don't check for a valid USB configuration read request.
  
  Submitted by: takahiro.kuros...@gmail.com
  PR:   238412

Modified:
  stable/9/lib/libusb/libusb20.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb20.c
==
--- stable/9/lib/libusb/libusb20.c  Tue Jun 11 08:53:26 2019
(r348895)
+++ stable/9/lib/libusb/libusb20.c  Tue Jun 11 08:54:21 2019
(r348896)
@@ -924,6 +924,14 @@ libusb20_dev_alloc_config(struct libusb20_device *pdev
uint8_t do_close;
int error;
 
+   /*
+* Catch invalid configuration descriptor reads early on to
+* avoid issues with devices that don't check for a valid USB
+* configuration read request.
+*/
+   if (configIndex >= pdev->ddesc.bNumConfigurations)
+   return (NULL);
+
if (!pdev->is_opened) {
error = libusb20_dev_open(pdev, 0);
if (error) {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r348858 - stable/9/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:38:57 2019
New Revision: 348858
URL: https://svnweb.freebsd.org/changeset/base/348858

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb_generic.c
==
--- stable/9/sys/dev/usb/usb_generic.c  Mon Jun 10 13:37:38 2019
(r348857)
+++ stable/9/sys/dev/usb/usb_generic.c  Mon Jun 10 13:38:57 2019
(r348858)
@@ -1206,6 +1206,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1230,8 +1264,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1351,6 +1390,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1438,12 +1478,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r345944 - stable/9/sys/sys

2019-04-05 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr  5 11:37:17 2019
New Revision: 345944
URL: https://svnweb.freebsd.org/changeset/base/345944

Log:
  MFC r345499:
  Change all kernel C-type macros into static inline functions.
  
  The current kernel C-type macros might obscurely hide the fact that
  the input argument might be used multiple times.
  
  This breaks code like:
  isalpha(*ptr++)
  
  Use static inline functions instead of macros to fix this.
  
  Reviewed by:  kib @
  Differential Revision:https://reviews.freebsd.org/D19694
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/sys/ctype.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/sys/ctype.h
==
--- stable/9/sys/sys/ctype.hFri Apr  5 11:35:58 2019(r345943)
+++ stable/9/sys/sys/ctype.hFri Apr  5 11:37:17 2019(r345944)
@@ -39,19 +39,65 @@
 
 #ifdef _KERNEL
 
-#define isspace(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
-#define isascii(c) (((c) & ~0x7f) == 0)
-#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
-#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#define isalpha(c) (isupper(c) || islower(c))
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
-#define isxdigit(c)(isdigit(c) \
- || ((c) >= 'A' && (c) <= 'F') \
- || ((c) >= 'a' && (c) <= 'f'))
-#define isprint(c) ((c) >= ' ' && (c) <= '~')
+static __inline int
+isspace(int c)
+{
+   return (c == ' ' || (c >= '\t' && c <= '\r'));
+}
 
-#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
-#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
+static __inline int
+isascii(int c)
+{
+   return ((c & ~0x7f) == 0);
+}
+
+static __inline int
+isupper(int c)
+{
+   return (c >= 'A' && c <= 'Z');
+}
+
+static __inline int
+islower(int c)
+{
+   return (c >= 'a' && c <= 'z');
+}
+
+static __inline int
+isalpha(int c)
+{
+   return (isupper(c) || islower(c));
+}
+
+static __inline int
+isdigit(int c)
+{
+   return (c >= '0' && c <= '9');
+}
+
+static __inline int
+isxdigit(int c)
+{
+   return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
+}
+
+static __inline int
+isprint(int c)
+{
+   return (c >= ' ' && c <= '~');
+}
+
+static __inline int
+toupper(int c)
+{
+   return (c - 0x20 * ((c >= 'a') && (c <= 'z')));
+}
+
+static __inline int
+tolower(int c)
+{
+   return (c + 0x20 * ((c >= 'A') && (c <= 'Z')));
+}
 
 #endif
 #endif /* !_SYS_CTYPE_H_ */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r344147 - stable/9/usr.sbin/bluetooth/sdpd

2019-02-15 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 15 09:25:52 2019
New Revision: 344147
URL: https://svnweb.freebsd.org/changeset/base/344147

Log:
  MFC r343905:
  Improve Bluetooth device discovery support for Android and Microsoft devices.
  
  Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
  project at github.com.
  
  PR:   210089
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/usr.sbin/bluetooth/sdpd/ssar.c
Directory Properties:
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/bluetooth/sdpd/   (props changed)

Modified: stable/9/usr.sbin/bluetooth/sdpd/ssar.c
==
--- stable/9/usr.sbin/bluetooth/sdpd/ssar.c Fri Feb 15 09:22:23 2019
(r344146)
+++ stable/9/usr.sbin/bluetooth/sdpd/ssar.c Fri Feb 15 09:25:52 2019
(r344147)
@@ -44,6 +44,131 @@ int32_t server_prepare_attr_list(provider_p const prov
uint8_t *rsp, uint8_t const * const rsp_end);
 
 /*
+ * Scan an attribute for matching UUID.
+ */
+static int
+server_search_uuid_sub(uint8_t *buf, uint8_t const * const eob, const 
uint128_t *uuid)
+{
+int128_t duuid;
+uint32_t value;
+uint8_t type;
+
+while (buf < eob) {
+
+SDP_GET8(type, buf);
+
+switch (type) {
+case SDP_DATA_UUID16:
+if (buf + 2 > eob)
+continue;
+SDP_GET16(value, buf);
+
+memcpy(, _base, sizeof(duuid));
+duuid.b[2] = value >> 8 & 0xff;
+duuid.b[3] = value & 0xff;
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UUID32:
+if (buf + 4 > eob)
+continue;
+SDP_GET32(value, buf);
+memcpy(, _base, sizeof(duuid));
+duuid.b[0] = value >> 24 & 0xff;
+duuid.b[1] = value >> 16 & 0xff;
+duuid.b[2] = value >> 8 & 0xff;
+duuid.b[3] = value & 0xff;
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UUID128:
+if (buf + 16 > eob)
+continue;
+SDP_GET_UUID128(, buf);
+
+if (memcmp(, uuid, sizeof(duuid)) == 0)
+return (0);
+break;
+case SDP_DATA_UINT8:
+case SDP_DATA_INT8:
+case SDP_DATA_SEQ8:
+buf++;
+break;
+case SDP_DATA_UINT16:
+case SDP_DATA_INT16:
+case SDP_DATA_SEQ16:
+buf += 2;
+break;
+case SDP_DATA_UINT32:
+case SDP_DATA_INT32:
+case SDP_DATA_SEQ32:
+buf += 4;
+break;
+case SDP_DATA_UINT64:
+case SDP_DATA_INT64:
+buf += 8;
+break;
+case SDP_DATA_UINT128:
+case SDP_DATA_INT128:
+buf += 16;
+break;
+case SDP_DATA_STR8:
+if (buf + 1 > eob)
+continue;
+SDP_GET8(value, buf);
+buf += value;
+break;
+case SDP_DATA_STR16:
+if (buf + 2 > eob)
+continue;
+SDP_GET16(value, buf);
+if (value > (eob - buf))
+return (1);
+buf += value;
+break;
+case SDP_DATA_STR32:
+if (buf + 4 > eob)
+continue;
+SDP_GET32(value, buf);
+if (value > (eob - buf))
+return (1);
+buf += value;
+break;
+case SDP_DATA_BOOL:
+buf += 1;
+break;
+default:
+return (1);
+}
+}
+return (1);
+}
+
+/*
+ * Search a provider for matching UUID in its attributes.
+ */
+static int
+server_search_uuid(provider_p const provider, const uint128_t *uuid)
+{
+uint8_t buffer[256];
+const attr_t *attr;
+int len;
+
+for (attr = 

svn commit: r343903 - in stable/9: lib/libsdp usr.sbin/bluetooth/sdpd

2019-02-08 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb  8 10:31:45 2019
New Revision: 343903
URL: https://svnweb.freebsd.org/changeset/base/343903

Log:
  MFC r343572:
  Add support for Audio Sink and Audio Source profiles to sdpd(8).
  
  This allows user-space programs like virtual_oss(8) to act
  as a Bluetooth speaker device.
  
  Sponsored by: Mellanox Technologies

Added:
  stable/9/usr.sbin/bluetooth/sdpd/audio_sink.c
 - copied unchanged from r343572, head/usr.sbin/bluetooth/sdpd/audio_sink.c
  stable/9/usr.sbin/bluetooth/sdpd/audio_source.c
 - copied unchanged from r343572, 
head/usr.sbin/bluetooth/sdpd/audio_source.c
Modified:
  stable/9/lib/libsdp/sdp.h
  stable/9/usr.sbin/bluetooth/sdpd/Makefile
  stable/9/usr.sbin/bluetooth/sdpd/profile.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/bluetooth/sdpd/   (props changed)

Modified: stable/9/lib/libsdp/sdp.h
==
--- stable/9/lib/libsdp/sdp.h   Fri Feb  8 10:28:13 2019(r343902)
+++ stable/9/lib/libsdp/sdp.h   Fri Feb  8 10:31:45 2019(r343903)
@@ -583,6 +583,24 @@ void   sdp_print  (uint32_t level, uin
 #define SDP_PDU_SERVICE_UNREGISTER_REQUEST 0x82
 #define SDP_PDU_SERVICE_CHANGE_REQUEST 0x83
 
+struct sdp_audio_sink_profile
+{
+   uint16_t psm;
+   uint16_t protover;
+   uint16_t features;
+};
+typedef struct sdp_audio_sink_profile  sdp_audio_sink_profile_t;
+typedef struct sdp_audio_sink_profile  *sdp_audio_sink_profile_p;
+
+struct sdp_audio_source_profile
+{
+   uint16_t psm;
+   uint16_t protover;
+   uint16_t features;
+};
+typedef struct sdp_audio_source_profilesdp_audio_source_profile_t;
+typedef struct sdp_audio_source_profile *sdp_audio_source_profile_p;
+
 struct sdp_dun_profile
 {
uint8_t server_channel;

Modified: stable/9/usr.sbin/bluetooth/sdpd/Makefile
==
--- stable/9/usr.sbin/bluetooth/sdpd/Makefile   Fri Feb  8 10:28:13 2019
(r343902)
+++ stable/9/usr.sbin/bluetooth/sdpd/Makefile   Fri Feb  8 10:31:45 2019
(r343903)
@@ -3,7 +3,8 @@
 
 PROG=  sdpd
 MAN=   sdpd.8
-SRCS=  bgd.c dun.c ftrn.c gn.c irmc.c irmc_command.c lan.c log.c \
+SRCS=  audio_sink.c audio_source.c \
+   bgd.c dun.c ftrn.c gn.c irmc.c irmc_command.c lan.c log.c \
main.c nap.c opush.c panu.c profile.c provider.c sar.c scr.c \
sd.c server.c sp.c srr.c ssar.c ssr.c sur.c uuid.c
 

Copied: stable/9/usr.sbin/bluetooth/sdpd/audio_sink.c (from r343572, 
head/usr.sbin/bluetooth/sdpd/audio_sink.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/9/usr.sbin/bluetooth/sdpd/audio_sink.c   Fri Feb  8 10:31:45 
2019(r343903, copy of r343572, 
head/usr.sbin/bluetooth/sdpd/audio_sink.c)
@@ -0,0 +1,188 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Hans Petter Selasky 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#defineL2CAP_SOCKET_CHECKED
+#include 
+#include 
+#include 
+#include "profile.h"
+#include "provider.h"
+
+static int32_t
+audio_sink_profile_create_service_class_id_list(
+uint8_t *buf, uint8_t const *const eob,
+uint8_t const *data, uint32_t datalen)
+{
+   static const uint16_t service_classes[] = {
+   SDP_SERVICE_CLASS_AUDIO_SINK,
+  

svn commit: r342729 - in stable/9/sys/dev/usb: . quirk

2019-01-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan  3 09:30:10 2019
New Revision: 342729
URL: https://svnweb.freebsd.org/changeset/base/342729

Log:
  MFC r342549:
  Add USB quirk for SPL Crimson Rev 1.
  
  PR:   234380
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/usbdevs
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/9/sys/dev/usb/quirk/usb_quirk.c  Thu Jan  3 09:29:37 2019
(r342728)
+++ stable/9/sys/dev/usb/quirk/usb_quirk.c  Thu Jan  3 09:30:10 2019
(r342729)
@@ -519,6 +519,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
USB_QUIRK(MAUDIO, FASTTRACKULTRA, 0x, 0x, UQ_AU_VENDOR_CLASS),
USB_QUIRK(MAUDIO, FASTTRACKULTRA8R, 0x, 0x, UQ_AU_VENDOR_CLASS),
USB_QUIRK(CMEDIA, CM6206, 0x, 0x, UQ_AU_SET_SPDIF_CM6206),
+   USB_QUIRK(PLOYTEC, SPL_CRIMSON_1, 0x, 0x, UQ_CFG_INDEX_1),
 
/*
 * Quirks for manufacturers which USB devices does not respond

Modified: stable/9/sys/dev/usb/usbdevs
==
--- stable/9/sys/dev/usb/usbdevsThu Jan  3 09:29:37 2019
(r342728)
+++ stable/9/sys/dev/usb/usbdevsThu Jan  3 09:30:10 2019
(r342729)
@@ -488,6 +488,7 @@ vendor ASAHIOPTICAL 0x0a17  Asahi Optical
 vendor BOCASYSTEMS 0x0a43  Boca Systems
 vendor SHANTOU 0x0a46  ShanTou
 vendor MEDIAGEAR   0x0a48  MediaGear
+vendor PLOYTEC 0x0a4a  Ploytec GmbH
 vendor BROADCOM0x0a5c  Broadcom
 vendor GREENHOUSE  0x0a6b  GREENHOUSE
 vendor MEDELI  0x0a67  Medeli
@@ -3565,6 +3566,9 @@ product PLANEX2 GWUSNANO  0xab28  GW-USNano
 
 /* Plextor Corp. */
 product PLEXTOR 40_12_40U  0x0011  PlexWriter 40/12/40U
+
+/* Ploytec GmbH */
+product PLOYTEC SPL_CRIMSON_1  0xc150  SPL Crimson Revision 1
 
 /* PLX products */
 product PLX TESTBOARD  0x9060  test board
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r342728 - stable/9/sys/dev/sound/usb

2019-01-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jan  3 09:29:37 2019
New Revision: 342728
URL: https://svnweb.freebsd.org/changeset/base/342728

Log:
  MFC r342456:
  Fix reading of USB sample rate descriptor for SPL Crimson Rev 1.
  
  Read first one entry, then try to read the full rate descriptor table.
  
  PR:   234380
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==
--- stable/9/sys/dev/sound/usb/uaudio.c Thu Jan  3 09:28:18 2019
(r342727)
+++ stable/9/sys/dev/sound/usb/uaudio.c Thu Jan  3 09:29:37 2019
(r342728)
@@ -1493,7 +1493,8 @@ uaudio20_check_rate(struct usb_device *udev, uint8_t i
 {
struct usb_device_request req;
usb_error_t error;
-   uint8_t data[255];
+#defineUAUDIO20_MAX_RATES 32   /* we support at maxium 32 rates */
+   uint8_t data[2 + UAUDIO20_MAX_RATES * 12];
uint16_t actlen;
uint16_t rates;
uint16_t x;
@@ -1505,19 +1506,57 @@ uaudio20_check_rate(struct usb_device *udev, uint8_t i
req.bRequest = UA20_CS_RANGE;
USETW2(req.wValue, UA20_CS_SAM_FREQ_CONTROL, 0);
USETW2(req.wIndex, clockid, iface_no);
-   USETW(req.wLength, 255);
+   /*
+* Assume there is at least one rate to begin with, else some
+* devices might refuse to return the USB descriptor:
+*/
+   USETW(req.wLength, (2 + 1 * 12));
 
-error = usbd_do_request_flags(udev, NULL, , data,
+   error = usbd_do_request_flags(udev, NULL, , data,
USB_SHORT_XFER_OK, , USB_DEFAULT_TIMEOUT);
 
-   if (error != 0 || actlen < 2)
-   return (USB_ERR_INVAL);
+   if (error != 0 || actlen < 2) {
+   /*
+* Likely the descriptor doesn't fit into the supplied
+* buffer. Try using a larger buffer and see if that
+* helps:
+*/
+   rates = MIN(UAUDIO20_MAX_RATES, (255 - 2) / 12);
+   error = USB_ERR_INVAL;
+   } else {
+   rates = UGETW(data);
 
-   rates = data[0] | (data[1] << 8);
+   if (rates > UAUDIO20_MAX_RATES) {
+   DPRINTF("Too many rates truncating to %d\n", 
UAUDIO20_MAX_RATES);
+   rates = UAUDIO20_MAX_RATES;
+   error = USB_ERR_INVAL;
+   } else if (rates > 1) {
+   DPRINTF("Need to read full rate descriptor\n");
+   error = USB_ERR_INVAL;
+   }
+   }
+
+   if (error != 0) {
+   /*
+* Try to read full rate descriptor.
+*/
+   actlen = (2 + rates * 12);
+
+   USETW(req.wLength, actlen);
+
+   error = usbd_do_request_flags(udev, NULL, , data,
+   USB_SHORT_XFER_OK, , USB_DEFAULT_TIMEOUT);
+   
+   if (error != 0 || actlen < 2)
+   return (USB_ERR_INVAL);
+
+   rates = UGETW(data);
+   }
+
actlen = (actlen - 2) / 12;
 
if (rates > actlen) {
-   DPRINTF("Too many rates\n");
+   DPRINTF("Too many rates truncating to %d\n", actlen);
rates = actlen;
}
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r340353 - stable/9/sys/dev/sound/usb

2018-11-11 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Nov 11 12:35:30 2018
New Revision: 340353
URL: https://svnweb.freebsd.org/changeset/base/340353

Log:
  MFC r340248:
  Don't read the USB audio sync endpoint when we don't use it to save
  isochronous bandwidth.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==
--- stable/9/sys/dev/sound/usb/uaudio.c Sun Nov 11 12:34:19 2018
(r340352)
+++ stable/9/sys/dev/sound/usb/uaudio.c Sun Nov 11 12:35:30 2018
(r340353)
@@ -97,7 +97,7 @@ static int uaudio_default_bits = 32;
 static int uaudio_default_channels = 0;/* use default */
 
 #ifdef USB_DEBUG
-static int uaudio_debug = 0;
+static int uaudio_debug;
 
 static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio");
 
@@ -115,6 +115,8 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTL
 TUNABLE_INT("hw.usb.uaudio.default_channels", _default_channels);
 SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW,
 _default_channels, 0, "uaudio default sample channels");
+#else
+#defineuaudio_debug 0
 #endif
 
 #defineUAUDIO_IRQS (8000 / UAUDIO_NFRAMES) /* interrupts per 
second */
@@ -2128,6 +2130,14 @@ uaudio_chan_play_sync_callback(struct usb_xfer *xfer, 
break;
 
case USB_ST_SETUP:
+   /*
+* Check if the recording stream can be used as a
+* source of jitter information to save some
+* isochronous bandwidth:
+*/
+   if (ch->priv_sc->sc_rec_chan.num_alt != 0 &&
+   uaudio_debug == 0)
+   break;
usbd_xfer_set_frames(xfer, 1);
usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_framelen(xfer));
usbd_transfer_submit(xfer);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r339854 - stable/9/sys/dev/usb/serial

2018-10-29 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 29 12:13:05 2018
New Revision: 339854
URL: https://svnweb.freebsd.org/changeset/base/339854

Log:
  MFC r339587:
  Added support for formula-based arbitrary baud rates, in contrast to
  the current fixed values, which enables use of rates above 1 Mbps.
  Improved the detection of HXD chips, and the status flag handling as
  well.
  
  Submitted by: Gabor Simon 
  PR:   225932
  Differential revision:https://reviews.freebsd.org/D16639
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/serial/uplcom.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/serial/uplcom.c
==
--- stable/9/sys/dev/usb/serial/uplcom.cMon Oct 29 12:11:27 2018
(r339853)
+++ stable/9/sys/dev/usb/serial/uplcom.cMon Oct 29 12:13:05 2018
(r339854)
@@ -132,12 +132,20 @@ SYSCTL_INT(_hw_usb_uplcom, OID_AUTO, debug, CTLFLAG_RW
 #defineUPLCOM_SET_CRTSCTS  0x41
 #defineUPLCOM_SET_CRTSCTS_PL2303X  0x61
 #defineRSAQ_STATUS_CTS 0x80
+#defineRSAQ_STATUS_OVERRUN_ERROR   0x40
+#defineRSAQ_STATUS_PARITY_ERROR0x20 
+#defineRSAQ_STATUS_FRAME_ERROR 0x10
+#defineRSAQ_STATUS_RING0x08
+#defineRSAQ_STATUS_BREAK_ERROR 0x04
 #defineRSAQ_STATUS_DSR 0x02
 #defineRSAQ_STATUS_DCD 0x01
 
 #defineTYPE_PL2303 0
 #defineTYPE_PL2303HX   1
+#defineTYPE_PL2303HXD  2
 
+#defineUPLCOM_STATE_INDEX  8
+
 enum {
UPLCOM_BULK_DT_WR,
UPLCOM_BULK_DT_RD,
@@ -366,18 +374,49 @@ uplcom_attach(device_t dev)
 
sc->sc_udev = uaa->device;
 
-   /* Determine the chip type.  This algorithm is taken from Linux. */
dd = usbd_get_device_descriptor(sc->sc_udev);
-   if (dd->bDeviceClass == 0x02)
-   sc->sc_chiptype = TYPE_PL2303;
-   else if (dd->bMaxPacketSize == 0x40)
+
+   switch (UGETW(dd->bcdDevice)) {
+   case 0x0300:
sc->sc_chiptype = TYPE_PL2303HX;
-   else
-   sc->sc_chiptype = TYPE_PL2303;
+   /* or TA, that is HX with external crystal */
+   break;
+   case 0x0400:
+   sc->sc_chiptype = TYPE_PL2303HXD;
+   /* or EA, that is HXD with ESD protection */
+   /* or RA, that has internal voltage level converter that works 
only up to 1Mbaud (!) */
+   break;
+   case 0x0500:
+   sc->sc_chiptype = TYPE_PL2303HXD;
+   /* in fact it's TB, that is HXD with external crystal */
+   break;
+   default:
+   /* NOTE: I have no info about the bcdDevice for the base PL2303 
(up to 1.2Mbaud,
+  only fixed rates) and for PL2303SA (8-pin chip, up to 115200 
baud */
+   /* Determine the chip type.  This algorithm is taken from 
Linux. */
+   if (dd->bDeviceClass == 0x02)
+   sc->sc_chiptype = TYPE_PL2303;
+   else if (dd->bMaxPacketSize == 0x40)
+   sc->sc_chiptype = TYPE_PL2303HX;
+   else
+   sc->sc_chiptype = TYPE_PL2303;
+   break;
+   }
 
-   DPRINTF("chiptype: %s\n",
-   (sc->sc_chiptype == TYPE_PL2303HX) ?
-   "2303X" : "2303");
+   switch (sc->sc_chiptype) {
+   case TYPE_PL2303:
+   DPRINTF("chiptype: 2303\n");
+   break;
+   case TYPE_PL2303HX:
+   DPRINTF("chiptype: 2303HX/TA\n");
+   break;
+   case TYPE_PL2303HXD:
+   DPRINTF("chiptype: 2303HXD/TB/RA/EA\n");
+   break;
+   default:
+   DPRINTF("chiptype: unknown %d\n", sc->sc_chiptype);
+   break;
+   }
 
/*
 * USB-RSAQ1 has two interface
@@ -426,13 +465,14 @@ uplcom_attach(device_t dev)
goto detach;
}
 
-   if (sc->sc_chiptype != TYPE_PL2303HX) {
+   if (sc->sc_chiptype == TYPE_PL2303) {
/* HX variants seem to lock up after a clear stall request. */
mtx_lock(>sc_mtx);
usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_WR]);
usbd_xfer_set_stall(sc->sc_xfer[UPLCOM_BULK_DT_RD]);
mtx_unlock(>sc_mtx);
} else {
+   /* reset upstream data pipes */
if (uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE,
UPLCOM_SET_REQUEST, 8, 0, 0) ||
uplcom_pl2303_do(sc->sc_udev, UT_WRITE_VENDOR_DEVICE,
@@ -551,7 +591,7 @@ uplcom_pl2303_init(struct usb_device *udev, uint8_t ch
|| uplcom_pl2303_do(udev, UT_WRITE_VENDOR_DEVICE, 
UPLCOM_SET_REQUEST, 1, 0, 0))
   

svn commit: r339722 - stable/9/sys/dev/sound/midi

2018-10-25 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Oct 25 14:57:33 2018
New Revision: 339722
URL: https://svnweb.freebsd.org/changeset/base/339722

Log:
  MFC r339582:
  Drop sequencer mutex around uiomove() and make sure we don't move more bytes
  than is available, else a panic might happen.
  
  Found by: Peter Holm 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/sound/midi/sequencer.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/midi/sequencer.c
==
--- stable/9/sys/dev/sound/midi/sequencer.c Thu Oct 25 14:56:19 2018
(r339721)
+++ stable/9/sys/dev/sound/midi/sequencer.c Thu Oct 25 14:57:33 2018
(r339722)
@@ -928,7 +928,9 @@ seq_read(struct cdev *i_dev, struct uio *uio, int iofl
 
SEQ_DEBUG(8, printf("midiread: uiomove cc=%d\n", used));
MIDIQ_DEQ(scp->in_q, buf, used);
+   mtx_unlock(>seq_lock);
retval = uiomove(buf, used, uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err1;
}
@@ -1003,7 +1005,9 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
retval = ENXIO;
goto err0;
}
+   mtx_unlock(>seq_lock);
retval = uiomove(event, used, uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err0;
 
@@ -1041,7 +1045,9 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
SEQ_DEBUG(2,
   printf("seq_write: SEQ_FULLSIZE flusing buffer.\n"));
while (uio->uio_resid > 0) {
-   retval = uiomove(event, EV_SZ, uio);
+   mtx_unlock(>seq_lock);
+   retval = uiomove(event, MIN(EV_SZ, 
uio->uio_resid), uio);
+   mtx_lock(>seq_lock);
if (retval)
goto err0;
 
@@ -1052,6 +1058,7 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
}
retval = EINVAL;
if (ev_code >= 128) {
+   int error;
 
/*
 * Some sort of an extended event. The size is eight
@@ -1061,7 +1068,13 @@ seq_write(struct cdev *i_dev, struct uio *uio, int iof
SEQ_DEBUG(2, printf("seq_write: invalid level 
two event %x.\n", ev_code));
goto err0;
}
-   if (uiomove((caddr_t)[4], 4, uio)) {
+   mtx_unlock(>seq_lock);
+   if (uio->uio_resid < 4)
+   error = EINVAL;
+   else
+   error = uiomove((caddr_t)[4], 4, uio);
+   mtx_lock(>seq_lock);
+   if (error) {
SEQ_DEBUG(2,
   printf("seq_write: user memory mangled?\n"));
goto err0;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r339716 - stable/9/sys/dev/sound/midi

2018-10-25 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Oct 25 14:36:56 2018
New Revision: 339716
URL: https://svnweb.freebsd.org/changeset/base/339716

Log:
  MFC r339581:
  Fix off-by-one which can lead to panics.
  
  Found by: Peter Holm 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/sound/midi/sequencer.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/midi/sequencer.c
==
--- stable/9/sys/dev/sound/midi/sequencer.c Thu Oct 25 14:35:52 2018
(r339715)
+++ stable/9/sys/dev/sound/midi/sequencer.c Thu Oct 25 14:36:56 2018
(r339716)
@@ -737,7 +737,7 @@ static int
 seq_fetch_mid(struct seq_softc *scp, int unit, kobj_t *md)
 {
 
-   if (unit > scp->midi_number || unit < 0)
+   if (unit >= scp->midi_number || unit < 0)
return EINVAL;
 
*md = scp->midis[unit];
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r339191 - stable/9/lib/libusb

2018-10-05 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Oct  5 07:52:28 2018
New Revision: 339191
URL: https://svnweb.freebsd.org/changeset/base/339191

Log:
  MFC r338993:
  When multiple threads are involved receiving completion events in LibUSB
  make sure there is always a master polling thread, by setting the 
"ctx_handler"
  field in the context. Else the reception of completion events can stop.
  This happens if event threads are created and destroyed during runtime.
  
  Found by: Ludovic Rousseau 
  PR:   231742
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusb/libusb10_io.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10_io.c
==
--- stable/9/lib/libusb/libusb10_io.c   Fri Oct  5 07:50:44 2018
(r339190)
+++ stable/9/lib/libusb/libusb10_io.c   Fri Oct  5 07:52:28 2018
(r339191)
@@ -305,6 +305,9 @@ libusb_wait_for_event(libusb_context *ctx, struct time
if (tv == NULL) {
pthread_cond_wait(>ctx_cond,
>ctx_lock);
+   /* try to grab polling of actual events, if any */
+   if (ctx->ctx_handler == NO_THREAD)
+   ctx->ctx_handler = pthread_self();
return (0);
}
err = clock_gettime(CLOCK_MONOTONIC, );
@@ -323,6 +326,9 @@ libusb_wait_for_event(libusb_context *ctx, struct time
}
err = pthread_cond_timedwait(>ctx_cond,
>ctx_lock, );
+   /* try to grab polling of actual events, if any */
+   if (ctx->ctx_handler == NO_THREAD)
+   ctx->ctx_handler = pthread_self();
 
if (err == ETIMEDOUT)
return (1);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r338793 - stable/9/lib/libusb

2018-09-19 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Sep 19 08:13:58 2018
New Revision: 338793
URL: https://svnweb.freebsd.org/changeset/base/338793

Log:
  MFC r338679:
  Improve LibUSB debugging by simultaneously allowing both function
  and transfer prints. Make sure the debug level comes from the
  correct USB context.
  
  Found by: Ludovic Rousseau 
  PR:   231264
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusb/libusb10.h
  stable/9/lib/libusb/libusb10_io.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10.h
==
--- stable/9/lib/libusb/libusb10.h  Wed Sep 19 08:12:41 2018
(r338792)
+++ stable/9/lib/libusb/libusb10.h  Wed Sep 19 08:13:58 2018
(r338793)
@@ -37,22 +37,24 @@
 #defineHOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
 #defineHOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
 
-#defineDPRINTF(ctx, dbg, format, args...) do { \
-if ((ctx)->debug == dbg) { \
-   switch (dbg) {  \
-   case LIBUSB_DEBUG_FUNCTION: \
-   printf("LIBUSB_FUNCTION: "  \
-   format "\n", ## args);  \
-   break;  \
-   case LIBUSB_DEBUG_TRANSFER: \
-   printf("LIBUSB_TRANSFER: "  \
-   format "\n", ## args);  \
-   break;  \
-   default:\
-   break;  \
-   }   \
-}  \
-} while(0)
+#defineDPRINTF(ctx, dbg, format, ...) do { \
+   switch (dbg) {  \
+   case LIBUSB_DEBUG_FUNCTION: \
+   if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \
+   printf("LIBUSB_FUNCTION: "  \
+  format "\n", ## __VA_ARGS__);\
+   }   \
+   break;  \
+   case LIBUSB_DEBUG_TRANSFER: \
+   if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \
+   printf("LIBUSB_TRANSFER: "  \
+  format "\n", ## __VA_ARGS__);\
+   }   \
+   break;  \
+   default:\
+   break;  \
+   }   \
+} while (0)
 
 /* internal structures */
 

Modified: stable/9/lib/libusb/libusb10_io.c
==
--- stable/9/lib/libusb/libusb10_io.c   Wed Sep 19 08:12:41 2018
(r338792)
+++ stable/9/lib/libusb/libusb10_io.c   Wed Sep 19 08:13:58 2018
(r338793)
@@ -482,13 +482,26 @@ libusb_control_transfer(libusb_device_handle *devh,
return (actlen);
 }
 
+static libusb_context *
+libusb10_get_context_by_device_handle(libusb_device_handle *devh)
+{
+   libusb_context *ctx;
+
+   if (devh != NULL)
+   ctx = libusb_get_device(devh)->ctx;
+   else
+   ctx = NULL;
+
+   return (GET_CONTEXT(ctx));
+}
+
 static void
 libusb10_do_transfer_cb(struct libusb_transfer *transfer)
 {
libusb_context *ctx;
int *pdone;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(transfer->dev_handle);
 
DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done");
 
@@ -578,7 +591,8 @@ libusb_bulk_transfer(libusb_device_handle *devh,
libusb_context *ctx;
int ret;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(devh);
+
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter");
 
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
@@ -596,7 +610,8 @@ libusb_interrupt_transfer(libusb_device_handle *devh,
libusb_context *ctx;
int ret;
 
-   ctx = GET_CONTEXT(NULL);
+   ctx = libusb10_get_context_by_device_handle(devh);
+
DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter");
 
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r336891 - stable/9/sys/dev/sound/pcm

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:29:32 2018
New Revision: 336891
URL: https://svnweb.freebsd.org/changeset/base/336891

Log:
  MFC r336632:
  Update modify counter when setting a mixer control.
  
  PR:   229969

Modified:
  stable/9/sys/dev/sound/pcm/mixer.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/pcm/mixer.c
==
--- stable/9/sys/dev/sound/pcm/mixer.c  Mon Jul 30 09:28:00 2018
(r336890)
+++ stable/9/sys/dev/sound/pcm/mixer.c  Mon Jul 30 09:29:32 2018
(r336891)
@@ -323,6 +323,7 @@ mixer_set(struct snd_mixer *m, u_int dev, u_int lev)
MIXER_SET_LOCK(m, dropmtx);
 
m->level[dev] = l | (r << 8);
+   m->modify_counter++;
 
return 0;
 }
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r336888 - stable/9/sys/dev/usb

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:22:21 2018
New Revision: 336888
URL: https://svnweb.freebsd.org/changeset/base/336888

Log:
  MFC r335700:
  Improve the kernel's USB descriptor reading function.
  Some USB devices does not allow a partial descriptor readout.
  
  Found by: bz@
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_request.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb_request.c
==
--- stable/9/sys/dev/usb/usb_request.c  Mon Jul 30 09:21:19 2018
(r336887)
+++ stable/9/sys/dev/usb/usb_request.c  Mon Jul 30 09:22:21 2018
(r336888)
@@ -981,7 +981,7 @@ usbd_req_get_desc(struct usb_device *udev,
 uint8_t retries)
 {
struct usb_device_request req;
-   uint8_t *buf;
+   uint8_t *buf = desc;
usb_error_t err;
 
DPRINTFN(4, "id=%d, type=%d, index=%d, max_len=%d\n",
@@ -1003,6 +1003,32 @@ usbd_req_get_desc(struct usb_device *udev,
err = usbd_do_request_flags(udev, mtx, ,
desc, 0, NULL, 500 /* ms */);
 
+   if (err != 0 && err != USB_ERR_TIMEOUT &&
+   min_len != max_len) {
+   /* clear descriptor data */
+   memset(desc, 0, max_len);
+
+   /* try to read full descriptor length */
+   USETW(req.wLength, max_len);
+
+   err = usbd_do_request_flags(udev, mtx, ,
+   desc, USB_SHORT_XFER_OK, NULL, 500 /* ms */);
+
+   if (err == 0) {
+   /* verify length */
+   if (buf[0] > max_len)
+   buf[0] = max_len;
+   else if (buf[0] < 2)
+   err = USB_ERR_INVAL;
+
+   min_len = buf[0];
+
+   /* enforce descriptor type */
+   buf[1] = type;
+   goto done;
+   }
+   }
+
if (err) {
if (!retries) {
goto done;
@@ -1013,7 +1039,6 @@ usbd_req_get_desc(struct usb_device *udev,
 
continue;
}
-   buf = desc;
 
if (min_len == max_len) {
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r336885 - stable/9/lib/libusb

2018-07-30 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul 30 09:18:45 2018
New Revision: 336885
URL: https://svnweb.freebsd.org/changeset/base/336885

Log:
  MFC r335669:
  Improve the userspace USB string reading function in LibUSB.
  Some USB devices does not allow a partial descriptor readout.
  
  Found by: bz @
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/lib/libusb/libusb20.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb20.c
==
--- stable/9/lib/libusb/libusb20.c  Mon Jul 30 09:16:47 2018
(r336884)
+++ stable/9/lib/libusb/libusb20.c  Mon Jul 30 09:18:45 2018
(r336885)
@@ -783,6 +783,7 @@ libusb20_dev_req_string_sync(struct libusb20_device *p
 {
struct LIBUSB20_CONTROL_SETUP_DECODED req;
int error;
+   int flags;
 
/* make sure memory is initialised */
memset(ptr, 0, len);
@@ -809,22 +810,24 @@ libusb20_dev_req_string_sync(struct libusb20_device *p
error = libusb20_dev_request_sync(pdev, ,
ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK);
if (error) {
-   return (error);
+   /* try to request full string */
+   req.wLength = 255;
+   flags = 0;
+   } else {
+   /* extract length and request full string */
+   req.wLength = *(uint8_t *)ptr;
+   flags = LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK;
}
-   req.wLength = *(uint8_t *)ptr;  /* bytes */
if (req.wLength > len) {
/* partial string read */
req.wLength = len;
}
-   error = libusb20_dev_request_sync(pdev, ,
-   ptr, NULL, 1000, LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK);
-
-   if (error) {
+   error = libusb20_dev_request_sync(pdev, , ptr, NULL, 1000, flags);
+   if (error)
return (error);
-   }
-   if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING) {
+
+   if (((uint8_t *)ptr)[1] != LIBUSB20_DT_STRING)
return (LIBUSB20_ERROR_OTHER);
-   }
return (0); /* success */
 }
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r328657 - stable/9/sys/ofed/include/linux

2018-02-01 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Feb  1 13:17:42 2018
New Revision: 328657
URL: https://svnweb.freebsd.org/changeset/base/328657

Log:
  MFC r328623:
  Properly implement the cond_resched() function macro in the LinuxKPI.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/linux/sched.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/sched.h
==
--- stable/9/sys/ofed/include/linux/sched.h Thu Feb  1 13:16:11 2018
(r328656)
+++ stable/9/sys/ofed/include/linux/sched.h Thu Feb  1 13:17:42 2018
(r328657)
@@ -103,7 +103,7 @@ do {
\
kick_proc0();   \
 } while (0)
 
-#definecond_resched()  if (!cold)  sched_relinquish(curthread)
+#definecond_resched()  do { if (!cold) sched_relinquish(curthread); } 
while (0)
 
 #definesched_yield()   sched_relinquish(curthread)
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r326693 - in stable/9: share/man/man4 sys/net

2017-12-08 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Dec  8 15:30:59 2017
New Revision: 326693
URL: https://svnweb.freebsd.org/changeset/base/326693

Log:
  MFC r326362:
  Disallow TUN and TAP character device IOCTLs to modify the network device
  type to any value. This can cause page faults and panics due to accessing
  uninitialized fields in the "struct ifnet" which are specific to the network
  device type.
  
  Found by: j...@iki.fi
  PR:   223767
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/share/man/man4/tap.4
  stable/9/share/man/man4/tun.4
  stable/9/sys/net/if_tap.c
  stable/9/sys/net/if_tun.c
Directory Properties:
  stable/9/share/   (props changed)
  stable/9/share/man/   (props changed)
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/net/   (props changed)

Modified: stable/9/share/man/man4/tap.4
==
--- stable/9/share/man/man4/tap.4   Fri Dec  8 15:26:57 2017
(r326692)
+++ stable/9/share/man/man4/tap.4   Fri Dec  8 15:30:59 2017
(r326693)
@@ -1,7 +1,7 @@
 .\" $FreeBSD$
 .\" Based on PR#2411
 .\"
-.Dd November 30, 2014
+.Dd November 29, 2017
 .Dt TAP 4
 .Os
 .Sh NAME
@@ -171,7 +171,14 @@ calls are supported
 .In net/if_tap.h ) :
 .Bl -tag -width VMIO_SIOCSETMACADDR
 .It Dv TAPSIFINFO
-Set network interface information (line speed, MTU and type).
+Set network interface information (line speed and MTU).
+The type must be the same as returned by
+.Dv TAPGIFINFO
+or set to
+.Dv IFT_ETHER
+else the
+.Xr ioctl 2
+call will fail.
 The argument should be a pointer to a
 .Va struct tapinfo .
 .It Dv TAPGIFINFO

Modified: stable/9/share/man/man4/tun.4
==
--- stable/9/share/man/man4/tun.4   Fri Dec  8 15:26:57 2017
(r326692)
+++ stable/9/share/man/man4/tun.4   Fri Dec  8 15:30:59 2017
(r326693)
@@ -2,7 +2,7 @@
 .\" $FreeBSD$
 .\" Based on PR#2411
 .\"
-.Dd November 30, 2014
+.Dd November 29, 2017
 .Dt TUN 4
 .Os
 .Sh NAME
@@ -208,8 +208,15 @@ this stores the internal debugging variable's value in
 .It Dv TUNSIFINFO
 The argument should be a pointer to an
 .Vt struct tuninfo
-and allows setting the MTU, the type, and the baudrate of the tunnel
+and allows setting the MTU and the baudrate of the tunnel
 device.
+The type must be the same as returned by
+.Dv TUNGIFINFO
+or set to
+.Dv IFT_PPP
+else the
+.Xr ioctl 2
+call will fail.
 The
 .Vt struct tuninfo
 is declared in

Modified: stable/9/sys/net/if_tap.c
==
--- stable/9/sys/net/if_tap.c   Fri Dec  8 15:26:57 2017(r326692)
+++ stable/9/sys/net/if_tap.c   Fri Dec  8 15:30:59 2017(r326693)
@@ -731,9 +731,10 @@ tapioctl(struct cdev *dev, u_long cmd, caddr_t data, i
switch (cmd) {
case TAPSIFINFO:
tapp = (struct tapinfo *)data;
+   if (ifp->if_type != tapp->type)
+   return (EPROTOTYPE);
mtx_lock(>tap_mtx);
ifp->if_mtu = tapp->mtu;
-   ifp->if_type = tapp->type;
ifp->if_baudrate = tapp->baudrate;
mtx_unlock(>tap_mtx);
break;

Modified: stable/9/sys/net/if_tun.c
==
--- stable/9/sys/net/if_tun.c   Fri Dec  8 15:26:57 2017(r326692)
+++ stable/9/sys/net/if_tun.c   Fri Dec  8 15:30:59 2017(r326693)
@@ -685,9 +685,10 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i
if (error)
return (error);
}
+   if (TUN2IFP(tp)->if_type != tunp->type)
+   return (EPROTOTYPE);
mtx_lock(>tun_mtx);
TUN2IFP(tp)->if_mtu = tunp->mtu;
-   TUN2IFP(tp)->if_type = tunp->type;
TUN2IFP(tp)->if_baudrate = tunp->baudrate;
mtx_unlock(>tun_mtx);
break;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r326517 - stable/9/sys/i386/include

2017-12-04 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec  4 09:48:31 2017
New Revision: 326517
URL: https://svnweb.freebsd.org/changeset/base/326517

Log:
  MFC r326161:
  Implement atomic_fetchadd_64() for i386. This function is needed by the
  atomic64 header file in the LinuxKPI for i386.
  
  Reviewed by:  kib
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/i386/include/atomic.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/i386/include/atomic.h
==
--- stable/9/sys/i386/include/atomic.h  Mon Dec  4 09:47:42 2017
(r326516)
+++ stable/9/sys/i386/include/atomic.h  Mon Dec  4 09:48:31 2017
(r326517)
@@ -94,6 +94,7 @@ void  atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_
 
 intatomic_cmpset_64(volatile uint64_t *, uint64_t, uint64_t);
 uint64_t   atomic_swap_64(volatile uint64_t *, uint64_t);
+uint64_t   atomic_fetchadd_64(volatile uint64_t *, uint64_t);
 
 #else /* !KLD_MODULE && __GNUCLIKE_ASM */
 
@@ -478,6 +479,17 @@ atomic_swap_64(volatile uint64_t *p, uint64_t v)
return (atomic_swap_64_i386(p, v));
else
return (atomic_swap_64_i586(p, v));
+}
+
+static __inline uint64_t
+atomic_fetchadd_64(volatile uint64_t *p, uint64_t v)
+{
+
+   for (;;) {
+   uint64_t t = *p;
+   if (atomic_cmpset_64(p, t, t + v))
+   return (t);
+   }
 }
 
 #endif /* _KERNEL */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r326513 - stable/9/sys/net

2017-12-04 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec  4 09:36:47 2017
New Revision: 326513
URL: https://svnweb.freebsd.org/changeset/base/326513

Log:
  MFC r326392:
  Properly define the VLAN_XXX() function macros to avoid miscompilation when
  used inside "if" statements comparing with another value.
  
  Detailed explanation:
  "if (a ? b : c != 0)" is not the same like "if ((a ? b : c) != 0)"
  which is the expected behaviour of a function macro.
  
  Affects:
  toecore, linuxkpi and ibcore.
  
  Reviewed by:  kib
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/net/if_vlan_var.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/net/   (props changed)

Modified: stable/9/sys/net/if_vlan_var.h
==
--- stable/9/sys/net/if_vlan_var.h  Mon Dec  4 09:27:36 2017
(r326512)
+++ stable/9/sys/net/if_vlan_var.h  Mon Dec  4 09:36:47 2017
(r326513)
@@ -132,16 +132,16 @@ structvlanreq {
 } while (0)
 
 #defineVLAN_TRUNKDEV(_ifp) \
-   (_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL
+   ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL)
 #defineVLAN_TAG(_ifp, _tag)\
-   (_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_tag)) : EINVAL
+   ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_tag)) : EINVAL)
 #defineVLAN_COOKIE(_ifp)   \
-   (_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL
+   ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL)
 #defineVLAN_SETCOOKIE(_ifp, _cookie)   \
-   (_ifp)->if_type == IFT_L2VLAN ? \
-   (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL
+   ((_ifp)->if_type == IFT_L2VLAN ?\
+   (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL)
 #defineVLAN_DEVAT(_ifp, _tag)  \
-   (_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_tag)) : NULL
+   ((_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_tag)) : NULL)
 
 extern void (*vlan_trunk_cap_p)(struct ifnet *);
 extern struct ifnet *(*vlan_trunkdev_p)(struct ifnet *);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r325938 - stable/9/sys/ofed/include/linux

2017-11-17 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Nov 17 15:32:27 2017
New Revision: 325938
URL: https://svnweb.freebsd.org/changeset/base/325938

Log:
  MFC r325533:
  Make the dma_alloc_coherent() function in the LinuxKPI NULL safe with regard
  to the "dev" argument.
  
  Submitted by: Krishnamraju Eraparaju @ Chelsio
  Sponsored by: Chelsio Communications

Modified:
  stable/9/sys/ofed/include/linux/dma-mapping.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/dma-mapping.h
==
--- stable/9/sys/ofed/include/linux/dma-mapping.h   Fri Nov 17 15:30:36 
2017(r325937)
+++ stable/9/sys/ofed/include/linux/dma-mapping.h   Fri Nov 17 15:32:27 
2017(r325938)
@@ -126,7 +126,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dm
size_t align;
void *mem;
 
-   if (dev->dma_mask)
+   if (dev != NULL && dev->dma_mask)
high = *dev->dma_mask;
else
high = BUS_SPACE_MAXADDR_32BIT;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r324801 - stable/9/sys/kern

2017-10-20 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Oct 20 10:07:17 2017
New Revision: 324801
URL: https://svnweb.freebsd.org/changeset/base/324801

Log:
  MFC r324445:
  When showing the sleepqueues from the in-kernel debugger,
  properly dump all the sleepqueues and not just the first one
  
  History:
  It appears that in the commit which introduced the code,
  r165272, the array indexes of "sq_blocked[0]" and "td_name[i]"
  were interchanged. In r180927 "td_name[i]" was corrected to
  "td_name[0]", but "sq_blocked[0]" was left unchanged.
  
  PR:   222624
  Discussed with:   kmacy @
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/kern/subr_sleepqueue.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/subr_sleepqueue.c
==
--- stable/9/sys/kern/subr_sleepqueue.c Fri Oct 20 10:06:02 2017
(r324800)
+++ stable/9/sys/kern/subr_sleepqueue.c Fri Oct 20 10:07:17 2017
(r324801)
@@ -1219,7 +1219,7 @@ found:
if (TAILQ_EMPTY(>sq_blocked[i]))
db_printf("\tempty\n");
else
-   TAILQ_FOREACH(td, >sq_blocked[0],
+   TAILQ_FOREACH(td, >sq_blocked[i],
  td_slpq) {
db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td,
  td->td_tid, td->td_proc->p_pid,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r322536 - stable/9/sys/ofed/drivers/net/mlx4

2017-08-15 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Aug 15 12:28:16 2017
New Revision: 322536
URL: https://svnweb.freebsd.org/changeset/base/322536

Log:
  MFC r322248:
  Fix for mlx4en(4) to properly call m_defrag().
  
  The m_defrag() function can only defrag mbuf chains which have a valid
  mbuf packet header. In r291699 when the mlx4en(4) driver was converted
  into using BUSDMA(9), the call to m_defrag() was moved after the part
  of the transmit routine which strips the header from the mbuf chain.
  This effectivly disabled the mbuf defrag mechanism and such packets
  simply got dropped.
  
  This patch removes the stripping of mbufs from a chain and loads all
  mbufs using busdma. If busdma finds there are no segments, unload
  the DMA map and free the mbuf right away, because that means all
  data in the mbuf has been inlined in the TX ring. Else proceed
  as usual.
  
  Add a per-ring rounter for the number of defrag attempts and
  make sure the oversized_packets counter gets zeroed while at it.
  
  The counters are per-ring to avoid excessive cache misses in the
  TX path.
  
  Submitted by: mjoras@
  Differential Revision:https://reviews.freebsd.org/D11683
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/9/sys/ofed/drivers/net/mlx4/en_port.c
  stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_stats.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Tue Aug 15 12:26:43 
2017(r322535)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Tue Aug 15 12:28:16 
2017(r322536)
@@ -2682,6 +2682,8 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p
SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_chksum_offload",
CTLFLAG_RD, >port_stats.tx_chksum_offload,
"TX checksum offloads");
+   SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "defrag_attempts", 
CTLFLAG_RD,
+   >port_stats.defrag_attempts, "Oversized chains defragged");
 
/* Could strdup the names and add in a loop.  This is simpler. */
SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_bytes", CTLFLAG_RD,
@@ -2775,6 +2777,10 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p
CTLFLAG_RD, _ring->packets, "TX packets");
SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "bytes",
CTLFLAG_RD, _ring->bytes, "TX bytes");
+   SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "tso_packets",
+   CTLFLAG_RD, _ring->tso_packets, "TSO packets");
+   SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "defrag_attempts",
+   CTLFLAG_RD, _ring->defrag_attempts, "Oversized chains 
defragged");
}
 
for (i = 0; i < priv->rx_ring_num; i++) {

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_port.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_port.cTue Aug 15 12:26:43 
2017(r322535)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_port.cTue Aug 15 12:28:16 
2017(r322536)
@@ -224,11 +224,16 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u
priv->port_stats.tx_chksum_offload = 0;
priv->port_stats.queue_stopped = 0;
priv->port_stats.wake_queue = 0;
+   priv->port_stats.oversized_packets = 0;
+   priv->port_stats.tso_packets = 0;
+   priv->port_stats.defrag_attempts = 0;
for (i = 0; i < priv->tx_ring_num; i++) {
priv->port_stats.tx_chksum_offload += priv->tx_ring[i]->tx_csum;
priv->port_stats.queue_stopped += 
priv->tx_ring[i]->queue_stopped;
priv->port_stats.wake_queue += priv->tx_ring[i]->wake_queue;
priv->port_stats.oversized_packets += 
priv->tx_ring[i]->oversized_packets;
+   priv->port_stats.tso_packets += priv->tx_ring[i]->tso_packets;
+   priv->port_stats.defrag_attempts += 
priv->tx_ring[i]->defrag_attempts;
}
/* RX Statistics */
priv->pkstats.rx_packets = be64_to_cpu(mlx4_en_stats->RTOT_prio_0) +

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Tue Aug 15 12:26:43 2017
(r322535)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Tue Aug 15 12:28:16 2017
(r322536)
@@ -789,7 +789,7 @@ static int mlx4_en_xmit(struct mlx4_en_priv *priv, int
num_pkts = DIV_ROUND_UP(payload_len, mss);
ring->bytes += payload_len + (num_pkts * ihs);
ring->packets += num_pkts;
-   

svn commit: r322506 - stable/9/sys/ofed/drivers/net/mlx4

2017-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 14 13:37:46 2017
New Revision: 322506
URL: https://svnweb.freebsd.org/changeset/base/322506

Log:
  MFC r322306:
  Print maximum MTU when trying to set invalid MTU in the mlx4en(4) driver.
  Useful for debugging.
  
  Submitted by: Sepherosa Ziehau 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Mon Aug 14 13:32:21 
2017(r322505)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Mon Aug 14 13:37:46 
2017(r322506)
@@ -1772,7 +1772,8 @@ static int mlx4_en_change_mtu(struct net_device *dev, 
   (unsigned)dev->if_mtu, (unsigned)new_mtu);
 
if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) {
-   en_err(priv, "Bad MTU size:%d.\n", new_mtu);
+   en_err(priv, "Bad MTU size:%d, max %u.\n", new_mtu,
+   priv->max_mtu);
return -EPERM;
}
mutex_lock(>state_lock);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r322503 - stable/9/sys/ofed/drivers/net/mlx4

2017-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 14 13:27:08 2017
New Revision: 322503
URL: https://svnweb.freebsd.org/changeset/base/322503

Log:
  MFC r322304:
  Add support for RX and TX statistics when the mlx4en(4) PCI device
  is in VF or SRIOV mode typically in a virtual machine environment.
  
  Submitted by: Sepherosa Ziehau 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_port.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_port.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_port.cMon Aug 14 13:25:35 
2017(r322502)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_port.cMon Aug 14 13:27:08 
2017(r322503)
@@ -124,11 +124,45 @@ out:
return err;
 }
 
+static void mlx4_en_fold_software_stats(struct net_device *dev)
+{
+   struct mlx4_en_priv *priv = netdev_priv(dev);
+   struct mlx4_en_dev *mdev = priv->mdev;
+   u64 packets, bytes;
+   int i;
+
+   if (!priv->port_up || mlx4_is_master(mdev->dev))
+   return;
+
+   packets = 0;
+   bytes = 0;
+   for (i = 0; i < priv->rx_ring_num; i++) {
+   const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
+
+   packets += READ_ONCE(ring->packets);
+   bytes += READ_ONCE(ring->bytes);
+   }
+   priv->pkstats.rx_packets = packets;
+   priv->pkstats.rx_bytes = bytes;
+
+   packets = 0;
+   bytes = 0;
+   for (i = 0; i < priv->tx_ring_num; i++) {
+   const struct mlx4_en_tx_ring *ring = priv->tx_ring[i];
+
+   packets += READ_ONCE(ring->packets);
+   bytes += READ_ONCE(ring->bytes);
+   }
+   priv->pkstats.tx_packets = packets;
+   priv->pkstats.tx_bytes = bytes;
+}
+
 int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 {
struct mlx4_en_stat_out_mbox *mlx4_en_stats;
struct mlx4_en_stat_out_flow_control_mbox *flowstats;
-   struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]);
+   struct net_device *dev = mdev->pndev[port];
+   struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_vport_stats *vport_stats = >vport_stats;
struct mlx4_cmd_mailbox *mailbox = NULL;
struct mlx4_cmd_mailbox *mailbox_flow = NULL;
@@ -138,7 +172,6 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u
int do_if_stat = 1;
unsigned long period = (unsigned long) (jiffies - 
priv->last_ifq_jiffies);
struct mlx4_en_vport_stats tmp_vport_stats;
-struct net_device *dev;
 
if (jiffies_to_msecs(period) < EN_IFQ_MIN_INTERVAL ||
priv->counter_index == 0xff)
@@ -523,8 +556,12 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u
be64_to_cpu(flowstats[i].tx_pause_transition);
}
 
-   memset(_vport_stats, 0, sizeof(tmp_vport_stats));
+   mlx4_en_fold_software_stats(dev);
+
spin_unlock(>stats_lock);
+
+   memset(_vport_stats, 0, sizeof(tmp_vport_stats));
+
err = mlx4_get_vport_ethtool_stats(mdev->dev, port,
   _vport_stats, reset);
spin_lock(>stats_lock);
@@ -547,19 +584,37 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u
vport_stats->tx_errors = tmp_vport_stats.tx_errors;
}
 
-   if (!mlx4_is_mfunc(mdev->dev)) {
-   /* netdevice stats format */
-dev = mdev->pndev[port];
-   dev->if_ipackets= priv->pkstats.rx_packets;
-   dev->if_opackets= priv->pkstats.tx_packets;
-   dev->if_ibytes  = priv->pkstats.rx_bytes;
-   dev->if_obytes  = priv->pkstats.tx_bytes;
-   dev->if_ierrors = priv->pkstats.rx_errors;
-   dev->if_iqdrops = priv->pkstats.rx_dropped;
-   dev->if_imcasts = priv->pkstats.rx_multicast_packets;
-dev->if_omcasts = priv->pkstats.tx_multicast_packets;
-dev->if_collisions  = 0;
+#if __FreeBSD_version >= 110
+   if (reset == 0) {
+   if_inc_counter(dev, IFCOUNTER_IPACKETS,
+   priv->pkstats.rx_packets - priv->pkstats_last.rx_packets);
+   if_inc_counter(dev, IFCOUNTER_OPACKETS,
+   priv->pkstats.tx_packets - priv->pkstats_last.tx_packets);
+   if_inc_counter(dev, IFCOUNTER_IBYTES,
+   priv->pkstats.rx_bytes - priv->pkstats_last.rx_bytes);
+   if_inc_counter(dev, IFCOUNTER_OBYTES,
+   priv->pkstats.tx_bytes - priv->pkstats_last.tx_bytes);
+   if_inc_counter(dev, IFCOUNTER_IERRORS,
+   priv->pkstats.rx_errors - priv->pkstats_last.rx_errors);
+  

svn commit: r322502 - stable/9/sys/ofed/include/linux

2017-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 14 13:25:35 2017
New Revision: 322502
URL: https://svnweb.freebsd.org/changeset/base/322502

Log:
  MFC r289577:
  Merge LinuxKPI changes from DragonflyBSD:
  - Map more Linux compiler related defines to FreeBSD ones.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/linux/compiler.h
  stable/9/sys/ofed/include/linux/types.h

Modified: stable/9/sys/ofed/include/linux/compiler.h
==
--- stable/9/sys/ofed/include/linux/compiler.h  Mon Aug 14 13:15:13 2017
(r322501)
+++ stable/9/sys/ofed/include/linux/compiler.h  Mon Aug 14 13:25:35 2017
(r322502)
@@ -2,7 +2,8 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,6 +63,13 @@
 #define typeof(x)  __typeof(x)
 
 #defineuninitialized_var(x)x = x
+#define__read_mostly __attribute__((__section__(".data.read_mostly")))
+#define__always_unused __unused
+#define__must_check__result_use_check
+
+#define__printf(a,b)   __printflike(a,b)
+
+#definebarrier()   __asm__ __volatile__("": : 
:"memory")
 
 #defineACCESS_ONCE(x)  (*(volatile __typeof(x) *)&(x))
   

Modified: stable/9/sys/ofed/include/linux/types.h
==
--- stable/9/sys/ofed/include/linux/types.h Mon Aug 14 13:15:13 2017
(r322501)
+++ stable/9/sys/ofed/include/linux/types.h Mon Aug 14 13:25:35 2017
(r322502)
@@ -36,8 +36,6 @@
 #include 
 #include 
 
-#define__read_mostly __attribute__((__section__(".data.read_mostly")))
-
 #ifndef __bitwise__
 #ifdef __CHECKER__
 #define __bitwise__ __attribute__((bitwise))
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

svn commit: r322501 - stable/9/sys/ofed/include/linux

2017-08-14 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 14 13:15:13 2017
New Revision: 322501
URL: https://svnweb.freebsd.org/changeset/base/322501

Log:
  MFC r292537 and r314878:
  Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/linux/compiler.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/compiler.h
==
--- stable/9/sys/ofed/include/linux/compiler.h  Mon Aug 14 12:59:14 2017
(r322500)
+++ stable/9/sys/ofed/include/linux/compiler.h  Mon Aug 14 13:15:13 2017
(r322501)
@@ -63,4 +63,21 @@
 
 #defineuninitialized_var(x)x = x
 
+#defineACCESS_ONCE(x)  (*(volatile __typeof(x) *)&(x))
+  
+#defineWRITE_ONCE(x,v) do {\
+   barrier();  \
+   ACCESS_ONCE(x) = (v);   \
+   barrier();  \
+} while (0)
+
+#defineREAD_ONCE(x) ({ \
+   __typeof(x) __var = ({  \
+   barrier();  \
+   ACCESS_ONCE(x); \
+   }); \
+   barrier();  \
+   __var;  \
+})
+
 #endif /* _LINUX_COMPILER_H_ */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r322166 - in stable/9/sys/ofed: drivers/net/mlx4 include/linux/mlx4

2017-08-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  7 13:27:35 2017
New Revision: 322166
URL: https://svnweb.freebsd.org/changeset/base/322166

Log:
  MFC r321782:
  Remove some dead statistics related code and a structure field from the
  mlx4en driver which is used by its Linux counterpart, but not under
  FreeBSD.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_stats.h
  stable/9/sys/ofed/drivers/net/mlx4/port.c
  stable/9/sys/ofed/include/linux/mlx4/device.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Mon Aug  7 13:25:57 
2017(r322165)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Mon Aug  7 13:27:35 
2017(r322166)
@@ -1378,8 +1378,6 @@ int mlx4_en_start_port(struct net_device *dev)
/* Schedule multicast task to populate multicast list */
queue_work(mdev->workqueue, >rx_mode_task);
 
-   mlx4_set_stats_bitmap(mdev->dev, priv->stats_bitmap);
-
priv->port_up = true;
 
 /* Enable the queues. */
@@ -2731,28 +2729,6 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p
SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_gt_1548_bytes_packets", 
CTLFLAG_RD,
>pkstats.rx_gt_1548_bytes_packets,
"RX Greater Then 1548 bytes Packets");
-
-struct mlx4_en_pkt_stats {
-   unsigned long tx_packets;
-   unsigned long tx_bytes;
-   unsigned long tx_multicast_packets;
-   unsigned long tx_broadcast_packets;
-   unsigned long tx_errors;
-   unsigned long tx_dropped;
-   unsigned long tx_lt_64_bytes_packets;
-   unsigned long tx_127_bytes_packets;
-   unsigned long tx_255_bytes_packets;
-   unsigned long tx_511_bytes_packets;
-   unsigned long tx_1023_bytes_packets;
-   unsigned long tx_1518_bytes_packets;
-   unsigned long tx_1522_bytes_packets;
-   unsigned long tx_1548_bytes_packets;
-   unsigned long tx_gt_1548_bytes_packets;
-   unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-   unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-#define NUM_PKT_STATS  72
-};
-
 
SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_packets", CTLFLAG_RD,
>pkstats.tx_packets, "TX packets");

Modified: stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
==
--- stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hMon Aug  7 13:25:57 
2017(r322165)
+++ stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hMon Aug  7 13:27:35 
2017(r322166)
@@ -571,7 +571,6 @@ struct mlx4_en_priv {
struct mlx4_en_port_stats port_stats;
struct mlx4_en_vport_stats vport_stats;
struct mlx4_en_vf_stats vf_stats;
-   DECLARE_BITMAP(stats_bitmap, NUM_ALL_STATS);
struct list_head mc_list;
struct list_head curr_list;
u64 broadcast_id;

Modified: stable/9/sys/ofed/drivers/net/mlx4/mlx4_stats.h
==
--- stable/9/sys/ofed/drivers/net/mlx4/mlx4_stats.h Mon Aug  7 13:25:57 
2017(r322165)
+++ stable/9/sys/ofed/drivers/net/mlx4/mlx4_stats.h Mon Aug  7 13:27:35 
2017(r322166)
@@ -82,7 +82,6 @@ struct mlx4_en_pkt_stats {
unsigned long tx_gt_1548_bytes_packets;
unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-#define NUM_PKT_STATS  72
 };
 
 struct mlx4_en_vf_stats {
@@ -97,7 +96,6 @@ struct mlx4_en_vf_stats {
unsigned long tx_multicast_packets;
unsigned long tx_broadcast_packets;
unsigned long tx_errors;
-#define NUM_VF_STATS   11
 };
 
 struct mlx4_en_vport_stats {
@@ -116,7 +114,6 @@ struct mlx4_en_vport_stats {
unsigned long tx_broadcast_packets;
unsigned long tx_broadcast_bytes;
unsigned long tx_errors;
-#define NUM_VPORT_STATS15
 };
 
 struct mlx4_en_port_stats {
@@ -129,7 +126,6 @@ struct mlx4_en_port_stats {
unsigned long rx_chksum_good;
unsigned long rx_chksum_none;
unsigned long tx_chksum_offload;
-#define NUM_PORT_STATS 8
 };
 
 struct mlx4_en_perf_stats {
@@ -139,7 +135,6 @@ struct mlx4_en_perf_stats {
u16 tx_coal_avg;
u16 rx_coal_avg;
u32 napi_quota;
-#define NUM_PERF_COUNTERS  6
 };
 
 struct mlx4_en_flow_stats {
@@ -151,8 +146,6 @@ struct mlx4_en_flow_stats {
u64 tx_pause_transition;
 };
 #define MLX4_NUM_PRIORITIES8
-#define NUM_FLOW_PRIORITY_STATS6
-#define NUM_FLOW_STATS (NUM_FLOW_PRIORITY_STATS*MLX4_NUM_PRIORITIES)
 
 
 struct 

svn commit: r322163 - in stable/9/sys/ofed: drivers/net/mlx4 include/linux/mlx4

2017-08-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  7 13:17:57 2017
New Revision: 322163
URL: https://svnweb.freebsd.org/changeset/base/322163

Log:
  MFC r321772:
  Fix broken usage of the mlx4_read_clock() function:
   - return value has too small width
   - cycle_t is unsigned and cannot be less than zero
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/main.c
  stable/9/sys/ofed/include/linux/mlx4/device.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/main.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon Aug  7 13:16:38 2017
(r322162)
+++ stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon Aug  7 13:17:57 2017
(r322163)
@@ -1795,10 +1795,10 @@ static void unmap_bf_area(struct mlx4_dev *dev)
io_mapping_free(mlx4_priv(dev)->bf_mapping);
 }
 
-int mlx4_read_clock(struct mlx4_dev *dev)
+s64 mlx4_read_clock(struct mlx4_dev *dev)
 {
u32 clockhi, clocklo, clockhi1;
-   cycle_t cycles;
+   s64 cycles;
int i;
struct mlx4_priv *priv = mlx4_priv(dev);
 
@@ -1815,7 +1815,7 @@ int mlx4_read_clock(struct mlx4_dev *dev)
 
cycles = (u64) clockhi << 32 | (u64) clocklo;
 
-   return cycles;
+   return cycles & CORE_CLOCK_MASK;
 }
 EXPORT_SYMBOL_GPL(mlx4_read_clock);
 

Modified: stable/9/sys/ofed/include/linux/mlx4/device.h
==
--- stable/9/sys/ofed/include/linux/mlx4/device.h   Mon Aug  7 13:16:38 
2017(r322162)
+++ stable/9/sys/ofed/include/linux/mlx4/device.h   Mon Aug  7 13:17:57 
2017(r322163)
@@ -1337,7 +1337,7 @@ int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev,
 
 int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, 
u32 max_range_qpn);
 
-int mlx4_read_clock(struct mlx4_dev *dev);
+s64 mlx4_read_clock(struct mlx4_dev *dev);
 int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
   struct mlx4_clock_params *params);
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r322157 - stable/9/sys/ofed/drivers/infiniband/core

2017-08-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  7 12:59:32 2017
New Revision: 322157
URL: https://svnweb.freebsd.org/changeset/base/322157

Log:
  MFC r321986:
  Change reject message type when destroying cm_id in ibore.
  
  This patch fixes an interopability issue between FreeBSD and non-FreeBSD
  systems when the connection establishment is aborted. Refer to the
  initial commit in Linux, drivers/infiniband/core/cm.c,
  for a more detailed description.
  
  Obtained from:Linux
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/infiniband/core/cm.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/core/cm.c
==
--- stable/9/sys/ofed/drivers/infiniband/core/cm.c  Mon Aug  7 12:58:31 
2017(r322156)
+++ stable/9/sys/ofed/drivers/infiniband/core/cm.c  Mon Aug  7 12:59:32 
2017(r322157)
@@ -870,6 +870,7 @@ retest:
cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
break;
case IB_CM_REQ_SENT:
+   case IB_CM_MRA_REQ_RCVD:
ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
spin_unlock_irq(_id_priv->lock);
ib_send_cm_rej(cm_id, IB_CM_REJ_TIMEOUT,
@@ -888,7 +889,6 @@ retest:
   NULL, 0, NULL, 0);
}
break;
-   case IB_CM_MRA_REQ_RCVD:
case IB_CM_REP_SENT:
case IB_CM_MRA_REP_RCVD:
ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r322154 - stable/9/sys/ofed/drivers/infiniband/core

2017-08-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug  7 12:56:03 2017
New Revision: 322154
URL: https://svnweb.freebsd.org/changeset/base/322154

Log:
  MFC r321985:
  Ticks are 32-bit in FreeBSD.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/infiniband/core/addr.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/core/addr.c
==
--- stable/9/sys/ofed/drivers/infiniband/core/addr.cMon Aug  7 12:53:10 
2017(r322153)
+++ stable/9/sys/ofed/drivers/infiniband/core/addr.cMon Aug  7 12:56:03 
2017(r322154)
@@ -192,10 +192,10 @@ EXPORT_SYMBOL(rdma_translate_ip);
 
 static void set_timeout(unsigned long time)
 {
-   unsigned long delay;
+   int delay;  /* under FreeBSD ticks are 32-bit */
 
delay = time - jiffies;
-   if ((long)delay <= 0)
+   if (delay <= 0)
delay = 1;
 
mod_delayed_work(addr_wq, , delay);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r320946 - stable/9/sys/ofed/drivers/net/mlx4

2017-07-13 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jul 13 15:12:01 2017
New Revision: 320946
URL: https://svnweb.freebsd.org/changeset/base/320946

Log:
  MFC r320876:
  Make sure the mlx4en RX DMA ring gets stamped with software ownership
  in order to prevent the flow of QP to error in the firmware once
  UPDATE_QP is called.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Thu Jul 13 15:10:02 2017
(r320945)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Thu Jul 13 15:12:01 2017
(r320946)
@@ -394,8 +394,14 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *pri
 ring->rx_mb_size = priv->rx_mb_size;
 
ring->stride = stride;
-   if (ring->stride <= TXBB_SIZE)
+   if (ring->stride <= TXBB_SIZE) {
+   /* Stamp first unused send wqe */
+   __be32 *ptr = (__be32 *)ring->buf;
+   __be32 stamp = cpu_to_be32(1 << STAMP_SHIFT);
+   *ptr = stamp;
+   /* Move pointer to start of rx section */   
ring->buf += TXBB_SIZE;
+   }
 
ring->log_stride = ffs(ring->stride) - 1;
ring->buf_size = ring->size * ring->stride;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r320068 - stable/9/sys/ofed/drivers/net/mlx4

2017-06-18 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Jun 18 11:50:09 2017
New Revision: 320068
URL: https://svnweb.freebsd.org/changeset/base/320068

Log:
  MFC r319972:
  Use static device numbering instead of dynamic one when creating
  mlx4en network interfaces. This prevents infinite unit number growth
  typically when the mlx4en driver is used inside virtual machines which
  support runtime PCI attach and detach.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Jun 18 11:48:40 
2017(r320067)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Sun Jun 18 11:50:09 
2017(r320068)
@@ -54,7 +54,6 @@
 
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv);
 static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv);
-static int mlx4_en_unit;
 
 #ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
@@ -2055,7 +2054,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
return -ENOMEM;
}
dev->if_softc = priv;
-   if_initname(dev, "mlxen", atomic_fetchadd_int(_en_unit, 1));
+   if_initname(dev, "mlxen", (device_get_unit(
+   mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1);
dev->if_mtu = ETHERMTU;
dev->if_init = mlx4_en_open;
dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r319565 - stable/9/sys/ofed/drivers/net/mlx4

2017-06-04 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Jun  4 08:30:55 2017
New Revision: 319565
URL: https://svnweb.freebsd.org/changeset/base/319565

Log:
  MFC r319414:
  Allow communication between functions on the same host when using the
  mlx4en(4) driver in SRIOV mode.
  
  Place a copy of the destination MAC address in the send WQE only under
  SRIOV/eSwitch configuration or when the device is in selftest. This
  allows communication between functions on the same host.
  
  PR:   216493
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Sun Jun  4 08:29:17 2017
(r319564)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Sun Jun  4 08:30:55 2017
(r319565)
@@ -657,18 +657,6 @@ static void mlx4_bf_copy(void __iomem *dst, volatile u
__iowrite64_copy(dst, __DEVOLATILE(void *, src), bytecnt / 8);
 }
 
-static u64 mlx4_en_mac_to_u64(u8 *addr)
-{
-u64 mac = 0;
-int i;
-
-for (i = 0; i < ETHER_ADDR_LEN; i++) {
-mac <<= 8;
-mac |= addr[i];
-}
-return mac;
-}
-
 static int mlx4_en_xmit(struct mlx4_en_priv *priv, int tx_ind, struct mbuf 
**mbp)
 {
enum {
@@ -766,8 +754,18 @@ static int mlx4_en_xmit(struct mlx4_en_priv *priv, int
tx_desc->ctrl.ins_vlan = 0;
}
 
-   /* clear immediate field */
-   tx_desc->ctrl.imm = 0;
+   if (unlikely(mlx4_is_mfunc(priv->mdev->dev) || 
priv->validate_loopback)) {
+   /*
+* Copy destination MAC address to WQE. This allows
+* loopback in eSwitch, so that VFs and PF can
+* communicate with each other:
+*/
+   m_copydata(mb, 0, 2, __DEVOLATILE(void *, 
_desc->ctrl.srcrb_flags16[0]));
+   m_copydata(mb, 2, 4, __DEVOLATILE(void *, _desc->ctrl.imm));
+   } else {
+   /* clear immediate field */
+   tx_desc->ctrl.imm = 0;
+   }
 
/* Handle LSO (TSO) packets */
if (mb->m_pkthdr.csum_flags & CSUM_TSO) {
@@ -925,22 +923,6 @@ skip_dma:
mlx4_en_store_inline_lso_header(dseg_inline, ihs, owner_bit);
else
mlx4_en_store_inline_header(dseg_inline, ihs, owner_bit);
-
-   if (unlikely(priv->validate_loopback)) {
-   /* Copy dst mac address to wqe */
-struct ether_header *ethh;
-u64 mac;
-u32 mac_l, mac_h;
-
-ethh = mtod(mb, struct ether_header *);
-mac = mlx4_en_mac_to_u64(ethh->ether_dhost);
-if (mac) {
-mac_h = (u32) ((mac & 0xULL) >> 16);
-mac_l = (u32) (mac & 0x);
-tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h);
-tx_desc->ctrl.imm = cpu_to_be32(mac_l);
-}
-   }
 
/* update producer counter */
ring->prod += tx_info->nr_txbb;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r319067 - in stable/9/sys: dev/sound/pcm tools/sound

2017-05-28 Thread Hans Petter Selasky
Author: hselasky
Date: Sun May 28 10:45:28 2017
New Revision: 319067
URL: https://svnweb.freebsd.org/changeset/base/319067

Log:
  MFC r318860:
  Declare the "snd_fxdiv_table" once. This shaves around 24Kbytes of
  binary data from sound.ko and the kernel.

Modified:
  stable/9/sys/dev/sound/pcm/buffer.c
  stable/9/sys/tools/sound/snd_fxdiv_gen.awk
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/pcm/buffer.c
==
--- stable/9/sys/dev/sound/pcm/buffer.c Sun May 28 10:44:43 2017
(r319066)
+++ stable/9/sys/dev/sound/pcm/buffer.c Sun May 28 10:45:28 2017
(r319067)
@@ -35,6 +35,7 @@
 #include "feeder_if.h"
 
 #define SND_USE_FXDIV
+#defineSND_DECLARE_FXDIV
 #include "snd_fxdiv_gen.h"
 
 SND_DECLARE_FILE("$FreeBSD$");

Modified: stable/9/sys/tools/sound/snd_fxdiv_gen.awk
==
--- stable/9/sys/tools/sound/snd_fxdiv_gen.awk  Sun May 28 10:44:43 2017
(r319066)
+++ stable/9/sys/tools/sound/snd_fxdiv_gen.awk  Sun May 28 10:45:28 2017
(r319067)
@@ -108,7 +108,10 @@ BEGIN {
printf(" * 508 = SND_CHN_MAX * PCM_32_BPS, which is why\n");
printf(" */\n\n");
 
-   printf("static const uint32_t snd_fxdiv_table[][2] = {\n");
+   printf("extern const uint32_t snd_fxdiv_table[%d][2];\n\n", 
SND_MAX_ALIGN + 1);
+
+   printf("#ifdef SND_DECLARE_FXDIV\n");
+   printf("const uint32_t snd_fxdiv_table[%d][2] = {\n", SND_MAX_ALIGN + 
1);
 
for (i = 1; i <= SND_MAX_ALIGN; i++) {
if (aligns[i] != 1)
@@ -120,7 +123,7 @@ BEGIN {
i, r["mul"], r["shift"]);
}
 
-   printf("};\n\n");
+   printf("};\n#endif\n\n");
 
printf("#define SND_FXDIV_MAX\t\t0x%08x\n", FXONE);
printf("#define SND_FXDIV(x, y)\t\t(((uint32_t)(x) *\t\t\t\\\n");
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r318629 - stable/9/sys/ofed/drivers/net/mlx4

2017-05-22 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May 22 08:20:50 2017
New Revision: 318629
URL: https://svnweb.freebsd.org/changeset/base/318629

Log:
  MFC r318531:
  
  mlx4: Use the CQ quota for SRIOV when creating completion EQs
  
  When creating EQs to handle CQ completion events for the PF or for
  VFs, we create enough EQE entries to handle completions for the max
  number of CQs that can use that EQ.
  
  When SRIOV is activated, the max number of CQs a VF (or the PF) can
  obtain is its CQ quota (determined by the Hypervisor resource
  tracker).  Therefore, when creating an EQ, the number of EQE entries
  that the VF should request for that EQ is the CQ quota value (and not
  the total number of CQs available in the firmware).
  
  Under SRIOV, the PF, also must use its CQ quota, because the resource
  tracker also controls how many CQs the PF can obtain.
  
  Using the firmware total CQs instead of the CQ quota when creating EQs
  resulted wasting MTT entries, due to allocating more EQEs than were
  needed.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/eq.c
  stable/9/sys/ofed/drivers/net/mlx4/main.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/eq.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/eq.c Mon May 22 08:19:08 2017
(r318628)
+++ stable/9/sys/ofed/drivers/net/mlx4/eq.c Mon May 22 08:20:50 2017
(r318629)
@@ -1169,8 +1169,7 @@ int mlx4_init_eq_table(struct mlx4_dev *
}
 
for (i = 0; i < dev->caps.num_comp_vectors; ++i) {
-   err = mlx4_create_eq(dev, dev->caps.num_cqs -
- dev->caps.reserved_cqs +
+   err = mlx4_create_eq(dev, dev->quotas.cq +
  MLX4_NUM_SPARE_EQE,
 (dev->flags & MLX4_FLAG_MSI_X) ? i : 0,
 >eq_table.eq[i]);
@@ -1190,8 +1189,7 @@ int mlx4_init_eq_table(struct mlx4_dev *
for (i = dev->caps.num_comp_vectors + 1;
  i < dev->caps.num_comp_vectors + dev->caps.comp_pool + 1; ++i) {
 
-   err = mlx4_create_eq(dev, dev->caps.num_cqs -
- dev->caps.reserved_cqs +
+   err = mlx4_create_eq(dev, dev->quotas.cq +
  MLX4_NUM_SPARE_EQE,
 (dev->flags & MLX4_FLAG_MSI_X) ? i : 0,
 >eq_table.eq[i]);

Modified: stable/9/sys/ofed/drivers/net/mlx4/main.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon May 22 08:19:08 2017
(r318628)
+++ stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon May 22 08:20:50 2017
(r318629)
@@ -3448,6 +3448,8 @@ slave_start:
goto err_free_eq;
}
 
+   mlx4_init_quotas(dev);
+
err = mlx4_setup_hca(dev);
if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X) &&
!mlx4_is_mfunc(dev)) {
@@ -3461,7 +3463,6 @@ slave_start:
if (err)
goto err_steer;
 
-   mlx4_init_quotas(dev);
mlx4_init_hca_info(dev);
 
for (port = 1; port <= dev->caps.num_ports; port++) {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r318541 - stable/9/sys/ofed/drivers/net/mlx4

2017-05-19 Thread Hans Petter Selasky
Author: hselasky
Date: Fri May 19 13:05:40 2017
New Revision: 318541
URL: https://svnweb.freebsd.org/changeset/base/318541

Log:
  MFC r317505:
  Don't free uninitialized sysctl contexts in the mlx4en driver. This
  can cause NULL pointer panics during failed device attach.
  
  Differential Revision:https://reviews.freebsd.org/D8876
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri May 19 13:04:09 
2017(r318540)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri May 19 13:05:40 
2017(r318541)
@@ -1640,7 +1640,7 @@ void mlx4_en_free_resources(struct mlx4_
mlx4_en_destroy_cq(priv, >rx_cq[i]);
}
 
-   if (priv->sysctl)
+   if (priv->stat_sysctl != NULL)
sysctl_ctx_free(>stat_ctx);
 }
 
@@ -1755,7 +1755,7 @@ void mlx4_en_destroy_netdev(struct net_d
mlx4_en_free_resources(priv);
 
/* freeing the sysctl conf cannot be called from within 
mlx4_en_free_resources */
-   if (priv->sysctl)
+   if (priv->conf_sysctl != NULL)
sysctl_ctx_free(>conf_ctx);
 
kfree(priv->tx_ring);
@@ -2573,9 +2573,9 @@ static void mlx4_en_sysctl_conf(struct m
pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev);
 
 sysctl_ctx_init(ctx);
-priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
+priv->conf_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
 OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet");
-node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->conf_sysctl), 
OID_AUTO,
 "conf", CTLFLAG_RD, NULL, "Configuration");
 node_list = SYSCTL_CHILDREN(node);
 
@@ -2638,7 +2638,6 @@ static void mlx4_en_sysctl_conf(struct m
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv)
 {
struct sysctl_ctx_list *ctx;
-   struct sysctl_oid *node;
struct sysctl_oid_list *node_list;
struct sysctl_oid *ring_node;
struct sysctl_oid_list *ring_list;
@@ -2649,9 +2648,9 @@ static void mlx4_en_sysctl_stat(struct m
 
ctx = >stat_ctx;
sysctl_ctx_init(ctx);
-   node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+   priv->stat_sysctl = SYSCTL_ADD_NODE(ctx, 
SYSCTL_CHILDREN(priv->conf_sysctl), OID_AUTO,
"stat", CTLFLAG_RD, NULL, "Statistics");
-   node_list = SYSCTL_CHILDREN(node);
+   node_list = SYSCTL_CHILDREN(priv->stat_sysctl);
 
 #ifdef MLX4_EN_PERF_STAT
SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_poll", CTLFLAG_RD,

Modified: stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
==
--- stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri May 19 13:04:09 
2017(r318540)
+++ stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri May 19 13:05:40 
2017(r318541)
@@ -586,7 +586,8 @@ struct mlx4_en_priv {
struct callout watchdog_timer;
 struct ifmedia media;
volatile int blocked;
-   struct sysctl_oid *sysctl;
+   struct sysctl_oid *conf_sysctl;
+   struct sysctl_oid *stat_sysctl;
struct sysctl_ctx_list conf_ctx;
struct sysctl_ctx_list stat_ctx;
 #define MLX4_EN_MAC_HASH_IDX 5
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r318537 - in stable/9/sys/ofed: drivers/net/mlx4 include/linux/mlx4

2017-05-19 Thread Hans Petter Selasky
Author: hselasky
Date: Fri May 19 12:56:18 2017
New Revision: 318537
URL: https://svnweb.freebsd.org/changeset/base/318537

Log:
  MFC r313555:
  Flexible and asymmetric allocation of EQs and MSI-X vectors for PF/VFs.
  
  Previously, the mlx4 driver queried the firmware in order to get the
  number of supported EQs. Under SRIOV, since this was done before the
  driver notified the firmware how many VFs it actually needs, the
  firmware had to take into account a worst case scenario and always
  allocated four EQs per VF, where one was used for events while the
  others were used for completions. Now, when the firmware supports the
  asymmetric allocation scheme, denoted by exposing num_sys_eqs > 0 (-->
  MLX4_DEV_CAP_FLAG2_SYS_EQS), we use the QUERY_FUNC command to query
  the firmware before enabling SRIOV. Thus we can get more EQs and MSI-X
  vectors per function. Moreover, when running in the new
  firmware/driver mode, the limitation that the number of EQs should be
  a power of two is lifted.
  
  Obtained from:Linux (dual BSD/GPLv2 licensed)
  Submitted by: Dexuan Cui @ microsoft . com
  Differential Revision:https://reviews.freebsd.org/D8867
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/eq.c
  stable/9/sys/ofed/drivers/net/mlx4/fw.c
  stable/9/sys/ofed/drivers/net/mlx4/fw.h
  stable/9/sys/ofed/drivers/net/mlx4/main.c
  stable/9/sys/ofed/drivers/net/mlx4/profile.c
  stable/9/sys/ofed/include/linux/mlx4/device.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/eq.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/eq.c Fri May 19 12:53:50 2017
(r318536)
+++ stable/9/sys/ofed/drivers/net/mlx4/eq.c Fri May 19 12:56:18 2017
(r318537)
@@ -1136,8 +1136,12 @@ int mlx4_init_eq_table(struct mlx4_dev *
goto err_out_free;
}
 
-   err = mlx4_bitmap_init(>eq_table.bitmap, dev->caps.num_eqs,
-  dev->caps.num_eqs - 1, dev->caps.reserved_eqs, 
0);
+   err = mlx4_bitmap_init(>eq_table.bitmap,
+   roundup_pow_of_two(dev->caps.num_eqs),
+   dev->caps.num_eqs - 1,
+   dev->caps.reserved_eqs,
+   roundup_pow_of_two(dev->caps.num_eqs) -
+   dev->caps.num_eqs);
if (err)
goto err_out_free;
 

Modified: stable/9/sys/ofed/drivers/net/mlx4/fw.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/fw.c Fri May 19 12:53:50 2017
(r318536)
+++ stable/9/sys/ofed/drivers/net/mlx4/fw.c Fri May 19 12:56:18 2017
(r318537)
@@ -177,6 +177,60 @@ int mlx4_MOD_STAT_CFG(struct mlx4_dev *d
return err;
 }
 
+int mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave)
+{
+   struct mlx4_cmd_mailbox *mailbox;
+   u32 *outbox;
+   u8 in_modifier;
+   u8 field;
+   u16 field16;
+   int err;
+
+#define QUERY_FUNC_BUS_OFFSET  0x00
+#define QUERY_FUNC_DEVICE_OFFSET   0x01
+#define QUERY_FUNC_FUNCTION_OFFSET 0x01
+#define QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET0x03
+#define QUERY_FUNC_RSVD_EQS_OFFSET 0x04
+#define QUERY_FUNC_MAX_EQ_OFFSET   0x06
+#define QUERY_FUNC_RSVD_UARS_OFFSET0x0b
+
+   mailbox = mlx4_alloc_cmd_mailbox(dev);
+   if (IS_ERR(mailbox))
+   return PTR_ERR(mailbox);
+   outbox = mailbox->buf;
+
+   in_modifier = slave;
+
+   err = mlx4_cmd_box(dev, 0, mailbox->dma, in_modifier, 0,
+   MLX4_CMD_QUERY_FUNC,
+   MLX4_CMD_TIME_CLASS_A,
+   MLX4_CMD_NATIVE);
+   if (err)
+   goto out;
+
+   MLX4_GET(field, outbox, QUERY_FUNC_BUS_OFFSET);
+   func->bus = field & 0xf;
+   MLX4_GET(field, outbox, QUERY_FUNC_DEVICE_OFFSET);
+   func->device = field & 0xf1;
+   MLX4_GET(field, outbox, QUERY_FUNC_FUNCTION_OFFSET);
+   func->function = field & 0x7;
+   MLX4_GET(field, outbox, QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET);
+   func->physical_function = field & 0xf;
+   MLX4_GET(field16, outbox, QUERY_FUNC_RSVD_EQS_OFFSET);
+   func->rsvd_eqs = field16 & 0x;
+   MLX4_GET(field16, outbox, QUERY_FUNC_MAX_EQ_OFFSET);
+   func->max_eq = field16 & 0x;
+   MLX4_GET(field, outbox, QUERY_FUNC_RSVD_UARS_OFFSET);
+   func->rsvd_uars = field & 0x0f;
+
+   mlx4_dbg(dev, "Bus: %d, Device: %d, Function: %d, Physical function: 
%d, Max EQs: %d, Reserved EQs: %d, Reserved UARs: %d\n",
+   func->bus, func->device, func->function, 
func->physical_function,
+   func->max_eq, func->rsvd_eqs, func->rsvd_uars);
+out:
+ 

svn commit: r318534 - in stable/9/sys/ofed: drivers/net/mlx4 include/linux/mlx4

2017-05-19 Thread Hans Petter Selasky
Author: hselasky
Date: Fri May 19 12:42:33 2017
New Revision: 318534
URL: https://svnweb.freebsd.org/changeset/base/318534

Log:
  MFC r313556:
  Change mlx4 QP allocation scheme.
  
  When using Blue-Flame, BF, the QPN overrides the VLAN, CV, and SV
  fields in the WQE. Thus, BF may only be used for QPNs with bits 6,7
  unset.
  
  The current ethernet driver code reserves a TX QP range with 256b
  alignment.
  
  This is wrong because if there are more than 64 TX QPs in use, QPNs >=
  base + 65 will have bits 6/7 set.
  
  This problem is not specific for the Ethernet driver, any entity that
  tries to reserve more than 64 BF-enabled QPs should fail. Also, using
  ranges is not necessary here and is wasteful.
  
  The new mechanism introduced here will support reservation for "Eth
  QPs eligible for BF" for all drivers: bare-metal, multi-PF, and VFs
  (when hypervisors support WC in VMs). The flow we use is:
  
  1. In mlx4_en, allocate Tx QPs one by one instead of a range allocation,
 and request "BF enabled QPs" if BF is supported for the function
  
  2. In the ALLOC_RES FW command, change param1 to:
  a. param1[23:0]  - number of QPs
  b. param1[31-24] - flags controlling QPs reservation
  
  Bit 31 refers to Eth blueflame supported QPs. Those QPs must have bits
  6 and 7 unset in order to be used in Ethernet.
  
  Bits 24-30 of the flags are currently reserved.
  
  When a function tries to allocate a QP, it states the required
  attributes for this QP. Those attributes are considered "best-effort".
  If an attribute, such as Ethernet BF enabled QP, is a must-have
  attribute, the function has to check that attribute is supported
  before trying to do the allocation.
  
  In a lower layer of the code, mlx4_qp_reserve_range masks out the bits
  which are unsupported. If SRIOV is used, the PF validates those
  attributes and masks out unsupported attributes as well. In order to
  notify VFs which attributes are supported, the VF uses QUERY_FUNC_CAP
  command. This command's mailbox is filled by the PF, which notifies
  which QP allocation attributes it supports.
  
  Obtained from:Linux (dual BSD/GPLv2 licensed)
  Submitted by: Dexuan Cui @ microsoft . com
  Differential Revision:https://reviews.freebsd.org/D8868
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/fw.c
  stable/9/sys/ofed/drivers/net/mlx4/fw.h
  stable/9/sys/ofed/drivers/net/mlx4/main.c
  stable/9/sys/ofed/drivers/net/mlx4/qp.c
  stable/9/sys/ofed/drivers/net/mlx4/resource_tracker.c
  stable/9/sys/ofed/include/linux/mlx4/device.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/fw.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/fw.c Fri May 19 12:39:35 2017
(r318533)
+++ stable/9/sys/ofed/drivers/net/mlx4/fw.c Fri May 19 12:42:33 2017
(r318534)
@@ -208,10 +208,15 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct m
 #define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET0x64
 #define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET0x68
 
+#define QUERY_FUNC_CAP_EXTRA_FLAGS_OFFSET  0x6c
+
 #define QUERY_FUNC_CAP_FMR_FLAG0x80
 #define QUERY_FUNC_CAP_FLAG_RDMA   0x40
 #define QUERY_FUNC_CAP_FLAG_ETH0x80
 #define QUERY_FUNC_CAP_FLAG_QUOTAS 0x10
+#define QUERY_FUNC_CAP_FLAG_VALID_MAILBOX  0x04
+
+#define QUERY_FUNC_CAP_EXTRA_FLAGS_BF_QP_ALLOC_FLAG(1UL << 31)
 
 /* when opcode modifier = 1 */
 #define QUERY_FUNC_CAP_PHYS_PORT_OFFSET0x3
@@ -264,7 +269,7 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct m
} else if (vhcr->op_modifier == 0) {
/* enable rdma and ethernet interfaces, and new quota locations 
*/
field = (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA |
-QUERY_FUNC_CAP_FLAG_QUOTAS);
+QUERY_FUNC_CAP_FLAG_QUOTAS | 
QUERY_FUNC_CAP_FLAG_VALID_MAILBOX);
MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET);
 
field = dev->caps.num_ports;
@@ -311,6 +316,8 @@ int mlx4_QUERY_FUNC_CAP_wrapper(struct m
MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET);
MLX4_PUT(outbox->buf, size, 
QUERY_FUNC_CAP_MCG_QUOTA_OFFSET_DEP);
 
+   size = QUERY_FUNC_CAP_EXTRA_FLAGS_BF_QP_ALLOC_FLAG;
+   MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_EXTRA_FLAGS_OFFSET);
} else
err = -EINVAL;
 
@@ -400,6 +407,17 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev 
MLX4_GET(size, outbox, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET);
func_cap->reserved_eq = size & 0xFF;
 
+   func_cap->extra_flags = 0;
+
+   /* Mailbox data from 0x6c and onward should only be treated if
+* 

svn commit: r318338 - stable/9/share/man/man4

2017-05-16 Thread Hans Petter Selasky
Author: hselasky
Date: Tue May 16 07:22:41 2017
New Revision: 318338
URL: https://svnweb.freebsd.org/changeset/base/318338

Log:
  MFC r317584:
  Correct manual page link to usbdi(9).

Modified:
  stable/9/share/man/man4/usb.4
Directory Properties:
  stable/9/share/   (props changed)
  stable/9/share/man/   (props changed)
  stable/9/share/man/man4/   (props changed)

Modified: stable/9/share/man/man4/usb.4
==
--- stable/9/share/man/man4/usb.4   Tue May 16 05:10:15 2017
(r318337)
+++ stable/9/share/man/man4/usb.4   Tue May 16 07:22:41 2017
(r318338)
@@ -144,7 +144,7 @@ specifications can be found at:
 .D1 Pa http://www.usb.org/developers/docs/
 .Pp
 .Xr libusb 3 ,
-.Xr usbdi 4 ,
+.Xr usbdi 9 ,
 .Xr aue 4 ,
 .Xr axe 4 ,
 .Xr axge 4 ,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r315269 - in stable/9/sys: kern sys

2017-03-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 14 16:01:36 2017
New Revision: 315269
URL: https://svnweb.freebsd.org/changeset/base/315269

Log:
  MFC r314553:
  
  Implement taskqueue_poll_is_busy() for use by the LinuxKPI.
  Refer to comment above function for a detailed description.
  
  Discussed with:   kib @
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/kern/subr_taskqueue.c
  stable/9/sys/sys/taskqueue.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/kern/subr_taskqueue.c
==
--- stable/9/sys/kern/subr_taskqueue.c  Tue Mar 14 16:00:33 2017
(r315268)
+++ stable/9/sys/kern/subr_taskqueue.c  Tue Mar 14 16:01:36 2017
(r315269)
@@ -356,6 +356,23 @@ task_is_running(struct taskqueue *queue,
return (0);
 }
 
+/*
+ * Only use this function in single threaded contexts. It returns
+ * non-zero if the given task is either pending or running. Else the
+ * task is idle and can be queued again or freed.
+ */
+int
+taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task)
+{
+   int retval;
+
+   TQ_LOCK(queue);
+   retval = task->ta_pending > 0 || task_is_running(queue, task);
+   TQ_UNLOCK(queue);
+
+   return (retval);
+}
+
 static int
 taskqueue_cancel_locked(struct taskqueue *queue, struct task *task,
 u_int *pendp)

Modified: stable/9/sys/sys/taskqueue.h
==
--- stable/9/sys/sys/taskqueue.hTue Mar 14 16:00:33 2017
(r315268)
+++ stable/9/sys/sys/taskqueue.hTue Mar 14 16:01:36 2017
(r315269)
@@ -64,6 +64,7 @@ int   taskqueue_start_threads(struct taskq
 inttaskqueue_enqueue(struct taskqueue *queue, struct task *task);
 inttaskqueue_enqueue_timeout(struct taskqueue *queue,
struct timeout_task *timeout_task, int ticks);
+inttaskqueue_poll_is_busy(struct taskqueue *queue, struct task *task);
 inttaskqueue_cancel(struct taskqueue *queue, struct task *task,
u_int *pendp);
 inttaskqueue_cancel_timeout(struct taskqueue *queue,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r315265 - stable/9/sys/dev/acpica

2017-03-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 14 15:57:21 2017
New Revision: 315265
URL: https://svnweb.freebsd.org/changeset/base/315265

Log:
  MFC r314328:
  
  Fix startup race initialising ACPI CM battery structures on MacBookPro.
  
  During acpi_cmbat_attach() the acpi_cmbat_init_battery() notification
  handler is registered. It has been observed this notification handler
  can be called instantly, before the attach routine has returned. In
  the notification handler there is a call to device_is_attached() which
  returns false. Because the softc is set we know an attach is in
  progress and the fix is simply to wait and try again in this case.
  
  Reviewed by:  avg @

Modified:
  stable/9/sys/dev/acpica/acpi_cmbat.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/acpica/acpi_cmbat.c
==
--- stable/9/sys/dev/acpica/acpi_cmbat.cTue Mar 14 15:56:19 2017
(r315264)
+++ stable/9/sys/dev/acpica/acpi_cmbat.cTue Mar 14 15:57:21 2017
(r315265)
@@ -164,6 +164,16 @@ acpi_cmbat_detach(device_t dev)
 handle = acpi_get_handle(dev);
 AcpiRemoveNotifyHandler(handle, ACPI_ALL_NOTIFY, 
acpi_cmbat_notify_handler);
 acpi_battery_remove(dev);
+
+/*
+ * Force any pending notification handler calls to complete by
+ * requesting cmbat serialisation while freeing and clearing the
+ * softc pointer:
+ */
+ACPI_SERIAL_BEGIN(cmbat);
+device_set_softc(dev, NULL);
+ACPI_SERIAL_END(cmbat);
+
 return (0);
 }
 
@@ -436,7 +446,6 @@ acpi_cmbat_init_battery(void *arg)
 device_t   dev;
 
 dev = (device_t)arg;
-sc = device_get_softc(dev);
 ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
"battery initialization start\n");
 
@@ -446,18 +455,33 @@ acpi_cmbat_init_battery(void *arg)
  * to wait a while.
  */
 for (retry = 0; retry < ACPI_CMBAT_RETRY_MAX; retry++, AcpiOsSleep(1)) 
{
-   /* batteries on DOCK can be ejected w/ DOCK during retrying */
-   if (!device_is_attached(dev))
+   /*
+* Batteries on DOCK can be ejected w/ DOCK during retrying.
+*
+* If there is a valid softc pointer the device may be in
+* attaching, attached or detaching state. If the state is
+* different from attached retry getting the device state
+* until it becomes stable. This solves a race if the ACPI
+* notification handler is called during attach, because
+* device_is_attached() doesn't return non-zero until after
+* the attach code has been executed.
+*/
+   ACPI_SERIAL_BEGIN(cmbat);
+   sc = device_get_softc(dev);
+   if (sc == NULL) {
+   ACPI_SERIAL_END(cmbat);
return;
+   }
 
-   if (!acpi_BatteryIsPresent(dev))
+   if (!acpi_BatteryIsPresent(dev) || !device_is_attached(dev)) {
+   ACPI_SERIAL_END(cmbat);
continue;
+   }
 
/*
 * Only query the battery if this is the first try or the specific
 * type of info is still invalid.
 */
-   ACPI_SERIAL_BEGIN(cmbat);
if (retry == 0 || !acpi_battery_bst_valid(>bst)) {
timespecclear(>bst_lastupdated);
acpi_cmbat_get_bst(dev);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r315258 - stable/9/sys/ofed/drivers/infiniband/hw/mlx4

2017-03-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 14 15:47:17 2017
New Revision: 315258
URL: https://svnweb.freebsd.org/changeset/base/315258

Log:
  MFC r313778:
  
  Improve code readability and fix compilation error when using clang 4.x.
  
  Found by: emaste @
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/infiniband/hw/mlx4/mad.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/hw/mlx4/mad.c
==
--- stable/9/sys/ofed/drivers/infiniband/hw/mlx4/mad.c  Tue Mar 14 15:44:39 
2017(r315257)
+++ stable/9/sys/ofed/drivers/infiniband/hw/mlx4/mad.c  Tue Mar 14 15:47:17 
2017(r315258)
@@ -593,7 +593,7 @@ static int mlx4_ib_demux_mad(struct ib_d
is_eth = 1;
 
if (is_eth) {
-   if (!wc->wc_flags & IB_WC_GRH) {
+   if (!(wc->wc_flags & IB_WC_GRH)) {
mlx4_ib_warn(ibdev, "RoCE grh not present.\n");
return -EINVAL;
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r315253 - stable/9/sys/dev/usb/controller

2017-03-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 14 15:30:46 2017
New Revision: 315253
URL: https://svnweb.freebsd.org/changeset/base/315253

Log:
  MFC r312424:
  
  Fix problem with suspend and resume when using Skylake chipsets. Make
  sure the XHCI controller is reset after halting it. The problem is
  clearly a BIOS bug as the suspend and resume is failing without
  loading the XHCI driver. The same happens when using Linux and the
  XHCI driver is not loaded.
  
  Submitted by: Yanko Yankulov 
  PR:   216261

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
  stable/9/sys/dev/usb/controller/xhci.h
  stable/9/sys/dev/usb/controller/xhci_pci.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Tue Mar 14 15:28:59 2017
(r315252)
+++ stable/9/sys/dev/usb/controller/xhci.c  Tue Mar 14 15:30:46 2017
(r315253)
@@ -341,6 +341,7 @@ xhci_start_controller(struct xhci_softc 
struct usb_page_search buf_res;
struct xhci_hw_root *phwr;
struct xhci_dev_ctx_addr *pdctxa;
+   usb_error_t err;
uint64_t addr;
uint32_t temp;
uint16_t i;
@@ -352,22 +353,9 @@ xhci_start_controller(struct xhci_softc 
sc->sc_command_ccs = 1;
sc->sc_command_idx = 0;
 
-   /* Reset controller */
-   XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_HCRST);
-
-   for (i = 0; i != 100; i++) {
-   usb_pause_mtx(NULL, hz / 100);
-   temp = (XREAD4(sc, oper, XHCI_USBCMD) & XHCI_CMD_HCRST) |
-   (XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_CNR);
-   if (!temp)
-   break;
-   }
-
-   if (temp) {
-   device_printf(sc->sc_bus.parent, "Controller "
-   "reset timeout.\n");
-   return (USB_ERR_IOERROR);
-   }
+   err = xhci_reset_controller(sc);
+   if (err)
+   return (err);
 
/* set up number of device slots */
DPRINTF("CONFIG=0x%08x -> 0x%08x\n",
@@ -515,6 +503,33 @@ xhci_halt_controller(struct xhci_softc *
 }
 
 usb_error_t
+xhci_reset_controller(struct xhci_softc *sc)
+{
+   uint32_t temp = 0;
+   uint16_t i;
+
+   DPRINTF("\n");
+
+   /* Reset controller */
+   XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_HCRST);
+
+   for (i = 0; i != 100; i++) {
+   usb_pause_mtx(NULL, hz / 100);
+   temp = (XREAD4(sc, oper, XHCI_USBCMD) & XHCI_CMD_HCRST) |
+   (XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_CNR);
+   if (!temp)
+   break;
+   }
+
+   if (temp) {
+   device_printf(sc->sc_bus.parent, "Controller "
+   "reset timeout.\n");
+   return (USB_ERR_IOERROR);
+   }
+   return (0);
+}
+
+usb_error_t
 xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32)
 {
uint32_t temp;
@@ -666,10 +681,12 @@ xhci_set_hw_power_sleep(struct usb_bus *
case USB_HW_POWER_SUSPEND:
DPRINTF("Stopping the XHCI\n");
xhci_halt_controller(sc);
+   xhci_reset_controller(sc);
break;
case USB_HW_POWER_SHUTDOWN:
DPRINTF("Stopping the XHCI\n");
xhci_halt_controller(sc);
+   xhci_reset_controller(sc);
break;
case USB_HW_POWER_RESUME:
DPRINTF("Starting the XHCI\n");

Modified: stable/9/sys/dev/usb/controller/xhci.h
==
--- stable/9/sys/dev/usb/controller/xhci.h  Tue Mar 14 15:28:59 2017
(r315252)
+++ stable/9/sys/dev/usb/controller/xhci.h  Tue Mar 14 15:30:46 2017
(r315253)
@@ -515,6 +515,7 @@ struct xhci_softc {
 
 uint8_txhci_use_polling(void);
 usb_error_t xhci_halt_controller(struct xhci_softc *);
+usb_error_t xhci_reset_controller(struct xhci_softc *);
 usb_error_t xhci_init(struct xhci_softc *, device_t, uint8_t);
 usb_error_t xhci_start_controller(struct xhci_softc *);
 void   xhci_interrupt(struct xhci_softc *);

Modified: stable/9/sys/dev/usb/controller/xhci_pci.c
==
--- stable/9/sys/dev/usb/controller/xhci_pci.c  Tue Mar 14 15:28:59 2017
(r315252)
+++ stable/9/sys/dev/usb/controller/xhci_pci.c  Tue Mar 14 15:30:46 2017
(r315253)
@@ -317,6 +317,7 @@ xhci_pci_detach(device_t self)
 
usb_callout_drain(>sc_callout);
xhci_halt_controller(sc);
+   xhci_reset_controller(sc);
 
pci_disable_busmaster(self);
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to 

svn commit: r315250 - in stable/9: share/man/man4 sys/dev/sound/usb sys/dev/usb sys/dev/usb/quirk

2017-03-14 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Mar 14 15:25:49 2017
New Revision: 315250
URL: https://svnweb.freebsd.org/changeset/base/315250

Log:
  MFC r312338:
  
  Add USB audio support for S/PDIF output with C-Media CM6206 devices.
  
  Submitted by: Julien Nadeau 
  PR:   216131

Modified:
  stable/9/share/man/man4/usb_quirk.4
  stable/9/sys/dev/sound/usb/uaudio.c
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/quirk/usb_quirk.h
  stable/9/sys/dev/usb/usbdevs
Directory Properties:
  stable/9/share/   (props changed)
  stable/9/share/man/   (props changed)
  stable/9/share/man/man4/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/share/man/man4/usb_quirk.4
==
--- stable/9/share/man/man4/usb_quirk.4 Tue Mar 14 15:21:41 2017
(r315249)
+++ stable/9/share/man/man4/usb_quirk.4 Tue Mar 14 15:25:49 2017
(r315250)
@@ -16,7 +16,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 26, 2015
+.Dd January 17, 2017
 .Dt USB_QUIRK 4
 .Os
 .Sh NAME
@@ -52,6 +52,10 @@ input is async despite claim of adaptive
 do not adjust for fractional samples
 .It UQ_AU_NO_XU
 audio device has broken extension unit
+.It UQ_AU_VENDOR_CLASS
+audio device uses vendor class to identify itself
+.It UQ_AU_SET_SPDIF_CM6206
+audio device needs special programming to enable S/PDIF audio output
 .It UQ_BAD_ADC
 bad audio spec version number
 .It UQ_BAD_AUDIO

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==
--- stable/9/sys/dev/sound/usb/uaudio.c Tue Mar 14 15:21:41 2017
(r315249)
+++ stable/9/sys/dev/sound/usb/uaudio.c Tue Mar 14 15:25:49 2017
(r315250)
@@ -317,6 +317,11 @@ struct uaudio_hid {
uint8_t mute_id;
 };
 
+#defineUAUDIO_SPDIF_OUT0x01/* Enable S/PDIF output */
+#defineUAUDIO_SPDIF_OUT_48K0x02/* Out sample rate = 48K */
+#defineUAUDIO_SPDIF_OUT_96K0x04/* Out sample rate = 96K */
+#defineUAUDIO_SPDIF_IN_MIX 0x10/* Input mix enable */
+
 struct uaudio_softc {
struct sbuf sc_sndstat;
struct sndcard_func sc_sndcard_func;
@@ -334,6 +339,7 @@ struct uaudio_softc {
struct usb_xfer *sc_mixer_xfer[1];
struct uaudio_mixer_node *sc_mixer_root;
struct uaudio_mixer_node *sc_mixer_curr;
+   int (*sc_set_spdif_fn) (struct uaudio_softc *, int);
 
uint32_t sc_mix_info;
uint32_t sc_recsrc_info;
@@ -864,6 +870,46 @@ uaudio_probe(device_t dev)
return (ENXIO);
 }
 
+/*
+ * Set Cmedia CM6206 S/PDIF settings
+ * Source: CM6206 Datasheet v2.3.
+ */
+static int
+uaudio_set_spdif_cm6206(struct uaudio_softc *sc, int flags)
+{
+   uint8_t cmd[2][4] = {
+   {0x20, 0x20, 0x00, 0},
+   {0x20, 0x30, 0x02, 1}
+   };
+   int i;
+
+   if (flags & UAUDIO_SPDIF_OUT)
+   cmd[1][1] = 0x00;
+   else
+   cmd[1][1] = 0x02;
+
+   if (flags & UAUDIO_SPDIF_OUT_96K)
+   cmd[0][1] = 0x60;   /* 96K: 3'b110 */
+
+   if (flags & UAUDIO_SPDIF_IN_MIX)
+   cmd[1][1] = 0x03;   /* SPDIFMIX */
+
+   for (i = 0; i < 2; i++) {
+   if (usbd_req_set_report(sc->sc_udev, NULL,
+   cmd[i], sizeof(cmd[0]),
+   sc->sc_mixer_iface_index, UHID_OUTPUT_REPORT, 0) != 0) {
+   return (ENXIO);
+   }
+   }
+   return (0);
+}
+
+static int
+uaudio_set_spdif_dummy(struct uaudio_softc *sc, int flags)
+{
+   return (0);
+}
+
 static int
 uaudio_attach(device_t dev)
 {
@@ -898,6 +944,12 @@ uaudio_attach(device_t dev)
if (usb_test_quirk(uaa, UQ_AU_VENDOR_CLASS))
sc->sc_uq_au_vendor_class = 1;
 
+   /* set S/PDIF function */
+   if (usb_test_quirk(uaa, UQ_AU_SET_SPDIF_CM6206))
+   sc->sc_set_spdif_fn = uaudio_set_spdif_cm6206;
+   else
+   sc->sc_set_spdif_fn = uaudio_set_spdif_dummy;
+
umidi_init(dev);
 
device_set_usb_desc(dev);
@@ -1034,6 +1086,11 @@ uaudio_attach(device_t dev)
/* reload all mixer settings */
uaudio_mixer_reload_all(sc);
 
+   /* enable S/PDIF output, if any */
+   if (sc->sc_set_spdif_fn(sc,
+   UAUDIO_SPDIF_OUT | UAUDIO_SPDIF_OUT_48K) != 0) {
+   device_printf(dev, "Failed to enable S/PDIF at 48K\n");
+   }
return (0); /* success */
 
 detach:
@@ -1114,6 +1171,9 @@ uaudio_detach_sub(device_t dev)
struct uaudio_softc *sc = device_get_softc(device_get_parent(dev));
int error = 0;
 
+   /* disable S/PDIF output, if any */
+   (void) sc->sc_set_spdif_fn(sc, 0);
+
 repeat:
if (sc->sc_pcm_registered) {
error = pcm_unregister(dev);

Modified: stable/9/sys/dev/usb/quirk/usb_quirk.c

svn commit: r311796 - stable/9/sys/ofed/drivers/net/mlx4

2017-01-09 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jan  9 17:09:53 2017
New Revision: 311796
URL: https://svnweb.freebsd.org/changeset/base/311796

Log:
  MFC r310058:
  Fix initialisation of mlx4_pci_table's .driver_data fields.
  
  Differential Revision:https://reviews.freebsd.org/D8791
  Sponsored by: Mellanox Technologies
  Submitted by: Dexuan Cui 

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/main.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/main.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon Jan  9 17:07:52 2017
(r311795)
+++ stable/9/sys/ofed/drivers/net/mlx4/main.c   Mon Jan  9 17:09:53 2017
(r311796)
@@ -3637,47 +3637,61 @@ int mlx4_restart_one(struct pci_dev *pde
 
 static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
/* MT25408 "Hermon" SDR */
-   { PCI_VDEVICE(MELLANOX, 0x6340), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6340),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" DDR */
-   { PCI_VDEVICE(MELLANOX, 0x634a), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x634a),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" QDR */
-   { PCI_VDEVICE(MELLANOX, 0x6354), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6354),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" DDR PCIe gen2 */
-   { PCI_VDEVICE(MELLANOX, 0x6732), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6732),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" QDR PCIe gen2 */
-   { PCI_VDEVICE(MELLANOX, 0x673c), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x673c),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" EN 10GigE */
-   { PCI_VDEVICE(MELLANOX, 0x6368), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6368),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25408 "Hermon" EN 10GigE PCIe gen2 */
-   { PCI_VDEVICE(MELLANOX, 0x6750), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6750),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25458 ConnectX EN 10GBASE-T 10GigE */
-   { PCI_VDEVICE(MELLANOX, 0x6372), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6372),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */
-   { PCI_VDEVICE(MELLANOX, 0x675a), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x675a),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT26468 ConnectX EN 10GigE PCIe gen2*/
-   { PCI_VDEVICE(MELLANOX, 0x6764), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6764),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */
-   { PCI_VDEVICE(MELLANOX, 0x6746), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x6746),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT26478 ConnectX2 40GigE PCIe gen2 */
-   { PCI_VDEVICE(MELLANOX, 0x676e), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+   { PCI_VDEVICE(MELLANOX, 0x676e),
+   .driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
/* MT25400 Family [ConnectX-2 Virtual Function] */
-   { PCI_VDEVICE(MELLANOX, 0x1002), MLX4_PCI_DEV_IS_VF },
+   { PCI_VDEVICE(MELLANOX, 0x1002),
+   .driver_data = MLX4_PCI_DEV_IS_VF },
/* MT27500 Family [ConnectX-3] */
-   { PCI_VDEVICE(MELLANOX, 0x1003), 0 },
+   { PCI_VDEVICE(MELLANOX, 0x1003) },
/* MT27500 Family [ConnectX-3 Virtual Function] */
-   { PCI_VDEVICE(MELLANOX, 0x1004), MLX4_PCI_DEV_IS_VF },
-   { PCI_VDEVICE(MELLANOX, 0x1005), 0 }, /* MT27510 Family */
-   { PCI_VDEVICE(MELLANOX, 0x1006), 0 }, /* MT27511 Family */
-   { PCI_VDEVICE(MELLANOX, 0x1007), 0 }, /* MT27520 Family */
-   { PCI_VDEVICE(MELLANOX, 0x1008), 0 }, /* MT27521 Family */
-   { PCI_VDEVICE(MELLANOX, 0x1009), 0 }, /* MT27530 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100a), 0 }, /* MT27531 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100b), 0 }, /* MT27540 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100c), 0 }, /* MT27541 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100d), 0 }, /* MT27550 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100e), 0 }, /* MT27551 Family */
-   { PCI_VDEVICE(MELLANOX, 0x100f), 0 }, /* MT27560 Family */
-   { PCI_VDEVICE(MELLANOX, 0x1010), 0 }, /* MT27561 Family */
+   { PCI_VDEVICE(MELLANOX, 0x1004),
+   .driver_data = MLX4_PCI_DEV_IS_VF },
+   { 

svn commit: r310255 - stable/9/sys/dev/acpica

2016-12-19 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Dec 19 09:54:59 2016
New Revision: 310255
URL: https://svnweb.freebsd.org/changeset/base/310255

Log:
  MFC r309400:
  Fix for endless recursion in the ACPI GPE handler during boot.
  
  When handling a GPE ACPI interrupt object the EcSpaceHandler()
  function can be called which checks the EC_EVENT_SCI bit and then
  recurse on the EcGpeQueryHandler() function. If there are multiple GPE
  events pending the EC_EVENT_SCI bit will be set at the next call to
  EcSpaceHandler() causing it to recurse again via the
  EcGpeQueryHandler() function. This leads to a slow never ending
  recursion during boot which prevents proper system startup, because
  the EC_EVENT_SCI bit never gets cleared in this scenario.
  
  The behaviour is reproducible with the ALASKA AMI in combination with
  a newer Skylake based mainboard in the following way:
  
  Enter BIOS and adjust the clock one hour forward. Save and exit the
  BIOS. System fails to boot due to the above mentioned bug in
  EcGpeQueryHandler() which was observed recursing multiple times.
  
  This patch adds a simple recursion guard to the EcGpeQueryHandler()
  function and also also adds logic to detect if new GPE events occurred
  during the execution of EcGpeQueryHandler() and then loop on this
  function instead of recursing.
  
  Reviewed by:  jhb

Modified:
  stable/9/sys/dev/acpica/acpi_ec.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/acpica/acpi_ec.c
==
--- stable/9/sys/dev/acpica/acpi_ec.c   Mon Dec 19 09:52:32 2016
(r310254)
+++ stable/9/sys/dev/acpica/acpi_ec.c   Mon Dec 19 09:54:59 2016
(r310255)
@@ -618,16 +618,14 @@ EcCheckStatus(struct acpi_ec_softc *sc, 
 }
 
 static void
-EcGpeQueryHandler(void *Context)
+EcGpeQueryHandlerSub(struct acpi_ec_softc *sc)
 {
-struct acpi_ec_softc   *sc = (struct acpi_ec_softc *)Context;
 UINT8  Data;
 ACPI_STATUSStatus;
 intretry;
 char   qxx[5];
 
 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
-KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
 
 /* Serialize user access with EcSpaceHandler(). */
 Status = EcLock(sc);
@@ -654,7 +652,6 @@ EcGpeQueryHandler(void *Context)
else
break;
 }
-sc->ec_sci_pend = FALSE;
 if (ACPI_FAILURE(Status)) {
EcUnlock(sc);
device_printf(sc->ec_dev, "GPE query failed: %s\n",
@@ -685,6 +682,29 @@ EcGpeQueryHandler(void *Context)
 }
 }
 
+static void
+EcGpeQueryHandler(void *Context)
+{
+struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
+int pending;
+
+KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
+
+do {
+   /* Read the current pending count */
+   pending = atomic_load_acq_int(>ec_sci_pend);
+
+   /* Call GPE handler function */
+   EcGpeQueryHandlerSub(sc);
+
+   /*
+* Try to reset the pending count to zero. If this fails we
+* know another GPE event has occurred while handling the
+* current GPE event and need to loop.
+*/
+} while (!atomic_cmpset_int(>ec_sci_pend, pending, 0));
+}
+
 /*
  * The GPE handler is called when IBE/OBF or SCI events occur.  We are
  * called from an unknown lock context.
@@ -713,13 +733,14 @@ EcGpeHandler(ACPI_HANDLE GpeDevice, UINT
  * It will run the query and _Qxx method later, under the lock.
  */
 EcStatus = EC_GET_CSR(sc);
-if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
+if ((EcStatus & EC_EVENT_SCI) &&
+   atomic_fetchadd_int(>ec_sci_pend, 1) == 0) {
CTR0(KTR_ACPI, "ec gpe queueing query handler");
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
-   if (ACPI_SUCCESS(Status))
-   sc->ec_sci_pend = TRUE;
-   else
+   if (ACPI_FAILURE(Status)) {
printf("EcGpeHandler: queuing GPE query handler failed\n");
+   atomic_store_rel_int(>ec_sci_pend, 0);
+   }
 }
 return (ACPI_REENABLE_GPE);
 }
@@ -766,7 +787,8 @@ EcSpaceHandler(UINT32 Function, ACPI_PHY
  * we call it directly here since our thread taskq is not active yet.
  */
 if (cold || rebooting || sc->ec_suspending) {
-   if ((EC_GET_CSR(sc) & EC_EVENT_SCI)) {
+   if ((EC_GET_CSR(sc) & EC_EVENT_SCI) &&
+   atomic_fetchadd_int(>ec_sci_pend, 1) == 0) {
CTR0(KTR_ACPI, "ec running gpe handler directly");
EcGpeQueryHandler(sc);
}
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r308573 - stable/9/sys/dev/sound/usb

2016-11-12 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Nov 12 17:32:22 2016
New Revision: 308573
URL: https://svnweb.freebsd.org/changeset/base/308573

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.
  
  Allow higher sample rates to have more jitter than lower ones.
  
  PR:   208791

Modified:
  stable/9/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==
--- stable/9/sys/dev/sound/usb/uaudio.c Sat Nov 12 17:30:55 2016
(r308572)
+++ stable/9/sys/dev/sound/usb/uaudio.c Sat Nov 12 17:32:22 2016
(r308573)
@@ -2047,9 +2047,23 @@ uaudio_chan_play_sync_callback(struct us
 * Use feedback value as fallback when there is no
 * recording channel:
 */
-   if (ch->priv_sc->sc_rec_chan.num_alt == 0)
-   ch->jitter_curr = temp - sample_rate;
+   if (ch->priv_sc->sc_rec_chan.num_alt == 0) {
+   int32_t jitter_max = howmany(sample_rate, 16000);
 
+   /*
+* Range check the jitter values to avoid
+* bogus sample rate adjustments. The expected
+* deviation should not be more than 1Hz per
+* second. The USB v2.0 specification also
+* mandates this requirement. Refer to chapter
+* 5.12.4.2 about feedback.
+*/
+   ch->jitter_curr = temp - sample_rate;
+   if (ch->jitter_curr > jitter_max)
+   ch->jitter_curr = jitter_max;
+   else if (ch->jitter_curr < -jitter_max)
+   ch->jitter_curr = -jitter_max;
+   }
ch->feedback_rate = temp;
break;
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r308403 - in stable/9/sys: dev/puc dev/usb dev/usb/controller kern mips/atheros mips/cavium/usb mips/rmi mips/rt305x

2016-11-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Nov  7 09:23:07 2016
New Revision: 308403
URL: https://svnweb.freebsd.org/changeset/base/308403

Log:
  MFC r307518:
  Fix device delete child function.
  
  When detaching device trees parent devices must be detached prior to
  detaching its children. This is because parent devices can have
  pointers to the child devices in their softcs which are not
  invalidated by device_delete_child(). This can cause use after free
  issues and panic().
  
  Device drivers implementing trees, must ensure its detach function
  detaches or deletes all its children before returning.
  
  While at it remove now redundant device_detach() calls before
  device_delete_child() and device_delete_children(), mostly in
  the USB controller drivers.
  
  Tested by:Jan Henrik Sylvester 
  Reviewed by:  jhb
  Differential Revision:https://reviews.freebsd.org/D8070

Modified:
  stable/9/sys/dev/puc/puc.c
  stable/9/sys/dev/usb/controller/at91dci_atmelarm.c
  stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c
  stable/9/sys/dev/usb/controller/ehci_ixp4xx.c
  stable/9/sys/dev/usb/controller/ehci_mv.c
  stable/9/sys/dev/usb/controller/ehci_pci.c
  stable/9/sys/dev/usb/controller/musb_otg_atmelarm.c
  stable/9/sys/dev/usb/controller/ohci_pci.c
  stable/9/sys/dev/usb/controller/ohci_s3c24x0.c
  stable/9/sys/dev/usb/controller/uhci_pci.c
  stable/9/sys/dev/usb/controller/uss820dci_atmelarm.c
  stable/9/sys/dev/usb/controller/xhci_pci.c
  stable/9/sys/dev/usb/usb_device.c
  stable/9/sys/kern/subr_bus.c
  stable/9/sys/mips/atheros/ar71xx_ehci.c
  stable/9/sys/mips/atheros/ar71xx_ohci.c
  stable/9/sys/mips/cavium/usb/octusb_octeon.c
  stable/9/sys/mips/rmi/xls_ehci.c
  stable/9/sys/mips/rt305x/rt305x_dotg.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/dev/puc/   (props changed)

Modified: stable/9/sys/dev/puc/puc.c
==
--- stable/9/sys/dev/puc/puc.c  Mon Nov  7 09:19:04 2016(r308402)
+++ stable/9/sys/dev/puc/puc.c  Mon Nov  7 09:23:07 2016(r308403)
@@ -412,8 +412,7 @@ puc_bfe_detach(device_t dev)
port = >sc_port[idx];
if (port->p_dev == NULL)
continue;
-   if (device_detach(port->p_dev) == 0) {
-   device_delete_child(dev, port->p_dev);
+   if (device_delete_child(dev, port->p_dev) == 0) {
if (port->p_rres != NULL)
rman_release_resource(port->p_rres);
if (port->p_ires != NULL)

Modified: stable/9/sys/dev/usb/controller/at91dci_atmelarm.c
==
--- stable/9/sys/dev/usb/controller/at91dci_atmelarm.c  Mon Nov  7 09:19:04 
2016(r308402)
+++ stable/9/sys/dev/usb/controller/at91dci_atmelarm.c  Mon Nov  7 09:23:07 
2016(r308403)
@@ -262,14 +262,8 @@ static int
 at91_udp_detach(device_t dev)
 {
struct at91_udp_softc *sc = device_get_softc(dev);
-   device_t bdev;
int err;
 
-   if (sc->sc_dci.sc_bus.bdev) {
-   bdev = sc->sc_dci.sc_bus.bdev;
-   device_detach(bdev);
-   device_delete_child(dev, bdev);
-   }
/* during module unload there are lots of children leftover */
device_delete_children(dev);
 

Modified: stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c
==
--- stable/9/sys/dev/usb/controller/atmegadci_atmelarm.cMon Nov  7 
09:19:04 2016(r308402)
+++ stable/9/sys/dev/usb/controller/atmegadci_atmelarm.cMon Nov  7 
09:23:07 2016(r308403)
@@ -155,14 +155,8 @@ static int
 atmegadci_detach(device_t dev)
 {
struct atmegadci_super_softc *sc = device_get_softc(dev);
-   device_t bdev;
int err;
 
-   if (sc->sc_otg.sc_bus.bdev) {
-   bdev = sc->sc_otg.sc_bus.bdev;
-   device_detach(bdev);
-   device_delete_child(dev, bdev);
-   }
/* during module unload there are lots of children leftover */
device_delete_children(dev);
 

Modified: stable/9/sys/dev/usb/controller/ehci_ixp4xx.c
==
--- stable/9/sys/dev/usb/controller/ehci_ixp4xx.c   Mon Nov  7 09:19:04 
2016(r308402)
+++ stable/9/sys/dev/usb/controller/ehci_ixp4xx.c   Mon Nov  7 09:23:07 
2016(r308403)
@@ -207,14 +207,8 @@ ehci_ixp_detach(device_t self)
 {
struct ixp_ehci_softc *isc = device_get_softc(self);
ehci_softc_t *sc = >base;
-   device_t bdev;
int err;
 
-   if (sc->sc_bus.bdev) {
-   bdev = sc->sc_bus.bdev;
-   device_detach(bdev);
-   device_delete_child(self, bdev);
-   

svn commit: r308400 - stable/9/sys/ofed/drivers/net/mlx4

2016-11-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Nov  7 08:26:19 2016
New Revision: 308400
URL: https://svnweb.freebsd.org/changeset/base/308400

Log:
  MFC r308031:
  Fix indentation and remove duplicate queue stopped stats increment.
  
  Found by: Ryan Stone 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Mon Nov  7 08:24:29 2016
(r308399)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Mon Nov  7 08:26:19 2016
(r308400)
@@ -703,20 +703,19 @@ static int mlx4_en_xmit(struct mlx4_en_p
 
/* check if TX ring is full */
if (unlikely(mlx4_en_tx_ring_is_full(ring))) {
-   /* every full native Tx ring stops queue */
-   if (ring->blocked == 0)
-   atomic_add_int(>blocked, 1);
-   /* Set HW-queue-is-full flag */
-   atomic_set_int(>if_drv_flags, IFF_DRV_OACTIVE);
-   priv->port_stats.queue_stopped++;
-   ring->blocked = 1;
+   /* every full native Tx ring stops queue */
+   if (ring->blocked == 0)
+   atomic_add_int(>blocked, 1);
+   /* Set HW-queue-is-full flag */
+   atomic_set_int(>if_drv_flags, IFF_DRV_OACTIVE);
priv->port_stats.queue_stopped++;
+   ring->blocked = 1;
ring->queue_stopped++;
 
/* Use interrupts to find out when queue opened */
mlx4_en_arm_cq(priv, priv->tx_cq[tx_ind]);
return (ENOBUFS);
-}
+   }
 
/* sanity check we are not wrapping around */
KASSERT(((~ring->prod) & ring->size_mask) >=
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r308396 - stable/9/sys/dev/usb/input

2016-11-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Nov  7 08:17:23 2016
New Revision: 308396
URL: https://svnweb.freebsd.org/changeset/base/308396

Log:
  MFC r308144 and r308165:
  Fixes for virtual T-axis buttons.
  
  Make sure the virtual T-axis buttons gets cleared for USB mice which has
  less than 6 buttons.
  
  Make sure the virtual T-axis buttons generate button release event(s)
  for continuous tilting.
  
  PR:   213919
  PR:   213957

Modified:
  stable/9/sys/dev/usb/input/ums.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/input/ums.c
==
--- stable/9/sys/dev/usb/input/ums.cMon Nov  7 08:15:58 2016
(r308395)
+++ stable/9/sys/dev/usb/input/ums.cMon Nov  7 08:17:23 2016
(r308396)
@@ -258,8 +258,11 @@ ums_intr_callback(struct usb_xfer *xfer,
}
 
if ((info->sc_flags & UMS_FLAG_T_AXIS) &&
-   (id == info->sc_iid_t))
+   (id == info->sc_iid_t)) {
dt -= hid_get_data(buf, len, >sc_loc_t);
+   /* T-axis is translated into button presses */
+   buttons_found |= (1UL << 5) | (1UL << 6);
+   }
 
for (i = 0; i < info->sc_buttons; i++) {
uint32_t mask;
@@ -287,10 +290,13 @@ ums_intr_callback(struct usb_xfer *xfer,
dx, dy, dz, dt, dw, buttons);
 
/* translate T-axis into button presses until further */
-   if (dt > 0)
+   if (dt > 0) {
+   ums_put_queue(sc, 0, 0, 0, 0, buttons);
buttons |= 1UL << 5;
-   else if (dt < 0)
+   } else if (dt < 0) {
+   ums_put_queue(sc, 0, 0, 0, 0, buttons);
buttons |= 1UL << 6;
+   }
 
sc->sc_status.button = buttons;
sc->sc_status.dx += dx;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r306958 - in stable/9/sys/dev/usb: . serial

2016-10-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 10 11:48:23 2016
New Revision: 306958
URL: https://svnweb.freebsd.org/changeset/base/306958

Log:
  MFC r306478:
  Add new USB ID.
  
  While at it remove some whitespaces.
  
  Submitted by: Jose Luis Duran 
  PR:   213110

Modified:
  stable/9/sys/dev/usb/serial/u3g.c
  stable/9/sys/dev/usb/usbdevs
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/serial/u3g.c
==
--- stable/9/sys/dev/usb/serial/u3g.c   Mon Oct 10 11:47:29 2016
(r306957)
+++ stable/9/sys/dev/usb/serial/u3g.c   Mon Oct 10 11:48:23 2016
(r306958)
@@ -523,6 +523,7 @@ static const STRUCT_USB_HOST_ID u3g_devs
U3G_DEV(SIERRA, MC5727, 0),
U3G_DEV(SIERRA, MC5727_2, 0),
U3G_DEV(SIERRA, MC5728, 0),
+   U3G_DEV(SIERRA, MC7430, 0),
U3G_DEV(SIERRA, MC8700, 0),
U3G_DEV(SIERRA, MC8755, 0),
U3G_DEV(SIERRA, MC8755_2, 0),
@@ -626,7 +627,7 @@ u3g_sael_m460_init(struct usb_device *ud
static const uint8_t setup[][24] = {
 { 0x41, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
 { 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 },
-{ 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 
+{ 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
 { 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02 },
@@ -638,7 +639,7 @@ u3g_sael_m460_init(struct usb_device *ud
 { 0x41, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 },
 { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x11, 0x13 },
-{ 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 
+{ 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
   0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
   0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 },
 { 0x41, 0x12, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -648,7 +649,7 @@ u3g_sael_m460_init(struct usb_device *ud
 { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x11, 0x13 },
 { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 
+  0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
   0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 },
 { 0x41, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 },
};
@@ -682,7 +683,7 @@ u3g_sael_m460_init(struct usb_device *ud
DPRINTFN(0, "too small buffer\n");
continue;
}
-   err = usbd_do_request(udev, NULL, , 
+   err = usbd_do_request(udev, NULL, ,
__DECONST(uint8_t *, [n][8]));
}
if (err) {
@@ -857,7 +858,7 @@ u3g_attach(device_t dev)
}
 
/* copy in USB config */
-   for (n = 0; n != U3G_N_TRANSFER; n++) 
+   for (n = 0; n != U3G_N_TRANSFER; n++)
u3g_config_tmp[n] = u3g_config[n];
 
device_set_usb_desc(dev);

Modified: stable/9/sys/dev/usb/usbdevs
==
--- stable/9/sys/dev/usb/usbdevsMon Oct 10 11:47:29 2016
(r306957)
+++ stable/9/sys/dev/usb/usbdevsMon Oct 10 11:48:23 2016
(r306958)
@@ -4078,6 +4078,7 @@ product SIERRA E6893  0x6893  E6893
 product SIERRA MC8700  0x68A3  MC8700
 product SIERRA MC7354  0x68C0  MC7354
 product SIERRA MC7355  0x9041  MC7355
+product SIERRA MC7430  0x9071  Sierra Wireless MC7430 Qualcomm 
Snapdragon X7 LTE-A
 product SIERRA AC313U  0x68aa  Sierra Wireless AirCard 313U
 product SIERRA TRUINSTALL  0x0fff  Aircard Tru Installer
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r306951 - stable/9/sys/ofed/include/linux

2016-10-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Oct 10 11:36:43 2016
New Revision: 306951
URL: https://svnweb.freebsd.org/changeset/base/306951

Log:
  MFC r306451:
  The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX
  are not bitmasks. Fix return value of pci_resource_flags() to reflect
  this change.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/linux/pci.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/pci.h
==
--- stable/9/sys/ofed/include/linux/pci.h   Mon Oct 10 11:34:51 2016
(r306950)
+++ stable/9/sys/ofed/include/linux/pci.h   Mon Oct 10 11:36:43 2016
(r306951)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -115,9 +115,9 @@ struct pci_device_id {
 #definePCI_EXP_TYPE_RC_EC  PCIEM_TYPE_ROOT_EC  /* Root 
Complex Event Collector */
 
 
-#defineIORESOURCE_MEM  SYS_RES_MEMORY
-#defineIORESOURCE_IO   SYS_RES_IOPORT
-#defineIORESOURCE_IRQ  SYS_RES_IRQ
+#defineIORESOURCE_MEM  (1 << SYS_RES_MEMORY)
+#defineIORESOURCE_IO   (1 << SYS_RES_IOPORT)
+#defineIORESOURCE_IRQ  (1 << SYS_RES_IRQ)
 
 struct pci_dev;
 
@@ -213,17 +213,28 @@ pci_resource_len(struct pci_dev *pdev, i
return rle->count;
 }
 
+static inline int
+pci_resource_type(struct pci_dev *pdev, int bar)
+{
+   struct resource_list_entry *rle;
+
+   if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+   return (-1);
+   return (rle->type);
+}
+
 /*
  * All drivers just seem to want to inspect the type not flags.
  */
 static inline int
 pci_resource_flags(struct pci_dev *pdev, int bar)
 {
-   struct resource_list_entry *rle;
+   int type;
 
-   if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+   type = pci_resource_type(pdev, bar);
+   if (type < 0)
return (0);
-   return rle->type;
+   return (1 << type);
 }
 
 static inline const char *
@@ -283,8 +294,8 @@ pci_request_region(struct pci_dev *pdev,
int rid;
int type;
 
-   type = pci_resource_flags(pdev, bar);
-   if (type == 0)
+   type = pci_resource_type(pdev, bar);
+   if (type < 0)
return (-ENODEV);
rid = PCIR_BAR(bar);
if (bus_alloc_resource_any(pdev->dev.bsddev, type, ,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r305830 - stable/9/sys/dev/usb/input

2016-09-15 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Sep 15 08:37:20 2016
New Revision: 305830
URL: https://svnweb.freebsd.org/changeset/base/305830

Log:
  MFC r305590:
  Correctly map the USB mouse tilt delta values into buttons 5 and 6
  instead of 3 and 4 which is used for the scroll wheel, according to
  X.org.
  
  PR:   170358

Modified:
  stable/9/sys/dev/usb/input/ums.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/input/ums.c
==
--- stable/9/sys/dev/usb/input/ums.cThu Sep 15 08:35:46 2016
(r305829)
+++ stable/9/sys/dev/usb/input/ums.cThu Sep 15 08:37:20 2016
(r305830)
@@ -288,9 +288,9 @@ ums_intr_callback(struct usb_xfer *xfer,
 
/* translate T-axis into button presses until further */
if (dt > 0)
-   buttons |= 1UL << 3;
+   buttons |= 1UL << 5;
else if (dt < 0)
-   buttons |= 1UL << 4;
+   buttons |= 1UL << 6;
 
sc->sc_status.button = buttons;
sc->sc_status.dx += dx;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r305735 - in stable/9/sys: dev/usb dev/usb/template sys

2016-09-12 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Sep 12 10:20:44 2016
New Revision: 305735
URL: https://svnweb.freebsd.org/changeset/base/305735

Log:
  MFC r305421:
  Resolve deadlock between device_detach() and usbd_do_request_flags()
  by reviving the SX control request lock and refining which lock
  protects the common scratch area in "struct usb_device".
  
  The SX control request lock was removed by r246759 because it caused a
  lock order reversal with the USB enumeration lock inside
  usbd_transfer_setup() as a function of r246616. It was thought that
  reducing the number of locks would resolve the LOR, but because some
  USB device drivers use usbd_do_request_flags() inside callback
  functions, like in taskqueues, a deadlock may occur when these are
  drained from device_detach(). By restoring the SX control request
  lock usbd_do_request_flags() is allowed to complete its execution
  when a USB device driver is detaching. By using the SX control request
  lock to protect the scratch area, the LOR introduced by r246616 is
  also resolved.
  
  Bump the FreeBSD version while at it to force recompilation of all USB
  kernel modules.
  
  Found by: avos@

Modified:
  stable/9/sys/dev/usb/template/usb_template.c
  stable/9/sys/dev/usb/usb_device.c
  stable/9/sys/dev/usb/usb_device.h
  stable/9/sys/dev/usb/usb_generic.c
  stable/9/sys/dev/usb/usb_request.c
  stable/9/sys/dev/usb/usb_transfer.c
  stable/9/sys/dev/usb/usb_util.c
  stable/9/sys/sys/param.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/dev/usb/template/usb_template.c
==
--- stable/9/sys/dev/usb/template/usb_template.cMon Sep 12 10:17:25 
2016(r305734)
+++ stable/9/sys/dev/usb/template/usb_template.cMon Sep 12 10:20:44 
2016(r305735)
@@ -1240,7 +1240,7 @@ usb_temp_setup(struct usb_device *udev,
return (0);
 
/* Protect scratch area */
-   do_unlock = usbd_enum_lock(udev);
+   do_unlock = usbd_ctrl_lock(udev);
 
uts = udev->scratch.temp_setup;
 
@@ -1319,7 +1319,7 @@ done:
if (error)
usb_temp_unsetup(udev);
if (do_unlock)
-   usbd_enum_unlock(udev);
+   usbd_ctrl_unlock(udev);
return (error);
 }
 

Modified: stable/9/sys/dev/usb/usb_device.c
==
--- stable/9/sys/dev/usb/usb_device.c   Mon Sep 12 10:17:25 2016
(r305734)
+++ stable/9/sys/dev/usb/usb_device.c   Mon Sep 12 10:20:44 2016
(r305735)
@@ -1555,6 +1555,7 @@ usb_alloc_device(device_t parent_dev, st
/* initialise our SX-lock */
sx_init_flags(>enum_sx, "USB config SX lock", SX_DUPOK);
sx_init_flags(>sr_sx, "USB suspend and resume SX lock", 
SX_NOWITNESS);
+   sx_init_flags(>ctrl_sx, "USB control transfer SX lock", SX_DUPOK);
 
cv_init(>ctrlreq_cv, "WCTRL");
cv_init(>ref_cv, "UGONE");
@@ -1740,7 +1741,7 @@ usb_alloc_device(device_t parent_dev, st
 */
 
/* Protect scratch area */
-   do_unlock = usbd_enum_lock(udev);
+   do_unlock = usbd_ctrl_lock(udev);
 
scratch_ptr = udev->scratch.data;
 
@@ -1791,7 +1792,7 @@ usb_alloc_device(device_t parent_dev, st
}
 
if (do_unlock)
-   usbd_enum_unlock(udev);
+   usbd_ctrl_unlock(udev);
 
/* assume 100mA bus powered for now. Changed when configured. */
udev->power = USB_MIN_POWER;
@@ -2158,6 +2159,7 @@ usb_free_device(struct usb_device *udev,

sx_destroy(>enum_sx);
sx_destroy(>sr_sx);
+   sx_destroy(>ctrl_sx);
 
cv_destroy(>ctrlreq_cv);
cv_destroy(>ref_cv);
@@ -2321,7 +2323,7 @@ usbd_set_device_strings(struct usb_devic
uint8_t do_unlock;
 
/* Protect scratch area */
-   do_unlock = usbd_enum_lock(udev);
+   do_unlock = usbd_ctrl_lock(udev);
 
temp_ptr = (char *)udev->scratch.data;
temp_size = sizeof(udev->scratch.data);
@@ -2381,7 +2383,7 @@ usbd_set_device_strings(struct usb_devic
}
 
if (do_unlock)
-   usbd_enum_unlock(udev);
+   usbd_ctrl_unlock(udev);
 }
 
 /*
@@ -2788,6 +2790,40 @@ usbd_enum_is_locked(struct usb_device *u
 }
 
 /*
+ * The following function is used to serialize access to USB control
+ * transfers and the USB scratch area. If the lock is already grabbed
+ * this function returns zero. Else a value of one is returned.
+ */
+uint8_t
+usbd_ctrl_lock(struct usb_device *udev)
+{
+   if (sx_xlocked(>ctrl_sx))
+   return (0);
+   sx_xlock(>ctrl_sx);
+
+   /*
+* We need to allow suspend and resume at this point, else the
+* control transfer will timeout if the device is suspended!
+*/
+   if (usbd_enum_is_locked(udev))
+   usbd_sr_unlock(udev);
+   return (1);
+}
+

svn commit: r305646 - stable/9/sys/dev/usb/input

2016-09-09 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Sep  9 06:41:16 2016
New Revision: 305646
URL: https://svnweb.freebsd.org/changeset/base/305646

Log:
  MFC r304571:
  Make the UKBD USB transfers double buffered and set them up one by one,
  so they are memory independent which allows for handling panics
  triggered by the keyboard driver itself, typically via CTRL+ALT+ESC
  sequences. Or if the USB keyboard driver was processing a key at the
  moment of panic. Allow UKBD to be attached while keyboard polling is active.

Modified:
  stable/9/sys/dev/usb/input/ukbd.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/input/ukbd.c
==
--- stable/9/sys/dev/usb/input/ukbd.c   Fri Sep  9 06:38:13 2016
(r305645)
+++ stable/9/sys/dev/usb/input/ukbd.c   Fri Sep  9 06:41:16 2016
(r305646)
@@ -107,7 +107,7 @@ TUNABLE_INT("hw.usb.ukbd.no_leds", 
 #defineUKBD_NMOD 8 /* units */
 #defineUKBD_NKEYCODE 6 /* units */
 #defineUKBD_IN_BUF_SIZE  (2*(UKBD_NMOD + (2*UKBD_NKEYCODE)))   /* 
bytes */
-#defineUKBD_IN_BUF_FULL  (UKBD_IN_BUF_SIZE / 2)/* bytes */
+#defineUKBD_IN_BUF_FULL  ((UKBD_IN_BUF_SIZE / 2) - 1)  /* bytes */
 #defineUKBD_NFKEY(sizeof(fkey_tab)/sizeof(fkey_tab[0]))
/* units */
 #defineUKBD_BUFFER_SIZE  64/* bytes */
 
@@ -128,7 +128,8 @@ struct ukbd_data {
 };
 
 enum {
-   UKBD_INTR_DT,
+   UKBD_INTR_DT_0,
+   UKBD_INTR_DT_1,
UKBD_CTRL_LED,
UKBD_N_TRANSFER,
 };
@@ -477,7 +478,8 @@ ukbd_get_key(struct ukbd_softc *sc, uint
if (sc->sc_inputs == 0 &&
(sc->sc_flags & UKBD_FLAG_GONE) == 0) {
/* start transfer, if not already started */
-   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]);
+   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT_0]);
+   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT_1]);
}
 
if (sc->sc_flags & UKBD_FLAG_POLLING)
@@ -953,7 +955,16 @@ ukbd_set_leds_callback(struct usb_xfer *
 
 static const struct usb_config ukbd_config[UKBD_N_TRANSFER] = {
 
-   [UKBD_INTR_DT] = {
+   [UKBD_INTR_DT_0] = {
+   .type = UE_INTERRUPT,
+   .endpoint = UE_ADDR_ANY,
+   .direction = UE_DIR_IN,
+   .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
+   .bufsize = 0,   /* use wMaxPacketSize */
+   .callback = _intr_callback,
+   },
+
+   [UKBD_INTR_DT_1] = {
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
@@ -1198,9 +1209,26 @@ ukbd_attach(device_t dev)
 
usb_callout_init_mtx(>sc_callout, , 0);
 
+#ifdef UKBD_NO_POLLING
err = usbd_transfer_setup(uaa->device,
>info.bIfaceIndex, sc->sc_xfer, ukbd_config,
UKBD_N_TRANSFER, sc, );
+#else
+   /*
+* Setup the UKBD USB transfers one by one, so they are memory
+* independent which allows for handling panics triggered by
+* the keyboard driver itself, typically via CTRL+ALT+ESC
+* sequences. Or if the USB keyboard driver was processing a
+* key at the moment of panic.
+*/
+   for (n = 0; n != UKBD_N_TRANSFER; n++) {
+   err = usbd_transfer_setup(uaa->device,
+   >info.bIfaceIndex, sc->sc_xfer + n, ukbd_config + n,
+   1, sc, );
+   if (err)
+   break;
+   }
+#endif
 
if (err) {
DPRINTF("error=%s\n", usbd_errstr(err));
@@ -1283,7 +1311,8 @@ ukbd_attach(device_t dev)
}
 
/* start the keyboard */
-   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]);
+   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT_0]);
+   usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT_1]);
 
return (0); /* success */
 
@@ -1309,7 +1338,8 @@ ukbd_detach(device_t dev)
/* kill any stuck keys */
if (sc->sc_flags & UKBD_FLAG_ATTACHED) {
/* stop receiving events from the USB keyboard */
-   usbd_transfer_stop(sc->sc_xfer[UKBD_INTR_DT]);
+   usbd_transfer_stop(sc->sc_xfer[UKBD_INTR_DT_0]);
+   usbd_transfer_stop(sc->sc_xfer[UKBD_INTR_DT_1]);
 
/* release all leftover keys, if any */
memset(>sc_ndata, 0, sizeof(sc->sc_ndata));
@@ -1974,7 +2004,7 @@ ukbd_poll(keyboard_t *kbd, int on)
 */
if (on)
sc->sc_polling++;
-   else
+   else if (sc->sc_polling > 0)
sc->sc_polling--;
 
if (sc->sc_polling != 0) {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to 

svn commit: r305642 - stable/9/lib/libusb

2016-09-09 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Sep  9 06:31:25 2016
New Revision: 305642
URL: https://svnweb.freebsd.org/changeset/base/305642

Log:
  MFC r305284:
  Fix array size issue when using the pre-scaling feature for
  ISOCHRONOUS USB transfers. Make sure enough length and buffer pointers
  are allocated when setting up the libusb transfer structure to support
  the maximum number of frames the kernel can handle.

Modified:
  stable/9/lib/libusb/libusb20.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb20.c
==
--- stable/9/lib/libusb/libusb20.c  Fri Sep  9 06:27:25 2016
(r305641)
+++ stable/9/lib/libusb/libusb20.c  Fri Sep  9 06:31:25 2016
(r305642)
@@ -165,6 +165,12 @@ libusb20_tr_open(struct libusb20_transfe
return (LIBUSB20_ERROR_BUSY);
if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) {
MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE;
+   /*
+* The kernel can setup 8 times more frames when
+* pre-scaling ISOCHRONOUS transfers. Make sure the
+* length and pointer buffers are big enough:
+*/
+   MaxFrameCount *= 8;
pre_scale = 1;
} else {
pre_scale = 0;
@@ -189,8 +195,13 @@ libusb20_tr_open(struct libusb20_transfe
}
memset(xfer->ppBuffer, 0, size);
 
-   error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
-   MaxFrameCount, ep_no, pre_scale);
+   if (pre_scale) {
+   error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+   MaxFrameCount / 8, ep_no, 1);
+   } else {
+   error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
+   MaxFrameCount, ep_no, 0);
+   }
 
if (error) {
free(xfer->ppBuffer);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r305000 - stable/9/sys/dev/usb/controller

2016-08-29 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 29 08:54:31 2016
New Revision: 305000
URL: https://svnweb.freebsd.org/changeset/base/305000

Log:
  MFC r304629:
  Don't separate the status stage of the XHCI USB control transfers into
  its own job because this breaks the simplified QEMU XHCI TRB parser,
  which expects the complete USB control transfer as a series of back to
  back TRBs. The old behaviour is kept under #ifdef in case this change
  breaks enumeration of any USB devices.
  
  PR:   212021

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Mon Aug 29 08:52:53 2016
(r304999)
+++ stable/9/sys/dev/usb/controller/xhci.c  Mon Aug 29 08:54:31 2016
(r305000)
@@ -2206,7 +2206,11 @@ xhci_setup_generic_chain(struct usb_xfer
 * Send a DATA1 message and invert the current
 * endpoint direction.
 */
+#ifdef XHCI_STEP_STATUS_STAGE
temp.step_td = (xfer->nframes != 0);
+#else
+   temp.step_td = 0;
+#endif
temp.direction = UE_GET_DIR(xfer->endpointno) ^ UE_DIR_IN;
temp.len = 0;
temp.pc = NULL;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r304994 - stable/9/sys/dev/usb/controller

2016-08-29 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 29 08:44:35 2016
New Revision: 304994
URL: https://svnweb.freebsd.org/changeset/base/304994

Log:
  MFC r304597:
  Fix for invalid use of bits in input context. Basically split
  configuring of EP0 and non-EP0 into xhci_cmd_evaluate_ctx() and
  xhci_cmd_configure_ep() respectivly. This resolves some errors when
  using XHCI under QEMU and gets is more in line with the XHCI
  specification.
  
  PR:   212021

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Mon Aug 29 08:42:37 2016
(r304993)
+++ stable/9/sys/dev/usb/controller/xhci.c  Mon Aug 29 08:44:35 2016
(r304994)
@@ -3806,12 +3806,10 @@ xhci_configure_reset_endpoint(struct usb
 
xhci_configure_mask(udev, (1U << epno) | 1U, 0);
 
-   err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index);
-
-   if (err != 0)
-   DPRINTF("Could not configure endpoint %u\n", epno);
-
-   err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index);
+   if (epno > 1)
+   err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index);
+   else
+   err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index);
 
if (err != 0)
DPRINTF("Could not configure endpoint %u\n", epno);
@@ -4191,6 +4189,10 @@ xhci_device_state_change(struct usb_devi
 
sc->sc_hw.devs[index].state = XHCI_ST_ADDRESSED;
 
+   /* set configure mask to slot only */
+   xhci_configure_mask(udev, 1, 0);
+
+   /* deconfigure all endpoints, except EP0 */
err = xhci_cmd_configure_ep(sc, 0, 1, index);
 
if (err) {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r304847 - stable/9/sys/ofed/drivers/infiniband/core

2016-08-26 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Aug 26 12:08:27 2016
New Revision: 304847
URL: https://svnweb.freebsd.org/changeset/base/304847

Log:
  MFC r304342:
  Add support for setting blocking and non-blocking mode on /dev/rdma_cm
  by returning success on FIONBIO and FIOASYNC IOCTLs. The actual flags
  handling is done by the kern_ioctl() function.
  
  Reported by:  Alex Bowden 
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/infiniband/core/ucma.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/core/ucma.c
==
--- stable/9/sys/ofed/drivers/infiniband/core/ucma.cFri Aug 26 12:06:43 
2016(r304846)
+++ stable/9/sys/ofed/drivers/infiniband/core/ucma.cFri Aug 26 12:08:27 
2016(r304847)
@@ -39,6 +39,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -1285,11 +1287,25 @@ static int ucma_close(struct inode *inod
return 0;
 }
 
+static long
+ucma_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+
+   switch (cmd) {
+   case FIONBIO:
+   case FIOASYNC:
+   return (0);
+   default:
+   return (-ENOTTY);
+   }
+}
+
 static const struct file_operations ucma_fops = {
.owner   = THIS_MODULE,
.open= ucma_open,
.release = ucma_close,
.write   = ucma_write,
+   .unlocked_ioctl = ucma_ioctl,
.poll= ucma_poll,
 };
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r304129 - stable/9/sys/dev/usb/input

2016-08-15 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Aug 15 09:03:05 2016
New Revision: 304129
URL: https://svnweb.freebsd.org/changeset/base/304129

Log:
  MFC r303765:
  Keep a reference count on USB keyboard polling to allow recursive
  cngrab() during a panic for example, similar to what the AT-keyboard
  driver is doing.
  
  Found by: Bruce Evans 

Modified:
  stable/9/sys/dev/usb/input/ukbd.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/input/ukbd.c
==
--- stable/9/sys/dev/usb/input/ukbd.c   Mon Aug 15 09:02:09 2016
(r304128)
+++ stable/9/sys/dev/usb/input/ukbd.c   Mon Aug 15 09:03:05 2016
(r304129)
@@ -197,6 +197,7 @@ struct ukbd_softc {
int sc_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */
int sc_state;   /* shift/lock key state */
int sc_accents; /* accent key index (> 0) */
+   int sc_polling; /* polling recursion count */
int sc_led_size;
int sc_kbd_size;
 
@@ -1967,7 +1968,16 @@ ukbd_poll(keyboard_t *kbd, int on)
struct ukbd_softc *sc = kbd->kb_data;
 
UKBD_LOCK();
-   if (on) {
+   /*
+* Keep a reference count on polling to allow recursive
+* cngrab() during a panic for example.
+*/
+   if (on)
+   sc->sc_polling++;
+   else
+   sc->sc_polling--;
+
+   if (sc->sc_polling != 0) {
sc->sc_flags |= UKBD_FLAG_POLLING;
sc->sc_poll_thread = curthread;
} else {
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r303997 - stable/9/sys/dev/usb/controller

2016-08-12 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Aug 12 08:07:19 2016
New Revision: 303997
URL: https://svnweb.freebsd.org/changeset/base/303997

Log:
  MFC r302371:
  Fix regression issue with XHCI on 32-bit ARMv7 Armada-38x. Make sure
  "struct xhci_dev_ctx_addr" fits into a single 4K page until further.

Modified:
  stable/9/sys/dev/usb/controller/xhci.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.h
==
--- stable/9/sys/dev/usb/controller/xhci.h  Fri Aug 12 08:05:40 2016
(r303996)
+++ stable/9/sys/dev/usb/controller/xhci.h  Fri Aug 12 08:07:19 2016
(r303997)
@@ -30,7 +30,7 @@
 
 #defineXHCI_MAX_DEVICESMIN(USB_MAX_DEVICES, 128)
 #defineXHCI_MAX_ENDPOINTS  32  /* hardcoded - do not change */
-#defineXHCI_MAX_SCRATCHPADS1024
+#defineXHCI_MAX_SCRATCHPADS256 /* theoretical max is 1023 */
 #defineXHCI_MAX_EVENTS (16 * 13)
 #defineXHCI_MAX_COMMANDS   (16 * 1)
 #defineXHCI_MAX_RSEG   1
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r303994 - stable/9/sys/dev/sound/usb

2016-08-12 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Aug 12 07:59:06 2016
New Revision: 303994
URL: https://svnweb.freebsd.org/changeset/base/303994

Log:
  MFC r301039:
  Add support for simplex USB MIDI devices, which only provide BULK or
  INTERRUPT endpoints for moving data in one direction, like the KeyRig
  49 from M-Audio.
  
  Requested by: Ivan Klymenko 

Modified:
  stable/9/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==
--- stable/9/sys/dev/sound/usb/uaudio.c Fri Aug 12 07:57:27 2016
(r303993)
+++ stable/9/sys/dev/sound/usb/uaudio.c Fri Aug 12 07:59:06 2016
(r303994)
@@ -660,6 +660,7 @@ static const struct usb_config
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = UMIDI_TX_BUFFER,
+   .flags = {.no_pipe_ok = 1},
.callback = _bulk_write_callback,
},
 
@@ -668,7 +669,7 @@ static const struct usb_config
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.bufsize = 4,   /* bytes */
-   .flags = {.short_xfer_ok = 1,.proxy_buffer = 1,},
+   .flags = {.short_xfer_ok = 1,.proxy_buffer = 1,.no_pipe_ok = 1},
.callback = _bulk_read_callback,
},
 };
@@ -5747,7 +5748,16 @@ umidi_start_write(struct usb_fifo *fifo)
 {
struct umidi_chan *chan = usb_fifo_softc(fifo);
 
-   usbd_transfer_start(chan->xfer[UMIDI_TX_TRANSFER]);
+   if (chan->xfer[UMIDI_TX_TRANSFER] == NULL) {
+   uint8_t buf[1];
+   int actlen;
+   do {
+   /* dump data */
+   usb_fifo_get_data_linear(fifo, buf, 1, , 0);
+   } while (actlen > 0);
+   } else {
+   usbd_transfer_start(chan->xfer[UMIDI_TX_TRANSFER]);
+   }
 }
 
 static void
@@ -5865,6 +5875,11 @@ umidi_probe(device_t dev)
DPRINTF("error=%s\n", usbd_errstr(error));
goto detach;
}
+   if (chan->xfer[UMIDI_TX_TRANSFER] == NULL &&
+   chan->xfer[UMIDI_RX_TRANSFER] == NULL) {
+   DPRINTF("no BULK or INTERRUPT MIDI endpoint(s) found\n");
+   goto detach;
+   }
 
/*
 * Some USB MIDI device makers couldn't resist using
@@ -5878,7 +5893,8 @@ umidi_probe(device_t dev)
 * and 64-byte maximum packet sizes for full-speed bulk
 * endpoints and 512 bytes for high-speed bulk endpoints."
 */
-   if (usbd_xfer_maxp_was_clamped(chan->xfer[UMIDI_TX_TRANSFER]))
+   if (chan->xfer[UMIDI_TX_TRANSFER] != NULL &&
+   usbd_xfer_maxp_was_clamped(chan->xfer[UMIDI_TX_TRANSFER]))
chan->single_command = 1;
 
if (chan->single_command != 0)
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r302276 - stable/9/lib/libusb

2016-06-29 Thread Hans Petter Selasky
lt; 24);
+
+   *usb_2_0_extension = desc;
+   return (0);
+}
+
+void
+libusb_free_usb_2_0_extension_descriptor(
+struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension)
+{
+
+   free(usb_2_0_extension);
+}
+
+int
+libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx,
+struct libusb_bos_dev_capability_descriptor *dev_cap,
+struct libusb_ss_usb_device_capability_descriptor 
**ss_usb_device_capability)
+{
+   struct libusb_ss_usb_device_capability_descriptor *desc;
+
+   if (dev_cap == NULL || ss_usb_device_capability == NULL ||
+   dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY)
+   return (LIBUSB_ERROR_INVALID_PARAM);
+   if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE)
+   return (LIBUSB_ERROR_IO);
+
+   desc = malloc(sizeof(*desc));
+   if (desc == NULL)
+   return (LIBUSB_ERROR_NO_MEM);
+
+   desc->bLength = LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE;
+   desc->bDescriptorType = dev_cap->bDescriptorType;
+   desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+   desc->bmAttributes = dev_cap->dev_capability_data[0];
+   desc->wSpeedSupported = dev_cap->dev_capability_data[1] |
+   (dev_cap->dev_capability_data[2] << 8);
+   desc->bFunctionalitySupport = dev_cap->dev_capability_data[3];
+   desc->bU1DevExitLat = dev_cap->dev_capability_data[4];
+   desc->wU2DevExitLat = dev_cap->dev_capability_data[5] |
+   (dev_cap->dev_capability_data[6] << 8);
+
+   *ss_usb_device_capability = desc;
+   return (0);
+}
+
+void
+libusb_free_ss_usb_device_capability_descriptor(
+struct libusb_ss_usb_device_capability_descriptor 
*ss_usb_device_capability)
+{
+
+   free(ss_usb_device_capability);
+}
+
+int
+libusb_get_container_id_descriptor(struct libusb_context *ctx,
+struct libusb_bos_dev_capability_descriptor *dev_cap,
+struct libusb_container_id_descriptor **container_id)
+{
+   struct libusb_container_id_descriptor *desc;
+
+   if (dev_cap == NULL || container_id == NULL ||
+   dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID)
+   return (LIBUSB_ERROR_INVALID_PARAM);
+   if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE)
+   return (LIBUSB_ERROR_IO);
+
+   desc = malloc(sizeof(*desc));
+   if (desc == NULL)
+   return (LIBUSB_ERROR_NO_MEM);
+
+   desc->bLength = LIBUSB_BT_CONTAINER_ID_SIZE;
+   desc->bDescriptorType = dev_cap->bDescriptorType;
+   desc->bDevCapabilityType = dev_cap->bDevCapabilityType;
+   desc->bReserved = dev_cap->dev_capability_data[0];
+   memcpy(desc->ContainerID, dev_cap->dev_capability_data + 1,
+   sizeof(desc->ContainerID));
+
+   *container_id = desc;
+   return (0);
+}
+
+void
+libusb_free_container_id_descriptor(
+struct libusb_container_id_descriptor *container_id)
+{
+
+   free(container_id);
+}

Copied: stable/9/lib/libusb/libusb10_hotplug.c (from r302080, 
head/lib/libusb/libusb10_hotplug.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/9/lib/libusb/libusb10_hotplug.c  Wed Jun 29 11:06:13 2016
(r302276, copy of r302080, head/lib/libusb/libusb10_hotplug.c)
@@ -0,0 +1,237 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef LIBUSB_GLOBAL_INCLUDE_FILE
+#include LIBUSB_GLOBAL_INCLUDE_FILE
+#else
+#include 
+#

svn commit: r302273 - stable/9/lib/libusb

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:46:10 2016
New Revision: 302273
URL: https://svnweb.freebsd.org/changeset/base/302273

Log:
  MFC r301842:
  Implement code to stop all USB endpoints before executing a USB device
  reset command, alternate setting command or set configuration
  command. Else LibUSB v1.0 will not re-open the endpoints which the
  kernel closes and the USB application might wait infinitely for
  transfers to complete.

Modified:
  stable/9/lib/libusb/libusb10.c
Directory Properties:
  stable/9/lib/   (props changed)
  stable/9/lib/libusb/   (props changed)

Modified: stable/9/lib/libusb/libusb10.c
==
--- stable/9/lib/libusb/libusb10.c  Wed Jun 29 10:43:31 2016
(r302272)
+++ stable/9/lib/libusb/libusb10.c  Wed Jun 29 10:46:10 2016
(r302273)
@@ -45,6 +45,8 @@
 #include "libusb.h"
 #include "libusb10.h"
 
+#defineLIBUSB_NUM_SW_ENDPOINTS (16 * 4)
+
 static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER;
 struct libusb_context *usbi_default_context = NULL;
 
@@ -436,7 +438,7 @@ libusb_open(libusb_device *dev, libusb_d
if (dev == NULL)
return (LIBUSB_ERROR_INVALID_PARAM);
 
-   err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ );
+   err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS);
if (err) {
libusb_unref_device(dev);
return (LIBUSB_ERROR_NO_MEM);
@@ -1489,7 +1491,17 @@ libusb_cancel_transfer(struct libusb_tra
 UNEXPORTED void
 libusb10_cancel_all_transfer(libusb_device *dev)
 {
-   /* TODO */
+   struct libusb20_device *pdev = dev->os_priv;
+   unsigned x;
+
+   for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) {
+   struct libusb20_transfer *xfer;
+
+   xfer = libusb20_tr_get_pointer(pdev, x);
+   if (xfer == NULL)
+   continue;
+   libusb20_tr_close(xfer);
+   }
 }
 
 uint16_t
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r302267 - stable/9/sys/dev/usb/controller

2016-06-29 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jun 29 10:23:19 2016
New Revision: 302267
URL: https://svnweb.freebsd.org/changeset/base/302267

Log:
  MFC r302076:
  Update the definition for number of scratch pages to match the latest
  version of the XHCI specification. Make sure the code can handle the
  maximum number of allowed scratch pages.
  
  Submitted by: shichun...@dell.com

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
  stable/9/sys/dev/usb/controller/xhci.h
  stable/9/sys/dev/usb/controller/xhcireg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Wed Jun 29 10:21:45 2016
(r302266)
+++ stable/9/sys/dev/usb/controller/xhci.c  Wed Jun 29 10:23:19 2016
(r302267)
@@ -204,7 +204,7 @@ static void
 xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb)
 {
struct xhci_softc *sc = XHCI_BUS2SC(bus);
-   uint8_t i;
+   uint16_t i;
 
cb(bus, >sc_hw.root_pc, >sc_hw.root_pg,
   sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE);
@@ -212,7 +212,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu
cb(bus, >sc_hw.ctx_pc, >sc_hw.ctx_pg,
   sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE);
 
-   for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) {
+   for (i = 0; i != sc->sc_noscratch; i++) {
cb(bus, >sc_hw.scratch_pc[i], >sc_hw.scratch_pg[i],
XHCI_PAGE_SIZE, XHCI_PAGE_SIZE);
}

Modified: stable/9/sys/dev/usb/controller/xhci.h
==
--- stable/9/sys/dev/usb/controller/xhci.h  Wed Jun 29 10:21:45 2016
(r302266)
+++ stable/9/sys/dev/usb/controller/xhci.h  Wed Jun 29 10:23:19 2016
(r302267)
@@ -30,7 +30,7 @@
 
 #defineXHCI_MAX_DEVICESMIN(USB_MAX_DEVICES, 128)
 #defineXHCI_MAX_ENDPOINTS  32  /* hardcoded - do not change */
-#defineXHCI_MAX_SCRATCHPADS32
+#defineXHCI_MAX_SCRATCHPADS1024
 #defineXHCI_MAX_EVENTS (16 * 13)
 #defineXHCI_MAX_COMMANDS   (16 * 1)
 #defineXHCI_MAX_RSEG   1
@@ -486,14 +486,15 @@ struct xhci_softc {
uint16_tsc_command_idx;
uint16_tsc_imod_default;
 
+   /* number of scratch pages */
+   uint16_tsc_noscratch;
+
uint8_t sc_event_ccs;
uint8_t sc_command_ccs;
/* number of XHCI device slots */
uint8_t sc_noslot;
/* number of ports on root HUB */
uint8_t sc_noport;
-   /* number of scratch pages */
-   uint8_t sc_noscratch;
/* root HUB device configuration */
uint8_t sc_conf;
/* root HUB port event bitmap, max 256 ports */

Modified: stable/9/sys/dev/usb/controller/xhcireg.h
==
--- stable/9/sys/dev/usb/controller/xhcireg.h   Wed Jun 29 10:21:45 2016
(r302266)
+++ stable/9/sys/dev/usb/controller/xhcireg.h   Wed Jun 29 10:23:19 2016
(r302267)
@@ -52,8 +52,8 @@
 #defineXHCI_HCSPARAMS2 0x08/* RO structual parameters 2 */
 #defineXHCI_HCS2_IST(x)((x) & 0xF)
 #defineXHCI_HCS2_ERST_MAX(x)   (((x) >> 4) & 0xF)
-#defineXHCI_HCS2_SPR(x)(((x) >> 24) & 0x1)
-#defineXHCI_HCS2_SPB_MAX(x)(((x) >> 27) & 0x7F)
+#defineXHCI_HCS2_SPR(x)(((x) >> 26) & 0x1)
+#defineXHCI_HCS2_SPB_MAX(x)x) >> 16) & 0x3E0) | (((x) >> 27) & 
0x1F))
 #defineXHCI_HCSPARAMS3 0x0C/* RO structual parameters 3 */
 #defineXHCI_HCS3_U1_DEL(x) ((x) & 0xFF)
 #defineXHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0x)
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r301262 - stable/9/sys/kern

2016-06-03 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun  3 09:17:22 2016
New Revision: 301262
URL: https://svnweb.freebsd.org/changeset/base/301262

Log:
  MFC r300489:
  Use DELAY() instead of _sleep() when SCHEDULER_STOPPED() is set inside
  pause_sbt(). This allows pause() to continue working during a panic()
  which is not invoking KDB. This is useful when debugging graphics
  drivers using the LinuxKPI.

Modified:
  stable/9/sys/kern/kern_synch.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_synch.c
==
--- stable/9/sys/kern/kern_synch.c  Fri Jun  3 09:10:37 2016
(r301261)
+++ stable/9/sys/kern/kern_synch.c  Fri Jun  3 09:17:22 2016
(r301262)
@@ -355,7 +355,7 @@ pause(const char *wmesg, int timo)
if (timo < 1)
timo = 1;
 
-   if (cold) {
+   if (cold || kdb_active || SCHEDULER_STOPPED()) {
/*
 * We delay one HZ at a time to avoid overflowing the
 * system specific DELAY() function(s):
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r301254 - stable/9/sys/dev/usb

2016-06-03 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun  3 08:56:54 2016
New Revision: 301254
URL: https://svnweb.freebsd.org/changeset/base/301254

Log:
  MFC r300667:
  Check for signals when locking the USB enumeration thread from
  userspace, so that USB applications can be killed if an enumeration
  thread should be stuck for various reasons.

Modified:
  stable/9/sys/dev/usb/usb_dev.c
  stable/9/sys/dev/usb/usb_device.c
  stable/9/sys/dev/usb/usb_device.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/usb_dev.c
==
--- stable/9/sys/dev/usb/usb_dev.c  Fri Jun  3 08:55:28 2016
(r301253)
+++ stable/9/sys/dev/usb/usb_dev.c  Fri Jun  3 08:56:54 2016
(r301254)
@@ -225,7 +225,7 @@ usb_ref_device(struct usb_cdev_privdata 
 * We need to grab the enumeration SX-lock before
 * grabbing the FIFO refs to avoid deadlock at detach!
 */
-   crd->do_unlock = usbd_enum_lock(cpd->udev);
+   crd->do_unlock = usbd_enum_lock_sig(cpd->udev);
 
mtx_lock(_ref_lock);
 
@@ -233,6 +233,12 @@ usb_ref_device(struct usb_cdev_privdata 
 * Set "is_uref" after grabbing the default SX lock
 */
crd->is_uref = 1;
+
+   /* check for signal */
+   if (crd->do_unlock > 1) {
+   crd->do_unlock = 0;
+   goto error;
+   }
}
 
/* check if we are doing an open */

Modified: stable/9/sys/dev/usb/usb_device.c
==
--- stable/9/sys/dev/usb/usb_device.c   Fri Jun  3 08:55:28 2016
(r301253)
+++ stable/9/sys/dev/usb/usb_device.c   Fri Jun  3 08:56:54 2016
(r301254)
@@ -2703,7 +2703,7 @@ usbd_device_attached(struct usb_device *
 /*
  * The following function locks enumerating the given USB device. If
  * the lock is already grabbed this function returns zero. Else a
- * non-zero value is returned.
+ * a value of one is returned.
  */
 uint8_t
 usbd_enum_lock(struct usb_device *udev)
@@ -2722,6 +2722,27 @@ usbd_enum_lock(struct usb_device *udev)
return (1);
 }
 
+#if USB_HAVE_UGEN
+/*
+ * This function is the same like usbd_enum_lock() except a value of
+ * 255 is returned when a signal is pending:
+ */
+uint8_t
+usbd_enum_lock_sig(struct usb_device *udev)
+{
+   if (sx_xlocked(>enum_sx))
+   return (0);
+   if (sx_xlock_sig(>enum_sx))
+   return (255);
+   if (sx_xlock_sig(>sr_sx)) {
+   sx_xunlock(>enum_sx);
+   return (255);
+   }
+   mtx_lock();
+   return (1);
+}
+#endif
+
 /* The following function unlocks enumerating the given USB device. */
 
 void

Modified: stable/9/sys/dev/usb/usb_device.h
==
--- stable/9/sys/dev/usb/usb_device.h   Fri Jun  3 08:55:28 2016
(r301253)
+++ stable/9/sys/dev/usb/usb_device.h   Fri Jun  3 08:56:54 2016
(r301254)
@@ -302,6 +302,9 @@ voidusb_set_device_state(struct usb_dev
 enum usb_dev_state usb_get_device_state(struct usb_device *);
 
 uint8_tusbd_enum_lock(struct usb_device *);
+#if USB_HAVE_UGEN
+uint8_tusbd_enum_lock_sig(struct usb_device *);
+#endif
 void   usbd_enum_unlock(struct usb_device *);
 void   usbd_sr_lock(struct usb_device *);
 void   usbd_sr_unlock(struct usb_device *);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r301251 - stable/9/sys/dev/usb

2016-06-03 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Jun  3 08:50:44 2016
New Revision: 301251
URL: https://svnweb.freebsd.org/changeset/base/301251

Log:
  MFC r299060:
  Extend the UQ_NO_STRINGS quirk to also cover the USB language string
  descriptor. This fixes enumeration of some older Samsung Galaxy S3
  phones.

Modified:
  stable/9/sys/dev/usb/usb_device.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/usb_device.c
==
--- stable/9/sys/dev/usb/usb_device.c   Fri Jun  3 08:49:04 2016
(r301250)
+++ stable/9/sys/dev/usb/usb_device.c   Fri Jun  3 08:50:44 2016
(r301251)
@@ -1744,7 +1744,9 @@ usb_alloc_device(device_t parent_dev, st
 
scratch_ptr = udev->scratch.data;
 
-   if (udev->ddesc.iManufacturer ||
+   if (udev->flags.no_strings) {
+   err = USB_ERR_INVAL;
+   } else if (udev->ddesc.iManufacturer ||
udev->ddesc.iProduct ||
udev->ddesc.iSerialNumber) {
/* read out the language ID string */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r299261 - stable/9/etc/devd

2016-05-09 Thread Hans Petter Selasky
Author: hselasky
Date: Mon May  9 13:13:55 2016
New Revision: 299261
URL: https://svnweb.freebsd.org/changeset/base/299261

Log:
  MFC r298783:
  Regenerate usb.conf .

Modified:
  stable/9/etc/devd/usb.conf
Directory Properties:
  stable/9/etc/   (props changed)

Modified: stable/9/etc/devd/usb.conf
==
--- stable/9/etc/devd/usb.conf  Mon May  9 13:12:12 2016(r299260)
+++ stable/9/etc/devd/usb.conf  Mon May  9 13:13:55 2016(r299261)
@@ -1721,7 +1721,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x07b8";
-   match "product" "(0x8178|0x8188|0x8189)";
+   match "product" "(0x8178|0x8179|0x8188|0x8189)";
action "kldload -n if_urtwn";
 };
 
@@ -3161,7 +3161,23 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0df6";
-   match "product" "(0x0052|0x005c|0x0061)";
+   match "product" "0x0052";
+   action "kldload -n if_urtwn";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0df6";
+   match "product" "0x0056";
+   action "kldload -n if_axe";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0df6";
+   match "product" "(0x005c|0x0061)";
action "kldload -n if_urtwn";
 };
 
@@ -4633,7 +4649,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x17e9";
-   match "product" 
"(0x0059|0x0100|0x0117|0x0136|0x0138|0x0141|0x015a|0x0198|0x019b|0x01ba|0x01bb|0x01d4|0x01d7|0x01e2|0x0215|0x024c|0x02a9|0x0377|0x03e0|0x401a)";
+   match "product" 
"(0x0059|0x0100|0x0117|0x0136|0x0138|0x0141|0x015a|0x0198|0x019b|0x01ba|0x01bb|0x01d4|0x01d7|0x01e2|0x0215|0x024c|0x02a9|0x02e9|0x0377|0x03e0|0x401a)";
action "kldload -n udl";
 };
 
@@ -5801,5 +5817,5 @@ nomatch 32 {
action "kldload -n umass";
 };
 
-# 2719 USB entries processed
+# 2722 USB entries processed
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r298782 - in stable/9/sys/dev/usb: . quirk

2016-04-29 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 29 11:38:45 2016
New Revision: 298782
URL: https://svnweb.freebsd.org/changeset/base/298782

Log:
  MFC r297696 and r298424:
  Add new USB quirks.
  
  Submitted by: AJ 
  PR:   208623
  Submitted by: Naram Qashat 
  PR:   208642

Modified:
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/usbdevs
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/quirk/usb_quirk.c
==
--- stable/9/sys/dev/usb/quirk/usb_quirk.c  Fri Apr 29 11:37:06 2016
(r298781)
+++ stable/9/sys/dev/usb/quirk/usb_quirk.c  Fri Apr 29 11:38:45 2016
(r298782)
@@ -135,6 +135,8 @@ static struct usb_quirk_entry usb_quirks
USB_QUIRK(CORSAIR, K60, 0x, 0x, UQ_KBD_BOOTPROTO),
/* Quirk for Corsair Vengeance K70 keyboard */
USB_QUIRK(CORSAIR, K70, 0x, 0x, UQ_KBD_BOOTPROTO),
+   /* Quirk for Corsair STRAFE Gaming keyboard */
+   USB_QUIRK(CORSAIR, STRAFE, 0x, 0x, UQ_KBD_BOOTPROTO),
/* umodem(4) device quirks */
USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA),
USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA),
@@ -528,6 +530,9 @@ static struct usb_quirk_entry usb_quirks
 
/* DYMO LabelManager Pnp */
USB_QUIRK(DYMO, LABELMANAGERPNP, 0x, 0x, UQ_MSC_DYMO_EJECT),
+
+   /* Holtek USB gaming keyboard */
+   USB_QUIRK(HOLTEK, F85, 0x, 0x, UQ_KBD_BOOTPROTO),
 };
 #undef USB_QUIRK_VP
 #undef USB_QUIRK

Modified: stable/9/sys/dev/usb/usbdevs
==
--- stable/9/sys/dev/usb/usbdevsFri Apr 29 11:37:06 2016
(r298781)
+++ stable/9/sys/dev/usb/usbdevsFri Apr 29 11:38:45 2016
(r298782)
@@ -1509,6 +1509,7 @@ product COREGA FETHER_USB_TXC 0x9601  FEt
 /* Corsair products */
 product CORSAIR K600x0a60  Corsair Vengeance K60 keyboard
 product CORSAIR K700x1b09  Corsair Vengeance K70 keyboard
+product CORSAIR STRAFE 0x1b15  Cossair STRAFE Gaming keyboard
 
 /* Creative products */
 product CREATIVE NOMAD_II  0x1002  Nomad II MP3 player
@@ -2266,6 +2267,9 @@ product HIDGLOBAL CM6020  0x1784  Omnikey 
 product HITACHI DVDCAM_DZ_MV100A   0x0004  DVD-CAM DZ-MV100A Camcorder
 product HITACHI DVDCAM_USB 0x001e  DVDCAM USB HS Interface
 
+/* Holtek products */
+product HOLTEK F85 0xa030  Holtek USB gaming keyboard
+
 /* HP products */
 product HP 895C0x0004  DeskJet 895C
 product HP 4100C   0x0101  Scanjet 4100C
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r298780 - stable/9/sys/ofed/drivers/infiniband/ulp/ipoib

2016-04-29 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 29 11:31:27 2016
New Revision: 298780
URL: https://svnweb.freebsd.org/changeset/base/298780

Log:
  MFC r298458:
  Add missing set of the current VNET when inputting IP packets in IPoIB.
  
  This fixes a kernel panic when using IPoIB with VIMAGE and infiniband.
  
  PR:   208957
  Sponsored by: Mellanox Technologies
  Tested by:Justin Clift 

Modified:
  stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
==
--- stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c   Fri Apr 29 
11:29:52 2016(r298779)
+++ stable/9/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c   Fri Apr 29 
11:31:27 2016(r298780)
@@ -481,6 +481,8 @@ void ipoib_cm_handle_rx_wc(struct ipoib_
int has_srq;
u_short proto;
 
+   CURVNET_SET_QUIET(dev->if_vnet);
+
ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n",
   wr_id, wc->status);
 
@@ -496,7 +498,7 @@ void ipoib_cm_handle_rx_wc(struct ipoib_
} else
ipoib_warn(priv, "cm recv completion event with wrid %d 
(> %d)\n",
   wr_id, ipoib_recvq_size);
-   return;
+   goto done;
}
 
p = wc->qp->qp_context;
@@ -520,7 +522,7 @@ void ipoib_cm_handle_rx_wc(struct ipoib_
queue_work(ipoib_workqueue, 
>cm.rx_reap_task);
spin_unlock(>lock);
}
-   return;
+   goto done;
}
}
 
@@ -579,6 +581,9 @@ repost:
   "for buf %d\n", wr_id);
}
}
+done:
+   CURVNET_RESTORE();
+   return;
 }
 
 static inline int post_send(struct ipoib_dev_priv *priv,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r298777 - stable/9/sys/ofed/drivers/net/mlx4

2016-04-29 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 29 11:17:25 2016
New Revision: 298777
URL: https://svnweb.freebsd.org/changeset/base/298777

Log:
  MFC r297968:
  Remove some unused fields.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
  stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Apr 29 11:15:48 
2016(r298776)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c  Fri Apr 29 11:17:25 
2016(r298777)
@@ -1244,10 +1244,6 @@ int mlx4_en_start_port(struct net_device
/* Calculate Rx buf size */
dev->if_mtu = min(dev->if_mtu, priv->max_mtu);
 mlx4_en_calc_rx_buf(dev);
-   priv->rx_alloc_size = max_t(int, 2 * 
roundup_pow_of_two(priv->rx_mb_size),
-   PAGE_SIZE);
-   priv->rx_alloc_order = get_order(priv->rx_alloc_size);
-   priv->rx_buf_size = roundup_pow_of_two(priv->rx_mb_size);
en_dbg(DRV, priv, "Rx buf size:%d\n", priv->rx_mb_size);
 
/* Configure rx cq's and rings */

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Fri Apr 29 11:15:48 2016
(r298776)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Fri Apr 29 11:17:25 2016
(r298777)
@@ -391,9 +391,6 @@ int mlx4_en_activate_rx_rings(struct mlx
ring->cons = 0;
ring->actual_size = 0;
ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn;
-   ring->rx_alloc_order = priv->rx_alloc_order;
-   ring->rx_alloc_size = priv->rx_alloc_size;
-   ring->rx_buf_size = priv->rx_buf_size;
 ring->rx_mb_size = priv->rx_mb_size;
 
ring->stride = stride;

Modified: stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
==
--- stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Apr 29 11:15:48 
2016(r298776)
+++ stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Apr 29 11:17:25 
2016(r298777)
@@ -316,9 +316,6 @@ struct mlx4_en_rx_ring {
u32 cons;
u32 buf_size;
u8  fcs_del;
-   u16 rx_alloc_order;
-   u32 rx_alloc_size;
-   u32 rx_buf_size;
u32 rx_mb_size;
int qpn;
u8 *buf;
@@ -557,9 +554,6 @@ struct mlx4_en_priv {
u32 tx_ring_num;
u32 rx_ring_num;
u32 rx_mb_size;
-   u16 rx_alloc_order;
-   u32 rx_alloc_size;
-   u32 rx_buf_size;
 
struct mlx4_en_tx_ring **tx_ring;
struct mlx4_en_rx_ring *rx_ring[MAX_RX_RINGS];
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r298776 - stable/9/sys/ofed/drivers/net/mlx4

2016-04-29 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 29 11:15:48 2016
New Revision: 298776
URL: https://svnweb.freebsd.org/changeset/base/298776

Log:
  MFC r297967:
  Ensure the received IP header gets 32-bits aligned.
  
  The FreeBSD's TCP/IP stack assumes that the IP-header is 32-bits aligned
  when decoding it. Else unaligned 32-bit memory access can happen, which
  not all processor architectures support.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
  stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Fri Apr 29 11:14:02 2016
(r298775)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Fri Apr 29 11:15:48 2016
(r298776)
@@ -55,7 +55,7 @@ static void mlx4_en_init_rx_desc(struct 
int i;
 
/* Set size and memtype fields */
-   rx_desc->data[0].byte_count = cpu_to_be32(priv->rx_mb_size);
+   rx_desc->data[0].byte_count = cpu_to_be32(priv->rx_mb_size - 
MLX4_NET_IP_ALIGN);
rx_desc->data[0].lkey = cpu_to_be32(priv->mdev->mr.key);
 
/*
@@ -87,7 +87,10 @@ mlx4_en_alloc_buf(struct mlx4_en_rx_ring
if (unlikely(mb == NULL))
return (-ENOMEM);
/* setup correct length */
-   mb->m_len = ring->rx_mb_size;
+   mb->m_pkthdr.len = mb->m_len = ring->rx_mb_size;
+
+   /* make sure IP header gets aligned */
+   m_adj(mb, MLX4_NET_IP_ALIGN);
 
/* load spare mbuf into BUSDMA */
err = -bus_dmamap_load_mbuf_sg(ring->dma_tag, 
ring->spare.dma_map,
@@ -117,7 +120,10 @@ mlx4_en_alloc_buf(struct mlx4_en_rx_ring
goto use_spare;
 
/* setup correct length */
-   mb->m_len = ring->rx_mb_size;
+   mb->m_pkthdr.len = mb->m_len = ring->rx_mb_size;
+
+   /* make sure IP header gets aligned */
+   m_adj(mb, MLX4_NET_IP_ALIGN);
 
err = -bus_dmamap_load_mbuf_sg(ring->dma_tag, mb_list->dma_map,
mb, segs, , BUS_DMA_NOWAIT);
@@ -249,7 +255,8 @@ static void mlx4_en_free_rx_buf(struct m
 void mlx4_en_calc_rx_buf(struct net_device *dev)
 {
struct mlx4_en_priv *priv = netdev_priv(dev);
-   int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
+   int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN +
+   MLX4_NET_IP_ALIGN;
 
if (eff_mtu > MJUM16BYTES) {
en_err(priv, "MTU(%d) is too big\n", (int)dev->if_mtu);

Modified: stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.h
==
--- stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Apr 29 11:14:02 
2016(r298775)
+++ stable/9/sys/ofed/drivers/net/mlx4/mlx4_en.hFri Apr 29 11:15:48 
2016(r298776)
@@ -69,6 +69,7 @@
 
 #define MLX4_EN_PAGE_SHIFT 12
 #define MLX4_EN_PAGE_SIZE  (1 << MLX4_EN_PAGE_SHIFT)
+#defineMLX4_NET_IP_ALIGN   2   /* bytes */
 #define DEF_RX_RINGS   16
 #define MAX_RX_RINGS   128
 #define MIN_RX_RINGS   4
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r298774 - stable/9/sys/ofed/drivers/net/mlx4

2016-04-29 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Apr 29 11:10:43 2016
New Revision: 298774
URL: https://svnweb.freebsd.org/changeset/base/298774

Log:
  MFC r297966:
  Add missing port_up checks.
  
  When downing a mlxen network adapter we need to check the port_up variable
  to ensure we don't continue to transmit data or restart timers which can
  reside in freed memory.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Fri Apr 29 11:06:24 2016
(r298773)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Fri Apr 29 11:10:43 2016
(r298774)
@@ -458,7 +458,7 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq)
struct mlx4_en_priv *priv = netdev_priv(cq->dev);
struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring];
 
-   if (!spin_trylock(>comp_lock))
+   if (priv->port_up == 0 || !spin_trylock(>comp_lock))
return;
mlx4_en_process_tx_cq(cq->dev, cq);
mod_timer(>timer, jiffies + 1);
@@ -474,6 +474,8 @@ void mlx4_en_poll_tx_cq(unsigned long da
 
INC_PERF_COUNTER(priv->pstats.tx_poll);
 
+   if (priv->port_up == 0)
+   return;
if (!spin_trylock(>comp_lock)) {
mod_timer(>timer, jiffies + MLX4_EN_TX_POLL_TIMEOUT);
return;
@@ -495,6 +497,9 @@ static inline void mlx4_en_xmit_poll(str
struct mlx4_en_cq *cq = priv->tx_cq[tx_ind];
struct mlx4_en_tx_ring *ring = priv->tx_ring[tx_ind];
 
+   if (priv->port_up == 0)
+   return;
+
/* If we don't have a pending timer, set one up to catch our recent
   post in case the interface becomes idle */
if (!timer_pending(>timer))
@@ -1042,7 +1047,9 @@ mlx4_en_tx_que(void *context, int pendin
priv = dev->if_softc;
tx_ind = cq->ring;
ring = priv->tx_ring[tx_ind];
-if (dev->if_drv_flags & IFF_DRV_RUNNING) {
+
+   if (priv->port_up != 0 &&
+   (dev->if_drv_flags & IFF_DRV_RUNNING) != 0) {
mlx4_en_xmit_poll(priv, tx_ind);
spin_lock(>tx_lock);
 if (!drbr_empty(dev, ring->br))
@@ -1059,6 +1066,11 @@ mlx4_en_transmit(struct ifnet *dev, stru
struct mlx4_en_cq *cq;
int i, err = 0;
 
+   if (priv->port_up == 0) {
+   m_freem(m);
+   return (ENETDOWN);
+   }
+
/* Compute which queue to use */
if (m->m_flags & M_FLOWID) {
i = (m->m_pkthdr.flowid % 128) % priv->tx_ring_num;
@@ -1092,6 +1104,9 @@ mlx4_en_qflush(struct ifnet *dev)
struct mlx4_en_tx_ring *ring;
struct mbuf *m;
 
+   if (priv->port_up == 0)
+   return;
+
for (int i = 0; i < priv->tx_ring_num; i++) {
ring = priv->tx_ring[i];
spin_lock(>tx_lock);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r297659 - stable/9/sys/ofed/include/asm

2016-04-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr  7 07:53:56 2016
New Revision: 297659
URL: https://svnweb.freebsd.org/changeset/base/297659

Log:
  MFC r294520:
  LinuxKPI atomic fixes:
  - Fix implementation of atomic_add_unless(). The atomic_cmpset_int()
function returns a boolean and not the previous value of the atomic
variable.
  - The atomic counters should be signed according to Linux.
  - Some minor cosmetics and styling while at it.
  
  Reviewed by:  alfred @
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/asm/atomic-long.h
  stable/9/sys/ofed/include/asm/atomic.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/asm/atomic-long.h
==
--- stable/9/sys/ofed/include/asm/atomic-long.h Thu Apr  7 07:52:09 2016
(r297658)
+++ stable/9/sys/ofed/include/asm/atomic-long.h Thu Apr  7 07:53:56 2016
(r297659)
@@ -35,7 +35,7 @@
 #include 
 
 typedef struct {
-   volatile u_long counter;
+   volatile long counter;
 } atomic_long_t;
 
 #defineatomic_long_add(i, v)   atomic_long_add_return((i), (v))

Modified: stable/9/sys/ofed/include/asm/atomic.h
==
--- stable/9/sys/ofed/include/asm/atomic.h  Thu Apr  7 07:52:09 2016
(r297658)
+++ stable/9/sys/ofed/include/asm/atomic.h  Thu Apr  7 07:53:56 2016
(r297659)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,9 +35,13 @@
 #include 
 
 typedef struct {
-   volatile u_int counter;
+   volatile int counter;
 } atomic_t;
 
+/**
+ * 32-bit atomic operations
+ **/
+
 #defineatomic_add(i, v)atomic_add_return((i), (v))
 #defineatomic_sub(i, v)atomic_sub_return((i), (v))
 #defineatomic_inc_return(v)atomic_add_return(1, (v))
@@ -45,7 +49,8 @@ typedef struct {
 #defineatomic_sub_and_test(i, v)   (atomic_sub_return((i), (v)) == 
0)
 #defineatomic_dec_and_test(v)  (atomic_sub_return(1, (v)) == 0)
 #defineatomic_inc_and_test(v)  (atomic_add_return(1, (v)) == 0)
-#define atomic_dec_return(v) atomic_sub_return(1, (v))
+#defineatomic_dec_return(v)atomic_sub_return(1, (v))
+#defineatomic_inc_not_zero(v)  atomic_add_unless((v), 1, 0)
 
 static inline int
 atomic_add_return(int i, atomic_t *v)
@@ -83,24 +88,19 @@ atomic_dec(atomic_t *v)
return atomic_fetchadd_int(>counter, -1) - 1;
 }
 
-static inline int atomic_add_unless(atomic_t *v, int a, int u)
+static inline int
+atomic_add_unless(atomic_t *v, int a, int u)
 {
-int c, old;
-c = atomic_read(v);
-for (;;) {
-if (unlikely(c == (u)))
-break;
-old = atomic_cmpset_int(>counter, c, c + (a));
-if (likely(old == c))
-break;
-c = old;
-}
-return c != (u);
-}
-
-#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
-
-
+   int c;
 
+   for (;;) {
+   c = atomic_read(v);
+   if (unlikely(c == u))
+   break;
+   if (likely(atomic_cmpset_int(>counter, c, c + a)))
+   break;
+   }
+   return (c != u);
+}
 
-#endif /* _ASM_ATOMIC_H_ */
+#endif /* _ASM_ATOMIC_H_ */
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r297657 - stable/9/sys/ofed/include/linux

2016-04-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr  7 07:45:31 2016
New Revision: 297657
URL: https://svnweb.freebsd.org/changeset/base/297657

Log:
  MFC r297444:
  Fix bugs in currently unused bit searching loop.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/include/linux/bitops.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/bitops.h
==
--- stable/9/sys/ofed/include/linux/bitops.hThu Apr  7 07:44:01 2016
(r297656)
+++ stable/9/sys/ofed/include/linux/bitops.hThu Apr  7 07:45:31 2016
(r297657)
@@ -138,11 +138,11 @@ find_last_bit(unsigned long *addr, unsig
if (mask)
return (bit + __flsl(mask));
}
-   while (--pos) {
+   while (pos--) {
addr--;
bit -= BITS_PER_LONG;
if (*addr)
-   return (bit + __flsl(mask));
+   return (bit + __flsl(*addr));
}
return (size);
 }
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r297654 - stable/9/sys/contrib/rdma/krping

2016-04-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr  7 07:39:55 2016
New Revision: 297654
URL: https://svnweb.freebsd.org/changeset/base/297654

Log:
  MFC r296934:
  Fix crash in krping when run as a client due to NULL pointer access.
  Initialize pointer in question which is used only when fast registers
  mode is selected.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/contrib/rdma/krping/krping.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/contrib/rdma/krping/krping.c
==
--- stable/9/sys/contrib/rdma/krping/krping.c   Thu Apr  7 07:38:18 2016
(r297653)
+++ stable/9/sys/contrib/rdma/krping/krping.c   Thu Apr  7 07:39:55 2016
(r297654)
@@ -259,6 +259,7 @@ static int krping_cma_event_handler(stru
 
case RDMA_CM_EVENT_ROUTE_RESOLVED:
cb->state = ROUTE_RESOLVED;
+   cb->child_cm_id = cma_id;
wake_up_interruptible(>sem);
break;
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r297653 - stable/9/sys/ofed/drivers/net/mlx4

2016-04-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr  7 07:38:18 2016
New Revision: 297653
URL: https://svnweb.freebsd.org/changeset/base/297653

Log:
  MFC r296987:
  Add missing curly brackets in for loop.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_port.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_port.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_port.cThu Apr  7 07:36:54 
2016(r297652)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_port.cThu Apr  7 07:38:18 
2016(r297653)
@@ -60,10 +60,11 @@ int mlx4_SET_VLAN_FLTR(struct mlx4_dev *
memset(filter, 0, sizeof(*filter));
for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) {
entry = 0;
-   for (j = 0; j < 32; j++)
+   for (j = 0; j < 32; j++) {
if (test_bit(index, priv->active_vlans))
entry |= 1 << j;
-index++;
+   index++;
+   }
filter->entry[i] = cpu_to_be32(entry);
}
err = mlx4_cmd(dev, mailbox->dma, priv->port, 0, MLX4_CMD_SET_VLAN_FLTR,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r297650 - stable/9/sys/ofed/drivers/net/mlx4

2016-04-07 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Apr  7 07:33:40 2016
New Revision: 297650
URL: https://svnweb.freebsd.org/changeset/base/297650

Log:
  MFC r296910:
  Use hardware computed Toeplitz hash for incoming flowids
  
  Use the Toeplitz hash value as source for the flowid. This makes the
  hash value more suitable for so-called hash bucket algorithms which
  are used in the FreeBSD's TCP/IP stack when RSS is enabled.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
  stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_rx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Thu Apr  7 07:31:17 2016
(r297649)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_rx.c  Thu Apr  7 07:33:40 2016
(r297650)
@@ -616,7 +616,8 @@ int mlx4_en_process_rx_cq(struct net_dev
goto next;
}
 
-   mb->m_pkthdr.flowid = cq->ring;
+   /* forward Toeplitz compatible hash value */
+   mb->m_pkthdr.flowid = be32_to_cpu(cqe->immed_rss_invalid);
mb->m_flags |= M_FLOWID;
mb->m_pkthdr.rcvif = dev;
if (be32_to_cpu(cqe->vlan_my_qpn) &

Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
==
--- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Thu Apr  7 07:31:17 2016
(r297649)
+++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c  Thu Apr  7 07:33:40 2016
(r297650)
@@ -1061,7 +1061,7 @@ mlx4_en_transmit(struct ifnet *dev, stru
 
/* Compute which queue to use */
if (m->m_flags & M_FLOWID) {
-   i = m->m_pkthdr.flowid % priv->tx_ring_num;
+   i = (m->m_pkthdr.flowid % 128) % priv->tx_ring_num;
}
else {
i = mlx4_en_select_queue(dev, m);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r296447 - stable/9/sys/dev/usb/controller

2016-03-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Mar  7 10:02:31 2016
New Revision: 296447
URL: https://svnweb.freebsd.org/changeset/base/296447

Log:
  MFC r295928:
  Configure the correct bMaxPacketSize for control endpoints before
  requesting the initial complete device descriptor and not as part of
  the subsequent babble error recovery. Babble means that the received
  USB packet was bigger than than configured maximum packet size. This
  only affects enumeration of FULL speed USB devices which use a
  bMaxPacketSize different from 8 bytes. This patch might help fix
  enumeration of USB devices which exhibit USB I/O errors in dmesg
  during boot.

Modified:
  stable/9/sys/dev/usb/controller/xhci.c
  stable/9/sys/dev/usb/controller/xhci.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/controller/xhci.c
==
--- stable/9/sys/dev/usb/controller/xhci.c  Mon Mar  7 09:42:16 2016
(r296446)
+++ stable/9/sys/dev/usb/controller/xhci.c  Mon Mar  7 10:02:31 2016
(r296447)
@@ -140,8 +140,8 @@ static struct xhci_endpoint_ext *xhci_ge
 static usb_proc_callback_t xhci_configure_msg;
 static usb_error_t xhci_configure_device(struct usb_device *);
 static usb_error_t xhci_configure_endpoint(struct usb_device *,
-   struct usb_endpoint_descriptor *, uint64_t, uint16_t,
-   uint8_t, uint8_t, uint8_t, uint16_t, uint16_t);
+struct usb_endpoint_descriptor *, struct xhci_endpoint_ext *,
+uint16_t, uint8_t, uint8_t, uint8_t, uint16_t, uint16_t);
 static usb_error_t xhci_configure_mask(struct usb_device *,
uint32_t, uint8_t);
 static usb_error_t xhci_cmd_evaluate_ctx(struct xhci_softc *,
@@ -1405,7 +1405,7 @@ xhci_set_address(struct usb_device *udev
USB_BUS_UNLOCK(udev->bus);
 
err = xhci_configure_endpoint(udev,
-   >ctrl_ep_desc, pepext->physaddr,
+   >ctrl_ep_desc, pepext,
0, 1, 1, 0, mps, mps);
 
if (err != 0) {
@@ -2301,13 +2301,15 @@ xhci_configure_mask(struct usb_device *u
 
 static usb_error_t
 xhci_configure_endpoint(struct usb_device *udev,
-struct usb_endpoint_descriptor *edesc, uint64_t ring_addr,
-uint16_t interval, uint8_t max_packet_count, uint8_t mult,
-uint8_t fps_shift, uint16_t max_packet_size, uint16_t max_frame_size)
+struct usb_endpoint_descriptor *edesc, struct xhci_endpoint_ext *pepext,
+uint16_t interval, uint8_t max_packet_count,
+uint8_t mult, uint8_t fps_shift, uint16_t max_packet_size,
+uint16_t max_frame_size)
 {
struct usb_page_search buf_inp;
struct xhci_softc *sc = XHCI_BUS2SC(udev->bus);
struct xhci_input_dev_ctx *pinp;
+   uint64_t ring_addr = pepext->physaddr;
uint32_t temp;
uint8_t index;
uint8_t epno;
@@ -2338,6 +2340,10 @@ xhci_configure_endpoint(struct usb_devic
if (mult == 0)
return (USB_ERR_BAD_BUFSIZE);
 
+   /* store bMaxPacketSize for control endpoints */
+   pepext->trb_ep_maxp = edesc->wMaxPacketSize[0];
+   usb_pc_cpu_flush(pepext->page_cache);
+
temp = XHCI_EPCTX_0_EPSTATE_SET(0) |
XHCI_EPCTX_0_MAXP_STREAMS_SET(0) |
XHCI_EPCTX_0_LSA_SET(0);
@@ -2457,7 +2463,7 @@ xhci_configure_endpoint_by_xfer(struct u
usb_pc_cpu_flush(pepext->page_cache);
 
return (xhci_configure_endpoint(xfer->xroot->udev,
-   xfer->endpoint->edesc, pepext->physaddr,
+   xfer->endpoint->edesc, pepext,
xfer->interval, xfer->max_packet_count,
(ecomp != NULL) ? (ecomp->bmAttributes & 3) + 1 : 1,
usbd_xfer_get_fps_shift(xfer), xfer->max_packet_size,
@@ -2849,6 +2855,17 @@ xhci_transfer_insert(struct usb_xfer *xf
return (USB_ERR_NOMEM);
}
 
+   /* check if bMaxPacketSize changed */
+   if (xfer->flags_int.control_xfr != 0 &&
+   pepext->trb_ep_maxp != xfer->endpoint->edesc->wMaxPacketSize[0]) {
+
+   DPRINTFN(8, "Reconfigure control endpoint\n");
+
+   /* force driver to reconfigure endpoint */
+   pepext->trb_halted = 1;
+   pepext->trb_running = 0;
+   }
+
/* check for stopped condition, after putting transfer on interrupt 
queue */
if (pepext->trb_running == 0) {
struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus);

Modified: stable/9/sys/dev/usb/controller/xhci.h
==
--- stable/9/sys/dev/usb/controller/xhci.h  Mon Mar  7 09:42:16 2016
(r296446)
+++ stable/9/sys/dev/usb/controller/xhci.h  Mon Mar  7 10:02:31 2016
(r296447)
@@ -373,6 +373,7 @@ struct xhci_endpoint_ext {
uint8_t trb_index;
uint8_t trb_halted;

svn commit: r296445 - stable/9/sys/dev/usb

2016-03-07 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Mar  7 09:39:35 2016
New Revision: 296445
URL: https://svnweb.freebsd.org/changeset/base/296445

Log:
  MFC r295923:
  Be more verbose when truncating number of HID items.
  
  Suggested by: Larry Rosenman 

Modified:
  stable/9/sys/dev/usb/usb_hid.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/usb_hid.c
==
--- stable/9/sys/dev/usb/usb_hid.c  Mon Mar  7 09:37:07 2016
(r296444)
+++ stable/9/sys/dev/usb/usb_hid.c  Mon Mar  7 09:39:35 2016
(r296445)
@@ -353,7 +353,8 @@ hid_get_item(struct hid_data *s, struct 
/* range check usage count */
if (c->loc.count > 255) {
DPRINTFN(0, "Number of "
-   "items truncated to 255\n");
+   "items(%u) truncated to 
255\n",
+   (unsigned)(c->loc.count));
s->ncount = 255;
} else
s->ncount = c->loc.count;
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r293737 - stable/9/sys/ofed/include/linux

2016-01-12 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Jan 12 09:03:39 2016
New Revision: 293737
URL: https://svnweb.freebsd.org/changeset/base/293737

Log:
  MFC r292989:
  Handle when filedescriptors are closed before initialized. An early
  fdclose() call can cause fget_unlocked() to fail.

Modified:
  stable/9/sys/ofed/include/linux/file.h
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/ofed/include/linux/file.h
==
--- stable/9/sys/ofed/include/linux/file.h  Tue Jan 12 09:00:19 2016
(r293736)
+++ stable/9/sys/ofed/include/linux/file.h  Tue Jan 12 09:03:39 2016
(r293737)
@@ -90,8 +90,12 @@ fd_install(unsigned int fd, struct linux
struct file *file;
 
file = fget_unlocked(curthread->td_proc->p_fd, fd);
-   filp->_file = file;
-   finit(file, filp->f_mode, DTYPE_DEV, filp, );
+   if (file == NULL) {
+   filp->_file = NULL;
+   } else {
+   filp->_file = file;
+   finit(file, filp->f_mode, DTYPE_DEV, filp, );
+   }
 
/* drop the extra reference */
fput(filp);
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


  1   2   3   4   >