CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2021-01-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 15 22:58:49 UTC 2021

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_netbsd_fdt.c

Log Message:
use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.3 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.3	Tue Dec  1 04:19:04 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c	Fri Jan 15 22:58:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd_fdt.c,v 1.3 2020/12/01 04:19:04 rin Exp $ */
+/* $NetBSD: vchiq_netbsd_fdt.c,v 1.4 2021/01/15 22:58:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.3 2020/12/01 04:19:04 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.4 2021/01/15 22:58:49 jmcneill Exp $");
 
 #include 
 #include 
@@ -130,8 +130,8 @@ vchiq_fdt_defer(device_t self)
 		return;
 	}
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, FDT_INTR_MPSAFE,
-	vchiq_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_VM,
+	FDT_INTR_MPSAFE, vchiq_intr, sc, device_xname(self));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt %s\n",
 		intrstr);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-11-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Dec  1 04:19:04 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_netbsd_acpi.c vchiq_netbsd_fdt.c

Log Message:
Do not attach vchiq(4) in big-endian mode.

For big-endian mode, all data written to and read from DMA buffer must be
byte-swapped. This requires heavy modifications to third party codes.

Also, we will switch to vc4 drm driver, hopefully soon.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.2	Sat Feb 22 19:37:31 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c	Tue Dec  1 04:19:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd_acpi.c,v 1.2 2020/02/22 19:37:31 jmcneill Exp $ */
+/* $NetBSD: vchiq_netbsd_acpi.c,v 1.3 2020/12/01 04:19:04 rin Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_acpi.c,v 1.2 2020/02/22 19:37:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_acpi.c,v 1.3 2020/12/01 04:19:04 rin Exp $");
 
 #include 
 #include 
@@ -93,6 +93,11 @@ vchiq_acpi_attach(device_t parent, devic
 	sc->sc_iot = aa->aa_memt;
 	asc->sc_handle = aa->aa_node->ad_handle;
 
+#if BYTE_ORDER == BIG_ENDIAN
+	aprint_error_dev(sc->sc_dev, "not supported yet in big-endian mode\n");
+	return;
+#endif
+
 	rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
 	, _resource_parse_ops_default);
 	if (ACPI_FAILURE(rv))
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.2	Tue Dec  1 03:28:08 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c	Tue Dec  1 04:19:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd_fdt.c,v 1.2 2020/12/01 03:28:08 rin Exp $ */
+/* $NetBSD: vchiq_netbsd_fdt.c,v 1.3 2020/12/01 04:19:04 rin Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.2 2020/12/01 03:28:08 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.3 2020/12/01 04:19:04 rin Exp $");
 
 #include 
 #include 
@@ -89,6 +89,11 @@ vchiq_fdt_attach(device_t parent, device
 	sc->sc_iot = faa->faa_bst;
 	fsc->sc_phandle = phandle;
 
+#if BYTE_ORDER == BIG_ENDIAN
+	aprint_error_dev(sc->sc_dev, "not supported yet in big-endian mode\n");
+	return;
+#endif
+
 	bus_addr_t addr;
 	bus_size_t size;
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-11-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Dec  1 03:28:08 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_netbsd_fdt.c

Log Message:
Fix style of error message.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.1	Tue Dec 31 01:00:23 2019
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c	Tue Dec  1 03:28:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd_fdt.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $ */
+/* $NetBSD: vchiq_netbsd_fdt.c,v 1.2 2020/12/01 03:28:08 rin Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.2 2020/12/01 03:28:08 rin Exp $");
 
 #include 
 #include 
@@ -93,7 +93,7 @@ vchiq_fdt_attach(device_t parent, device
 	bus_size_t size;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
-		aprint_error(": couldn't get register address\n");
+		aprint_error_dev(sc->sc_dev, "couldn't get register address\n");
 		return;
 	}
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-11-03 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov  3 12:04:56 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.h

Log Message:
state struct should use fixed size types. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.7 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.8
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.7	Tue Nov  3 08:41:30 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h	Tue Nov  3 12:04:56 2020
@@ -371,7 +371,7 @@ typedef struct vchiq_shared_state_struct
 	REMOTE_EVENT_T recycle;
 
 	/* The slot_queue index where the next recycled slot will be written. */
-	int slot_queue_recycle;
+	int32_t slot_queue_recycle;
 
 	/* This event should be signalled when a synchronous message is sent. */
 	REMOTE_EVENT_T sync_trigger;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-11-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Nov  3 08:41:30 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c
vchiq_core.h

Log Message:
Fix build on aa64


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.22 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.23
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.22	Sat Sep 26 12:58:23 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Tue Nov  3 08:41:30 2020
@@ -42,6 +42,8 @@
 
 #include 
 
+#include 
+
 #include 
 #include 
 

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.6	Sat Sep 26 12:58:23 2020
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h	Tue Nov  3 08:41:30 2020
@@ -37,6 +37,8 @@
 #include 
 #include 
 
+#include 
+
 #include "vchiq_cfg.h"
 
 #include "vchiq.h"



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2020-09-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 26 10:56:37 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.15 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.16
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.15	Tue Aug 28 09:25:21 2018
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Sat Sep 26 10:56:37 2020
@@ -293,7 +293,7 @@ int fatal_signal_pending(VCHIQ_THREAD_T)
 #define __user
 
 #define	current			curlwp
-#define EXPORT_SYMBOL(x) 
+#define EXPORT_SYMBOL(x)
 #define PAGE_ALIGN(addr)	round_page(addr)
 
 typedef	void	irqreturn_t;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-02-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 22 19:37:31 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_netbsd_acpi.c

Log Message:
build fix


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.1	Tue Dec 31 01:00:23 2019
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c	Sat Feb 22 19:37:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd_acpi.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $ */
+/* $NetBSD: vchiq_netbsd_acpi.c,v 1.2 2020/02/22 19:37:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_acpi.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_acpi.c,v 1.2 2020/02/22 19:37:31 jmcneill Exp $");
 
 #include 
 #include 
@@ -105,7 +105,7 @@ vchiq_acpi_attach(device_t parent, devic
 		return;
 	}
 
-	if (bus_space_map(sc->sc_iot, mem->ar_base, mem->ar_size, 0,
+	if (bus_space_map(sc->sc_iot, mem->ar_base, mem->ar_length, 0,
 	>sc_ioh) != 0) {
 		aprint_error_dev(sc->sc_dev, "unable to map device\n");
 		return;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2020-01-22 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Jan 22 19:15:49 UTC 2020

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c
vchiq_arm.c vchiq_core.c vchiq_core.h vchiq_kern_lib.c vchiq_shim.c

Log Message:
align with upstream for 64bit compatibility.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.20 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.21
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.20	Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Wed Jan 22 19:15:49 2020
@@ -57,6 +57,9 @@
 #include "vchiq_netbsd.h"
 #include "vchiq_connected.h"
 
+#define VCPAGE_OFFSET 0x0fff
+#define VCPAGE_SHIFT  12
+
 #define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2)
 
 typedef struct vchiq_2835_state_struct {
@@ -146,7 +149,7 @@ vchiq_platform_init(VCHIQ_STATE_T *state
 	vchiq_log_info(vchiq_arm_log_level,
 	"%s: slot_phys = %lx\n", __func__, slot_phys);
 
-	WARN_ON(((int)slot_mem & (PAGE_SIZE - 1)) != 0);
+	WARN_ON(((uintptr_t)slot_mem & (PAGE_SIZE - 1)) != 0);
 
 	vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size);
 	if (!vchiq_slot_zero) {
@@ -187,12 +190,12 @@ vchiq_platform_init(VCHIQ_STATE_T *state
 	BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
 	vchiq_log_info(vchiq_arm_log_level,
-		"vchiq_init - done (slots %x, phys %x)",
-		(unsigned int)vchiq_slot_zero, (unsigned int)slot_phys);
+		"vchiq_init - done (slots %p, phys %x)",
+		vchiq_slot_zero, (unsigned int)slot_phys);
 
 	vchiq_call_connected_callbacks();
 
-   return 0;
+	return 0;
 
 failed_vchiq_init:
 failed_init_slots:
@@ -355,7 +358,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	pagelist->type = (dir == VCHIQ_BULK_RECEIVE) ?
 	PAGELIST_READ : PAGELIST_WRITE;
 	pagelist->length = size;
-	pagelist->offset = va & L2_S_OFFSET;
+	pagelist->offset = va & VCPAGE_OFFSET;
 
 	/*
 	 * busdma already coalesces contiguous pages for us
@@ -363,10 +366,10 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	for (int i = 0; i < bi->dmamap->dm_nsegs; i++) {
 		bus_addr_t addr = bi->dmamap->dm_segs[i].ds_addr;
 		bus_size_t len = bi->dmamap->dm_segs[i].ds_len;
-		bus_size_t off = addr & L2_S_OFFSET;
-		int npgs = ((off + len + L2_S_OFFSET) >> L2_S_SHIFT);
+		bus_size_t off = addr & VCPAGE_OFFSET;
+		int npgs = ((off + len + VCPAGE_OFFSET) >> VCPAGE_SHIFT);
 
-		pagelist->addrs[i] = addr & ~L2_S_OFFSET;
+		pagelist->addrs[i] = addr & ~VCPAGE_OFFSET;
 		pagelist->addrs[i] |= npgs - 1;
 	}
 
@@ -443,7 +446,7 @@ vchiq_complete_bulk(VCHIQ_BULK_T *bulk)
 		PAGELIST_T *pagelist = bi->pagelist;
 
 		vchiq_log_trace(vchiq_arm_log_level,
-			"free_pagelist - %x, %d", (unsigned int)pagelist, actual);
+			"free_pagelist - %p, %d", pagelist, actual);
 
 		bus_dmamap_sync(dma_tag, bi->pagelist_map, 0,
 		bi->pagelist_size, BUS_DMASYNC_POSTWRITE);
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.20 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.21
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.20	Tue Aug  7 09:01:52 2018
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Wed Jan 22 19:15:49 2020
@@ -461,8 +461,8 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 #define	_IOC_TYPE(x)	IOCGROUP(x)
 
 	vchiq_log_trace(vchiq_arm_log_level,
-		 "vchiq_ioctl - instance %x, cmd %s, arg %p",
-		(unsigned int)instance,
+		 "vchiq_ioctl - instance %p, cmd %s, arg %p",
+		instance,
 		((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
 		(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
 		ioctl_names[_IOC_NR(cmd)] : "", arg);
@@ -755,8 +755,8 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 break;
 			}
 			vchiq_log_info(vchiq_arm_log_level,
-"found bulk_waiter %x for pid %d",
-(unsigned int)waiter, current->l_proc->p_pid);
+"found bulk_waiter %p for pid %d",
+waiter, current->l_proc->p_pid);
 			args.userdata = >bulk_waiter;
 		}
 		status = vchiq_bulk_transfer
@@ -786,8 +786,8 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			list_add(>list, 

CVS commit: src/sys/external/bsd/vchiq

2019-12-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 31 01:00:23 UTC 2019

Modified Files:
src/sys/external/bsd/vchiq/conf: files.vchiq
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c vchiq_netbsd.h
Added Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_netbsd_acpi.c vchiq_netbsd_fdt.c

Log Message:
Split vchiq into separate fdt and acpi attachments.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/vchiq/conf/files.vchiq
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/conf/files.vchiq
diff -u src/sys/external/bsd/vchiq/conf/files.vchiq:1.3 src/sys/external/bsd/vchiq/conf/files.vchiq:1.4
--- src/sys/external/bsd/vchiq/conf/files.vchiq:1.3	Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/conf/files.vchiq	Tue Dec 31 01:00:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.vchiq,v 1.3 2017/12/10 21:38:27 skrll Exp $
+#	$NetBSD: files.vchiq,v 1.4 2019/12/31 01:00:22 jmcneill Exp $
 #
 # Broadcom VideoCore IV
 #
@@ -6,7 +6,6 @@
 define	vchiqbus { }
 
 device	vchiq: vchiqbus
-attach	vchiq at fdt
 file	external/bsd/vchiq/dist/interface/compat/vchi_bsd.c		vchiq
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	vchiq
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c		vchiq
@@ -17,4 +16,12 @@ file	external/bsd/vchiq/dist/interface/v
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	vchiq
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	vchiq
 
+attach	vchiq at fdt with vchiq_fdt
+file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c	vchiq_fdt
+
+ifdef acpinodebus
+attach	vchiq at acpinodebus with vchiq_acpi
+file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c	vchiq_acpi
+endif
+
 makeoptions	vchiq	CPPFLAGS+="-I$S/external/bsd/vchiq/dist -I$S/external/bsd/common/include -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x0400 -DVCHIQ_ENABLE_DEBUG=1 -DVCHIQ_LOG_DEFAULT=5"

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.10 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.11
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.10	Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Tue Dec 31 01:00:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.10 2017/12/10 21:38:27 skrll Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.11 2019/12/31 01:00:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.10 2017/12/10 21:38:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.11 2019/12/31 01:00:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -42,122 +42,26 @@ __KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_n
 #include 
 #include 
 
-#include 
-
 #include "vchiq_arm.h"
 #include "vchiq_2835.h"
 #include "vchiq_netbsd.h"
 
 extern VCHIQ_STATE_T g_state;
 
-struct vchiq_softc {
-	device_t sc_dev;
-	device_t sc_audiodev;
-
-	bus_space_tag_t sc_iot;
-	bus_space_handle_t sc_ioh;
-	void *sc_ih;
-
-	int sc_intr;
-	int sc_phandle;
-};
-
 static struct vchiq_softc *vchiq_softc = NULL;
 
-static int vchiq_match(device_t, cfdata_t, void *);
-static void vchiq_attach(device_t, device_t, void *);
-
-static int vchiq_intr(void *);
-static int vchiq_print(void *, const char *);
-static void vchiq_defer(device_t);
-
-/* External functions */
-int vchiq_init(void);
-
-
 #define VCHIQ_DOORBELL0		0x0
 #define VCHIQ_DOORBELL1		0x4
 #define VCHIQ_DOORBELL2		0x8
 #define VCHIQ_DOORBELL3		0xC
 
