CVS commit: src/sys/arch/arm/fdt

2024-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 12 11:24:48 UTC 2024

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.32 src/sys/arch/arm/fdt/pcihost_fdt.c:1.33
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.32	Sat Oct 15 11:07:38 2022
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Fri Jan 12 11:24:48 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.32 2022/10/15 11:07:38 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.33 2024/01/12 11:24:48 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.32 2022/10/15 11:07:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.33 2024/01/12 11:24:48 skrll Exp $");
 
 #include 
 
@@ -506,8 +506,8 @@ pcihost_intr_map(const struct pci_attach
 	index = 0;
 	while (imaplen >= 20) {
 		const int map_ihandle = fdtbus_get_phandle_from_native(be32toh(imap[4]));
-	if (of_getprop_uint32(map_ihandle, "#address-cells", _cells))
-	addr_cells = 2;
+		if (of_getprop_uint32(map_ihandle, "#address-cells", _cells))
+			addr_cells = 2;
 		if (of_getprop_uint32(map_ihandle, "#interrupt-cells", _cells))
 			interrupt_cells = 0;
 		if (imaplen < (addr_cells + interrupt_cells) * 4)
@@ -542,8 +542,8 @@ pcihost_find_intr(struct pcihost_softc *
 	index = 0;
 	while (imaplen >= 20) {
 		const int map_ihandle = fdtbus_get_phandle_from_native(be32toh(imap[4]));
-	if (of_getprop_uint32(map_ihandle, "#address-cells", _cells))
-	addr_cells = 2;
+		if (of_getprop_uint32(map_ihandle, "#address-cells", _cells))
+			addr_cells = 2;
 		if (of_getprop_uint32(map_ihandle, "#interrupt-cells", _cells))
 			interrupt_cells = 0;
 		if (imaplen < (addr_cells + interrupt_cells) * 4)



CVS commit: src/sys/arch/arm/fdt

2024-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 12 11:24:48 UTC 2024

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2023-10-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Oct  2 08:42:20 UTC 2023

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
armpmu(4): Add missing newline to error message.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/fdt/pmu_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/arch/arm/fdt/pmu_fdt.c
diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.11 src/sys/arch/arm/fdt/pmu_fdt.c:1.12
--- src/sys/arch/arm/fdt/pmu_fdt.c:1.11	Wed Nov  9 19:03:38 2022
+++ src/sys/arch/arm/fdt/pmu_fdt.c	Mon Oct  2 08:42:20 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $ */
+/* $NetBSD: pmu_fdt.c,v 1.12 2023/10/02 08:42:20 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.12 2023/10/02 08:42:20 riastradh Exp $");
 
 #include 
 #include 
@@ -136,7 +136,7 @@ pmu_fdt_init(device_t self)
 		error = arm_pmu_init();
 		if (error) {
 			aprint_error_dev(self,
-			"couldn't initialise PMU event counter");
+			"couldn't initialise PMU event counter\n");
 			return;
 		}
 	}



CVS commit: src/sys/arch/arm/fdt

2023-10-02 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Oct  2 08:42:20 UTC 2023

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
armpmu(4): Add missing newline to error message.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/fdt/pmu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-11-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Nov  9 19:03:38 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
fdt/pmu was not working. do return only if there is an error.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pmu_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/arch/arm/fdt/pmu_fdt.c
diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.10 src/sys/arch/arm/fdt/pmu_fdt.c:1.11
--- src/sys/arch/arm/fdt/pmu_fdt.c:1.10	Thu Nov 25 09:36:20 2021
+++ src/sys/arch/arm/fdt/pmu_fdt.c	Wed Nov  9 19:03:38 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pmu_fdt.c,v 1.10 2021/11/25 09:36:20 skrll Exp $ */
+/* $NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.10 2021/11/25 09:36:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $");
 
 #include 
 #include 
@@ -137,8 +137,8 @@ pmu_fdt_init(device_t self)
 		if (error) {
 			aprint_error_dev(self,
 			"couldn't initialise PMU event counter");
+			return;
 		}
-		return;
 	}
 
 	ih = kmem_zalloc(sizeof(void *) * ncpu, KM_SLEEP);



CVS commit: src/sys/arch/arm/fdt

2022-11-09 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Nov  9 19:03:38 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
fdt/pmu was not working. do return only if there is an error.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pmu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  5 17:30:07 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: a9ptmr_fdt.c

Log Message:
Handle speed change events


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/a9ptmr_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-11-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  5 17:30:07 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: a9ptmr_fdt.c

Log Message:
Handle speed change events


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/a9ptmr_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/arch/arm/fdt/a9ptmr_fdt.c
diff -u src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.6 src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.7
--- src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.6	Tue Nov  1 11:05:18 2022
+++ src/sys/arch/arm/fdt/a9ptmr_fdt.c	Sat Nov  5 17:30:06 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $ */
+/* $NetBSD: a9ptmr_fdt.c,v 1.7 2022/11/05 17:30:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.7 2022/11/05 17:30:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,6 +50,7 @@ static int	a9ptmr_fdt_match(device_t, cf
 static void	a9ptmr_fdt_attach(device_t, device_t, void *);
 
 static void	a9ptmr_fdt_cpu_hatch(void *, struct cpu_info *);
+static void	a9ptmr_fdt_speed_changed(device_t);
 
 struct a9ptmr_fdt_softc {
 	device_t	sc_dev;
@@ -144,6 +145,8 @@ a9ptmr_fdt_attach(device_t parent, devic
 		arm_fdt_cpu_hatch_register(self, a9ptmr_fdt_cpu_hatch);
 		arm_fdt_timer_register(a9ptmr_cpu_initclocks);
 	}
+
+	pmf_event_register(self, PMFE_SPEED_CHANGED, a9ptmr_fdt_speed_changed, true);
 }
 
 static void
@@ -151,3 +154,16 @@ a9ptmr_fdt_cpu_hatch(void *priv, struct 
 {
 	a9ptmr_init_cpu_clock(ci);
 }
+
+static void
+a9ptmr_fdt_speed_changed(device_t dev)
+{
+	struct a9ptmr_fdt_softc * const sc = device_private(dev);
+	prop_dictionary_t dict = device_properties(dev);
+	uint32_t rate;
+
+	rate = clk_get_rate(sc->sc_clk);
+	prop_dictionary_set_uint32(dict, "frequency", rate);
+
+	a9ptmr_update_freq(rate);
+}



CVS commit: src/sys/arch/arm/fdt

2022-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  1 11:05:18 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: a9ptmr_fdt.c a9tmr_fdt.c

Log Message:
On a system with both global and private timers, we cannot drive hardclock
from both or else time will move too fast.

Check MPIDR and install the global timer interrupt handler on uniprocessor
configs, and the private timer interrupt handler on MPCore configs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/a9ptmr_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/a9tmr_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/arch/arm/fdt/a9ptmr_fdt.c
diff -u src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.5 src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.6
--- src/sys/arch/arm/fdt/a9ptmr_fdt.c:1.5	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/fdt/a9ptmr_fdt.c	Tue Nov  1 11:05:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: a9ptmr_fdt.c,v 1.5 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.5 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c,v 1.6 2022/11/01 11:05:18 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: a9ptmr_fdt.c
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -78,6 +80,8 @@ a9ptmr_fdt_attach(device_t parent, devic
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
 	bus_space_handle_t bsh;
+	uint32_t mpidr;
+	bool is_hardclock;
 
 	sc->sc_dev = self;
 	sc->sc_clk = fdtbus_clock_get_index(phandle, 0);
@@ -103,13 +107,18 @@ a9ptmr_fdt_attach(device_t parent, devic
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	void *ih = fdtbus_intr_establish_xname(phandle, 0, IPL_CLOCK,
-	FDT_INTR_MPSAFE, a9ptmr_intr, NULL, device_xname(self));
-	if (ih == NULL) {
-		aprint_error_dev(self, "couldn't install interrupt handler\n");
-		return;
+	mpidr = armreg_mpidr_read();
+	is_hardclock = (mpidr & MPIDR_U) == 0;	/* Use private timer for SMP */
+
+	if (is_hardclock) {
+		void *ih = fdtbus_intr_establish_xname(phandle, 0, IPL_CLOCK,
+		FDT_INTR_MPSAFE, a9ptmr_intr, NULL, device_xname(self));
+		if (ih == NULL) {
+			aprint_error_dev(self, "couldn't install interrupt handler\n");
+			return;
+		}
+		aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	bus_addr_t addr;
 	bus_size_t size;
@@ -131,8 +140,10 @@ a9ptmr_fdt_attach(device_t parent, devic
 
 	config_found(self, , NULL, CFARGS_NONE);
 
-	arm_fdt_cpu_hatch_register(self, a9ptmr_fdt_cpu_hatch);
-	arm_fdt_timer_register(a9ptmr_cpu_initclocks);
+	if (is_hardclock) {
+		arm_fdt_cpu_hatch_register(self, a9ptmr_fdt_cpu_hatch);
+		arm_fdt_timer_register(a9ptmr_cpu_initclocks);
+	}
 }
 
 static void

Index: src/sys/arch/arm/fdt/a9tmr_fdt.c
diff -u src/sys/arch/arm/fdt/a9tmr_fdt.c:1.7 src/sys/arch/arm/fdt/a9tmr_fdt.c:1.8
--- src/sys/arch/arm/fdt/a9tmr_fdt.c:1.7	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/fdt/a9tmr_fdt.c	Tue Nov  1 11:05:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: a9tmr_fdt.c,v 1.7 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: a9tmr_fdt.c,v 1.8 2022/11/01 11:05:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.7 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.8 2022/11/01 11:05:18 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -79,6 +81,8 @@ a9tmr_fdt_attach(device_t parent, device
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
 	bus_space_handle_t bsh;
+	uint32_t mpidr;
+	bool is_hardclock;
 
 	sc->sc_dev = self;
 	sc->sc_clk = fdtbus_clock_get_index(phandle, 0);
@@ -104,13 +108,18 @@ a9tmr_fdt_attach(device_t parent, device
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	void *ih = fdtbus_intr_establish_xname(phandle, 0, IPL_CLOCK,
-	FDT_INTR_MPSAFE, a9tmr_intr, NULL, device_xname(self));
-	if (ih == NULL) {
-		aprint_error_dev(self, "couldn't install interrupt handler\n");
-		return;
+	mpidr = armreg_mpidr_read();
+	is_hardclock = (mpidr & MPIDR_U) != 0;	/* Global timer for UP */
+
+	if (is_hardclock) {
+		void *ih = fdtbus_intr_establish_xname(phandle, 0, IPL_CLOCK,
+		FDT_INTR_MPSAFE, a9tmr_intr, NULL, device_xname(self));
+		if (ih == NULL) {
+			aprint_error_dev(self, "couldn't install interrupt handler\n");
+			return;
+		}
+		aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 	}
-	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	bus_addr_t addr;
 	bus_size_t size;
@@ 

CVS commit: src/sys/arch/arm/fdt

2022-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Nov  1 11:05:18 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: a9ptmr_fdt.c a9tmr_fdt.c

Log Message:
On a system with both global and private timers, we cannot drive hardclock
from both or else time will move too fast.

Check MPIDR and install the global timer interrupt handler on uniprocessor
configs, and the private timer interrupt handler on MPCore configs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/a9ptmr_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/a9tmr_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-09-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  6 11:55:07 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c pcihost_fdtvar.h

Log Message:
pcihost: Track MSI/MSI-X interrupt handlers.

Track the MSI/MSI-X interrupt handlers so that fdtbus_intr_disestablish
doesn't get called for them.

This avoids a KASSERT firing when using 'drvctl -d' on a pci device that
uses MSI/MSI-X interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/fdt/pcihost_fdt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/pcihost_fdtvar.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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.30 src/sys/arch/arm/fdt/pcihost_fdt.c:1.31
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.30	Sun Sep  4 16:01:25 2022
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Tue Sep  6 11:55:07 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.30 2022/09/04 16:01:25 skrll Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.31 2022/09/06 11:55:07 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.30 2022/09/04 16:01:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.31 2022/09/06 11:55:07 skrll Exp $");
 
 #include 
 
@@ -101,6 +101,12 @@ static const struct device_compatible_en
 	DEVICE_COMPAT_EOL
 };
 
+struct pcihost_msi_handler {
+	LIST_ENTRY(pcihost_msi_handler) pmh_next;
+	void *pmh_ih;
+};
+
+
 static int
 pcihost_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -178,6 +184,8 @@ pcihost_init2(struct pcihost_softc *sc)
 	if (of_getprop_uint32(sc->sc_phandle, "linux,pci-domain", >sc_seg))
 		sc->sc_seg = pcihost_segment++;
 
+	mutex_init(>sc_msi_handlers_mutex, MUTEX_DEFAULT, IPL_NONE);
+
 	if (pcihost_config(sc) != 0)
 		return;
 
@@ -601,18 +609,30 @@ pcihost_intr_setattr(void *v, pci_intr_h
 }
 
 static void *
-pcihost_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
+pcihost_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
 int (*callback)(void *), void *arg, const char *xname)
 {
 	struct pcihost_softc *sc = v;
-	const int flags = (ih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
+	const int flags = (pih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
 	const u_int *specifier;
 	int ihandle;
 
-	if ((ih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
-		return arm_pci_msi_intr_establish(>sc_pc, ih, ipl, callback, arg, xname);
+	if ((pih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0) {
+		void *ih = arm_pci_msi_intr_establish(>sc_pc, pih, ipl,
+		callback, arg, xname);
+
+		if (ih) {
+			struct pcihost_msi_handler * const pmh =
+			kmem_alloc(sizeof(*pmh), KM_SLEEP);
+			pmh->pmh_ih = ih;
+			mutex_enter(>sc_msi_handlers_mutex);
+			LIST_INSERT_HEAD(>sc_msi_handlers, pmh, pmh_next);
+			mutex_exit(>sc_msi_handlers_mutex);
+		}
+		return ih;
+	}
 
-	specifier = pcihost_find_intr(sc, ih & ARM_PCI_INTR_IRQ, );
+	specifier = pcihost_find_intr(sc, pih & ARM_PCI_INTR_IRQ, );
 	if (specifier == NULL)
 		return NULL;
 
@@ -625,6 +645,18 @@ pcihost_intr_disestablish(void *v, void 
 {
 	struct pcihost_softc *sc = v;
 
+	mutex_enter(>sc_msi_handlers_mutex);
+	struct pcihost_msi_handler *pmh;
+	LIST_FOREACH(pmh, >sc_msi_handlers, pmh_next) {
+		if (pmh->pmh_ih == vih) {
+			LIST_REMOVE(pmh, pmh_next);
+			mutex_exit(>sc_msi_handlers_mutex);
+			kmem_free(pmh, sizeof(*pmh));
+			return;
+		}
+	}
+	mutex_exit(>sc_msi_handlers_mutex);
+
 	fdtbus_intr_disestablish(sc->sc_phandle, vih);
 }
 

Index: src/sys/arch/arm/fdt/pcihost_fdtvar.h
diff -u src/sys/arch/arm/fdt/pcihost_fdtvar.h:1.4 src/sys/arch/arm/fdt/pcihost_fdtvar.h:1.5
--- src/sys/arch/arm/fdt/pcihost_fdtvar.h:1.4	Mon Sep  6 14:03:17 2021
+++ src/sys/arch/arm/fdt/pcihost_fdtvar.h	Tue Sep  6 11:55:07 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdtvar.h,v 1.4 2021/09/06 14:03:17 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdtvar.h,v 1.5 2022/09/06 11:55:07 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -47,6 +47,8 @@ enum pcihost_type {
 	PCIHOST_ECAM,
 };
 
+struct pcihost_msi_handlers;
+
 struct pcih_bus_space {
 	struct bus_space	bst;
 
@@ -85,6 +87,10 @@ struct pcihost_softc {
 
 	const u_int		*sc_pci_ranges;
 	u_int			sc_pci_ranges_cells;
+
+	kmutex_t 		sc_msi_handlers_mutex;
+	LIST_HEAD(, pcihost_msi_handler)
+sc_msi_handlers;
 };
 
 void	pcihost_init2(struct pcihost_softc *);



CVS commit: src/sys/arch/arm/fdt

2022-09-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  6 11:55:07 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c pcihost_fdtvar.h

Log Message:
pcihost: Track MSI/MSI-X interrupt handlers.

Track the MSI/MSI-X interrupt handlers so that fdtbus_intr_disestablish
doesn't get called for them.

This avoids a KASSERT firing when using 'drvctl -d' on a pci device that
uses MSI/MSI-X interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/fdt/pcihost_fdt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/pcihost_fdtvar.h

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



CVS commit: src/sys/arch/arm/fdt

2022-09-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep  4 16:01:25 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Revert previous

kern/56994: wm(4) panic on attach in interrupt_distribute, sometimes


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-09-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep  4 16:01:25 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Revert previous

kern/56994: wm(4) panic on attach in interrupt_distribute, sometimes


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.29 src/sys/arch/arm/fdt/pcihost_fdt.c:1.30
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.29	Sun Sep  4 10:20:33 2022
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Sun Sep  4 16:01:25 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.29 2022/09/04 10:20:33 skrll Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.30 2022/09/04 16:01:25 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.29 2022/09/04 10:20:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.30 2022/09/04 16:01:25 skrll Exp $");
 
 #include 
 
@@ -600,54 +600,32 @@ pcihost_intr_setattr(void *v, pci_intr_h
 	}
 }
 
-struct pcihost_cookie {
-	pci_intr_handle_t phic_pih;
-	void *phic_ih;
-};
-
-
 static void *
-pcihost_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
+pcihost_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
 int (*callback)(void *), void *arg, const char *xname)
 {
 	struct pcihost_softc *sc = v;
-	const int flags = (pih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
+	const int flags = (ih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
 	const u_int *specifier;
 	int ihandle;
 
-	struct pcihost_cookie * const phic = kmem_alloc(sizeof(*phic), KM_SLEEP);
-	phic->phic_pih = pih;
-	if ((pih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0) {
-		phic->phic_ih = arm_pci_msi_intr_establish(>sc_pc, pih, ipl,
-		callback, arg, xname);
-
-		return phic;
-	}
+	if ((ih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
+		return arm_pci_msi_intr_establish(>sc_pc, ih, ipl, callback, arg, xname);
 
-	specifier = pcihost_find_intr(sc, pih & ARM_PCI_INTR_IRQ, );
+	specifier = pcihost_find_intr(sc, ih & ARM_PCI_INTR_IRQ, );
 	if (specifier == NULL)
 		return NULL;
 
-	phic->phic_ih = fdtbus_intr_establish_raw(ihandle, specifier, ipl, flags,
+	return fdtbus_intr_establish_raw(ihandle, specifier, ipl, flags,
 	callback, arg, xname);
-
-	return phic;
 }
 
 static void
 pcihost_intr_disestablish(void *v, void *vih)
 {
 	struct pcihost_softc *sc = v;
-	struct pcihost_cookie * const phic = vih;
-	const pci_intr_handle_t pih = phic->phic_pih;
-	void * const ih = phic->phic_ih;
-
-	kmem_free(phic, sizeof(*phic));
-
-	if ((pih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
-		return;
 
-	fdtbus_intr_disestablish(sc->sc_phandle, ih);
+	fdtbus_intr_disestablish(sc->sc_phandle, vih);
 }
 
 static int



CVS commit: src/sys/arch/arm/fdt

2022-09-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep  4 10:20:33 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
pcihost: Don't call fdtbus_intr_disestablish for MSI/MSI-X interrupts.

This avoids a KASSERT firing when using 'drvctl -d' on a pci device that
uses MSI/MSI-X interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.28 src/sys/arch/arm/fdt/pcihost_fdt.c:1.29
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.28	Sat Aug 13 16:01:34 2022
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Sun Sep  4 10:20:33 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.28 2022/08/13 16:01:34 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.29 2022/09/04 10:20:33 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.28 2022/08/13 16:01:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.29 2022/09/04 10:20:33 skrll Exp $");
 
 #include 
 
@@ -600,32 +600,54 @@ pcihost_intr_setattr(void *v, pci_intr_h
 	}
 }
 
+struct pcihost_cookie {
+	pci_intr_handle_t phic_pih;
+	void *phic_ih;
+};
+
+
 static void *
-pcihost_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
+pcihost_intr_establish(void *v, pci_intr_handle_t pih, int ipl,
 int (*callback)(void *), void *arg, const char *xname)
 {
 	struct pcihost_softc *sc = v;
-	const int flags = (ih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
+	const int flags = (pih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
 	const u_int *specifier;
 	int ihandle;
 
-	if ((ih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
-		return arm_pci_msi_intr_establish(>sc_pc, ih, ipl, callback, arg, xname);
+	struct pcihost_cookie * const phic = kmem_alloc(sizeof(*phic), KM_SLEEP);
+	phic->phic_pih = pih;
+	if ((pih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0) {
+		phic->phic_ih = arm_pci_msi_intr_establish(>sc_pc, pih, ipl,
+		callback, arg, xname);
+
+		return phic;
+	}
 
-	specifier = pcihost_find_intr(sc, ih & ARM_PCI_INTR_IRQ, );
+	specifier = pcihost_find_intr(sc, pih & ARM_PCI_INTR_IRQ, );
 	if (specifier == NULL)
 		return NULL;
 
-	return fdtbus_intr_establish_raw(ihandle, specifier, ipl, flags,
+	phic->phic_ih = fdtbus_intr_establish_raw(ihandle, specifier, ipl, flags,
 	callback, arg, xname);
+
+	return phic;
 }
 
 static void
 pcihost_intr_disestablish(void *v, void *vih)
 {
 	struct pcihost_softc *sc = v;
+	struct pcihost_cookie * const phic = vih;
+	const pci_intr_handle_t pih = phic->phic_pih;
+	void * const ih = phic->phic_ih;
+
+	kmem_free(phic, sizeof(*phic));
+
+	if ((pih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
+		return;
 
-	fdtbus_intr_disestablish(sc->sc_phandle, vih);
+	fdtbus_intr_disestablish(sc->sc_phandle, ih);
 }
 
 static int



CVS commit: src/sys/arch/arm/fdt

2022-09-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep  4 10:20:33 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
pcihost: Don't call fdtbus_intr_disestablish for MSI/MSI-X interrupts.

This avoids a KASSERT firing when using 'drvctl -d' on a pci device that
uses MSI/MSI-X interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 16:01:35 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Process "ranges" property even when linux,pci-probe-only is set.

When the linux,pci-probe-only flag is set, we still need to process the
ranges property to determine whether or not to set PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_OKAY flags on the bus.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.27 src/sys/arch/arm/fdt/pcihost_fdt.c:1.28
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.27	Mon Sep  6 14:03:17 2021
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Sat Aug 13 16:01:34 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.27 2021/09/06 14:03:17 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.28 2022/08/13 16:01:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.27 2021/09/06 14:03:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.28 2022/08/13 16:01:34 jmcneill Exp $");
 
 #include 
 
@@ -250,8 +250,6 @@ pcihost_config(struct pcihost_softc *sc)
 	const int chosen = OF_finddevice("/chosen");
 	if (chosen <= 0 || of_getprop_uint32(chosen, "linux,pci-probe-only", _only))
 		probe_only = 0;
-	if (probe_only)
-		return 0;
 
 	if (sc->sc_pci_ranges != NULL) {
 		ranges = sc->sc_pci_ranges;
@@ -350,8 +348,12 @@ pcihost_config(struct pcihost_softc *sc)
 		}
 	}
 
-	error = pci_configure_bus(>sc_pc, pcires, sc->sc_bus_min,
-	PCIHOST_CACHELINE_SIZE);
+	if (probe_only) {
+		error = 0;
+	} else {
+		error = pci_configure_bus(>sc_pc, pcires, sc->sc_bus_min,
+		PCIHOST_CACHELINE_SIZE);
+	}
 
 	pciconf_resource_fini(pcires);
 



CVS commit: src/sys/arch/arm/fdt

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 16:01:35 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Process "ranges" property even when linux,pci-probe-only is set.

When the linux,pci-probe-only flag is set, we still need to process the
ranges property to determine whether or not to set PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_OKAY flags on the bus.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2022-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 11 13:04:35 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
gic at fdt: Don't assume all irqs are established on disestablish.

Fixes panic on detach of PCI devices on pcihost.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/fdt/gic_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/arch/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.24 src/sys/arch/arm/fdt/gic_fdt.c:1.25
--- src/sys/arch/arm/fdt/gic_fdt.c:1.24	Thu Nov  4 21:31:30 2021
+++ src/sys/arch/arm/fdt/gic_fdt.c	Thu Aug 11 13:04:35 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.25 2022/08/11 13:04:35 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.25 2022/08/11 13:04:35 riastradh Exp $");
 
 #include 
 #include 
@@ -328,7 +328,7 @@ gic_fdt_disestablish(device_t dev, void 
 
 	for (n = 0; n < GIC_MAXIRQ; n++) {
 		firq = sc->sc_irq[n];
-		if (firq->intr_ih != ih)
+		if (firq == NULL || firq->intr_ih != ih)
 			continue;
 
 		KASSERT(firq->intr_refcnt > 0);



CVS commit: src/sys/arch/arm/fdt

2022-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 11 13:04:35 UTC 2022

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
gic at fdt: Don't assume all irqs are established on disestablish.

Fixes panic on detach of PCI devices on pcihost.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/fdt/gic_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2021-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 17 21:46:12 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gicv3_fdt.c

Log Message:
gicv3: add support for mbi-alias property

The mbi-alias property, if present, contains the base address of a GICD
alias frame that contains only SET/CLRSPI registers. Use this instead of
the GICD register frame if present.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/gicv3_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/arch/arm/fdt/gicv3_fdt.c
diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.15 src/sys/arch/arm/fdt/gicv3_fdt.c:1.16
--- src/sys/arch/arm/fdt/gicv3_fdt.c:1.15	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/fdt/gicv3_fdt.c	Wed Nov 17 21:46:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.16 2021/11/17 21:46:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.16 2021/11/17 21:46:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -273,14 +273,18 @@ gicv3_fdt_attach_mbi(struct gicv3_fdt_so
 	bus_addr_t addr;
 	int len, frame_count;
 
-	if (of_hasprop(sc->sc_phandle, "mbi-alias")) {
-		aprint_error_dev(sc->sc_gic.sc_dev, "'mbi-alias' property not supported\n");
+	/*
+	 * If a GICD alias frame containing only the SET/CLRSPI registers
+	 * exists, the base address will be reported by the 'mbi-alias'
+	 * property. If this doesn't exist, use the GICD register frame
+	 * instead.
+	 */
+	if (of_getprop_uint64(sc->sc_phandle, "mbi-alias", ) != 0 &&
+	fdtbus_get_reg(sc->sc_phandle, 0, , NULL) != 0) {
+		aprint_error_dev(sc->sc_gic.sc_dev, "couldn't find MBI register frame\n");
 		return;
 	}
 
-	if (fdtbus_get_reg(sc->sc_phandle, 0, , NULL) != 0)
-		return;
-
 	ranges = fdtbus_get_prop(sc->sc_phandle, "mbi-ranges", );
 	if (ranges == NULL) {
 		aprint_error_dev(sc->sc_gic.sc_dev, "missing 'mbi-ranges' property\n");



CVS commit: src/sys/arch/arm/fdt

2021-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 17 21:46:12 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gicv3_fdt.c

Log Message:
gicv3: add support for mbi-alias property

The mbi-alias property, if present, contains the base address of a GICD
alias frame that contains only SET/CLRSPI registers. Use this instead of
the GICD register frame if present.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/gicv3_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2021-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Nov  4 21:31:30 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
make compilable at NPCI==0


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/gic_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/arch/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.23 src/sys/arch/arm/fdt/gic_fdt.c:1.24
--- src/sys/arch/arm/fdt/gic_fdt.c:1.23	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/fdt/gic_fdt.c	Thu Nov  4 21:31:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.23 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.23 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.24 2021/11/04 21:31:30 jakllsch Exp $");
 
 #include 
 #include 
@@ -117,10 +117,12 @@ static const struct device_compatible_en
 	DEVICE_COMPAT_EOL
 };
 
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static const struct device_compatible_entry v2m_compat_data[] = {
 	{ .compat = "arm,gic-v2m-frame" },
 	DEVICE_COMPAT_EOL
 };
+#endif
 
 static int
 gic_fdt_match(device_t parent, cfdata_t cf, void *aux)



CVS commit: src/sys/arch/arm/fdt

2021-11-04 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Nov  4 21:31:30 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
make compilable at NPCI==0


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/gic_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2021-09-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Sep 27 09:54:52 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
No longer need to call arm_pmu_init on all CPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/fdt/pmu_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/arch/arm/fdt/pmu_fdt.c
diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.8 src/sys/arch/arm/fdt/pmu_fdt.c:1.9
--- src/sys/arch/arm/fdt/pmu_fdt.c:1.8	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/fdt/pmu_fdt.c	Mon Sep 27 09:54:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmu_fdt.c,v 1.8 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: pmu_fdt.c,v 1.9 2021/09/27 09:54:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.8 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.9 2021/09/27 09:54:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -113,19 +113,12 @@ pmu_fdt_attach(device_t parent, device_t
 }
 
 static void
-pmu_fdt_init_cpu(void *arg1, void *arg2)
-{
-	arm_pmu_init();
-}
-
-static void
 pmu_fdt_init(device_t self)
 {
 	struct pmu_fdt_softc * const sc = device_private(self);
 	const int phandle = sc->sc_phandle;
 	char intrstr[128];
 	int error, n;
-	uint64_t xc;
 	void **ih;
 
 	if (pmu_fdt_uses_ppi && pmu_fdt_count > 0) {
@@ -140,8 +133,7 @@ pmu_fdt_init(device_t self)
 	}
 
 	if (pmu_fdt_count == 0) {
-		xc = xc_broadcast(0, pmu_fdt_init_cpu, NULL, NULL);
-		xc_wait(xc);
+		arm_pmu_init();
 	}
 
 	ih = kmem_zalloc(sizeof(void *) * ncpu, KM_SLEEP);



CVS commit: src/sys/arch/arm/fdt

2021-09-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Sep 27 09:54:52 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
No longer need to call arm_pmu_init on all CPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/fdt/pmu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2021-09-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep  5 13:20:34 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: arm_fdt.c arm_fdtvar.h

Log Message:
Remove unused arm_fdt_memory_dump


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/fdt/arm_fdt.c \
src/sys/arch/arm/fdt/arm_fdtvar.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/arch/arm/fdt/arm_fdt.c
diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.18 src/sys/arch/arm/fdt/arm_fdt.c:1.19
--- src/sys/arch/arm/fdt/arm_fdt.c:1.18	Mon Aug 30 23:20:00 2021
+++ src/sys/arch/arm/fdt/arm_fdt.c	Sun Sep  5 13:20:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdt.c,v 1.18 2021/08/30 23:20:00 jmcneill Exp $ */
+/* $NetBSD: arm_fdt.c,v 1.19 2021/09/05 13:20:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -31,7 +31,7 @@
 #include "opt_modular.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.18 2021/08/30 23:20:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.19 2021/09/05 13:20:34 jmcneill Exp $");
 
 #include 
 #include 
@@ -227,29 +227,6 @@ arm_fdt_timer_register(void (*timerfn)(v
 	_arm_fdt_timer_init = timerfn;
 }
 
-void
-arm_fdt_memory_dump(paddr_t pa)
-{
-	const struct arm_platform *plat = arm_fdt_platform();
-	struct fdt_attach_args faa;
-	bus_space_tag_t bst;
-	bus_space_handle_t bsh;
-
-	plat->ap_init_attach_args();
-
-	bst = faa.faa_bst;
-	bus_space_map(bst, pa, 0x100, 0, );
-
-	for (int i = 0; i < 0x100; i += 0x10) {
-		printf("%" PRIxPTR ": %08x %08x %08x %08x\n",
-		(uintptr_t)(pa + i),
-		bus_space_read_4(bst, bsh, i + 0),
-		bus_space_read_4(bst, bsh, i + 4),
-		bus_space_read_4(bst, bsh, i + 8),
-		bus_space_read_4(bst, bsh, i + 12));
-	}
-}
-
 #ifdef __HAVE_GENERIC_CPU_INITCLOCKS
 void
 cpu_initclocks(void)
Index: src/sys/arch/arm/fdt/arm_fdtvar.h
diff -u src/sys/arch/arm/fdt/arm_fdtvar.h:1.18 src/sys/arch/arm/fdt/arm_fdtvar.h:1.19
--- src/sys/arch/arm/fdt/arm_fdtvar.h:1.18	Mon Aug 30 23:20:00 2021
+++ src/sys/arch/arm/fdt/arm_fdtvar.h	Sun Sep  5 13:20:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.18 2021/08/30 23:20:00 jmcneill Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.19 2021/09/05 13:20:34 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill 
@@ -97,8 +97,6 @@ void	arm_fdt_irq_handler(void *);
 void	arm_fdt_fiq_set_handler(void (*)(void *));
 void	arm_fdt_fiq_handler(void *);
 
-void	arm_fdt_memory_dump(paddr_t);
-
 void	arm_fdt_module_init(void);
 
 #endif /* !_ARM_ARM_FDTVAR_H */



CVS commit: src/sys/arch/arm/fdt

2021-09-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep  5 13:20:34 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: arm_fdt.c arm_fdtvar.h

Log Message:
Remove unused arm_fdt_memory_dump


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/fdt/arm_fdt.c \
src/sys/arch/arm/fdt/arm_fdtvar.h

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



CVS commit: src/sys/arch/arm/fdt

2021-08-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Aug 30 23:16:17 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
Inspect #address-cells to determine if the cpu-release-addr requires
a 32- or 64-bit write.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/fdt/cpu_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/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.40 src/sys/arch/arm/fdt/cpu_fdt.c:1.41
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.40	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Mon Aug 30 23:16:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.40 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.41 2021/08/30 23:16:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.40 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.41 2021/08/30 23:16:17 jmcneill Exp $");
 
 #include 
 #include 
@@ -332,7 +332,8 @@ ARM_CPU_METHOD(psci, "psci", cpu_enable_
 
 #if defined(MULTIPROCESSOR) && defined(__aarch64__)
 static int
-spintable_cpu_on(u_int cpuindex, paddr_t entry_point_address, paddr_t cpu_release_addr)
+spintable_cpu_on(const int phandle, u_int cpuindex,
+paddr_t entry_point_address, paddr_t cpu_release_addr)
 {
 	/*
 	 * we need devmap for cpu-release-addr in advance.
@@ -346,10 +347,18 @@ spintable_cpu_on(u_int cpuindex, paddr_t
 		extern struct bus_space arm_generic_bs_tag;
 		bus_space_handle_t ioh;
 
+		const int parent = OF_parent(phandle);
+		const int addr_cells = fdtbus_get_addr_cells(parent);
+
 		bus_space_map(_generic_bs_tag, cpu_release_addr,
 		sizeof(paddr_t), 0, );
-		bus_space_write_4(_generic_bs_tag, ioh, 0,
-		entry_point_address);
+		if (addr_cells == 1) {
+			bus_space_write_4(_generic_bs_tag, ioh, 0,
+			entry_point_address);
+		} else {
+			bus_space_write_8(_generic_bs_tag, ioh, 0,
+			entry_point_address);
+		}
 		bus_space_unmap(_generic_bs_tag, ioh, sizeof(paddr_t));
 	}
 
@@ -367,7 +376,8 @@ cpu_enable_spin_table(int phandle)
 	if (of_getprop_uint64(phandle, "cpu-release-addr", ) != 0)
 		return ENXIO;
 
-	ret = spintable_cpu_on(mpidr, cpu_fdt_mpstart_pa(), (paddr_t)addr);
+	ret = spintable_cpu_on(phandle, mpidr, cpu_fdt_mpstart_pa(),
+	(paddr_t)addr);
 	if (ret != 0)
 		return EIO;
 



CVS commit: src/sys/arch/arm/fdt

2021-08-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Aug 30 23:16:17 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
Inspect #address-cells to determine if the cpu-release-addr requires
a 32- or 64-bit write.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/fdt/cpu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
Remove unnecessary cast and wrap a long line.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/fdt/gic_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/arch/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.17 src/sys/arch/arm/fdt/gic_fdt.c:1.18
--- src/sys/arch/arm/fdt/gic_fdt.c:1.17	Fri Jul 19 12:14:15 2019
+++ src/sys/arch/arm/fdt/gic_fdt.c	Sun Nov 24 11:10:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $");
 
 #include 
 #include 
@@ -226,9 +226,9 @@ gic_fdt_attach_v2m(struct gic_fdt_softc 
 	if (gic_v2m_init(frame, sc->sc_gicdev, sc->sc_v2m_count++) != 0) {
 		aprint_error_dev(sc->sc_gicdev, "failed to initialize GICv2m\n");
 	} else {
-		aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64 ", SPIs %u-%u\n",
-		(uint64_t)frame->frame_reg, frame->frame_base,
-		frame->frame_base + frame->frame_count);
+		aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64
+		", SPIs %u-%u\n", frame->frame_reg,
+		frame->frame_base, frame->frame_base + frame->frame_count);
 	}
 }
 #endif



CVS commit: src/sys/arch/arm/fdt

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 11:10:13 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c

Log Message:
Remove unnecessary cast and wrap a long line.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/fdt/gic_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 12:06:33 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: smsh_fdt.c

Log Message:
Match smsc,lan9115 and honour local-mac-address/mac-address properties


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/smsh_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 12:06:33 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: smsh_fdt.c

Log Message:
Match smsc,lan9115 and honour local-mac-address/mac-address properties


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/smsh_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/arch/arm/fdt/smsh_fdt.c
diff -u src/sys/arch/arm/fdt/smsh_fdt.c:1.1 src/sys/arch/arm/fdt/smsh_fdt.c:1.2
--- src/sys/arch/arm/fdt/smsh_fdt.c:1.1	Fri Jun  2 10:46:07 2017
+++ src/sys/arch/arm/fdt/smsh_fdt.c	Sun Nov  3 12:06:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $ */
+/* $NetBSD: smsh_fdt.c,v 1.2 2019/11/03 12:06:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v 1.1 2017/06/02 10:46:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v 1.2 2019/11/03 12:06:32 jmcneill Exp $");
 
 #include 
 #include 
@@ -49,7 +49,11 @@ __KERNEL_RCSID(0, "$NetBSD: smsh_fdt.c,v
 static int	smsh_fdt_match(device_t, cfdata_t, void *);
 static void	smsh_fdt_attach(device_t, device_t, void *);
 
-static const char * const compatible[] = { "smsc,lan9118", NULL };
+static const char * const compatible[] = {
+	"smsc,lan9118",
+	"smsc,lan9115",
+	NULL
+};
 
 CFATTACH_DECL_NEW(smsh_fdt, sizeof(struct lan9118_softc),
 	smsh_fdt_match, smsh_fdt_attach, NULL, NULL);
@@ -67,10 +71,12 @@ smsh_fdt_attach(device_t parent, device_
 {
 	struct lan9118_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
-	char intrstr[128];
 	const int phandle = faa->faa_phandle;
+	const char *enaddr;
+	char intrstr[128];
 	bus_addr_t addr;
 	bus_size_t size;
+	int len;
 	void *ih;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
@@ -95,6 +101,14 @@ smsh_fdt_attach(device_t parent, device_
 	if (of_hasprop(phandle, "smsc,irq-push-pull"))
 		sc->sc_flags |= LAN9118_FLAGS_IRQ_PP;
 
+	enaddr = fdtbus_get_prop(phandle, "local-mac-address", );
+	if (enaddr == NULL || len != ETHER_ADDR_LEN)
+		enaddr = fdtbus_get_prop(phandle, "mac-address", );
+	if (enaddr != NULL && len == ETHER_ADDR_LEN) {
+		memcpy(sc->sc_enaddr, enaddr, ETHER_ADDR_LEN);
+		sc->sc_flags |= LAN9118_FLAGS_NO_EEPROM;
+	}
+
 	if (lan9118_attach(sc) != 0)
 		goto unmap;
 



CVS commit: src/sys/arch/arm/fdt

2019-11-01 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Nov  1 13:22:08 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
fix typos in comment in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/fdt/cpu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-11-01 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Nov  1 13:22:08 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
fix typos in comment in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/fdt/cpu_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/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.29 src/sys/arch/arm/fdt/cpu_fdt.c:1.30
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.29	Fri Nov  1 12:44:54 2019
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Fri Nov  1 13:22:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.29 2019/11/01 12:44:54 bad Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.30 2019/11/01 13:22:08 bad Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.29 2019/11/01 12:44:54 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.30 2019/11/01 13:22:08 bad Exp $");
 
 #include 
 #include 
@@ -349,7 +349,7 @@ cpu_enable_psci(int phandle)
 
 #if !defined(AARCH64)
 	/*
-	 * not necessary on AARCH64. besids there it hangs the sysmte
+	 * not necessary on AARCH64. beside there it hangs the system
 	 * because cache ops are only functional after cpu_attach()
 	 * was called.
 	 */



CVS commit: src/sys/arch/arm/fdt

2019-11-01 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Nov  1 12:44:54 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
re-apply r1.26. but only #if !defined(AARCH64).

not necessary on armv8 and cache ops are not available that early there.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/fdt/cpu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-11-01 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Nov  1 12:44:54 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
re-apply r1.26. but only #if !defined(AARCH64).

not necessary on armv8 and cache ops are not available that early there.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/fdt/cpu_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/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.28 src/sys/arch/arm/fdt/cpu_fdt.c:1.29
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.28	Sat Oct 19 18:04:26 2019
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Fri Nov  1 12:44:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.28 2019/10/19 18:04:26 jmcneill Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.29 2019/11/01 12:44:54 bad Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.28 2019/10/19 18:04:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.29 2019/11/01 12:44:54 bad Exp $");
 
 #include 
 #include 
@@ -347,6 +347,14 @@ cpu_enable_psci(int phandle)
 
 	fdtbus_get_reg64(phandle, 0, , NULL);
 
+#if !defined(AARCH64)
+	/*
+	 * not necessary on AARCH64. besids there it hangs the sysmte
+	 * because cache ops are only functional after cpu_attach()
+	 * was called.
+	 */
+	cpu_dcache_wbinv_all();
+#endif
 	ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0);
 	if (ret != PSCI_SUCCESS)
 		return EIO;



CVS commit: src/sys/arch/arm/fdt

2019-10-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Thu Oct 17 21:52:27 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
back out r1.26. it makes the pinebook fail to boot.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/fdt/cpu_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/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.26 src/sys/arch/arm/fdt/cpu_fdt.c:1.27
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.26	Tue Oct 15 17:25:02 2019
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Thu Oct 17 21:52:26 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.26 2019/10/15 17:25:02 bad Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.27 2019/10/17 21:52:26 bad Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.26 2019/10/15 17:25:02 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.27 2019/10/17 21:52:26 bad Exp $");
 
 #include 
 #include 
@@ -348,7 +348,6 @@ cpu_enable_psci(int phandle)
 
 	fdtbus_get_reg64(phandle, 0, , NULL);
 
-	cpu_dcache_wbinv_all();
 	ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0);
 	if (ret != PSCI_SUCCESS)
 		return EIO;



CVS commit: src/sys/arch/arm/fdt

2019-10-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Thu Oct 17 21:52:27 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
back out r1.26. it makes the pinebook fail to boot.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/fdt/cpu_fdt.c

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



Re: CVS commit: src/sys/arch/arm/fdt

2019-10-17 Thread Jonathan A. Kollasch
This change causes evbarm/aarch64 to hang early on an Allwinner
A64-based Pinebook.

On Tue, Oct 15, 2019 at 05:25:02PM +, Christoph Badura wrote:
> Module Name:  src
> Committed By: bad
> Date: Tue Oct 15 17:25:02 UTC 2019
> 
> Modified Files:
>   src/sys/arch/arm/fdt: cpu_fdt.c
> 
> Log Message:
> flush the dcache in cpu_enable_psci() before calling psci_cpu_on().
> 
> fixes the kernel hanging with multiple "mpstart" on (at least) NanoPi R1.
> 
> OK jmcneill@, skrll@
> 
> XXX pullup-9
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/fdt/cpu_fdt.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 


CVS commit: src/sys/arch/arm/fdt

2019-10-15 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Tue Oct 15 17:25:02 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
flush the dcache in cpu_enable_psci() before calling psci_cpu_on().

fixes the kernel hanging with multiple "mpstart" on (at least) NanoPi R1.

OK jmcneill@, skrll@

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/fdt/cpu_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/arch/arm/fdt/cpu_fdt.c
diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.25 src/sys/arch/arm/fdt/cpu_fdt.c:1.26
--- src/sys/arch/arm/fdt/cpu_fdt.c:1.25	Sat Apr 13 19:15:25 2019
+++ src/sys/arch/arm/fdt/cpu_fdt.c	Tue Oct 15 17:25:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_fdt.c,v 1.25 2019/04/13 19:15:25 jmcneill Exp $ */
+/* $NetBSD: cpu_fdt.c,v 1.26 2019/10/15 17:25:02 bad Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "psci_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.25 2019/04/13 19:15:25 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.26 2019/10/15 17:25:02 bad Exp $");
 
 #include 
 #include 
@@ -348,6 +348,7 @@ cpu_enable_psci(int phandle)
 
 	fdtbus_get_reg64(phandle, 0, , NULL);
 
+	cpu_dcache_wbinv_all();
 	ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0);
 	if (ret != PSCI_SUCCESS)
 		return EIO;



CVS commit: src/sys/arch/arm/fdt

2019-10-15 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Tue Oct 15 17:25:02 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: cpu_fdt.c

Log Message:
flush the dcache in cpu_enable_psci() before calling psci_cpu_on().

fixes the kernel hanging with multiple "mpstart" on (at least) NanoPi R1.

OK jmcneill@, skrll@

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/fdt/cpu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jul 23 12:34:05 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plfb_fdt.c

Log Message:
Add support for WSDISPLAY_MULTICONS


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/plfb_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/arch/arm/fdt/plfb_fdt.c
diff -u src/sys/arch/arm/fdt/plfb_fdt.c:1.3 src/sys/arch/arm/fdt/plfb_fdt.c:1.4
--- src/sys/arch/arm/fdt/plfb_fdt.c:1.3	Sat Jul  6 15:53:38 2019
+++ src/sys/arch/arm/fdt/plfb_fdt.c	Tue Jul 23 12:34:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: plfb_fdt.c,v 1.3 2019/07/06 15:53:38 jmcneill Exp $ */
+/* $NetBSD: plfb_fdt.c,v 1.4 2019/07/23 12:34:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,8 +30,10 @@
  * ARM PrimeCell PL111 framebuffer console driver
  */
 
+#include "opt_wsdisplay_compat.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plfb_fdt.c,v 1.3 2019/07/06 15:53:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plfb_fdt.c,v 1.4 2019/07/23 12:34:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -171,15 +173,27 @@ plfb_attach(device_t parent, device_t se
 
 	plfb_init(sc);
 
+	aprint_naive("\n");
+	aprint_normal("\n");
+
 	sc->sc_wstype = WSDISPLAY_TYPE_PLFB;
-	prop_dictionary_set_bool(dict, "is_console",
-	phandle == plfb_console_phandle);
+
+#ifdef WSDISPLAY_MULTICONS
+	const bool is_console = true;
+	genfb_cnattach();
+#else
+	const bool is_console = phandle == plfb_console_phandle;
+	if (is_console)
+		aprint_normal_dev(self, "switching to framebuffer console\n");
+#endif
+
+	prop_dictionary_set_bool(dict, "is_console", is_console);
 
 	genfb_init(>sc_gen);
 
 	if (sc->sc_gen.sc_width == 0 ||
 	sc->sc_gen.sc_fbsize == 0) {
-		aprint_normal(": disabled\n");
+		aprint_normal_dev(self, "disabled\n");
 		return;
 	}
 
@@ -189,9 +203,6 @@ plfb_attach(device_t parent, device_t se
 	ops.genfb_ioctl = plfb_ioctl;
 	ops.genfb_mmap = plfb_mmap;
 
-	aprint_naive("\n");
-	aprint_normal("\n");
-
 	genfb_attach(>sc_gen, );
 }
 



CVS commit: src/sys/arch/arm/fdt

2019-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jul 23 12:34:05 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plfb_fdt.c

Log Message:
Add support for WSDISPLAY_MULTICONS


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/plfb_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-07-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jul 19 12:14:16 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c gicv3_fdt.c

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/gic_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/gicv3_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/arch/arm/fdt/gic_fdt.c
diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.16 src/sys/arch/arm/fdt/gic_fdt.c:1.17
--- src/sys/arch/arm/fdt/gic_fdt.c:1.16	Sat Jan 26 14:43:46 2019
+++ src/sys/arch/arm/fdt/gic_fdt.c	Fri Jul 19 12:14:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -29,7 +29,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.17 2019/07/19 12:14:15 hkenken Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@ struct gic_fdt_irq;
 
 static int	gic_fdt_match(device_t, cfdata_t, void *);
 static void	gic_fdt_attach(device_t, device_t, void *);
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void	gic_fdt_attach_v2m(struct gic_fdt_softc *, bus_space_tag_t, int);
 #endif
 
@@ -179,7 +179,7 @@ gic_fdt_attach(device_t parent, device_t
 
 	arm_fdt_irq_set_handler(armgic_irq_handler);
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
 		if (!fdtbus_status_okay(child))
 			continue;
@@ -190,7 +190,7 @@ gic_fdt_attach(device_t parent, device_t
 #endif
 }
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void
 gic_fdt_attach_v2m(struct gic_fdt_softc *sc, bus_space_tag_t bst, int phandle)
 {

Index: src/sys/arch/arm/fdt/gicv3_fdt.c
diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.7 src/sys/arch/arm/fdt/gicv3_fdt.c:1.8
--- src/sys/arch/arm/fdt/gicv3_fdt.c:1.7	Sat Jan 26 14:43:46 2019
+++ src/sys/arch/arm/fdt/gicv3_fdt.c	Fri Jul 19 12:14:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.8 2019/07/19 12:14:15 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.8 2019/07/19 12:14:15 hkenken Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ static int	gicv3_fdt_match(device_t, cfd
 static void	gicv3_fdt_attach(device_t, device_t, void *);
 
 static int	gicv3_fdt_map_registers(struct gicv3_fdt_softc *);
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void	gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int);
 #endif
 
@@ -158,7 +158,7 @@ gicv3_fdt_attach(device_t parent, device
 		return;
 	}
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
 		if (!fdtbus_status_okay(child))
 			continue;
@@ -238,7 +238,7 @@ gicv3_fdt_map_registers(struct gicv3_fdt
 	return 0;
 }
 
-#if NPCI > 0
+#if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX)
 static void
 gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle)
 {



CVS commit: src/sys/arch/arm/fdt

2019-07-19 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Jul 19 12:14:16 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: gic_fdt.c gicv3_fdt.c

Log Message:
Fixed compile error.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/gic_fdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/gicv3_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul  6 15:53:38 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plfb_fdt.c

Log Message:
If panel timings are missing, assume 800x600


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/plfb_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-07-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul  6 15:53:38 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plfb_fdt.c

Log Message:
If panel timings are missing, assume 800x600


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/plfb_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/arch/arm/fdt/plfb_fdt.c
diff -u src/sys/arch/arm/fdt/plfb_fdt.c:1.2 src/sys/arch/arm/fdt/plfb_fdt.c:1.3
--- src/sys/arch/arm/fdt/plfb_fdt.c:1.2	Tue Jun  6 00:26:59 2017
+++ src/sys/arch/arm/fdt/plfb_fdt.c	Sat Jul  6 15:53:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: plfb_fdt.c,v 1.2 2017/06/06 00:26:59 jmcneill Exp $ */
+/* $NetBSD: plfb_fdt.c,v 1.3 2019/07/06 15:53:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plfb_fdt.c,v 1.2 2017/06/06 00:26:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plfb_fdt.c,v 1.3 2019/07/06 15:53:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -262,9 +262,15 @@ plfb_init(struct plfb_softc *sc)
 	struct display_timing timing;
 
 	if (plfb_get_panel_timing(sc, ) != 0) {
-		aprint_error_dev(sc->sc_gen.sc_dev,
-		"couldn't get panel timings\n");
-		return;
+		/* No timings specified in DT, assume 800x600 */
+		timing.hactive = 800;
+		timing.hback_porch = 128;
+		timing.hfront_porch = 24;
+		timing.hsync_len = 72;
+		timing.vactive = 600;
+		timing.vback_porch = 22;
+		timing.vfront_porch = 1;
+		timing.vsync_len = 2;
 	}
 
 	prop_dictionary_set_uint32(dict, "width", timing.hactive);



CVS commit: src/sys/arch/arm/fdt

2019-06-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 29 12:53:05 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
Add support for multiple PMUs


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/pmu_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/arch/arm/fdt/pmu_fdt.c
diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.5 src/sys/arch/arm/fdt/pmu_fdt.c:1.6
--- src/sys/arch/arm/fdt/pmu_fdt.c:1.5	Mon Jan 21 08:04:26 2019
+++ src/sys/arch/arm/fdt/pmu_fdt.c	Sat Jun 29 12:53:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pmu_fdt.c,v 1.5 2019/01/21 08:04:26 skrll Exp $ */
+/* $NetBSD: pmu_fdt.c,v 1.6 2019/06/29 12:53:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.5 2019/01/21 08:04:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.6 2019/06/29 12:53:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -52,6 +53,9 @@ __KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 
 
 #include 
 
+static bool	pmu_fdt_uses_ppi;
+static int	pmu_fdt_count;
+
 static int	pmu_fdt_match(device_t, cfdata_t, void *);
 static void	pmu_fdt_attach(device_t, device_t, void *);
 
@@ -109,20 +113,37 @@ pmu_fdt_attach(device_t parent, device_t
 }
 
 static void
+pmu_fdt_init_cpu(void *arg1, void *arg2)
+{
+	arm_pmu_init();
+}
+
+static void
 pmu_fdt_init(device_t self)
 {
 	struct pmu_fdt_softc * const sc = device_private(self);
 	const int phandle = sc->sc_phandle;
 	char intrstr[128];
 	int error, n;
+	uint64_t xc;
 	void **ih;
 
-	error = arm_pmu_init();
-	if (error != 0) {
-		aprint_error_dev(self, "failed to initialize PMU\n");
+	if (pmu_fdt_uses_ppi && pmu_fdt_count > 0) {
+		/*
+		 * Second instance of a PMU where PPIs are used. Since the PMU
+		 * is already initialized and the PPI interrupt handler has
+		 * already been installed, there is nothing left to do here.
+		 */
+		if (fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)))
+			aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 		return;
 	}
 
+	if (pmu_fdt_count == 0) {
+		xc = xc_broadcast(0, pmu_fdt_init_cpu, NULL, NULL);
+		xc_wait(xc);
+	}
+
 	ih = kmem_zalloc(sizeof(void *) * ncpu, KM_SLEEP);
 
 	for (n = 0; n < ncpu; n++) {
@@ -158,6 +179,9 @@ pmu_fdt_init(device_t self)
 		}
 	}
 
+	pmu_fdt_count++;
+	pmu_fdt_uses_ppi = nirq == 1 && ncpu > 1;
+
 cleanup:
 	kmem_free(ih, sizeof(void *) * ncpu);
 }



CVS commit: src/sys/arch/arm/fdt

2019-06-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jun 29 12:53:05 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pmu_fdt.c

Log Message:
Add support for multiple PMUs


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/pmu_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 23 22:06:03 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Use ARM_PCI_INTR_* definitions from pci_machdep.h instead of own copies


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.10 src/sys/arch/arm/fdt/pcihost_fdt.c:1.11
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.10	Wed Jun 12 22:47:03 2019
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Sun Jun 23 22:06:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.10 2019/06/12 22:47:03 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.11 2019/06/23 22:06:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.10 2019/06/12 22:47:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.11 2019/06/23 22:06:03 jmcneill Exp $");
 
 #include 
 #include 
@@ -53,9 +53,6 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.
 #include 
 #include 
 
-#define	IH_INDEX_MASK			0x
-#define	IH_MPSAFE			0x8000
-
 #define	PCIHOST_DEFAULT_BUS_MIN		0
 #define	PCIHOST_DEFAULT_BUS_MAX		255
 
@@ -572,7 +569,7 @@ pcihost_intr_string(void *v, pci_intr_ha
 	} else if (ih & ARM_PCI_INTR_MSI) {
 		snprintf(buf, len, "irq %d (MSI vec %d)", irq, vec);
 	} else {
-		specifier = pcihost_find_intr(sc, ih & IH_INDEX_MASK, );
+		specifier = pcihost_find_intr(sc, ih & ARM_PCI_INTR_IRQ, );
 		if (specifier == NULL)
 			return NULL;
 
@@ -595,9 +592,9 @@ pcihost_intr_setattr(void *v, pci_intr_h
 	switch (attr) {
 	case PCI_INTR_MPSAFE:
 		if (data)
-			*ih |= IH_MPSAFE;
+			*ih |= ARM_PCI_INTR_MPSAFE;
 		else
-			*ih &= ~IH_MPSAFE;
+			*ih &= ~ARM_PCI_INTR_MPSAFE;
 		return 0;
 	default:
 		return ENODEV;
@@ -609,14 +606,14 @@ pcihost_intr_establish(void *v, pci_intr
 int (*callback)(void *), void *arg, const char *xname)
 {
 	struct pcihost_softc *sc = v;
-	const int flags = (ih & IH_MPSAFE) ? FDT_INTR_MPSAFE : 0;
+	const int flags = (ih & ARM_PCI_INTR_MPSAFE) ? FDT_INTR_MPSAFE : 0;
 	const u_int *specifier;
 	int ihandle;
 
 	if ((ih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
 		return arm_pci_msi_intr_establish(>sc_pc, ih, ipl, callback, arg, xname);
 
-	specifier = pcihost_find_intr(sc, ih & IH_INDEX_MASK, );
+	specifier = pcihost_find_intr(sc, ih & ARM_PCI_INTR_IRQ, );
 	if (specifier == NULL)
 		return NULL;
 



CVS commit: src/sys/arch/arm/fdt

2019-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 23 22:06:03 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Use ARM_PCI_INTR_* definitions from pci_machdep.h instead of own copies


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-06-22 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Jun 22 17:57:10 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
Restore previous range of aa_dmat.

Should fix ahcisata_acpi on OverDrive 1000, which has no DRAM below 4GiB.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/acpi_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-06-22 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Jun 22 17:57:10 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
Restore previous range of aa_dmat.

Should fix ahcisata_acpi on OverDrive 1000, which has no DRAM below 4GiB.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/acpi_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/arch/arm/fdt/acpi_fdt.c
diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.10 src/sys/arch/arm/fdt/acpi_fdt.c:1.11
--- src/sys/arch/arm/fdt/acpi_fdt.c:1.10	Wed Jun 19 13:39:18 2019
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Sat Jun 22 17:57:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.10 2019/06/19 13:39:18 jmcneill Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.11 2019/06/22 17:57:10 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.10 2019/06/19 13:39:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.11 2019/06/22 17:57:10 jakllsch Exp $");
 
 #include 
 #include 
@@ -70,7 +70,6 @@ static int	acpi_fdt_efi_rtc_settime(todr
 
 static void	acpi_fdt_sysctl_init(void);
 
-extern struct arm32_bus_dma_tag acpi_coherent32_dma_tag;
 extern struct arm32_bus_dma_tag acpi_coherent64_dma_tag;
 
 #if NPCI > 0
@@ -137,7 +136,7 @@ acpi_fdt_attach(device_t parent, device_
 #endif
 
 	aa.aa_memt = faa->faa_bst;
-	aa.aa_dmat = _coherent32_dma_tag;
+	aa.aa_dmat = _coherent64_dma_tag;
 #ifdef _PCI_HAVE_DMA64
 	aa.aa_dmat64 = _coherent64_dma_tag;
 #endif



CVS commit: src/sys/arch/arm/fdt

2019-06-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 12 22:47:03 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Support configuring ranges where only prefetchable memory is defined


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/pcihost_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-06-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 12 22:47:03 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: pcihost_fdt.c

Log Message:
Support configuring ranges where only prefetchable memory is defined


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/pcihost_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/arch/arm/fdt/pcihost_fdt.c
diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.9 src/sys/arch/arm/fdt/pcihost_fdt.c:1.10
--- src/sys/arch/arm/fdt/pcihost_fdt.c:1.9	Wed Jun 12 10:13:44 2019
+++ src/sys/arch/arm/fdt/pcihost_fdt.c	Wed Jun 12 22:47:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pcihost_fdt.c,v 1.9 2019/06/12 10:13:44 jmcneill Exp $ */
+/* $NetBSD: pcihost_fdt.c,v 1.10 2019/06/12 22:47:03 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.9 2019/06/12 10:13:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.10 2019/06/12 22:47:03 jmcneill Exp $");
 
 #include 
 #include 
@@ -347,6 +347,11 @@ pcihost_config(struct pcihost_softc *sc)
 		}
 	}
 
+	if (memext == NULL && pmemext != NULL) {
+		memext = pmemext;
+		pmemext = NULL;
+	}
+
 	error = pci_configure_bus(>sc_pc, ioext, memext, pmemext, sc->sc_bus_min, PCIHOST_CACHELINE_SIZE);
 
 	if (ioext)



CVS commit: src/sys/arch/arm/fdt

2019-06-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jun 12 10:19:27 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plmmc_fdt.c

Log Message:
Print interrupt details


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/plmmc_fdt.c

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



CVS commit: src/sys/arch/arm/fdt

2019-06-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jun 12 10:19:27 UTC 2019

Modified Files:
src/sys/arch/arm/fdt: plmmc_fdt.c

Log Message:
Print interrupt details


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/plmmc_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/arch/arm/fdt/plmmc_fdt.c
diff -u src/sys/arch/arm/fdt/plmmc_fdt.c:1.1 src/sys/arch/arm/fdt/plmmc_fdt.c:1.2
--- src/sys/arch/arm/fdt/plmmc_fdt.c:1.1	Fri Jun  2 11:04:01 2017
+++ src/sys/arch/arm/fdt/plmmc_fdt.c	Wed Jun 12 10:19:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: plmmc_fdt.c,v 1.1 2017/06/02 11:04:01 jmcneill Exp $ */
+/* $NetBSD: plmmc_fdt.c,v 1.2 2019/06/12 10:19:27 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plmmc_fdt.c,v 1.1 2017/06/02 11:04:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plmmc_fdt.c,v 1.2 2019/06/12 10:19:27 skrll Exp $");
 
 #include 
 #include 
@@ -87,6 +87,12 @@ plmmc_fdt_attach(device_t parent, device
 		return;
 	}
 
+	char intrstr[128];
+	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
+		aprint_error(": failed to decode interrupt\n");
+		return;
+	}
+
 	sc->sc_dev = self;
 	sc->sc_clock_freq = clk_get_rate(clk);
 	of_getprop_uint32(phandle, "max-frequency", >sc_max_freq);
@@ -104,6 +110,7 @@ plmmc_fdt_attach(device_t parent, device
 		aprint_error_dev(self, "couldn't install interrupt handler\n");
 		return;
 	}
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	plmmc_init(sc);
 }