Re: CVS commit: src/sys/dev/usb

2025-04-06 Thread Hans Rosenfeld
Hi,

On Tue, Mar 25, 2025 at 08:28:10PM +, Taylor R Campbell wrote:
> Thanks for taking a look at this!  This change is not quite enough,
> though.  There are two issues:
> 
> 1. `#ifdef DIAGNOSTIC printf(...)' is almost always wrong.  Generally,
>either:
> 
>(a) the condition should be KASSERTed, or
>(b) the condition should be quietly handled both ways.
> 
>It's not a priori clear in all places where we currently have buggy
>#ifdef DIAGNOSTIC printfs branches which case applies.

I'm looking at that again to figure out whether it's (a) or (b). I'm
almost done with wsmux, where I think it's (a) in nearly all cases. I'll
likely look at the stuff I changed in wsmouse and wskbd again, too.

> 2. uts_enable has this questionable logic:
> 
>   sc->sc_enabled = 1;
>   ...
>   return uhidev_open(sc->sc_hdev, &uts_intr, sc);
> 
>Note that this _always_ sets sc_enabled, even if uhidev_open fails!
>This logic should almost certainly instead be:
> 
>   error = uhidev_open(...);
>   if (error)
>   return error;
>   sc->sc_enabled = 1;
>   return 0;

Thanks for pointing that out. The uts_enable() logic is definitely
broken.

Interestingly, ums_enable() similarly just sets sc_enabled and then
reverts it back to 0 if uhidev_open() failed, which while it works
seems backwards to me. Not sure it's worth changing this, though.

> Now what I'm not sure about is whether a _failed_ uts_enable call will
> be followed by a uts_disable call.  This is a (possibly unwritten)
> part of the struct wsmouse_accessops contract; the wsmouse(9) man page
> doesn't say one way or another, though.
> 
> If wsmouse(9) guarantees that after a _failed_ enable call, it will
> never call disable, then we can (and should) dispense with the
> sc_enabled bit altogether and prune all the dead branches.  (This is
> preferable: less code in multiple drivers, fewer states to consider,
> fewer conditionals to exercise.)
> 
> If wsmouse(9) doesn't guarantee this, then we need to keep the extra
> state in all the drivers, but there's no reason to have each one print
> noise to the console about it.
> 
> (Either way, we should update the wsmouse(9) man page to spell out
> what is or isn't guaranteed.)

The problem seems to be mostly in wsmux, not wsmouse.

In particular, wsmux_do_open() ignores failures opening child devices.
Those failures can happen because a child device is already open,
which on the system I'm testing on happens to be the case because the X
server opened it before opening the mux it is part of.

Looking at xsrc/external/mit/xorg-server/dist/config/wscons.c, in
wscons_add_pointers() it checks /dev/wsmouse[0-3] in succession, and if
it finds a touchscreen type device, it adds a config section for it.

Finally, it'll create a config section for /dev/wsmouse, which I presume
by convention is actually /dev/wsmux0. So on the system I'm debugging
kern/59206 on, X will open /dev/wsmouse1 and /dev/wsmux0 as separate
pointer devices. I'm not sure how wsmux currently handles input from
wsmouse1 in this case, whether it's all ignored or delivered to X twice,
but whichever way it is it doesn't seem to cause problems.

The problem that was kern/59206 was triggered later when X stopped,
because X of course closes /dev/wsmouse1 and /dev/wsmux0 (in that
order). As wsmux doesn't keep track of which of its child devices it
successfully opened, wsmux_do_close() will just close each child device
regardless of whether a previous open succeeded. So apart from there
being a chance that it closes a device that is still open elsewhere,
here it actually closed a device again that was closed already, causing
kern/59206.

Currently the underlying drivers are checking for these situations and
handle them gracefully, except for uts(4). I actually think that wsmux
really should keep track of which of its child devices it successfully
opened, and only close those later.

And also, since the X server already opens /dev/wsmouse (aka
/dev/wsmux0) using the "ws" driver, perhaps it shouldn't even bother
looking at /dev/wsmouse[0-3]?


Hans


-- 
%SYSTEM-F-ANARCHISM, The operating system has been overthrown


CVS commit: src/sys/dev/usb

2025-04-05 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Sun Mar 23 12:07:24 UTC 2025

Modified Files:
src/sys/dev/usb: uts.c

Log Message:
uts(4): make sure the device is enabled before calling uhidev_close()

This check was already there, but only enabled for DIAGNOSTIC kernels.
The check and early return is always needed, but the message should only
be printed in DIAGNOSTIC kernels.

Fixes PR kern/59206


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/uts.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uts.c
diff -u src/sys/dev/usb/uts.c:1.16 src/sys/dev/usb/uts.c:1.17
--- src/sys/dev/usb/uts.c:1.16	Wed May 10 00:12:44 2023
+++ src/sys/dev/usb/uts.c	Sun Mar 23 12:07:24 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: uts.c,v 1.16 2023/05/10 00:12:44 riastradh Exp $	*/
+/*	$NetBSD: uts.c,v 1.17 2025/03/23 12:07:24 hans Exp $	*/
 
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.16 2023/05/10 00:12:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.17 2025/03/23 12:07:24 hans Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -331,12 +331,12 @@ uts_disable(void *v)
 	struct uts_softc *sc = v;
 
 	DPRINTFN(1,("uts_disable: sc=%p\n", sc));
-#ifdef DIAGNOSTIC
 	if (!sc->sc_enabled) {
+#ifdef DIAGNOSTIC
 		printf("uts_disable: not enabled\n");
+#endif
 		return;
 	}
-#endif
 
 	sc->sc_enabled = 0;
 	uhidev_close(sc->sc_hdev);



CVS commit: src/sys/dev/usb

2025-04-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 31 14:45:14 UTC 2025

Modified Files:
src/sys/dev/usb: usbdivar.h

Log Message:
usbdivar.h: Add missing usbdi.h include for usbd_status &c.

Sort includes while here.

Prompted by:

PR port-amd64/59180: System reboots instead of shutting down


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/dev/usb/usbdivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.138 src/sys/dev/usb/usbdivar.h:1.139
--- src/sys/dev/usb/usbdivar.h:1.138	Sun Feb  4 05:43:06 2024
+++ src/sys/dev/usb/usbdivar.h	Mon Mar 31 14:45:14 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbdivar.h,v 1.138 2024/02/04 05:43:06 mrg Exp $	*/
+/*	$NetBSD: usbdivar.h,v 1.139 2025/03/31 14:45:14 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -74,9 +74,11 @@
  *
  */
 
+#include 
 #include 
 #include 
-#include 
+
+#include 
 
 /* From usb_mem.h */
 struct usb_dma_block;



CVS commit: src/sys/dev/usb

2025-03-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 31 14:45:14 UTC 2025

Modified Files:
src/sys/dev/usb: usbdivar.h

Log Message:
usbdivar.h: Add missing usbdi.h include for usbd_status &c.

Sort includes while here.

Prompted by:

PR port-amd64/59180: System reboots instead of shutting down


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/dev/usb/usbdivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 25 20:38:27 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c umcpmio_subr.c

Log Message:
umcpmio(4): Linearize error branch structure.

This dramatically reduces the unnecessary indentation of success
cases and puts error messages adjacent to the conditions they report.

Rewriting it this way reveals that two of the error branches in
umcpmio_dev_read are probably wrong -- should probably break out of
the loop, not continue it.  To be fixed in a separate commit.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/umcpmio.c \
src/sys/dev/usb/umcpmio_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/umcpmio.c
diff -u src/sys/dev/usb/umcpmio.c:1.2 src/sys/dev/usb/umcpmio.c:1.3
--- src/sys/dev/usb/umcpmio.c:1.2	Mon Mar 17 18:24:08 2025
+++ src/sys/dev/usb/umcpmio.c	Tue Mar 25 20:38:27 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: umcpmio.c,v 1.2 2025/03/17 18:24:08 riastradh Exp $	*/
+/*	$NetBSD: umcpmio.c,v 1.3 2025/03/25 20:38:27 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2024 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.2 2025/03/17 18:24:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.3 2025/03/25 20:38:27 riastradh Exp $");
 
 /*
  * Driver for the Microchip MCP2221 / MCP2221A USB multi-io chip
@@ -455,22 +455,25 @@ umcpmio_gpio_pin_ctlctl(void *arg, int p
 	}
 
 	err = umcpmio_put_sram(sc, &set_sram_req, &set_sram_res, false);
-	if (! err) {
-		umcpmio_dump_buffer(sc->sc_dumpbuffer,
-		(uint8_t *)&set_sram_res, MCP2221_RES_BUFFER_SIZE,
-		"umcpmio_gpio_pin_ctlctl set sram buffer copy");
-		if (set_sram_res.cmd == MCP2221_CMD_SET_SRAM &&
-		set_sram_res.completion == MCP2221_CMD_COMPLETE_OK) {
-			sc->sc_gpio_pins[pin].pin_flags = flags;
-		} else {
-			device_printf(sc->sc_dev, "umcpmio_gpio_pin_ctlctl:"
-			" not the command desired, or error: %02x %02x\n",
-			set_sram_res.cmd,
-			set_sram_res.completion);
-			err = EIO;
-		}
+	if (err)
+		goto out;
+
+	umcpmio_dump_buffer(sc->sc_dumpbuffer,
+	(uint8_t *)&set_sram_res, MCP2221_RES_BUFFER_SIZE,
+	"umcpmio_gpio_pin_ctlctl set sram buffer copy");
+	if (set_sram_res.cmd != MCP2221_CMD_SET_SRAM ||
+	set_sram_res.completion != MCP2221_CMD_COMPLETE_OK) {
+		device_printf(sc->sc_dev, "umcpmio_gpio_pin_ctlctl:"
+		" not the command desired, or error: %02x %02x\n",
+		set_sram_res.cmd,
+		set_sram_res.completion);
+		err = EIO;
+		goto out;
 	}
 
+	sc->sc_gpio_pins[pin].pin_flags = flags;
+	err = 0;
+
  out:
 	if (takemutex)
 		mutex_exit(&sc->sc_action_mutex);
@@ -530,25 +533,26 @@ umcpmio_gpio_intr_establish(void *vsc, i
 	set_sram_req.gp3_settings = current_sram_res.gp3_settings;
 	umcpmio_set_gpio_irq_sram(&set_sram_req, irqmode);
 	err = umcpmio_put_sram(sc, &set_sram_req, &set_sram_res, false);
-	if (! err) {
-		umcpmio_dump_buffer(sc->sc_dumpbuffer,
-		(uint8_t *)&set_sram_res, MCP2221_RES_BUFFER_SIZE,
-		"umcpmio_intr_establish set sram buffer copy");
-		if (set_sram_res.cmd == MCP2221_CMD_SET_SRAM &&
-		set_sram_res.completion == MCP2221_CMD_COMPLETE_OK) {
-			sc->sc_gpio_pins[1].pin_flags = GPIO_PIN_ALT2;
-		} else {
-			device_printf(sc->sc_dev, "umcpmio_intr_establish:"
-			" not the command desired, or error: %02x %02x\n",
-			set_sram_res.cmd,
-			set_sram_res.completion);
-		}
-	} else {
+	if (err) {
 		device_printf(sc->sc_dev, "umcpmio_intr_establish:"
 		" set sram error: err=%d\n",
 		err);
+		goto out;
+	}
+	umcpmio_dump_buffer(sc->sc_dumpbuffer,
+	(uint8_t *)&set_sram_res, MCP2221_RES_BUFFER_SIZE,
+	"umcpmio_intr_establish set sram buffer copy");
+	if (set_sram_res.cmd != MCP2221_CMD_SET_SRAM ||
+	set_sram_res.completion != MCP2221_CMD_COMPLETE_OK) {
+		device_printf(sc->sc_dev, "umcpmio_intr_establish:"
+		" not the command desired, or error: %02x %02x\n",
+		set_sram_res.cmd,
+		set_sram_res.completion);
+		goto out;
 	}
 
+	sc->sc_gpio_pins[1].pin_flags = GPIO_PIN_ALT2;
+
  out:
 	mutex_exit(&sc->sc_action_mutex);
 
@@ -581,24 +585,27 @@ umcpmio_gpio_intr_disestablish(void *vsc
 	set_sram_req.gp3_settings = current_sram_res.gp3_settings;
 	umcpmio_set_gpio_irq_sram(&set_sram_req, 0);
 	err = umcpmio_put_sram(sc, &set_sram_req, &set_sram_res, true);
-	if (! err) {
-		umcpmio_dump_buffer(sc->sc_dumpbuffer,
-		(uint8_t *)&set_sram_res, MCP2221_RES_BUFFER_SIZE,
-		"umcpmio_intr_disestablish set sram buffer copy");
-		if (set_sram_res.cmd == MCP2221_CMD_SET_SRAM &&
-		set_sram_res.completion == MCP2221_CMD_COMPLETE_OK) {
-			sc->sc_gpio_pins[1].pin_flags = GPIO_PIN_INPUT;
-		} else {
-			device_printf(sc->sc_dev, "umcpmio_intr_disestablish:"
-			" not the command desired, or error: %02x %02x\n",
-			set_sram_res.cmd,
-	

CVS commit: src/sys/dev/usb

2025-03-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 25 20:38:54 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c

Log Message:
umcpmio(4): Omit needless boolean `takemutex' parameter.

This is generally a questionable pattern and it's wholly unnecessary
here.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/umcpmio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 25 20:38:27 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c umcpmio_subr.c

Log Message:
umcpmio(4): Linearize error branch structure.

This dramatically reduces the unnecessary indentation of success
cases and puts error messages adjacent to the conditions they report.

Rewriting it this way reveals that two of the error branches in
umcpmio_dev_read are probably wrong -- should probably break out of
the loop, not continue it.  To be fixed in a separate commit.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/umcpmio.c \
src/sys/dev/usb/umcpmio_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 25 20:38:54 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c

Log Message:
umcpmio(4): Omit needless boolean `takemutex' parameter.

This is generally a questionable pattern and it's wholly unnecessary
here.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/umcpmio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/umcpmio.c
diff -u src/sys/dev/usb/umcpmio.c:1.3 src/sys/dev/usb/umcpmio.c:1.4
--- src/sys/dev/usb/umcpmio.c:1.3	Tue Mar 25 20:38:27 2025
+++ src/sys/dev/usb/umcpmio.c	Tue Mar 25 20:38:54 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: umcpmio.c,v 1.3 2025/03/25 20:38:27 riastradh Exp $	*/
+/*	$NetBSD: umcpmio.c,v 1.4 2025/03/25 20:38:54 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2024 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.3 2025/03/25 20:38:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.4 2025/03/25 20:38:54 riastradh Exp $");
 
 /*
  * Driver for the Microchip MCP2221 / MCP2221A USB multi-io chip
@@ -348,7 +348,7 @@ umcpmio_gpio_pin_write(void *arg, int pi
  */
 
 static int
-umcpmio_gpio_pin_ctlctl(void *arg, int pin, int flags, bool takemutex)
+umcpmio_gpio_pin_ctlctl(void *arg, int pin, int flags)
 {
 	struct umcpmio_softc *sc = arg;
 	struct mcp2221_set_sram_req set_sram_req;
@@ -360,8 +360,7 @@ umcpmio_gpio_pin_ctlctl(void *arg, int p
 	if (sc->sc_dying)
 		return 0;
 
-	if (takemutex)
-		mutex_enter(&sc->sc_action_mutex);
+	KASSERT(mutex_owned(&sc->sc_action_mutex));
 
 	err = umcpmio_get_sram(sc, ¤t_sram_res, false);
 	if (err)
@@ -475,9 +474,6 @@ umcpmio_gpio_pin_ctlctl(void *arg, int p
 	err = 0;
 
  out:
-	if (takemutex)
-		mutex_exit(&sc->sc_action_mutex);
-
 	return err;
 }
 
@@ -489,7 +485,9 @@ umcpmio_gpio_pin_ctl(void *arg, int pin,
 	if (sc->sc_dying)
 		return;
 
-	umcpmio_gpio_pin_ctlctl(sc, pin, flags, true);
+	mutex_enter(&sc->sc_action_mutex);
+	umcpmio_gpio_pin_ctlctl(sc, pin, flags);
+	mutex_exit(&sc->sc_action_mutex);
 }
 
 /*
@@ -1177,13 +1175,13 @@ umcpmio_dev_open(dev_t dev, int flags, i
 		 */
 		if (flags & FREAD) {
 			error = umcpmio_gpio_pin_ctlctl(sc, pin,
-			GPIO_PIN_ALT0, false);
+			GPIO_PIN_ALT0);
 		} else {
 			if (pin == 1) {
 error = EINVAL;
 			} else {
 error = umcpmio_gpio_pin_ctlctl(sc,
-pin, GPIO_PIN_ALT1, false);
+pin, GPIO_PIN_ALT1);
 			}
 		}
 	}
@@ -1334,8 +1332,7 @@ umcpmio_dev_close(dev_t dev, int flags, 
 		 * maybe the gpio config and save out what the
 		 * pin was set to.
 		 */
-		error = umcpmio_gpio_pin_ctlctl(sc, pin,
-		GPIO_PIN_INPUT, false);
+		error = umcpmio_gpio_pin_ctlctl(sc, pin, GPIO_PIN_INPUT);
 	}
 out:
 	sc->sc_dev_open[dunit] = false;



Re: CVS commit: src/sys/dev/usb

2025-03-25 Thread Taylor R Campbell
> Module Name:src
> Committed By:   hans
> Date:   Sun Mar 23 12:07:24 UTC 2025
> 
> Modified Files:
> src/sys/dev/usb: uts.c
> 
> Log Message:
> uts(4): make sure the device is enabled before calling uhidev_close()
> 
> This check was already there, but only enabled for DIAGNOSTIC kernels.
> The check and early return is always needed, but the message should only
> be printed in DIAGNOSTIC kernels.
> 
> Fixes PR kern/59206
> 
> + if (!sc->sc_enabled) {
>  #ifdef DIAGNOSTIC
> - if (!sc->sc_enabled) {
>   printf("uts_disable: not enabled\n");
> +#endif
>   return;
>   }
> -#endif

Thanks for taking a look at this!  This change is not quite enough,
though.  There are two issues:

1. `#ifdef DIAGNOSTIC printf(...)' is almost always wrong.  Generally,
   either:

   (a) the condition should be KASSERTed, or
   (b) the condition should be quietly handled both ways.

   It's not a priori clear in all places where we currently have buggy
   #ifdef DIAGNOSTIC printfs branches which case applies.

