-/* $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 $ */
/*
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;
/* 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);
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;
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;
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);
-/* $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
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;
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