Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Data written to bcmdmac(4) should be i...



details:   https://anonhg.NetBSD.org/src/rev/61183c5cae21
branches:  trunk
changeset: 946555:61183c5cae21
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Dec 01 04:15:04 2020 +0000

description:
Data written to bcmdmac(4) should be in little-endian.

diffstat:

 sys/arch/arm/broadcom/bcm2835_dmac.h   |  18 +++++++++++++++++-
 sys/arch/arm/broadcom/bcm2835_emmc.c   |   5 +++--
 sys/arch/arm/broadcom/bcm2835_sdhost.c |   5 +++--
 3 files changed, 23 insertions(+), 5 deletions(-)

diffs (97 lines):

diff -r 6dcdfedf071a -r 61183c5cae21 sys/arch/arm/broadcom/bcm2835_dmac.h
--- a/sys/arch/arm/broadcom/bcm2835_dmac.h      Tue Dec 01 04:14:31 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_dmac.h      Tue Dec 01 04:15:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_dmac.h,v 1.4 2015/08/09 13:06:44 mlelstv Exp $ */
+/* $NetBSD: bcm2835_dmac.h,v 1.5 2020/12/01 04:15:04 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,6 +29,8 @@
 #ifndef BCM2835_DMAC_H
 #define BCM2835_DMAC_H
 
+#include <sys/endian.h>
+
 #define DMAC_CS(n)             (0x00 + (0x100 * (n)))
 #define  DMAC_CS_RESET         __BIT(31)
 #define  DMAC_CS_ABORT         __BIT(30)
@@ -62,6 +64,9 @@
 #define  DMAC_DEBUG_FIFO_ERROR __BIT(1)
 #define  DMAC_DEBUG_READ_LAST_NOT_SET_ERROR __BIT(0)
 
+/*
+ * Byte-order is little endain.
+ */
 struct bcm_dmac_conblk {
        uint32_t        cb_ti;
 #define DMAC_TI_NO_WIDE_BURSTS __BIT(26)
@@ -108,5 +113,16 @@
 int bcm_dmac_transfer(struct bcm_dmac_channel *);
 void bcm_dmac_halt(struct bcm_dmac_channel *);
 
+static inline void
+bcm_dmac_swap_conblk(struct bcm_dmac_conblk *conblk)
+{
+
+       HTOLE32(conblk->cb_ti);
+       HTOLE32(conblk->cb_source_ad);
+       HTOLE32(conblk->cb_dest_ad);
+       HTOLE32(conblk->cb_txfr_len);
+       HTOLE32(conblk->cb_stride);
+       HTOLE32(conblk->cb_nextconbk);
+}
 
 #endif /* !BCM2835_DMAC_H */
diff -r 6dcdfedf071a -r 61183c5cae21 sys/arch/arm/broadcom/bcm2835_emmc.c
--- a/sys/arch/arm/broadcom/bcm2835_emmc.c      Tue Dec 01 04:14:31 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_emmc.c      Tue Dec 01 04:15:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_emmc.c,v 1.38 2020/08/28 13:13:55 skrll Exp $  */
+/*     $NetBSD: bcm2835_emmc.c,v 1.39 2020/12/01 04:15:04 rin Exp $    */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.38 2020/08/28 13:13:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.39 2020/12/01 04:15:04 rin Exp $");
 
 #include "bcmdmac.h"
 
@@ -327,6 +327,7 @@
                            sc->sc_dmamap->dm_segs[0].ds_addr +
                            sizeof(struct bcm_dmac_conblk) * (seg+1);
                }
+               bcm_dmac_swap_conblk(&sc->sc_cblk[seg]);
                sc->sc_cblk[seg].cb_padding[0] = 0;
                sc->sc_cblk[seg].cb_padding[1] = 0;
        }
diff -r 6dcdfedf071a -r 61183c5cae21 sys/arch/arm/broadcom/bcm2835_sdhost.c
--- a/sys/arch/arm/broadcom/bcm2835_sdhost.c    Tue Dec 01 04:14:31 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_sdhost.c    Tue Dec 01 04:15:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_sdhost.c,v 1.5 2020/05/31 23:52:19 thorpej Exp $ */
+/* $NetBSD: bcm2835_sdhost.c,v 1.6 2020/12/01 04:15:04 rin Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_sdhost.c,v 1.5 2020/05/31 23:52:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_sdhost.c,v 1.6 2020/12/01 04:15:04 rin Exp $");
 
 #include "bcmdmac.h"
 
@@ -397,6 +397,7 @@
                            sc->sc_dmamap->dm_segs[0].ds_addr +
                            sizeof(struct bcm_dmac_conblk) * (seg+1);
                }
+               bcm_dmac_swap_conblk(&sc->sc_cblk[seg]);
                sc->sc_cblk[seg].cb_padding[0] = 0;
                sc->sc_cblk[seg].cb_padding[1] = 0;
        }



Home | Main Index | Thread Index | Old Index