Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen put xenbus dmat into xenbus_device so it's avai...



details:   https://anonhg.NetBSD.org/src/rev/9dcbb5bafb13
branches:  trunk
changeset: 1009058:9dcbb5bafb13
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat Apr 11 11:01:12 2020 +0000

description:
put xenbus dmat into xenbus_device so it's available also for backend
devices which don't use autoconfig, remove from attach args

diffstat:

 sys/arch/xen/include/xenbus.h       |   4 ++--
 sys/arch/xen/xen/if_xennet_xenbus.c |  32 +++++++++++++++++---------------
 sys/arch/xen/xenbus/xenbus_probe.c  |   6 +++---
 3 files changed, 22 insertions(+), 20 deletions(-)

diffs (180 lines):

diff -r 76251548a5e4 -r 9dcbb5bafb13 sys/arch/xen/include/xenbus.h
--- a/sys/arch/xen/include/xenbus.h     Sat Apr 11 09:15:23 2020 +0000
+++ b/sys/arch/xen/include/xenbus.h     Sat Apr 11 11:01:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus.h,v 1.23 2020/04/10 14:54:34 jdolecek Exp $ */
+/* $NetBSD: xenbus.h,v 1.24 2020/04/11 11:01:12 jdolecek Exp $ */
 /******************************************************************************
  * xenbus.h
  *
@@ -52,7 +52,6 @@
        const char              *xa_type;
        int                     xa_id;
        struct xenbus_device    *xa_xbusd;
-       bus_dma_tag_t           xa_dmat;
 };
 
 /* Register callback to watch this node. */
@@ -100,6 +99,7 @@
        /* for xenbus internal use */
        struct xenbus_watch xbusd_otherend_watch;
        size_t xbusd_sz;                /* size of allocated structure */
+       bus_dma_tag_t xbusd_dmat;
        const char xbusd_path[1]; /* our path */
 };
 
diff -r 76251548a5e4 -r 9dcbb5bafb13 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Sat Apr 11 09:15:23 2020 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Sat Apr 11 11:01:12 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.111 2020/04/10 19:08:10 jdolecek Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.111 2020/04/10 19:08:10 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.112 2020/04/11 11:01:12 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -169,7 +169,6 @@
        struct ethercom sc_ethercom;
        uint8_t sc_enaddr[ETHER_ADDR_LEN];
        struct xenbus_device *sc_xbusd;
-       bus_dma_tag_t sc_dmat;
 
        netif_tx_front_ring_t sc_tx_ring;
        netif_rx_front_ring_t sc_rx_ring;
@@ -264,7 +263,6 @@
 
        sc->sc_xbusd = xa->xa_xbusd;
        sc->sc_xbusd->xbusd_otherend_changed = xennet_backend_changed;