-
-CFATTACH_DECL_NEW(vchiq, sizeof(struct vchiq_softc),
-vchiq_match, vchiq_attach, NULL, NULL);
-
-static int
-vchiq_match(device_t parent, cfdata_t match, void *aux)
-{
-	const char * const compatible[] = { "brcm,bcm2835-vchiq", NULL };
-	struct fdt_attach_args * const faa = aux;
-
-	return of_match_compatible(faa->faa_phandle, compatible);
-}
-
-static void
-vchiq_attach(device_t parent, device_t self, void *aux)
+void
+vchiq_set_softc(struct vchiq_softc *sc)
 {
-	struct vchiq_softc *sc = device_private(self);
-	struct fdt_attach_args * const faa = aux;
-	const int phandle = faa->faa_phandle;
-
-	aprint_naive("\n");
-	aprint_normal(": BCM2835 VCHIQ\n");
-
-	sc->sc_dev = self;
-	sc->sc_iot = 

CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2018-08-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 28 09:25:21 UTC 2018

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Remove stuff now in sys/external/bsd/common


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.14 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.15
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.14	Sun Nov  5 09:11:43 2017
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Tue Aug 28 09:25:21 2018
@@ -216,32 +216,6 @@ device_rlprintf(int pps, device_t dev, c
 
 #define vchiq_static_assert(cond) CTASSERT(cond)
 
-#define KERN_EMERG	"<0>"	/* system is unusable			*/
-#define KERN_ALERT	"<1>"	/* action must be taken immediately	*/
-#define KERN_CRIT	"<2>"	/* critical conditions			*/
-#define KERN_ERR	"<3>"	/* error conditions			*/
-#define KERN_WARNING	"<4>"	/* warning conditions			*/
-#define KERN_NOTICE	"<5>"	/* normal but significant condition	*/
-#define KERN_INFO	"<6>"	/* informational			*/
-#define KERN_DEBUG	"<7>"	/* debug-level messages			*/
-#define KERN_CONT	""
-
-#define printk(fmt, args...)		printf(fmt, ##args)
-#define vprintk(fmt, args)		vprintf(fmt, args)
-
-/*
- * Malloc API
- */
-#define GFP_KERNEL	0
-#define GFP_ATOMIC	0
-
-MALLOC_DECLARE(M_VCHI);
-
-#define kmalloc(size, flags)	malloc((size), M_VCHI, M_NOWAIT | M_ZERO)
-#define kcalloc(n, size, flags)	malloc((n) * (size), M_VCHI, M_NOWAIT | M_ZERO)
-#define kzalloc(a, b)		kcalloc(1, (a), (b))
-#define kfree(p)		do { if (p) free(p, M_VCHI); } while (0)
-
 /*
  * Kernel module API
  */



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2018-08-09 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Thu Aug  9 06:29:08 UTC 2018

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
One newline is enough.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.12 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.13
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.12	Sun Feb  5 16:05:20 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Thu Aug  9 06:29:08 2018
@@ -3123,7 +3123,7 @@ vchiq_pause_internal(VCHIQ_STATE_T *stat
 		break;
 	default:
 		vchiq_log_error(vchiq_core_log_level,
-			"vchiq_pause_internal in state %s\n",
+			"vchiq_pause_internal in state %s",
 			conn_state_names[state->conn_state]);
 		status = VCHIQ_ERROR;
 		VCHIQ_STATS_INC(state, error_count);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2018-08-07 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Aug  7 09:01:52 UTC 2018

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_kern_lib.c

Log Message:
One newline is enough.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.19 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.20
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.19	Thu Nov 30 20:25:55 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Tue Aug  7 09:01:52 2018
@@ -1489,7 +1489,7 @@ dump_phys_mem(void *virt_addr, uint32_t 
 	pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
 	if (pages == NULL) {
 		vchiq_log_error(vchiq_arm_log_level,
-			"Unable to allocation memory for %d pages\n",
+			"Unable to allocation memory for %d pages",
 			num_pages);
 		return;
 	}

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.6	Wed Jan 28 09:41:04 2015
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	Tue Aug  7 09:01:52 2018
@@ -84,17 +84,17 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_IN
 	}
 	if (i==VCHIQ_INIT_RETRIES) {
 		vchiq_log_error(vchiq_core_log_level,
-			"%s: videocore not initialized\n", __func__);
+			"%s: videocore not initialized", __func__);
 		goto failed;
 	} else if (i>0) {
 		vchiq_log_warning(vchiq_core_log_level,
-			"%s: videocore initialized after %d retries\n", __func__, i);
+			"%s: videocore initialized after %d retries", __func__, i);
 	}
 
 	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 	if (!instance) {
 		vchiq_log_error(vchiq_core_log_level,
-			"%s: error allocating vchiq instance\n", __func__);
+			"%s: error allocating vchiq instance", __func__);
 		goto failed;
 	}
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface

2017-11-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov  5 09:11:43 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c vchi_bsd.h
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
Use IPL_VM and IST_MPSAFE instead of IPL_SCHED


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.9 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.10
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.9	Tue Sep  2 09:55:48 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Sun Nov  5 09:11:43 2017
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.9 2014/09/02 09:55:48 jmcneill Exp $
+ * $Id: vchi_bsd.c,v 1.10 2017/11/05 09:11:43 skrll Exp $
  */
 
 #include 
@@ -136,7 +136,7 @@ void
 _sema_init(struct semaphore *s, int value)
 {
 	memset(s, 0, sizeof(*s));
-	mutex_init(>mtx, MUTEX_DEFAULT, IPL_SCHED);
+	mutex_init(>mtx, MUTEX_DEFAULT, IPL_VM);
 	cv_init(>cv, "semacv");
 	s->value = value;
 }

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.13 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.14
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.13	Mon Sep 11 07:33:45 2017
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Sun Nov  5 09:11:43 2017
@@ -84,7 +84,7 @@ typedef kmutex_t spinlock_t;
  */
 #define DEFINE_SPINLOCK(name)	kmutex_t name
 
-#define spin_lock_init(lock)	mutex_init(lock, MUTEX_DEFAULT, IPL_SCHED)
+#define spin_lock_init(lock)	mutex_init(lock, MUTEX_DEFAULT, IPL_VM)
 #define spin_lock_destroy(lock)	mutex_destroy(lock)
 #define spin_lock(lock)		mutex_spin_enter(lock)
 #define spin_unlock(lock)	mutex_spin_exit(lock)
@@ -109,7 +109,7 @@ typedef kmutex_t rwlock_t;
 
 #define DEFINE_RWLOCK(name)	kmutex_t name
 
-#define rwlock_init(rwlock)	mutex_init(rwlock, MUTEX_DEFAULT, IPL_SCHED)
+#define rwlock_init(rwlock)	mutex_init(rwlock, MUTEX_DEFAULT, IPL_VM)
 #define read_lock(rwlock)	mutex_spin_enter(rwlock)
 #define read_unlock(rwlock)	mutex_spin_exit(rwlock)
 

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.8 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.9
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.8	Thu Sep 21 19:29:35 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Sun Nov  5 09:11:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.8 2017/09/21 19:29:35 skrll Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.9 2017/11/05 09:11:43 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.8 2017/09/21 19:29:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.9 2017/11/05 09:11:43 skrll Exp $");
 
 #include 
 #include 
@@ -125,7 +125,7 @@ vchiq_defer(device_t self)
 
 	vchiq_core_initialize();
 
-	sc->sc_ih = intr_establish(sc->sc_intr, IPL_SCHED, IST_LEVEL,
+	sc->sc_ih = intr_establish(sc->sc_intr, IPL_VM, IST_LEVEL | IST_MPSAFE,
 	vchiq_intr, sc);
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "failed to establish interrupt %d\n",



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2017-09-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 21 19:29:35 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
Spaces to TAB


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.7 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.8
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.7	Thu Jan 12 05:35:45 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Thu Sep 21 19:29:35 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.7 2017/01/12 05:35:45 skrll Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.8 2017/09/21 19:29:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.7 2017/01/12 05:35:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.8 2017/09/21 19:29:35 skrll Exp $");
 
 #include 
 #include 
@@ -96,7 +96,7 @@ vchiq_match(device_t parent, cfdata_t ma
 static void
 vchiq_attach(device_t parent, device_t self, void *aux)
 {
-struct vchiq_softc *sc = device_private(self);
+	struct vchiq_softc *sc = device_private(self);
 	struct amba_attach_args *aaa = aux;
 
 	aprint_naive("\n");
@@ -181,8 +181,8 @@ remote_event_signal(REMOTE_EVENT_T *even
 	if (event->armed) {
 		bus_space_write_4(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
 		VCHIQ_DOORBELL2, 0);
-bus_space_barrier(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
-VCHIQ_DOORBELL2, 4, BUS_SPACE_BARRIER_WRITE);
+		bus_space_barrier(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
+		VCHIQ_DOORBELL2, 4, BUS_SPACE_BARRIER_WRITE);
 	}
 }
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2017-09-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Sep 11 05:25:53 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Use common barrier.h rather than separate implementation. NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.11 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.12
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.11	Mon Sep 11 00:58:20 2017
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Mon Sep 11 05:25:53 2017
@@ -28,10 +28,6 @@
 #ifndef __VCHI_NETBSD_H__
 #define __VCHI_NETBSD_H__
 
-#ifdef _KERNEL_OPT
-#include "opt_multiprocessor.h"
-#endif
-
 #include 
 #include 
 #include 
@@ -49,6 +45,7 @@
 #include 
 
 #include 
+#include 
 
 /*
  * Copy from/to user API
@@ -331,21 +328,6 @@ typedef	off_t	loff_t;
 #define BCM2835_MBOX_CHAN_VCHIQ	3
 #define bcm_mbox_write	bcmmbox_write
 
-#define mb  membar_sync
-#define wmb membar_producer
-#define rmb membar_consumer
-#define dsb	membar_producer
-
-#ifdef MULTIPROCESSOR
-#  define   smp_mb  mb
-#  define   smp_wmb wmb
-#  define   smp_rmb rmb
-#else
-#  define   smp_mb()do {} while (0)
-#  define   smp_wmb()   do {} while (0)
-#  define   smp_rmb()   do {} while (0)
-#endif
-
 #define device_print_prettyname(dev)	device_printf((dev), "")
 
 #endif /* __VCHI_NETBSD_H__ */



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2017-09-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Sep 11 00:58:20 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Include opt_multiprocessor.h for MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.10 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.11
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.10	Thu Jan 12 05:25:03 2017
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Mon Sep 11 00:58:20 2017
@@ -28,6 +28,10 @@
 #ifndef __VCHI_NETBSD_H__
 #define __VCHI_NETBSD_H__
 
+#ifdef _KERNEL_OPT
+#include "opt_multiprocessor.h"
+#endif
+
 #include 
 #include 
 #include 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2017-02-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  5 16:05:20 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
Don't call _sema_init twice on various objects... remote_event_create
will initialise them

Found by LOCKDEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.11 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.12
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.11	Thu Jan 12 05:41:25 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sun Feb  5 16:05:20 2017
@@ -2443,10 +2443,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, V
 
 	_sema_init(>connect, 0);
 	lmutex_init(>mutex);
-	_sema_init(>trigger_event, 0);
-	_sema_init(>recycle_event, 0);
-	_sema_init(>sync_trigger_event, 0);
-	_sema_init(>sync_release_event, 0);
 
 	lmutex_init(>slot_mutex);
 	lmutex_init(>recycle_mutex);



CVS commit: src/sys/external/bsd/vchiq/dist/interface

2017-01-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 05:41:25 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchi: vchi.h vchi_common.h
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq.h
vchiq_2835_arm.c vchiq_arm.c vchiq_arm.h vchiq_cfg.h
vchiq_connected.h vchiq_core.c vchiq_core.h vchiq_genversion
vchiq_if.h vchiq_ioctl.h vchiq_shim.c vchiq_util.c vchiq_util.h
Added Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_debugfs.h
Removed Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_proc.c

Log Message:
Sync with latest github/raspberrypi/linux sources

XXX should provide a vchiq2netbsd and cvs import


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h \
src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_cfg.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_connected.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_genversion
cvs rdiff -u -r1.17 -r1.18 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_debugfs.h
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_if.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_ioctl.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h
cvs rdiff -u -r1.2 -r0 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchi/vchi.h	Thu Jan 12 05:41:25 2017
@@ -220,7 +220,12 @@ extern int32_t vchi_service_use( const V
 // Routine to decrement ref count on a named service
 extern int32_t vchi_service_release( const VCHI_SERVICE_HANDLE_T handle );
 
-// Routine to send a message accross a service
+// Routine to set a control option for a named service
+extern int32_t vchi_service_set_option( const VCHI_SERVICE_HANDLE_T handle,
+	VCHI_SERVICE_OPTION_T option,
+	int value);
+
+// Routine to send a message across a service
 extern int32_t vchi_msg_queue( VCHI_SERVICE_HANDLE_T handle,
const void *data,
uint32_t data_size,
Index: src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_common.h	Thu Jan 12 05:41:25 2017
@@ -110,7 +110,19 @@ typedef enum
VCHI_CALLBACK_REASON_MAX
 } VCHI_CALLBACK_REASON_T;
 
-//Calback used by all services / bulk transfers
+// service control options
+typedef enum
+{
+   VCHI_SERVICE_OPTION_MIN,
+
+   VCHI_SERVICE_OPTION_TRACE,
+   VCHI_SERVICE_OPTION_SYNCHRONOUS,
+
+   VCHI_SERVICE_OPTION_MAX
+} VCHI_SERVICE_OPTION_T;
+
+
+//Callback used by all services / bulk transfers
 typedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param
  VCHI_CALLBACK_REASON_T reason,
  void *handle ); //for transmitting msg's only

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq.h	Thu Jan 12 05:41:25 2017
@@ -38,4 +38,3 @@
 #include "vchiq_util.h"
 
 #endif
-
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.h
diff -u 

CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2017-01-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 05:35:45 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
Use some macros for magic numbers and correct return value.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.6	Fri Jan 15 07:49:41 2016
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Thu Jan 12 05:35:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.6 2016/01/15 07:49:41 mlelstv Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.7 2017/01/12 05:35:45 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.6 2016/01/15 07:49:41 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.7 2017/01/12 05:35:45 skrll Exp $");
 
 #include 
 #include 
@@ -72,6 +72,13 @@ static void vchiq_defer(device_t);
 /* External functions */
 int vchiq_init(void);
 
+
+#define VCHIQ_DOORBELL0		0x40
+#define VCHIQ_DOORBELL1		0x44
+#define VCHIQ_DOORBELL2		0x48
+#define VCHIQ_DOORBELL3		0x4C
+
+
 CFATTACH_DECL_NEW(vchiq, sizeof(struct vchiq_softc),
 vchiq_match, vchiq_attach, NULL, NULL);
 
@@ -138,14 +145,17 @@ vchiq_intr(void *priv)
 	struct vchiq_softc *sc = priv;
 	uint32_t status;
 
-	status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, 0x40);
-	if (status & 0x4)
-		remote_event_pollall(_state);
+	bus_space_barrier(sc->sc_iot, sc->sc_ioh,
+	VCHIQ_DOORBELL0, 4, BUS_SPACE_BARRIER_READ);
 
-	bus_space_barrier(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
-	0x40, 4, BUS_SPACE_BARRIER_READ);
+	rmb();
+	status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, VCHIQ_DOORBELL0);
+	if (status & 0x4) {
+		remote_event_pollall(_state);
+		return 1;
+	}
 
-	return 1;
+	return 0;
 }
 
 static int
