From 36b588eb8bb74677cdbe1728cbdc96890fd818bb Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Wed, 27 May 2020 09:55:06 +0200 Subject: rtwn_usb: Make sure buffers are cache aligned --- freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c | 11 +++++++++++ freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'freebsd') diff --git a/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c b/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c index 8626d0a3..fad41f36 100644 --- a/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c +++ b/freebsd/sys/dev/rtwn/usb/rtwn_usb_attach.c @@ -37,6 +37,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef __rtems__ +#include +#include +#endif /* __rtems__ */ #include #include @@ -115,7 +119,14 @@ rtwn_usb_alloc_list(struct rtwn_softc *sc, struct rtwn_data data[], for (i = 0; i < ndata; i++) { struct rtwn_data *dp = &data[i]; dp->m = NULL; +#if defined(__rtems__) && defined(CPU_DATA_CACHE_ALIGNMENT) + maxsz = maxsz + (CPU_DATA_CACHE_ALIGNMENT - 1) & + ~(CPU_DATA_CACHE_ALIGNMENT - 1); + dp->buf = rtems_heap_allocate_aligned_with_boundary(maxsz, + CPU_DATA_CACHE_ALIGNMENT, 0); +#else /* __rtems__ */ dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT); +#endif /* __rtems__ */ if (dp->buf == NULL) { device_printf(sc->sc_dev, "could not allocate buffer\n"); diff --git a/freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c b/freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c index 61f0ba43..14762c0c 100644 --- a/freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c +++ b/freebsd/sys/dev/rtwn/usb/rtwn_usb_tx.c @@ -64,6 +64,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __rtems__ +#include +#endif /* __rtems__ */ + static struct rtwn_data * _rtwn_usb_getbuf(struct rtwn_usb_softc *); static struct rtwn_data * rtwn_usb_getbuf(struct rtwn_usb_softc *); static void rtwn_usb_txeof(struct rtwn_usb_softc *, @@ -170,6 +174,9 @@ tr_setup: if (data->ni == NULL && RTWN_CHIP_HAS_BCNQ1(sc)) rtwn_switch_bcnq(sc, data->id); usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen); +#if defined(__rtems__) && defined(CPU_DATA_CACHE_ALIGNMENT) + usbd_xfer_frame_allow_cache_line_blow_up(xfer, 0); +#endif /* __rtems__ */ usbd_transfer_submit(xfer); if (sc->sc_ratectl != RTWN_RATECTL_NET80211) sc->sc_tx_n_active++; -- cgit v1.2.3