-       sc->sc_dmat = xa->xa_dmat;
 
        /* xenbus ensure 2 devices can't be probed at the same time */
        if (if_xennetrxbuf_cache_inited == 0) {
@@ -280,8 +278,8 @@
                struct xennet_txreq *txreq = &sc->sc_txreqs[i];
        
                txreq->txreq_id = i;
-               if (bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
-                   PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
+               if (bus_dmamap_create(sc->sc_xbusd->xbusd_dmat, PAGE_SIZE, 1,
+                   PAGE_SIZE, PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
                    &txreq->txreq_dmamap) != 0)
                        break;
 
@@ -294,8 +292,8 @@
        for (i = 0; i < NET_RX_RING_SIZE; i++) {
                struct xennet_rxreq *rxreq = &sc->sc_rxreqs[i];
                rxreq->rxreq_id = i;
-               if (bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
-                   PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
+               if (bus_dmamap_create(sc->sc_xbusd->xbusd_dmat, PAGE_SIZE, 1,
+                   PAGE_SIZE, PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
                    &rxreq->rxreq_dmamap) != 0)
                        break;
                rxreq->rxreq_gntref = GRANT_INVALID_REF;
@@ -725,7 +723,8 @@
 
                /* Set M_EXT_CLUSTER so that load_mbuf uses m_ext.ext_paddr */
                m->m_flags |= M_EXT_CLUSTER;
-               if (__predict_false(bus_dmamap_load_mbuf(sc->sc_dmat,
+               if (__predict_false(bus_dmamap_load_mbuf(
+                   sc->sc_xbusd->xbusd_dmat,
                    req->rxreq_dmamap, m, BUS_DMA_NOWAIT) != 0)) {
                        printf("%s: rx mbuf load failed", ifp->if_xname);
                        m->m_flags &= ~M_EXT_CLUSTER;
@@ -867,7 +866,7 @@
                else
                        if_statinc(ifp, if_opackets);
                xengnt_revoke_access(req->txreq_gntref);
-               bus_dmamap_unload(sc->sc_dmat, req->txreq_dmamap);
+               bus_dmamap_unload(sc->sc_xbusd->xbusd_dmat, req->txreq_dmamap);
                m_freem(req->txreq_m);
                req->txreq_m = NULL;
                SLIST_INSERT_HEAD(&sc->sc_txreq_head, req, txreq_next);
@@ -927,7 +926,7 @@
                req->rxreq_m = NULL;
 
                m->m_len = m->m_pkthdr.len = rx->status;
-               bus_dmamap_sync(sc->sc_dmat, req->rxreq_dmamap, 0,
+               bus_dmamap_sync(sc->sc_xbusd->xbusd_dmat, req->rxreq_dmamap, 0,
                     m->m_pkthdr.len, BUS_DMASYNC_PREREAD);
 
                MCLAIM(m, &sc->sc_ethercom.ec_rx_mowner);
@@ -998,7 +997,8 @@
                }
 
                /* Try to load the mbuf as-is, if that fails allocate new */
-               if (__predict_false(bus_dmamap_load_mbuf(sc->sc_dmat,
+               if (__predict_false(bus_dmamap_load_mbuf(
+                   sc->sc_xbusd->xbusd_dmat,
                    req->txreq_dmamap, m, BUS_DMA_NOWAIT) != 0)) {
                        struct mbuf *new_m;
 
@@ -1026,7 +1026,8 @@
                        m_freem(m);
                        m = new_m;
 
-                       if (__predict_false(bus_dmamap_load_mbuf(sc->sc_dmat,
+                       if (__predict_false(bus_dmamap_load_mbuf(
+                           sc->sc_xbusd->xbusd_dmat,
                            req->txreq_dmamap, m, BUS_DMA_NOWAIT) != 0)) {
                                printf("%s: cannot load new mbuf\n",
                                       device_xname(sc->sc_dev));
@@ -1043,13 +1044,14 @@
                    sc->sc_xbusd->xbusd_otherend_id,
                    trunc_page(ma),
                    GNTMAP_readonly, &req->txreq_gntref) != 0)) {
-                       bus_dmamap_unload(sc->sc_dmat, req->txreq_dmamap);
+                       bus_dmamap_unload(sc->sc_xbusd->xbusd_dmat,
+                           req->txreq_dmamap);
                        m_freem(m);
                        break;
                }
 
                /* We are now committed to transmit the packet */
-               bus_dmamap_sync(sc->sc_dmat, req->txreq_dmamap, 0,
+               bus_dmamap_sync(sc->sc_xbusd->xbusd_dmat, req->txreq_dmamap, 0,
                     m->m_pkthdr.len, BUS_DMASYNC_POSTWRITE);
                MCLAIM(m, &sc->sc_ethercom.ec_tx_mowner);
 
diff -r 76251548a5e4 -r 9dcbb5bafb13 sys/arch/xen/xenbus/xenbus_probe.c
--- a/sys/arch/xen/xenbus/xenbus_probe.c        Sat Apr 11 09:15:23 2020 +0000
+++ b/sys/arch/xen/xenbus/xenbus_probe.c        Sat Apr 11 11:01:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.48 2020/04/10 14:54:33 jdolecek Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.49 2020/04/11 11:01:12 jdolecek Exp $ */
 /******************************************************************************
  * Talks to Xen Store to figure out what devices we have.
  *
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.48 2020/04/10 14:54:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.49 2020/04/11 11:01:12 jdolecek Exp $");
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -387,6 +387,7 @@
                msize = sizeof(*xbusd) + strlen(path) + strlen(dir[i]) + 2;
                xbusd = kmem_zalloc(msize, KM_SLEEP);
                xbusd->xbusd_sz = msize;
+               xbusd->xbusd_dmat = xenbus_dmat;
 
                snprintf(__UNCONST(xbusd->xbusd_path),
                    msize - sizeof(*xbusd) + 1, "%s/%s", path, dir[i]);
@@ -427,7 +428,6 @@
                        }
                } else {
                        xbusd->xbusd_type = XENBUS_FRONTEND_DEVICE;
-                       xa.xa_dmat = xenbus_dmat;
                        xa.xa_xbusd = xbusd;
                        xa.xa_type = type;
                        xa.xa_id = strtoul(dir[i], &ep, 0);



Home | Main Index | Thread Index | Old Index