@@ -169,10 +179,10 @@ remote_event_signal(REMOTE_EVENT_T *even
 	dsb();		/* data barrier operation */
 
 	if (event->armed) {
-		bus_space_barrier(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
-		0x48, 4, BUS_SPACE_BARRIER_WRITE);
 		bus_space_write_4(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
-		0x48, 0);
+		VCHIQ_DOORBELL2, 0);
+bus_space_barrier(vchiq_softc->sc_iot, vchiq_softc->sc_ioh,
+VCHIQ_DOORBELL2, 4, BUS_SPACE_BARRIER_WRITE);
 	}
 }
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2017-01-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jan 12 05:25:03 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Sync memory barriers with sys/external/bsd/drm2/include/asm/barrier.h


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.9 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.10
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.9	Sat Oct 25 11:35:15 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Thu Jan 12 05:25:03 2017
@@ -327,13 +327,20 @@ typedef	off_t	loff_t;
 #define BCM2835_MBOX_CHAN_VCHIQ	3
 #define bcm_mbox_write	bcmmbox_write
 
-#define rmb	membar_consumer
-#define wmb	membar_producer
+#define mb  membar_sync
+#define wmb membar_producer
+#define rmb membar_consumer
 #define dsb	membar_producer
 
-#define smp_mb	membar_producer
-#define smp_rmb	membar_consumer
-#define smp_wmb	membar_producer
+#ifdef MULTIPROCESSOR
+#  define   smp_mb  mb
+#  define   smp_wmb wmb
+#  define   smp_rmb rmb
+#else
+#  define   smp_mb()do {} while (0)
+#  define   smp_wmb()   do {} while (0)
+#  define   smp_rmb()   do {} while (0)
+#endif
 
 #define device_print_prettyname(dev)	device_printf((dev), "")
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2017-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan  8 05:20:51 UTC 2017

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
xxx: gcc avoid bogus ssp warning


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.16 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.17
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.16	Wed Jan 28 04:41:04 2015
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sun Jan  8 00:20:51 2017
@@ -2513,7 +2513,7 @@ vchiq_dump_service_use_state(VCHIQ_STATE
 	VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state);
 	int i, j = 0;
 	/* Only dump 64 services */
-	static const int local_max_services = 64;
+#define local_max_services 64
 	/* If there's more than 64 services, only dump ones with
 	 * non-zero counts */
 	int only_nonzero = 0;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2016-01-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 15 07:49:41 UTC 2016

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
add sysctl nodes to configure vchiq log levels.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.5	Wed Jul 29 14:22:49 2015
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Fri Jan 15 07:49:41 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.5 2015/07/29 14:22:49 skrll Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.6 2016/01/15 07:49:41 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.5 2015/07/29 14:22:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.6 2016/01/15 07:49:41 mlelstv Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -174,3 +175,32 @@ remote_event_signal(REMOTE_EVENT_T *even
 		0x48, 0);
 	}
 }
+
+SYSCTL_SETUP(sysctl_hw_vchiq_setup, "sysctl hw.vchiq setup")
+{
+	const struct sysctlnode *rnode = NULL;
+	const struct sysctlnode *cnode = NULL;
+
+	sysctl_createv(clog, 0, NULL, ,
+	CTLFLAG_PERMANENT, CTLTYPE_NODE, "vchiq", NULL,
+	NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, , ,
+	CTLFLAG_PERMANENT, CTLTYPE_NODE, "loglevel", NULL,
+	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, , NULL,
+	CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+	CTLTYPE_INT, "core", "VChiq Core Loglevel", NULL, 0,
+	_core_log_level, 0, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, , NULL,
+	CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+	CTLTYPE_INT, "coremsg", "VChiq Core Message Loglevel", NULL, 0,
+	_core_msg_log_level, 0, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, , NULL,
+	CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+	CTLTYPE_INT, "sync", "VChiq Sync Loglevel", NULL, 0,
+	_sync_log_level, 0, CTL_CREATE, CTL_EOL);
+}



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2015-01-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 28 09:41:04 UTC 2015

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_kern_lib.c

Log Message:
It turns out we needed to track pid all along, so revert the lwp tracking
I did ages ago.

quake has a chance of working now.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.15 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.16
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.15	Fri Jan 23 10:19:22 2015
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Wed Jan 28 09:41:04 2015
@@ -120,7 +120,7 @@ typedef struct user_service_struct {
 
 struct bulk_waiter_node {
 	struct bulk_waiter bulk_waiter;
-	struct lwp *l;
+	int pid;
 	struct list_head list;
 };
 
@@ -135,7 +135,7 @@ struct vchiq_instance_struct {
 
 	int connected;
 	int closing;
-	struct lwp *l;
+	int pid;
 	int mark;
 
 	struct list_head bulk_waiter_list;
@@ -527,7 +527,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 
 			if (pargs-is_open) {
 status = vchiq_open_service_internal
-	(service, (uintptr_t)instance-l);
+	(service, instance-pid);
 if (status != VCHIQ_SUCCESS) {
 	vchiq_remove_service(service-handle);
 	service = NULL;
@@ -660,7 +660,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			lmutex_lock(instance-bulk_waiter_list_mutex);
 			list_for_each(pos, instance-bulk_waiter_list) {
 if (list_entry(pos, struct bulk_waiter_node,
-	list)-l == current) {
+	list)-pid == current-l_proc-p_pid) {
 	waiter = list_entry(pos,
 		struct bulk_waiter_node,
 		list);
@@ -672,14 +672,14 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			lmutex_unlock(instance-bulk_waiter_list_mutex);
 			if (!waiter) {
 vchiq_log_error(vchiq_arm_log_level,
-	no bulk_waiter found for lwp %p,
-	current);
+	no bulk_waiter found for pid %d,
+	current-l_proc-p_pid);
 ret = -ESRCH;
 break;
 			}
 			vchiq_log_info(vchiq_arm_log_level,
-found bulk_waiter %x for lwp %p,
-(unsigned int)waiter, current);
+found bulk_waiter %x for pid %d,
+(unsigned int)waiter, current-l_proc-p_pid);
 			pargs-userdata = waiter-bulk_waiter;
 		}
 		status = vchiq_bulk_transfer
@@ -704,13 +704,13 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 		} else {
 			const VCHIQ_BULK_MODE_T mode_waiting =
 VCHIQ_BULK_MODE_WAITING;
-			waiter-l = current;
+			waiter-pid = current-l_proc-p_pid;
 			lmutex_lock(instance-bulk_waiter_list_mutex);
 			list_add(waiter-list, instance-bulk_waiter_list);
 			lmutex_unlock(instance-bulk_waiter_list_mutex);
 			vchiq_log_info(vchiq_arm_log_level,
-saved bulk_waiter %x for lwp %p,
-(unsigned int)waiter, current);
+saved bulk_waiter %x for pid %d,
+(unsigned int)waiter, current-l_proc-p_pid);
 
 			pargs-mode = mode_waiting;
 		}
@@ -1064,7 +1064,7 @@ vchiq_open(dev_t dev, int flags, int mod
 		}
 
 		instance-state = state;
-		instance-l = l;
+		instance-pid = current-l_proc-p_pid;
 
 #ifdef notyet
 		ret = vchiq_proc_add_instance(instance);
@@ -1205,8 +1205,8 @@ vchiq_close(struct file *fp)
 list_del(pos);
 vchiq_log_info(vchiq_arm_log_level,
 	bulk_waiter - cleaned up %x 
-	for lwp %p,
-	(unsigned int)waiter, waiter-l);
+	for pid %d,
+	(unsigned int)waiter, waiter-pid);
 		_sema_destroy(waiter-bulk_waiter.event);
 kfree(waiter);
 			}
