Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Add USBMALLOC_ZERO flag for requesting zero init...



details:   https://anonhg.NetBSD.org/src/rev/a1bb9d048aea
branches:  trunk
changeset: 979597:a1bb9d048aea
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jan 02 12:39:03 2021 +0000

description:
Add USBMALLOC_ZERO flag for requesting zero initialized DMA memory.

diffstat:

 sys/dev/usb/usb_mem.c |  13 ++++++++++---
 sys/dev/usb/usb_mem.h |   3 ++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 8c1ec0641383 -r a1bb9d048aea sys/dev/usb/usb_mem.c
--- a/sys/dev/usb/usb_mem.c     Sat Jan 02 12:12:26 2021 +0000
+++ b/sys/dev/usb/usb_mem.c     Sat Jan 02 12:39:03 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.c,v 1.77 2020/05/15 06:26:44 skrll Exp $       */
+/*     $NetBSD: usb_mem.c,v 1.78 2021/01/02 12:39:03 jmcneill Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.77 2020/05/15 06:26:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_mem.c,v 1.78 2021/01/02 12:39:03 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -179,9 +179,16 @@
                goto destroy;
 
        *dmap = b;
+
 #ifdef USB_FRAG_DMA_WORKAROUND
-       memset(b->kaddr, 0, b->size);
+       flags |= USBMALLOC_ZERO;
 #endif
+       if ((flags & USBMALLOC_ZERO) != 0) {
+               memset(b->kaddr, 0, b->size);
+               bus_dmamap_sync(b->tag, b->map, 0, b->size,
+                   BUS_DMASYNC_PREWRITE);
+       }
+
        mutex_enter(&usb_blk_lock);
 
        return USBD_NORMAL_COMPLETION;
diff -r 8c1ec0641383 -r a1bb9d048aea sys/dev/usb/usb_mem.h
--- a/sys/dev/usb/usb_mem.h     Sat Jan 02 12:12:26 2021 +0000
+++ b/sys/dev/usb/usb_mem.h     Sat Jan 02 12:39:03 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_mem.h,v 1.32 2020/04/05 20:59:38 skrll Exp $       */
+/*     $NetBSD: usb_mem.h,v 1.33 2021/01/02 12:39:03 jmcneill Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $     */
 
 /*
@@ -49,6 +49,7 @@
 
 #define USBMALLOC_MULTISEG     __BIT(0)
 #define USBMALLOC_COHERENT     __BIT(1)
+#define USBMALLOC_ZERO         __BIT(2)
 
 usbd_status    usb_allocmem(struct usbd_bus *, size_t, size_t, u_int, usb_dma_t *);
 void           usb_freemem(struct usbd_bus *, usb_dma_t *);



Home | Main Index | Thread Index | Old Index