Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen add and pass dma tag to PV drivers attached to ...



details:   https://anonhg.NetBSD.org/src/rev/724717e51dde
branches:  trunk
changeset: 930616:724717e51dde
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Apr 10 14:54:33 2020 +0000

description:
add and pass dma tag to PV drivers attached to xenbus, so thay can
use bus_dmamap_load_mbuf() et.al.

due to XENPV override, _BUS_BUS_TO_PHYS() dmamap segment ds_addr
gets filled with ma, so value can be directly used for e.g. grant calls

diffstat:

 sys/arch/xen/include/xenbus.h      |   5 ++++-
 sys/arch/xen/x86/xen_bus_dma.c     |  13 +++++++++++--
 sys/arch/xen/xen/hypervisor.c      |   8 +++++---
 sys/arch/xen/xenbus/xenbus_probe.c |   8 ++++++--
 4 files changed, 26 insertions(+), 8 deletions(-)

diffs (152 lines):

diff -r 40776569f31a -r 724717e51dde sys/arch/xen/include/xenbus.h
--- a/sys/arch/xen/include/xenbus.h     Fri Apr 10 14:35:26 2020 +0000
+++ b/sys/arch/xen/include/xenbus.h     Fri Apr 10 14:54:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus.h,v 1.22 2020/04/07 16:10:48 jdolecek Exp $ */
+/* $NetBSD: xenbus.h,v 1.23 2020/04/10 14:54:34 jdolecek Exp $ */
 /******************************************************************************
  * xenbus.h
  *
@@ -33,6 +33,7 @@
 #define _ASM_XEN_XENBUS_H
 
 #include <sys/device.h>
+#include <sys/bus.h>
 #include <sys/queue.h>
 #include <xen/include/public/xen.h>
 #include <xen/include/public/io/xenbus.h>
@@ -43,6 +44,7 @@
 struct xenbus_attach_args {
        const char              *xa_device;
        int                     xa_handle;
+       bus_dma_tag_t           xa_dmat;
 };
 
 /* devices to xenbus attach */
@@ -50,6 +52,7 @@
        const char              *xa_type;
        int                     xa_id;
        struct xenbus_device    *xa_xbusd;
+       bus_dma_tag_t           xa_dmat;
 };
 
 /* Register callback to watch this node. */
diff -r 40776569f31a -r 724717e51dde sys/arch/xen/x86/xen_bus_dma.c
--- a/sys/arch/xen/x86/xen_bus_dma.c    Fri Apr 10 14:35:26 2020 +0000
+++ b/sys/arch/xen/x86/xen_bus_dma.c    Fri Apr 10 14:54:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xen_bus_dma.c,v 1.29 2020/04/09 19:26:37 jdolecek Exp $        */
+/*     $NetBSD: xen_bus_dma.c,v 1.30 2020/04/10 14:54:33 jdolecek Exp $        */
 /*     NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.29 2020/04/09 19:26:37 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.30 2020/04/10 14:54:33 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -47,6 +47,15 @@
 
 extern paddr_t avail_end;
 
+/* No special needs */
+struct x86_bus_dma_tag xenbus_bus_dma_tag = {
+       ._tag_needs_free        = 0,
+       ._bounce_thresh         = 0,
+       ._bounce_alloc_lo       = 0,
+       ._bounce_alloc_hi       = 0,
+       ._may_bounce            = NULL,
+};
+
 /* Pure 2^n version of get_order */
 static inline int get_order(unsigned long size)
 {
diff -r 40776569f31a -r 724717e51dde sys/arch/xen/xen/hypervisor.c
--- a/sys/arch/xen/xen/hypervisor.c     Fri Apr 10 14:35:26 2020 +0000
+++ b/sys/arch/xen/xen/hypervisor.c     Fri Apr 10 14:54:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */
+/* $NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -415,7 +415,7 @@
        bi.common.len = sizeof(struct btinfo_rootdevice);
 
        /* From i386/multiboot.c */
-       /*      $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */
+       /*      $NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $ */
        int i, len;
        vaddr_t data;
        extern struct bootinfo  bootinfo;
@@ -545,8 +545,10 @@
 #endif /* MULTIPROCESSOR */
 
 #if NXENBUS > 0
+       extern struct x86_bus_dma_tag xenbus_bus_dma_tag;
        memset(&hac, 0, sizeof(hac));
        hac.hac_xenbus.xa_device = "xenbus";
+       hac.hac_xenbus.xa_dmat = &xenbus_bus_dma_tag;
        config_found_ia(self, "xendevbus", &hac.hac_xenbus, hypervisor_print);
 #endif
 #if NXENCONS > 0
diff -r 40776569f31a -r 724717e51dde sys/arch/xen/xenbus/xenbus_probe.c
--- a/sys/arch/xen/xenbus/xenbus_probe.c        Fri Apr 10 14:35:26 2020 +0000
+++ b/sys/arch/xen/xenbus/xenbus_probe.c        Fri Apr 10 14:54:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.47 2020/04/10 12:38:40 jdolecek Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.48 2020/04/10 14:54:33 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.47 2020/04/10 12:38:40 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.48 2020/04/10 14:54:33 jdolecek Exp $");
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -81,6 +81,7 @@
     NULL, NULL);
 
 device_t xenbus_dev;
+bus_dma_tag_t xenbus_dmat;
 
 SLIST_HEAD(, xenbus_device) xenbus_device_list;
 SLIST_HEAD(, xenbus_backend_driver) xenbus_backend_driver_list =
@@ -99,10 +100,12 @@
 static void
 xenbus_attach(device_t parent, device_t self, void *aux)
 {
+       struct xenbus_attach_args *xa = (struct xenbus_attach_args *)aux;
        int err;
 
        aprint_normal(": Xen Virtual Bus Interface\n");
        xenbus_dev = self;
+       xenbus_dmat = xa->xa_dmat;
        config_pending_incr(self);
 
        err = kthread_create(PRI_NONE, 0, NULL, xenbus_probe_init, NULL,
@@ -424,6 +427,7 @@
                        }
                } 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