@@ -1297,9 +1297,9 @@ vchiq_dump_platform_instances(void *dump
 			instance = service-instance;
 			if (instance  !instance-mark) {
 len = snprintf(buf, sizeof(buf),
-	Instance %x: lwp %p,%s completions 
+	Instance %x: pid %d,%s completions 
 		%d/%d,
-	(unsigned int)instance, instance-l,
+	(unsigned int)instance, instance-pid,
 	instance-connected ?  connected,  :
 		,
 	instance-completion_insert -

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.5	Wed Jul 16 23:59:58 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	Wed Jan 28 09:41:04 2015
@@ -42,7 +42,7 @@
 
 struct bulk_waiter_node {
 	struct bulk_waiter bulk_waiter;
-	struct lwp *l;
+	int pid;
 	struct list_head list;
 };
 
@@ -151,8 +151,8 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INST
 			

CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2015-01-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 23 10:19:22 UTC 2015

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
More count vs ret confusion. Need to send notification if count != 0.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.14 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.15
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.14	Sat Dec 20 19:40:49 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Fri Jan 23 10:19:22 2015
@@ -718,6 +718,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 
 	case VCHIQ_IOC_AWAIT_COMPLETION: {
 		VCHIQ_AWAIT_COMPLETION_T *pargs = arg;
+		int count = 0;
 
 		DEBUG_TRACE(AWAIT_COMPLETION_LINE);
 		if (!instance-connected) {
@@ -752,9 +753,8 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 
 		if (ret == 0) {
 			int msgbufcount = pargs-msgbufcount;
-			int count;
 
-			for (count = 0; count  pargs-count; count++) {
+			for (; count  pargs-count; count++) {
 VCHIQ_COMPLETION_DATA_T *completion;
 VCHIQ_SERVICE_T *service1;
 USER_SERVICE_T *user_service;
@@ -847,7 +847,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			pargs-count = count;
 		}
 
-		if (ret != 0)
+		if (count != 0)
 			up(instance-remove_event);
 		lmutex_unlock(instance-completion_mutex);
 		DEBUG_TRACE(AWAIT_COMPLETION_LINE);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-12-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Dec 20 19:40:49 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
Enable state/stats information on vchiq device read.

This commit was approved by skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.13 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.14
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.13	Fri Jul 25 08:10:40 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sat Dec 20 19:40:49 2014
@@ -36,6 +36,7 @@
 #include sys/device.h
 #include sys/file.h
 #include sys/filedesc.h
+#include sys/kmem.h
 
 #include vchiq_core.h
 #include vchiq_ioctl.h
@@ -196,9 +197,10 @@ extern struct cfdriver vchiq_cd;
 
 static int	vchiq_ioctl(struct file *, u_long, void *);
 static int	vchiq_close(struct file *);
+static int	vchiq_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
 
 static const struct fileops vchiq_fileops = {
-	.fo_read = fbadop_read,
+	.fo_read = vchiq_read,
 	.fo_write = fbadop_write,
 	.fo_ioctl = vchiq_ioctl,
 	.fo_fcntl = fnullop_fcntl,
@@ -1245,9 +1247,7 @@ vchiq_dump(void *dump_context, const cha
 		copy_bytes = min(len, (int)(context-space - context-actual));
 		if (copy_bytes == 0)
 			return;
-		if (copy_to_user(context-buf + context-actual, str,
-			copy_bytes))
-			context-actual = -EFAULT;
+		memcpy(context-buf + context-actual, str, copy_bytes);
 		context-actual += copy_bytes;
 		len -= copy_bytes;
 
@@ -1256,9 +1256,7 @@ vchiq_dump(void *dump_context, const cha
 		** carriage return. */
 		if ((len == 0)  (str[copy_bytes - 1] == '\0')) {
 			char cr = '\n';
-			if (copy_to_user(context-buf + context-actual - 1,
-cr, 1))
-context-actual = -EFAULT;
+			memcpy(context-buf + context-actual - 1, cr, 1);
 		}
 	}
 }
@@ -1432,6 +1430,7 @@ dump_phys_mem(void *virt_addr, uint32_t 
 
 	kfree(pages);
 }
+#endif
 
 /
 *
@@ -1439,23 +1438,29 @@ dump_phys_mem(void *virt_addr, uint32_t 
 *
 ***/
 
-static ssize_t
-vchiq_read(struct file *file, char __user *buf,
-	size_t count, loff_t *ppos)
+static int
+vchiq_read(struct file *file, off_t *ppos, struct uio *uio, kauth_cred_t cred,
+int flags)
 {
+	int result;
+
+	char *buf = kmem_zalloc(PAGE_SIZE, KM_SLEEP);
+
 	DUMP_CONTEXT_T context;
 	context.buf = buf;
 	context.actual = 0;
-	context.space = count;
+	context.space = PAGE_SIZE;
 	context.offset = *ppos;
 
 	vchiq_dump_state(context, g_state);
 
 	*ppos += context.actual;
 
-	return context.actual;
+	result = uiomove(buf, context.actual, uio);
+	kmem_free(buf, PAGE_SIZE);
+	
+	return result;
 }
-#endif
 
 VCHIQ_STATE_T *
 vchiq_get_state(void)



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-12-20 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Dec 20 19:49:27 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
Allow more space for temp string buffer in service stats display.
Fixes corrupted display when rx and tx count become large.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.9 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.10
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.9	Thu Mar 27 23:03:07 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sat Dec 20 19:49:27 2014
@@ -3648,7 +3648,7 @@ vchiq_dump_state(void *dump_context, VCH
 void
 vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service)
 {
-	char buf[80];
+	char buf[120];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), Service %d: %s (ref %u),



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-10-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 25 11:35:15 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
G/C some unused code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.8 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.9
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.8	Tue Sep  2 09:55:48 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Sat Oct 25 11:35:15 2014
@@ -53,46 +53,6 @@
 #define copy_to_user(to, from, n)	copyout((from), (to), (n))
 
 /*
- * Bit API
- */
-
-static __inline int
-test_and_set_bit(int nr, volatile void *addr)
-{
-	volatile uint32_t *val;
-	uint32_t mask, old;
-
-	val = (volatile uint32_t *)addr;
-	mask = 1  nr;
-
-	do {
-		old = *val;
-		if ((old  mask) != 0)
-			break;
-	} while (atomic_cas_uint(val, old, old | mask) != old);
-
-	return old  mask;
-}
-
-static __inline__ int
-test_and_clear_bit(int nr, volatile void *addr)
-{
-	volatile uint32_t *val;
-	uint32_t mask, old;
-
-	val = (volatile uint32_t *)addr;
-	mask = 1  nr;
-
-	do {
-		old = *val;
-		if ((old  mask) == 0)
-			break;
-	} while (atomic_cas_uint(val, old, old  ~mask) != old);
-
-	return old  mask;
-}
-
-/*
  * Atomic API
  */
 typedef volatile unsigned int atomic_t;



CVS commit: src/sys/external/bsd/vchiq/dist/interface

2014-09-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep  2 09:55:48 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c vchi_bsd.h
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
IPL_VM - IPL_SCHED, and callout_stop - callout_halt


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.8 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.9
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.8	Fri Apr 25 15:49:17 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Tue Sep  2 09:55:48 2014
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.8 2014/04/25 15:49:17 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.9 2014/09/02 09:55:48 jmcneill Exp $
  */
 
 #include sys/types.h
@@ -106,7 +106,7 @@ int
 del_timer_sync(struct timer_list *t)
 {
 	spin_lock(t-mtx);
-	callout_stop(t-callout);
+	callout_halt(t-callout, t-mtx);
 	spin_unlock(t-mtx);
 
 	spin_lock_destroy(t-mtx);
@@ -136,7 +136,7 @@ void
 _sema_init(struct semaphore *s, int value)
 {
 	memset(s, 0, sizeof(*s));
-	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_VM);
+	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_SCHED);
 	cv_init(s-cv, semacv);
 	s-value = value;
 }
@@ -314,8 +314,8 @@ vchiq_thread_create(int (*threadfn)(void
 	va_end(ap);
 
 	newt = NULL;
-	if (kthread_create(PRI_NONE, 0, NULL, kthread_wrapper, slot, newt,
-	%s, name) != 0) {
+	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, kthread_wrapper,
+	slot, newt, %s, name) != 0) {
 		/* Just to be sure */
 		newt = NULL;
 	} else {

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.7 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.8
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.7	Sat Apr 12 13:28:41 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Tue Sep  2 09:55:48 2014
@@ -123,7 +123,7 @@ typedef kmutex_t spinlock_t;
  */
 #define DEFINE_SPINLOCK(name)	kmutex_t name
 
-#define spin_lock_init(lock)	mutex_init(lock, MUTEX_DEFAULT, IPL_VM)
+#define spin_lock_init(lock)	mutex_init(lock, MUTEX_DEFAULT, IPL_SCHED)
 #define spin_lock_destroy(lock)	mutex_destroy(lock)
 #define spin_lock(lock)		mutex_spin_enter(lock)
 #define spin_unlock(lock)	mutex_spin_exit(lock)
@@ -148,7 +148,7 @@ typedef kmutex_t rwlock_t;
 
 #define DEFINE_RWLOCK(name)	kmutex_t name
 
-#define rwlock_init(rwlock)	mutex_init(rwlock, MUTEX_DEFAULT, IPL_VM)
+#define rwlock_init(rwlock)	mutex_init(rwlock, MUTEX_DEFAULT, IPL_SCHED)
 #define read_lock(rwlock)	mutex_spin_enter(rwlock)
 #define read_unlock(rwlock)	mutex_spin_exit(rwlock)
 

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.2	Mon Mar 25 22:59:25 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Tue Sep  2 09:55:48 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.2 2013/03/25 22:59:25 jmcneill Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.3 2014/09/02 09:55:48 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vchiq_kmod_netbsd.c,v 1.2 2013/03/25 22:59:25 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: vchiq_kmod_netbsd.c,v 1.3 2014/09/02 09:55:48 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -117,7 +117,7 @@ vchiq_defer(device_t self)
 
 	vchiq_core_initialize();
 
-	sc-sc_ih = bcm2835_intr_establish(sc-sc_intr, IPL_VM,
+	sc-sc_ih = bcm2835_intr_establish(sc-sc_intr, IPL_SCHED,
 	vchiq_intr, sc);
 	if (sc-sc_ih == NULL) {
 		aprint_error_dev(self, failed to establish interrupt %d\n,



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-09-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep  2 21:38:28 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_shim.c

Log Message:
expose vchi_get_peer_version


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.4 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.4	Wed Jul 16 23:59:58 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c	Tue Sep  2 21:38:28 2014
@@ -725,7 +725,6 @@ int32_t vchi_service_destroy(const VCHI_
 }
 EXPORT_SYMBOL(vchi_service_destroy);
 
-#ifdef notyet
 int32_t vchi_get_peer_version( const VCHI_SERVICE_HANDLE_T handle, short *peer_version )
 {
int32_t ret = -1;
@@ -739,6 +738,7 @@ int32_t vchi_get_peer_version( const VCH
 }
 EXPORT_SYMBOL(vchi_get_peer_version);
 
+#if notyet
 /* --
  * read a uint32_t from buffer.
  * network format is defined to be little endian



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-07-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jul 16 23:59:58 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_kern_lib.c
vchiq_shim.c

Log Message:
From 
https://github.com/raspberrypi/linux/commit/517d5c1c9ceb7bf94c4e56e4fb97758e13f24b3b

 Fix for ALSA driver crash
 Avoids an issue when closing and opening vchiq where a message can arrive 
 before service handle has been written


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.4 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.4	Thu Mar 27 23:03:07 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	Wed Jul 16 23:59:58 2014
@@ -288,12 +288,13 @@ VCHIQ_STATUS_T vchiq_open_service(
 		NULL);
 
 	if (service) {
+		*phandle = service-handle;
 		status = vchiq_open_service_internal(service,
 		(uintptr_t)current);
-		if (status == VCHIQ_SUCCESS)
-			*phandle = service-handle;
-		else
+		if (status != VCHIQ_SUCCESS) {
 			vchiq_remove_service(service-handle);
+			*phandle = VCHIQ_SERVICE_HANDLE_INVALID;
+		}
 	}
 
 failed:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.3 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.3	Thu Mar 27 23:03:07 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c	Wed Jul 16 23:59:58 2014
@@ -632,6 +632,9 @@ int32_t vchi_service_open(VCHI_INSTANCE_
 {
 	VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle;
 	SHIM_SERVICE_T *service = service_alloc(instance, setup);
+
+	*handle = (VCHI_SERVICE_HANDLE_T)service;
+
 	if (service) {
 		VCHIQ_SERVICE_PARAMS_T params;
 		VCHIQ_STATUS_T status;
@@ -648,11 +651,10 @@ int32_t vchi_service_open(VCHI_INSTANCE_
 		if (status != VCHIQ_SUCCESS) {
 			service_free(service);
 			service = NULL;
+			*handle = NULL;
 		}
 	}
 
-	*handle = (VCHI_SERVICE_HANDLE_T)service;
-
 	return (service != NULL) ? 0 : -1;
 }
 EXPORT_SYMBOL(vchi_service_open);
@@ -663,6 +665,9 @@ int32_t vchi_service_create(VCHI_INSTANC
 {
 	VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle;
 	SHIM_SERVICE_T *service = service_alloc(instance, setup);
+
+	*handle = (VCHI_SERVICE_HANDLE_T)service;
+
 	if (service) {
 		VCHIQ_SERVICE_PARAMS_T params;
 		VCHIQ_STATUS_T status;
@@ -678,11 +683,10 @@ int32_t vchi_service_create(VCHI_INSTANC
 		if (status != VCHIQ_SUCCESS) {
 			service_free(service);
 			service = NULL;
+			*handle = NULL;
 		}
 	}
 
-	*handle = (VCHI_SERVICE_HANDLE_T)service;
-
 	return (service != NULL) ? 0 : -1;
 }
 EXPORT_SYMBOL(vchi_service_create);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-04-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May  1 03:07:50 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
First argument of vchiq_log_info is the log level, not a boolean.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.16 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.17
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.16	Sat Apr 19 07:28:18 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Thu May  1 03:07:50 2014
@@ -553,7 +553,7 @@ vchiq_platform_use_suspend_timer(void)
 void
 vchiq_dump_platform_use_state(VCHIQ_STATE_T *state)
 {
-	vchiq_log_info((vchiq_arm_log_level=VCHIQ_LOG_INFO),Suspend timer not in use);
+	vchiq_log_info(vchiq_arm_log_level, Suspend timer not in use);
 }
 void
 vchiq_platform_handle_timeout(VCHIQ_STATE_T *state)



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-04-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Apr 25 15:49:17 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.7 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.8
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.7	Sat Apr 12 13:28:41 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Fri Apr 25 15:49:17 2014
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.7 2014/04/12 13:28:41 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.8 2014/04/25 15:49:17 skrll Exp $
  */
 
 #include sys/types.h
@@ -281,7 +281,7 @@ struct thread_data {
 
 static struct thread_data thread_slots[MAX_THREAD_DATA_SLOTS];
 
-static void 
+static void
 kthread_wrapper(void *data)
 {
 	struct thread_data *slot;
@@ -312,7 +312,7 @@ vchiq_thread_create(int (*threadfn)(void
 	va_start(ap, namefmt);
 	vsnprintf(name, sizeof(name), namefmt, ap);
 	va_end(ap);
-	
+
 	newt = NULL;
 	if (kthread_create(PRI_NONE, 0, NULL, kthread_wrapper, slot, newt,
 	%s, name) != 0) {



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-04-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr 19 07:28:18 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Deal in 4KB pages for vchiq regardless of ARM page size.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.15 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.16
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.15	Sat Apr 19 07:17:21 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Sat Apr 19 07:28:18 2014
@@ -338,14 +338,19 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	pagelist-type = (dir == VCHIQ_BULK_RECEIVE) ?
 	PAGELIST_READ : PAGELIST_WRITE;
 	pagelist-length = size;
-	pagelist-offset = va  PAGE_MASK;
+	pagelist-offset = va  L2_S_OFFSET;
 
 	/*
 	 * busdma already coalesces contiguous pages for us
 	 */
 	for (int i = 0; i  bi-dmamap-dm_nsegs; i++) {
-		pagelist-addrs[i] = bi-dmamap-dm_segs[i].ds_addr  ~PAGE_MASK;
-		pagelist-addrs[i] |= atop(round_page(bi-dmamap-dm_segs[i].ds_len)) - 1;
+		bus_addr_t addr = bi-dmamap-dm_segs[i].ds_addr;
+		bus_size_t len = bi-dmamap-dm_segs[i].ds_len;
+		bus_size_t off = addr  L2_S_OFFSET;
+		int npgs = ((off + len + L2_S_OFFSET)  L2_S_SHIFT);
+
+		pagelist-addrs[i] = addr  ~L2_S_OFFSET;
+		pagelist-addrs[i] |= npgs - 1;
 	}
 
 	/* Partial cache lines (fragments) require special measures */



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 07:54:43 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
bzero - memset


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.3 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.3	Fri Sep  6 05:50:22 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Thu Mar 27 07:54:43 2014
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.3 2013/09/06 05:50:22 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.4 2014/03/27 07:54:43 skrll Exp $
  */
 
 #include sys/types.h
@@ -252,7 +252,7 @@ void sema_sysinit(void *arg)
 void
 _sema_init(struct semaphore *s, int value)
 {
-	bzero(s, sizeof(*s));
+	memset(s, 0, sizeof(*s));
 	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_VM);
 	cv_init(s-cv, semacv);
 	s-value = value;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 07:56:56 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.4 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.4	Thu Mar 27 07:54:43 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Thu Mar 27 07:56:56 2014
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.4 2014/03/27 07:54:43 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.5 2014/03/27 07:56:56 skrll Exp $
  */
 
 #include sys/types.h
@@ -296,14 +296,14 @@ down_interruptible(struct semaphore *s)
 
 		if (ret == EINTR || ret == ERESTART) {
 			mutex_exit(s-mtx);
-			return (-EINTR);
+			return -EINTR;
 		}
 	}
 
 	s-value--;
 	mutex_exit(s-mtx);
 
-	return (0);
+	return 0;
 }
 
 int
@@ -325,7 +325,7 @@ down_trylock(struct semaphore *s)
 
 	mutex_exit(s-mtx);
 
-	return (ret);
+	return ret;
 }
 
 void
@@ -385,7 +385,7 @@ int
 fatal_signal_pending(VCHIQ_THREAD_T thr)
 {
 	printf(Implement ME: %s\n, __func__);
-	return (0);
+	return 0;
 }
 
 /*
@@ -426,7 +426,7 @@ vchiq_thread_create(int (*threadfn)(void
 
 	if (thread_data_slot = MAX_THREAD_DATA_SLOTS) {
 		printf(kthread_create: out of thread data slots\n);
-		return (NULL);
+		return NULL;
 	}
 
 	slot = thread_slots[thread_data_slot];



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 07:59:17 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
Simplify the semaphore code a little


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.5 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.5	Thu Mar 27 07:56:56 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Thu Mar 27 07:59:17 2014
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.5 2014/03/27 07:56:56 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.6 2014/03/27 07:59:17 skrll Exp $
  */
 
 #include sys/types.h
@@ -283,15 +283,12 @@ down(struct semaphore *s)
 int
 down_interruptible(struct semaphore *s)
 {
-	int ret ;
-
-	ret = 0;
 
 	mutex_enter(s-mtx);
 
 	while (s-value == 0) {
 		s-waiters++;
-		ret = cv_wait_sig(s-cv, s-mtx);
+		int ret = cv_wait_sig(s-cv, s-mtx);
 		s-waiters--;
 
 		if (ret == EINTR || ret == ERESTART) {
@@ -309,9 +306,7 @@ down_interruptible(struct semaphore *s)
 int
 down_trylock(struct semaphore *s)
 {
-	int ret;
-
-	ret = 0;
+	int ret = 1;
 
 	mutex_enter(s-mtx);
 
@@ -319,8 +314,6 @@ down_trylock(struct semaphore *s)
 		/* Success. */
 		s-value--;
 		ret = 0;
-	} else {
-		ret = -EAGAIN;
 	}
 
 	mutex_exit(s-mtx);
@@ -333,7 +326,7 @@ up(struct semaphore *s)
 {
 	mutex_enter(s-mtx);
 	s-value++;
-	if (s-waiters  s-value  0)
+	if (s-value  0  s-waiters)
 		cv_signal(s-cv);
 
 	mutex_exit(s-mtx);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 10:11:04 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Remove #if 0'ed code.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.10 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.11
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.10	Wed Mar 26 16:07:15 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Thu Mar 27 10:11:04 2014
@@ -251,6 +251,13 @@ typedef struct bulkinfo_struct {
 	int		size;
 } BULKINFO_T;
 
+/* There is a potential problem with partial cache lines (pages?)
+** at the ends of the block when reading. If the CPU accessed anything in
+** the same line (page?) then it may have pulled old data into the cache,
+** obscuring the new data underneath. We can solve this by transferring the
+** partial cache lines separately, and allowing the ARM to copy into the
+** cached area.
+*/
 VCHIQ_STATUS_T
 vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, VCHI_MEM_HANDLE_T memhandle,
 	void *buf, int size, int dir)
@@ -554,195 +561,3 @@ vchiq_platform_handle_timeout(VCHIQ_STAT
 {
 	(void)state;
 }
-/*
- * Local functions
- */
-
-/* There is a potential problem with partial cache lines (pages?)
-** at the ends of the block when reading. If the CPU accessed anything in
-** the same line (page?) then it may have pulled old data into the cache,
-** obscuring the new data underneath. We can solve this by transferring the
-** partial cache lines separately, and allowing the ARM to copy into the
-** cached area.
-
-** N.B. This implementation plays slightly fast and loose with the Linux
-** driver programming rules, e.g. its use of __virt_to_bus instead of
-** dma_map_single, but it isn't a multi-platform driver and it benefits
-** from increased speed as a result.
-*/
-
-#if 0
-static int
-create_pagelist(char __user *buf, size_t count, unsigned short type,
-	struct task_struct *task, PAGELIST_T ** ppagelist)
-{
-	PAGELIST_T *pagelist;
-	struct page **pages;
-	struct page *page;
-	unsigned long *addrs;
-	unsigned int num_pages, offset, i;
-	char *addr, *base_addr, *next_addr;
-	int run, addridx, actual_pages;
-
-	offset = (unsigned int)buf  (PAGE_SIZE - 1);
-	num_pages = (count + offset + PAGE_SIZE - 1) / PAGE_SIZE;
-
-	*ppagelist = NULL;
-
-	/* Allocate enough storage to hold the page pointers and the page
-	** list
-	*/
-	pagelist = kmalloc(sizeof(PAGELIST_T) +
-		(num_pages * sizeof(unsigned long)) +
-		(num_pages * sizeof(pages[0])),
-		GFP_KERNEL);
-
-	vchiq_log_trace(vchiq_arm_log_level,
-		create_pagelist - %x, (unsigned int)pagelist);
-	if (!pagelist)
-		return -ENOMEM;
-
-	addrs = pagelist-addrs;
-	pages = (struct page **)(addrs + num_pages);
-
-	down_read(task-mm-mmap_sem);
-	actual_pages = get_user_pages(task, task-mm,
-		(unsigned long)buf  ~(PAGE_SIZE - 1), num_pages,
-		(type == PAGELIST_READ) /*Write */ , 0 /*Force */ ,
-		pages, NULL /*vmas */);
-	up_read(task-mm-mmap_sem);
-
-   if (actual_pages != num_pages)
-   {
-  /* This is probably due to the process being killed */
-  while (actual_pages  0)
-  {
- actual_pages--;
- page_cache_release(pages[actual_pages]);
-  }
-  kfree(pagelist);
-  if (actual_pages == 0)
- actual_pages = -ENOMEM;
-  return actual_pages;
-	}
-
-	pagelist-length = count;
-	pagelist-type = type;
-	pagelist-offset = offset;
-
-	/* Group the pages into runs of contiguous pages */
-
-	base_addr = VCHIQ_ARM_ADDRESS(page_address(pages[0]));
-	next_addr = base_addr + PAGE_SIZE;
-	addridx = 0;
-	run = 0;
-
-	for (i = 1; i  num_pages; i++) {
-		addr = VCHIQ_ARM_ADDRESS(page_address(pages[i]));
-		if ((addr == next_addr)  (run  (PAGE_SIZE - 1))) {
-			next_addr += PAGE_SIZE;
-			run++;
-		} else {
-			addrs[addridx] = (unsigned long)base_addr + run;
-			addridx++;
-			base_addr = addr;
-			next_addr = addr + PAGE_SIZE;
-			run = 0;
-		}
-	}
-
-	addrs[addridx] = (unsigned long)base_addr + run;
-	addridx++;
-
-	/* Partial cache lines (fragments) require special measures */
-	if ((type == PAGELIST_READ) 
-		((pagelist-offset  (CACHE_LINE_SIZE - 1)) ||
-		((pagelist-offset + pagelist-length) 
-		(CACHE_LINE_SIZE - 1 {
-		FRAGMENTS_T *fragments;
-
-		if (down_interruptible(g_free_fragments_sema) != 0) {
-			kfree(pagelist);
-			return -EINTR;
-		}
-
-		WARN_ON(g_free_fragments == NULL);
-
-		down(g_free_fragments_mutex);
-		fragments = (FRAGMENTS_T *) g_free_fragments;
-		WARN_ON(fragments == NULL);
-		g_free_fragments = *(FRAGMENTS_T **) g_free_fragments;

CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 10:42:47 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
More #if 0'ed removal


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.11 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.12
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.11	Thu Mar 27 10:11:04 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Thu Mar 27 10:42:47 2014
@@ -72,15 +72,6 @@ struct semaphore g_free_fragments_sema;
 
 static DEFINE_SEMAPHORE(g_free_fragments_mutex);
 
-#if 0
-static int
-create_pagelist(char __user *buf, size_t count, unsigned short type,
-lwp_t *l, PAGELIST_T ** ppagelist);
-
-static void
-free_pagelist(PAGELIST_T *pagelist, int actual);
-#endif
-
 int __init
 vchiq_platform_init(VCHIQ_STATE_T *state)
 {



CVS commit: src/sys/external/bsd/vchiq/dist/interface

2014-03-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 27 23:03:07 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h
src/sys/external/bsd/vchiq/dist/interface/vchi: vchi_cfg.h
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_core.c vchiq_core.h vchiq_if.h vchiq_ioctl.h vchiq_kern_lib.c
vchiq_shim.c vchiq_util.c

Log Message:
Merge upstream fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_if.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_ioctl.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.5 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.6
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.5	Wed Mar 26 16:44:41 2014
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Thu Mar 27 23:03:06 2014
@@ -391,6 +391,10 @@ typedef	off_t	loff_t;
 #define wmb	membar_producer
 #define dsb	membar_producer
 
+#define smp_mb	membar_producer
+#define smp_rmb	membar_consumer
+#define smp_wmb	membar_producer
+
 #define device_print_prettyname(dev)	device_printf((dev), )
 
 #endif /* __VCHI_NETBSD_H__ */

Index: src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchi/vchi_cfg.h	Thu Mar 27 23:03:07 2014
@@ -41,7 +41,6 @@
 
 /* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */
 /* Really determined by the message driver, and should be available from a run-time call. */
-/* XXX: fixme */
 #ifndef VCHI_BULK_ALIGN
 #   if __VCCOREVER__ = 0x0400
 #   define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.10 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.11
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.10	Tue Mar 25 15:33:22 2014
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Thu Mar 27 23:03:07 2014
@@ -384,6 +384,22 @@ service_callback(VCHIQ_REASON_T reason, 
 
 /
 *
+*   user_service_free
+*
+***/
+static void
+user_service_free(void *userdata)
+{
+	USER_SERVICE_T *user_service = userdata;
+	
+	_sema_destroy(user_service-insert_event);
+	_sema_destroy(user_service-remove_event);
+
+	kfree(user_service);
+}
+
+/
+*
 *   vchiq_ioctl
 *
 ***/
@@ -465,7 +481,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 		void *userdata;
 		int srvstate;
 
-		user_service = kmalloc(sizeof(USER_SERVICE_T), GFP_KERNEL);
+		user_service = kzalloc(sizeof(USER_SERVICE_T), GFP_KERNEL);
 		if (!user_service) {
 			ret = -ENOMEM;
 			break;
@@ -491,7 +507,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 		service = vchiq_add_service_internal(
 instance-state,
 pargs-params, srvstate,
-instance);
+instance, user_service_free);
 
 		if (service != NULL) {
 			user_service-service = service;
@@ -514,8 +530,6 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 	service = NULL;
 	ret = (status == VCHIQ_RETRY) ?
 		-EINTR : -EIO;
-	user_service-service = NULL;
-	user_service-instance = NULL;
 	break;
 }
 			}
@@ -655,14 +669,14 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			lmutex_unlock(instance-bulk_waiter_list_mutex);
 			if (!waiter) {
 vchiq_log_error(vchiq_arm_log_level,
-	no bulk_waiter found for pid %d,
-		

CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2014-03-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Mar 26 16:07:15 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Correct some bus_dma operations.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.9 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.10
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.9	Sun Apr 28 20:57:26 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Wed Mar 26 16:07:15 2014
@@ -100,7 +100,7 @@ vchiq_platform_init(VCHIQ_STATE_T *state
 	dma_nsegs = __arraycount(dma_segs);
 	err = bus_dmamem_alloc(bcm2835_bus_dma_tag,
 	g_slot_mem_size + frag_mem_size, PAGE_SIZE, 0,
-	dma_segs, dma_nsegs, dma_nsegs, BUS_DMA_COHERENT | BUS_DMA_WAITOK);
+	dma_segs, dma_nsegs, dma_nsegs, BUS_DMA_WAITOK);
 	if (err) {
 		vchiq_log_error(vchiq_core_log_level, Unable to allocate channel memory);
 		err = -ENOMEM;
@@ -289,7 +289,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 		goto fail1;
 
 	ret = bus_dmamem_map(bcm2835_bus_dma_tag, bi-pagelist_sgs, nsegs,
-	bi-pagelist_size, bi-pagelist, BUS_DMA_WAITOK);
+	bi-pagelist_size, bi-pagelist, BUS_DMA_COHERENT | BUS_DMA_WAITOK);
 	if (ret != 0)
 		goto fail2;
 
@@ -378,7 +378,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	bulk-remote_data = bi;
 
 	bus_dmamap_sync(bcm2835_bus_dma_tag, bi-pagelist_map, 0,
-	bi-pagelist_size, BUS_DMASYNC_PREREAD);
+	bi-pagelist_size, BUS_DMASYNC_PREWRITE);
 
 	bus_dmamap_sync(bcm2835_bus_dma_tag, bi-dmamap, 0, bi-size,
 	pagelist-type == PAGELIST_WRITE ?
@@ -420,6 +420,13 @@ vchiq_complete_bulk(VCHIQ_BULK_T *bulk)
 		BULKINFO_T *bi = bulk-remote_data;
 		PAGELIST_T *pagelist = bi-pagelist;
 
+		bus_dmamap_sync(bcm2835_bus_dma_tag, bi-pagelist_map, 0,
+		bi-pagelist_size, BUS_DMASYNC_POSTWRITE);
+
+		bus_dmamap_sync(bcm2835_bus_dma_tag, bi-dmamap, 0, bi-size,
+		pagelist-type == PAGELIST_WRITE ?
+		BUS_DMASYNC_POSTWRITE : BUS_DMASYNC_POSTREAD);
+
 		/* Deal with any partial cache lines (fragments) */
 		if (pagelist-type = PAGELIST_READ_WITH_FRAGMENTS) {
 			FRAGMENTS_T *fragments = g_fragments_base +
@@ -469,13 +476,6 @@ vchiq_complete_bulk(VCHIQ_BULK_T *bulk)
 			up(g_free_fragments_mutex);
 			up(g_free_fragments_sema);
 		}
-		bus_dmamap_sync(bcm2835_bus_dma_tag, bi-pagelist_map, 0,
-		bi-pagelist_size, BUS_DMASYNC_POSTREAD);
-
-		bus_dmamap_sync(bcm2835_bus_dma_tag, bi-dmamap, 0, bi-size,
-		pagelist-type == PAGELIST_WRITE ?
-		BUS_DMASYNC_POSTWRITE : BUS_DMASYNC_POSTREAD);
-
 		bus_dmamap_unload(bcm2835_bus_dma_tag, bi-dmamap);
 		bus_dmamap_destroy(bcm2835_bus_dma_tag, bi-dmamap);
 		if (IS_USER_ADDRESS(bi-buf))



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2014-03-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Mar 26 16:44:41 UTC 2014

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.4 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.5
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.4	Thu Sep 19 14:43:39 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Wed Mar 26 16:44:41 2014
@@ -315,7 +315,8 @@ MALLOC_DECLARE(M_VCHI);
  */
 #if 1
 /* emulate jiffies */
-static inline unsigned long _jiffies(void)
+static inline unsigned long
+_jiffies(void)
 {
 	struct timeval tv;
 
@@ -323,7 +324,8 @@ static inline unsigned long _jiffies(voi
 	return tvtohz(tv);
 }
 
-static inline unsigned long msecs_to_jiffies(unsigned long msecs)
+static inline unsigned long
+msecs_to_jiffies(unsigned long msecs)
 {
 	struct timeval tv;
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 09:58:43 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
Remove unused variables.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.7 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.8
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.7	Sun Oct 13 07:46:26 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sat Dec 14 09:58:43 2013
@@ -2358,7 +2358,6 @@ vchiq_release_internal(VCHIQ_STATE_T *st
 	VCHIQ_STATUS_T ret = VCHIQ_SUCCESS;
 	char entity[16];
 	int *entity_uc;
-	int local_uc, local_entity_uc;
 
 	if (!arm_state)
 		goto out;
@@ -2383,8 +2382,8 @@ vchiq_release_internal(VCHIQ_STATE_T *st
 		ret = VCHIQ_ERROR;
 		goto unlock;
 	}
-	local_uc = --arm_state-videocore_use_count;
-	local_entity_uc = --(*entity_uc);
+	--arm_state-videocore_use_count;
+	--(*entity_uc);
 
 	if (!vchiq_videocore_wanted(state)) {
 		if (vchiq_platform_use_suspend_timer() 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 10:00:42 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
Comment out unsed variable. Left for reference.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.7 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.8
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.7	Sun Dec  1 02:57:43 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sat Dec 14 10:00:42 2013
@@ -1462,12 +1462,11 @@ parse_open(VCHIQ_STATE_T *state, VCHIQ_H
 {
 	VCHIQ_SERVICE_T *service = NULL;
 	int msgid, size;
-	int type;
 	unsigned int localport, remoteport;
 
 	msgid = header-msgid;
 	size = header-size;
-	type = VCHIQ_MSG_TYPE(msgid);
+	//int type = VCHIQ_MSG_TYPE(msgid);
 	localport = VCHIQ_MSG_DSTPORT(msgid);
 	remoteport = VCHIQ_MSG_SRCPORT(msgid);
 	if (size = sizeof(struct vchiq_open_payload)) {



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-11-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Dec  1 02:57:43 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
remote_event_destroy is unused, mark it so.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.6	Sun Oct 13 07:46:26 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sun Dec  1 02:57:43 2013
@@ -387,7 +387,7 @@ remote_event_create(REMOTE_EVENT_T *even
 	_sema_init(event-event, 0);
 }
 
-static inline void
+__unused static inline void
 remote_event_destroy(REMOTE_EVENT_T *event)
 {
 	(void)event;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-10-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 13 07:46:26 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_core.c

Log Message:
Print the client_id (lwp address) as hex and avoid stack overflow. Use
snprintf while here.

Fixes PR/48287


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.6	Thu Sep 19 15:13:43 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sun Oct 13 07:46:26 2013
@@ -577,7 +577,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			if (status != VCHIQ_SUCCESS) {
 vchiq_log_error(vchiq_susp_log_level,
 	%s: cmd %s returned error %d for 
-	service %c%c%c%c:%03d,
+	service %c%c%c%c:%8x,
 	__func__,
 	(cmd == VCHIQ_IOC_USE_SERVICE) ?
 		VCHIQ_IOC_USE_SERVICE :
@@ -1942,7 +1942,7 @@ output_timeout_error(VCHIQ_STATE_T *stat
 		VCHIQ_SERVICE_T *service_ptr = state-services[i];
 		if (service_ptr  service_ptr-service_use_count 
 			(service_ptr-srvstate != VCHIQ_SRVSTATE_FREE)) {
-			snprintf(service_err, 50,  %c%c%c%c(%d) service has 
+			snprintf(service_err, 50,  %c%c%c%c(%8x) service has 
 use count %d%s, VCHIQ_FOURCC_AS_4CHARS(
 	service_ptr-base.fourcc),
  service_ptr-client_id,
@@ -2237,7 +2237,7 @@ vchiq_use_internal(VCHIQ_STATE_T *state,
 		sprintf(entity, VCHIQ:   );
 		entity_uc = arm_state-peer_use_count;
 	} else if (service) {
-		sprintf(entity, %c%c%c%c:%03d,
+		snprintf(entity, sizeof(entity), %c%c%c%c:%8x,
 			VCHIQ_FOURCC_AS_4CHARS(service-base.fourcc),
 			service-client_id);
 		entity_uc = service-service_use_count;
@@ -2366,7 +2366,7 @@ vchiq_release_internal(VCHIQ_STATE_T *st
 	vchiq_log_trace(vchiq_susp_log_level, %s, __func__);
 
 	if (service) {
-		sprintf(entity, %c%c%c%c:%03d,
+		snprintf(entity, sizeof(entity), %c%c%c%c:%8x,
 			VCHIQ_FOURCC_AS_4CHARS(service-base.fourcc),
 			service-client_id);
 		entity_uc = service-service_use_count;
@@ -2596,7 +2596,7 @@ vchiq_check_service(VCHIQ_SERVICE_T *ser
 
 	if (ret == VCHIQ_ERROR) {
 		vchiq_log_error(vchiq_susp_log_level,
-			%s ERROR - %c%c%c%c:%d service count %d, 
+			%s ERROR - %c%c%c%c:%8x service count %d, 
 			state count %d, videocore suspend state %s, __func__,
 			VCHIQ_FOURCC_AS_4CHARS(service-base.fourcc),
 			service-client_id, service-service_use_count,

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.5	Fri Sep 20 09:05:53 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sun Oct 13 07:46:26 2013
@@ -3664,7 +3664,7 @@ vchiq_dump_service_state(void *dump_cont
 			if (service-public_fourcc != VCHIQ_FOURCC_INVALID)
 snprintf(remoteport + len2,
 	sizeof(remoteport) - len2,
-	 (client %x), service-client_id);
+	 (client %8x), service-client_id);
 		} else
 			strcpy(remoteport, n/a);
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-09-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 20 09:05:53 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
Clean up semaphore initialisation.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.4 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.4	Thu Sep 19 13:51:44 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Fri Sep 20 09:05:53 2013
@@ -384,7 +384,7 @@ remote_event_create(REMOTE_EVENT_T *even
 	event-armed = 0;
 	/* Don't clear the 'fired' flag because it may already have been set
 	** by the other side. */
-	event-event-value = 0;
+	_sema_init(event-event, 0);
 }
 
 static inline void
@@ -2377,10 +2377,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, V
 
 	_sema_init(state-connect, 0);
 	lmutex_init(state-mutex);
-	_sema_init(state-trigger_event, 0);
-	_sema_init(state-recycle_event, 0);
-	_sema_init(state-sync_trigger_event, 0);
-	_sema_init(state-sync_release_event, 0);
 
 	lmutex_init(state-slot_mutex);
 	lmutex_init(state-recycle_mutex);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-09-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 19 13:51:45 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_core.c vchiq_kern_lib.c

Log Message:
Call {lmutex,_sema)_destroy appropriately


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.4 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.4	Sat Aug  3 13:23:10 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Thu Sep 19 13:51:44 2013
@@ -682,6 +682,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 waiter-bulk_waiter.bulk-userdata = NULL;
 spin_unlock(bulk_waiter_spinlock);
 			}
+			_sema_destroy(waiter-bulk_waiter.event);
 			kfree(waiter);
 		} else {
 			const VCHIQ_BULK_MODE_T mode_waiting =
@@ -810,6 +811,8 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 if (completion-reason ==
 	VCHIQ_SERVICE_CLOSED) {
 	unlock_service(service1);
+	_sema_destroy(user_service-insert_event);
+	_sema_destroy(user_service-remove_event);
 	kfree(user_service);
 }
 
@@ -1159,6 +1162,8 @@ vchiq_close(struct file *fp)
 			spin_unlock(msg_queue_spinlock);
 
 			unlock_service(service);
+			_sema_destroy(user_service-insert_event);
+			_sema_destroy(user_service-remove_event);
 			kfree(user_service);
 		}
 
@@ -1192,6 +1197,7 @@ vchiq_close(struct file *fp)
 	bulk_waiter - cleaned up %x 
 	for pid %d,
 	(unsigned int)waiter, waiter-pid);
+		_sema_destroy(waiter-bulk_waiter.event);
 kfree(waiter);
 			}
 		}

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.3 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.3	Mon Mar 25 22:58:42 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Thu Sep 19 13:51:44 2013
@@ -276,6 +276,10 @@ unlock_service(VCHIQ_SERVICE_T *service)
 		if (!service-ref_count) {
 			BUG_ON(service-srvstate != VCHIQ_SRVSTATE_FREE);
 			state-services[service-localport] = NULL;
+
+			_sema_destroy(service-remove_event);
+			_sema_destroy(service-bulk_remove_event);
+			lmutex_destroy(service-bulk_mutex);
 		} else
 			service = NULL;
 	}
@@ -2588,6 +2592,10 @@ vchiq_add_service_internal(VCHIQ_STATE_T
 		lmutex_unlock(state-mutex);
 
 		if (!pservice) {
+			_sema_destroy(service-remove_event);
+			_sema_destroy(service-bulk_remove_event);
+			lmutex_destroy(service-bulk_mutex);
+
 			kfree(service);
 			service = NULL;
 		}

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	Thu Sep 19 13:51:44 2013
@@ -153,8 +153,13 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INST
 	bulk_waiter - cleaned up %x 
 	for pid %d,
 	(unsigned int)waiter, waiter-pid);
+			_sema_destroy(waiter-bulk_waiter.event);
+
 			kfree(waiter);
 		}
+
+		lmutex_destroy(instance-bulk_waiter_list_mutex);
+
 		kfree(instance);
 	}
 
@@ -436,6 +441,8 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVI
 			bulk-userdata = NULL;
 			spin_unlock(bulk_waiter_spinlock);
 		}
+		_sema_destroy(waiter-bulk_waiter.event);
+
 		kfree(waiter);
 	} else {
 		waiter-pid = current-l_proc-p_pid;



CVS commit: src/sys/external/bsd/vchiq

2013-09-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 19 14:43:39 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/conf: files.vchiq
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.h
vchiq_util.h
Removed Files:
src/sys/external/bsd/vchiq/dist/interface/compat: list.h

Log Message:
Use the common list.h


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/vchiq/conf/files.vchiq
cvs rdiff -u -r1.1 -r0 \
src/sys/external/bsd/vchiq/dist/interface/compat/list.h
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/conf/files.vchiq
diff -u src/sys/external/bsd/vchiq/conf/files.vchiq:1.1 src/sys/external/bsd/vchiq/conf/files.vchiq:1.2
--- src/sys/external/bsd/vchiq/conf/files.vchiq:1.1	Fri Mar  8 12:32:29 2013
+++ src/sys/external/bsd/vchiq/conf/files.vchiq	Thu Sep 19 14:43:39 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: files.vchiq,v 1.1 2013/03/08 12:32:29 jmcneill Exp $
+#	$NetBSD: files.vchiq,v 1.2 2013/09/19 14:43:39 skrll Exp $
 #
 # Broadcom VideoCore IV
 #
@@ -17,4 +17,4 @@ file	external/bsd/vchiq/dist/interface/v
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	vchiq
 file	external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	vchiq
 
-makeoptions	vchiq	CPPFLAGS+=-I$S/external/bsd/vchiq/dist -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x0400 -DVCHIQ_ENABLE_DEBUG=1 -DVCHIQ_LOG_DEFAULT=5
+makeoptions	vchiq	CPPFLAGS+=-I$S/external/bsd/vchiq/dist -I$S/external/bsd/common/include -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x0400 -DVCHIQ_ENABLE_DEBUG=1 -DVCHIQ_LOG_DEFAULT=5

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.3 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.4
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.3	Thu Sep  5 13:56:12 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Thu Sep 19 14:43:39 2013
@@ -375,8 +375,6 @@ int fatal_signal_pending(VCHIQ_THREAD_T)
 
 #define __user
 
-#define likely(x)		__builtin_expect(!!(x), 1)
-#define unlikely(x)		__builtin_expect(!!(x), 0)
 #define	current			curlwp
 #define EXPORT_SYMBOL(x) 
 #define PAGE_ALIGN(addr)	round_page(addr)

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.h	Thu Sep 19 14:43:39 2013
@@ -35,7 +35,7 @@
 #define VCHIQ_CORE_H
 
 #include interface/compat/vchi_bsd.h
-#include interface/compat/list.h
+#include linux/list.h
 
 #include vchiq_cfg.h
 
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_util.h	Thu Sep 19 14:43:39 2013
@@ -34,6 +34,8 @@
 #ifndef VCHIQ_UTIL_H
 #define VCHIQ_UTIL_H
 
+#include linux/kernel.h
+
 #include interface/compat/vchi_bsd.h
 
 #include vchiq_if.h



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-09-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 19 15:13:43 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
vchiq_kern_lib.c

Log Message:
Track waiters/clients via lwp pointer and not pid.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.5	Thu Sep 19 13:51:44 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Thu Sep 19 15:13:43 2013
@@ -119,7 +119,7 @@ typedef struct user_service_struct {
 
 struct bulk_waiter_node {
 	struct bulk_waiter bulk_waiter;
-	int pid;
+	struct lwp *l;
 	struct list_head list;
 };
 
@@ -134,7 +134,7 @@ struct vchiq_instance_struct {
 
 	int connected;
 	int closing;
-	int pid;
+	struct lwp *l;
 	int mark;
 
 	struct list_head bulk_waiter_list;
@@ -508,7 +508,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 
 			if (pargs-is_open) {
 status = vchiq_open_service_internal
-	(service, instance-pid);
+	(service, (uintptr_t)instance-l);
 if (status != VCHIQ_SUCCESS) {
 	vchiq_remove_service(service-handle);
 	service = NULL;
@@ -643,7 +643,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			lmutex_lock(instance-bulk_waiter_list_mutex);
 			list_for_each(pos, instance-bulk_waiter_list) {
 if (list_entry(pos, struct bulk_waiter_node,
-	list)-pid == current-l_proc-p_pid) {
+	list)-l == current) {
 	waiter = list_entry(pos,
 		struct bulk_waiter_node,
 		list);
@@ -687,7 +687,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 		} else {
 			const VCHIQ_BULK_MODE_T mode_waiting =
 VCHIQ_BULK_MODE_WAITING;
-			waiter-pid = current-l_proc-p_pid;
+			waiter-l = current;
 			lmutex_lock(instance-bulk_waiter_list_mutex);
 			list_add(waiter-list, instance-bulk_waiter_list);
 			lmutex_unlock(instance-bulk_waiter_list_mutex);
@@ -1050,8 +1050,7 @@ vchiq_open(dev_t dev, int flags, int mod
 		}
 
 		instance-state = state;
-		/* XXXBSD: PID or thread ID? */
-		instance-pid = l-l_proc-p_pid;
+		instance-l = l;
 
 #ifdef notyet
 		ret = vchiq_proc_add_instance(instance);
@@ -1195,8 +1194,8 @@ vchiq_close(struct file *fp)
 list_del(pos);
 vchiq_log_info(vchiq_arm_log_level,
 	bulk_waiter - cleaned up %x 
-	for pid %d,
-	(unsigned int)waiter, waiter-pid);
+	for lwp %p,
+	(unsigned int)waiter, waiter-l);
 		_sema_destroy(waiter-bulk_waiter.event);
 kfree(waiter);
 			}
@@ -1291,9 +1290,9 @@ vchiq_dump_platform_instances(void *dump
 			instance = service-instance;
 			if (instance  !instance-mark) {
 len = snprintf(buf, sizeof(buf),
-	Instance %x: pid %d,%s completions 
+	Instance %x: lwp %p,%s completions 
 		%d/%d,
-	(unsigned int)instance, instance-pid,
+	(unsigned int)instance, instance-l,
 	instance-connected ?  connected,  :
 		,
 	instance-completion_insert -

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c:1.2	Thu Sep 19 13:51:44 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c	Thu Sep 19 15:13:43 2013
@@ -42,7 +42,7 @@
 
 struct bulk_waiter_node {
 	struct bulk_waiter bulk_waiter;
-	int pid;
+	struct lwp *l;
 	struct list_head list;
 };
 
@@ -151,8 +151,8 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INST
 			list_del(pos);
 			vchiq_log_info(vchiq_arm_log_level,
 	bulk_waiter - cleaned up %x 
-	for pid %d,
-	(unsigned int)waiter, waiter-pid);
+	for lwp %p,
+	(unsigned int)waiter, waiter-l);
 			_sema_destroy(waiter-bulk_waiter.event);
 
 			kfree(waiter);
@@ -287,7 +287,7 @@ VCHIQ_STATUS_T vchiq_open_service(
 
 	if (service) {
 		status = vchiq_open_service_internal(service,
-		current-l_proc-p_pid);
+		(uintptr_t)current);
 		if (status == VCHIQ_SUCCESS)
 			*phandle = service-handle;
 		else
@@ -393,7 +393,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVI
 	lmutex_lock(instance-bulk_waiter_list_mutex);
 	list_for_each(pos, instance-bulk_waiter_list) {
 		if (list_entry(pos, struct bulk_waiter_node,
-list)-pid == current-l_proc-p_pid) {
+list)-l == current) {
 			waiter = list_entry(pos,
 struct bulk_waiter_node,
 list);
@@ -445,13 +445,13 @@ 

CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2013-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep  5 13:56:12 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
Do a better job of matching some linux APIs. Still not quite working.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.2 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.3
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.2	Mon Mar 25 22:17:01 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Thu Sep  5 13:56:12 2013
@@ -96,7 +96,7 @@ test_and_clear_bit(int nr, volatile void
 typedef volatile unsigned int atomic_t;
 
 #define atomic_set(p, v)	(*(p) = (v))
-#define atomic_read(p)		(*(p))
+#define atomic_read(p)		(*(volatile int *)(p))
 #define atomic_inc(p)		atomic_inc_uint(p)
 #define atomic_dec(p)		atomic_dec_uint(p)
 #define atomic_dec_and_test(p)	(atomic_dec_uint_nv(p) == 0)
@@ -125,15 +125,6 @@ typedef kmutex_t spinlock_t;
 #define spin_lock_destroy(lock)	mutex_destroy(lock)
 #define spin_lock(lock)		mutex_spin_enter(lock)
 #define spin_unlock(lock)	mutex_spin_exit(lock)
-#define spin_lock_bh(lock)	spin_lock(lock)
-#define spin_unlock_bh(lock)	spin_unlock(lock)
-#define spin_lock_irqsave(lock, flags)			\
-	do {		\
-		spin_lock(lock);			\
-		(void) (flags);			\
-	} while (0)
-#define spin_unlock_irqrestore(lock, flags)		\
-	spin_unlock(lock)
 
 /*
  * Mutex API
@@ -151,25 +142,16 @@ struct mutex {
 /*
  * Rwlock API
  */
-typedef krwlock_t rwlock_t;
+typedef kmutex_t rwlock_t;
 
-/*
- * NB: Need to initialize these at attach time!
- */
-#define DEFINE_RWLOCK(name)	rwlock_t name
-#define rwlock_init(rwlock)	rw_init(rwlock)
-#define read_lock(rwlock)	rw_enter(rwlock, RW_READER)
-#define read_unlock(rwlock)	rw_exit(rwlock)
-
-#define write_lock(rwlock)	rw_enter(rwlock, RW_WRITER)
-#define write_unlock(rwlock)	rw_exit(rwlock)
-#define write_lock_irqsave(rwlock, flags)		\
-	do {		\
-		write_lock(rwlock);			\
-		(void) (flags);			\
-	} while (0)
-#define write_unlock_irqrestore(rwlock, flags)		\
-	write_unlock(rwlock)
+#define DEFINE_RWLOCK(name)	kmutex_t name
+
+#define rwlock_init(rwlock)	mutex_init(rwlock, MUTEX_DEFAULT, IPL_VM)
+#define read_lock(rwlock)	mutex_spin_enter(rwlock)
+#define read_unlock(rwlock)	mutex_spin_exit(rwlock)
+
+#define write_lock(rwlock)	mutex_spin_enter(rwlock)
+#define write_unlock(rwlock)	mutex_spin_exit(rwlock)
 
 #define read_lock_bh(rwlock)	read_lock(rwlock)
 #define read_unlock_bh(rwlock)	read_unlock(rwlock)
@@ -371,7 +353,7 @@ static inline unsigned long msecs_to_jif
 #define time_before(a, b)	time_after((b), (a))
 
 /*
- * kthread API (we use proc)
+ * kthread API (we use lwp)
  */
 typedef lwp_t * VCHIQ_THREAD_T;
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2013-09-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep  6 05:50:22 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
Change the cv name slightly


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.2 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.2	Sun Mar 24 14:26:16 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Fri Sep  6 05:50:22 2013
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.2 2013/03/24 14:26:16 jmcneill Exp $
+ * $Id: vchi_bsd.c,v 1.3 2013/09/06 05:50:22 skrll Exp $
  */
 
 #include sys/types.h
@@ -254,7 +254,7 @@ _sema_init(struct semaphore *s, int valu
 {
 	bzero(s, sizeof(*s));
 	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_VM);
-	cv_init(s-cv, sema cv);
+	cv_init(s-cv, semacv);
 	s-value = value;
 }
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-08-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug  6 07:57:49 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_shim.c

Log Message:
Make a comment match the code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_shim.c	Tue Aug  6 07:57:49 2013
@@ -248,7 +248,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive);
  * Name: vchi_bulk_queue_transmit
  *
  * Arguments:  VCHI_BULK_HANDLE_T handle,
- * const void *data_src,
+ * void *data_src,
  * uint32_t data_size,
  * VCHI_FLAGS_T flags,
  * void *bulk_handle



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-08-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug  3 13:23:10 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.3 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.3	Sun Apr 28 20:58:51 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sat Aug  3 13:23:10 2013
@@ -1064,7 +1064,7 @@ vchiq_open(dev_t dev, int flags, int mod
 		lmutex_init(instance-bulk_waiter_list_mutex);
 		INIT_LIST_HEAD(instance-bulk_waiter_list);
 
-	} 
+	}
 	else {
 		vchiq_log_error(vchiq_arm_log_level,
 			Unknown minor device);



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 20:57:26 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
G/C M_VCPAGELIST


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.8 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.9
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.8	Fri Apr 26 16:56:42 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Sun Apr 28 20:57:26 2013
@@ -43,8 +43,6 @@
 #include arch/arm/broadcom/bcm2835_mbox.h
 #include arch/arm/broadcom/bcm2835var.h
 
-MALLOC_DEFINE(M_VCPAGELIST, vcpagelist, VideoCore pagelist memory);
-
 #define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32)
 
 #define VCHIQ_DOORBELL_IRQ IRQ_ARM_DOORBELL_0



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-04-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 28 20:58:52 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
Spello


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.2	Mon Mar 25 22:40:12 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sun Apr 28 20:58:51 2013
@@ -58,7 +58,7 @@
 #define KEEPALIVE_VER 1
 #define KEEPALIVE_VER_MIN KEEPALIVE_VER
 
-MALLOC_DEFINE(M_VCHIQ, vchiq_cdev, VideoCore cdev memroy);
+MALLOC_DEFINE(M_VCHIQ, vchiq_cdev, VideoCore cdev memory);
 
 /* Run time control of log level, based on KERN_XXX level. */
 int vchiq_arm_log_level = VCHIQ_LOG_DEFAULT;



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-04-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 25 04:31:41 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.5	Mon Mar 25 22:01:49 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Thu Apr 25 04:31:41 2013
@@ -279,7 +279,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 
 	bi-buf = buf;
 	bi-size = size;
-	bi-pagelist_size = sizeof(PAGELIST_T) + 
+	bi-pagelist_size = sizeof(PAGELIST_T) +
 	(maxsegs * sizeof(unsigned long));
 	bi-vmspace = curproc-p_vmspace;
 
@@ -322,10 +322,10 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 			goto fail5;
 		}
 	}
-	
+
 	ret = bus_dmamap_create(bcm2835_bus_dma_tag, size, maxsegs, size, 0,
 	BUS_DMA_WAITOK, bi-dmamap);
-	
+
 	if (ret != 0)
 		goto fail6;
 
@@ -369,7 +369,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 		pagelist-type = PAGELIST_READ_WITH_FRAGMENTS +
 		(fragments - g_fragments_base);
 	}
-	
+
 	/*
 	 * Store the BULKINFO_T address in remote_data, which isn't used by the
 	 * slave.
@@ -394,7 +394,7 @@ fail6:
 
 fail5:
 	bus_dmamap_unload(bcm2835_bus_dma_tag, bi-pagelist_map);
-	
+
 fail4:
 	bus_dmamap_destroy(bcm2835_bus_dma_tag, bi-pagelist_map);
 
@@ -404,7 +404,7 @@ fail3:
 fail2:
 	bus_dmamem_free(bcm2835_bus_dma_tag, bi-pagelist_sgs,
 	__arraycount(bi-pagelist_sgs));
-	
+
 fail1:
 	kmem_free(bi, sizeof(*bi));
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-04-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Apr 25 04:45:33 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Style nit.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.6	Thu Apr 25 04:31:41 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Thu Apr 25 04:45:33 2013
@@ -379,7 +379,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	bus_dmamap_sync(bcm2835_bus_dma_tag, bi-pagelist_map, 0,
 	bi-pagelist_size, BUS_DMASYNC_PREREAD);
 
-	bus_dmamap_sync(bcm2835_bus_dma_tag, bi-dmamap, 0, size,
+	bus_dmamap_sync(bcm2835_bus_dma_tag, bi-dmamap, 0, bi-size,
 	pagelist-type == PAGELIST_WRITE ?
 	BUS_DMASYNC_PREWRITE : BUS_DMASYNC_PREREAD);
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-04-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr  3 20:21:38 UTC 2013

Removed Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_freebsd.c

Log Message:
Remove unnecessary freebsd code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_freebsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Mar 25 21:55:12 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Revert commented out create_pagelist/free_pagelist to the original
version and not the broken FreeBSD version.  Should really be deleted
someday soon.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Mon Mar 25 21:55:11 2013
@@ -537,15 +537,15 @@ vchiq_doorbell_irq(int irq, void *dev_id
 #if 0
 static int
 create_pagelist(char __user *buf, size_t count, unsigned short type,
-	lwp_t *l, PAGELIST_T ** ppagelist)
+	struct task_struct *task, PAGELIST_T ** ppagelist)
 {
 	PAGELIST_T *pagelist;
-	paddr_t *pages;
+	struct page **pages;
+	struct page *page;
 	unsigned long *addrs;
 	unsigned int num_pages, offset, i;
-	int pagelist_size;
 	char *addr, *base_addr, *next_addr;
-	int run, addridx, err;
+	int run, addridx, actual_pages;
 
 	offset = (unsigned int)buf  (PAGE_SIZE - 1);
 	num_pages = (count + offset + PAGE_SIZE - 1) / PAGE_SIZE;
@@ -555,10 +555,10 @@ create_pagelist(char __user *buf, size_t
 	/* Allocate enough storage to hold the page pointers and the page
 	** list
 	*/
-	pagelist_size = sizeof(PAGELIST_T) +
+	pagelist = kmalloc(sizeof(PAGELIST_T) +
 		(num_pages * sizeof(unsigned long)) +
-		(num_pages * sizeof(paddr_t));
-	pagelist = malloc(pagelist_size, M_VCPAGELIST, M_WAITOK | M_ZERO);
+		(num_pages * sizeof(pages[0])),
+		GFP_KERNEL);
 
 	vchiq_log_trace(vchiq_arm_log_level,
 		create_pagelist - %x, (unsigned int)pagelist);
@@ -566,28 +566,27 @@ create_pagelist(char __user *buf, size_t
 		return -ENOMEM;
 
 	addrs = pagelist-addrs;
-	pages = (paddr_t *)(addrs + num_pages);
+	pages = (struct page **)(addrs + num_pages);
 
-	err = uvm_map_pageable(l-l_proc-p_vmspace-vm_map,
-	(vaddr_t)buf, (vaddr_t)buf + count, false, 0);
-	if (err == 0) {
-		err = uvm_map_protect(l-l_proc-p_vmspace-vm_map,
-		(vaddr_t)buf, (vaddr_t)buf + count,
-		(type == PAGELIST_READ ? VM_PROT_WRITE : 0) | VM_PROT_READ,
-		false);
-	}
-	if (err == 0) {
-		for (i = 0; i  num_pages; i++) {
-			pmap_extract(vm_map_pmap(l-l_proc-p_vmspace-vm_map),
-			(vaddr_t)buf + (i * PAGE_SIZE), pages[i]);
-		}
-	}
-
-	if (err != 0) {
-		uvm_map_pageable(l-l_proc-p_vmspace-vm_map,
-		(vaddr_t)buf, (vaddr_t)buf + count, true, 0);
-		free(pagelist, M_VCPAGELIST);
-		return (-ENOMEM);
+	down_read(task-mm-mmap_sem);
+	actual_pages = get_user_pages(task, task-mm,
+		(unsigned long)buf  ~(PAGE_SIZE - 1), num_pages,
+		(type == PAGELIST_READ) /*Write */ , 0 /*Force */ ,
+		pages, NULL /*vmas */);
+	up_read(task-mm-mmap_sem);
+
+   if (actual_pages != num_pages)
+   {
+  /* This is probably due to the process being killed */
+  while (actual_pages  0)
+  {
+ actual_pages--;
+ page_cache_release(pages[actual_pages]);
+  }
+  kfree(pagelist);
+  if (actual_pages == 0)
+ actual_pages = -ENOMEM;
+  return actual_pages;
 	}
 
 	pagelist-length = count;
@@ -596,13 +595,13 @@ create_pagelist(char __user *buf, size_t
 
 	/* Group the pages into runs of contiguous pages */
 
-	base_addr = (void *)PHYS_TO_VCBUS(pages[0]);
+	base_addr = VCHIQ_ARM_ADDRESS(page_address(pages[0]));
 	next_addr = base_addr + PAGE_SIZE;
 	addridx = 0;
 	run = 0;
 
 	for (i = 1; i  num_pages; i++) {
-		addr = (void *)PHYS_TO_VCBUS(pages[i]);
+		addr = VCHIQ_ARM_ADDRESS(page_address(pages[i]));
 		if ((addr == next_addr)  (run  (PAGE_SIZE - 1))) {
 			next_addr += PAGE_SIZE;
 			run++;
@@ -626,7 +625,7 @@ create_pagelist(char __user *buf, size_t
 		FRAGMENTS_T *fragments;
 
 		if (down_interruptible(g_free_fragments_sema) != 0) {
-  			free(pagelist, M_VCPAGELIST);
+			kfree(pagelist);
 			return -EINTR;
 		}
 
@@ -642,7 +641,11 @@ create_pagelist(char __user *buf, size_t
 			 g_fragments_base);
 	}
 
-	cpu_dcache_wbinv_range((vm_offset_t)pagelist, pagelist_size);
+	for (page = virt_to_page(pagelist);
+		page = virt_to_page(addrs + num_pages - 1); page++) {
+		flush_dcache_page(page);
+	}
+
 	*ppagelist = pagelist;
 
 	return 0;
@@ -651,9 +654,8 @@ create_pagelist(char __user *buf, size_t
 static void
 free_pagelist(PAGELIST_T *pagelist, int actual)
 {
-	paddr_t *pages;
-	unsigned int num_pages;
-	void *page_address;
+	struct page **pages;
+	unsigned int num_pages, i;
 
 	

CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Mar 25 21:58:00 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Remove a bogus KASSERT and improve a comment while I'm nearby.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.2	Mon Mar 25 21:55:11 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Mon Mar 25 21:58:00 2013
@@ -341,11 +341,9 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	pagelist-offset = va  PAGE_MASK;
 
 	/*
-	 * busdma coalesce contiguous pages for us
+	 * busdma already coalesces contiguous pages for us
 	 */
 	for (int i = 0; i  bi-dmamap-dm_nsegs; i++) {
-		KASSERT(bi-dmamap-dm_segs[i].ds_len / PAGE_SIZE  PAGE_SIZE);
-
 		pagelist-addrs[i] = bi-dmamap-dm_segs[i].ds_addr  ~PAGE_MASK;
 		pagelist-addrs[i] |= atop(round_page(bi-dmamap-dm_segs[i].ds_len)) - 1;
 	}



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Mar 25 21:58:24 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Wrap a long line


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.3 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.4
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.3	Mon Mar 25 21:58:00 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Mon Mar 25 21:58:24 2013
@@ -263,7 +263,8 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bu
 	int ret;
 
 	vchiq_log_info(vchiq_arm_log_level,
-	%s: buf %p size %08x dir %s\n, __func__, buf, size, dir == VCHIQ_BULK_RECEIVE ? read : write);
+	%s: buf %p size %08x dir %s\n, __func__, buf, size,
+	dir == VCHIQ_BULK_RECEIVE ? read : write);
 
 	vaddr_t va = (vaddr_t)buf;
 	const size_t maxsegs = atop(round_page(va + size) - trunc_page(va));



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Mar 25 22:01:50 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_2835_arm.c

Log Message:
Remove vchiq_doorbell_irq. We have our own version in vchiq_intr.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.4 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.5
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c:1.4	Mon Mar 25 21:58:24 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c	Mon Mar 25 22:01:49 2013
@@ -500,26 +500,6 @@ vchiq_platform_handle_timeout(VCHIQ_STAT
  * Local functions
  */
 
-#ifdef notyet 
-static irqreturn_t
-vchiq_doorbell_irq(int irq, void *dev_id)
-{
-	VCHIQ_STATE_T *state = dev_id;
-	irqreturn_t ret = IRQ_NONE;
-	unsigned int status;
-
-	/* Read (and clear) the doorbell */
-	status = readl(__io_address(ARM_0_BELL0));
-
-	if (status  0x4) {  /* Was the doorbell rung? */
-		remote_event_pollall(state);
-		ret = IRQ_HANDLED;
-	}
-
-	return ret;
-}
-#endif
-
 /* There is a potential problem with partial cache lines (pages?)
 ** at the ends of the block when reading. If the CPU accessed anything in
 ** the same line (page?) then it may have pulled old data into the cache,



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2013-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Mar 25 22:17:01 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.h

Log Message:
fix atomic_cmpxchg wrapper


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.1 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.2
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.h	Mon Mar 25 22:17:01 2013
@@ -107,16 +107,10 @@ typedef volatile unsigned int atomic_t;
 #define atomic_add_return(v, p)	atomic_add_int_nv(p, v)
 #define atomic_sub_return(v, p)	atomic_add_int_nv(p, -(v))
 #define atomic_xchg(p, v)	atomic_swap_uint(p, v)
+#define atomic_cmpxchg(p, oldv, newv) atomic_cas_uint(p, oldv, newv)
 
 #define ATOMIC_INIT(v)		(v)
 
-static inline int
-atomic_cmpxchg(atomic_t *v, int oldv, int newv)
-{
-	atomic_cas_uint(v, oldv, newv);
-	return *v;
-}
-
 /*
  * Spinlock API
  */



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Mar 25 22:40:12 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c

Log Message:
hide some debug printfs under VCHIQ_IOCTL_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Mon Mar 25 22:40:12 2013
@@ -520,7 +520,9 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 }
 			}
 
+#ifdef VCHIQ_IOCTL_DEBUG
 			printf(%s: [CREATE SERVICE] handle = %08x\n, __func__, service-handle);
+#endif
 			pargs-handle = service-handle;
 
 			service = NULL;
@@ -533,7 +535,9 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 	case VCHIQ_IOC_CLOSE_SERVICE: {
 		VCHIQ_SERVICE_HANDLE_T handle = *(VCHIQ_SERVICE_HANDLE_T *)arg;
 
+#ifdef VCHIQ_IOCTL_DEBUG
 		printf(%s: [CLOSE SERVICE] handle = %08x\n, __func__, handle);
+#endif
 
 		service = find_service_for_instance(instance, handle);
 		if (service != NULL)
@@ -545,7 +549,9 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 	case VCHIQ_IOC_REMOVE_SERVICE: {
 		VCHIQ_SERVICE_HANDLE_T handle = *(VCHIQ_SERVICE_HANDLE_T *)arg;
 
+#ifdef VCHIQ_IOCTL_DEBUG
 		printf(%s: [REMOVE SERVICE] handle = %08x\n, __func__, handle);
+#endif
 
 		service = find_service_for_instance(instance, handle);
 		if (service != NULL)
@@ -558,8 +564,10 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 	case VCHIQ_IOC_RELEASE_SERVICE:	{
 		VCHIQ_SERVICE_HANDLE_T handle = *(VCHIQ_SERVICE_HANDLE_T *)arg;
 
+#ifdef VCHIQ_IOCTL_DEBUG
 		printf(%s: [%s SERVICE] handle = %08x\n, __func__,
 		cmd == VCHIQ_IOC_USE_SERVICE ? USE : RELEASE, handle);
+#endif
 
 		service = find_service_for_instance(instance, handle);
 		if (service != NULL) {
@@ -587,7 +595,9 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 	case VCHIQ_IOC_QUEUE_MESSAGE: {
 		VCHIQ_QUEUE_MESSAGE_T *pargs = arg;
 
+#ifdef VCHIQ_IOCTL_DEBUG
 		printf(%s: [QUEUE MESSAGE] handle = %08x\n, __func__, pargs-handle);
+#endif
 
 		service = find_service_for_instance(instance, pargs-handle);
 



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Mar 25 22:58:42 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
remove unnecessary newline and function name from log message that reports 
vchiq local and remote versions


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.2	Sun Mar 24 22:54:21 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Mon Mar 25 22:58:42 2013
@@ -2275,8 +2275,8 @@ vchiq_init_state(VCHIQ_STATE_T *state, V
 	}
 
 	vchiq_log_warning(vchiq_core_log_level,
-		%s: local ver %d (min %d), remote ver %d\n,
-		__func__, VCHIQ_VERSION, VCHIQ_VERSION_MIN,
+		local ver %d (min %d), remote ver %d.,
+		VCHIQ_VERSION, VCHIQ_VERSION_MIN,
 		slot_zero-version);
 
 	if (slot_zero-version  VCHIQ_VERSION_MIN) {



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Mar 25 22:59:25 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c

Log Message:
defer vchiq initialization with config_mountroot, works around a timing issue 
that caused problems during sdhc init on some boards


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c	Mon Mar 25 22:59:25 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.1 2013/03/08 12:32:31 jmcneill Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.2 2013/03/25 22:59:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vchiq_kmod_netbsd.c,v 1.1 2013/03/08 12:32:31 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: vchiq_kmod_netbsd.c,v 1.2 2013/03/25 22:59:25 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -104,10 +104,19 @@ vchiq_attach(device_t parent, device_t s
 		return;
 	}
 
-	vchiq_core_initialize();
-
 	vchiq_softc = sc;
 
+	config_mountroot(self, vchiq_defer);
+}
+
+static void
+vchiq_defer(device_t self)
+{
+	struct vchiq_attach_args vaa;
+	struct vchiq_softc *sc = device_private(self);
+
+	vchiq_core_initialize();
+
 	sc-sc_ih = bcm2835_intr_establish(sc-sc_intr, IPL_VM,
 	vchiq_intr, sc);
 	if (sc-sc_ih == NULL) {
@@ -118,14 +127,6 @@ vchiq_attach(device_t parent, device_t s
 
 	vchiq_init();
 
-	config_mountroot(self, vchiq_defer);
-}
-
-static void
-vchiq_defer(device_t self)
-{
-	struct vchiq_attach_args vaa;
-
 	vaa.vaa_name = AUDS;
 	config_found_ia(self, vchiqbus, vaa, vchiq_print);
 }



CVS commit: src/sys/external/bsd/vchiq/dist/interface/compat

2013-03-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Mar 24 14:26:16 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/compat: vchi_bsd.c

Log Message:
sema mutex needs to be IPL_VM


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.1 src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c:1.1	Fri Mar  8 12:32:30 2013
+++ src/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c	Sun Mar 24 14:26:16 2013
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.1 2013/03/08 12:32:30 jmcneill Exp $
+ * $Id: vchi_bsd.c,v 1.2 2013/03/24 14:26:16 jmcneill Exp $
  */
 
 #include sys/types.h
@@ -253,7 +253,7 @@ void
 _sema_init(struct semaphore *s, int value)
 {
 	bzero(s, sizeof(*s));
-	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(s-mtx, MUTEX_DEFAULT, IPL_VM);
 	cv_init(s-cv, sema cv);
 	s-value = value;
 }



CVS commit: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm

2013-03-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Mar 24 22:54:22 UTC 2013

Modified Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_core.c

Log Message:
print the local and remote vchiq versions


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.1 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.2
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.1	Fri Mar  8 12:32:31 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sun Mar 24 22:54:21 2013
@@ -2263,10 +2263,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, V
 	static int id;
 	int i;
 
-	vchiq_log_warning(vchiq_core_log_level,
-		%s: slot_zero = 0x%08lx, is_master = %d,
-		__func__, (unsigned long)slot_zero, is_master);
-
 	/* Check the input configuration */
 
 	if (slot_zero-magic != VCHIQ_MAGIC) {
@@ -2278,6 +2274,11 @@ vchiq_init_state(VCHIQ_STATE_T *state, V
 		return VCHIQ_ERROR;
 	}
 
+	vchiq_log_warning(vchiq_core_log_level,
+		%s: local ver %d (min %d), remote ver %d\n,
+		__func__, VCHIQ_VERSION, VCHIQ_VERSION_MIN,
+		slot_zero-version);
+
 	if (slot_zero-version  VCHIQ_VERSION_MIN) {
 		vchiq_loud_error_header();
 		vchiq_loud_error(Incompatible VCHIQ versions found.);