Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jul 2015 05:44:59 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285074 - head/sys/dev/proto
Message-ID:  <201507030544.t635ixbS074277@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Fri Jul  3 05:44:58 2015
New Revision: 285074
URL: https://svnweb.freebsd.org/changeset/base/285074

Log:
  Implement unload and sync operations.

Modified:
  head/sys/dev/proto/proto_busdma.c
  head/sys/dev/proto/proto_dev.h

Modified: head/sys/dev/proto/proto_busdma.c
==============================================================================
--- head/sys/dev/proto/proto_busdma.c	Fri Jul  3 03:34:21 2015	(r285073)
+++ head/sys/dev/proto/proto_busdma.c	Fri Jul  3 05:44:58 2015	(r285074)
@@ -306,6 +306,28 @@ proto_busdma_md_load(struct proto_busdma
 	return (0);
 }
 
+static int
+proto_busdma_md_unload(struct proto_busdma *busdma, struct proto_md *md)
+{
+
+	if (!md->physaddr)
+		return (ENXIO);
+	bus_dmamap_unload(md->bd_tag, md->bd_map);
+	md->physaddr = 0;
+	return (0);
+}
+
+static int
+proto_busdma_sync(struct proto_busdma *busdma, struct proto_md *md,
+    struct proto_ioc_busdma *ioc)
+{
+ 
+	if (!md->physaddr)
+		return (ENXIO);
+	bus_dmamap_sync(md->bd_tag, md->bd_map, ioc->u.sync.op);
+	return (0);
+}
+
 static struct proto_md *
 proto_busdma_md_lookup(struct proto_busdma *busdma, u_long key)
 {
@@ -419,6 +441,22 @@ proto_busdma_ioctl(struct proto_softc *s
 		}
 		error = proto_busdma_md_load(busdma, md, ioc, td);
 		break;
+	case PROTO_IOC_BUSDMA_MD_UNLOAD:
+		md = proto_busdma_md_lookup(busdma, ioc->key);
+		if (md == NULL) {
+			error = EINVAL;
+			break;
+		}
+		error = proto_busdma_md_unload(busdma, md);
+		break;
+	case PROTO_IOC_BUSDMA_SYNC:
+		md = proto_busdma_md_lookup(busdma, ioc->key);
+		if (md == NULL) {
+			error = EINVAL;
+			break;
+		}
+		error = proto_busdma_sync(busdma, md, ioc);
+		break;
 	default:
 		error = EINVAL;
 		break;

Modified: head/sys/dev/proto/proto_dev.h
==============================================================================
--- head/sys/dev/proto/proto_dev.h	Fri Jul  3 03:34:21 2015	(r285073)
+++ head/sys/dev/proto/proto_dev.h	Fri Jul  3 05:44:58 2015	(r285074)
@@ -50,6 +50,8 @@ struct proto_ioc_busdma {
 #define	PROTO_IOC_BUSDMA_MD_CREATE	20
 #define	PROTO_IOC_BUSDMA_MD_DESTROY	21
 #define	PROTO_IOC_BUSDMA_MD_LOAD	22
+#define	PROTO_IOC_BUSDMA_MD_UNLOAD	29
+#define	PROTO_IOC_BUSDMA_SYNC		30
 	unsigned long	key;
 	union {
 		struct {
@@ -72,6 +74,11 @@ struct proto_ioc_busdma {
 			unsigned long	bus_addr;
 			unsigned int	bus_nsegs;
 		} md;
+		struct {
+			unsigned int	op;
+			unsigned long	base;
+			unsigned long	size;
+		} sync;
 	} u;
 	unsigned long	result;
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507030544.t635ixbS074277>