2. uts_enable has this questionable logic:

sc->sc_enabled = 1;
...
return uhidev_open(sc->sc_hdev, &uts_intr, sc);

   Note that this _always_ sets sc_enabled, even if uhidev_open fails!
   This logic should almost certainly instead be:

error = uhidev_open(...);
if (error)
return error;
sc->sc_enabled = 1;
return 0;

Now what I'm not sure about is whether a _failed_ uts_enable call will
be followed by a uts_disable call.  This is a (possibly unwritten)
part of the struct wsmouse_accessops contract; the wsmouse(9) man page
doesn't say one way or another, though.

If wsmouse(9) guarantees that after a _failed_ enable call, it will
never call disable, then we can (and should) dispense with the
sc_enabled bit altogether and prune all the dead branches.  (This is
preferable: less code in multiple drivers, fewer states to consider,
fewer conditionals to exercise.)

If wsmouse(9) doesn't guarantee this, then we need to keep the extra
state in all the drivers, but there's no reason to have each one print
noise to the console about it.

(Either way, we should update the wsmouse(9) man page to spell out
what is or isn't guaranteed.)


CVS commit: src/sys/dev/usb

2025-03-25 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Tue Mar 25 10:37:39 UTC 2025

Modified Files:
src/sys/dev/usb: ums.c

Log Message:
ums(4): remove redundant check for sc_enabled


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/ums.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ums.c
diff -u src/sys/dev/usb/ums.c:1.107 src/sys/dev/usb/ums.c:1.108
--- src/sys/dev/usb/ums.c:1.107	Sun Mar 23 12:08:13 2025
+++ src/sys/dev/usb/ums.c	Tue Mar 25 10:37:39 2025
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: ums.c,v 1.107 2025/03/23 12:08:13 hans Exp $	*/
+/*	$NetBSD: ums.c,v 1.108 2025/03/25 10:37:39 hans Exp $	*/
 
 /*
  * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.107 2025/03/23 12:08:13 hans Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.108 2025/03/25 10:37:39 hans Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -383,11 +383,9 @@ ums_disable(void *v)
 		return;
 	}
 
-	if (sc->sc_enabled) {
-		sc->sc_enabled = 0;
-		if (!sc->sc_alwayson)
-			uhidev_close(sc->sc_hdev);
-	}
+	sc->sc_enabled = 0;
+	if (!sc->sc_alwayson)
+		uhidev_close(sc->sc_hdev);
 }
 
 Static int



CVS commit: src/sys/dev/usb

2025-03-25 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Tue Mar 25 10:37:39 UTC 2025

Modified Files:
src/sys/dev/usb: ums.c

Log Message:
ums(4): remove redundant check for sc_enabled


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/usb/ums.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/dev/usb

2025-03-25 Thread Hans Rosenfeld
On Tue, Mar 25, 2025 at 06:42:38PM +1100, matthew green wrote:
> hm.  does this really change anything?

You're right. I missed that the ums.c code is a bit different from
uts.c and doesn't suffer from the same panic-inducing problem.

> i've had a couple of crashes near here recently and i haven't been
> able to understand them (or reproduce easily, with USBHIST), so i
> was thinking this might help me, but unless i've missed something
> above, this doesn't actually change behaviour.  the issue in uts.c
> does appear to have been a real problem, perhaps because it didn't
> have the 2nd if() that ums_disable() currently does.

Yes, uts_disable() was causing kern/59206 because of this. A friend of
mine wanted to try 10.1 on his slightly outdated Thinkpad an ran into
this immediately, which is why I tried to find the issue and fix it for
them.

> (note: the second if() could be removed now, since it will always
> be true if the code gets to this point.  oh, which makes it like
> the uts.c version.)

Will do.

Hans


-- 
%SYSTEM-F-ANARCHISM, The operating system has been overthrown


re: CVS commit: src/sys/dev/usb

2025-03-25 Thread matthew green
"Hans Rosenfeld" writes:
> Module Name:  src
> Committed By: hans
> Date: Sun Mar 23 12:08:13 UTC 2025
>
> Modified Files:
>   src/sys/dev/usb: ums.c
>
> Log Message:
> ums(4): make sure the device is enabled before calling uhidev_close()
>
> Same issue as in uts(4), his check was already there, but only enabled
> for DIAGNOSTIC kernels.  The check and early return are always needed,
> but the message should only be printed in DIAGNOSTIC kernels.

hm.  does this really change anything?

---
Static void
ums_disable(void *v)
{
struct ums_softc *sc = v;

UMSHIST_FUNC(); UMSHIST_CALLARGS("sc=%jx\n", (uintptr_t)sc, 0, 0, 0);

if (!sc->sc_enabled) {
#ifdef DIAGNOSTIC
printf("ums_disable: not enabled\n");
#endif
return;
}

if (sc->sc_enabled) {
sc->sc_enabled = 0;
if (!sc->sc_alwayson)
uhidev_close(sc->sc_hdev);
}
}
---

whether the DIAGNOSTIC check covers the return or not, in the case
it isn't enabled, it should end up doing nothing anyway?  eg, there
are two cases to handle:

1 - sc_enabled set.  the first if() is skipped, and the second if()
is entered, enabled cleared, and maybe close device if open.
2 - sc_enabled not set.  if the first if() is not there at all,
then the second if() will fail, and nothing happens.  if the
first if() is there, nothing happens.

i've had a couple of crashes near here recently and i haven't been
able to understand them (or reproduce easily, with USBHIST), so i
was thinking this might help me, but unless i've missed something
above, this doesn't actually change behaviour.  the issue in uts.c
does appear to have been a real problem, perhaps because it didn't
have the 2nd if() that ums_disable() currently does.

(note: the second if() could be removed now, since it will always
be true if the code gets to this point.  oh, which makes it like
the uts.c version.)

thanks.


.mrg.


CVS commit: src/sys/dev/usb

2025-03-23 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Sun Mar 23 12:08:13 UTC 2025

Modified Files:
src/sys/dev/usb: ums.c

Log Message:
ums(4): make sure the device is enabled before calling uhidev_close()

Same issue as in uts(4), his check was already there, but only enabled
for DIAGNOSTIC kernels.  The check and early return are always needed,
but the message should only be printed in DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/ums.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-23 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Sun Mar 23 12:08:13 UTC 2025

Modified Files:
src/sys/dev/usb: ums.c

Log Message:
ums(4): make sure the device is enabled before calling uhidev_close()

Same issue as in uts(4), his check was already there, but only enabled
for DIAGNOSTIC kernels.  The check and early return are always needed,
but the message should only be printed in DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/usb/ums.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ums.c
diff -u src/sys/dev/usb/ums.c:1.106 src/sys/dev/usb/ums.c:1.107
--- src/sys/dev/usb/ums.c:1.106	Mon Mar 18 15:15:27 2024
+++ src/sys/dev/usb/ums.c	Sun Mar 23 12:08:13 2025
@@ -1,4 +1,5 @@
-/*	$NetBSD: ums.c,v 1.106 2024/03/18 15:15:27 jakllsch Exp $	*/
+
+/*	$NetBSD: ums.c,v 1.107 2025/03/23 12:08:13 hans Exp $	*/
 
 /*
  * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -35,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.106 2024/03/18 15:15:27 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.107 2025/03/23 12:08:13 hans Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -375,12 +376,12 @@ ums_disable(void *v)
 
 	UMSHIST_FUNC(); UMSHIST_CALLARGS("sc=%jx\n", (uintptr_t)sc, 0, 0, 0);
 
-#ifdef DIAGNOSTIC
 	if (!sc->sc_enabled) {
+#ifdef DIAGNOSTIC
 		printf("ums_disable: not enabled\n");
+#endif
 		return;
 	}
-#endif
 
 	if (sc->sc_enabled) {
 		sc->sc_enabled = 0;



CVS commit: src/sys/dev/usb

2025-03-23 Thread Hans Rosenfeld
Module Name:src
Committed By:   hans
Date:   Sun Mar 23 12:07:24 UTC 2025

Modified Files:
src/sys/dev/usb: uts.c

Log Message:
uts(4): make sure the device is enabled before calling uhidev_close()

This check was already there, but only enabled for DIAGNOSTIC kernels.
The check and early return is always needed, but the message should only
be printed in DIAGNOSTIC kernels.

Fixes PR kern/59206


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/uts.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 17 18:24:08 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c umcpmio.h umcpmio_hid_reports.h umcpmio_io.h
umcpmio_subr.c umcpmio_subr.h

Log Message:
umcpmio(4): Fix a lot of KNF issues.

- Space after comma.
- Space between _keyword_ and parentheses: `for (...)'
- No space between _function_ and parentheses: `foo(...)'.
- Space around assignment operators: `x = y', not `x=y'.
- Space after semicolons: `for (x = 0; x < n; x++)'
- Break overlong lines.
- Sort includes.
- `do { ... } while (0)' in statement macros.
- Parenthesize macro arguments (or just use functions if macros
  aren't necessary).
- No parentheses needed for `return': say `return EINVAL;', not
  `return (EINVAL);' (but parenthesizing complex expressions is
  fine).
- Various other things.

/*
 * block comments like this
 */

Please, folks, read through /usr/share/misc/style and try to adhere to
it _before_ committing.  There's also an Emacs C style in
/usr/share/misc/NetBSD.el and a clang-format configuration in
/usr/share/misc/dot.clang-format to help you.

Aside from KNF, I strongly encourage you to write:

error = foo();
if (error)
goto out;
error = bar();
if (error)
goto out;
...

instead of

error = foo();
if (!error) {
error = bar();
if (!error) {
...
} else {
printf("error in bar\n");
}
} else {
printf("error in foo\n");
}

It's hard to follow _both_ the success cases _and_ the failure cases
when the success cases grow progressively more deeply indented, and the
failure cases are farther and farther away from the logic handling them
as you have more conditions.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/umcpmio.c src/sys/dev/usb/umcpmio.h \
src/sys/dev/usb/umcpmio_hid_reports.h src/sys/dev/usb/umcpmio_io.h \
src/sys/dev/usb/umcpmio_subr.c src/sys/dev/usb/umcpmio_subr.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 17 18:24:08 UTC 2025

Modified Files:
src/sys/dev/usb: umcpmio.c umcpmio.h umcpmio_hid_reports.h umcpmio_io.h
umcpmio_subr.c umcpmio_subr.h

Log Message:
umcpmio(4): Fix a lot of KNF issues.

- Space after comma.
- Space between _keyword_ and parentheses: `for (...)'
- No space between _function_ and parentheses: `foo(...)'.
- Space around assignment operators: `x = y', not `x=y'.
- Space after semicolons: `for (x = 0; x < n; x++)'
- Break overlong lines.
- Sort includes.
- `do { ... } while (0)' in statement macros.
- Parenthesize macro arguments (or just use functions if macros
  aren't necessary).
- No parentheses needed for `return': say `return EINVAL;', not
  `return (EINVAL);' (but parenthesizing complex expressions is
  fine).
- Various other things.

/*
 * block comments like this
 */

Please, folks, read through /usr/share/misc/style and try to adhere to
it _before_ committing.  There's also an Emacs C style in
/usr/share/misc/NetBSD.el and a clang-format configuration in
/usr/share/misc/dot.clang-format to help you.

Aside from KNF, I strongly encourage you to write:

error = foo();
if (error)
goto out;
error = bar();
if (error)
goto out;
...

instead of

error = foo();
if (!error) {
error = bar();
if (!error) {
...
} else {
printf("error in bar\n");
}
} else {
printf("error in foo\n");
}

It's hard to follow _both_ the success cases _and_ the failure cases
when the success cases grow progressively more deeply indented, and the
failure cases are farther and farther away from the logic handling them
as you have more conditions.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/umcpmio.c src/sys/dev/usb/umcpmio.h \
src/sys/dev/usb/umcpmio_hid_reports.h src/sys/dev/usb/umcpmio_io.h \
src/sys/dev/usb/umcpmio_subr.c src/sys/dev/usb/umcpmio_subr.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/umcpmio.c
diff -u src/sys/dev/usb/umcpmio.c:1.1 src/sys/dev/usb/umcpmio.c:1.2
--- src/sys/dev/usb/umcpmio.c:1.1	Mon Dec 16 16:37:38 2024
+++ src/sys/dev/usb/umcpmio.c	Mon Mar 17 18:24:08 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: umcpmio.c,v 1.1 2024/12/16 16:37:38 brad Exp $	*/
+/*	$NetBSD: umcpmio.c,v 1.2 2025/03/17 18:24:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2024 Brad Spencer 
@@ -17,49 +17,52 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.1 2024/12/16 16:37:38 brad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umcpmio.c,v 1.2 2025/03/17 18:24:08 riastradh Exp $");
 
 /*
-  Driver for the Microchip MCP2221 / MCP2221A USB multi-io chip
-*/
+ * Driver for the Microchip MCP2221 / MCP2221A USB multi-io chip
+ */
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
 #endif
 
 #include 
-#include 
+#include 
+
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
-#include 
 #include 
-#include 
-#include 
 
-#include 
+#include 
+
 #include 
 
-#include 
+#include 
 
+#include 
 #include 
-#include 
-
+#include 
 #include 
 #include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
-#include 
 #include 
 #include 
+#include 
 
-int umcpmio_send_report(struct umcpmio_softc *, uint8_t *, size_t, uint8_t *, int);
+int umcpmio_send_report(struct umcpmio_softc *, uint8_t *, size_t, uint8_t *,
+int);
 
 static const struct usb_devno umcpmio_devs[] = {
 	{ USB_VENDOR_MICROCHIP, USB_PRODUCT_MICROCHIP_MCP2221 },
@@ -78,20 +81,23 @@ static int	umcpmio_verify_gpioclock_cd_s
 
 #define UMCPMIO_DEBUG 1
 #ifdef UMCPMIO_DEBUG
-#define DPRINTF(x)	if (umcpmiodebug) printf x
-#define DPRINTFN(n, x)	if (umcpmiodebug > (n)) printf x
+#define DPRINTF(x)	do { if (umcpmiodebug) printf x; } while (0)
+#define DPRINTFN(n, x)	do { if (umcpmiodebug > (n)) printf x; } while (0)
 int	umcpmiodebug = 0;
 #else
 #define DPRINTF(x)	__nothing
-#define DPRINTFN(n,x)	__nothing
+#define DPRINTFN(n, x)	__nothing
 #endif
 
-
 CFATTACH_DECL_NEW(umcpmio, sizeof(struct umcpmio_softc), umcpmio_match,
 umcpmio_attach, umcpmio_detach, umcpmio_activate);
 
-
-#define WAITMS(ms) if (ms > 0) delay(ms * 1000)
+static void
+WAITMS(int ms)
+{
+	if (ms > 0)
+		delay(ms * 1000);
+}
 
 extern struct cfdriver umcpmio_cd;
 
@@ -100,6 +106,7 @@ static dev_type_read(umcpmio_dev_read);
 static dev_type_write(umcpmio_dev_write);
 static dev_type_close(umcpmio_dev_close);
 static dev_type_ioctl(umcpmio_dev_ioctl);
+
 const struct cdevsw umcpmio_cdevsw = {
 	.d_open = umcpmio_dev_open,
 	.d_close = umcpmio_dev_close,
@@ -115,7 +122,6 @@ const struct cdevsw umcpmio_cdevsw = {
 	.d_flag = D_OTHER
 };
 
-
 static const char umcpmio

CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:31:37 UTC 2025

Modified Files:
src/sys/dev/usb: uslsareg.h

Log Message:
uslsa: add additional request IDs from datasheet


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/uslsareg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uslsareg.h
diff -u src/sys/dev/usb/uslsareg.h:1.1 src/sys/dev/usb/uslsareg.h:1.2
--- src/sys/dev/usb/uslsareg.h:1.1	Sat Jan 14 21:06:01 2012
+++ src/sys/dev/usb/uslsareg.h	Sun Feb 16 18:31:37 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: uslsareg.h,v 1.1 2012/01/14 21:06:01 jakllsch Exp $ */
+/* $NetBSD: uslsareg.h,v 1.2 2025/02/16 18:31:37 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2011 Jonathan A. Kollasch.
@@ -60,6 +60,9 @@
 #define SLSA_R_SET_FLOW		0x13
 #define SLSA_R_GET_FLOW		0x14
 #define SLSA_R_EMBED_EVENTS	0x15
+#define SLSA_R_GET_EVENTSTATE	0x16
+#define SLSA_R_SET_RECEIVE	0x17
+#define SLSA_R_GET_RECEIVE	0x18
 #define SLSA_R_SET_CHARS	0x19
 #define SLSA_R_GET_BAUDRATE	0x1d
 #define SLSA_R_SET_BAUDRATE	0x1e



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:31:37 UTC 2025

Modified Files:
src/sys/dev/usb: uslsareg.h

Log Message:
uslsa: add additional request IDs from datasheet


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/uslsareg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:30:28 UTC 2025

Modified Files:
src/sys/dev/usb: uslsa.c

Log Message:
uslsa: match another SiLabs device ID


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/uslsa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uslsa.c
diff -u src/sys/dev/usb/uslsa.c:1.32 src/sys/dev/usb/uslsa.c:1.33
--- src/sys/dev/usb/uslsa.c:1.32	Fri Jul 29 13:07:14 2022
+++ src/sys/dev/usb/uslsa.c	Sun Feb 16 18:30:28 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: uslsa.c,v 1.32 2022/07/29 13:07:14 rin Exp $ */
+/* $NetBSD: uslsa.c,v 1.33 2025/02/16 18:30:28 jakllsch Exp $ */
 
 /* from ugensa.c */
 
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uslsa.c,v 1.32 2022/07/29 13:07:14 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uslsa.c,v 1.33 2025/02/16 18:30:28 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -138,6 +138,7 @@ static const struct usb_devno uslsa_devs
 { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_POLOLU },
 { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_1 },
 { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_2 },
+{ USB_VENDOR_SILABS,USB_PRODUCT_SILABS_CP210X_3 },
 { USB_VENDOR_SILABS,USB_PRODUCT_SILABS_SUNNTO },
 { USB_VENDOR_SILABS2,   USB_PRODUCT_SILABS2_DCU11CLONE },
 { USB_VENDOR_USI,   USB_PRODUCT_USI_MC60 },



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:30:28 UTC 2025

Modified Files:
src/sys/dev/usb: uslsa.c

Log Message:
uslsa: match another SiLabs device ID


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/usb/uslsa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:29:54 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
re-generate


To generate a diff of this commit:
cvs rdiff -u -r1.811 -r1.812 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:29:54 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
re-generate


To generate a diff of this commit:
cvs rdiff -u -r1.811 -r1.812 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.811 src/sys/dev/usb/usbdevs.h:1.812
--- src/sys/dev/usb/usbdevs.h:1.811	Thu Jan 23 07:12:12 2025
+++ src/sys/dev/usb/usbdevs.h	Sun Feb 16 18:29:53 2025
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.811 2025/01/23 07:12:12 mrg Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.812 2025/02/16 18:29:53 jakllsch Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.819 2025/01/23 07:11:27 mrg Exp
+ *	NetBSD: usbdevs,v 1.820 2025/02/16 18:28:29 jakllsch Exp
  */
 
 /*-
@@ -3200,6 +3200,7 @@
 #define	USB_PRODUCT_SILABS2_DCU11CLONE	0xaa26		/* DCU-11 clone */
 #define	USB_PRODUCT_SILABS_CP210X_1	0xea60		/* CP210x Serial */
 #define	USB_PRODUCT_SILABS_CP210X_2	0xea61		/* CP210x Serial */
+#define	USB_PRODUCT_SILABS_CP210X_3	0xea70		/* CP210x Serial */
 #define	USB_PRODUCT_SILABS_EC3	0x8044		/* EC3 USB Debug Adapter */
 
 /* Silicon Portals Inc. */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.811 src/sys/dev/usb/usbdevs_data.h:1.812
--- src/sys/dev/usb/usbdevs_data.h:1.811	Thu Jan 23 07:12:12 2025
+++ src/sys/dev/usb/usbdevs_data.h	Sun Feb 16 18:29:53 2025
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.811 2025/01/23 07:12:12 mrg Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.812 2025/02/16 18:29:53 jakllsch Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.819 2025/01/23 07:11:27 mrg Exp
+ *	NetBSD: usbdevs,v 1.820 2025/02/16 18:28:29 jakllsch Exp
  */
 
 /*-
@@ -4395,6 +4395,8 @@ static const uint32_t usb_products[] = {
 	18848, 7044, 0,
 	USB_VENDOR_SILABS, USB_PRODUCT_SILABS_CP210X_2, 
 	18848, 7044, 0,
+	USB_VENDOR_SILABS, USB_PRODUCT_SILABS_CP210X_3, 
+	18848, 7044, 0,
 	USB_VENDOR_SILABS, USB_PRODUCT_SILABS_EC3, 
 	18855, 4968, 18859, 4982, 0,
 	USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPH_NF, 
@@ -6058,7 +6060,7 @@ static const char usb_words[] = { "." 
 	"Parallel\0" /* 5 refs @ 7020 */
 	"printer\0" /* 6 refs @ 7029 */
 	"10Mbps\0" /* 3 refs @ 7037 */
-	"Serial\0" /* 37 refs @ 7044 */
+	"Serial\0" /* 38 refs @ 7044 */
 	"UC210T\0" /* 1 refs @ 7051 */
 	"UC2324\0" /* 1 refs @ 7058 */
 	"DSB-650C\0" /* 1 refs @ 7065 */
@@ -7622,7 +7624,7 @@ static const char usb_words[] = { "." 
 	"HARP-1\0" /* 1 refs @ 18828 */
 	"DCU-11\0" /* 1 refs @ 18835 */
 	"clone\0" /* 1 refs @ 18842 */
-	"CP210x\0" /* 2 refs @ 18848 */
+	"CP210x\0" /* 3 refs @ 18848 */
 	"EC3\0" /* 1 refs @ 18855 */
 	"Debug\0" /* 1 refs @ 18859 */
 	"YAP\0" /* 2 refs @ 18865 */



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:28:29 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
usbdevs: add another SiLabs serial adapter ID


To generate a diff of this commit:
cvs rdiff -u -r1.819 -r1.820 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:28:29 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
usbdevs: add another SiLabs serial adapter ID


To generate a diff of this commit:
cvs rdiff -u -r1.819 -r1.820 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.819 src/sys/dev/usb/usbdevs:1.820
--- src/sys/dev/usb/usbdevs:1.819	Thu Jan 23 07:11:27 2025
+++ src/sys/dev/usb/usbdevs	Sun Feb 16 18:28:29 2025
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.819 2025/01/23 07:11:27 mrg Exp $
+$NetBSD: usbdevs,v 1.820 2025/02/16 18:28:29 jakllsch Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -3193,6 +3193,7 @@ product SILABS LIPOWSKY_HARP	0x8218	Lipo
 product SILABS2 DCU11CLONE	0xaa26	DCU-11 clone
 product SILABS CP210X_1		0xea60	CP210x Serial
 product SILABS CP210X_2		0xea61	CP210x Serial
+product SILABS CP210X_3		0xea70	CP210x Serial
 product SILABS EC3		0x8044	EC3 USB Debug Adapter
 
 /* Silicon Portals Inc. */



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:24:41 UTC 2025

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
ehci: wrap long line, add whitespace line to match other similar functions


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.330 src/sys/dev/usb/ehci.c:1.331
--- src/sys/dev/usb/ehci.c:1.330	Sun Feb 16 18:21:19 2025
+++ src/sys/dev/usb/ehci.c	Sun Feb 16 18:24:41 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.330 2025/02/16 18:21:19 jakllsch Exp $ */
+/*	$NetBSD: ehci.c,v 1.331 2025/02/16 18:24:41 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.330 2025/02/16 18:21:19 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.331 2025/02/16 18:24:41 jakllsch Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -4795,7 +4795,8 @@ ehci_device_isoc_transfer(struct usbd_xf
 			xfer->ux_nframes >= (sc->sc_flsize - 4) * 8) {
 		DPRINTF(
 		"isoc descriptor spans entire frametable", 0, 0, 0, 0);
-		printf("ehci: isoc descriptor requested that spans the entire frametable, too many frames\n");
+		printf("ehci: isoc descriptor requested that spans the entire"
+		" frametable, too many frames\n");
 		return USBD_INVAL;
 	}
 
@@ -5029,6 +5030,7 @@ ehci_device_isoc_done(struct usbd_xfer *
 
 	epipe->isoc.cur_xfers--;
 	ehci_remove_itd_chain(sc, exfer->ex_sitdstart);
+
 	if (xfer->ux_length)
 		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
 		isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:24:41 UTC 2025

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
ehci: wrap long line, add whitespace line to match other similar functions


To generate a diff of this commit:
cvs rdiff -u -r1.330 -r1.331 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:21:19 UTC 2025

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
ehci(4): only sync isochronous DMA in the necessary direction


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.329 src/sys/dev/usb/ehci.c:1.330
--- src/sys/dev/usb/ehci.c:1.329	Fri Oct  4 10:25:51 2024
+++ src/sys/dev/usb/ehci.c	Sun Feb 16 18:21:19 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.329 2024/10/04 10:25:51 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.330 2025/02/16 18:21:19 jakllsch Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.329 2024/10/04 10:25:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.330 2025/02/16 18:21:19 jakllsch Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -4397,6 +4397,7 @@ Static usbd_status
 ehci_device_fs_isoc_transfer(struct usbd_xfer *xfer)
 {
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
+	const bool isread = usbd_xfer_isread(xfer);
 	struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
 	struct usbd_device *dev = xfer->ux_pipe->up_dev;
 	struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
@@ -4540,7 +4541,7 @@ ehci_device_fs_isoc_transfer(struct usbd
 
 	if (xfer->ux_length)
 		usb_syncmem(&exfer->ex_xfer.ux_dmabuf, 0, xfer->ux_length,
-		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		isread ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
 	/*
 	 * Part 2: Transfer descriptors have now been set up, now they must
@@ -4638,6 +4639,7 @@ ehci_device_fs_isoc_done(struct usbd_xfe
 	struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
 	struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
+	const bool isread = usbd_xfer_isread(xfer);
 
 	KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -4646,7 +4648,7 @@ ehci_device_fs_isoc_done(struct usbd_xfe
 
 	if (xfer->ux_length)
 		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-		BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
+		isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
 }
 
 /* -- */
@@ -4761,6 +4763,7 @@ Static usbd_status
 ehci_device_isoc_transfer(struct usbd_xfer *xfer)
 {
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
+	const bool isread = usbd_xfer_isread(xfer);
 	struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
 	struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
 	ehci_soft_itd_t *itd, *prev;
@@ -4917,7 +4920,7 @@ ehci_device_isoc_transfer(struct usbd_xf
 
 	if (xfer->ux_length)
 		usb_syncmem(&exfer->ex_xfer.ux_dmabuf, 0, xfer->ux_length,
-		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		isread ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
 	/*
 	 * Part 2: Transfer descriptors have now been set up, now they must
@@ -5020,6 +5023,7 @@ ehci_device_isoc_done(struct usbd_xfer *
 	struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
 	ehci_softc_t *sc = EHCI_XFER2SC(xfer);
 	struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
+	const bool isread = usbd_xfer_isread(xfer);
 
 	KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -5027,5 +5031,5 @@ ehci_device_isoc_done(struct usbd_xfer *
 	ehci_remove_itd_chain(sc, exfer->ex_sitdstart);
 	if (xfer->ux_length)
 		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
-		BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
+		isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
 }



CVS commit: src/sys/dev/usb

2025-02-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 16 18:21:19 UTC 2025

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
ehci(4): only sync isochronous DMA in the necessary direction


To generate a diff of this commit:
cvs rdiff -u -r1.329 -r1.330 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-01-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan 30 10:51:39 UTC 2025

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: Do not clobber existing state in xhci_update_ep0_mps

When updating the MPS field, make sure to preserve existing configuration.
Without this, the XHCI IP on CIX CD8180 was returning a parameter error
in response to the command.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-01-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan 30 10:51:39 UTC 2025

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: Do not clobber existing state in xhci_update_ep0_mps

When updating the MPS field, make sure to preserve existing configuration.
Without this, the XHCI IP on CIX CD8180 was returning a parameter error
in response to the command.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.187 src/sys/dev/usb/xhci.c:1.188
--- src/sys/dev/usb/xhci.c:1.187	Thu Jan 30 00:42:47 2025
+++ src/sys/dev/usb/xhci.c	Thu Jan 30 10:51:39 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.187 2025/01/30 00:42:47 jmcneill Exp $	*/
+/*	$NetBSD: xhci.c,v 1.188 2025/01/30 10:51:39 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.187 2025/01/30 00:42:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.188 2025/01/30 10:51:39 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3446,7 +3446,8 @@ xhci_update_ep0_mps(struct xhci_softc * 
 	cp[1] = htole32(XHCI_INCTX_1_ADD_MASK(XHCI_DCI_EP_CONTROL));
 
 	cp = xhci_slot_get_icv(sc, xs, xhci_dci_to_ici(XHCI_DCI_EP_CONTROL));
-	cp[1] = htole32(XHCI_EPCTX_1_MAXP_SIZE_SET(mps));
+	cp[1] &= ~htole32(XHCI_EPCTX_1_MAXP_SIZE_MASK);
+	cp[1] |= htole32(XHCI_EPCTX_1_MAXP_SIZE_SET(mps));
 
 	/* sync input contexts before they are read from memory */
 	usb_syncmem(&xs->xs_ic_dma, 0, sc->sc_pgsz, BUS_DMASYNC_PREWRITE);



CVS commit: src/sys/dev/usb

2025-01-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 23 07:12:12 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
regen.


To generate a diff of this commit:
cvs rdiff -u -r1.810 -r1.811 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-01-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 23 07:11:27 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add intel gale peak bluetooth 5.4 controller


To generate a diff of this commit:
cvs rdiff -u -r1.818 -r1.819 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.818 src/sys/dev/usb/usbdevs:1.819
--- src/sys/dev/usb/usbdevs:1.818	Wed Nov 27 12:46:37 2024
+++ src/sys/dev/usb/usbdevs	Thu Jan 23 07:11:27 2025
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.818 2024/11/27 12:46:37 brad Exp $
+$NetBSD: usbdevs,v 1.819 2025/01/23 07:11:27 mrg Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1967,6 +1967,7 @@ product INTEL TESTBOARD		0x9890	82930 te
 
 product INTEL2 RMH		0x0020	Rate Matching Hub
 product INTEL2 RMH2		0x0024	Rate Matching Hub
+product INTEL2 GPBT54		0x0036	Gale Peak Bluetooth 5.4
 product INTEL2 RMH3		0x8000	Rate Matching Hub
 product INTEL2 RMH4		0x8001	Rate Matching Hub
 product INTEL2 RMH5		0x8002	Rate Matching Hub



CVS commit: src/sys/dev/usb

2025-01-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 23 07:11:27 UTC 2025

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
add intel gale peak bluetooth 5.4 controller


To generate a diff of this commit:
cvs rdiff -u -r1.818 -r1.819 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-01-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan 18 18:35:47 UTC 2025

Modified Files:
src/sys/dev/usb: if_cdce.c

Log Message:
cdce(4): Update links to spec in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/usb/if_cdce.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_cdce.c
diff -u src/sys/dev/usb/if_cdce.c:1.82 src/sys/dev/usb/if_cdce.c:1.83
--- src/sys/dev/usb/if_cdce.c:1.82	Sat Jul  6 07:09:22 2024
+++ src/sys/dev/usb/if_cdce.c	Sat Jan 18 18:35:47 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cdce.c,v 1.82 2024/07/06 07:09:22 mlelstv Exp $ */
+/*	$NetBSD: if_cdce.c,v 1.83 2025/01/18 18:35:47 riastradh Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul 
@@ -36,11 +36,17 @@
 
 /*
  * USB Communication Device Class (Ethernet Networking Control Model)
- * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
+ *
+ * Originally written for the 1.1 spec at:
+ * https://web.archive.org/web/20140824090418/http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
+ *
+ * Updated 1.2 spec at:
+ * https://web.archive.org/web/20241127002135/https://www.usb.org/document-library/class-definitions-communication-devices-12
+ * https://web.archive.org/web/20240510195654/https://www.usb.org/sites/default/files/CDC1.2_WMC1.1_012011.zip
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.82 2024/07/06 07:09:22 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.83 2025/01/18 18:35:47 riastradh Exp $");
 
 #include 
 



CVS commit: src/sys/dev/usb

2025-01-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan 18 18:35:47 UTC 2025

Modified Files:
src/sys/dev/usb: if_cdce.c

Log Message:
cdce(4): Update links to spec in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/usb/if_cdce.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2025-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan  9 10:17:23 UTC 2025

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: Don't use USBMALLOC_COHERENT

Use normal WB mappings with non-cache coherent tags, will improve
performance and seems to avoid stalling transfers on X1E.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.185 src/sys/dev/usb/xhci.c:1.186
--- src/sys/dev/usb/xhci.c:1.185	Sat Dec 21 07:31:23 2024
+++ src/sys/dev/usb/xhci.c	Thu Jan  9 10:17:22 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.185 2024/12/21 07:31:23 skrll Exp $	*/
+/*	$NetBSD: xhci.c,v 1.186 2025/01/09 10:17:22 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.185 2024/12/21 07:31:23 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.186 2025/01/09 10:17:22 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1515,8 +1515,7 @@ xhci_init(struct xhci_softc *sc)
 	if (sc->sc_maxspbuf != 0) {
 		err = usb_allocmem(sc->sc_bus.ub_dmatag,
 		sizeof(uint64_t) * sc->sc_maxspbuf, sizeof(uint64_t),
-		USBMALLOC_COHERENT | USBMALLOC_ZERO,
-		&sc->sc_spbufarray_dma);
+		USBMALLOC_ZERO, &sc->sc_spbufarray_dma);
 		if (err) {
 			aprint_error_dev(sc->sc_dev,
 			"spbufarray init fail, err %d\n", err);
@@ -1530,8 +1529,7 @@ xhci_init(struct xhci_softc *sc)
 			usb_dma_t * const dma = &sc->sc_spbuf_dma[i];
 			/* allocate contexts */
 			err = usb_allocmem(sc->sc_bus.ub_dmatag, sc->sc_pgsz,
-			sc->sc_pgsz, USBMALLOC_COHERENT | USBMALLOC_ZERO,
-			dma);
+			sc->sc_pgsz, USBMALLOC_ZERO, dma);
 			if (err) {
 aprint_error_dev(sc->sc_dev,
 "spbufarray_dma init fail, err %d\n", err);
@@ -1580,7 +1578,7 @@ xhci_init(struct xhci_softc *sc)
 	KASSERTMSG(size <= (512 * 1024), "eventst size %zu too large", size);
 	align = XHCI_EVENT_RING_SEGMENT_TABLE_ALIGN;
 	err = usb_allocmem(sc->sc_bus.ub_dmatag, size, align,
-	USBMALLOC_COHERENT | USBMALLOC_ZERO, dma);
+	USBMALLOC_ZERO, dma);
 	if (err) {
 		aprint_error_dev(sc->sc_dev, "eventst init fail, err %d\n",
 		err);
@@ -1598,7 +1596,7 @@ xhci_init(struct xhci_softc *sc)
 	KASSERTMSG(size <= 2048, "dcbaa size %zu too large", size);
 	align = XHCI_DEVICE_CONTEXT_BASE_ADDRESS_ARRAY_ALIGN;
 	err = usb_allocmem(sc->sc_bus.ub_dmatag, size, align,
-	USBMALLOC_COHERENT | USBMALLOC_ZERO, dma);
+	USBMALLOC_ZERO, dma);
 	if (err) {
 		aprint_error_dev(sc->sc_dev, "dcbaa init fail, err %d\n", err);
 		rv = ENOMEM;
@@ -3033,7 +3031,7 @@ xhci_ring_init(struct xhci_softc * const
 	DPRINTFN(1, "ring %#jx", (uintptr_t)xr, 0, 0, 0);
 
 	int err = usb_allocmem(sc->sc_bus.ub_dmatag, size, align,
-	USBMALLOC_COHERENT | USBMALLOC_ZERO, &xr->xr_dma);
+	USBMALLOC_ZERO, &xr->xr_dma);
 	if (err) {
 		kmem_free(xr, sizeof(struct xhci_ring));
 		DPRINTFN(1, "alloc xr_dma failed %jd", err, 0, 0, 0);
@@ -3474,7 +3472,7 @@ xhci_init_slot(struct usbd_device *dev, 
 
 	/* allocate contexts */
 	int err = usb_allocmem(sc->sc_bus.ub_dmatag, sc->sc_pgsz, sc->sc_pgsz,
-	USBMALLOC_COHERENT | USBMALLOC_ZERO, &xs->xs_dc_dma);
+	USBMALLOC_ZERO, &xs->xs_dc_dma);
 	if (err) {
 		DPRINTFN(1, "failed to allocmem output device context %jd",
 		err, 0, 0, 0);
@@ -3482,7 +3480,7 @@ xhci_init_slot(struct usbd_device *dev, 
 	}
 
 	err = usb_allocmem(sc->sc_bus.ub_dmatag, sc->sc_pgsz, sc->sc_pgsz,
-	USBMALLOC_COHERENT | USBMALLOC_ZERO, &xs->xs_ic_dma);
+	USBMALLOC_ZERO, &xs->xs_ic_dma);
 	if (err) {
 		DPRINTFN(1, "failed to allocmem input device context %jd",
 		err, 0, 0, 0);



CVS commit: src/sys/dev/usb

2025-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan  9 10:17:23 UTC 2025

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci: Don't use USBMALLOC_COHERENT

Use normal WB mappings with non-cache coherent tags, will improve
performance and seems to avoid stalling transfers on X1E.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 21 07:31:23 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
Relax the KASSERT in xhci_event_cmd to allow xhci_polling_p


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.184 src/sys/dev/usb/xhci.c:1.185
--- src/sys/dev/usb/xhci.c:1.184	Mon May 20 11:36:20 2024
+++ src/sys/dev/usb/xhci.c	Sat Dec 21 07:31:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.185 2024/12/21 07:31:23 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.185 2024/12/21 07:31:23 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2567,7 +2567,7 @@ xhci_event_cmd(struct xhci_softc * const
 
 	XHCIHIST_FUNC(); XHCIHIST_CALLED();
 
-	KASSERT(mutex_owned(&sc->sc_lock));
+	KASSERT(xhci_polling_p(sc) || mutex_owned(&sc->sc_lock));
 
 	trb_0 = le64toh(trb->trb_0);
 	trb_2 = le32toh(trb->trb_2);



CVS commit: src/sys/dev/usb

2024-12-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 21 07:31:23 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
Relax the KASSERT in xhci_event_cmd to allow xhci_polling_p


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-12-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 10 11:21:31 UTC 2024

Modified Files:
src/sys/dev/usb: ukbd.c

Log Message:
We track ENABLED changes, always call uhidev_open/close as necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/dev/usb/ukbd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-12-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 10 11:21:31 UTC 2024

Modified Files:
src/sys/dev/usb: ukbd.c

Log Message:
We track ENABLED changes, always call uhidev_open/close as necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/dev/usb/ukbd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ukbd.c
diff -u src/sys/dev/usb/ukbd.c:1.164 src/sys/dev/usb/ukbd.c:1.165
--- src/sys/dev/usb/ukbd.c:1.164	Sat Sep  2 17:43:16 2023
+++ src/sys/dev/usb/ukbd.c	Tue Dec 10 11:21:30 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: ukbd.c,v 1.164 2023/09/02 17:43:16 riastradh Exp $*/
+/*  $NetBSD: ukbd.c,v 1.165 2024/12/10 11:21:30 mlelstv Exp $*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.164 2023/09/02 17:43:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.165 2024/12/10 11:21:30 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -531,27 +531,26 @@ int
 ukbd_enable(void *v, int on)
 {
 	struct ukbd_softc *sc = v;
+	int error = 0;
 
 	if (on && sc->sc_dying)
 		return EIO;
 
-	/* Should only be called to change state */
-	if ((sc->sc_flags & FLAG_ENABLED) != 0 && on != 0) {
-#ifdef DIAGNOSTIC
-		aprint_error_dev(sc->sc_dev, "bad call on=%d\n", on);
-#endif
-		return EBUSY;
-	}
-
 	DPRINTF(("%s: sc=%p on=%d\n", __func__, sc, on));
 	if (on) {
-		sc->sc_flags |= FLAG_ENABLED;
-		return uhidev_open(sc->sc_hdev, &ukbd_intr, sc);
+		if ((sc->sc_flags & FLAG_ENABLED) == 0) {
+			error = uhidev_open(sc->sc_hdev, &ukbd_intr, sc);
+			if (error == 0)
+sc->sc_flags |= FLAG_ENABLED;
+		}
 	} else {
-		sc->sc_flags &= ~FLAG_ENABLED;
-		uhidev_close(sc->sc_hdev);
-		return 0;
+		if ((sc->sc_flags & FLAG_ENABLED) != 0) {
+			uhidev_close(sc->sc_hdev);
+			sc->sc_flags &= ~FLAG_ENABLED;
+		}
 	}
+
+	return error;
 }
 
 



CVS commit: src/sys/dev/usb

2024-12-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Dec  5 21:59:11 UTC 2024

Modified Files:
src/sys/dev/usb: xhcireg.h

Log Message:
s/Foce/Force/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/xhcireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhcireg.h
diff -u src/sys/dev/usb/xhcireg.h:1.24 src/sys/dev/usb/xhcireg.h:1.25
--- src/sys/dev/usb/xhcireg.h:1.24	Sat Feb 10 09:21:53 2024
+++ src/sys/dev/usb/xhcireg.h	Thu Dec  5 21:59:11 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: xhcireg.h,v 1.24 2024/02/10 09:21:53 andvar Exp $ */
+/* $NetBSD: xhcireg.h,v 1.25 2024/12/05 21:59:11 andvar Exp $ */
 
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
@@ -103,7 +103,7 @@
 #define XHCI_HCCPARAMS2		0x1c	/* RO capability parameters 2 */
 #define	 XHCI_HCC2_U3C(x)	__SHIFTOUT((x), __BIT(0))	/* U3 Entry capable */
 #define	 XHCI_HCC2_CMC(x)	__SHIFTOUT((x), __BIT(1))	/* CEC MaxExLatTooLg */
-#define	 XHCI_HCC2_FSC(x)	__SHIFTOUT((x), __BIT(2))	/* Foce Save Context */
+#define	 XHCI_HCC2_FSC(x)	__SHIFTOUT((x), __BIT(2))	/* Force Save Context */
 #define	 XHCI_HCC2_CTC(x)	__SHIFTOUT((x), __BIT(3))	/* Compliance Transc */
 #define	 XHCI_HCC2_LEC(x)	__SHIFTOUT((x), __BIT(4))	/* Large ESIT Payload */
 #define	 XHCI_HCC2_CIC(x)	__SHIFTOUT((x), __BIT(5))	/* Configuration Inf */



CVS commit: src/sys/dev/usb

2024-12-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Dec  5 21:59:11 UTC 2024

Modified Files:
src/sys/dev/usb: xhcireg.h

Log Message:
s/Foce/Force/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/usb/xhcireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-11-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Nov 27 12:47:05 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen


To generate a diff of this commit:
cvs rdiff -u -r1.809 -r1.810 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-11-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Nov 27 12:46:37 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add the MCP2221 / MCP2221A multi-io chip


To generate a diff of this commit:
cvs rdiff -u -r1.817 -r1.818 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.817 src/sys/dev/usb/usbdevs:1.818
--- src/sys/dev/usb/usbdevs:1.817	Wed Oct  2 17:15:10 2024
+++ src/sys/dev/usb/usbdevs	Wed Nov 27 12:46:37 2024
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.817 2024/10/02 17:15:10 tsutsui Exp $
+$NetBSD: usbdevs,v 1.818 2024/11/27 12:46:37 brad Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -2360,6 +2360,7 @@ product MSI BLUETOOTH_3		0xa97a	Bluetoot
 product MICROCHIP PICKIT1	0x0032	PICkit(TM) 1 FLASH Starter Kit
 product MICROCHIP PICKIT2	0x0033	PICkit 2 Microcontroller Programmer
 product MICROCHIP PICKIT3	0x900a	PICkit 3 Microcontroller Programmer
+product MICROCHIP MCP2221	0x00dd	USB to I2C/UART Protocol Converter
 
 /* Microdia / Sonix Technology Co., Ltd. products */
 product MICRODIA YUREX		0x1010	YUREX



CVS commit: src/sys/dev/usb

2024-11-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Nov 27 12:46:37 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add the MCP2221 / MCP2221A multi-io chip


To generate a diff of this commit:
cvs rdiff -u -r1.817 -r1.818 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-11-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 10 19:01:25 UTC 2024

Modified Files:
src/sys/dev/usb: if_urtwn.c

Log Message:
if_urtwn.c: Indentation fixes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/usb/if_urtwn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.110 src/sys/dev/usb/if_urtwn.c:1.111
--- src/sys/dev/usb/if_urtwn.c:1.110	Sun Nov 10 11:52:32 2024
+++ src/sys/dev/usb/if_urtwn.c	Sun Nov 10 19:01:25 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.110 2024/11/10 11:52:32 mlelstv Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.111 2024/11/10 19:01:25 riastradh Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.110 2024/11/10 11:52:32 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.111 2024/11/10 19:01:25 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2482,7 +2482,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 		if_statinc(ifp, if_ierrors);
 		return;
 	}
-MCLAIM(m, &sc->sc_ec.ec_rx_mowner);
+	MCLAIM(m, &sc->sc_ec.ec_rx_mowner);
 	if (pktlen > (int)MHLEN) {
 		MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
@@ -2669,7 +2669,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void
 usbd_clear_endpoint_stall_async(pipe);
 			}
 			device_printf(sc->sc_dev, "transmit failed, %s\n",
-			  usbd_errstr(status));
+			usbd_errstr(status));
 			if_statinc(ifp, if_oerrors);
 		}
 		splx(s);
@@ -4840,7 +4840,7 @@ urtwn_init(struct ifnet *ifp)
 
 	/* Init interrupts. */
 	if (ISSET(sc->chip, URTWN_CHIP_88E) ||
-	 ISSET(sc->chip, URTWN_CHIP_92EU)) {
+	ISSET(sc->chip, URTWN_CHIP_92EU)) {
 		urtwn_write_4(sc, R88E_HISR, 0x);
 		urtwn_write_4(sc, R88E_HIMR, R88E_HIMR_CPWM | R88E_HIMR_CPWM2 |
 		R88E_HIMR_TBDER | R88E_HIMR_PSTIMEOUT);



CVS commit: src/sys/dev/usb

2024-11-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 10 19:01:25 UTC 2024

Modified Files:
src/sys/dev/usb: if_urtwn.c

Log Message:
if_urtwn.c: Indentation fixes.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/usb/if_urtwn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 11:53:04 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Add MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.120 src/sys/dev/usb/usbnet.c:1.121
--- src/sys/dev/usb/usbnet.c:1.120	Sat May  4 12:41:03 2024
+++ src/sys/dev/usb/usbnet.c	Sun Nov 10 11:53:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.121 2024/11/10 11:53:04 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.121 2024/11/10 11:53:04 mlelstv Exp $");
 
 #include 
 #include 
@@ -305,6 +305,7 @@ usbnet_enqueue(struct usbnet * const un,
 		if_statinc(ifp, if_ierrors);
 		return;
 	}
+	MCLAIM(m, &unp->unp_ec.ec_rx_mowner);
 
 	m_set_rcvif(m, ifp);
 	m->m_pkthdr.csum_flags = csum_flags;
@@ -334,6 +335,7 @@ usbnet_input(struct usbnet * const un, u
 		if_statinc(ifp, if_ierrors);
 		return;
 	}
+	MCLAIM(m, &unp->unp_ec.ec_rx_mowner);
 
 	m_set_rcvif(m, ifp);
 	memcpy(mtod(m, char *), buf, buflen);



CVS commit: src/sys/dev/usb

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 11:53:04 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Add MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 11:52:32 UTC 2024

Modified Files:
src/sys/dev/usb: if_urtwn.c

Log Message:
Add MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/dev/usb/if_urtwn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.109 src/sys/dev/usb/if_urtwn.c:1.110
--- src/sys/dev/usb/if_urtwn.c:1.109	Wed Feb 28 20:18:13 2024
+++ src/sys/dev/usb/if_urtwn.c	Sun Nov 10 11:52:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.109 2024/02/28 20:18:13 riastradh Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.110 2024/11/10 11:52:32 mlelstv Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.109 2024/02/28 20:18:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.110 2024/11/10 11:52:32 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2482,6 +2482,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 		if_statinc(ifp, if_ierrors);
 		return;
 	}
+MCLAIM(m, &sc->sc_ec.ec_rx_mowner);
 	if (pktlen > (int)MHLEN) {
 		MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {



CVS commit: src/sys/dev/usb

2024-11-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Nov 10 11:52:32 UTC 2024

Modified Files:
src/sys/dev/usb: if_urtwn.c

Log Message:
Add MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/dev/usb/if_urtwn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-08 Thread Lloyd Parkes
Module Name:src
Committed By:   lloyd
Date:   Tue Oct  8 20:40:10 UTC 2024

Modified Files:
src/sys/dev/usb: uftdi.c usbdevices.config

Log Message:
Add a match quirk matching interface 0 on an iCEBreaker FPGA board

This board has an FTDI 2232C with port A (USB interface 0) connected
to the SPI Flash memory for programming and port B (USB interface 1)
connected to the FPGA's serial lines.

The quirk matching was adjusted to use pmatch(9) because the
iCEBreaker product string contains a version number which changes from
time to time.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/uftdi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/usbdevices.config

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uftdi.c
diff -u src/sys/dev/usb/uftdi.c:1.79 src/sys/dev/usb/uftdi.c:1.80
--- src/sys/dev/usb/uftdi.c:1.79	Thu Apr 25 01:33:03 2024
+++ src/sys/dev/usb/uftdi.c	Tue Oct  8 20:40:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $	*/
+/*	$NetBSD: uftdi.c,v 1.80 2024/10/08 20:40:10 lloyd Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.80 2024/10/08 20:40:10 lloyd Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -242,6 +242,20 @@ static const struct uftdi_match_quirk_en
 	  .product_str	= "JTAG Debugger",
 	  .match_ret	= UMATCH_NONE,
 	},
+	/*
+	 * The iCEBreaker board (https://1bitsquared.com/products/icebreaker)
+ * has two interfaces, one of which is meant to act as a
+ * regular USB serial port (interface 1), the other of which
+ * is meant for other protocols.
+	 */
+	{
+	  .vendor_id	= USB_VENDOR_FTDI,
+	  .product_id	= USB_PRODUCT_FTDI_SERIAL_2232C,
+	  .iface_no	= 0,
+	  .vendor_str	= "1BitSquared",
+	  .product_str	= "iCEBreaker *",
+	  .match_ret	= UMATCH_NONE,
+	},
 };
 
 static int
@@ -265,7 +279,7 @@ uftdi_quirk_match(struct usbif_attach_ar
 		}
 		if (q->product_str != NULL &&
 		(dev->ud_product == NULL ||
-		 strcmp(dev->ud_product, q->product_str) != 0)) {
+		 pmatch(dev->ud_product, q->product_str, NULL) != 2)) {
 			continue;
 		}
 		/*

Index: src/sys/dev/usb/usbdevices.config
diff -u src/sys/dev/usb/usbdevices.config:1.43 src/sys/dev/usb/usbdevices.config:1.44
--- src/sys/dev/usb/usbdevices.config:1.43	Tue Mar 26 03:38:02 2024
+++ src/sys/dev/usb/usbdevices.config	Tue Oct  8 20:40:10 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: usbdevices.config,v 1.43 2024/03/26 03:38:02 thorpej Exp $
+#	$NetBSD: usbdevices.config,v 1.44 2024/10/08 20:40:10 lloyd Exp $
 #
 # This file contains all USB related configuration.
 # It is suitable for inclusion in a kernel config(5) file.
@@ -260,9 +260,9 @@ ugenif* at uhub? vendor 0x1050 product 0
 ugenif* at uhub? vendor 0x1050 product 0x0406 configuration 1 interface 1
 ugenif* at uhub? vendor 0x1050 product 0x0407 configuration 1 interface 2
 
-# Tigard debug board (FT2232C-based).  This line is used in conjunction
-# with a match quirk in uftdi.c.  The "flags 1" is important; normally
-# ugenif matches with higest priority, but we don't want that for all
-# FT2232C interfaces, only interfaces that go unclaimed by uftdi (which
-# is what the match quirk ensures).
-ugenif* at uhub? vendor 0x0403 product 0x6010 configuration 1 interface 1 flags 1
+# This line is used in conjunction with a match quirk in uftdi.c.  The
+# "flags 1" is important; normally ugenif matches with higest
+# priority, but we don't want that for all FT2232C interfaces, only
+# interfaces that go unclaimed by uftdi (which is what the match quirk
+# ensures).
+ugenif* at uhub? vendor 0x0403 product 0x6010 configuration 1 interface ? flags 1



CVS commit: src/sys/dev/usb

2024-10-08 Thread Lloyd Parkes
Module Name:src
Committed By:   lloyd
Date:   Tue Oct  8 20:40:10 UTC 2024

Modified Files:
src/sys/dev/usb: uftdi.c usbdevices.config

Log Message:
Add a match quirk matching interface 0 on an iCEBreaker FPGA board

This board has an FTDI 2232C with port A (USB interface 0) connected
to the SPI Flash memory for programming and port B (USB interface 1)
connected to the FPGA's serial lines.

The quirk matching was adjusted to use pmatch(9) because the
iCEBreaker product string contains a version number which changes from
time to time.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/uftdi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/usbdevices.config

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Oct  6 14:08:58 UTC 2024

Modified Files:
src/sys/dev/usb: uhci.c

Log Message:
Simplify/optimize usb_syncmem() in uhci_device_isoc_done()

Matches ohci(4)


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 src/sys/dev/usb/uhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Oct  6 14:08:58 UTC 2024

Modified Files:
src/sys/dev/usb: uhci.c

Log Message:
Simplify/optimize usb_syncmem() in uhci_device_isoc_done()

Matches ohci(4)


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 src/sys/dev/usb/uhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.318 src/sys/dev/usb/uhci.c:1.319
--- src/sys/dev/usb/uhci.c:1.318	Fri Apr  5 18:57:10 2024
+++ src/sys/dev/usb/uhci.c	Sun Oct  6 14:08:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.318 2024/04/05 18:57:10 riastradh Exp $	*/
+/*	$NetBSD: uhci.c,v 1.319 2024/10/06 14:08:58 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.318 2024/04/05 18:57:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.319 2024/10/06 14:08:58 jakllsch Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -3132,7 +3132,6 @@ uhci_device_isoc_done(struct usbd_xfer *
 	uhci_softc_t *sc __diagused = UHCI_XFER2SC(xfer);
 	struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe);
 	struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer);
-	int i, offs;
 	int rd = UE_GET_DIR(upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN;
 
 	UHCIHIST_FUNC(); UHCIHIST_CALLED();
@@ -3164,12 +3163,9 @@ uhci_device_isoc_done(struct usbd_xfer *
 	sizeof(ux->ux_stdend->td.td_status),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
-	offs = 0;
-	for (i = 0; i < xfer->ux_nframes; i++) {
-		usb_syncmem(&xfer->ux_dmabuf, offs, xfer->ux_frlengths[i],
+	if (xfer->ux_length)
+		usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
 		rd ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
-		offs += xfer->ux_frlengths[i];
-	}
 }
 
 void



CVS commit: src/sys/dev/usb

2024-10-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct  4 10:25:51 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
G/C ehci_dump_qh_qtd


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.328 src/sys/dev/usb/ehci.c:1.329
--- src/sys/dev/usb/ehci.c:1.328	Thu Oct  3 12:58:10 2024
+++ src/sys/dev/usb/ehci.c	Fri Oct  4 10:25:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.328 2024/10/03 12:58:10 hannken Exp $ */
+/*	$NetBSD: ehci.c,v 1.329 2024/10/04 10:25:51 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.328 2024/10/03 12:58:10 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.329 2024/10/04 10:25:51 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -294,7 +294,6 @@ void			ehci_dump(void);
 Static void		ehci_dump_regs(ehci_softc_t *);
 Static void		ehci_dump_sqtds(ehci_soft_qtd_t *);
 Static void		ehci_dump_sqtd(ehci_soft_qtd_t *);
-Static void		ehci_dump_qh_qtd(ehci_qtd_t *);
 Static void		ehci_dump_qtd(ehci_qtd_t *);
 Static void		ehci_dump_sqh(ehci_soft_qh_t *);
 Static void		ehci_dump_sitd(struct ehci_soft_itd *);
@@ -1770,23 +1769,6 @@ ehci_dump_sqtd(ehci_soft_qtd_t *sqtd)
 	sizeof(*sqtd->qtd), BUS_DMASYNC_PREREAD);
 }
 
-Static void
-ehci_dump_qh_qtd(ehci_qtd_t *qh_qtd)
-{
-	ehci_qtd_t qtd = {
-		.qtd_next = qh_qtd->qtd_next,
-		.qtd_altnext = qh_qtd->qtd_altnext,
-		.qtd_status = qh_qtd->qtd_status,
-	};
-
-	/* Manually memcpy(), because of volatile. */
-	for (unsigned i = 0; i < EHCI_QTD_NBUFFERS; i++) {
-		qtd.qtd_buffer[i] = qh_qtd->qtd_buffer[i];
-		qtd.qtd_buffer_hi[i] = qh_qtd->qtd_buffer_hi[i];
-	}
-
-	ehci_dump_qtd(&qtd);
-}
 
 Static void
 ehci_dump_qtd(ehci_qtd_t *qtd)
@@ -1864,7 +1846,7 @@ ehci_dump_sqh(ehci_soft_qh_t *sqh)
 	link = le32toh(qh->qh_curqtd);
 	ehci_dump_link(link, false);
 	DPRINTFN(10, "Overlay qTD:", 0, 0, 0, 0);
-	ehci_dump_qh_qtd(&qh->qh_qtd);
+	ehci_dump_qtd(&qh->qh_qtd);
 
 	usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 	BUS_DMASYNC_PREREAD);



CVS commit: src/sys/dev/usb

2024-10-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct  4 10:25:51 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
G/C ehci_dump_qh_qtd


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Oct  3 12:58:10 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Fix fallout from "struct ehci_qh_qtd_t" -> "ehci_qtd_t" conversion.

Kernels ALL/i386 and ALL/amd64 compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.327 src/sys/dev/usb/ehci.c:1.328
--- src/sys/dev/usb/ehci.c:1.327	Mon Sep 23 16:28:06 2024
+++ src/sys/dev/usb/ehci.c	Thu Oct  3 12:58:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.327 2024/09/23 16:28:06 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.328 2024/10/03 12:58:10 hannken Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.327 2024/09/23 16:28:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.328 2024/10/03 12:58:10 hannken Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -294,7 +294,7 @@ void			ehci_dump(void);
 Static void		ehci_dump_regs(ehci_softc_t *);
 Static void		ehci_dump_sqtds(ehci_soft_qtd_t *);
 Static void		ehci_dump_sqtd(ehci_soft_qtd_t *);
-Static void		ehci_dump_qh_qtd(struct ehci_qh_qtd_t *);
+Static void		ehci_dump_qh_qtd(ehci_qtd_t *);
 Static void		ehci_dump_qtd(ehci_qtd_t *);
 Static void		ehci_dump_sqh(ehci_soft_qh_t *);
 Static void		ehci_dump_sitd(struct ehci_soft_itd *);
@@ -1771,7 +1771,7 @@ ehci_dump_sqtd(ehci_soft_qtd_t *sqtd)
 }
 
 Static void
-ehci_dump_qh_qtd(struct ehci_qh_qtd_t *qh_qtd)
+ehci_dump_qh_qtd(ehci_qtd_t *qh_qtd)
 {
 	ehci_qtd_t qtd = {
 		.qtd_next = qh_qtd->qtd_next,



CVS commit: src/sys/dev/usb

2024-10-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Oct  3 12:58:10 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Fix fallout from "struct ehci_qh_qtd_t" -> "ehci_qtd_t" conversion.

Kernels ALL/i386 and ALL/amd64 compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct  2 17:22:45 UTC 2024

Modified Files:
src/sys/dev/usb: udl.c

Log Message:
Add support for SANWA SUPPLY 500-KC002N USB to VGA Adapter.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/usb/udl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct  2 17:22:45 UTC 2024

Modified Files:
src/sys/dev/usb: udl.c

Log Message:
Add support for SANWA SUPPLY 500-KC002N USB to VGA Adapter.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/usb/udl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/udl.c
diff -u src/sys/dev/usb/udl.c:1.34 src/sys/dev/usb/udl.c:1.35
--- src/sys/dev/usb/udl.c:1.34	Sun May  7 12:41:49 2023
+++ src/sys/dev/usb/udl.c	Wed Oct  2 17:22:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: udl.c,v 1.34 2023/05/07 12:41:49 skrll Exp $	*/
+/*	$NetBSD: udl.c,v 1.35 2024/10/02 17:22:45 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2009 FUKAUMI Naoki.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.34 2023/05/07 12:41:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udl.c,v 1.35 2024/10/02 17:22:45 tsutsui Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -335,6 +335,7 @@ static const struct usb_devno udl_devs[]
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LUM70 },
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LCD8000UD_DVI },
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LDEWX015U },
+	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_KC002N },
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_MIMO },
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_PLUGABLE },
 	{ USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LT1421WIDE },



CVS commit: src/sys/dev/usb

2024-10-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct  2 17:17:26 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen from usbdevs rev 1.817:

> Add SANWA SUPPLY 500-KC002N USB to VGA Adapter.


To generate a diff of this commit:
cvs rdiff -u -r1.808 -r1.809 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-10-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct  2 17:15:10 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add SANWA SUPPLY 500-KC002N USB to VGA Adapter.


To generate a diff of this commit:
cvs rdiff -u -r1.816 -r1.817 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.816 src/sys/dev/usb/usbdevs:1.817
--- src/sys/dev/usb/usbdevs:1.816	Sun May 12 17:17:56 2024
+++ src/sys/dev/usb/usbdevs	Wed Oct  2 17:15:10 2024
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.816 2024/05/12 17:17:56 christos Exp $
+$NetBSD: usbdevs,v 1.817 2024/10/02 17:15:10 tsutsui Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1415,6 +1415,7 @@ product DISPLAYLINK SWDVI	0x024c	SUNWEIT
 product DISPLAYLINK LUM70	0x02a9	Lilliput UM-70
 product DISPLAYLINK LCD8000UD_DVI	0x02b8	LCD-8000UD-DVI
 product DISPLAYLINK LDEWX015U	0x02e3	Logitec LDE-WX015U
+product DISPLAYLINK KC002N	0x02ee	SANWA SUPPLY 500-KC002N
 product DISPLAYLINK MIMO	0x0335	DisplayLink MIMO
 product DISPLAYLINK PLUGABLE	0x0377	Plugable docking station
 product DISPLAYLINK LT1421WIDE	0x03e0	Lenovo ThinkVision LT1421 Wide



CVS commit: src/sys/dev/usb

2024-10-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct  2 17:15:10 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs

Log Message:
Add SANWA SUPPLY 500-KC002N USB to VGA Adapter.


To generate a diff of this commit:
cvs rdiff -u -r1.816 -r1.817 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-09-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Sep 23 16:28:06 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Ensure the overlay qtd_buffer{,_hi} fields are zeroised when QHs are
allocated/set. The allocation zeroisation was lost in my last commit.

Minor whitespace tweaks while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-09-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Sep 23 16:28:06 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c

Log Message:
Ensure the overlay qtd_buffer{,_hi} fields are zeroised when QHs are
allocated/set. The allocation zeroisation was lost in my last commit.

Minor whitespace tweaks while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/sys/dev/usb/ehci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.326 src/sys/dev/usb/ehci.c:1.327
--- src/sys/dev/usb/ehci.c:1.326	Mon Sep 23 10:07:26 2024
+++ src/sys/dev/usb/ehci.c	Mon Sep 23 16:28:06 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.326 2024/09/23 10:07:26 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.327 2024/09/23 16:28:06 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.326 2024/09/23 10:07:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.327 2024/09/23 16:28:06 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -615,6 +615,13 @@ ehci_init(ehci_softc_t *sc)
 		sqh->qh->qh_qtd.qtd_next = EHCI_NULL;
 		sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
 		sqh->qh->qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
+
+		ehci_qtd_t *qh_qtd = &sqh->qh->qh_qtd;
+		for (unsigned n = 0; n < EHCI_QTD_NBUFFERS; n++) {
+			qh_qtd->qtd_buffer[n] = 0;
+			qh_qtd->qtd_buffer_hi[n] = 0;
+		}
+
 		sqh->sqtd = NULL;
 		usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 		BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
@@ -649,6 +656,13 @@ ehci_init(ehci_softc_t *sc)
 	sqh->qh->qh_qtd.qtd_next = EHCI_NULL;
 	sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
 	sqh->qh->qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
+
+	ehci_qtd_t *qh_qtd = &sqh->qh->qh_qtd;
+	for (unsigned n = 0; n < EHCI_QTD_NBUFFERS; n++) {
+		qh_qtd->qtd_buffer[n] = 0;
+		qh_qtd->qtd_buffer_hi[n] = 0;
+	}
+
 	sqh->sqtd = NULL;
 	usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
@@ -2075,6 +2089,12 @@ ehci_open(struct usbd_pipe *pipe)
 		sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
 		sqh->qh->qh_qtd.qtd_status = htole32(0);
 
+		ehci_qtd_t *qh_qtd = &sqh->qh->qh_qtd;
+		for (unsigned n = 0; n < EHCI_QTD_NBUFFERS; n++) {
+			qh_qtd->qtd_buffer[n] = 0;
+			qh_qtd->qtd_buffer_hi[n] = 0;
+		}
+
 		usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 		BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 		epipe->sqh = sqh;
@@ -,7 +2242,6 @@ ehci_rem_qh(ehci_softc_t *sc, ehci_soft_
 Static void
 ehci_set_qh_qtd(ehci_soft_qh_t *sqh, ehci_soft_qtd_t *sqtd)
 {
-	int i;
 	uint32_t status;
 
 	/* Save toggle bit and ping status. */
@@ -2241,8 +2260,11 @@ ehci_set_qh_qtd(ehci_soft_qh_t *sqh, ehc
 	sqh->qh->qh_curqtd = 0;
 	sqh->qh->qh_qtd.qtd_next = htole32(sqtd->physaddr);
 	sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
-	for (i = 0; i < EHCI_QTD_NBUFFERS; i++)
-		sqh->qh->qh_qtd.qtd_buffer[i] = 0;
+	for (unsigned n = 0; n < EHCI_QTD_NBUFFERS; n++) {
+		sqh->qh->qh_qtd.qtd_buffer[n] = 0;
+		sqh->qh->qh_qtd.qtd_buffer_hi[n] = 0;
+	}
+
 	sqh->sqtd = sqtd;
 	usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
@@ -2949,6 +2971,7 @@ ehci_alloc_sqh(ehci_softc_t *sc)
 
 	memset(sqh->qh, 0, sizeof(*sqh->qh));
 	sqh->next = NULL;
+
 	return sqh;
 }
 
@@ -3279,8 +3302,8 @@ ehci_alloc_itd(ehci_softc_t *sc)
 	itd = freeitd;
 	LIST_REMOVE(itd, free_list);
 	mutex_exit(&sc->sc_lock);
-	memset(itd->itd, 0, sizeof(*itd->itd));
 
+	memset(itd->itd, 0, sizeof(*itd->itd));
 	itd->frame_list.next = NULL;
 	itd->frame_list.prev = NULL;
 	itd->xfer_next = NULL;
@@ -3342,7 +3365,6 @@ ehci_alloc_sitd(ehci_softc_t *sc)
 	mutex_exit(&sc->sc_lock);
 
 	memset(sitd->sitd, 0, sizeof(*sitd->sitd));
-
 	sitd->frame_list.next = NULL;
 	sitd->frame_list.prev = NULL;
 	sitd->xfer_next = NULL;



CVS commit: src/sys/dev/usb

2024-09-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Sep 23 10:07:27 UTC 2024

Modified Files:
src/sys/dev/usb: ehci.c ehcireg.h ehcivar.h

Log Message:
Allocate a whole cacheline for all the descriptor types used by ehci so
that

 i) they can be alloc'ed without USBMALLOC_COHERENT which can mean they're
 now mapped cacheable, and
ii) the "soft" versions are cacheable, and mapped as small as possible.

A quick test of

dd if=/dev/rsd0 of=/dev/null bs=1m count=1024

improved by approximagely 10% on a Banana PI.


To generate a diff of this commit:
cvs rdiff -u -r1.325 -r1.326 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/usb/ehcireg.h
cvs rdiff -u -r1.52 -r1.53 src/sys/dev/usb/ehcivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.325 src/sys/dev/usb/ehci.c:1.326
--- src/sys/dev/usb/ehci.c:1.325	Fri Apr  5 18:57:10 2024
+++ src/sys/dev/usb/ehci.c	Mon Sep 23 10:07:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.325 2024/04/05 18:57:10 riastradh Exp $ */
+/*	$NetBSD: ehci.c,v 1.326 2024/09/23 10:07:26 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.325 2024/04/05 18:57:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.326 2024/09/23 10:07:26 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -600,22 +600,23 @@ ehci_init(ehci_softc_t *sc)
 		sqh = sc->sc_islots[i].sqh;
 		if (i == 0) {
 			/* The last (1ms) QH terminates. */
-			sqh->qh.qh_link = EHCI_NULL;
+			sqh->qh->qh_link = EHCI_NULL;
 			sqh->next = NULL;
 		} else {
 			/* Otherwise the next QH has half the poll interval */
 			sqh->next = sc->sc_islots[(i + 1) / 2 - 1].sqh;
-			sqh->qh.qh_link = htole32(sqh->next->physaddr |
+			sqh->qh->qh_link = htole32(sqh->next->physaddr |
 			EHCI_LINK_QH);
 		}
-		sqh->qh.qh_endp = htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH));
-		sqh->qh.qh_endphub = htole32(EHCI_QH_SET_MULT(1));
-		sqh->qh.qh_curqtd = EHCI_NULL;
-		sqh->qh.qh_qtd.qtd_next = EHCI_NULL;
-		sqh->qh.qh_qtd.qtd_altnext = EHCI_NULL;
-		sqh->qh.qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
+		sqh->qh->qh_endp = htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH));
+		sqh->qh->qh_endphub = htole32(EHCI_QH_SET_MULT(1));
+		sqh->qh->qh_curqtd = EHCI_NULL;
+
+		sqh->qh->qh_qtd.qtd_next = EHCI_NULL;
+		sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
+		sqh->qh->qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
 		sqh->sqtd = NULL;
-		usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh),
+		usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 		BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 	}
 	/* Point the frame list at the last level (128ms). */
@@ -638,18 +639,18 @@ ehci_init(ehci_softc_t *sc)
 		goto fail3;
 	}
 	/* Fill the QH */
-	sqh->qh.qh_endp =
+	sqh->qh->qh_endp =
 	htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH) | EHCI_QH_HRECL);
-	sqh->qh.qh_link =
+	sqh->qh->qh_link =
 	htole32(sqh->physaddr | EHCI_LINK_QH);
-	sqh->qh.qh_curqtd = EHCI_NULL;
+	sqh->qh->qh_curqtd = EHCI_NULL;
 	sqh->next = NULL;
 	/* Fill the overlay qTD */
-	sqh->qh.qh_qtd.qtd_next = EHCI_NULL;
-	sqh->qh.qh_qtd.qtd_altnext = EHCI_NULL;
-	sqh->qh.qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
+	sqh->qh->qh_qtd.qtd_next = EHCI_NULL;
+	sqh->qh->qh_qtd.qtd_altnext = EHCI_NULL;
+	sqh->qh->qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
 	sqh->sqtd = NULL;
-	usb_syncmem(&sqh->dma, sqh->offs, sizeof(sqh->qh),
+	usb_syncmem(&sqh->dma, sqh->offs, sizeof(*sqh->qh),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 #ifdef EHCI_DEBUG
 	DPRINTFN(5, "--- dump start ---", 0, 0, 0, 0);
@@ -957,12 +958,12 @@ ehci_check_qh_intr(ehci_softc_t *sc, str
 	 */
 	usb_syncmem(&lsqtd->dma,
 	lsqtd->offs + offsetof(ehci_qtd_t, qtd_status),
-	sizeof(lsqtd->qtd.qtd_status),
+	sizeof(lsqtd->qtd->qtd_status),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
-	status = le32toh(lsqtd->qtd.qtd_status);
+	status = le32toh(lsqtd->qtd->qtd_status);
 	usb_syncmem(&lsqtd->dma,
 	lsqtd->offs + offsetof(ehci_qtd_t, qtd_status),
-	sizeof(lsqtd->qtd.qtd_status), BUS_DMASYNC_PREREAD);
+	sizeof(lsqtd->qtd->qtd_status), BUS_DMASYNC_PREREAD);
 	if (status & EHCI_QTD_ACTIVE) {
 		DPRINTFN(10, "active ex=%#jx", (uintptr_t)ex, 0, 0, 0);
 
@@ -970,12 +971,12 @@ ehci_check_qh_intr(ehci_softc_t *sc, str
 		for (sqtd = fsqtd; sqtd != lsqtd; sqtd = sqtd->nextqtd) {
 			usb_syncmem(&sqtd->dma,
 			sqtd->offs + offsetof(ehci_qtd_t, qtd_status),
-			sizeof(sqtd->qtd.qtd_status),
+			sizeof(sqtd->qtd->qtd_status),
 			BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
-			status = le32toh(sqtd->qtd.qtd_status);
+			status = le32toh(sqtd->qtd->qtd_status);
 			usb_syncmem(&sqtd->dma,
 			sqtd->offs + offsetof(ehci_qtd_t, qtd_status),
-			sizeof(sqtd->qtd.qtd_status), BUS_DMASYNC_PRER

CVS commit: src/sys/dev/usb

2024-09-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 22 14:05:47 UTC 2024

Modified Files:
src/sys/dev/usb: ohci.c ohcireg.h ohcivar.h

Log Message:
ohci: Allocate a whole cacheline for all descriptors

Allocate a whole cacheline for all descriptor types such that:

 i) they can be alloc'ed without USBMALLOC_COHERENT which can mean they're
now mapped cacheable, and
ii) the "soft" versions are cacheable, and mapped as small as possible.

Patch/idea mainly from Nick (skrll@) with a few fixes from me.


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/usb/ohcireg.h
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/usb/ohcivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.328 src/sys/dev/usb/ohci.c:1.329
--- src/sys/dev/usb/ohci.c:1.328	Sun Apr 28 08:55:03 2024
+++ src/sys/dev/usb/ohci.c	Sun Sep 22 14:05:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.328 2024/04/28 08:55:03 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.329 2024/09/22 14:05:47 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.328 2024/04/28 08:55:03 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.329 2024/09/22 14:05:47 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -409,19 +409,29 @@ ohci_alloc_sed(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_SED_SIZE * OHCI_SED_CHUNK,
-		OHCI_ED_ALIGN, 0 /*!USBMALLOC_COHERENT*/, &dma);
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		OHCI_ED_SIZE * OHCI_ED_CHUNK,
+		OHCI_ED_ALIGN, 0, &dma);
 		if (err)
 			return NULL;
 
+		ohci_soft_ed_t *seds =
+		kmem_alloc(sizeof(*sed) * OHCI_ED_CHUNK, KM_SLEEP);
+		/*
+		 * We can avoid USBMALLOC_COHERENT as the EDs are each on a
+		 * cacheline.
+		 */
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_SED_CHUNK; i++) {
-			offs = i * OHCI_SED_SIZE;
-			sed = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_ED_CHUNK; i++) {
+			offs = i * OHCI_ED_SIZE;
+
+			sed = &seds[i];
+			sed->ed = KERNADDR(&dma, offs);
 			sed->physaddr = DMAADDR(&dma, offs);
 			sed->dma = dma;
 			sed->offs = offs;
 			sed->next = sc->sc_freeeds;
+
 			sc->sc_freeeds = sed;
 		}
 	}
@@ -429,7 +439,7 @@ ohci_alloc_sed(ohci_softc_t *sc)
 	sc->sc_freeeds = sed->next;
 	mutex_exit(&sc->sc_lock);
 
-	memset(&sed->ed, 0, sizeof(ohci_ed_t));
+	memset(sed->ed, 0, sizeof(*sed->ed));
 	sed->next = 0;
 	return sed;
 }
@@ -467,19 +477,29 @@ ohci_alloc_std(ohci_softc_t *sc)
 		DPRINTFN(2, "allocating chunk", 0, 0, 0, 0);
 		mutex_exit(&sc->sc_lock);
 
-		int err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_STD_SIZE * OHCI_STD_CHUNK,
-		   OHCI_TD_ALIGN, USBMALLOC_COHERENT, &dma);
+		ohci_soft_td_t *stds =
+		kmem_alloc(sizeof(*std) * OHCI_TD_CHUNK, KM_SLEEP);
+		/*
+		 * We can avoid USBMALLOC_COHERENT as the TDs are each on a
+		 * cacheline.
+		 */
+		int err = usb_allocmem(sc->sc_bus.ub_dmatag,
+		OHCI_TD_SIZE * OHCI_TD_CHUNK,
+		OHCI_TD_ALIGN, 0, &dma);
 		if (err)
 			return NULL;
 
 		mutex_enter(&sc->sc_lock);
-		for (i = 0; i < OHCI_STD_CHUNK; i++) {
-			offs = i * OHCI_STD_SIZE;
-			std = KERNADDR(&dma, offs);
+		for (i = 0; i < OHCI_TD_CHUNK; i++) {
+			offs = i * OHCI_TD_SIZE;
+
+			std = &stds[i];
+			std->td = KERNADDR(&dma, offs);
 			std->physaddr = DMAADDR(&dma, offs);
 			std->dma = dma;
 			std->offs = offs;
 			std->nexttd = sc->sc_freetds;
+
 			sc->sc_freetds = std;
 		}
 	}
@@ -488,7 +508,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	sc->sc_freetds = std->nexttd;
 	mutex_exit(&sc->sc_lock);
 
-	memset(&std->td, 0, sizeof(ohci_td_t));
+	memset(std->td, 0, sizeof(*std->td));
 	std->nexttd = NULL;
 	std->xfer = NULL;
 	std->held = NULL;
@@ -651,10 +671,10 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		DPRINTFN(4, "sdataphys=0x%08jx edataphys=0x%08jx "
 		"len=%jd curlen=%jd", sdataphys, edataphys, len, curlen);
 
-		cur->td.td_flags = tdflags;
-		cur->td.td_cbp = HTOO32(sdataphys);
-		cur->td.td_be = HTOO32(edataphys);
-		cur->td.td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
+		cur->td->td_flags = tdflags;
+		cur->td->td_cbp = HTOO32(sdataphys);
+		cur->td->td_be = HTOO32(edataphys);
+		cur->td->td_nexttd = (next != NULL) ? HTOO32(next->physaddr) : 0;
 		cur->nexttd = next;
 		cur->len = curlen;
 		cur->flags = OHCI_ADD_LEN;
@@ -667,20 +687,20 @@ ohci_reset_std_chain(ohci_softc_t *sc, s
 		if (len != 0) {
 			KASSERT(next != NULL);
 			DPRINTFN(10, "extend chain", 0, 0, 0, 0);
-			usb_syncmem(&cur->dma, cur->offs, sizeof(cur->td),
+			usb_syncmem(&cur->dma, cur->offs, sizeof(*cur->td),
 			BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
 			cur = next;
 		}
 	}

CVS commit: src/sys/dev/usb

2024-07-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul  6 07:09:22 UTC 2024

Modified Files:
src/sys/dev/usb: if_cdce.c

Log Message:
There is no link state for CDCE. Pretend that the link is always up so that
programs like dhcpcd will handle the interface.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/if_cdce.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-07-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul  6 07:09:22 UTC 2024

Modified Files:
src/sys/dev/usb: if_cdce.c

Log Message:
There is no link state for CDCE. Pretend that the link is always up so that
programs like dhcpcd will handle the interface.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/usb/if_cdce.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_cdce.c
diff -u src/sys/dev/usb/if_cdce.c:1.81 src/sys/dev/usb/if_cdce.c:1.82
--- src/sys/dev/usb/if_cdce.c:1.81	Thu Mar  3 05:56:28 2022
+++ src/sys/dev/usb/if_cdce.c	Sat Jul  6 07:09:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cdce.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $ */
+/*	$NetBSD: if_cdce.c,v 1.82 2024/07/06 07:09:22 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul 
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.82 2024/07/06 07:09:22 mlelstv Exp $");
 
 #include 
 
@@ -251,6 +251,9 @@ cdce_attach(device_t parent, device_t se
 	usbnet_attach(un);
 	usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
 0, NULL);
+
+	/* XXX There is no link state, pretend we are always on */
+	if_link_state_change(usbnet_ifp(un), LINK_STATE_UP);
 }
 
 static void



CVS commit: src/sys/dev/usb

2024-07-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  4 00:23:48 UTC 2024

Modified Files:
src/sys/dev/usb: u3g.c

Log Message:
PR/58396: Reinhard Speyerer: u3g(4): add support for Sierra Wireless MC7304
devices


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/u3g.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/u3g.c
diff -u src/sys/dev/usb/u3g.c:1.44 src/sys/dev/usb/u3g.c:1.45
--- src/sys/dev/usb/u3g.c:1.44	Mon Feb 13 09:05:26 2023
+++ src/sys/dev/usb/u3g.c	Wed Jul  3 20:23:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: u3g.c,v 1.44 2023/02/13 14:05:26 manu Exp $	*/
+/*	$NetBSD: u3g.c,v 1.45 2024/07/04 00:23:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.44 2023/02/13 14:05:26 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.45 2024/07/04 00:23:48 christos Exp $");
 
 #include 
 #include 
@@ -234,6 +234,7 @@ static const struct usb_devno u3g_devs[]
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720 },
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720_2 },
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5725 },
+	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC7304 },
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755 },
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_2 },
 	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_3 },
@@ -264,6 +265,39 @@ static const struct usb_devno u3g_devs[]
 	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222 },
 };
 
+static bool
+ignoreSierra(const struct usbif_attach_arg *uiaa,
+const usb_interface_descriptor_t *id)
+{
+	if (uiaa->uiaa_vendor != USB_VENDOR_SIERRA)
+		return false;
+
+	if (id->bInterfaceClass != UICLASS_VENDOR)
+		return false;
+
+	switch (uiaa->uiaa_product) {
+	case USB_PRODUCT_SIERRA_MC7304:
+		 /*
+		  * Some modems use the vendor-specific class also for
+		  * ADB/Fastboot interfaces, which we should avoid attaching to.
+		  */
+		if (id->bInterfaceSubClass == 0x42)
+			return true;
+		/*FALLTHROUGH*/
+	case USB_PRODUCT_SIERRA_USB305:
+		/*
+		 * Sierra Wireless modems use the vendor-specific class also
+		 * for Direct IP or QMI interfaces, which we should avoid
+		 * attaching to.
+		 */
+		if (uiaa->uiaa_ifaceno >= 7)
+			return true;
+		/*FALLTHROUGH*/
+	default:
+		return false;
+	}
+}
+
 /*
  * Second personality:
  *
@@ -282,7 +316,8 @@ u3g_match(device_t parent, cfdata_t matc
 
 	id = usbd_get_interface_descriptor(iface);
 	if (id == NULL) {
-		printf("u3g_match: failed to get interface descriptor\n");
+		aprint_error("%s: failed to get interface descriptor\n",
+		__func__);
 		return UMATCH_NONE;
 	}
 
@@ -295,14 +330,7 @@ u3g_match(device_t parent, cfdata_t matc
 	(id->bInterfaceProtocol & 0xf) == 6)	/* 0x16, 0x46, 0x76 */
 		return UMATCH_NONE;
 
-	/*
-	 * Sierra Wireless modems use the vendor-specific class also for
-	 * Direct IP or QMI interfaces, which we should avoid attaching to.
-	 */
-	if (uiaa->uiaa_vendor == USB_VENDOR_SIERRA &&
-	id->bInterfaceClass == UICLASS_VENDOR &&
-	uiaa->uiaa_product == USB_PRODUCT_SIERRA_USB305 &&
-	 uiaa->uiaa_ifaceno >= 7)
+	if (ignoreSierra(uiaa, id))
 		return UMATCH_NONE;
 
 	/*



CVS commit: src/sys/dev/usb

2024-07-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  4 00:23:48 UTC 2024

Modified Files:
src/sys/dev/usb: u3g.c

Log Message:
PR/58396: Reinhard Speyerer: u3g(4): add support for Sierra Wireless MC7304
devices


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/u3g.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/dev/usb

2024-06-30 Thread Taylor R Campbell
> Module Name:src
> Committed By:   riastradh
> Date:   Sun Jun 30 16:35:19 UTC 2024
> 
> Modified Files:
> src/sys/dev/usb: if_url.c
> 
> Log Message:
> url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not +1/-1.

That was supposed to read:

url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not 0/-1.


CVS commit: src/sys/dev/usb

2024-06-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 30 16:35:19 UTC 2024

Modified Files:
src/sys/dev/usb: if_url.c

Log Message:
url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not +1/-1.

Should avoid buffer overrun in PR 58382.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/if_url.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.97 src/sys/dev/usb/if_url.c:1.98
--- src/sys/dev/usb/if_url.c:1.97	Sat Aug 20 14:08:59 2022
+++ src/sys/dev/usb/if_url.c	Sun Jun 30 16:35:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.97 2022/08/20 14:08:59 riastradh Exp $	*/
+/*	$NetBSD: if_url.c,v 1.98 2024/06/30 16:35:19 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.97 2022/08/20 14:08:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.98 2024/06/30 16:35:19 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -422,7 +422,7 @@ url_uno_mcast(struct ifnet *ifp)
 	struct ether_multi *enm;
 	struct ether_multistep step;
 	uint32_t mchash[2] = { 0, 0 };
-	int h = 0, rcr;
+	uint32_t h = 0, rcr;
 
 	DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
 



CVS commit: src/sys/dev/usb

2024-06-30 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jun 30 16:35:19 UTC 2024

Modified Files:
src/sys/dev/usb: if_url.c

Log Message:
url(4): uint32_t for 32-bit hash so h>>31 becomes 0/1, not +1/-1.

Should avoid buffer overrun in PR 58382.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/usb/if_url.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:36:21 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow some more variable scopes in xhci_device_isoc_enter.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.183 src/sys/dev/usb/xhci.c:1.184
--- src/sys/dev/usb/xhci.c:1.183	Mon May 20 11:35:54 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:36:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.184 2024/05/20 11:36:20 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4560,14 +4560,12 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	uint64_t parameter;
 	uint32_t status;
 	uint32_t control;
-	uint32_t mfindex;
 	uint32_t offs;
 	int i, ival;
 	const bool polling = xhci_polling_p(sc);
 	const uint16_t MPS = UGETW(xfer->ux_pipe->up_endpoint->ue_edesc->wMaxPacketSize);
 	const uint16_t mps = UE_GET_SIZE(MPS);
 	const uint8_t maxb = xpipe->xp_maxb;
-	u_int tdpc, tbc, tlbpc;
 
 	XHCIHIST_FUNC();
 	XHCIHIST_CALLARGS("%#jx slot %ju dci %ju",
@@ -4593,7 +4591,8 @@ xhci_device_isoc_enter(struct usbd_xfer 
 		ival = 1; /* fake something up */
 
 	if (xpipe->xp_isoc_next == -1) {
-		mfindex = xhci_rt_read_4(sc, XHCI_MFINDEX);
+		uint32_t mfindex = xhci_rt_read_4(sc, XHCI_MFINDEX);
+
 		DPRINTF("mfindex %jx", (uintmax_t)mfindex, 0, 0, 0);
 		mfindex = XHCI_MFINDEX_GET(mfindex + 1);
 		mfindex /= USB_UFRAMES_PER_FRAME;
@@ -4604,11 +4603,10 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	offs = 0;
 	for (i = 0; i < xfer->ux_nframes; i++) {
 		const uint32_t len = xfer->ux_frlengths[i];
-
-		tdpc = howmany(len, mps);
-		tbc = howmany(tdpc, maxb) - 1;
-		tlbpc = tdpc % maxb;
-		tlbpc = tlbpc ? tlbpc - 1 : maxb - 1;
+		const unsigned tdpc = howmany(len, mps);
+		const unsigned tbc = howmany(tdpc, maxb) - 1;
+		const unsigned tlbpc1 = tdpc % maxb;
+		const unsigned tlbpc = tlbpc1 ? tlbpc1 - 1 : maxb - 1;
 
 		KASSERTMSG(len <= 0x1, "len %d", len);
 		parameter = DMAADDR(dma, offs);



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:36:21 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow some more variable scopes in xhci_device_isoc_enter.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:55 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow scope of variable.

Nix spurious initialization in wider scope.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.182 src/sys/dev/usb/xhci.c:1.183
--- src/sys/dev/usb/xhci.c:1.182	Mon May 20 11:35:36 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:35:54 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.183 2024/05/20 11:35:54 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -4556,7 +4556,6 @@ xhci_device_isoc_enter(struct usbd_xfer 
 	struct xhci_ring * const tr = xs->xs_xr[dci];
 	struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer);
 	struct xhci_pipe * const xpipe = (struct xhci_pipe *)xfer->ux_pipe;
-	uint32_t len = xfer->ux_length;
 	usb_dma_t * const dma = &xfer->ux_dmabuf;
 	uint64_t parameter;
 	uint32_t status;
@@ -4604,7 +4603,7 @@ xhci_device_isoc_enter(struct usbd_xfer 
 
 	offs = 0;
 	for (i = 0; i < xfer->ux_nframes; i++) {
-		len = xfer->ux_frlengths[i];
+		const uint32_t len = xfer->ux_frlengths[i];
 
 		tdpc = howmany(len, mps);
 		tbc = howmany(tdpc, maxb) - 1;



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:55 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci(4): Narrow scope of variable.

Nix spurious initialization in wider scope.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:37 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci.c: Fix confusing line break.

No functionanl change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon May 20 11:35:37 UTC 2024

Modified Files:
src/sys/dev/usb: xhci.c

Log Message:
xhci.c: Fix confusing line break.

No functionanl change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/usb/xhci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.181 src/sys/dev/usb/xhci.c:1.182
--- src/sys/dev/usb/xhci.c:1.181	Fri Apr  5 18:57:10 2024
+++ src/sys/dev/usb/xhci.c	Mon May 20 11:35:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.181 2024/04/05 18:57:10 riastradh Exp $	*/
+/*	$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.181 2024/04/05 18:57:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.182 2024/05/20 11:35:36 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2496,8 +2496,7 @@ xhci_event_transfer(struct xhci_softc * 
 			xfer->ux_frlengths[xx->xx_isoc_done] -=
 			XHCI_TRB_2_REM_GET(trb_2);
 			xfer->ux_actlen += xfer->ux_frlengths[xx->xx_isoc_done];
-		} else
-		if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
+		} else if ((trb_3 & XHCI_TRB_3_ED_BIT) == 0) {
 			if (xfer->ux_actlen == 0)
 xfer->ux_actlen = xfer->ux_length -
 XHCI_TRB_2_REM_GET(trb_2);



CVS commit: src/sys/dev/usb

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:18:34 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen


To generate a diff of this commit:
cvs rdiff -u -r1.807 -r1.808 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.807 src/sys/dev/usb/usbdevs.h:1.808
--- src/sys/dev/usb/usbdevs.h:1.807	Tue Apr 16 22:33:04 2024
+++ src/sys/dev/usb/usbdevs.h	Sun May 12 13:18:34 2024
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.807 2024/04/17 02:33:04 maya Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.808 2024/05/12 17:18:34 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.814 2024/02/28 21:50:51 dholland Exp
+ *	NetBSD: usbdevs,v 1.816 2024/05/12 17:17:56 christos Exp
  */
 
 /*-
@@ -3474,6 +3474,7 @@
 #define	USB_PRODUCT_TPLINK_T4UV2	0x010d		/* Archer T4U ver 2 */
 #define	USB_PRODUCT_TPLINK_T4UHV2	0x010e		/* Archer T4UH ver 2 */
 #define	USB_PRODUCT_TPLINK_T2UNANO	0x011e		/* Archer T2U Nano */
+#define	USB_PRODUCT_TPLINK_UE300	0x0601		/* UE300 10/100/1000 LAN */
 
 /* Trek Technology products */
 #define	USB_PRODUCT_TREK_THUMBDRIVE	0x		/* ThumbDrive */
Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.807 src/sys/dev/usb/usbdevs_data.h:1.808
--- src/sys/dev/usb/usbdevs_data.h:1.807	Tue Apr 16 22:33:04 2024
+++ src/sys/dev/usb/usbdevs_data.h	Sun May 12 13:18:34 2024
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.807 2024/04/17 02:33:04 maya Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.808 2024/05/12 17:18:34 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.814 2024/02/28 21:50:51 dholland Exp
+ *	NetBSD: usbdevs,v 1.816 2024/05/12 17:17:56 christos Exp
  */
 
 /*-
@@ -4767,168 +4767,170 @@ static const uint32_t usb_products[] = {
 	20027, 20038, 7643, 6624, 0,
 	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_T2UNANO, 
 	20027, 20043, 6975, 0,
+	USB_VENDOR_TPLINK, USB_PRODUCT_TPLINK_UE300, 
+	20047, 20053, 7459, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE, 
-	20047, 0,
+	20065, 0,
 	USB_VENDOR_TREK, USB_PRODUCT_TREK_THUMBDRIVE_8MB, 
-	20047, 20058, 0,
+	20065, 20076, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8192CU, 
 	5282, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_RTL8188CU, 
 	5302, 0,
 	USB_VENDOR_TRENDNET, USB_PRODUCT_TRENDNET_TEW648UBM, 
-	20062, 0,
+	20080, 0,
 	USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, 
-	20073, 7044, 5007, 0,
+	20091, 7044, 5007, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_UPS, 
 	3207, 3213, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_SMARTLCD, 
-	20078, 480, 0,
+	20096, 480, 0,
 	USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_AVR550U, 
-	3207, 3213, 20087, 0,
+	3207, 3213, 20105, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_T33521, 
-	20095, 20103, 0,
+	20113, 20121, 0,
 	USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_XXX1100, 
-	16365, 20111, 0,
+	16365, 20129, 0,
 	USB_VENDOR_TSUNAMI, USB_PRODUCT_TSUNAMI_SM2000, 
-	20116, 0,
+	20134, 0,
 	USB_VENDOR_TWINMOS, USB_PRODUCT_TWINMOS_G240, 
-	20124, 0,
+	20142, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_1200UBPLUS, 
 	11625, 15247, 11515, 7345, 0,
 	USB_VENDOR_ULTIMA, USB_PRODUCT_ULTIMA_T14BR, 
-	20129, 20135, 6945, 0,
+	20147, 20153, 6945, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U, 
-	20141, 5778, 20147, 0,
+	20159, 5778, 20165, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U, 
-	20141, 20155, 20147, 0,
+	20159, 20173, 20165, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U, 
-	20141, 20161, 20147, 0,
+	20159, 20179, 20165, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400, 
-	20141, 20167, 20147, 0,
+	20159, 20185, 20165, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2100U, 
-	20141, 20172, 20147, 0,
+	20159, 20190, 20165, 0,
 	USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U, 
-	20141, 20178, 20147, 0,
+	20159, 20196, 20165, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB_A, 
-	20184, 0,
+	20202, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UB, 
-	20196, 0,
+	20214, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW429UBC1, 
-	20196, 9551, 0,
+	20214, 9551, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_RT2870_1, 
 	5161, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_TEW645UB, 
-	20206, 0,
+	20224, 0,
 	USB_VENDOR_UMEDIA, USB_PRODUCT_UMEDIA_ALL0298V2, 
-	20216, 7632, 0,
+	20234, 7632, 0,
 	USB_VENDOR_UNIACCESS, USB_PRODUCT_UNIACCESS

CVS commit: src/sys/dev/usb

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:18:34 UTC 2024

Modified Files:
src/sys/dev/usb: usbdevs.h usbdevs_data.h

Log Message:
Regen


To generate a diff of this commit:
cvs rdiff -u -r1.807 -r1.808 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:17:56 UTC 2024

Modified Files:
src/sys/dev/usb: if_ure.c usbdevs

Log Message:
PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.815 -r1.816 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/if_ure.c
diff -u src/sys/dev/usb/if_ure.c:1.59 src/sys/dev/usb/if_ure.c:1.60
--- src/sys/dev/usb/if_ure.c:1.59	Mon Oct  9 07:28:05 2023
+++ src/sys/dev/usb/if_ure.c	Sun May 12 13:17:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ure.c,v 1.59 2023/10/09 11:28:05 riastradh Exp $	*/
+/*	$NetBSD: if_ure.c,v 1.60 2024/05/12 17:17:56 christos Exp $	*/
 /*	$OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $	*/
 
 /*-
@@ -30,7 +30,7 @@
 /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.59 2023/10/09 11:28:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.60 2024/05/12 17:17:56 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -72,7 +72,8 @@ int	uredebug = 0;
 
 static const struct usb_devno ure_devs[] = {
 	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8152 },
-	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 }
+	{ USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8153 },
+	{ USB_VENDOR_TPLINK,  USB_PRODUCT_TPLINK_UE300 },
 };
 
 #define URE_BUFSZ	(16 * 1024)

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.815 src/sys/dev/usb/usbdevs:1.816
--- src/sys/dev/usb/usbdevs:1.815	Tue Apr 16 22:32:08 2024
+++ src/sys/dev/usb/usbdevs	Sun May 12 13:17:56 2024
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.815 2024/04/17 02:32:08 maya Exp $
+$NetBSD: usbdevs,v 1.816 2024/05/12 17:17:56 christos Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -3467,6 +3467,7 @@ product TPLINK RTL8188EU	0x010c	RTL8188E
 product	TPLINK T4UV2		0x010d  Archer T4U ver 2
 product	TPLINK T4UHV2		0x010e  Archer T4UH ver 2
 product	TPLINK T2UNANO		0x011e  Archer T2U Nano
+product	TPLINK UE300		0x0601	UE300 10/100/1000 LAN
 
 /* Trek Technology products */
 product TREK THUMBDRIVE		0x	ThumbDrive



CVS commit: src/sys/dev/usb

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:17:56 UTC 2024

Modified Files:
src/sys/dev/usb: if_ure.c usbdevs

Log Message:
PR/58250: RVP: Add TP-Link UE300 USB LAN adapter


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.815 -r1.816 src/sys/dev/usb/usbdevs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:49:16 UTC 2024

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uhub.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:49:16 UTC 2024

Modified Files:
src/sys/dev/usb: uhub.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uhub.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.161 src/sys/dev/usb/uhub.c:1.162
--- src/sys/dev/usb/uhub.c:1.161	Wed Apr  6 22:01:45 2022
+++ src/sys/dev/usb/uhub.c	Sat May  4 12:49:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.161 2022/04/06 22:01:45 mlelstv Exp $	*/
+/*	$NetBSD: uhub.c,v 1.162 2024/05/04 12:49:15 mlelstv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 /*	$OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.161 2022/04/06 22:01:45 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.162 2024/05/04 12:49:15 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -864,7 +864,7 @@ uhub_explore(struct usbd_device *dev)
 			 * some other serious problem.  Since we cannot leave
 			 * at 0 we have to disable the port instead.
 			 */
-			aprint_error_dev(sc->sc_dev,
+			device_printf(sc->sc_dev,
 			"device problem, disabling port %d\n", port);
 			usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
 		} else {



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:45:14 UTC 2024

Modified Files:
src/sys/dev/usb: usb_subr.c

Log Message:
Make usb address and hub topology available to drvctl.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/dev/usb/usb_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.278 src/sys/dev/usb/usb_subr.c:1.279
--- src/sys/dev/usb/usb_subr.c:1.278	Tue Apr 11 08:50:07 2023
+++ src/sys/dev/usb/usb_subr.c	Sat May  4 12:45:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.278 2023/04/11 08:50:07 riastradh Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.279 2024/05/04 12:45:13 mlelstv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.278 2023/04/11 08:50:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.279 2024/05/04 12:45:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1083,6 +1083,24 @@ usbd_properties(device_t dv, struct usbd
 	vendor = UGETW(dd->idVendor);
 	product = UGETW(dd->idProduct);
 
+	prop_dictionary_set_uint8(dict, "address", dev->ud_addr);
+
+	if (dev->ud_myhub) {
+		struct usbd_device *hdev = dev->ud_myhub;
+		struct usbd_hub *hub = hdev->ud_hub;
+		int p;
+
+		KASSERT(hub != NULL);
+
+		prop_dictionary_set_uint8(dict, "hub-address", hdev->ud_addr);
+		for (p=1; p <= hub->uh_hubdesc.bNbrPorts; ++p) {
+			if (hub->uh_ports[p-1].up_dev == dev) {
+prop_dictionary_set_uint8(dict, "hub-port", p);
+break;
+			}
+		}
+	}
+
 	prop_dictionary_set_uint8(dict, "class", class);
 	prop_dictionary_set_uint8(dict, "subclass", subclass);
 	prop_dictionary_set_uint16(dict, "release", release);



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:45:14 UTC 2024

Modified Files:
src/sys/dev/usb: usb_subr.c

Log Message:
Make usb address and hub topology available to drvctl.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/sys/dev/usb/usb_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:41:03 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.119 src/sys/dev/usb/usbnet.c:1.120
--- src/sys/dev/usb/usbnet.c:1.119	Fri Feb  2 22:00:33 2024
+++ src/sys/dev/usb/usbnet.c	Sat May  4 12:41:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.119 2024/02/02 22:00:33 andvar Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.119 2024/02/02 22:00:33 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.120 2024/05/04 12:41:03 mlelstv Exp $");
 
 #include 
 #include 
@@ -377,7 +377,7 @@ usbnet_rxeof(struct usbd_xfer *xfer, voi
 	usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
 
 	if (total_len > un->un_rx_bufsz) {
-		aprint_error_dev(un->un_dev,
+		device_printf(un->un_dev,
 		"rxeof: too large transfer (%u > %u)\n",
 		total_len, un->un_rx_bufsz);
 		goto done;
@@ -471,7 +471,7 @@ usbnet_pipe_intr(struct usbd_xfer *xfer,
 
 	if (status != USBD_NORMAL_COMPLETION) {
 		if (usbd_ratecheck(&unp->unp_intr_notice)) {
-			aprint_error_dev(un->un_dev, "usb error on intr: %s\n",
+			device_printf(un->un_dev, "usb error on intr: %s\n",
 			usbd_errstr(status));
 		}
 		if (status == USBD_STALLED)



CVS commit: src/sys/dev/usb

2024-05-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat May  4 12:41:03 UTC 2024

Modified Files:
src/sys/dev/usb: usbnet.c

Log Message:
Use device_printf instead of autoconf messages for errors.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 08:55:03 UTC 2024

Modified Files:
src/sys/dev/usb: ohci.c

Log Message:
Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/sys/dev/usb/ohci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.327 src/sys/dev/usb/ohci.c:1.328
--- src/sys/dev/usb/ohci.c:1.327	Sun Apr 28 07:52:52 2024
+++ src/sys/dev/usb/ohci.c	Sun Apr 28 08:55:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.327 2024/04/28 07:52:52 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.328 2024/04/28 08:55:03 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.327 2024/04/28 07:52:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.328 2024/04/28 08:55:03 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -844,6 +844,9 @@ ohci_init(ohci_softc_t *sc)
 		goto bad1;
 	}
 	sc->sc_ctrl_head->ed.ed_flags |= HTOO32(OHCI_ED_SKIP);
+	usb_syncmem(&sc->sc_ctrl_head->dma, sc->sc_ctrl_head->offs,
+	sizeof(sc->sc_ctrl_head->ed),
+	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 
 	/* Allocate dummy ED that starts the bulk list. */
 	sc->sc_bulk_head = ohci_alloc_sed(sc);
@@ -1609,6 +1612,10 @@ ohci_softintr(void *v)
 			for (i = 0, sitd = xfer->ux_hcpriv;;
 			sitd = next) {
 next = sitd->nextitd;
+
+usb_syncmem(&sitd->dma, sitd->offs, sizeof(sitd->itd),
+BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
+
 if (OHCI_ITD_GET_CC(O32TOH(sitd->
 itd.itd_flags)) != OHCI_CC_NO_ERROR)
 	xfer->ux_status = USBD_IOERROR;
@@ -2259,8 +2266,7 @@ ohci_abortx(struct usbd_xfer *xfer)
 	 * waiting for the next start of frame (OHCI_SF)
 	 */
 	DPRINTFN(1, "stop ed=%#jx", (uintptr_t)sed, 0, 0, 0);
-	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags),
-	sizeof(sed->ed.ed_flags),
+	usb_syncmem(&sed->dma, sed->offs, sizeof(sed->ed),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	if (!(sed->ed.ed_flags & OHCI_HALTED)) {
 		/* force hardware skip */
@@ -2337,6 +2343,9 @@ ohci_abortx(struct usbd_xfer *xfer)
 		hit |= headp == p->physaddr;
 		n = p->nexttd;
 
+		usb_syncmem(&p->dma, p->offs + offsetof(ohci_td_t, td_flags),
+		sizeof(p->td.td_flags),
+		BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 		int cc = OHCI_TD_GET_CC(O32TOH(p->td.td_flags));
 		if (!OHCI_CC_ACCESSED_P(cc)) {
 			ohci_hash_rem_td(sc, p);
@@ -2951,8 +2960,17 @@ ohci_device_clear_toggle(struct usbd_pip
 {
 	struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(pipe);
 	ohci_softc_t *sc = OHCI_PIPE2SC(pipe);
+	ohci_soft_ed_t *sed = opipe->sed;
+
+	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_headp),
+	sizeof(sed->ed.ed_headp),
+	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 
 	opipe->sed->ed.ed_headp &= HTOO32(~OHCI_TOGGLECARRY);
+
+	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_headp),
+	sizeof(sed->ed.ed_headp),
+	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 }
 
 Static void
@@ -3403,17 +3421,21 @@ ohci_device_setintr(ohci_softc_t *sc, st
 	mutex_enter(&sc->sc_lock);
 	hsed = sc->sc_eds[best];
 	sed->next = hsed->next;
-	usb_syncmem(&hsed->dma, hsed->offs + offsetof(ohci_ed_t, ed_flags),
-	sizeof(hsed->ed.ed_flags),
+	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted),
+	sizeof(sed->ed.ed_nexted),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	sed->ed.ed_nexted = hsed->ed.ed_nexted;
-	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags),
-	sizeof(sed->ed.ed_flags),
+	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_nexted),
+	sizeof(sed->ed.ed_nexted),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
+
 	hsed->next = sed;
+	usb_syncmem(&hsed->dma, hsed->offs + offsetof(ohci_ed_t, ed_nexted),
+	sizeof(hsed->ed.ed_nexted),
+	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	hsed->ed.ed_nexted = HTOO32(sed->physaddr);
-	usb_syncmem(&hsed->dma, hsed->offs + offsetof(ohci_ed_t, ed_flags),
-	sizeof(hsed->ed.ed_flags),
+	usb_syncmem(&hsed->dma, hsed->offs + offsetof(ohci_ed_t, ed_nexted),
+	sizeof(hsed->ed.ed_nexted),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 	mutex_exit(&sc->sc_lock);
 
@@ -3685,8 +3707,7 @@ ohci_device_isoc_enter(struct usbd_xfer 
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
 	sed->ed.ed_tailp = HTOO32(tail->physaddr);
 	sed->ed.ed_flags &= HTOO32(~OHCI_ED_SKIP);
-	usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags),
-	sizeof(sed->ed.ed_flags),
+	usb_syncmem(&sed->dma, sed->offs, sizeof(sed->ed),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 }
 



CVS commit: src/sys/dev/usb

2024-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 08:55:03 UTC 2024

Modified Files:
src/sys/dev/usb: ohci.c

Log Message:
Fix some usb_syncmem calls and add some missing ones.


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/sys/dev/usb/ohci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 07:52:52 UTC 2024

Modified Files:
src/sys/dev/usb: ohci.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/sys/dev/usb/ohci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.326 src/sys/dev/usb/ohci.c:1.327
--- src/sys/dev/usb/ohci.c:1.326	Fri Apr  5 18:57:10 2024
+++ src/sys/dev/usb/ohci.c	Sun Apr 28 07:52:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.326 2024/04/05 18:57:10 riastradh Exp $	*/
+/*	$NetBSD: ohci.c,v 1.327 2024/04/28 07:52:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.326 2024/04/05 18:57:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.327 2024/04/28 07:52:52 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -826,8 +826,8 @@ ohci_init(ohci_softc_t *sc)
 
 	/* XXX determine alignment by R/W */
 	/* Allocate the HCCA area. */
-	err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_HCCA_SIZE,	OHCI_HCCA_ALIGN,
-	USBMALLOC_COHERENT, &sc->sc_hccadma);
+	err = usb_allocmem(sc->sc_bus.ub_dmatag, OHCI_HCCA_SIZE,
+	OHCI_HCCA_ALIGN, USBMALLOC_COHERENT, &sc->sc_hccadma);
 	if (err) {
 		sc->sc_hcca = NULL;
 		return err;



CVS commit: src/sys/dev/usb

2024-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 07:52:52 UTC 2024

Modified Files:
src/sys/dev/usb: ohci.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/sys/dev/usb/ohci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2024-04-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Apr 25 01:33:04 UTC 2024

Modified Files:
src/sys/dev/usb: uftdi.c

Log Message:
Add a match quirk to prevent matching any interface on SiPEED FPGA
development boards (e.g. Tang Nano 9K).  The FT2232s on these boards
are wired up only for JTAG.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/uftdi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uftdi.c
diff -u src/sys/dev/usb/uftdi.c:1.78 src/sys/dev/usb/uftdi.c:1.79
--- src/sys/dev/usb/uftdi.c:1.78	Wed Apr 17 02:34:45 2024
+++ src/sys/dev/usb/uftdi.c	Thu Apr 25 01:33:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uftdi.c,v 1.78 2024/04/17 02:34:45 maya Exp $	*/
+/*	$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.78 2024/04/17 02:34:45 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -229,7 +229,19 @@ static const struct uftdi_match_quirk_en
 	  .vendor_str	= "SecuringHardware.com",
 	  .product_str	= "Tigard V1.1",
 	  .match_ret	= UMATCH_NONE,
-	}
+	},
+	/*
+	 * The SiPEED Tang Nano 9K (and other SiPEED Tang FPGA development
+	 * boards) have an FT2232 on-board, wired up only for JTAG.
+	 */
+	{
+	  .vendor_id	= USB_VENDOR_FTDI,
+	  .product_id	= USB_PRODUCT_FTDI_SERIAL_2232C,
+	  .iface_no	= -1,
+	  .vendor_str	= "SIPEED",
+	  .product_str	= "JTAG Debugger",
+	  .match_ret	= UMATCH_NONE,
+	},
 };
 
 static int
@@ -243,7 +255,7 @@ uftdi_quirk_match(struct usbif_attach_ar
 		q = &uftdi_match_quirks[i];
 		if (uiaa->uiaa_vendor != q->vendor_id ||
 		uiaa->uiaa_product != q->product_id ||
-		uiaa->uiaa_ifaceno != q->iface_no) {
+		(q->iface_no != -1 && uiaa->uiaa_ifaceno != q->iface_no)) {
 			continue;
 		}
 		if (q->vendor_str != NULL &&



CVS commit: src/sys/dev/usb

2024-04-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Apr 25 01:33:04 UTC 2024

Modified Files:
src/sys/dev/usb: uftdi.c

Log Message:
Add a match quirk to prevent matching any interface on SiPEED FPGA
development boards (e.g. Tang Nano 9K).  The FT2232s on these boards
are wired up only for JTAG.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/uftdi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   3   4   5   6   7   8   9   10   >