summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/ehci.c3
-rw-r--r--sys/dev/usb/usb_mem.c30
-rw-r--r--sys/dev/usb/usb_mem.h4
-rw-r--r--sys/dev/usb/usbdivar.h3
-rw-r--r--sys/dev/usb/xhci.c7
5 files changed, 24 insertions, 23 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 95b28784b6e..d1a69b662d1 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.220 2024/05/23 03:21:08 jsg Exp $ */
+/* $OpenBSD: ehci.c,v 1.221 2024/10/08 19:42:31 kettenis Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -317,6 +317,7 @@ ehci_init(struct ehci_softc *sc)
sc->sc_noport = EHCI_HCS_N_PORTS(sparams);
cparams = EREAD4(sc, EHCI_HCCPARAMS);
DPRINTF(("ehci_init: cparams=0x%x\n", cparams));
+ sc->sc_bus.dmaflags = EHCI_HCC_64BIT(cparams) ? BUS_DMA_64BIT : 0;
/* MUST clear segment register if 64 bit capable. */
if (EHCI_HCC_64BIT(cparams))
diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c
index 6dec6d52764..e792e6a720e 100644
--- a/sys/dev/usb/usb_mem.c
+++ b/sys/dev/usb/usb_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_mem.c,v 1.35 2024/05/23 03:21:09 jsg Exp $ */
+/* $OpenBSD: usb_mem.c,v 1.36 2024/10/08 19:42:31 kettenis Exp $ */
/* $NetBSD: usb_mem.c,v 1.26 2003/02/01 06:23:40 thorpej Exp $ */
/*
@@ -82,7 +82,7 @@ LIST_HEAD(, usb_frag_dma) usb_frag_freelist =
usbd_status
usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
- struct usb_dma_block **dmap, int coherent)
+ struct usb_dma_block **dmap, int flags)
{
int error;
struct usb_dma_block *p;
@@ -95,7 +95,7 @@ usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
/* First check the free list. */
for (p = LIST_FIRST(&usb_blk_freelist); p; p = LIST_NEXT(p, next)) {
if (p->tag == tag && p->size >= size && p->align >= align &&
- p->coherent == coherent) {
+ p->flags == flags) {
LIST_REMOVE(p, next);
usb_blk_nfree--;
splx(s);
@@ -115,26 +115,25 @@ usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
p->tag = tag;
p->size = size;
p->align = align;
- p->coherent = coherent;
+ p->flags = flags;
error = bus_dmamem_alloc(tag, p->size, align, 0,
- p->segs, nitems(p->segs),
- &p->nsegs, BUS_DMA_NOWAIT);
+ p->segs, nitems(p->segs), &p->nsegs,
+ BUS_DMA_NOWAIT | (flags & BUS_DMA_64BIT));
if (error)
goto free0;
error = bus_dmamem_map(tag, p->segs, p->nsegs, p->size,
- &p->kaddr, BUS_DMA_NOWAIT | (coherent ?
- BUS_DMA_COHERENT : 0));
+ &p->kaddr, BUS_DMA_NOWAIT | (flags & BUS_DMA_COHERENT));
if (error)
goto free1;
error = bus_dmamap_create(tag, p->size, 1, p->size,
- 0, BUS_DMA_NOWAIT, &p->map);
+ 0, BUS_DMA_NOWAIT | (flags & BUS_DMA_64BIT), &p->map);
if (error)
goto unmap;
error = bus_dmamap_load(tag, p->map, p->kaddr, p->size, NULL,
- BUS_DMA_NOWAIT);
+ BUS_DMA_NOWAIT);
if (error)
goto destroy;
@@ -189,18 +188,17 @@ usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, int flags,
usbd_status err;
struct usb_frag_dma *f;
struct usb_dma_block *b;
- int coherent;
int i;
int s;
- coherent = !!(flags & USB_DMA_COHERENT);
+ flags = (flags & USB_DMA_COHERENT) ? BUS_DMA_COHERENT : 0;
+ flags |= bus->dmaflags;
/* If the request is large then just use a full block. */
if (size > USB_MEM_SMALL || align > USB_MEM_SMALL) {
DPRINTFN(1, ("%s: large alloc %d\n", __func__, (int)size));
size = (size + USB_MEM_BLOCK - 1) & ~(USB_MEM_BLOCK - 1);
- err = usb_block_allocmem(tag, size, align, &p->block,
- coherent);
+ err = usb_block_allocmem(tag, size, align, &p->block, flags);
if (!err) {
p->block->frags = NULL;
p->offs = 0;
@@ -211,12 +209,12 @@ usb_allocmem(struct usbd_bus *bus, size_t size, size_t align, int flags,
s = splusb();
/* Check for free fragments. */
for (f = LIST_FIRST(&usb_frag_freelist); f; f = LIST_NEXT(f, next))
- if (f->block->tag == tag && f->block->coherent == coherent)
+ if (f->block->tag == tag && f->block->flags == flags)
break;
if (f == NULL) {
DPRINTFN(1, ("usb_allocmem: adding fragments\n"));
err = usb_block_allocmem(tag, USB_MEM_BLOCK, USB_MEM_SMALL, &b,
- coherent);
+ flags);
if (err) {
splx(s);
return (err);
diff --git a/sys/dev/usb/usb_mem.h b/sys/dev/usb/usb_mem.h
index 98a221eae9a..e291f719ff4 100644
--- a/sys/dev/usb/usb_mem.h
+++ b/sys/dev/usb/usb_mem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_mem.h,v 1.17 2020/03/21 12:08:31 patrick Exp $ */
+/* $OpenBSD: usb_mem.h,v 1.18 2024/10/08 19:42:31 kettenis Exp $ */
/* $NetBSD: usb_mem.h,v 1.20 2003/05/03 18:11:42 wiz Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -40,7 +40,7 @@ struct usb_dma_block {
caddr_t kaddr;
bus_dma_segment_t segs[1];
int nsegs;
- int coherent;
+ int flags;
size_t size;
size_t align;
struct usb_frag_dma *frags;
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 45cfe20eb90..7a3baa4d6fd 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdivar.h,v 1.83 2022/09/04 08:42:39 mglocker Exp $ */
+/* $OpenBSD: usbdivar.h,v 1.84 2024/10/08 19:42:31 kettenis Exp $ */
/* $NetBSD: usbdivar.h,v 1.70 2002/07/11 21:14:36 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
@@ -135,6 +135,7 @@ struct usbd_bus {
#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0", "3.0" }
void *soft; /* soft interrupt cookie */
bus_dma_tag_t dmatag; /* DMA tag */
+ int dmaflags;
};
struct usbd_device {
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c
index d7a1fc0c9f1..a40204265ff 100644
--- a/sys/dev/usb/xhci.c
+++ b/sys/dev/usb/xhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci.c,v 1.134 2024/08/17 01:55:03 jsg Exp $ */
+/* $OpenBSD: xhci.c,v 1.135 2024/10/08 19:42:31 kettenis Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -238,12 +238,12 @@ usbd_dma_contig_alloc(struct usbd_bus *bus, struct usbd_dma_info *dma,
dma->size = size;
error = bus_dmamap_create(dma->tag, size, 1, size, boundary,
- BUS_DMA_NOWAIT, &dma->map);
+ BUS_DMA_NOWAIT | bus->dmaflags, &dma->map);
if (error != 0)
return (error);
error = bus_dmamem_alloc(dma->tag, size, alignment, boundary, &dma->seg,
- 1, &dma->nsegs, BUS_DMA_NOWAIT | BUS_DMA_ZERO);
+ 1, &dma->nsegs, BUS_DMA_NOWAIT | BUS_DMA_ZERO | bus->dmaflags);
if (error != 0)
goto destroy;
@@ -329,6 +329,7 @@ xhci_init(struct xhci_softc *sc)
hcr = XREAD4(sc, XHCI_HCCPARAMS);
sc->sc_ctxsize = XHCI_HCC_CSZ(hcr) ? 64 : 32;
+ sc->sc_bus.dmaflags |= XHCI_HCC_AC64(hcr) ? BUS_DMA_64BIT : 0;
DPRINTF(("%s: %d bytes context\n", DEVNAME(sc), sc->sc_ctxsize));
#ifdef XHCI_DEBUG