CVS commit: src/sys/arch/powerpc/booke/dev

2021-04-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Apr 22 01:33:18 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Fix rnd(9) support; events were not sampled actually in the previous.

Remove #if-0'ed and wrap long line for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.52 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.53
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.52	Sun Jan 24 05:16:56 2021
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Thu Apr 22 01:33:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.53 2021/04/22 01:33:18 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.53 2021/04/22 01:33:18 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1640,14 +1640,14 @@ pq3etsec_rxq_consume(
 			rxq->rxq_consumer = consumer;
 			rxq->rxq_inuse -= rxconsumed;
 			KASSERT(rxq->rxq_inuse == 0);
-			return;
+			break;
 		}
 		pq3etsec_rxq_desc_postsync(sc, rxq, consumer, 1);
 		const uint16_t rxbd_flags = consumer->rxbd_flags;
 		if (rxbd_flags & RXBD_E) {
 			rxq->rxq_consumer = consumer;
 			rxq->rxq_inuse -= rxconsumed;
-			return;
+			break;
 		}
 		KASSERT(rxq->rxq_mconsumer != NULL);
 #ifdef ETSEC_DEBUG
@@ -2178,6 +2178,7 @@ pq3etsec_txq_consume(
 	struct ifnet * const ifp = &sc->sc_if;
 	volatile struct txbd *consumer = txq->txq_consumer;
 	size_t txfree = 0;
+	bool ret;
 
 #if 0
 	printf("%s: entry: free=%zu\n", __func__, txq->txq_free);
@@ -2189,13 +2190,11 @@ pq3etsec_txq_consume(
 			txq->txq_consumer = consumer;
 			txq->txq_free += txfree;
 			txq->txq_lastintr -= uimin(txq->txq_lastintr, txfree);
-#if 0
-			printf("%s: empty: freed %zu descriptors going form %zu to %zu\n",
-			__func__, txfree, txq->txq_free - txfree, txq->txq_free);
-#endif
 			KASSERT(txq->txq_lastintr == 0);
-			KASSERT(txq->txq_free == txq->txq_last - txq->txq_first - 1);
-			return true;
+			KASSERT(txq->txq_free ==
+			txq->txq_last - txq->txq_first - 1);
+			ret = true;
+			break;
 		}
 		pq3etsec_txq_desc_postsync(sc, txq, consumer, 1);
 		const uint16_t txbd_flags = consumer->txbd_flags;
@@ -2203,11 +2202,8 @@ pq3etsec_txq_consume(
 			txq->txq_consumer = consumer;
 			txq->txq_free += txfree;
 			txq->txq_lastintr -= uimin(txq->txq_lastintr, txfree);
-#if 0
-			printf("%s: freed %zu descriptors\n",
-			__func__, txfree);
-#endif
-			return pq3etsec_txq_fillable_p(sc, txq);
+			ret = pq3etsec_txq_fillable_p(sc, txq);
+			break;
 		}
 
 		/*
@@ -2274,6 +2270,7 @@ pq3etsec_txq_consume(
 
 	if (txfree != 0)
 		rnd_add_uint32(&sc->rnd_source, txfree);
+	return ret;
 }
 
 static void



CVS commit: src/sys/arch/powerpc/booke

2021-03-30 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Mar 30 14:29:54 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
- Write-back msgbuf and update bootstr for reboot from halt.
- Remove dead code.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.32 src/sys/arch/powerpc/booke/booke_machdep.c:1.33
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.32	Mon Jul  6 10:08:16 2020
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Tue Mar 30 14:29:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.32 2020/07/06 10:08:16 rin Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.33 2021/03/30 14:29:54 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.32 2020/07/06 10:08:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.33 2021/03/30 14:29:54 rin Exp $");
 
 #include "ksyms.h"
 
@@ -288,15 +288,6 @@ cpu_reboot(int howto, char *what)
 		cnpollc(1);	/* For proper keyboard command handling */
 		cngetc();
 		cnpollc(0);
-
-		printf("rebooting...\n\n");
-		goto reboot;	/* XXX for now... */
-
-#ifdef DDB
-		printf("dropping to debugger\n");
-		while(1)
-			Debugger();
-#endif
 	}
 
 	printf("rebooting\n\n");
@@ -321,7 +312,6 @@ cpu_reboot(int howto, char *what)
 	/* flush cache for msgbuf */
 	dcache_wb(msgbuf_paddr, round_page(MSGBUFSIZE));
 
- reboot:
 	__asm volatile("msync; isync");
 	(*cpu_md_ops.md_cpu_reset)();
 



CVS commit: src/sys/arch/powerpc/booke/dev

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:16:57 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Add rnd(9) support.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.52
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51	Sun Jan 24 05:14:55 2021
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sun Jan 24 05:16:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -237,6 +239,8 @@ struct pq3etsec_softc {
 	int sc_ic_rx_count;
 	int sc_ic_tx_time;
 	int sc_ic_tx_count;
+
+	krndsource_t rnd_source;
 };
 
 #define	ETSEC_IC_RX_ENABLED(sc)		\
@@ -808,6 +812,9 @@ pq3etsec_attach(device_t parent, device_
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 
+	rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET,
+	RND_FLAG_DEFAULT);
+
 	pq3etsec_ifstop(ifp, true);
 
 	evcnt_attach_dynamic(&sc->sc_ev_rx_stall, EVCNT_TYPE_MISC,
@@ -1714,6 +1721,9 @@ pq3etsec_rxq_consume(
 		KASSERT(rxq->rxq_mbufs[consumer - rxq->rxq_first] == rxq->rxq_mconsumer);
 #endif
 	}
+
+	if (rxconsumed != 0)
+		rnd_add_uint32(&sc->rnd_source, rxconsumed);
 }
 
 static void
@@ -2261,6 +2271,9 @@ pq3etsec_txq_consume(
 			KASSERT(consumer < txq->txq_last);
 		}
 	}
+
+	if (txfree != 0)
+		rnd_add_uint32(&sc->rnd_source, txfree);
 }
 
 static void



CVS commit: src/sys/arch/powerpc/booke/dev

2021-01-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jan 24 05:14:55 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Switch to if_percpuq_enqueue() from if_input().


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.50 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.51
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.50	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sun Jan 24 05:14:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.50 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.50 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -804,8 +804,9 @@ pq3etsec_attach(device_t parent, device_
 		goto fail_10;
 	}
 	pq3etsec_sysctl_setup(NULL, sc);
+	if_attach(ifp);
+	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
-	if_register(ifp);
 
 	pq3etsec_ifstop(ifp, true);
 
@@ -1613,9 +1614,7 @@ pq3etsec_rx_input(
 	/*
 	 * Let's give it to the network subsystm to deal with.
 	 */
-	int s = splnet();
-	if_input(ifp, m);
-	splx(s);
+	if_percpuq_enqueue(ifp->if_percpuq, m);
 }
 
 static void



CVS commit: src/sys/arch/powerpc/booke

2021-01-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jan  6 08:04:58 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Sort headers. Also, use  instead of db_interface.h and
db_machdep.h in order not to be bothered by subtle include order.

No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.35 src/sys/arch/powerpc/booke/trap.c:1.36
--- src/sys/arch/powerpc/booke/trap.c:1.35	Thu Sep 10 02:45:28 2020
+++ src/sys/arch/powerpc/booke/trap.c	Wed Jan  6 08:04:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.35 2020/09/10 02:45:28 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.36 2021/01/06 08:04:57 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.35 2020/09/10 02:45:28 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.36 2021/01/06 08:04:57 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -43,34 +43,32 @@ __KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.3
 #endif
 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
 #include 
+#include 
+#include 
+
+#include 
 
 #include 
 
+#include 		/* use same interface for SPE */
+#include 
 #include 
-#include 
 #include 
-#include 
-#include 		/* use same interface for SPE */
-
 #include 
-#include 
-#include 
+#include 
+#include 
 
 #include 
 
-#include 
-#include 
-
-#include 
-#include 
+#include 
 #include 
+#include 
+#include 
 
 void trap(enum ppc_booke_exceptions, struct trapframe *);
 



CVS commit: src/sys/arch/powerpc/booke

2021-01-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jan  6 07:56:20 UTC 2021

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
Fix pmap_procwr() for powerpc/booke:

- Use PAGE_MASK, not PAGE_SIZE, to calculate page offset.
- Do not drop page offset of target address.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.30 src/sys/arch/powerpc/booke/booke_pmap.c:1.31
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.30	Sun Dec 20 16:38:25 2020
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Wed Jan  6 07:56:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.30 2020/12/20 16:38:25 skrll Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.31 2021/01/06 07:56:19 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,7 +37,7 @@
 #define __PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.30 2020/12/20 16:38:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.31 2021/01/06 07:56:19 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -62,7 +62,7 @@ void
 pmap_procwr(struct proc *p, vaddr_t va, size_t len)
 {
 	struct pmap * const pmap = p->p_vmspace->vm_map.pmap;
-	vsize_t off = va & PAGE_SIZE;
+	vsize_t off = va & PAGE_MASK;
 
 	kpreempt_disable();
 	for (const vaddr_t eva = va + len; va < eva; off = 0) {
@@ -78,8 +78,8 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 			continue;
 		}
 		kpreempt_enable();
-		dcache_wb(pte_to_paddr(pt_entry), segeva - va);
-		icache_inv(pte_to_paddr(pt_entry), segeva - va);
+		dcache_wb(pte_to_paddr(pt_entry) + off, segeva - va);
+		icache_inv(pte_to_paddr(pt_entry) + off, segeva - va);
 		kpreempt_disable();
 		va = segeva;
 	}



CVS commit: src/sys/arch/powerpc/booke/pci

2020-11-11 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Nov 12 00:44:22 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
pq3pci_msi_claim(): remove KASSERT that is valid when allocating MSI
vectors, while apparently invalid when freeing them.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.26 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.27
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.26	Thu Nov 12 00:37:51 2020
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Thu Nov 12 00:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.26 2020/11/12 00:37:51 rin Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.27 2020/11/12 00:44:22 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define	__INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.26 2020/11/12 00:37:51 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.27 2020/11/12 00:44:22 rin Exp $");
 
 #include "locators.h"
 
@@ -1196,7 +1196,6 @@ pq3pci_msi_claim(pci_intr_handle_t handl
 	KASSERT(msig != NULL);
 	struct pq3pci_msihand * const msih = &msig->msig_ihands[irq & 31];
 	mutex_spin_enter(&msig->msig_lock);
-	KASSERT(msig->msig_free_mask & irq_mask);
 	msig->msig_free_mask ^= irq_mask;
 	mutex_spin_exit(&msig->msig_lock);
 	return msih;



CVS commit: src/sys/arch/powerpc/booke/pci

2020-11-11 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Nov 12 00:37:51 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
Oops, forget to commit local change necessary to support nvme(4) on RB800;
provide pci_intr_setattr(9) (no-op).


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.25 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.26
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.25	Tue Jul  7 03:38:48 2020
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Thu Nov 12 00:37:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.25 2020/07/07 03:38:48 thorpej Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.26 2020/11/12 00:37:51 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define	__INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.25 2020/07/07 03:38:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.26 2020/11/12 00:37:51 rin Exp $");
 
 #include "locators.h"
 
@@ -1753,6 +1753,7 @@ pq3pci_pci_chipset_init(struct pq3pci_so
 	pc->pc_intr_type = pq3pci_intr_type;
 	pc->pc_intr_alloc = pq3pci_intr_alloc;
 	pc->pc_intr_release = pq3pci_intr_release;
+	pc->pc_intr_setattr = genppc_pci_intr_setattr;
 	pc->pc_intx_alloc = genppc_pci_intx_alloc;
 
 	pc->pc_msi_v = sc;



CVS commit: src/sys/arch/powerpc/booke

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 02:45:28 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Fix build with UVMHIST; stop passing string literal to UVMHIST_LOG(),
and also cast pointer arguments into uintptr_t.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.34 src/sys/arch/powerpc/booke/trap.c:1.35
--- src/sys/arch/powerpc/booke/trap.c:1.34	Wed Jul 15 09:10:14 2020
+++ src/sys/arch/powerpc/booke/trap.c	Thu Sep 10 02:45:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.34 2020/07/15 09:10:14 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.35 2020/09/10 02:45:28 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.34 2020/07/15 09:10:14 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.35 2020/09/10 02:45:28 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -294,12 +294,18 @@ isi_exception(struct trapframe *tf, ksig
 		KASSERT(pg);
 		struct vm_page_md * const mdpg = VM_PAGE_TO_MD(pg);
 
-		UVMHIST_LOG(pmapexechist,
-		"srr0=%#x pg=%p (pa %#"PRIxPADDR"): %s", 
-		tf->tf_srr0, pg, pa, 
-		(VM_PAGEMD_EXECPAGE_P(mdpg)
-			? "no syncicache (already execpage)"
-			: "performed syncicache (now execpage)"));
+#ifdef UVMHIST
+		if (VM_PAGEMD_EXECPAGE_P(mdpg))
+			UVMHIST_LOG(pmapexechist,
+			"srr0=%#x pg=%p (pa %#"PRIxPADDR"): "
+			"no syncicache (already execpage)", 
+			tf->tf_srr0, (uintptr_t)pg, pa, 0);
+		else
+			UVMHIST_LOG(pmapexechist,
+			"srr0=%#x pg=%p (pa %#"PRIxPADDR"): "
+			"performed syncicache (now execpage)",
+			tf->tf_srr0, (uintptr_t)pg, pa, 0);
+#endif
 
 		if (!VM_PAGEMD_EXECPAGE_P(mdpg)) {
 			ci->ci_softc->cpu_ev_exec_trap_sync.ev_count++;



CVS commit: src/sys/arch/powerpc/booke

2020-07-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jul 15 07:44:34 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Do not use curlwp twice. No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.32 src/sys/arch/powerpc/booke/trap.c:1.33
--- src/sys/arch/powerpc/booke/trap.c:1.32	Tue Jul  7 00:49:09 2020
+++ src/sys/arch/powerpc/booke/trap.c	Wed Jul 15 07:44:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.32 2020/07/07 00:49:09 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.33 2020/07/15 07:44:34 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.32 2020/07/07 00:49:09 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.33 2020/07/15 07:44:34 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -477,10 +477,12 @@ pgm_exception(struct trapframe *tf, ksig
 	}
 
 	if (tf->tf_esr & ESR_PIL) {
-		struct pcb * const pcb = lwp_getpcb(curlwp);
-		if (__predict_false(!fpu_used_p(curlwp))) {
+		struct lwp * const l = curlwp;
+		struct pcb * const pcb = lwp_getpcb(l);
+
+		if (__predict_false(!fpu_used_p(l))) {
 			memset(&pcb->pcb_fpu, 0, sizeof(pcb->pcb_fpu));
-			fpu_mark_used(curlwp);
+			fpu_mark_used(l);
 		}
 		if (fpu_emulate(tf, &pcb->pcb_fpu, ksi)) {
 			if (ksi->ksi_signo == 0) {



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  7 00:59:30 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
Revert previous; tmpfs should be fixed instead.

Pointed out by thorpej@, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.22 src/sys/arch/powerpc/booke/e500_tlb.c:1.23
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.22	Tue Jul  7 00:28:30 2020
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Tue Jul  7 00:59:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.22 2020/07/07 00:28:30 rin Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.23 2020/07/07 00:59:29 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,7 +37,7 @@
 #define	__PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.22 2020/07/07 00:28:30 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.23 2020/07/07 00:59:29 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -536,13 +536,6 @@ e500_tlb_invalidate_addr(vaddr_t va, tlb
 static bool
 e500_tlb_update_addr(vaddr_t va, tlb_asid_t asid, pt_entry_t pte, bool insert)
 {
-
-	/*
-	 * In case where pmap_kenter_pa(9) is called for va with page offset.
-	 * Required for tmpfs.
-	 */
-	va &= ~PAGE_MASK;
-
 #if defined(MULTIPROCESSOR)
 	e500_tlb_invalidate_addr(va, asid);
 	return true;



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  7 00:49:09 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
For booke, fix signo and other siginfo returned for userland by
syncing with oea and ibm4xx.

Now, tests/kernel/t_trapsignal:bus_handle and friends pass on booke.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.31 src/sys/arch/powerpc/booke/trap.c:1.32
--- src/sys/arch/powerpc/booke/trap.c:1.31	Tue Jul  7 00:41:32 2020
+++ src/sys/arch/powerpc/booke/trap.c	Tue Jul  7 00:49:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.31 2020/07/07 00:41:32 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.32 2020/07/07 00:49:09 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.31 2020/07/07 00:41:32 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.32 2020/07/07 00:49:09 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -112,15 +112,13 @@ mchk_exception(struct trapframe *tf, ksi
 	struct cpu_info * const ci = curcpu();
 	int rv = EFAULT;
 
-	if (usertrap)
+	if (usertrap) {
 		ci->ci_ev_umchk.ev_count++;
-
-	if (rv != 0 && usertrap) {
 		KSI_INIT_TRAP(ksi);
-		ksi->ksi_signo = SIGSEGV;
-		ksi->ksi_trap = EXC_DSI;
-		ksi->ksi_code = SEGV_ACCERR;
+		ksi->ksi_signo = SIGBUS;
+		ksi->ksi_trap = EXC_MCHK;
 		ksi->ksi_addr = (void *)faultva;
+		ksi->ksi_code = BUS_OBJERR;
 	}
 
 	return rv;
@@ -169,8 +167,6 @@ pagefault(struct vm_map *map, vaddr_t va
 		rv = uvm_fault(map, trunc_page(va), ftype);
 		if (rv == 0)
 			uvm_grow(l->l_proc, trunc_page(va));
-		if (rv == EACCES)
-			rv = EFAULT;
 	} else {
 		if (cpu_intr_p())
 			return EFAULT;
@@ -184,12 +180,33 @@ pagefault(struct vm_map *map, vaddr_t va
 			if (rv == 0)
 uvm_grow(l->l_proc, trunc_page(va));
 		}
-		if (rv == EACCES)
-			rv = EFAULT;
 	}
 	return rv;
 }
 
+static void
+vm_signal(int error, int trap, vaddr_t addr, ksiginfo_t *ksi)
+{
+
+	KSI_INIT_TRAP(ksi);
+	switch (error) {
+	case EINVAL:
+		ksi->ksi_signo = SIGBUS;
+		ksi->ksi_code = BUS_ADRERR;
+		break;
+	case EACCES:
+		ksi->ksi_signo = SIGSEGV;
+		ksi->ksi_code = SEGV_ACCERR;
+		break;
+	default:
+		ksi->ksi_signo = SIGSEGV;
+		ksi->ksi_code = SEGV_MAPERR;
+		break;
+	}
+	ksi->ksi_trap = trap;
+	ksi->ksi_addr = (void *)addr;
+}
+
 static int
 dsi_exception(struct trapframe *tf, ksiginfo_t *ksi)
 {
@@ -236,16 +253,9 @@ dsi_exception(struct trapframe *tf, ksig
 
 	int rv = pagefault(faultmap, faultva, ftype, usertrap);
 
-	/*
-	 * We can't get a MAPERR here since that's a different exception.
-	 */
 	if (__predict_false(rv != 0 && usertrap)) {
 		ci->ci_ev_udsi_fatal.ev_count++;
-		KSI_INIT_TRAP(ksi);
-		ksi->ksi_signo = SIGSEGV;
-		ksi->ksi_trap = EXC_DSI;
-		ksi->ksi_code = SEGV_ACCERR;
-		ksi->ksi_addr = (void *)faultva;
+		vm_signal(rv, EXC_DSI, faultva, ksi);
 	}
 	return rv;
 }
@@ -313,16 +323,8 @@ isi_exception(struct trapframe *tf, ksig
 	usertrap);
 
 	if (__predict_false(rv != 0 && usertrap)) {
-		/*
-		 * We can't get a MAPERR here since
-		 * that's a different exception.
-		 */
 		ci->ci_ev_isi_fatal.ev_count++;
-		KSI_INIT_TRAP(ksi);
-		ksi->ksi_signo = SIGSEGV;
-		ksi->ksi_trap = EXC_ISI;
-		ksi->ksi_code = SEGV_ACCERR;
-		ksi->ksi_addr = (void *)tf->tf_srr0; /* not truncated */
+		vm_signal(rv, EXC_ISI, tf->tf_srr0, ksi);
 	}
 	UVMHIST_LOG(pmapexechist, "<- %d", rv, 0,0,0);
 	return rv;
@@ -358,11 +360,7 @@ dtlb_exception(struct trapframe *tf, ksi
 
 	if (__predict_false(rv != 0 && usertrap)) {
 		ci->ci_ev_udsi_fatal.ev_count++;
-		KSI_INIT_TRAP(ksi);
-		ksi->ksi_signo = SIGSEGV;
-		ksi->ksi_trap = EXC_DSI;
-		ksi->ksi_code = (rv == EACCES ? SEGV_ACCERR : SEGV_MAPERR);
-		ksi->ksi_addr = (void *)faultva;
+		vm_signal(rv, EXC_DSI, faultva, ksi);
 	}
 	return rv;
 }
@@ -382,11 +380,7 @@ itlb_exception(struct trapframe *tf, ksi
 
 	if (__predict_false(rv != 0 && usertrap)) {
 		ci->ci_ev_isi_fatal.ev_count++;
-		KSI_INIT_TRAP(ksi);
-		ksi->ksi_signo = SIGSEGV;
-		ksi->ksi_trap = EXC_ISI;
-		ksi->ksi_code = (rv == EACCES ? SEGV_ACCERR : SEGV_MAPERR);
-		ksi->ksi_addr = (void *)tf->tf_srr0;
+		vm_signal(rv, EXC_ISI, tf->tf_srr0, ksi);
 	}
 	return rv;
 }
@@ -880,6 +874,7 @@ trap(enum ppc_booke_exceptions trap_code
 			p->p_pid, l->l_lid, p->p_comm,
 			l->l_cred ?  kauth_cred_geteuid(l->l_cred) : -1);
 			ksi.ksi_signo = SIGKILL;
+			ksi.ksi_code = 0;
 		}
 		if (rv != 0) {
 			/*



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  7 00:41:32 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Do not clear pcb_onfault for error path of setfault().
This is caller's responsibility, and all the callers actually do so.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.30 src/sys/arch/powerpc/booke/trap.c:1.31
--- src/sys/arch/powerpc/booke/trap.c:1.30	Tue Jul  7 00:37:46 2020
+++ src/sys/arch/powerpc/booke/trap.c	Tue Jul  7 00:41:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.30 2020/07/07 00:37:46 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.31 2020/07/07 00:41:32 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.30 2020/07/07 00:37:46 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.31 2020/07/07 00:41:32 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -691,7 +691,6 @@ onfaulted(struct trapframe *tf, register
 	tf->tf_fixreg[2] = fb->fb_r2;
 	tf->tf_fixreg[3] = rv;
 	memcpy(&tf->tf_fixreg[13], fb->fb_fixreg, sizeof(fb->fb_fixreg));
-	pcb->pcb_onfault = NULL;
 	return true;
 }
 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  7 00:37:46 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
For booke, restore callee saved registers when recovery for page fault
fails for kernel.

OOPS! How on the earth we had overlooked this error so far...


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.29 src/sys/arch/powerpc/booke/trap.c:1.30
--- src/sys/arch/powerpc/booke/trap.c:1.29	Mon Jul  6 10:13:02 2020
+++ src/sys/arch/powerpc/booke/trap.c	Tue Jul  7 00:37:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.29 2020/07/06 10:13:02 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.30 2020/07/07 00:37:46 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.29 2020/07/06 10:13:02 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.30 2020/07/07 00:37:46 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -690,6 +690,7 @@ onfaulted(struct trapframe *tf, register
 	tf->tf_fixreg[1] = fb->fb_sp;
 	tf->tf_fixreg[2] = fb->fb_r2;
 	tf->tf_fixreg[3] = rv;
+	memcpy(&tf->tf_fixreg[13], fb->fb_fixreg, sizeof(fb->fb_fixreg));
 	pcb->pcb_onfault = NULL;
 	return true;
 }



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  7 00:28:31 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
Fix kernel panic due to tmpfs.

pmap for booke assumes that the ``va'' argument for pmap_kenter_pa(9) is
page-aligned. However, by recent changes, tmpfs became to use ``va'' with
page offset via ubc_uiomove(9). So, truncate it to page boundary.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.21 src/sys/arch/powerpc/booke/e500_tlb.c:1.22
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.21	Mon Jul  6 10:12:04 2020
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Tue Jul  7 00:28:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.21 2020/07/06 10:12:04 rin Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.22 2020/07/07 00:28:30 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,7 +37,7 @@
 #define	__PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.21 2020/07/06 10:12:04 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.22 2020/07/07 00:28:30 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -536,6 +536,13 @@ e500_tlb_invalidate_addr(vaddr_t va, tlb
 static bool
 e500_tlb_update_addr(vaddr_t va, tlb_asid_t asid, pt_entry_t pte, bool insert)
 {
+
+	/*
+	 * In case where pmap_kenter_pa(9) is called for va with page offset.
+	 * Required for tmpfs.
+	 */
+	va &= ~PAGE_MASK;
+
 #if defined(MULTIPROCESSOR)
 	e500_tlb_invalidate_addr(va, asid);
 	return true;



CVS commit: src/sys/arch/powerpc/booke/dev

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:22:44 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3cfi.c pq3nandfcm.c

Log Message:
Drop unused opt_flash.h.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/booke/dev/pq3cfi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/dev/pq3nandfcm.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/powerpc/booke/dev/pq3cfi.c
diff -u src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.6 src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.7
--- src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.6	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/dev/pq3cfi.c	Mon Jul  6 10:22:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3cfi.c,v 1.6 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: pq3cfi.c,v 1.7 2020/07/06 10:22:44 rin Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,14 +33,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.6 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.7 2020/07/06 10:22:44 rin Exp $");
 
 #include "locators.h"
 
-#ifdef _KERNEL_OPT
-#include "opt_flash.h"
-#endif
-
 #include 
 #include 
 #include 

Index: src/sys/arch/powerpc/booke/dev/pq3nandfcm.c
diff -u src/sys/arch/powerpc/booke/dev/pq3nandfcm.c:1.3 src/sys/arch/powerpc/booke/dev/pq3nandfcm.c:1.4
--- src/sys/arch/powerpc/booke/dev/pq3nandfcm.c:1.3	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/dev/pq3nandfcm.c	Mon Jul  6 10:22:44 2020
@@ -30,11 +30,7 @@
 #define LBC_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3nandfcm.c,v 1.3 2020/07/06 09:34:16 rin Exp $");
-
-#ifdef _KERNEL_OPT
-#include "opt_flash.h"
-#endif
+__KERNEL_RCSID(0, "$NetBSD: pq3nandfcm.c,v 1.4 2020/07/06 10:22:44 rin Exp $");
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:16:12 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap_subr.S

Log Message:
Include required opt_*.h for sure.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/booke/trap_subr.S

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/powerpc/booke/trap_subr.S
diff -u src/sys/arch/powerpc/booke/trap_subr.S:1.12 src/sys/arch/powerpc/booke/trap_subr.S:1.13
--- src/sys/arch/powerpc/booke/trap_subr.S:1.12	Mon Jan 26 04:47:53 2015
+++ src/sys/arch/powerpc/booke/trap_subr.S	Mon Jul  6 10:16:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.12 2015/01/26 04:47:53 nonaka Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.13 2020/07/06 10:16:12 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-RCSID("$NetBSD: trap_subr.S,v 1.12 2015/01/26 04:47:53 nonaka Exp $")
+RCSID("$NetBSD: trap_subr.S,v 1.13 2020/07/06 10:16:12 rin Exp $")
+
+#ifdef _KERNEL_OPT
+#include "opt_altivec.h"
+#include "opt_ddb.h"
+#include "opt_mpc85xx.h"
+#include "opt_multiprocessor.h"
+#endif
 
 	.globl	_C_LABEL(sctrapexit), _C_LABEL(trapexit), _C_LABEL(intrcall)
 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:13:02 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Include missing opt_altivec.h for PPC_HAVE_SPE.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.28 src/sys/arch/powerpc/booke/trap.c:1.29
--- src/sys/arch/powerpc/booke/trap.c:1.28	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/trap.c	Mon Jul  6 10:13:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.28 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.29 2020/07/06 10:13:02 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,9 +35,10 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.28 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.29 2020/07/06 10:13:02 rin Exp $");
 
 #ifdef _KERNEL_OPT
+#include "opt_altivec.h"
 #include "opt_ddb.h"
 #endif
 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:12:04 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
Include missing opt_multiprocessor.h and opt_pmap.h.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.20 src/sys/arch/powerpc/booke/e500_tlb.c:1.21
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.20	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Mon Jul  6 10:12:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.20 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.21 2020/07/06 10:12:04 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,9 +37,11 @@
 #define	__PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.20 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.21 2020/07/06 10:12:04 rin Exp $");
 
 #ifdef _KERNEL_OPT
+#include "opt_multiprocessor.h"
+#include "opt_pmap.h"
 #include "opt_ppcparam.h"
 #endif
 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:11:14 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Drop unused opt_ddb.h.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.43 src/sys/arch/powerpc/booke/e500_intr.c:1.44
--- src/sys/arch/powerpc/booke/e500_intr.c:1.43	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/e500_intr.c	Mon Jul  6 10:11:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.43 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.44 2020/07/06 10:11:14 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,10 +37,9 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.43 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.44 2020/07/06 10:11:14 rin Exp $");
 
 #ifdef _KERNEL_OPT
-#include "opt_ddb.h"
 #include "opt_mpc85xx.h"
 #include "opt_multiprocessor.h"
 #endif



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:09:23 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
Include missing opt_multiprocessor.h and opt_pmap.h.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.28 src/sys/arch/powerpc/booke/booke_pmap.c:1.29
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.28	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Mon Jul  6 10:09:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.28 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.29 2020/07/06 10:09:23 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,7 +37,12 @@
 #define __PMAP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.28 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.29 2020/07/06 10:09:23 rin Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_multiprocessor.h"
+#include "opt_pmap.h"
+#endif
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:08:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
Include missing ksyms.h, opt_ddb.h, and opt_multiprocessor.h.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.31 src/sys/arch/powerpc/booke/booke_machdep.c:1.32
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.31	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Mon Jul  6 10:08:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.31 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.32 2020/07/06 10:08:16 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,10 +38,14 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.31 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.32 2020/07/06 10:08:16 rin Exp $");
+
+#include "ksyms.h"
 
 #ifdef _KERNEL_OPT
+#include "opt_ddb.h"
 #include "opt_modular.h"
+#include "opt_multiprocessor.h"
 #endif
 
 #include 



CVS commit: src/sys/arch/powerpc/booke

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 08:13:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
XXX
Skip KASSERT which fires when !__HAVE_FAST_SOFTINTS. Just for debug.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.41 src/sys/arch/powerpc/booke/e500_intr.c:1.42
--- src/sys/arch/powerpc/booke/e500_intr.c:1.41	Sat Jul  4 17:20:45 2020
+++ src/sys/arch/powerpc/booke/e500_intr.c	Mon Jul  6 08:13:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.41 2020/07/04 17:20:45 rin Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.42 2020/07/06 08:13:00 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.41 2020/07/04 17:20:45 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.42 2020/07/06 08:13:00 rin Exp $");
 
 #include 
 #include 
@@ -510,7 +510,9 @@ e500_splset(struct cpu_info *ci, int ipl
 {
 	struct cpu_softc * const cpu = ci->ci_softc;
 
+#ifdef __HAVE_FAST_SOFTINTS /* XXX */
 	KASSERT((curlwp->l_pflag & LP_INTR) == 0 || ipl != IPL_NONE);
+#endif
 	const u_int ctpr = IPL2CTPR(ipl);
 	KASSERT(openpic_read(cpu, OPENPIC_CTPR) == IPL2CTPR(ci->ci_cpl));
 	openpic_write(cpu, OPENPIC_CTPR, ctpr);



CVS commit: src/sys/arch/powerpc/booke

2020-07-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul  4 17:20:45 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Do not panic when splraise to IPL_NONE, which is required for
subr_cprng.c rev 1.36 and above:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_cprng.c#rev1.36


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.40 src/sys/arch/powerpc/booke/e500_intr.c:1.41
--- src/sys/arch/powerpc/booke/e500_intr.c:1.40	Sun Dec  1 15:34:45 2019
+++ src/sys/arch/powerpc/booke/e500_intr.c	Sat Jul  4 17:20:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.40 2019/12/01 15:34:45 ad Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.41 2020/07/04 17:20:45 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.40 2019/12/01 15:34:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.41 2020/07/04 17:20:45 rin Exp $");
 
 #include 
 #include 
@@ -599,15 +599,16 @@ e500_splraise(int ipl)
 			msr = 0;
 #endif
 		wrtee(msr);
-	} else if (ipl == IPL_NONE) {
+	}
+#if 0
+	else if (ipl == IPL_NONE) {
 		panic("%s: %p: cpl=%u: attempt to splraise(IPL_NONE)",
 		__func__, __builtin_return_address(0), old_ipl);
-#if 0
 	} else if (old_ipl > ipl) {
 		printf("%s: %p: cpl=%u: ignoring splraise(%u) to lower ipl\n",
 		__func__, __builtin_return_address(0), old_ipl, ipl);
-#endif
 	}
+#endif
 
 	return old_ipl;
 }



CVS commit: src/sys/arch/powerpc/booke/dev

2020-06-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Jun 25 14:52:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3obio.c

Log Message:
avoid variable-length array


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/dev/pq3obio.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/powerpc/booke/dev/pq3obio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3obio.c:1.3 src/sys/arch/powerpc/booke/dev/pq3obio.c:1.4
--- src/sys/arch/powerpc/booke/dev/pq3obio.c:1.3	Sat May 28 05:27:20 2011
+++ src/sys/arch/powerpc/booke/dev/pq3obio.c	Thu Jun 25 14:52:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3obio.c,v 1.3 2011/05/28 05:27:20 matt Exp $	*/
+/*	$NetBSD: pq3obio.c,v 1.4 2020/06/25 14:52:00 jdolecek Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,7 +40,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3obio.c,v 1.3 2011/05/28 05:27:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3obio.c,v 1.4 2020/06/25 14:52:00 jdolecek Exp $");
 
 #include 
 #include 
@@ -53,6 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: pq3obio.c,v 
 #include 
 #include 
 
+#define OBIO_PORTS	8
+
 static int pq3obio_match(device_t, cfdata_t, void *);
 static void pq3obio_attach(device_t, device_t, void *);
 
@@ -189,7 +191,7 @@ pq3obio_attach(device_t parent, device_t
 		return;
 	}
 
-	for (u_int i = 0; i < 8; i++) {
+	for (u_int i = 0; i < OBIO_PORTS; i++) {
 		struct pq3lbc_softc * const lbc = &sc->sc_lbcs[i];
 		uint32_t br = bus_space_read_4(sc->sc_bst, sc->sc_bsh, BRn(i));
 		if (br & BR_V) {
@@ -210,10 +212,10 @@ pq3obio_attach(device_t parent, device_t
 	t->pbs_limit = 0;
 	t->pbs_flags = _BUS_SPACE_BIG_ENDIAN;
 
-	u_int sorted[found];
+	u_int sorted[OBIO_PORTS];
 	u_int nsorted = 0;
 
-	for (u_int i = 0; i < 8; i++) {
+	for (u_int i = 0; i < OBIO_PORTS; i++) {
 		struct pq3lbc_softc * const lbc = &sc->sc_lbcs[i];
 		if ((lbc->lbc_br & BR_V) == 0)
 			continue;



CVS commit: src/sys/arch/powerpc/booke

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 02:02:08 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: copyout.c

Log Message:
copyoutstr(9): return ENAMETOOLONG correctly when source string is
not NUL-terminated.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/booke/copyout.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/powerpc/booke/copyout.c
diff -u src/sys/arch/powerpc/booke/copyout.c:1.7 src/sys/arch/powerpc/booke/copyout.c:1.8
--- src/sys/arch/powerpc/booke/copyout.c:1.7	Thu Mar  5 00:33:56 2020
+++ src/sys/arch/powerpc/booke/copyout.c	Thu Mar  5 02:02:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyout.c,v 1.7 2020/03/05 00:33:56 rin Exp $	*/
+/*	$NetBSD: copyout.c,v 1.8 2020/03/05 02:02:08 rin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.7 2020/03/05 00:33:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.8 2020/03/05 02:02:08 rin Exp $");
 
 #define	__UFETCHSTORE_PRIVATE
 
@@ -432,13 +432,15 @@ copyoutstr(const void *ksaddr, void *uda
 		const uint8_t data = *ksaddr8++;
 		copyout_uint8(udaddr8++, data, ds_msr);
 		if (data == 0)
-			break;
+			goto out;
 	}
+	rv = ENAMETOOLONG;
 
+out:
 	pcb->pcb_onfault = NULL;
 	if (done)
 		*done = copylen;
-	return 0;
+	return rv;
 }
 #else
 /* XXX This version of copyoutstr(9) has never beeen enabled so far. */



CVS commit: src/sys/arch/powerpc/booke

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 00:33:56 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: copyout.c

Log Message:
copyoutstr(9): sync style with copyinstr(9).

- use variable name "done" instead of "lenp"
- return return value from setfault() on fault, instead of hardcoded EFAULT

No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/booke/copyout.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/powerpc/booke/copyout.c
diff -u src/sys/arch/powerpc/booke/copyout.c:1.6 src/sys/arch/powerpc/booke/copyout.c:1.7
--- src/sys/arch/powerpc/booke/copyout.c:1.6	Wed Mar  4 13:01:52 2020
+++ src/sys/arch/powerpc/booke/copyout.c	Thu Mar  5 00:33:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyout.c,v 1.6 2020/03/04 13:01:52 rin Exp $	*/
+/*	$NetBSD: copyout.c,v 1.7 2020/03/05 00:33:56 rin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.6 2020/03/04 13:01:52 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.7 2020/03/05 00:33:56 rin Exp $");
 
 #define	__UFETCHSTORE_PRIVATE
 
@@ -402,22 +402,24 @@ copyout(const void *vksaddr, void *vudad
 
 #if 1
 int
-copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
+copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *done)
 {
 	struct pcb * const pcb = lwp_getpcb(curlwp);
 	struct faultbuf env;
+	int rv;
 
 	if (__predict_false(len == 0)) {
-		if (lenp)
-			*lenp = 0;
+		if (done)
+			*done = 0;
 		return 0;
 	}
 
-	if (setfault(&env)) {
+	rv = setfault(&env);
+	if (rv != 0) {
 		pcb->pcb_onfault = NULL;
-		if (lenp)
-			*lenp = 0;
-		return EFAULT;
+		if (done)
+			*done = 0;
+		return rv;
 	}
 
 	const register_t ds_msr = mfmsr() | PSL_DS;
@@ -434,8 +436,8 @@ copyoutstr(const void *ksaddr, void *uda
 	}
 
 	pcb->pcb_onfault = NULL;
-	if (lenp)
-		*lenp = copylen;
+	if (done)
+		*done = copylen;
 	return 0;
 }
 #else



CVS commit: src/sys/arch/powerpc/booke

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Mar  4 13:01:52 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: copyout.c

Log Message:
Comment out full function of optimized version of copyoutstr(9),
which has never been enabled so far.

Only for clarity. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/copyout.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/powerpc/booke/copyout.c
diff -u src/sys/arch/powerpc/booke/copyout.c:1.5 src/sys/arch/powerpc/booke/copyout.c:1.6
--- src/sys/arch/powerpc/booke/copyout.c:1.5	Sun Apr  7 05:25:55 2019
+++ src/sys/arch/powerpc/booke/copyout.c	Wed Mar  4 13:01:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $	*/
+/*	$NetBSD: copyout.c,v 1.6 2020/03/04 13:01:52 rin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.5 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.6 2020/03/04 13:01:52 rin Exp $");
 
 #define	__UFETCHSTORE_PRIVATE
 
@@ -400,6 +400,7 @@ copyout(const void *vksaddr, void *vudad
 	return 0;
 }
 
+#if 1
 int
 copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
 {
@@ -423,7 +424,6 @@ copyoutstr(const void *ksaddr, void *uda
 	const uint8_t *ksaddr8 = ksaddr;
 	size_t copylen = 0;
 
-#if 1
 	uint8_t *udaddr8 = (void *)udaddr;
 
 	while (copylen++ < len) {
@@ -432,7 +432,37 @@ copyoutstr(const void *ksaddr, void *uda
 		if (data == 0)
 			break;
 	}
+
+	pcb->pcb_onfault = NULL;
+	if (lenp)
+		*lenp = copylen;
+	return 0;
+}
 #else
+/* XXX This version of copyoutstr(9) has never beeen enabled so far. */
+int
+copyoutstr(const void *ksaddr, void *udaddr, size_t len, size_t *lenp)
+{
+	struct pcb * const pcb = lwp_getpcb(curlwp);
+	struct faultbuf env;
+
+	if (__predict_false(len == 0)) {
+		if (lenp)
+			*lenp = 0;
+		return 0;
+	}
+
+	if (setfault(&env)) {
+		pcb->pcb_onfault = NULL;
+		if (lenp)
+			*lenp = 0;
+		return EFAULT;
+	}
+
+	const register_t ds_msr = mfmsr() | PSL_DS;
+	const uint8_t *ksaddr8 = ksaddr;
+	size_t copylen = 0;
+
 	uint32_t *udaddr32 = (void *)((uintptr_t)udaddr & ~3);
 
 	size_t boff = (uintptr_t)udaddr & 3;
@@ -523,10 +553,10 @@ copyoutstr(const void *ksaddr, void *uda
 		copyout_le32_with_mask(udaddr32, data, mask, ds_msr);
 		copylen += wlen;
 	}
-#endif
 
 	pcb->pcb_onfault = NULL;
 	if (lenp)
 		*lenp = copylen;
 	return 0;
 }
+#endif



CVS commit: src/sys/arch/powerpc/booke

2020-03-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Mar  2 03:34:28 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke: copyin.c

Log Message:
Let copyinstr(9) return ENAMETOOLONG correctly if source is not
NUL-terminated; it cannot be determined by (uint8_t)data == '\0'
since data is right shifted at the end of loop.

Found by POOL_REDZONE.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/booke/copyin.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/powerpc/booke/copyin.c
diff -u src/sys/arch/powerpc/booke/copyin.c:1.7 src/sys/arch/powerpc/booke/copyin.c:1.8
--- src/sys/arch/powerpc/booke/copyin.c:1.7	Sun Apr  7 05:25:55 2019
+++ src/sys/arch/powerpc/booke/copyin.c	Mon Mar  2 03:34:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyin.c,v 1.7 2019/04/07 05:25:55 thorpej Exp $	*/
+/*	$NetBSD: copyin.c,v 1.8 2020/03/02 03:34:28 rin Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.7 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.8 2020/03/02 03:34:28 rin Exp $");
 
 #define	__UFETCHSTORE_PRIVATE
 
@@ -306,6 +306,7 @@ copyinstr(const void *usaddr, void *kdad
 {
 	struct pcb * const pcb = lwp_getpcb(curlwp);
 	struct faultbuf env;
+	int rv;
 
 	if (__predict_false(len == 0)) {
 		if (done)
@@ -313,7 +314,7 @@ copyinstr(const void *usaddr, void *kdad
 		return 0;
 	}
 
-	int rv = setfault(&env);
+	rv = setfault(&env);
 	if (rv != 0) {
 		pcb->pcb_onfault = NULL;
 		if (done)
@@ -346,15 +347,14 @@ copyinstr(const void *usaddr, void *kdad
 		*kdaddr8++ = data;
 		if ((uint8_t) data == 0) {
 			copylen++;
-			break;
+			goto out;
 		}
 	}
+	rv = ENAMETOOLONG;
 
+out:
 	pcb->pcb_onfault = NULL;
 	if (done)
 		*done = copylen;
-	/*
-	 * If the last byte is not NUL (0), then the name is too long.
-	 */
-	return (uint8_t)data ? ENAMETOOLONG : 0;
+	return rv;
 }



CVS commit: src/sys/arch/powerpc/booke/dev

2020-01-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 30 06:27:13 UTC 2020

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.48 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.49
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.48	Wed Jan 29 05:35:28 2020
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Thu Jan 30 06:27:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.48 2020/01/29 05:35:28 thorpej Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.49 2020/01/30 06:27:13 martin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.48 2020/01/29 05:35:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.49 2020/01/30 06:27:13 martin Exp $");
 
 #include 
 #include 
@@ -2226,7 +2226,7 @@ pq3etsec_txq_consume(
 			if (m->m_flags & M_HASFCB)
 m_adj(m, sizeof(struct txfcb));
 			bpf_mtap(ifp, m, BPF_D_OUT);
-			net_stats_ref_t nsr = IF_STAT_GETREF(ifp);
+			net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 			if_statinc_ref(nsr, if_opackets);
 			if_statadd_ref(nsr, if_obytes, m->m_pkthdr.len);
 			if (m->m_flags & M_MCAST)



CVS commit: src/sys/arch/powerpc/booke/dev

2019-04-24 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 24 11:12:12 UTC 2019

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
SIOCS is 'S'et function and the ioctl argument is ifreq.
SIOCG is 'G'et function and the ioctl armument is ifmediareq.
Before this change, SIOCG modify request unexpectedly but it doesn't cause a
real bug because the modification is overriden in ifmedia_ioctl().


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.41 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.42
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.41	Fri Mar  8 08:12:39 2019
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Wed Apr 24 11:12:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.41 2019/03/08 08:12:39 msaitoh Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.42 2019/04/24 11:12:12 msaitoh Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.41 2019/03/08 08:12:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.42 2019/04/24 11:12:12 msaitoh Exp $");
 
 #include 
 #include 
@@ -1200,7 +1200,6 @@ pq3etsec_ifioctl(struct ifnet *ifp, u_lo
 
 	switch (cmd) {
 	case SIOCSIFMEDIA:
-	case SIOCGIFMEDIA:
 		/* Flow control requires full-duplex mode. */
 		if (IFM_SUBTYPE(ifr->ifr_media) == IFM_AUTO ||
 		(ifr->ifr_media & IFM_FDX) == 0)



CVS commit: src/sys/arch/powerpc/booke

2018-01-26 Thread Felix Deichmann
Module Name:src
Committed By:   flxd
Date:   Fri Jan 26 17:49:55 UTC 2018

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Another try fixing printf format using the ultimate uintmax_t idiom.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.36 src/sys/arch/powerpc/booke/e500_intr.c:1.37
--- src/sys/arch/powerpc/booke/e500_intr.c:1.36	Fri Jan 26 09:26:43 2018
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Jan 26 17:49:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.36 2018/01/26 09:26:43 christos Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.37 2018/01/26 17:49:55 flxd Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.36 2018/01/26 09:26:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.37 2018/01/26 17:49:55 flxd Exp $");
 
 #include 
 #include 
@@ -1150,8 +1150,8 @@ e500_intr_init(void)
 		break;
 #endif
 	default:
-		panic("%s: don't know how to deal with SVR %#" PRIxREGISTER,
-		__func__, mfspr(SPR_SVR));
+		panic("%s: don't know how to deal with SVR %#jx",
+		__func__, (uintmax_t)mfspr(SPR_SVR));
 	}
 
 	/*



CVS commit: src/sys/arch/powerpc/booke

2018-01-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 26 09:26:43 UTC 2018

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
fix printf format.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.35 src/sys/arch/powerpc/booke/e500_intr.c:1.36
--- src/sys/arch/powerpc/booke/e500_intr.c:1.35	Wed May 31 22:45:07 2017
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Jan 26 04:26:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.35 2017/06/01 02:45:07 chs Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.36 2018/01/26 09:26:43 christos Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.35 2017/06/01 02:45:07 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.36 2018/01/26 09:26:43 christos Exp $");
 
 #include 
 #include 
@@ -1150,7 +1150,7 @@ e500_intr_init(void)
 		break;
 #endif
 	default:
-		panic("%s: don't know how to deal with SVR %#lx",
+		panic("%s: don't know how to deal with SVR %#" PRIxREGISTER,
 		__func__, mfspr(SPR_SVR));
 	}
 



CVS commit: src/sys/arch/powerpc/booke/dev

2017-10-23 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 23 09:23:48 UTC 2017

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
 If error occured in pq3etsec_attach(), free resources and return.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.31 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.32
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.31	Mon Oct  2 01:55:40 2017
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Mon Oct 23 09:23:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.31 2017/10/02 01:55:40 knakahara Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.32 2017/10/23 09:23:48 msaitoh Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.31 2017/10/02 01:55:40 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.32 2017/10/23 09:23:48 msaitoh Exp $");
 
 #include 
 #include 
@@ -648,27 +648,27 @@ pq3etsec_attach(device_t parent, device_
 	error = pq3etsec_rxq_attach(sc, &sc->sc_rxq, 0);
 	if (error) {
 		aprint_error(": failed to init rxq: %d\n", error);
-		return;
+		goto fail_1;
 	}
 
 	error = pq3etsec_txq_attach(sc, &sc->sc_txq, 0);
 	if (error) {
 		aprint_error(": failed to init txq: %d\n", error);
-		return;
+		goto fail_2;
 	}
 
 	error = pq3etsec_mapcache_create(sc, &sc->sc_rx_mapcache, 
 	ETSEC_MAXRXMBUFS, MCLBYTES, ETSEC_NRXSEGS);
 	if (error) {
 		aprint_error(": failed to allocate rx dmamaps: %d\n", error);
-		return;
+		goto fail_3;
 	}
 
 	error = pq3etsec_mapcache_create(sc, &sc->sc_tx_mapcache, 
 	ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS);
 	if (error) {
 		aprint_error(": failed to allocate tx dmamaps: %d\n", error);
-		return;
+		goto fail_4;
 	}
 
 	sc->sc_tx_ih = intr_establish(cnl->cnl_intrs[0], IPL_VM, IST_ONCHIP,
@@ -676,7 +676,7 @@ pq3etsec_attach(device_t parent, device_
 	if (sc->sc_tx_ih == NULL) {
 		aprint_error(": failed to establish tx interrupt: %d\n",
 		cnl->cnl_intrs[0]);
-		return;
+		goto fail_5;
 	}
 
 	sc->sc_rx_ih = intr_establish(cnl->cnl_intrs[1], IPL_VM, IST_ONCHIP,
@@ -684,7 +684,7 @@ pq3etsec_attach(device_t parent, device_
 	if (sc->sc_rx_ih == NULL) {
 		aprint_error(": failed to establish rx interrupt: %d\n",
 		cnl->cnl_intrs[1]);
-		return;
+		goto fail_6;
 	}
 
 	sc->sc_error_ih = intr_establish(cnl->cnl_intrs[2], IPL_VM, IST_ONCHIP,
@@ -692,7 +692,7 @@ pq3etsec_attach(device_t parent, device_
 	if (sc->sc_error_ih == NULL) {
 		aprint_error(": failed to establish error interrupt: %d\n",
 		cnl->cnl_intrs[2]);
-		return;
+		goto fail_7;
 	}
 
 	int softint_flags = SOFTINT_NET;
@@ -703,7 +703,7 @@ pq3etsec_attach(device_t parent, device_
 	pq3etsec_soft_intr, sc);
 	if (sc->sc_soft_ih == NULL) {
 		aprint_error(": failed to establish soft interrupt\n");
-		return;
+		goto fail_8;
 	}
 
 	/*
@@ -719,7 +719,7 @@ pq3etsec_attach(device_t parent, device_
 		sc->sc_mdio_dev = device_find_by_driver_unit("mdio", mdio);
 		if (sc->sc_mdio_dev == NULL) {
 			aprint_error(": failed to locate mdio device\n");
-			return;
+			goto fail_9;
 		}
 		aprint_normal("\n");
 	}
@@ -734,7 +734,6 @@ pq3etsec_attach(device_t parent, device_
 	sc->sc_ic_tx_count = 16;
 	pq3etsec_set_ic_rx(sc);
 	pq3etsec_set_ic_tx(sc);
-	pq3etsec_sysctl_setup(NULL, sc);
 
 	char enaddr[ETHER_ADDR_LEN] = {
 	[0] = sc->sc_macstnaddr2 >> 16,
@@ -794,7 +793,13 @@ pq3etsec_attach(device_t parent, device_
 	/*
 	 * Attach the interface.
 	 */
-	if_initialize(ifp);
+	error = if_initialize(ifp);
+	if (error != 0) {
+		aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
+		error);
+		goto fail_10;
+	}
+	pq3etsec_sysctl_setup(NULL, sc);
 	ether_ifattach(ifp, enaddr);
 	if_register(ifp);
 
@@ -818,6 +823,36 @@ pq3etsec_attach(device_t parent, device_
 	NULL, xname, "rx pause");
 	evcnt_attach_dynamic(&sc->sc_ev_mii_ticks, EVCNT_TYPE_MISC,
 	NULL, xname, "mii ticks");
+	return;
+
+fail_10:
+	ifmedia_removeall(&sc->sc_mii.mii_media);
+	mii_detach(&sc->sc_mii, sc->sc_phy_addr, MII_OFFSET_ANY);
+fail_9:
+	softint_disestablish(sc->sc_soft_ih);
+fail_8:
+	intr_disestablish(sc->sc_error_ih);
+fail_7:
+	intr_disestablish(sc->sc_rx_ih);
+fail_6:
+	intr_disestablish(sc->sc_tx_ih);
+fail_5:
+	pq3etsec_mapcache_destroy(sc, sc->sc_tx_mapcache);
+fail_4:
+	pq3etsec_mapcache_destroy(sc, sc->sc_rx_mapcache);
+fail_3:
+#if 0 /* notyet */
+	pq3etsec_txq_detach(sc);
+#endif
+fail_2:
+#if 0 /* notyet */
+	pq3etsec_rxq_detach(sc);
+#endif
+fail_1:
+	callout_destroy(&sc->sc_mii_callout);
+	mutex_obj_free(sc->sc_lock);
+	mutex_obj_free(sc->sc_hwlock);
+	bus_space_unmap(sc->sc_bst, sc->sc_bsh, cnl->cnl_size);
 }
 
 static uint64_t



CVS commit: src/sys/arch/powerpc/booke/dev

2017-10-01 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct  2 01:55:40 UTC 2017

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
only get vtag when we have vtag like the other drivers.

like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.30 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.31
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.30	Tue Sep 26 07:42:05 2017
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Mon Oct  2 01:55:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.30 2017/09/26 07:42:05 knakahara Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.31 2017/10/02 01:55:40 knakahara Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.30 2017/09/26 07:42:05 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.31 2017/10/02 01:55:40 knakahara Exp $");
 
 #include 
 #include 
@@ -1996,7 +1996,7 @@ pq3etsec_tx_offload(
 	KASSERT(m->m_flags & M_PKTHDR);
 
 	have_vtag = vlan_has_tag(m);
-	vtag = vlan_get_tag(m);
+	vtag = (have_vtag) ? vlan_get_tag(m) : 0;
 
 	/*
 	 * Let see if we are doing any offload first.
@@ -2031,7 +2031,7 @@ pq3etsec_tx_offload(
 		fcb.txfcb_l4os = M_CSUM_DATA_IPv6_HL(m->m_pkthdr.csum_data);
 	fcb.txfcb_l3os = ETHER_HDR_LEN;
 	fcb.txfcb_phcs = 0;
-	fcb.txfcb_vlctl = have_vtag ? vtag : 0;
+	fcb.txfcb_vlctl = vtag;
 
 #if 0
 	printf("%s: csum_flags=%#x: txfcb flags=%#x lsos=%u l4os=%u phcs=%u vlctl=%#x\n",



CVS commit: src/sys/arch/powerpc/booke

2017-03-17 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Mar 17 23:43:43 UTC 2017

Modified Files:
src/sys/arch/powerpc/booke: spe.c

Log Message:
apply changes to this file as well, as part of:
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/spe.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/powerpc/booke/spe.c
diff -u src/sys/arch/powerpc/booke/spe.c:1.9 src/sys/arch/powerpc/booke/spe.c:1.10
--- src/sys/arch/powerpc/booke/spe.c:1.9	Thu Mar 16 16:13:20 2017
+++ src/sys/arch/powerpc/booke/spe.c	Fri Mar 17 23:43:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spe.c,v 1.9 2017/03/16 16:13:20 chs Exp $	*/
+/*	$NetBSD: spe.c,v 1.10 2017/03/17 23:43:43 chs Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spe.c,v 1.9 2017/03/16 16:13:20 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spe.c,v 1.10 2017/03/17 23:43:43 chs Exp $");
 
 #include "opt_altivec.h"
 
@@ -149,9 +149,7 @@ vec_restore_from_mcontext(lwp_t *l, cons
 	struct pcb * const pcb = lwp_getpcb(l);
 	const union __vr *vr = mcp->__vrf.__vrs;
 
-	KASSERT(l == curlwp);
-
-	vec_save();
+	vec_save(l);
 
 	/* grab the accumulator */
 	pcb->pcb_vr.vreg[8][0] = vr->__vr32[2];
@@ -175,12 +173,10 @@ vec_save_to_mcontext(lwp_t *l, mcontext_
 {
 	struct pcb * const pcb = lwp_getpcb(l);
 
-	KASSERT(l == curlwp);
-
 	if (!vec_used_p(l))
 		return false;
 
-	vec_save();
+	vec_save(l);
 
 	mcp->__gregs[_REG_MSR] |= PSL_SPV;
 



CVS commit: src/sys/arch/powerpc/booke

2016-12-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Dec  6 07:34:22 UTC 2016

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
PR port-evbppc/51564 (myself): wait for console input after halting the machine.
ok joerg


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.24 src/sys/arch/powerpc/booke/booke_machdep.c:1.25
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.24	Mon Jul 11 16:06:52 2016
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Tue Dec  6 07:34:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.24 2016/07/11 16:06:52 matt Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.25 2016/12/06 07:34:22 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.24 2016/07/11 16:06:52 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.25 2016/12/06 07:34:22 rin Exp $");
 
 #include "opt_modular.h"
 
@@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: booke_machde
 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -275,8 +277,13 @@ cpu_reboot(int howto, char *what)
 	}
 
 	if (howto & RB_HALT) {
-		printf("halted\n\n");
+		printf("The operating system has halted.\n"
+		"Press any key to reboot.\n\n");
+		cnpollc(1);	/* For proper keyboard command handling */
+		cngetc();
+		cnpollc(0);
 
+		printf("rebooting...\n\n");
 		goto reboot;	/* XXX for now... */
 
 #ifdef DDB



CVS commit: src/sys/arch/powerpc/booke/dev

2016-07-25 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Jul 26 01:36:51 UTC 2016

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
IFQ_PURGE() must be called only after call if_initialize().
it lock ifp->if_snd.ifq_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.27 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.28
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.27	Fri Jun 10 13:27:12 2016
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Tue Jul 26 01:36:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.27 2016/06/10 13:27:12 ozaki-r Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.28 2016/07/26 01:36:50 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.27 2016/06/10 13:27:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.28 2016/07/26 01:36:50 nonaka Exp $");
 
 #include 
 #include 
@@ -791,8 +791,6 @@ pq3etsec_attach(device_t parent, device_
 	ifp->if_stop = pq3etsec_ifstop;
 	IFQ_SET_READY(&ifp->if_snd);
 
-	pq3etsec_ifstop(ifp, true);
-
 	/*
 	 * Attach the interface.
 	 */
@@ -800,6 +798,8 @@ pq3etsec_attach(device_t parent, device_
 	ether_ifattach(ifp, enaddr);
 	if_register(ifp);
 
+	pq3etsec_ifstop(ifp, true);
+
 	evcnt_attach_dynamic(&sc->sc_ev_rx_stall, EVCNT_TYPE_MISC,
 	NULL, xname, "rx stall");
 	evcnt_attach_dynamic(&sc->sc_ev_tx_stall, EVCNT_TYPE_MISC,



CVS commit: src/sys/arch/powerpc/booke/dev

2015-09-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Sep 11 06:55:56 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3ehci.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/booke/dev/pq3ehci.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/powerpc/booke/dev/pq3ehci.c
diff -u src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.6 src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.7
--- src/sys/arch/powerpc/booke/dev/pq3ehci.c:1.6	Fri Sep 11 06:51:43 2015
+++ src/sys/arch/powerpc/booke/dev/pq3ehci.c	Fri Sep 11 06:55:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3ehci.c,v 1.6 2015/09/11 06:51:43 skrll Exp $	*/
+/*	$NetBSD: pq3ehci.c,v 1.7 2015/09/11 06:55:56 skrll Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3ehci.c,v 1.6 2015/09/11 06:51:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3ehci.c,v 1.7 2015/09/11 06:55:56 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -130,7 +130,7 @@ pq3ehci_attach(device_t parent, device_t
 	 * We need to tell the USB interface to snoop all off RAM starting
 	 * at 0.  Since it can do it by powers of 2, get the highest RAM
 	 * address and roughly round it to the next power of 2 and find
-	 * the number of leading zero bits.  
+	 * the number of leading zero bits.
 	 */
 	cpu_write_4(cnl->cnl_addr + USB_SNOOP1,
 	SNOOP_2GB - __builtin_clz(curcpu()->ci_softc->cpu_highmem * 2 - 1));



CVS commit: src/sys/arch/powerpc/booke/dev

2015-02-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Feb 27 16:09:06 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3sdhc.c

Log Message:
Enable DMA transfer.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/dev/pq3sdhc.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/powerpc/booke/dev/pq3sdhc.c
diff -u src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.5 src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.6
--- src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.5	Thu Jul 26 18:38:10 2012
+++ src/sys/arch/powerpc/booke/dev/pq3sdhc.c	Fri Feb 27 16:09:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3sdhc.c,v 1.5 2012/07/26 18:38:10 matt Exp $	*/
+/*	$NetBSD: pq3sdhc.c,v 1.6 2015/02/27 16:09:05 nonaka Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -31,7 +31,7 @@
 #define	ESDHC_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.5 2012/07/26 18:38:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.6 2015/02/27 16:09:05 nonaka Exp $");
 
 #include 
 #include 
@@ -87,7 +87,7 @@ pq3sdhc_attach(device_t parent, device_t
 	psc->sc_children |= cna->cna_childmask;
 	sc->sc.sc_dmat = cna->cna_dmat;
 	sc->sc.sc_dev = self;
-	//sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
+	sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
 	sc->sc.sc_flags |=
 	SDHC_FLAG_HAVE_DVS | SDHC_FLAG_32BIT_ACCESS | SDHC_FLAG_ENHANCED;
 	sc->sc.sc_host = sc->sc_hosts;



CVS commit: src/sys/arch/powerpc/booke

2015-02-19 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb 19 08:59:56 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
fix compile failure without DIAGNOSTIC.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.16 src/sys/arch/powerpc/booke/e500_tlb.c:1.17
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.16	Fri Jan 23 06:52:55 2015
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Thu Feb 19 08:59:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.16 2015/01/23 06:52:55 nonaka Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.17 2015/02/19 08:59:56 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,7 +40,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.16 2015/01/23 06:52:55 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.17 2015/02/19 08:59:56 nonaka Exp $");
 
 #include 
 
@@ -781,7 +781,7 @@ e500_tlb_ioreserve(vaddr_t va, vsize_t l
 	KASSERT(((pte & PTE_RPN_MASK) & (len - 1)) == 0);
 
 	if ((xtlb = e500_tlb_lookup_xtlb2(va, len)) != NULL) {
-		psize_t mask = ~(xtlb->e_tlb.tlb_size - 1);
+		psize_t mask __diagused = ~(xtlb->e_tlb.tlb_size - 1);
 		KASSERT(len <= xtlb->e_tlb.tlb_size);
 		KASSERT((pte & mask) == (xtlb->e_tlb.tlb_pte & mask));
 		xtlb->e_refcnt++;



CVS commit: src/sys/arch/powerpc/booke

2015-01-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 23 09:02:42 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Initialize timer DR.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.31 src/sys/arch/powerpc/booke/e500_intr.c:1.32
--- src/sys/arch/powerpc/booke/e500_intr.c:1.31	Fri Jan 23 07:27:05 2015
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Jan 23 09:02:42 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.31 2015/01/23 07:27:05 nonaka Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.32 2015/01/23 09:02:42 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.31 2015/01/23 07:27:05 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.32 2015/01/23 09:02:42 nonaka Exp $");
 
 #include 
 #include 
@@ -409,6 +409,7 @@ static void 	e500_intr_cpu_attach(struct
 static void 	e500_intr_cpu_hatch(struct cpu_info *ci);
 static void	e500_intr_cpu_send_ipi(cpuid_t, uintptr_t);
 static void 	e500_intr_init(void);
+static void 	e500_intr_init_precpu(void);
 static const char *e500_intr_string(int, int, char *, size_t);
 static const char *e500_intr_typename(int);
 static void 	e500_critintr(struct trapframe *tf);
@@ -1145,6 +1146,22 @@ e500_intr_init(void)
 }
 
 static void
+e500_intr_init_precpu(void)
+{
+	struct cpu_info const *ci = curcpu();
+	struct cpu_softc * const cpu = ci->ci_softc;
+	bus_addr_t dr;
+
+	/*
+	 * timer's DR is set to be delivered to cpu0 as initial value.
+	 */
+	for (u_int irq = 0; irq < e500_intr_info.ii_timer_sources; irq++) { 
+		dr = OPENPIC_GTDR(ci->ci_cpuid, irq);
+		openpic_write(cpu, dr, 0);	/* stop delivery */
+	}
+}
+
+static void
 e500_idlespin(void)
 {
 	KASSERTMSG(curcpu()->ci_cpl == IPL_NONE,
@@ -1312,6 +1329,10 @@ e500_ipi_intr(void *v)
 static void
 e500_intr_cpu_hatch(struct cpu_info *ci)
 {
+
+	/* Initialize percpu interupts. */
+	e500_intr_init_precpu();
+
 	/*
 	 * Establish clock interrupt for this CPU.
 	 */



CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 23 06:58:33 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Avoid if_snd race condition when MP.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.23 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.24
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.23	Fri Jan 16 07:48:16 2015
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Jan 23 06:58:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.23 2015/01/16 07:48:16 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.24 2015/01/23 06:58:32 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,10 +36,12 @@
 
 #include "opt_inet.h"
 #include "opt_mpc85xx.h"
+#include "opt_multiprocessor.h"
+#include "opt_net_mpsafe.h"
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.23 2015/01/16 07:48:16 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.24 2015/01/23 06:58:32 nonaka Exp $");
 
 #include 
 #include 
@@ -677,7 +679,11 @@ pq3etsec_attach(device_t parent, device_
 		return;
 	}
 
-	sc->sc_soft_ih = softint_establish(SOFTINT_NET|SOFTINT_MPSAFE,
+	int softint_flags = SOFTINT_NET;
+#if !defined(MULTIPROCESSOR) || defined(NET_MPSAFE)
+	softint_flags |= SOFTINT_MPSAFE;
+#endif	/* !MULTIPROCESSOR || NET_MPSAFE */
+	sc->sc_soft_ih = softint_establish(softint_flags,
 	pq3etsec_soft_intr, sc);
 	if (sc->sc_soft_ih == NULL) {
 		aprint_error(": failed to establish soft interrupt\n");



CVS commit: src/sys/arch/powerpc/booke

2015-01-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 23 06:52:55 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
- Use tlbivax instruction for TLB update/invalidate when MULTIPROCESSOR is
  defined. Because TLB entry operation is not notified to another CPU.
- When TLB1 is updated, send IPI_TLB1SYNC to another CPU.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.15 src/sys/arch/powerpc/booke/e500_tlb.c:1.16
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.15	Sun Dec 28 14:13:56 2014
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Fri Jan 23 06:52:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.15 2014/12/28 14:13:56 nonaka Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.16 2015/01/23 06:52:55 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,7 +40,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.15 2014/12/28 14:13:56 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.16 2015/01/23 06:52:55 nonaka Exp $");
 
 #include 
 
@@ -372,6 +372,9 @@ e500_tlb_invalidate_all(void)
 static void
 e500_tlb_invalidate_globals(void)
 {
+#if defined(MULTIPROCESSOR)
+	e500_tlb_invalidate_all();
+#else	/* !MULTIPROCESSOR */
 	const size_t tlbassoc = TLBCFG_ASSOC(mftlb0cfg());
 	const size_t tlbentries = TLBCFG_NENTRY(mftlb0cfg());
 	const size_t max_epn = (tlbentries / tlbassoc) << PAGE_SHIFT;
@@ -416,11 +419,15 @@ e500_tlb_invalidate_globals(void)
 	}
 	__asm volatile("isync\n\tsync");
 	wrtee(msr);
+#endif	/* MULTIPROCESSOR */
 }
 
 static void
 e500_tlb_invalidate_asids(tlb_asid_t asid_lo, tlb_asid_t asid_hi)
 {
+#if defined(MULTIPROCESSOR)
+	e500_tlb_invalidate_all();
+#else	/* !MULTIPROCESSOR */
 	const size_t tlbassoc = TLBCFG_ASSOC(mftlb0cfg());
 	const size_t tlbentries = TLBCFG_NENTRY(mftlb0cfg());
 	const size_t max_epn = (tlbentries / tlbassoc) << PAGE_SHIFT;
@@ -454,6 +461,7 @@ e500_tlb_invalidate_asids(tlb_asid_t asi
 	}
 	__asm volatile("isync\n\tsync");
 	wrtee(msr);
+#endif	/* MULTIPROCESSOR */
 }
 
 static u_int
@@ -525,6 +533,10 @@ e500_tlb_invalidate_addr(vaddr_t va, tlb
 static bool
 e500_tlb_update_addr(vaddr_t va, tlb_asid_t asid, pt_entry_t pte, bool insert)
 {
+#if defined(MULTIPROCESSOR)
+	e500_tlb_invalidate_addr(va, asid);
+	return true;
+#else	/* !MULTIPROCESSOR */
 	struct e500_hwtlb hwtlb = tlb_to_hwtlb(
 	(struct e500_tlb){ .tlb_va = va, .tlb_asid = asid,
 		.tlb_size = PAGE_SIZE, .tlb_pte = pte,});
@@ -558,6 +570,7 @@ e500_tlb_update_addr(vaddr_t va, tlb_asi
 	hwtlb.hwtlb_mas1, hwtlb.hwtlb_mas2, hwtlb.hwtlb_mas3);
 #endif
 	return (mas1 & MAS1_V) != 0;
+#endif	/* MULTIPROCESSOR */
 }
 
 static void
@@ -788,6 +801,11 @@ e500_tlb_ioreserve(vaddr_t va, vsize_t l
 	xtlb->e_hwtlb = tlb_to_hwtlb(xtlb->e_tlb);
 	xtlb->e_hwtlb.hwtlb_mas0 |= __SHIFTIN(slot, MAS0_ESEL);
 	hwtlb_write(xtlb->e_hwtlb, true);
+
+#if defined(MULTIPROCESSOR)
+	cpu_send_ipi(IPI_DST_NOTME, IPI_TLB1SYNC);
+#endif
+
 	return 0;
 }
 
@@ -805,6 +823,10 @@ e500_tlb_iorelease(vaddr_t va)
 
 	e500_free_tlb1_entry(xtlb, slot, true);
 
+#if defined(MULTIPROCESSOR)
+	cpu_send_ipi(IPI_DST_NOTME, IPI_TLB1SYNC);
+#endif
+
 	return 0;
 }
 
@@ -841,6 +863,10 @@ e500_tlbmemmap(paddr_t memstart, psize_t
 		}
 	}
 
+#if defined(MULTIPROCESSOR)
+	cpu_send_ipi(IPI_DST_NOTME, IPI_TLB1SYNC);
+#endif
+
 	return nextslot;
 }
 



CVS commit: src/sys/arch/powerpc/booke

2015-01-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 23 06:39:41 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c booke_pmap.c

Log Message:
When pmap_bootstrap is called, kcpuset_running has not been created yet.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/booke/booke_machdep.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.21 src/sys/arch/powerpc/booke/booke_machdep.c:1.22
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.21	Mon Sep 22 21:35:15 2014
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Fri Jan 23 06:39:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.21 2014/09/22 21:35:15 matt Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.22 2015/01/23 06:39:41 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.21 2014/09/22 21:35:15 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.22 2015/01/23 06:39:41 nonaka Exp $");
 
 #include "opt_modular.h"
 
@@ -207,6 +207,9 @@ booke_cpu_startup(const char *model)
 	fake_mapiodev = 0;
 
 #ifdef MULTIPROCESSOR
+	pmap_kernel()->pm_active = kcpuset_running;
+	pmap_kernel()->pm_onproc = kcpuset_running;
+
 	for (size_t i = 1; i < __arraycount(cpu_info); i++) {
 		struct cpu_info * const ci = &cpu_info[i];
 		struct cpu_softc * const cpu = &cpu_softc[i];

Index: src/sys/arch/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.20 src/sys/arch/powerpc/booke/booke_pmap.c:1.21
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.20	Fri Jan  9 11:45:11 2015
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Fri Jan 23 06:39:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.20 2015/01/09 11:45:11 nonaka Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.21 2015/01/23 06:39:41 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.20 2015/01/09 11:45:11 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.21 2015/01/23 06:39:41 nonaka Exp $");
 
 #include 
 #include 
@@ -160,10 +160,6 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	 */
 	pmap_kernel()->pm_segtab = stp;
 	curcpu()->ci_pmap_kern_segtab = stp;
-#ifdef MULTIPROCESSOR
-	pmap_kernel()->pm_active = kcpuset_running;
-	pmap_kernel()->pm_onproc = kcpuset_running;
-#endif
 
 	KASSERT(endkernel == trunc_page(endkernel));
 



CVS commit: src/sys/arch/powerpc/booke

2015-01-22 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 23 06:16:23 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Allow to share IPI interrupt.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.29 src/sys/arch/powerpc/booke/e500_intr.c:1.30
--- src/sys/arch/powerpc/booke/e500_intr.c:1.29	Mon Jan  5 07:40:05 2015
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Jan 23 06:16:23 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.29 2015/01/05 07:40:05 nonaka Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.30 2015/01/23 06:16:23 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.29 2015/01/05 07:40:05 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.30 2015/01/23 06:16:23 nonaka Exp $");
 
 #include 
 #include 
@@ -83,6 +83,7 @@ struct intr_source {
 	int8_t is_ipl;
 	uint8_t is_ist;
 	uint8_t is_irq;
+	uint8_t is_refcnt;
 	bus_size_t is_vpr;
 	bus_size_t is_dr;
 };
@@ -737,8 +738,16 @@ e500_intr_cpu_establish(struct cpu_info 
 	struct intr_source * const is = &e500_intr_sources[ii.irq_vector];
 	mutex_enter(&e500_intr_lock);
 	if (is->is_ipl != IPL_NONE) {
-		mutex_exit(&e500_intr_lock);
-		return NULL;
+		/* XXX IPI0 is shared by all CPU. */
+		if (is->is_ist != IST_IPI ||
+		is->is_irq != irq ||
+		is->is_ipl != ipl ||
+		is->is_ist != ist ||
+		is->is_func != handler ||
+		is->is_arg != arg) {
+			mutex_exit(&e500_intr_lock);
+			return NULL;
+		}
 	}
 
 	is->is_func = handler;
@@ -746,6 +755,7 @@ e500_intr_cpu_establish(struct cpu_info 
 	is->is_ipl = ipl;
 	is->is_ist = ist;
 	is->is_irq = irq;
+	is->is_refcnt++;
 	is->is_vpr = ii.irq_vpr;
 	is->is_dr = ii.irq_dr;
 
@@ -812,6 +822,12 @@ e500_intr_disestablish(void *vis)
 	KASSERT(is - e500_intr_sources == ii.irq_vector);
 
 	mutex_enter(&e500_intr_lock);
+
+	if (is->is_refcnt-- > 1) {
+		mutex_exit(&e500_intr_lock);
+		return;
+	}
+
 	/*
 	 * Mask the source using the mask (MSK) bit in the vector/priority reg.
 	 */



CVS commit: src/sys/arch/powerpc/booke

2015-01-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Jan 21 06:11:39 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: e500_timer.c

Log Message:
fix build failure with lockstat.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/e500_timer.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/powerpc/booke/e500_timer.c
diff -u src/sys/arch/powerpc/booke/e500_timer.c:1.5 src/sys/arch/powerpc/booke/e500_timer.c:1.6
--- src/sys/arch/powerpc/booke/e500_timer.c:1.5	Tue Jul 29 23:35:00 2014
+++ src/sys/arch/powerpc/booke/e500_timer.c	Wed Jan 21 06:11:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_timer.c,v 1.5 2014/07/29 23:35:00 joerg Exp $	*/
+/*	$NetBSD: e500_timer.c,v 1.6 2015/01/21 06:11:39 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_timer.c,v 1.5 2014/07/29 23:35:00 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_timer.c,v 1.6 2015/01/21 06:11:39 nonaka Exp $");
 
 #include 
 #include 
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: e500_timer.c
 #include 
 #include 
 
+uint32_t ticks_per_sec;
 static u_long ns_per_tick;
 
 static void init_ppcbooke_tc(void);
@@ -173,6 +174,7 @@ calc_delayconst(void)
 	struct cpu_info * const ci = curcpu();
 
 	ci->ci_data.cpu_cc_freq = board_info_get_number("timebase-frequency");
+	ticks_per_sec = (uint32_t)ci->ci_data.cpu_cc_freq;
 	ns_per_tick = 10 / (u_int)ci->ci_data.cpu_cc_freq;
 }
 



CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 16 07:48:16 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Fix various conditions with setting IMASK.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.22 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.23
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.22	Fri Jan 16 06:38:27 2015
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Jan 16 07:48:16 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.22 2015/01/16 06:38:27 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.23 2015/01/16 07:48:16 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.22 2015/01/16 06:38:27 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.23 2015/01/16 07:48:16 nonaka Exp $");
 
 #include 
 #include 
@@ -212,6 +212,7 @@ struct pq3etsec_softc {
 	void *sc_soft_ih;
 
 	kmutex_t *sc_lock;
+	kmutex_t *sc_hwlock;
 
 	struct evcnt sc_ev_tx_stall;
 	struct evcnt sc_ev_tx_intr;
@@ -617,14 +618,14 @@ pq3etsec_attach(device_t parent, device_
 #endif
 	}
 
-	char enaddr[ETHER_ADDR_LEN] = {
-	[0] = sc->sc_macstnaddr2 >> 16,
-	[1] = sc->sc_macstnaddr2 >> 24,
-	[2] = sc->sc_macstnaddr1 >>  0,
-	[3] = sc->sc_macstnaddr1 >>  8,
-	[4] = sc->sc_macstnaddr1 >> 16,
-	[5] = sc->sc_macstnaddr1 >> 24,
-	};
+	sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
+	sc->sc_hwlock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_VM);
+
+	callout_init(&sc->sc_mii_callout, CALLOUT_MPSAFE);
+	callout_setfunc(&sc->sc_mii_callout, pq3etsec_mii_tick, sc);
+
+	/* Disable interrupts */
+	etsec_write(sc, IMASK, 0);
 
 	error = pq3etsec_rxq_attach(sc, &sc->sc_rxq, 0);
 	if (error) {
@@ -704,11 +705,14 @@ pq3etsec_attach(device_t parent, device_
 	etsec_write(sc, ATTR, ATTR_DEFAULT);
 	etsec_write(sc, ATTRELI, ATTRELI_DEFAULT);
 
-	sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
-
-	callout_init(&sc->sc_mii_callout, CALLOUT_MPSAFE);
-	callout_setfunc(&sc->sc_mii_callout, pq3etsec_mii_tick, sc);
-
+	char enaddr[ETHER_ADDR_LEN] = {
+	[0] = sc->sc_macstnaddr2 >> 16,
+	[1] = sc->sc_macstnaddr2 >> 24,
+	[2] = sc->sc_macstnaddr1 >>  0,
+	[3] = sc->sc_macstnaddr1 >>  8,
+	[4] = sc->sc_macstnaddr1 >> 16,
+	[5] = sc->sc_macstnaddr1 >> 24,
+	};
 	aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n",
 	   ether_sprintf(enaddr));
 
@@ -2261,6 +2265,10 @@ pq3etsec_ifstart(struct ifnet *ifp)
 {
 	struct pq3etsec_softc * const sc = ifp->if_softc;
 
+	if (__predict_false((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)) {
+		return;
+	}
+
 	atomic_or_uint(&sc->sc_soft_flags, SOFT_TXINTR);
 	softint_schedule(sc->sc_soft_ih);
 }
@@ -2294,6 +2302,8 @@ pq3etsec_tx_intr(void *arg)
 {
 	struct pq3etsec_softc * const sc = arg;
 
+	mutex_enter(sc->sc_hwlock);
+
 	sc->sc_ev_tx_intr.ev_count++;
 
 	uint32_t ievent = etsec_read(sc, IEVENT);
@@ -2305,13 +2315,18 @@ pq3etsec_tx_intr(void *arg)
 	__func__, ievent, etsec_read(sc, IMASK));
 #endif
 
-	if (ievent == 0)
+	if (ievent == 0) {
+		mutex_exit(sc->sc_hwlock);
 		return 0;
+	}
 
 	sc->sc_imask &= ~(IEVENT_TXF|IEVENT_TXB);
 	atomic_or_uint(&sc->sc_soft_flags, SOFT_TXINTR);
 	etsec_write(sc, IMASK, sc->sc_imask);
 	softint_schedule(sc->sc_soft_ih);
+
+	mutex_exit(sc->sc_hwlock);
+
 	return 1;
 }
 
@@ -2320,13 +2335,17 @@ pq3etsec_rx_intr(void *arg)
 {
 	struct pq3etsec_softc * const sc = arg;
 
+	mutex_enter(sc->sc_hwlock);
+
 	sc->sc_ev_rx_intr.ev_count++;
 
 	uint32_t ievent = etsec_read(sc, IEVENT);
 	ievent &= IEVENT_RXF|IEVENT_RXB;
 	etsec_write(sc, IEVENT, ievent);	/* write 1 to clear */
-	if (ievent == 0)
+	if (ievent == 0) {
+		mutex_exit(sc->sc_hwlock);
 		return 0;
+	}
 
 #if 0
 	aprint_normal_dev(sc->sc_dev, "%s: ievent=%#x\n", __func__, ievent);
@@ -2336,6 +2355,9 @@ pq3etsec_rx_intr(void *arg)
 	atomic_or_uint(&sc->sc_soft_flags, SOFT_RXINTR);
 	etsec_write(sc, IMASK, sc->sc_imask);
 	softint_schedule(sc->sc_soft_ih);
+
+	mutex_exit(sc->sc_hwlock);
+
 	return 1;
 }
 
@@ -2344,6 +2366,8 @@ pq3etsec_error_intr(void *arg)
 {
 	struct pq3etsec_softc * const sc = arg;
 
+	mutex_enter(sc->sc_hwlock);
+
 	sc->sc_ev_error_intr.ev_count++;
 
 	for (int rv = 0, soft_flags = 0;; rv = 1) {
@@ -2355,6 +2379,7 @@ pq3etsec_error_intr(void *arg)
 atomic_or_uint(&sc->sc_soft_flags, soft_flags);
 softint_schedule(sc->sc_soft_ih);
 			}
+			mutex_exit(sc->sc_hwlock);
 			return rv;
 		}
 #if 0
@@ -2401,6 +2426,7 @@ pq3etsec_soft_intr(void *arg)
 {
 	struct pq3etsec_softc * const sc = arg;
 	struct ifnet * const ifp = &sc->sc_if;
+	uint32_t imask = 0;
 
 	mutex_en

CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 16 06:38:27 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Added missing tx bpf_mtap().


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.21 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.22
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.21	Fri Jan 16 05:50:15 2015
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Jan 16 06:38:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.21 2015/01/16 05:50:15 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.22 2015/01/16 06:38:27 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.21 2015/01/16 05:50:15 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.22 2015/01/16 06:38:27 nonaka Exp $");
 
 #include 
 #include 
@@ -2151,6 +2151,7 @@ pq3etsec_txq_consume(
 #endif
 			if (m->m_flags & M_HASFCB)
 m_adj(m, sizeof(struct txfcb));
+			bpf_mtap(ifp, m);
 			ifp->if_opackets++;
 			ifp->if_obytes += m->m_pkthdr.len;
 			if (m->m_flags & M_MCAST)



CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 16 05:50:15 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Replace if_attach with if_initialize and if_register.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.20 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.21
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.20	Fri Jan 16 05:36:47 2015
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Jan 16 05:50:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.20 2015/01/16 05:36:47 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.21 2015/01/16 05:50:15 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.20 2015/01/16 05:36:47 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.21 2015/01/16 05:50:15 nonaka Exp $");
 
 #include 
 #include 
@@ -761,8 +761,9 @@ pq3etsec_attach(device_t parent, device_
 	/*
 	 * Attach the interface.
 	 */
-	if_attach(ifp);
+	if_initialize(ifp);
 	ether_ifattach(ifp, enaddr);
+	if_register(ifp);
 
 	evcnt_attach_dynamic(&sc->sc_ev_rx_stall, EVCNT_TYPE_MISC,
 	NULL, xname, "rx stall");



CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan 16 05:36:47 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Use IFQ_* macro instead of IF_*.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.19 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.20
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.19	Wed Jan  7 01:11:47 2015
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Jan 16 05:36:47 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.19 2015/01/07 01:11:47 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.20 2015/01/16 05:36:47 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.19 2015/01/07 01:11:47 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.20 2015/01/16 05:36:47 nonaka Exp $");
 
 #include 
 #include 
@@ -1033,7 +1033,7 @@ pq3etsec_ifstop(struct ifnet *ifp, int d
 	pq3etsec_txq_consume(sc, &sc->sc_txq);
 	if (disable) {
 		pq3etsec_txq_purge(sc, &sc->sc_txq);
-		IF_PURGE(&ifp->if_snd);
+		IFQ_PURGE(&ifp->if_snd);
 	}
 }
 
@@ -2059,7 +2059,7 @@ pq3etsec_txq_enqueue(
 		struct mbuf *m = txq->txq_next;
 		if (m == NULL) {
 			int s = splnet();
-			IF_DEQUEUE(&sc->sc_if.if_snd, m);
+			IFQ_DEQUEUE(&sc->sc_if.if_snd, m);
 			splx(s);
 			if (m == NULL)
 return true;



CVS commit: src/sys/arch/powerpc/booke

2015-01-09 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jan  9 11:45:12 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
Use correct register for next cacheline address.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.19 src/sys/arch/powerpc/booke/booke_pmap.c:1.20
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.19	Mon Jan  5 07:40:05 2015
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Fri Jan  9 11:45:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.19 2015/01/05 07:40:05 nonaka Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.20 2015/01/09 11:45:11 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.19 2015/01/05 07:40:05 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.20 2015/01/09 11:45:11 nonaka Exp $");
 
 #include 
 #include 
@@ -364,8 +364,8 @@ pmap_copy_page(paddr_t src, paddr_t dst)
 	const vaddr_t end = src_va + PAGE_SIZE;
 
 	while (src_va < end) {
-		__asm(
-			"dcbt	%2,%1"	"\n\t"	/* touch next src cachline */
+		__asm __volatile(
+			"dcbt	%2,%0"	"\n\t"	/* touch next src cacheline */
 			"dcba	0,%1"	"\n\t" 	/* don't fetch dst cacheline */
 		:: "b"(src_va), "b"(dst_va), "b"(line_size));
 		for (u_int i = 0;



CVS commit: src/sys/arch/powerpc/booke/dev

2015-01-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Jan  7 01:11:47 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Remove non-printable character.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.18 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.19
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.18	Sat Dec 20 18:03:17 2014
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Wed Jan  7 01:11:47 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.18 2014/12/20 18:03:17 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.19 2015/01/07 01:11:47 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.18 2014/12/20 18:03:17 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.19 2015/01/07 01:11:47 nonaka Exp $");
 
 #include 
 #include 
@@ -684,7 +684,7 @@ pq3etsec_attach(device_t parent, device_
 	}
 
 	/*
-	 * If there was no MDIO 
+	 * If there was no MDIO
 	 */
 	if (mdio == CPUNODECF_MDIO_DEFAULT) {
 		aprint_normal("\n");



CVS commit: src/sys/arch/powerpc/booke

2015-01-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Jan  5 07:40:05 UTC 2015

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c e500_intr.c

Log Message:
Initialize lock objects.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/powerpc/booke/booke_pmap.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.18 src/sys/arch/powerpc/booke/booke_pmap.c:1.19
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.18	Tue Mar 18 18:20:41 2014
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Mon Jan  5 07:40:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.18 2014/03/18 18:20:41 riastradh Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.19 2015/01/05 07:40:05 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.18 2014/03/18 18:20:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.19 2015/01/05 07:40:05 nonaka Exp $");
 
 #include 
 #include 
@@ -167,6 +167,9 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 
 	KASSERT(endkernel == trunc_page(endkernel));
 
+	/* init the lock */
+	pmap_tlb_info_init(&pmap_tlb0_info);
+
 	/*
 	 * Compute the number of pages kmem_arena will have.
 	 */

Index: src/sys/arch/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.28 src/sys/arch/powerpc/booke/e500_intr.c:1.29
--- src/sys/arch/powerpc/booke/e500_intr.c:1.28	Sat Dec 27 16:19:33 2014
+++ src/sys/arch/powerpc/booke/e500_intr.c	Mon Jan  5 07:40:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.28 2014/12/27 16:19:33 nonaka Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.29 2015/01/05 07:40:05 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.28 2014/12/27 16:19:33 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.29 2015/01/05 07:40:05 nonaka Exp $");
 
 #include 
 #include 
@@ -1095,6 +1095,11 @@ e500_intr_init(void)
 	}
 
 	/*
+	 * Initialize interrupt handler lock
+	 */
+	mutex_init(&e500_intr_lock, MUTEX_DEFAULT, IPL_HIGH);
+
+	/*
 	 * We need to be in mixed mode.
 	 */
 	openpic_write(cpu, OPENPIC_GCR, GCR_M);



CVS commit: src/sys/arch/powerpc/booke

2014-12-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Dec 28 14:13:56 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
include "opt_ppcparam.h" for VERBOSE_INITPPC.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.14 src/sys/arch/powerpc/booke/e500_tlb.c:1.15
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.14	Fri Dec 26 11:13:05 2014
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Sun Dec 28 14:13:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.14 2014/12/26 11:13:05 nonaka Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.15 2014/12/28 14:13:56 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,11 +34,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_ppcparam.h"
+
 #define	__PMAP_PRIVATE
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.14 2014/12/26 11:13:05 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.15 2014/12/28 14:13:56 nonaka Exp $");
 
 #include 
 
@@ -841,6 +843,7 @@ e500_tlbmemmap(paddr_t memstart, psize_t
 
 	return nextslot;
 }
+
 static const struct tlb_md_ops e500_tlb_ops = {
 	.md_tlb_get_asid = e500_tlb_get_asid,
 	.md_tlb_set_asid = e500_tlb_set_asid,



CVS commit: src/sys/arch/powerpc/booke

2014-12-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 26 11:13:05 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.13 src/sys/arch/powerpc/booke/e500_tlb.c:1.14
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.13	Mon Dec  9 09:35:16 2013
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Fri Dec 26 11:13:05 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.13 2013/12/09 09:35:16 wiz Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.14 2014/12/26 11:13:05 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.13 2013/12/09 09:35:16 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.14 2014/12/26 11:13:05 nonaka Exp $");
 
 #include 
 
@@ -361,7 +361,7 @@ e500_tlb_invalidate_all(void)
 	__asm volatile("tlbivax\t0, %0" :: "b"(4));	/* INV_ALL */
 	__asm volatile("tlbsync\n\tisync\n\tsync");
 #else
-	mtspr(SPR_MMUCSR0, MMUCSR0_TLB0_FL);
+	mtspr(SPR_MMUCSR0, MMUCSR0_TLB0_FI);
 	while (mfspr(SPR_MMUCSR0) != 0)
 		;
 #endif



CVS commit: src/sys/arch/powerpc/booke

2014-12-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Dec 20 18:03:17 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c pq3gpio.c
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
Revert previous accidental commit.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/booke/dev/pq3etsec.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/dev/pq3gpio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.17 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.18
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.17	Sat Dec 20 17:55:08 2014
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sat Dec 20 18:03:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.17 2014/12/20 17:55:08 nonaka Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.18 2014/12/20 18:03:17 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.17 2014/12/20 17:55:08 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.18 2014/12/20 18:03:17 nonaka Exp $");
 
 #include 
 #include 
@@ -330,11 +330,9 @@ pq3mdio_match(device_t parent, cfdata_t 
 	const uint16_t svr = (mfspr(SPR_SVR) & ~0x8) >> 16;
 	const bool p1025_p = (svr == (SVR_P1025v1 >> 16)
 	|| svr == (SVR_P1016v1 >> 16));
-	const bool p1023_p = (svr == (SVR_P1023v1 >> 16)
-	|| svr == (SVR_P1017v1 >> 16));
 
 	if (device_is_a(parent, "cpunode")) {
-		if ((!p1025_p && !p1023_p)
+		if (!p1025_p
 		|| !e500_cpunode_submatch(parent, cf, cf->cf_name, aux))
 			return 0;
 
@@ -342,7 +340,7 @@ pq3mdio_match(device_t parent, cfdata_t 
 	}
 
 	if (device_is_a(parent, "tsec")) {
-		if ((p1025_p || p1023_p)
+		if (p1025_p
 		|| !e500_cpunode_submatch(parent, cf, cf->cf_name, aux))
 			return 0;
 

Index: src/sys/arch/powerpc/booke/dev/pq3gpio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.9 src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.10
--- src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.9	Sat Dec 20 17:55:08 2014
+++ src/sys/arch/powerpc/booke/dev/pq3gpio.c	Sat Dec 20 18:03:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3gpio.c,v 1.9 2014/12/20 17:55:08 nonaka Exp $	*/
+/*	$NetBSD: pq3gpio.c,v 1.10 2014/12/20 18:03:17 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.9 2014/12/20 17:55:08 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.10 2014/12/20 18:03:17 nonaka Exp $");
 
 #include 
 #include 
@@ -161,7 +161,7 @@ pq3gpio_pin_ctl(void *v, int num, int ct
 }
 #endif
 
-#if defined(MPC8536) || defined(P2020) || defined(P1023)
+#if defined(MPC8536) || defined(P2020)
 /*
  * MPC8536 / P20x0 have controllable input/output pins
  */
@@ -379,43 +379,6 @@ pq3gpio_mpc8548_attach(device_t self, bu
 }
 #endif /* MPC8548 */
 
-#ifdef P1023
-static void
-pq3gpio_p1023_attach(device_t self, bus_space_tag_t bst,
-	bus_space_handle_t bsh, u_int svr)
-{
-	static const uint32_t gpio2pmuxcr_map[][2] = {
-		{ __BIT(8), PMUXCR_SDHC_CD },
-		{ __BIT(9), PMUXCR_SDHC_WP },
-		/*
-		 * These are really two bits but the low bit MBZ so we ignore
-		 * it.
-		 */
-		{ __BIT(10), PMUXCR_TSEC3_TS },
-		{ __BIT(11), PMUXCR_TSEC3_TS },
-	};
-	
-	uint32_t pinmask = 0x;	/* assume all bits are valid */
-	size_t pincnt = 16;
-	const uint32_t pmuxcr = cpu_read_4(GLOBAL_BASE + PMUXCR);
-	for (size_t i = 0; i < __arraycount(gpio2pmuxcr_map); i++) {
-		if (pmuxcr & gpio2pmuxcr_map[i][1]) {
-			pinmask &= ~gpio2pmuxcr_map[i][0];
-			pincnt--;
-		}
-	}
-
-	/*
-	 * Create GPIO pin groups
-	 */
-	aprint_normal_dev(self, "%zu input/output/opendrain pins\n",
-	pincnt);
-	pq3gpio_group_create(self, bst, bsh, GPDAT, pinmask,
-	GPIO_PIN_INPUT|GPIO_PIN_OUTPUT|GPIO_PIN_OPENDRAIN,
-	pq3gpio_pin_ctl);
-}
-#endif /* P1023 */
-
 #ifdef P1025
 static void
 pq3gpio_p1025_attach(device_t self, bus_space_tag_t bst,
@@ -524,10 +487,6 @@ static const struct pq3gpio_svr_info {
 	{ SVR_MPC8536v1 >> 16, pq3gpio_mpc8536_attach,
 	GPIO_BASE, GPIO_SIZE },
 #endif
-#ifdef P1023
-	{ SVR_P1023v1 >> 16, pq3gpio_p1023_attach,
-	GPIO_BASE, GPIO_SIZE },
-#endif
 #ifdef P1025
 	{ SVR_P1025v1 >> 16, pq3gpio_p1025_attach,
 	GLOBAL_BASE, GLOBAL_SIZE },

Index: src/sys/arch/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.18 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.19
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.18	Sat Dec 20 17:55:08 2014
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Sat Dec 20 18:03:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.18 2014/12/20 17:55:08 nonaka Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.19 2014/12/20 18:03:17 no

CVS commit: src/sys/arch/powerpc/booke

2014-12-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Dec 20 17:55:08 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c
src/sys/arch/powerpc/booke/dev: pq3etsec.c pq3gpio.c
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
Revert previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/powerpc/booke/e500_intr.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/booke/dev/pq3etsec.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/booke/dev/pq3gpio.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.26 src/sys/arch/powerpc/booke/e500_intr.c:1.27
--- src/sys/arch/powerpc/booke/e500_intr.c:1.26	Fri Dec 19 04:00:35 2014
+++ src/sys/arch/powerpc/booke/e500_intr.c	Sat Dec 20 17:55:07 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.26 2014/12/19 04:00:35 nonaka Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.27 2014/12/20 17:55:07 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.26 2014/12/19 04:00:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.27 2014/12/20 17:55:07 nonaka Exp $");
 
 #include 
 #include 
@@ -1205,7 +1205,7 @@ e500_intr_cpu_send_ipi(cpuid_t target, u
 			atomic_or_32(&dst_ci->ci_pending_ipis, ipimsg);
 	}
 
-	openpic_write(cpu, OPENPIC_IPIDR(target), dstmask);
+	openpic_write(cpu, OPENPIC_IPIDR(0), dstmask);
 }
 
 typedef void (*ipifunc_t)(void);
@@ -1260,8 +1260,8 @@ e500_intr_cpu_hatch(struct cpu_info *ci)
 	/*
 	 * Establish the IPI interrupts for this CPU.
 	 */
-	if (e500_intr_cpu_establish(ci, ci->ci_cpuid, IPL_VM, IST_IPI,
-	e500_ipi_intr, NULL) == NULL)
+	if (e500_intr_cpu_establish(ci, 0, IPL_VM, IST_IPI, e500_ipi_intr,
+	NULL) == NULL)
 		panic("%s: failed to establish ipi interrupt!", __func__);
 
 	/*

Index: src/sys/arch/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.16 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.17
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.16	Sun Jul 22 23:46:10 2012
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Sat Dec 20 17:55:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.16 2012/07/22 23:46:10 matt Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.17 2014/12/20 17:55:08 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.16 2012/07/22 23:46:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.17 2014/12/20 17:55:08 nonaka Exp $");
 
 #include 
 #include 
@@ -330,9 +330,11 @@ pq3mdio_match(device_t parent, cfdata_t 
 	const uint16_t svr = (mfspr(SPR_SVR) & ~0x8) >> 16;
 	const bool p1025_p = (svr == (SVR_P1025v1 >> 16)
 	|| svr == (SVR_P1016v1 >> 16));
+	const bool p1023_p = (svr == (SVR_P1023v1 >> 16)
+	|| svr == (SVR_P1017v1 >> 16));
 
 	if (device_is_a(parent, "cpunode")) {
-		if (!p1025_p
+		if ((!p1025_p && !p1023_p)
 		|| !e500_cpunode_submatch(parent, cf, cf->cf_name, aux))
 			return 0;
 
@@ -340,7 +342,7 @@ pq3mdio_match(device_t parent, cfdata_t 
 	}
 
 	if (device_is_a(parent, "tsec")) {
-		if (p1025_p
+		if ((p1025_p || p1023_p)
 		|| !e500_cpunode_submatch(parent, cf, cf->cf_name, aux))
 			return 0;
 

Index: src/sys/arch/powerpc/booke/dev/pq3gpio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.8 src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.9
--- src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.8	Sun Jul 15 08:44:56 2012
+++ src/sys/arch/powerpc/booke/dev/pq3gpio.c	Sat Dec 20 17:55:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3gpio.c,v 1.8 2012/07/15 08:44:56 matt Exp $	*/
+/*	$NetBSD: pq3gpio.c,v 1.9 2014/12/20 17:55:08 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.8 2012/07/15 08:44:56 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.9 2014/12/20 17:55:08 nonaka Exp $");
 
 #include 
 #include 
@@ -161,7 +161,7 @@ pq3gpio_pin_ctl(void *v, int num, int ct
 }
 #endif
 
-#if defined(MPC8536) || defined(P2020)
+#if defined(MPC8536) || defined(P2020) || defined(P1023)
 /*
  * MPC8536 / P20x0 have controllable input/output pins
  */
@@ -379,6 +379,43 @@ pq3gpio_mpc8548_attach(device_t self, bu
 }
 #endif /* MPC8548 */
 
+#ifdef P1023
+static void
+pq3gpio_p1023_attach(device_t self, bus_space_tag_t bst,
+	bus_space_handle_t bsh, u_int svr)
+{
+	static const uint32_t gpio2pmuxcr_map[][2] = {
+		{ __BIT(8), PMUXCR_SDHC_CD },
+		{ __BIT(9), PMUXCR_SDHC_WP },
+		/*
+		 * These are really two bits but the low bit MBZ so we ignore
+		 * it.
+		 */
+		{ __B

CVS commit: src/sys/arch/powerpc/booke

2014-12-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 19 04:00:35 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Pass ci->ci_cpuid as irq of IST_IPI.
Avoid "panic: e500_intr_cpu_hatch: failed to establish ipi interrupt!" on cpu1.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.25 src/sys/arch/powerpc/booke/e500_intr.c:1.26
--- src/sys/arch/powerpc/booke/e500_intr.c:1.25	Fri Dec 19 03:51:38 2014
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Dec 19 04:00:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.25 2014/12/19 03:51:38 nonaka Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.26 2014/12/19 04:00:35 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.25 2014/12/19 03:51:38 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.26 2014/12/19 04:00:35 nonaka Exp $");
 
 #include 
 #include 
@@ -1205,7 +1205,7 @@ e500_intr_cpu_send_ipi(cpuid_t target, u
 			atomic_or_32(&dst_ci->ci_pending_ipis, ipimsg);
 	}
 
-	openpic_write(cpu, OPENPIC_IPIDR(0), dstmask);
+	openpic_write(cpu, OPENPIC_IPIDR(target), dstmask);
 }
 
 typedef void (*ipifunc_t)(void);
@@ -1260,8 +1260,8 @@ e500_intr_cpu_hatch(struct cpu_info *ci)
 	/*
 	 * Establish the IPI interrupts for this CPU.
 	 */
-	if (e500_intr_cpu_establish(ci, 0, IPL_VM, IST_IPI, e500_ipi_intr,
-	NULL) == NULL)
+	if (e500_intr_cpu_establish(ci, ci->ci_cpuid, IPL_VM, IST_IPI,
+	e500_ipi_intr, NULL) == NULL)
 		panic("%s: failed to establish ipi interrupt!", __func__);
 
 	/*



CVS commit: src/sys/arch/powerpc/booke

2014-12-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 19 03:51:38 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Added missing mutex_exit() at error path.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.24 src/sys/arch/powerpc/booke/e500_intr.c:1.25
--- src/sys/arch/powerpc/booke/e500_intr.c:1.24	Mon May 19 22:47:53 2014
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Dec 19 03:51:38 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.24 2014/05/19 22:47:53 rmind Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.25 2014/12/19 03:51:38 nonaka Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.24 2014/05/19 22:47:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.25 2014/12/19 03:51:38 nonaka Exp $");
 
 #include 
 #include 
@@ -713,8 +713,10 @@ e500_intr_cpu_establish(struct cpu_info 
 
 	struct intr_source * const is = &e500_intr_sources[ii.irq_vector];
 	mutex_enter(&e500_intr_lock);
-	if (is->is_ipl != IPL_NONE)
+	if (is->is_ipl != IPL_NONE) {
+		mutex_exit(&e500_intr_lock);
 		return NULL;
+	}
 
 	is->is_func = handler;
 	is->is_arg = arg;



CVS commit: src/sys/arch/powerpc/booke

2014-12-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec 19 03:46:23 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_mpsubr.S

Log Message:
Set correct stack pointer.
Please handle %r0 with care.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/e500_mpsubr.S

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/powerpc/booke/e500_mpsubr.S
diff -u src/sys/arch/powerpc/booke/e500_mpsubr.S:1.3 src/sys/arch/powerpc/booke/e500_mpsubr.S:1.4
--- src/sys/arch/powerpc/booke/e500_mpsubr.S:1.3	Tue Nov 27 19:24:46 2012
+++ src/sys/arch/powerpc/booke/e500_mpsubr.S	Fri Dec 19 03:46:23 2014
@@ -278,8 +278,8 @@ ENTRY_NOPROFILE(e500_spinup_trampoline)
 	/*
 	 * Now we can use our stack...
 	 */
-	lwz	%r0, CI_CURPCB(%r21)
-	lwz	%r1, PCB_SP(%r0)
+	lwz	%r3, CI_CURPCB(%r21)
+	lwz	%r1, PCB_SP(%r3)
 
 	li	%r0, 12
 	stw	%r0, HATCH_RUNNING(%r20)	/* progress */



CVS commit: src/sys/arch/powerpc/booke

2014-09-22 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Sep 22 21:35:15 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
Change insn mask to properly match instructions (bctr/blr)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.20 src/sys/arch/powerpc/booke/booke_machdep.c:1.21
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.20	Mon Mar 24 19:29:59 2014
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Mon Sep 22 21:35:15 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.20 2014/03/24 19:29:59 christos Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.21 2014/09/22 21:35:15 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.20 2014/03/24 19:29:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.21 2014/09/22 21:35:15 matt Exp $");
 
 #include "opt_modular.h"
 
@@ -566,10 +566,10 @@ booke_sstep(struct trapframe *tf)
 			const int16_t off = insn & ~3;
 			iac2 = ((insn & 2) ? 0 : tf->tf_srr0) + off;
 			dbcr0 |= DBCR0_IAC2;
-		} else if ((insn & 0xfc00ffde) == 0x4c000420) {
+		} else if ((insn & 0xfc00fffe) == 0x4c000420) {
 			iac2 = tf->tf_ctr;
 			dbcr0 |= DBCR0_IAC2;
-		} else if ((insn & 0xfc00ffde) == 0x4c20) {
+		} else if ((insn & 0xfc00fffe) == 0x4c20) {
 			iac2 = tf->tf_lr;
 			dbcr0 |= DBCR0_IAC2;
 		}



CVS commit: src/sys/arch/powerpc/booke

2014-09-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Sep 18 23:37:51 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: trap_subr.S

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/booke/trap_subr.S

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/powerpc/booke/trap_subr.S
diff -u src/sys/arch/powerpc/booke/trap_subr.S:1.10 src/sys/arch/powerpc/booke/trap_subr.S:1.11
--- src/sys/arch/powerpc/booke/trap_subr.S:1.10	Thu Jul 31 01:04:00 2014
+++ src/sys/arch/powerpc/booke/trap_subr.S	Thu Sep 18 23:37:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.10 2014/07/31 01:04:00 matt Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.11 2014/09/18 23:37:51 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,14 +34,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-RCSID("$NetBSD: trap_subr.S,v 1.10 2014/07/31 01:04:00 matt Exp $")
+RCSID("$NetBSD: trap_subr.S,v 1.11 2014/09/18 23:37:51 joerg Exp $")
 
 	.globl	_C_LABEL(sctrapexit), _C_LABEL(trapexit), _C_LABEL(intrcall)
 
 	/*
 	 * We have a problem with critical (MSR[CE] or machine check (MSR[ME])
 	 * or debug (MSR[DE]) interrupts/exception in that they could happen
-	 * inbewtween the mtsprg1 %r2 and mfsprg1 %r2.  If that happens, %r2
+	 * inbetween the mtsprg1 %r2 and mfsprg1 %r2.  If that happens, %r2
 	 * will be lost.  Even if we moved to a different sprg, subsequent
 	 * expceptions would use SPRG1 and its value would be lost.  The only
 	 * way to be safe for CE/ME/DE faults to save and restore SPRG1.



CVS commit: src/sys/arch/powerpc/booke

2014-08-10 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Aug 10 18:08:34 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: spe_subr.S

Log Message:
Skip .machine when building with clang.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/spe_subr.S

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/powerpc/booke/spe_subr.S
diff -u src/sys/arch/powerpc/booke/spe_subr.S:1.3 src/sys/arch/powerpc/booke/spe_subr.S:1.4
--- src/sys/arch/powerpc/booke/spe_subr.S:1.3	Sun May 20 06:17:28 2012
+++ src/sys/arch/powerpc/booke/spe_subr.S	Sun Aug 10 18:08:33 2014
@@ -30,10 +30,12 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: spe_subr.S,v 1.3 2012/05/20 06:17:28 matt Exp $")
+RCSID("$NetBSD: spe_subr.S,v 1.4 2014/08/10 18:08:33 joerg Exp $")
 
 	.text
+#ifndef __clang__
 	.machine	e500x2
+#endif
 /*
  * Lintstub: void vec_load_from_vreg(const struct vreg *);
  */



CVS commit: src/sys/arch/powerpc/booke

2014-07-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul 31 12:11:37 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Fix macro spelling.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.25 src/sys/arch/powerpc/booke/trap.c:1.26
--- src/sys/arch/powerpc/booke/trap.c:1.25	Thu Jul 31 01:01:55 2014
+++ src/sys/arch/powerpc/booke/trap.c	Thu Jul 31 12:11:37 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.25 2014/07/31 01:01:55 matt Exp $	*/
+/*	$NetBSD: trap.c,v 1.26 2014/07/31 12:11:37 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.25 2014/07/31 01:01:55 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.26 2014/07/31 12:11:37 joerg Exp $");
 
 #include 
 #include 
@@ -430,7 +430,7 @@ emulate_opcode(struct trapframe *tf, ksi
 	if (OPC_MFSPR_P(opcode, SPR_PIR)) {
 		__asm ("mfspr %0, %1"
 		:	"=r"(tf->tf_fixreg[OPC_MFSPR_REG(opcode)])
-		:	"n"(SPL_PIR));
+		:	"n"(SPR_PIR));
 		return true;
 	}
 



CVS commit: src/sys/arch/powerpc/booke

2014-07-30 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 31 01:04:00 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: trap_subr.S

Log Message:
Use symbolic constant for SPR.  Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/trap_subr.S

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/powerpc/booke/trap_subr.S
diff -u src/sys/arch/powerpc/booke/trap_subr.S:1.9 src/sys/arch/powerpc/booke/trap_subr.S:1.10
--- src/sys/arch/powerpc/booke/trap_subr.S:1.9	Wed Jul 30 23:56:01 2014
+++ src/sys/arch/powerpc/booke/trap_subr.S	Thu Jul 31 01:04:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.9 2014/07/30 23:56:01 joerg Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.10 2014/07/31 01:04:00 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-RCSID("$NetBSD: trap_subr.S,v 1.9 2014/07/30 23:56:01 joerg Exp $")
+RCSID("$NetBSD: trap_subr.S,v 1.10 2014/07/31 01:04:00 matt Exp $")
 
 	.globl	_C_LABEL(sctrapexit), _C_LABEL(trapexit), _C_LABEL(intrcall)
 
@@ -858,7 +858,7 @@ _C_LABEL(exception_init):
 	ori	%r5,%r6,_C_LABEL(perfmon_vector)@l
 	mtspr	SPR_IVOR35, %r5
 
-	mfspr	%r5, 286	/* get Process ID register */
+	mfspr	%r5, SPR_PIR	/* get Processor ID register */
 	cmplwi	%r5,0
 	bnelr			/* return if non-0 (non-primary) */
 



CVS commit: src/sys/arch/powerpc/booke

2014-07-30 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 31 01:01:55 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Don't use numeric constants for SPR.  Use the symbolic name (SPR_PIR).
Add DBSR_BRT to KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.24 src/sys/arch/powerpc/booke/trap.c:1.25
--- src/sys/arch/powerpc/booke/trap.c:1.24	Wed Jul 30 23:56:01 2014
+++ src/sys/arch/powerpc/booke/trap.c	Thu Jul 31 01:01:55 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.24 2014/07/30 23:56:01 joerg Exp $	*/
+/*	$NetBSD: trap.c,v 1.25 2014/07/31 01:01:55 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.24 2014/07/30 23:56:01 joerg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.25 2014/07/31 01:01:55 matt Exp $");
 
 #include 
 #include 
@@ -428,7 +428,9 @@ emulate_opcode(struct trapframe *tf, ksi
 	}
 
 	if (OPC_MFSPR_P(opcode, SPR_PIR)) {
-		__asm ("mfspr %0, 286" : "=r"(tf->tf_fixreg[OPC_MFSPR_REG(opcode)]));
+		__asm ("mfspr %0, %1"
+		:	"=r"(tf->tf_fixreg[OPC_MFSPR_REG(opcode)])
+		:	"n"(SPL_PIR));
 		return true;
 	}
 
@@ -525,7 +527,7 @@ debug_exception(struct trapframe *tf, ks
 	 * Ack the interrupt.
 	 */
 	mtspr(SPR_DBSR, tf->tf_esr);
-	KASSERT(tf->tf_esr & (DBSR_IAC1|DBSR_IAC2));
+	KASSERT(tf->tf_esr & (DBSR_IAC1|DBSR_IAC2|DBSR_BRT));
 	KASSERT((tf->tf_srr1 & PSL_SE) == 0);
 
 	/*



CVS commit: src/sys/arch/powerpc/booke

2014-07-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jul 30 23:56:01 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: trap.c trap_subr.S

Log Message:
Replace mfpir with mfspr r, 286. The Power ISA and GAS disagree on the
semantics of this instruction, so prefer the well defined replacement.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/booke/trap.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/booke/trap_subr.S

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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.23 src/sys/arch/powerpc/booke/trap.c:1.24
--- src/sys/arch/powerpc/booke/trap.c:1.23	Fri Aug 23 06:19:46 2013
+++ src/sys/arch/powerpc/booke/trap.c	Wed Jul 30 23:56:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.23 2013/08/23 06:19:46 matt Exp $	*/
+/*	$NetBSD: trap.c,v 1.24 2014/07/30 23:56:01 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.23 2013/08/23 06:19:46 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.24 2014/07/30 23:56:01 joerg Exp $");
 
 #include 
 #include 
@@ -428,7 +428,7 @@ emulate_opcode(struct trapframe *tf, ksi
 	}
 
 	if (OPC_MFSPR_P(opcode, SPR_PIR)) {
-		__asm ("mfpir %0" : "=r"(tf->tf_fixreg[OPC_MFSPR_REG(opcode)]));
+		__asm ("mfspr %0, 286" : "=r"(tf->tf_fixreg[OPC_MFSPR_REG(opcode)]));
 		return true;
 	}
 

Index: src/sys/arch/powerpc/booke/trap_subr.S
diff -u src/sys/arch/powerpc/booke/trap_subr.S:1.8 src/sys/arch/powerpc/booke/trap_subr.S:1.9
--- src/sys/arch/powerpc/booke/trap_subr.S:1.8	Wed Aug  1 16:19:43 2012
+++ src/sys/arch/powerpc/booke/trap_subr.S	Wed Jul 30 23:56:01 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.8 2012/08/01 16:19:43 matt Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.9 2014/07/30 23:56:01 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-RCSID("$NetBSD: trap_subr.S,v 1.8 2012/08/01 16:19:43 matt Exp $")
+RCSID("$NetBSD: trap_subr.S,v 1.9 2014/07/30 23:56:01 joerg Exp $")
 
 	.globl	_C_LABEL(sctrapexit), _C_LABEL(trapexit), _C_LABEL(intrcall)
 
@@ -858,7 +858,7 @@ _C_LABEL(exception_init):
 	ori	%r5,%r6,_C_LABEL(perfmon_vector)@l
 	mtspr	SPR_IVOR35, %r5
 
-	mfpir	%r5		/* get Process ID register */
+	mfspr	%r5, 286	/* get Process ID register */
 	cmplwi	%r5,0
 	bnelr			/* return if non-0 (non-primary) */
 



CVS commit: src/sys/arch/powerpc/booke/pci

2014-07-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jul 30 10:50:54 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
pq3pci_config_addr_read is only used in a #if 0 block, so hide it under
the same condition.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.16 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.17
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.16	Sat Mar 29 19:28:29 2014
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Wed Jul 30 10:50:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.16 2014/03/29 19:28:29 christos Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.17 2014/07/30 10:50:54 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -44,7 +44,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.16 2014/03/29 19:28:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.17 2014/07/30 10:50:54 joerg Exp $");
 
 #include 
 #include 
@@ -998,6 +998,7 @@ pq3pci_make_tag(void *v, int bus, int de
 	return (bus << 16) | (dev << 11) | (func << 8);
 }
 
+#if 0
 static inline pcitag_t
 pq3pci_config_addr_read(pci_chipset_tag_t pc)
 {
@@ -1006,6 +1007,7 @@ pq3pci_config_addr_read(pci_chipset_tag_
 __asm volatile("mbar\n\tmsync");
 	return v;
 }
+#endif
 
 static inline void
 pq3pci_config_addr_write(pci_chipset_tag_t pc, pcitag_t v)



CVS commit: src/sys/arch/powerpc/booke

2014-07-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Jul 29 23:35:00 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: e500_timer.c

Log Message:
GC openpic_read.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/booke/e500_timer.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/powerpc/booke/e500_timer.c
diff -u src/sys/arch/powerpc/booke/e500_timer.c:1.4 src/sys/arch/powerpc/booke/e500_timer.c:1.5
--- src/sys/arch/powerpc/booke/e500_timer.c:1.4	Wed Jun 29 05:56:31 2011
+++ src/sys/arch/powerpc/booke/e500_timer.c	Tue Jul 29 23:35:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_timer.c,v 1.4 2011/06/29 05:56:31 matt Exp $	*/
+/*	$NetBSD: e500_timer.c,v 1.5 2014/07/29 23:35:00 joerg Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_timer.c,v 1.4 2011/06/29 05:56:31 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_timer.c,v 1.5 2014/07/29 23:35:00 joerg Exp $");
 
 #include 
 #include 
@@ -69,14 +69,6 @@ static struct timecounter ppcbooke_timec
 	NULL			/* tc_next */
 };
 
-static inline uint32_t 
-openpic_read(struct cpu_softc *cpu, bus_size_t offset)
-{
-
-	return bus_space_read_4(cpu->cpu_bst, cpu->cpu_bsh,
-	OPENPIC_BASE + offset);
-}
-
 static inline void 
 openpic_write(struct cpu_softc *cpu, bus_size_t offset, uint32_t val)
 {



CVS commit: src/sys/arch/powerpc/booke

2014-07-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul 24 23:29:02 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: copyout.c

Log Message:
#if 0 copyout_le32 and friends, they are currently unused.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/copyout.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/powerpc/booke/copyout.c
diff -u src/sys/arch/powerpc/booke/copyout.c:1.3 src/sys/arch/powerpc/booke/copyout.c:1.4
--- src/sys/arch/powerpc/booke/copyout.c:1.3	Mon Jun 20 05:17:24 2011
+++ src/sys/arch/powerpc/booke/copyout.c	Thu Jul 24 23:29:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyout.c,v 1.3 2011/06/20 05:17:24 matt Exp $	*/
+/*	$NetBSD: copyout.c,v 1.4 2014/07/24 23:29:02 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.3 2011/06/20 05:17:24 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyout.c,v 1.4 2014/07/24 23:29:02 joerg Exp $");
 
 #include 
 #include 
@@ -58,6 +58,7 @@ copyout_uint8(uint8_t *udaddr, uint8_t d
 	: [ds_msr] "r" (ds_msr), [data] "r" (data), [udaddr] "b" (udaddr));
 }
 
+#if 0
 static inline void
 copyout_uint16(uint8_t *udaddr, uint8_t data, register_t ds_msr)
 {
@@ -70,6 +71,7 @@ copyout_uint16(uint8_t *udaddr, uint8_t 
 	: [msr] "=&r" (msr)
 	: [ds_msr] "r" (ds_msr), [data] "r" (data), [udaddr] "b" (udaddr));
 }
+#endif
 
 static inline void
 copyout_uint32(uint32_t * const udaddr, uint32_t data, register_t ds_msr)
@@ -84,6 +86,7 @@ copyout_uint32(uint32_t * const udaddr, 
 	: [ds_msr] "r" (ds_msr), [data] "r" (data), [udaddr] "b" (udaddr));
 }
 
+#if 0
 static inline void
 copyout_le32(uint32_t * const udaddr, uint32_t data, register_t ds_msr)
 {
@@ -116,6 +119,7 @@ copyout_le32_with_mask(uint32_t * const 
 	: [ds_msr] "r" (ds_msr), [data] "r" (data),
 	  [mask] "r" (mask), [udaddr] "b" (udaddr));
 }
+#endif
 
 static inline void
 copyout_16uint8s(const uint8_t *ksaddr8, uint8_t *udaddr8, register_t ds_msr)



CVS commit: src/sys/arch/powerpc/booke

2014-07-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jul 24 23:27:25 UTC 2014

Modified Files:
src/sys/arch/powerpc/booke: copyin.c

Log Message:
#if 0 unused copyin_halfword.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/copyin.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/powerpc/booke/copyin.c
diff -u src/sys/arch/powerpc/booke/copyin.c:1.5 src/sys/arch/powerpc/booke/copyin.c:1.6
--- src/sys/arch/powerpc/booke/copyin.c:1.5	Fri Mar 16 07:23:38 2012
+++ src/sys/arch/powerpc/booke/copyin.c	Thu Jul 24 23:27:25 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyin.c,v 1.5 2012/03/16 07:23:38 matt Exp $	*/
+/*	$NetBSD: copyin.c,v 1.6 2014/07/24 23:27:25 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.5 2012/03/16 07:23:38 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.6 2014/07/24 23:27:25 joerg Exp $");
 
 #include 
 #include 
@@ -60,6 +60,7 @@ copyin_byte(const uint8_t * const usaddr
 	return data;
 }
 
+#if 0
 static inline uint16_t
 copyin_halfword(const uint16_t * const usaddr16, register_t ds_msr)
 {
@@ -74,6 +75,7 @@ copyin_halfword(const uint16_t * const u
 	: [ds_msr] "r" (ds_msr), [usaddr16] "b" (usaddr16));
 	return data;
 }
+#endif
 
 static inline uint32_t
 copyin_word(const uint32_t * const usaddr32, register_t ds_msr)



CVS commit: src/sys/arch/powerpc/booke

2012-10-28 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Oct 29 05:25:20 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Change a KASSERT to a KASSERTMSG.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.21 src/sys/arch/powerpc/booke/e500_intr.c:1.22
--- src/sys/arch/powerpc/booke/e500_intr.c:1.21	Wed Aug  1 21:30:22 2012
+++ src/sys/arch/powerpc/booke/e500_intr.c	Mon Oct 29 05:25:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.21 2012/08/01 21:30:22 matt Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.22 2012/10/29 05:25:19 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.21 2012/08/01 21:30:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.22 2012/10/29 05:25:19 matt Exp $");
 
 #include 
 #include 
@@ -913,7 +913,9 @@ e500_extintr(struct trapframe *tf)
 			 * Timer interrupts get their argument overriden with
 			 * the pointer to the trapframe.
 			 */
-			KASSERT(is->is_ipl == ipl);
+			KASSERTMSG(is->is_ipl == ipl,
+			"iack %#x: is %p: irq %d ipl %d != iack ipl %d",
+			iack, is, irq, is->is_ipl, ipl);
 			void *arg = (is->is_ist == IST_TIMER ? tf : is->is_arg);
 			if (is->is_ipl <= old_ipl)
 panic("%s(%p): %s (%u): is->is_ipl (%u) <= old_ipl (%u)\n",



CVS commit: src/sys/arch/powerpc/booke

2012-10-28 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Oct 29 05:23:45 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
Make bus_dmamap_sync a noop for BookE.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.16 src/sys/arch/powerpc/booke/booke_machdep.c:1.17
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.16	Wed Aug  1 21:30:21 2012
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Mon Oct 29 05:23:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.16 2012/08/01 21:30:21 matt Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.17 2012/10/29 05:23:44 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.16 2012/08/01 21:30:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.17 2012/10/29 05:23:44 matt Exp $");
 
 #include "opt_modular.h"
 
@@ -85,7 +85,11 @@ struct powerpc_bus_dma_tag booke_bus_dma
 	._dmamap_load_uio = _bus_dmamap_load_uio,
 	._dmamap_load_raw = _bus_dmamap_load_raw,
 	._dmamap_unload = _bus_dmamap_unload,
-	._dmamap_sync = _bus_dmamap_sync,
+	/*
+	 * The caches on BookE are coherent so we don't need to do any special
+	 * cache synchronization.
+	 */
+	//._dmamap_sync = _bus_dmamap_sync,
 	._dmamem_alloc = _bus_dmamem_alloc,
 	._dmamem_free = _bus_dmamem_free,
 	._dmamem_map = _bus_dmamem_map,



CVS commit: src/sys/arch/powerpc/booke

2012-09-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  7 18:05:11 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c

Log Message:
Fool gcc into thinking we aren't using r31.  We do use it but we don't
clobber it since it save and restore it from a temporary register.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/booke/booke_pmap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.15 src/sys/arch/powerpc/booke/booke_pmap.c:1.16
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.15	Mon Jul  9 17:45:22 2012
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Fri Sep  7 18:05:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.15 2012/07/09 17:45:22 matt Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.16 2012/09/07 18:05:11 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.15 2012/07/09 17:45:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.16 2012/09/07 18:05:11 matt Exp $");
 
 #include 
 #include 
@@ -364,12 +364,16 @@ pmap_copy_page(paddr_t src, paddr_t dst)
 		for (u_int i = 0;
 		 i < line_size;
 		 src_va += 32, dst_va += 32, i += 32) {
-			__asm(
-"lmw	24,0(%0)" "\n\t"
-"stmw	24,0(%1)"
-			:: "b"(src_va), "b"(dst_va)
+			register_t tmp;
+			__asm __volatile(
+"mr	%[tmp],31"	"\n\t"
+"lmw	24,0(%[src])"	"\n\t"
+"stmw	24,0(%[dst])"	"\n\t"
+"mr	31,%[tmp]"	"\n\t"
+			: [tmp] "=&r"(tmp)
+			: [src] "b"(src_va), [dst] "b"(dst_va)
 			: "r24", "r25", "r26", "r27",
-			  "r28", "r29", "r30", "r31");
+			  "r28", "r29", "r30", "memory");
 		}
 	}
 	pmap_md_unmap_poolpage(src_va, NBPG);



CVS commit: src/sys/arch/powerpc/booke/pci

2012-08-14 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Tue Aug 14 13:02:19 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
Make this build again by adding a couple of right-parens.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.14 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.15
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.14	Mon Aug 13 00:52:45 2012
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Tue Aug 14 13:02:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.14 2012/08/13 00:52:45 matt Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.15 2012/08/14 13:02:19 he Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -44,7 +44,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.14 2012/08/13 00:52:45 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.15 2012/08/14 13:02:19 he Exp $");
 
 #include 
 #include 
@@ -882,7 +882,7 @@ pq3pci_cpunode_attach(device_t parent, d
 		bus_space_write_4(sc->sc_bst, sc->sc_bsh, PEXOWBAR1, owin1.powbar);
 		bus_space_write_4(sc->sc_bst, sc->sc_bsh, PEXOWAR1, owin1.powar);
 		pq3pci_owin_record(sc, 1, &owin1);
-		if (!pq3pci_owin_init(sc, &sc->sc_pci_mem_bst, false) {
+		if (!pq3pci_owin_init(sc, &sc->sc_pci_mem_bst, false)) {
 			return;
 		}
 
@@ -907,7 +907,7 @@ pq3pci_cpunode_attach(device_t parent, d
 		bus_space_write_4(sc->sc_bst, sc->sc_bsh, PEXOWBAR2, owin2.powbar);
 		bus_space_write_4(sc->sc_bst, sc->sc_bsh, PEXOWAR2, owin2.powar);
 		pq3pci_owin_record(sc, 2, &owin1);
-		if (!pq3pci_owin_init(sc, &sc->sc_pci_io_bst, true) {
+		if (!pq3pci_owin_init(sc, &sc->sc_pci_io_bst, true)) {
 			return;
 		}
 



CVS commit: src/sys/arch/powerpc/booke/pci

2012-08-12 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Aug 13 00:52:46 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/pci: pq3pci.c

Log Message:
Deal with PCIe/PCI hoses with more than one window so the bus_space
encompasses all of it and reserves those portions not assigned so
no one can allocate from them.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/booke/pci/pq3pci.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/powerpc/booke/pci/pq3pci.c
diff -u src/sys/arch/powerpc/booke/pci/pq3pci.c:1.13 src/sys/arch/powerpc/booke/pci/pq3pci.c:1.14
--- src/sys/arch/powerpc/booke/pci/pq3pci.c:1.13	Wed Jul 18 19:38:26 2012
+++ src/sys/arch/powerpc/booke/pci/pq3pci.c	Mon Aug 13 00:52:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3pci.c,v 1.13 2012/07/18 19:38:26 matt Exp $	*/
+/*	$NetBSD: pq3pci.c,v 1.14 2012/08/13 00:52:45 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -44,7 +44,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.13 2012/07/18 19:38:26 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3pci.c,v 1.14 2012/08/13 00:52:45 matt Exp $");
 
 #include 
 #include 
@@ -193,6 +193,10 @@ static const struct e500_truthtab pq3pci
 
 struct pq3pci_bst {
 	struct powerpc_bus_space bs_tag;
+	uint8_t bs_numwin;
+	bus_addr_t bs_base[3];
+	bus_addr_t bs_offset[3];
+	bus_addr_t bs_limit[3];
 	char bs_name[16];
 	char bs_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)] __aligned(8);
 };
@@ -381,8 +385,8 @@ struct pq3pci_owin {
 	uint32_t powar;
 };
 
-static bool
-pq3pci_owin_setup(struct pq3pci_softc *sc, u_int winnum,
+static void
+pq3pci_owin_record(struct pq3pci_softc *sc, u_int winnum,
 	const struct pq3pci_owin *owin)
 {
 	const bool io_win = (owin->powar & PEXOWAR_RTT) == PEXOWAR_RTT_IO;
@@ -391,12 +395,25 @@ pq3pci_owin_setup(struct pq3pci_softc *s
 	| ((uint64_t)owin->potear << (32+12));
 	const uint64_t local_base = (uint64_t)owin->powbar << 12;
 	const u_int win_size_log2 = PEXIWAR_IWS_GET(owin->powar) + 1;
+	u_int slot;
 
 	bs->bs_tag.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN
 	| (io_win ? _BUS_SPACE_IO_TYPE : _BUS_SPACE_MEM_TYPE);
-	bs->bs_tag.pbs_base = pci_base;
-	bs->bs_tag.pbs_offset = local_base - pci_base;
-	bs->bs_tag.pbs_limit = bs->bs_tag.pbs_base + (1ULL << win_size_log2);
+
+	for (slot = 0; slot < bs->bs_numwin; slot++) {
+		if (pci_base < bs->bs_base[slot]) {
+			for (size_t j = slot; j < bs->bs_numwin; j++) {
+bs->bs_base[j+1] = bs->bs_base[j];
+bs->bs_offset[j+1] = bs->bs_offset[j];
+bs->bs_limit[j+1] = bs->bs_limit[j];
+			}
+			break;
+		}
+	}
+	bs->bs_base[slot] = pci_base;
+	bs->bs_offset[slot] = local_base - pci_base;
+	bs->bs_limit[slot] = pci_base + (1ULL << win_size_log2);
+	bs->bs_numwin++;
 
 #if 0
 	const char units[] = " KMGTP";
@@ -409,9 +426,20 @@ pq3pci_owin_setup(struct pq3pci_softc *s
 	(owin->powar & PEXOWAR_RTT) == PEXOWAR_RTT_IO ? "I/O" : "memory",
 	local_base, pci_base);
 #endif
+}
+
+static bool
+pq3pci_owin_init(struct pq3pci_softc *sc, struct pq3pci_bst *bs, bool io_win)
+{
+	if (bs->bs_numwin == 0)
+		return true;
+
+	bs->bs_tag.pbs_base = bs->bs_base[0];
+	bs->bs_tag.pbs_offset = bs->bs_offset[0];
+	bs->bs_tag.pbs_limit = bs->bs_limit[bs->bs_numwin - 1];
 
-	snprintf(bs->bs_name, sizeof(bs->bs_name), "%s-%s@%u",
-	device_xname(sc->sc_dev), io_win ? "io" : "mem", winnum);
+	snprintf(bs->bs_name, sizeof(bs->bs_name), "%s-%s",
+	device_xname(sc->sc_dev), io_win ? "io" : "mem");
 
 #if 0
 	printf("%s: %s: base=%#x offset=%#x limit=%#x\n", __func__, bs->bs_name,
@@ -425,6 +453,19 @@ pq3pci_owin_setup(struct pq3pci_softc *s
 		bs->bs_name, error);
 		return false;
 	}
+	for (size_t slot = 1; slot < bs->bs_numwin; slot++) {
+		if (bs->bs_limit[slot - 1] < bs->bs_base[slot]) {
+			error = extent_alloc_region(bs->bs_tag.pbs_extent,
+			bs->bs_limit[slot - 1],
+			bs->bs_base[slot] - bs->bs_limit[slot - 1],
+			EX_WAITOK);
+			if (error) {
+aprint_error(": failed to hole in %s bus space: %d\n",
+bs->bs_name, error);
+return false;
+			}
+		}
+	}
 	aprint_debug_dev(sc->sc_dev, "bus space %s created\n", bs->bs_name);
 	sc->sc_pba_flags |=
 	io_win ? PCI_FLAGS_IO_OKAY : PCI_FLAGS_MEM_OKAY;
@@ -732,10 +773,13 @@ pq3pci_cpunode_attach(device_t parent, d
 #endif
 		if (owin.powar & PEXOWAR_EN) {
 			valid_owins++;
-			if (!pq3pci_owin_setup(sc, i, &owin))
-return;
+			pq3pci_owin_record(sc, i, &owin);
 		}
 	}
+	if (!pq3pci_owin_init(sc, &sc->sc_pci_io_bst, true)
+	|| !pq3pci_owin_init(sc, &sc->sc_pci_mem_bst, false)) {
+		return;
+	}
 #ifndef PCI_NETBSD_CONFIGURE
 	if (valid_owins == 0) {
 		aprint_normal(": %s controller%s\n", buf,
@@ -837,10 +881,8 @@ pq3pci_cpunode_attach(device_t parent, d
 		bus_space_write_4(sc->sc_bst, sc->sc_bsh, PEXOTEAR1, owin1.potear);
 		bus_space_write_4(sc->sc_bst, sc->sc_

CVS commit: src/sys/arch/powerpc/booke

2012-08-02 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Aug  2 14:07:47 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Also supprese printing fatal traps if the process is being debugged.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.21 src/sys/arch/powerpc/booke/trap.c:1.22
--- src/sys/arch/powerpc/booke/trap.c:1.21	Thu Aug  2 13:50:15 2012
+++ src/sys/arch/powerpc/booke/trap.c	Thu Aug  2 14:07:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.21 2012/08/02 13:50:15 matt Exp $	*/
+/*	$NetBSD: trap.c,v 1.22 2012/08/02 14:07:47 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.21 2012/08/02 13:50:15 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.22 2012/08/02 14:07:47 matt Exp $");
 
 #include 
 #include 
@@ -882,6 +882,7 @@ trap(enum ppc_booke_exceptions trap_code
 			 * uncaught.
 			 */
 			if (cpu_printfataltraps
+			&& (p->p_slflag & PSL_TRACED) == 0
 			&& !sigismember(&p->p_sigctx.ps_sigcatch,
 ksi.ksi_signo)) {
 printf("%s: pid %d.%d (%s):"



CVS commit: src/sys/arch/powerpc/booke/dev

2012-07-26 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul 26 18:38:11 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3sdhc.c

Log Message:
When using DMA, make sure to initialize SNOOPing.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/booke/dev/pq3sdhc.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/powerpc/booke/dev/pq3sdhc.c
diff -u src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.4 src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.5
--- src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.4	Thu Feb 23 21:07:35 2012
+++ src/sys/arch/powerpc/booke/dev/pq3sdhc.c	Thu Jul 26 18:38:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3sdhc.c,v 1.4 2012/02/23 21:07:35 matt Exp $	*/
+/*	$NetBSD: pq3sdhc.c,v 1.5 2012/07/26 18:38:10 matt Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,8 +28,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define	ESDHC_PRIVATE
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.4 2012/02/23 21:07:35 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.5 2012/07/26 18:38:10 matt Exp $");
 
 #include 
 #include 
@@ -85,7 +87,7 @@ pq3sdhc_attach(device_t parent, device_t
 	psc->sc_children |= cna->cna_childmask;
 	sc->sc.sc_dmat = cna->cna_dmat;
 	sc->sc.sc_dev = self;
-	sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
+	//sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
 	sc->sc.sc_flags |=
 	SDHC_FLAG_HAVE_DVS | SDHC_FLAG_32BIT_ACCESS | SDHC_FLAG_ENHANCED;
 	sc->sc.sc_host = sc->sc_hosts;
@@ -100,8 +102,18 @@ pq3sdhc_attach(device_t parent, device_t
 		return;
 	}
 
+	/*
+	 * If using DMA, enable SNOOPing.
+	 */
+	if (sc->sc.sc_flags & SDHC_FLAG_USE_DMA) {
+		uint32_t dcr = bus_space_read_4(sc->sc_bst, sc->sc_bsh, DCR);
+		dcr |= DCR_SNOOP | DCR_RD_SAFE | DCR_RD_PFE;
+		bus_space_write_4(sc->sc_bst, sc->sc_bsh, DCR, dcr);
+	}
+
 	aprint_naive(": SDHC controller\n");
-	aprint_normal(": SDHC controller\n");
+	aprint_normal(": SDHC controller%s\n",
+	   (sc->sc.sc_flags & SDHC_FLAG_USE_DMA) ? " (DMA enabled)" : "");
 
 	sc->sc_ih = intr_establish(cnl->cnl_intrs[0], IPL_VM, IST_ONCHIP,
 	sdhc_intr, &sc->sc);



CVS commit: src/sys/arch/powerpc/booke

2012-07-25 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 25 22:11:37 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
When dealing with kernel invalidations, make sure to use context-synchronizing
instructions.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.10 src/sys/arch/powerpc/booke/e500_tlb.c:1.11
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.10	Wed Jul 18 18:50:46 2012
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Wed Jul 25 22:11:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.10 2012/07/18 18:50:46 matt Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.11 2012/07/25 22:11:36 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.10 2012/07/18 18:50:46 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.11 2012/07/25 22:11:36 matt Exp $");
 
 #include 
 
@@ -212,8 +212,7 @@ hwtlb_write(const struct e500_hwtlb hwtl
 #endif
 	__asm volatile("tlbwe");
 	if (needs_sync) {
-		__asm volatile("tlbsync");
-		__asm volatile("isync");
+		__asm volatile("tlbsync\n\tisync\n\tsync");
 	}
 
 	mtspr(SPR_MAS0, saved_mas0);
@@ -359,6 +358,7 @@ e500_tlb_invalidate_all(void)
 	 */
 #if 1
 	__asm volatile("tlbivax\t0, %0" :: "b"(4));	/* INV_ALL */
+	__asm volatile("tlbsync\n\tisync\n\tsync");
 #else
 	mtspr(SPR_MMUCSR0, MMUCSR0_TLB0_FL);
 	while (mfspr(SPR_MMUCSR0) != 0)
@@ -411,7 +411,7 @@ e500_tlb_invalidate_globals(void)
 			__asm volatile("tlbwe");
 		}
 	}
-	__asm volatile("isync");
+	__asm volatile("isync\n\tsync");
 	wrtee(msr);
 }
 
@@ -449,7 +449,7 @@ e500_tlb_invalidate_asids(tlb_asid_t asi
 			}
 		}
 	}
-	__asm volatile("isync");
+	__asm volatile("isync\n\tsync");
 	wrtee(msr);
 }
 
@@ -497,9 +497,26 @@ e500_tlb_invalidate_addr(vaddr_t va, tlb
 	/*
 	 * Bits 60 & 61 have meaning
 	 */
+	if (asid == KERNEL_PID) {
+		/*
+		 * For data accesses, the context-synchronizing instruction
+		 * before tlbwe or tlbivax ensures that all memory accesses
+		 * due to preceding instructions have completed to a point
+		 * at which they have reported all exceptions they will cause.
+		 */
+		__asm volatile("isync");
+	}
 	__asm volatile("tlbivax\t0, %0" :: "b"(va));
 	__asm volatile("tlbsync");
-	__asm volatile("tlbsync");
+	__asm volatile("tlbsync");	/* Why? */
+	if (asid == KERNEL_PID) {
+		/*
+		 * The context-synchronizing instruction after tlbwe or tlbivax
+		 * ensures that subsequent accesses (data and instruction) use
+		 * the updated value in any TLB entries affected.
+		 */
+		__asm volatile("isync\n\tsync");
+	}
 }
 
 static bool
@@ -527,8 +544,8 @@ e500_tlb_update_addr(vaddr_t va, tlb_asi
 	mtspr(SPR_MAS2, hwtlb.hwtlb_mas2);
 	mtspr(SPR_MAS3, hwtlb.hwtlb_mas3);
 	__asm volatile("tlbwe");
-	if (asid == 0)
-		__asm volatile("isync");
+	if (asid == KERNEL_PID)
+		__asm volatile("isync\n\tsync");
 	wrtee(msr);
 #if 0
 	if (asid)



CVS commit: src/sys/arch/powerpc/booke/dev

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 19:01:50 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3cfi.c

Log Message:
Map NOR as PREFETCHABLE.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/booke/dev/pq3cfi.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/powerpc/booke/dev/pq3cfi.c
diff -u src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.4 src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.5
--- src/sys/arch/powerpc/booke/dev/pq3cfi.c:1.4	Sat Aug  6 05:48:01 2011
+++ src/sys/arch/powerpc/booke/dev/pq3cfi.c	Wed Jul 18 19:01:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3cfi.c,v 1.4 2011/08/06 05:48:01 cliff Exp $	*/
+/*	$NetBSD: pq3cfi.c,v 1.5 2012/07/18 19:01:50 matt Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 #include "locators.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.4 2011/08/06 05:48:01 cliff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.5 2012/07/18 19:01:50 matt Exp $");
 
 #include 
 #include 
@@ -148,7 +148,7 @@ pq3cfi_attach(device_t parent, device_t 
 	cfi_print(self, &sc->sc_cfi);
 
 	error = bus_space_map(sc->sc_cfi.cfi_bst, sc->sc_addr, sc->sc_size,
-		0, &sc->sc_cfi.cfi_bsh);
+		BUS_SPACE_MAP_PREFETCHABLE, &sc->sc_cfi.cfi_bsh);
 	if (error != 0) {
 		aprint_error_dev(self, "could not map error %d\n", error);
 		return;



CVS commit: src/sys/arch/powerpc/booke

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 18:55:27 UTC 2012

Removed Files:
src/sys/arch/powerpc/booke: copyinstr.c copyoutstr.c

Log Message:
These are not used so nuke 'em.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/sys/arch/powerpc/booke/copyinstr.c \
src/sys/arch/powerpc/booke/copyoutstr.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/powerpc/booke

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 18:51:59 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: booke_machdep.c

Log Message:
If allocating lots of VA space for an io device, try to 'reserve' the space
so that the TLB might be able to create a large TLB entry to map it all.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/booke/booke_machdep.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/powerpc/booke/booke_machdep.c
diff -u src/sys/arch/powerpc/booke/booke_machdep.c:1.14 src/sys/arch/powerpc/booke/booke_machdep.c:1.15
--- src/sys/arch/powerpc/booke/booke_machdep.c:1.14	Thu Jun 30 00:52:58 2011
+++ src/sys/arch/powerpc/booke/booke_machdep.c	Wed Jul 18 18:51:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_machdep.c,v 1.14 2011/06/30 00:52:58 matt Exp $	*/
+/*	$NetBSD: booke_machdep.c,v 1.15 2012/07/18 18:51:59 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 #define	_POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.14 2011/06/30 00:52:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_machdep.c,v 1.15 2012/07/18 18:51:59 matt Exp $");
 
 #include "opt_modular.h"
 
@@ -329,13 +329,45 @@ mapiodev(paddr_t pa, psize_t len, bool p
 		panic("mapiodev: no TLB entry reserved for %llx+%llx",
 		(long long)pa, (long long)len);
 
+	const paddr_t orig_pa = pa;
+	const psize_t orig_len = len;
+	vsize_t align = 0;
 	pa = trunc_page(pa);
 	len = round_page(off + len);
-	vaddr_t va = uvm_km_alloc(kernel_map, len, 0, UVM_KMF_VAONLY);
+	/*
+	 * If we are allocating a large amount (>= 1MB) try to get an
+	 * aligned VA region for it so try to do a large mapping for it.
+	 */
+	if ((len & (len - 1)) == 0 && len >= 0x10)
+		align = len;
+
+	vaddr_t va = uvm_km_alloc(kernel_map, len, align, UVM_KMF_VAONLY);
 
+	if (va == 0 && align > 0) {
+		/*
+		 * Large aligned request failed.  Let's just get anything.
+		 */
+		align = 0;
+		va = uvm_km_alloc(kernel_map, len, align, UVM_KMF_VAONLY);
+	}
 	if (va == 0)
 		return NULL;
 
+	if (align) {
+		/*
+		 * Now try to map that via one big TLB entry.
+		 */
+		pt_entry_t pte = pte_make_kenter_pa(pa, NULL,
+		VM_PROT_READ|VM_PROT_WRITE,
+		prefetchable ? 0 : PMAP_NOCACHE);
+		if (!tlb_ioreserve(va, len, pte)) {
+			void * const p0 = tlb_mapiodev(orig_pa, orig_len,
+			prefetchable);
+			KASSERT(p0 != NULL);
+			return p0;
+		}
+	}
+
 	for (va += len, pa += len; len > 0; len -= PAGE_SIZE) {
 		va -= PAGE_SIZE;
 		pa -= PAGE_SIZE;



CVS commit: src/sys/arch/powerpc/booke

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 18:50:46 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
Don't assume 1:1 PA:VA mapping


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.9 src/sys/arch/powerpc/booke/e500_tlb.c:1.10
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.9	Wed Jul 18 18:29:22 2012
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Wed Jul 18 18:50:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.9 2012/07/18 18:29:22 matt Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.10 2012/07/18 18:50:46 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.9 2012/07/18 18:29:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.10 2012/07/18 18:50:46 matt Exp $");
 
 #include 
 
@@ -722,7 +722,8 @@ e500_tlb_mapiodev(paddr_t pa, psize_t le
 	&& (prefetchable
 		|| (xtlb->e_tlb.tlb_pte & PTE_WIG) == (PTE_I|PTE_G))) {
 		xtlb->e_refcnt++;
-		return (void *) pa;
+		return (void *) (xtlb->e_tlb.tlb_va
+		+ pa - (xtlb->e_tlb.tlb_pte & PTE_RPN_MASK));
 	}
 	return NULL;
 }



CVS commit: src/sys/arch/powerpc/booke

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 18:29:22 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_tlb.c

Log Message:
Fix some SHIFTOUT to SHIFTIN
Add a lookup of tlb1 by pa.  fix comparisions of xtlb entries by using
masks.  (since xtlb can looked up by pa & va and va may not equal pa).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/e500_tlb.c
diff -u src/sys/arch/powerpc/booke/e500_tlb.c:1.8 src/sys/arch/powerpc/booke/e500_tlb.c:1.9
--- src/sys/arch/powerpc/booke/e500_tlb.c:1.8	Thu Mar 29 15:48:20 2012
+++ src/sys/arch/powerpc/booke/e500_tlb.c	Wed Jul 18 18:29:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_tlb.c,v 1.8 2012/03/29 15:48:20 matt Exp $	*/
+/*	$NetBSD: e500_tlb.c,v 1.9 2012/07/18 18:29:22 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.8 2012/03/29 15:48:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_tlb.c,v 1.9 2012/07/18 18:29:22 matt Exp $");
 
 #include 
 
@@ -318,7 +318,7 @@ e500_alloc_tlb1_entry(void)
 	const u_int slot = tlb1->tlb1_freelist[--tlb1->tlb1_numfree];
 	KASSERT((tlb1->tlb1_entries[slot].e_hwtlb.hwtlb_mas1 & MAS1_V) == 0);
 	tlb1->tlb1_entries[slot].e_hwtlb.hwtlb_mas0 = 
-	MAS0_TLBSEL_TLB1 | __SHIFTOUT(slot, MAS0_ESEL);
+	MAS0_TLBSEL_TLB1 | __SHIFTIN(slot, MAS0_ESEL);
 	return (int)slot;
 }
 
@@ -644,7 +644,7 @@ e500_tlb_walk(void *ctx, bool (*func)(vo
 }
 
 static struct e500_xtlb *
-e500_tlb_lookup_xtlb(vaddr_t va, u_int *slotp)
+e500_tlb_lookup_xtlb_pa(vaddr_t pa, u_int *slotp)
 {
 	struct e500_tlb1 * const tlb1 = &e500_tlb1;
 	struct e500_xtlb *xtlb = tlb1->tlb1_entries;
@@ -653,9 +653,31 @@ e500_tlb_lookup_xtlb(vaddr_t va, u_int *
 	 * See if we have a TLB entry for the pa.
 	 */
 	for (u_int i = 0; i < tlb1->tlb1_numentries; i++, xtlb++) {
+		psize_t mask = ~(xtlb->e_tlb.tlb_size - 1);
+		if ((xtlb->e_hwtlb.hwtlb_mas1 & MAS1_V)
+		&& ((pa ^ xtlb->e_tlb.tlb_pte) & mask) == 0) {
+			if (slotp != NULL)
+*slotp = i;
+			return xtlb;
+		}
+	}
+
+	return NULL;
+}
+
+static struct e500_xtlb *
+e500_tlb_lookup_xtlb(vaddr_t va, u_int *slotp)
+{
+	struct e500_tlb1 * const tlb1 = &e500_tlb1;
+	struct e500_xtlb *xtlb = tlb1->tlb1_entries;
+
+	/*
+	 * See if we have a TLB entry for the va.
+	 */
+	for (u_int i = 0; i < tlb1->tlb1_numentries; i++, xtlb++) {
+		vsize_t mask = ~(xtlb->e_tlb.tlb_size - 1);
 		if ((xtlb->e_hwtlb.hwtlb_mas1 & MAS1_V)
-		&& xtlb->e_tlb.tlb_va <= va
-		&& va < xtlb->e_tlb.tlb_va + xtlb->e_tlb.tlb_size) {
+		&& ((va ^ xtlb->e_tlb.tlb_va) & mask) == 0) {
 			if (slotp != NULL)
 *slotp = i;
 			return xtlb;
@@ -675,9 +697,10 @@ e500_tlb_lookup_xtlb2(vaddr_t va, vsize_
 	 * See if we have a TLB entry for the pa.
 	 */
 	for (u_int i = 0; i < tlb1->tlb1_numentries; i++, xtlb++) {
+		vsize_t mask = ~(xtlb->e_tlb.tlb_size - 1);
 		if ((xtlb->e_hwtlb.hwtlb_mas1 & MAS1_V)
-		&& xtlb->e_tlb.tlb_va < va + len
-		&& va < xtlb->e_tlb.tlb_va + xtlb->e_tlb.tlb_size) {
+		&& ((va ^ xtlb->e_tlb.tlb_va) & mask) == 0
+		&& (((va + len - 1) ^ va) & mask) == 0) {
 			return xtlb;
 		}
 	}
@@ -688,7 +711,7 @@ e500_tlb_lookup_xtlb2(vaddr_t va, vsize_
 static void *
 e500_tlb_mapiodev(paddr_t pa, psize_t len, bool prefetchable)
 {
-	struct e500_xtlb * const xtlb = e500_tlb_lookup_xtlb(pa, NULL);
+	struct e500_xtlb * const xtlb = e500_tlb_lookup_xtlb_pa(pa, NULL);
 
 	/*
 	 * See if we have a TLB entry for the pa.  If completely falls within
@@ -696,7 +719,6 @@ e500_tlb_mapiodev(paddr_t pa, psize_t le
 	 * is not cacheable.
 	 */
 	if (xtlb
-	&& pa + len <= xtlb->e_tlb.tlb_va + xtlb->e_tlb.tlb_size
 	&& (prefetchable
 		|| (xtlb->e_tlb.tlb_pte & PTE_WIG) == (PTE_I|PTE_G))) {
 		xtlb->e_refcnt++;
@@ -726,13 +748,12 @@ e500_tlb_ioreserve(vaddr_t va, vsize_t l
 	KASSERT(len >= PAGE_SIZE);
 	KASSERT((len & (len - 1)) == 0);
 	KASSERT((va & (len - 1)) == 0);
-	KASSERT((pte & (len - 1)) == 0);
+	KASSERT(((pte & PTE_RPN_MASK) & (len - 1)) == 0);
 
 	if ((xtlb = e500_tlb_lookup_xtlb2(va, len)) != NULL) {
-		if (va < xtlb->e_tlb.tlb_va
-		|| xtlb->e_tlb.tlb_va + xtlb->e_tlb.tlb_size < va + len
-		|| va - xtlb->e_tlb.tlb_va != pte - xtlb->e_tlb.tlb_pte)
-			return EBUSY;
+		psize_t mask = ~(xtlb->e_tlb.tlb_size - 1);
+		KASSERT(len <= xtlb->e_tlb.tlb_size);
+		KASSERT((pte & mask) == (xtlb->e_tlb.tlb_pte & mask));
 		xtlb->e_refcnt++;
 		return 0;
 	}
@@ -748,7 +769,7 @@ e500_tlb_ioreserve(vaddr_t va, vsize_t l
 	xtlb->e_tlb.tlb_asid = KERNEL_PID;
 
 	xtlb->e_hwtlb = tlb_to_hwtlb(xtlb->e_tlb);
-	xtlb->e_hwtlb.hwtlb_mas0 |= __SHIFTOUT(slot, MAS0_ESEL);
+	xtlb->e_hwtlb.hwtlb_mas0 |= __SHIFTIN(slot, MAS0_ESEL);
 	hwtlb_write(xtlb->e_hwtlb, true);

CVS commit: src/sys/arch/powerpc/booke

2012-07-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul 18 16:45:35 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Add two missing interrupt sources for P1025.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.19 src/sys/arch/powerpc/booke/e500_intr.c:1.20
--- src/sys/arch/powerpc/booke/e500_intr.c:1.19	Sun Jul 15 08:44:56 2012
+++ src/sys/arch/powerpc/booke/e500_intr.c	Wed Jul 18 16:45:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.19 2012/07/15 08:44:56 matt Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.20 2012/07/18 16:45:33 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.19 2012/07/15 08:44:56 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.20 2012/07/18 16:45:33 matt Exp $");
 
 #include 
 #include 
@@ -333,6 +333,8 @@ const struct e500_intr_name p1025_onchip
 	{ ISOURCE_ETSEC3_G1_TX, "etsec3-g1-tx" },
 	{ ISOURCE_ETSEC3_G1_RX, "etsec3-g1-rx" },
 	{ ISOURCE_ETSEC3_G1_ERR, "etsec3-g1-error" },
+	{ ISOURCE_QEB_MUECC, "qeb-low" },
+	{ ISOURCE_QEB_HIGH, "qeb-crit" },
 	{ ISOURCE_DMA2_CHAN1, "dma2-chan1" },
 	{ ISOURCE_DMA2_CHAN2, "dma2-chan2" },
 	{ ISOURCE_DMA2_CHAN3, "dma2-chan3" },



CVS commit: src/sys/arch/powerpc/booke

2012-07-09 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jul  9 11:40:19 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
If we paniced because a watchdog timed out, PSL_CE will be clear.  So don't
assert PSL_CE is set if panicstr is not NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.17 src/sys/arch/powerpc/booke/e500_intr.c:1.18
--- src/sys/arch/powerpc/booke/e500_intr.c:1.17	Fri Jun  8 23:35:23 2012
+++ src/sys/arch/powerpc/booke/e500_intr.c	Mon Jul  9 11:40:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.17 2012/06/08 23:35:23 matt Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.18 2012/07/09 11:40:19 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.17 2012/06/08 23:35:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.18 2012/07/09 11:40:19 matt Exp $");
 
 #include 
 #include 
@@ -491,7 +491,8 @@ e500_splx(int ipl)
 	struct cpu_info * const ci = curcpu();
 	const int old_ipl = ci->ci_cpl;
 
-	KASSERT(mfmsr() & PSL_CE);
+	/* if we paniced because of watchdog, PSL_CE will be clear.  */
+	KASSERT(panicstr != NULL || (mfmsr() & PSL_CE));
 
 	if (ipl == old_ipl)
 		return;
@@ -527,7 +528,8 @@ e500_splraise(int ipl)
 	struct cpu_info * const ci = curcpu();
 	const int old_ipl = ci->ci_cpl;
 
-	KASSERT(mfmsr() & PSL_CE);
+	/* if we paniced because of watchdog, PSL_CE will be clear.  */
+	KASSERT(panicstr != NULL || (mfmsr() & PSL_CE));
 
 	if (old_ipl < ipl) {
 		//const
@@ -814,7 +816,8 @@ e500_extintr(struct trapframe *tf)
 	struct cpu_softc * const cpu = ci->ci_softc;
 	const int old_ipl = ci->ci_cpl;
 
-	KASSERT(mfmsr() & PSL_CE);
+	/* if we paniced because of watchdog, PSL_CE will be clear.  */
+	KASSERT(panicstr != NULL || (mfmsr() & PSL_CE));
 
 #if 0
 //	printf("%s(%p): idepth=%d enter\n", __func__, tf, ci->ci_idepth);



CVS commit: src/sys/arch/powerpc/booke

2012-07-05 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Jul  5 17:25:36 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c trap.c

Log Message:
s/seg_tab/seg_ptr/


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/booke/booke_pmap.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.13 src/sys/arch/powerpc/booke/booke_pmap.c:1.14
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.13	Thu Mar 29 15:48:20 2012
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Thu Jul  5 17:25:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.13 2012/03/29 15:48:20 matt Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.14 2012/07/05 17:25:36 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.13 2012/03/29 15:48:20 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.14 2012/07/05 17:25:36 matt Exp $");
 
 #include 
 #include 
@@ -126,7 +126,7 @@ pmap_md_direct_mapped_vaddr_to_paddr(vad
 static pt_entry_t *
 kvtopte(const struct pmap_segtab *stp, vaddr_t va)
 {
-	pt_entry_t * const ptep = stp->seg_tab[va >> SEGSHIFT];
+	pt_entry_t * const ptep = stp->seg_ptr[va >> SEGSHIFT];
 	if (ptep == NULL)
 		return NULL;
 	return &ptep[(va & SEGOFSET) >> PAGE_SHIFT];
@@ -226,7 +226,7 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	 * an extra page for the segment table and allows the user/kernel
 	 * access to be common.
 	 */
-	pt_entry_t **ptp = &stp->seg_tab[VM_MIN_KERNEL_ADDRESS >> SEGSHIFT];
+	void **ptp = &stp->seg_ptr[VM_MIN_KERNEL_ADDRESS >> SEGSHIFT];
 	pt_entry_t *ptep = (void *)kv_segtabs;
 	memset(ptep, 0, NBPG * kv_nsegtabs);
 	for (size_t i = 0; i < kv_nsegtabs; i++, ptep += NPTEPG) {
@@ -244,7 +244,7 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	avail[0].size -= NBPG * dm_nsegtabs;
 	endkernel += NBPG * dm_nsegtabs;
 
-	ptp = stp->seg_tab;
+	ptp = stp->seg_ptr;
 	ptep = (void *)dm_segtabs;
 	memset(ptep, 0, NBPG * dm_nsegtabs);
 	for (size_t i = 0; i < dm_nsegtabs; i++, ptp++, ptep += NPTEPG) {

Index: src/sys/arch/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.15 src/sys/arch/powerpc/booke/trap.c:1.16
--- src/sys/arch/powerpc/booke/trap.c:1.15	Thu May 17 16:22:38 2012
+++ src/sys/arch/powerpc/booke/trap.c	Thu Jul  5 17:25:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.15 2012/05/17 16:22:38 matt Exp $	*/
+/*	$NetBSD: trap.c,v 1.16 2012/07/05 17:25:36 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.15 2012/05/17 16:22:38 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.16 2012/07/05 17:25:36 matt Exp $");
 
 #include 
 #include 
@@ -148,7 +148,7 @@ trap_pte_lookup(struct trapframe *tf, va
 	struct pmap_segtab * const stp = stps[(tf->tf_srr1 / psl_mask) & 1];
 	if (__predict_false(stp == NULL))
 		return NULL;
-	pt_entry_t *ptep = stp->seg_tab[va >> SEGSHIFT];
+	pt_entry_t * const ptep = stp->seg_ptr[va >> SEGSHIFT];
 	if (__predict_false(ptep == NULL))
 		return NULL;
 	return ptep + ((va & SEGOFSET) >> PAGE_SHIFT);



CVS commit: src/sys/arch/powerpc/booke

2012-06-08 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Jun  8 23:35:24 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: e500_intr.c

Log Message:
Compute softintr mask correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/booke/e500_intr.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/powerpc/booke/e500_intr.c
diff -u src/sys/arch/powerpc/booke/e500_intr.c:1.16 src/sys/arch/powerpc/booke/e500_intr.c:1.17
--- src/sys/arch/powerpc/booke/e500_intr.c:1.16	Tue Sep 27 01:02:35 2011
+++ src/sys/arch/powerpc/booke/e500_intr.c	Fri Jun  8 23:35:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: e500_intr.c,v 1.16 2011/09/27 01:02:35 jym Exp $	*/
+/*	$NetBSD: e500_intr.c,v 1.17 2012/06/08 23:35:23 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +39,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.16 2011/09/27 01:02:35 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: e500_intr.c,v 1.17 2012/06/08 23:35:23 matt Exp $");
 
 #include 
 #include 
@@ -506,7 +506,7 @@ e500_splx(int ipl)
 	// const
 	register_t msr = wrtee(0);
 #ifdef __HAVE_FAST_SOFTINTS
-	const u_int softints = (ci->ci_data.cpu_softints << ipl) & IPL_SOFTMASK;
+	const u_int softints = ci->ci_data.cpu_softints & (IPL_SOFTMASK << ipl);
 	if (__predict_false(softints != 0)) {
 		e500_splset(ci, IPL_HIGH);
 		powerpc_softint(ci, ipl,
@@ -940,7 +940,7 @@ e500_extintr(struct trapframe *tf)
 	/*
 	 * Before exiting, deal with any softints that need to be dealt with.
 	 */
-	const u_int softints = (ci->ci_data.cpu_softints << old_ipl) & IPL_SOFTMASK;
+	const u_int softints = ci->ci_data.cpu_softints & (IPL_SOFTMASK << old_ipl);
 	if (__predict_false(softints != 0)) {
 		KASSERT(old_ipl < IPL_VM);
 		e500_splset(ci, IPL_HIGH);	/* pop to high */



CVS commit: src/sys/arch/powerpc/booke

2012-05-19 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun May 20 06:17:28 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: spe_subr.S

Log Message:
Fix SPE loading typo as described in PR/45731


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/powerpc/booke/spe_subr.S

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/powerpc/booke/spe_subr.S
diff -u src/sys/arch/powerpc/booke/spe_subr.S:1.2 src/sys/arch/powerpc/booke/spe_subr.S:1.3
--- src/sys/arch/powerpc/booke/spe_subr.S:1.2	Tue Jan 18 01:02:52 2011
+++ src/sys/arch/powerpc/booke/spe_subr.S	Sun May 20 06:17:28 2012
@@ -30,7 +30,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: spe_subr.S,v 1.2 2011/01/18 01:02:52 matt Exp $")
+RCSID("$NetBSD: spe_subr.S,v 1.3 2012/05/20 06:17:28 matt Exp $")
 
 	.text
 	.machine	e500x2
@@ -90,11 +90,11 @@ ENTRY(vec_load_from_vreg)
 	evldw %r10,(10 << 2)(%r3)
 		evmergelo %r11,%r10,%r11
 	evldw %r8,(8 << 2)(%r3)
-		evmergelo %r19,%r8,%r19
+		evmergelo %r9,%r8,%r9
 	evldw %r6,(6 << 2)(%r3)
-		evmergelo %r17,%r6,%r17
+		evmergelo %r7,%r6,%r7
 	evldw %r4,(4 << 2)(%r3)
-		evmergelo %r15,%r4,%r15
+		evmergelo %r5,%r4,%r5
 
 	/*
 	 * R2 isn't a callee-saved, so load into r0 because we still need r3



CVS commit: src/sys/arch/powerpc/booke/dev

2012-05-18 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat May 19 00:11:46 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3gpio.c

Log Message:
Fix a few compile problems on non-P2020 platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/booke/dev/pq3gpio.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/powerpc/booke/dev/pq3gpio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.6 src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.7
--- src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.6	Thu May 17 16:24:09 2012
+++ src/sys/arch/powerpc/booke/dev/pq3gpio.c	Sat May 19 00:11:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3gpio.c,v 1.6 2012/05/17 16:24:09 matt Exp $	*/
+/*	$NetBSD: pq3gpio.c,v 1.7 2012/05/19 00:11:46 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.6 2012/05/17 16:24:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.7 2012/05/19 00:11:46 matt Exp $");
 
 #include 
 #include 
@@ -163,7 +163,7 @@ pq3gpio_group_create(device_t self, bus_
 #endif
 	gc->gc_tag.gp_pin_read = pq3gpio_pin_read;
 	gc->gc_tag.gp_pin_write = pq3gpio_pin_write;
-	gc->gc_tag.gp_pin_ctl = pq3gpio_pin_ctl;
+	gc->gc_tag.gp_pin_ctl = pin_ctl;
 
 	u_int data = bus_space_read_4(gc->gc_bst, gc->gc_bsh, reg);
 	u_int mask = __BIT(31);
@@ -227,7 +227,7 @@ pq3gpio_mpc8536_attach(device_t self, bu
 	 * Create GPIO pin groups
 	 */
 	aprint_normal_dev(self, "%zu input/output/opendrain pins\n",
-	pincnt, pincnt);
+	pincnt);
 	pq3gpio_group_create(self, bst, bsh, GPDAT, pinmask,
 	GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN,
 	pq3gpio_pin_ctl);



CVS commit: src/sys/arch/powerpc/booke/dev

2012-05-17 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May 17 16:24:09 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3gpio.c

Log Message:
The P2020 doesn't have GPIO in the same place as othe 85xx.  Deal with it.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/booke/dev/pq3gpio.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/powerpc/booke/dev/pq3gpio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.5 src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.6
--- src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.5	Thu Mar 29 14:47:09 2012
+++ src/sys/arch/powerpc/booke/dev/pq3gpio.c	Thu May 17 16:24:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3gpio.c,v 1.5 2012/03/29 14:47:09 matt Exp $	*/
+/*	$NetBSD: pq3gpio.c,v 1.6 2012/05/17 16:24:09 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.5 2012/03/29 14:47:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.6 2012/05/17 16:24:09 matt Exp $");
 
 #include 
 #include 
@@ -64,10 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 
 #include 
 
 struct pq3gpio_group {
-#if 0
-	SIMPLEQ_ENTRY(pq3gpio_group) gc_link;
-	struct pq3gpio_softc *gc_softc;
-#endif
 	struct gpio_chipset_tag gc_tag;
 	gpio_pin_t gc_pins[32];
 	bus_space_tag_t gc_bst;
@@ -106,27 +102,54 @@ pq3gpio_pin_write(void *v, int num, int 
 	}
 }
 
+#if defined(MPC8548) || defined(MPC8555) || defined(MPC8544)
+static void
+pq3gpio_null_pin_ctl(void *v, int num, int ctl)
+{
+}
+#endif
+
+#if defined(MPC8536) || defined(P2020)
+/*
+ * MPC8536 / P20x0 have controllable input/output pins
+ */
 static void
 pq3gpio_pin_ctl(void *v, int num, int ctl)
 {
 	struct pq3gpio_group * const gc = v;
 	const u_int mask = 1 << (gc->gc_pins[num].pin_num ^ 31);
-uint32_t old, new; 
   
-old = bus_space_read_4(gc->gc_bst, gc->gc_bsh, GPDIR);
-new = old;
-switch (ctl & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
-case GPIO_PIN_OUTPUT:new |= mask; break;
-case GPIO_PIN_INPUT:   new &= ~mask; break;
-default:return;
-}
-if (old != new)
-		bus_space_write_4(gc->gc_bst, gc->gc_bsh, GPDIR, new);
+	uint32_t old_dir = bus_space_read_4(gc->gc_bst, gc->gc_bsh, GPDIR);
+	uint32_t new_dir = old_dir;
+	switch (ctl & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
+	case GPIO_PIN_OUTPUT:	new_dir |= mask; break;
+	case GPIO_PIN_INPUT:	new_dir &= ~mask; break;
+	default:		return;
+	}
+	if (old_dir != new_dir)
+		bus_space_write_4(gc->gc_bst, gc->gc_bsh, GPDIR, new_dir);
+
+	/*
+	 * Now handle opendrain
+	 */
+	uint32_t old_odr = bus_space_read_4(gc->gc_bst, gc->gc_bsh, GPODR);
+	uint32_t new_odr = old_odr;
+
+	if (ctl & GPIO_PIN_OPENDRAIN) {
+		new_odr |= mask;
+	} else {
+		new_odr &= ~mask;
+	}
+
+	if (old_odr != new_odr)
+		bus_space_write_4(gc->gc_bst, gc->gc_bsh, GPODR, new_odr);
 }
+#endif
 
 static void
 pq3gpio_group_create(device_t self, bus_space_tag_t bst, bus_space_handle_t bsh,
-	bus_size_t reg, uint32_t pinmask, int pincaps)
+	bus_size_t reg, uint32_t pinmask, int pincaps,
+	void (*pin_ctl)(void *, int, int))
 {
 	struct pq3gpio_group * const gc = kmem_zalloc(sizeof(*gc), KM_SLEEP);
 
@@ -188,10 +211,10 @@ pq3gpio_mpc8536_attach(device_t self, bu
 		[15] = ilog2(PMUXCR_DMA1),
 	};
 	
-	uint32_t pinmask = ~0;	/* assume all bits are valid */
+	uint32_t pinmask = 0x;	/* assume all bits are valid */
 	uint32_t gpiomask = __BIT(31);
-	size_t pincnt = 32;
-	const uint32_t pmuxcr = bus_space_read_4(bst, bsh, PMUXCR);
+	size_t pincnt = 16;
+	const uint32_t pmuxcr = cpu_read_4(GLOBAL_BASE + PMUXCR);
 	for (size_t i = 0; i < __arraycount(gpio2pmuxcr_map);
 	 i++, gpiomask >>= 1) {
 		if (pmuxcr & __BIT(gpio2pmuxcr_map[i])) {
@@ -203,10 +226,11 @@ pq3gpio_mpc8536_attach(device_t self, bu
 	/*
 	 * Create GPIO pin groups
 	 */
-	aprint_normal_dev(self, "%zu input pins, %zu output pins\n",
+	aprint_normal_dev(self, "%zu input/output/opendrain pins\n",
 	pincnt, pincnt);
-	pq3gpio_group_create(self, bst, bsh, GPINDR, pinmask, GPIO_PIN_INPUT);
-	pq3gpio_group_create(self, bst, bsh, GPOUTDR, pinmask, GPIO_PIN_OUTPUT);
+	pq3gpio_group_create(self, bst, bsh, GPDAT, pinmask,
+	GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN,
+	pq3gpio_pin_ctl);
 }
 #endif /* MPC8536 */
 
@@ -227,8 +251,10 @@ pq3gpio_mpc8544_attach(device_t self, bu
 	/*
 	 * Create GPIO pin groups
 	 */
-	pq3gpio_group_create(self, bst, bsh, GPINDR, 0xff00, GPIO_PIN_INPUT);
-	pq3gpio_group_create(self, bst, bsh, GPOUTDR, 0xff00, GPIO_PIN_OUTPUT);
+	pq3gpio_group_create(self, bst, bsh, GPINDR, 0xff00,
+	GPIO_PIN_INPUT, pq3gpio_null_pin_ctl);
+	pq3gpio_group_create(self, bst, bsh, GPOUTDR, 0xff00,
+	GPIO_PIN_OUTPUT, pq3gpio_null_pin_ctl);
 }
 #endif /* MPC8544 */
 
@@ -293,9 +31

CVS commit: src/sys/arch/powerpc/booke

2012-05-17 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu May 17 16:22:38 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: trap.c

Log Message:
Allow user addresses >= 0x8000


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/booke/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.14 src/sys/arch/powerpc/booke/trap.c:1.15
--- src/sys/arch/powerpc/booke/trap.c:1.14	Sun Feb 19 21:06:22 2012
+++ src/sys/arch/powerpc/booke/trap.c	Thu May 17 16:22:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.14 2012/02/19 21:06:22 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.15 2012/05/17 16:22:38 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.14 2012/02/19 21:06:22 rmind Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.15 2012/05/17 16:22:38 matt Exp $");
 
 #include 
 #include 
@@ -699,7 +699,8 @@ trap(enum ppc_booke_exceptions trap_code
 	}
 #endif
 
-	if (usertrap && (tf->tf_fixreg[1] & 0x8000)) {
+	if ((VM_MAX_ADDRESS & 0x8000) == 0
+	&& usertrap && (tf->tf_fixreg[1] & 0x8000)) {
 		printf("%s(entry): pid %d.%d (%s): %s invalid sp %#lx (sprg1=%#lx)\n",
 		__func__, p->p_pid, l->l_lid, p->p_comm,
 		trap_names[trap_code], tf->tf_fixreg[1], mfspr(SPR_SPRG1));
@@ -778,7 +779,8 @@ trap(enum ppc_booke_exceptions trap_code
 	case T_AST:
 		KASSERT(usertrap);
 		cpu_ast(l, ci);
-		if (tf->tf_fixreg[1] & 0x8000) {
+		if ((VM_MAX_ADDRESS & 0x8000) == 0
+		   && (tf->tf_fixreg[1] & 0x8000)) {
 			printf("%s(ast-exit): pid %d.%d (%s): invalid sp %#lx\n",
 			__func__, p->p_pid, l->l_lid, p->p_comm,
 			tf->tf_fixreg[1]);



CVS commit: src/sys/arch/powerpc/booke/dev

2012-04-20 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Apr 20 13:51:48 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Don't use the current value of maccfg2.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.11 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.12
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.11	Thu Apr 19 21:32:01 2012
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Fri Apr 20 13:51:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.12 2012/04/20 13:51:48 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.12 2012/04/20 13:51:48 matt Exp $");
 
 #include 
 #include 
@@ -501,6 +501,8 @@ pq3etsec_attach(device_t parent, device_
 	sc->sc_macstnaddr2 = etsec_read(sc, MACSTNADDR2);
 	sc->sc_macstnaddr1 = etsec_read(sc, MACSTNADDR1);
 	sc->sc_rctrl = RCTRL_DEFAULT;
+	sc->sc_ecntrl = etsec_read(sc, ECNTRL);
+	sc->sc_maccfg1 = etsec_read(sc, MACCFG1);
 	sc->sc_maccfg2 = MACCFG2_DEFAULT;
 
 	if (sc->sc_macstnaddr1 == 0 && sc->sc_macstnaddr2 == 0) {
@@ -592,9 +594,6 @@ pq3etsec_attach(device_t parent, device_
 
 	etsec_write(sc, ATTR, ATTR_DEFAULT);
 	etsec_write(sc, ATTRELI, ATTRELI_DEFAULT);
-	sc->sc_maccfg1 = etsec_read(sc, MACCFG1);
-	sc->sc_maccfg2 = etsec_read(sc, MACCFG2);
-	sc->sc_ecntrl = etsec_read(sc, ECNTRL);
 
 	sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
 



CVS commit: src/sys/arch/powerpc/booke/dev

2012-04-19 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 19 21:32:01 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Read maccfg1/maccfg2/ecntrl so we can preserve bits we don't change (like
GMII mode).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.11
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10	Tue Feb 21 02:08:55 2012
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Thu Apr 19 21:32:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.11 2012/04/19 21:32:01 matt Exp $");
 
 #include 
 #include 
@@ -592,6 +592,9 @@ pq3etsec_attach(device_t parent, device_
 
 	etsec_write(sc, ATTR, ATTR_DEFAULT);
 	etsec_write(sc, ATTRELI, ATTRELI_DEFAULT);
+	sc->sc_maccfg1 = etsec_read(sc, MACCFG1);
+	sc->sc_maccfg2 = etsec_read(sc, MACCFG2);
+	sc->sc_ecntrl = etsec_read(sc, ECNTRL);
 
 	sc->sc_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
 



CVS commit: src/sys/arch/powerpc/booke

2012-03-29 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Mar 29 15:48:20 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: booke_pmap.c e500_tlb.c

Log Message:
Add support PMAP_MINIMALTLB option.  This changes the default use of TLB1
entries to map all of physical memory to using two TLB1 entries, one for
mapping text and one for data.  The rest of memory is mapped using the
page table which is updated as needed.  This is used to trap memory
corruption issues.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/booke/booke_pmap.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/booke/e500_tlb.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/powerpc/booke/booke_pmap.c
diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.12 src/sys/arch/powerpc/booke/booke_pmap.c:1.13
--- src/sys/arch/powerpc/booke/booke_pmap.c:1.12	Thu Feb  2 18:59:44 2012
+++ src/sys/arch/powerpc/booke/booke_pmap.c	Thu Mar 29 15:48:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: booke_pmap.c,v 1.12 2012/02/02 18:59:44 para Exp $	*/
+/*	$NetBSD: booke_pmap.c,v 1.13 2012/03/29 15:48:20 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.12 2012/02/02 18:59:44 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.13 2012/03/29 15:48:20 matt Exp $");
 
 #include 
 #include 
@@ -59,6 +59,8 @@ __KERNEL_RCSID(0, "$NetBSD: booke_pmap.c
 
 CTASSERT(sizeof(struct pmap_segtab) == NBPG);
 
+struct pmap_segtab pmap_kernel_segtab;
+
 void
 pmap_procwr(struct proc *p, vaddr_t va, size_t len)
 {
@@ -120,30 +122,46 @@ pmap_md_direct_mapped_vaddr_to_paddr(vad
 	return (paddr_t) va;
 }
 
+#ifdef PMAP_MINIMALTLB
+static pt_entry_t *
+kvtopte(const struct pmap_segtab *stp, vaddr_t va)
+{
+	pt_entry_t * const ptep = stp->seg_tab[va >> SEGSHIFT];
+	if (ptep == NULL)
+		return NULL;
+	return &ptep[(va & SEGOFSET) >> PAGE_SHIFT];
+}
+
+vaddr_t
+pmap_kvptefill(vaddr_t sva, vaddr_t eva, pt_entry_t pt_entry)
+{
+	const struct pmap_segtab * const stp = pmap_kernel()->pm_segtab;
+	KASSERT(sva == trunc_page(sva));
+	pt_entry_t *ptep = kvtopte(stp, sva);
+	for (; sva < eva; sva += NBPG) {
+		*ptep++ = pt_entry ? (sva | pt_entry) : 0;
+	}
+	return sva;
+}
+#endif
+
 /*
  *	Bootstrap the system enough to run with virtual memory.
  *	firstaddr is the first unused kseg0 address (not page aligned).
  */
-void
+vaddr_t
 pmap_bootstrap(vaddr_t startkernel, vaddr_t endkernel,
-	const phys_ram_seg_t *avail, size_t cnt)
+	phys_ram_seg_t *avail, size_t cnt)
 {
-	for (size_t i = 0; i < cnt; i++) {
-		printf(" uvm_page_physload(%#lx,%#lx,%#lx,%#lx,%d)",
-		atop(avail[i].start),
-		atop(avail[i].start + avail[i].size) - 1,
-		atop(avail[i].start),
-		atop(avail[i].start + avail[i].size) - 1,
-		VM_FREELIST_DEFAULT);
-		uvm_page_physload(
-		atop(avail[i].start),
-		atop(avail[i].start + avail[i].size) - 1,
-		atop(avail[i].start),
-		atop(avail[i].start + avail[i].size) - 1,
-		VM_FREELIST_DEFAULT);
-	}
+	struct pmap_segtab * const stp = &pmap_kernel_segtab;
+
+	/*
+	 * Initialize the kernel segment table.
+	 */
+	pmap_kernel()->pm_segtab = stp;
+	curcpu()->ci_pmap_kern_segtab = stp;
 
-	pmap_tlb_info_init(&pmap_tlb0_info);		/* init the lock */
+	KASSERT(endkernel == trunc_page(endkernel));
 
 	/*
 	 * Compute the number of pages kmem_arena will have.
@@ -160,7 +178,7 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	vsize_t bufsz = buf_memcalc();
 	buf_setvalimit(bufsz);
 
-	vsize_t nsegtabs = pmap_round_seg(VM_PHYS_SIZE
+	vsize_t kv_nsegtabs = pmap_round_seg(VM_PHYS_SIZE
 	+ (ubc_nwins << ubc_winshift)
 	+ bufsz
 	+ 16 * NCARGS
@@ -169,7 +187,7 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 #ifdef SYSVSHM
 	+ NBPG * shminfo.shmall
 #endif
-	+ NBPG * nkmempages);
+	+ NBPG * nkmempages) >> SEGSHIFT;
 
 	/*
 	 * Initialize `FYI' variables.	Note we're relying on
@@ -179,68 +197,100 @@ pmap_bootstrap(vaddr_t startkernel, vadd
 	 */
 	pmap_limits.avail_start = vm_physmem[0].start << PGSHIFT;
 	pmap_limits.avail_end = vm_physmem[vm_nphysseg - 1].end << PGSHIFT;
-	const vsize_t max_nsegtabs =
+	const size_t max_nsegtabs =
 	(pmap_round_seg(VM_MAX_KERNEL_ADDRESS)
 		- pmap_trunc_seg(VM_MIN_KERNEL_ADDRESS)) / NBSEG;
-	if (nsegtabs >= max_nsegtabs) {
+	if (kv_nsegtabs >= max_nsegtabs) {
 		pmap_limits.virtual_end = VM_MAX_KERNEL_ADDRESS;
-		nsegtabs = max_nsegtabs;
+		kv_nsegtabs = max_nsegtabs;
 	} else {
 		pmap_limits.virtual_end = VM_MIN_KERNEL_ADDRESS
-		+ nsegtabs * NBSEG;
+		+ kv_nsegtabs * NBSEG;
 	}
 
-	pmap_pvlist_lock_init(curcpu()->ci_ci.dcache_line_size);
-
 	/*
 	 * Now actually allocate the kernel PTE array (must be done
 	 * after virtual_end is initialized).
 	 */
-	vaddr_t segtabs =
-	uvm_pageboot_alloc(NBPG * nsegtabs + sizeof(struct pma

CVS commit: src/sys/arch/powerpc/booke/dev

2012-03-29 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Mar 29 14:47:09 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3gpio.c

Log Message:
Fix P2020 GPIO support (which has pins that are input/output instead of just
input or output).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/booke/dev/pq3gpio.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/powerpc/booke/dev/pq3gpio.c
diff -u src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.4 src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.5
--- src/sys/arch/powerpc/booke/dev/pq3gpio.c:1.4	Thu Jun 30 04:43:47 2011
+++ src/sys/arch/powerpc/booke/dev/pq3gpio.c	Thu Mar 29 14:47:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3gpio.c,v 1.4 2011/06/30 04:43:47 matt Exp $	*/
+/*	$NetBSD: pq3gpio.c,v 1.5 2012/03/29 14:47:09 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,12 +35,13 @@
  */
 
 #define	GLOBAL_PRIVATE
+#define	GPIO_PRIVATE
 
 #include "opt_mpc85xx.h"
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.4 2011/06/30 04:43:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3gpio.c,v 1.5 2012/03/29 14:47:09 matt Exp $");
 
 #include 
 #include 
@@ -108,6 +109,19 @@ pq3gpio_pin_write(void *v, int num, int 
 static void
 pq3gpio_pin_ctl(void *v, int num, int ctl)
 {
+	struct pq3gpio_group * const gc = v;
+	const u_int mask = 1 << (gc->gc_pins[num].pin_num ^ 31);
+uint32_t old, new; 
+  
+old = bus_space_read_4(gc->gc_bst, gc->gc_bsh, GPDIR);
+new = old;
+switch (ctl & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
+case GPIO_PIN_OUTPUT:new |= mask; break;
+case GPIO_PIN_INPUT:   new &= ~mask; break;
+default:return;
+}
+if (old != new)
+		bus_space_write_4(gc->gc_bst, gc->gc_bsh, GPDIR, new);
 }
 
 static void
@@ -291,19 +305,21 @@ pq3gpio_p20x0_attach(device_t self, bus_
 	bus_space_handle_t bsh, u_int svr)
 {
 	static const uint32_t gpio2pmuxcr_map[][2] = {
-		{ __BIT(10), PMUXCR_TSEC3_TS|PMUXCR_USB },
-		{ __BIT(11), PMUXCR_TSEC3_TS|PMUXCR_USB },
-		{ __BIT(12), PMUXCR_TSEC1_TS },
-		{ __BIT(13), PMUXCR_TSEC1_TS },
-		{ __BIT(14), PMUXCR_TSEC2_TS },
-		{ __BIT(15), PMUXCR_TSEC2_TS },
+		{ __BIT(8), PMUXCR_SDHC_CD },
+		{ __BIT(9), PMUXCR_SDHC_WP },
+		/*
+		 * These are really two bits but the low bit MBZ so we ignore
+		 * it.
+		 */
+		{ __BIT(10), PMUXCR_TSEC3_TS },
+		{ __BIT(11), PMUXCR_TSEC3_TS },
 	};
 	
-	uint32_t pinmask = ~0;	/* assume all bits are valid */
-	size_t pincnt = 32;
+	uint32_t pinmask = 0x;	/* assume all bits are valid */
+	size_t pincnt = 16;
 	const uint32_t pmuxcr = bus_space_read_4(bst, bsh, PMUXCR);
 	for (size_t i = 0; i < __arraycount(gpio2pmuxcr_map); i++) {
-		if (pmuxcr & gpio2pmuxcr_map[i][1]) {
+		if ((pmuxcr & gpio2pmuxcr_map[i][1]) == 0) {
 			pinmask &= ~gpio2pmuxcr_map[i][0];
 			pincnt--;
 		}
@@ -312,10 +328,10 @@ pq3gpio_p20x0_attach(device_t self, bus_
 	/*
 	 * Create GPIO pin groups
 	 */
-	aprint_normal_dev(self, "%zu input pins, %zu output pins\n",
-	pincnt, pincnt);
-	pq3gpio_group_create(self, bst, bsh, GPINDR, pinmask, GPIO_PIN_INPUT);
-	pq3gpio_group_create(self, bst, bsh, GPOUTDR, pinmask, GPIO_PIN_OUTPUT);
+	aprint_normal_dev(self, "%zu input/output pins\n",
+	pincnt);
+	pq3gpio_group_create(self, bst, bsh, GPDAT, pinmask,
+	GPIO_PIN_INPUT|GPIO_PIN_OUTPUT);
 }
 #endif /* P2020 */
 



CVS commit: src/sys/arch/powerpc/booke

2012-03-16 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Mar 16 07:23:38 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke: copyin.c

Log Message:
Make sure to have copyinstr return ENAMETOOLONG if the string was too long.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/booke/copyin.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/powerpc/booke/copyin.c
diff -u src/sys/arch/powerpc/booke/copyin.c:1.4 src/sys/arch/powerpc/booke/copyin.c:1.5
--- src/sys/arch/powerpc/booke/copyin.c:1.4	Mon Jun 20 05:20:37 2011
+++ src/sys/arch/powerpc/booke/copyin.c	Fri Mar 16 07:23:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyin.c,v 1.4 2011/06/20 05:20:37 matt Exp $	*/
+/*	$NetBSD: copyin.c,v 1.5 2012/03/16 07:23:38 matt Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.4 2011/06/20 05:20:37 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.5 2012/03/16 07:23:38 matt Exp $");
 
 #include 
 #include 
@@ -314,5 +314,8 @@ copyinstr(const void *usaddr, void *kdad
 	pcb->pcb_onfault = NULL;
 	if (done)
 		*done = copylen;
-	return 0;
+	/*
+	 * If the last byte is not NUL (0), then the name is too long.
+	 */
+	return (uint8_t)data ? ENAMETOOLONG : 0;
 }



CVS commit: src/sys/arch/powerpc/booke/dev

2012-02-23 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Feb 23 21:07:35 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3sdhc.c

Log Message:
Use the new 32-bit and ESDHC support in sdhc.c


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/booke/dev/pq3sdhc.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/powerpc/booke/dev/pq3sdhc.c
diff -u src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.3 src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.4
--- src/sys/arch/powerpc/booke/dev/pq3sdhc.c:1.3	Wed Jun 29 06:12:10 2011
+++ src/sys/arch/powerpc/booke/dev/pq3sdhc.c	Thu Feb 23 21:07:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3sdhc.c,v 1.3 2011/06/29 06:12:10 matt Exp $	*/
+/*	$NetBSD: pq3sdhc.c,v 1.4 2012/02/23 21:07:35 matt Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.3 2011/06/29 06:12:10 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3sdhc.c,v 1.4 2012/02/23 21:07:35 matt Exp $");
 
 #include 
 #include 
@@ -53,7 +53,6 @@ static int pq3sdhc_match(device_t, cfdat
 static void pq3sdhc_attach(device_t, device_t, void *);
 
 struct pq3sdhc_softc {
-	struct powerpc_bus_space sc_mybst;
 	struct sdhc_softc	sc;
 	bus_space_tag_t		sc_bst;
 	bus_space_handle_t	sc_bsh;
@@ -64,114 +63,6 @@ struct pq3sdhc_softc {
 CFATTACH_DECL_NEW(pq3sdhc, sizeof(struct pq3sdhc_softc),
 pq3sdhc_match, pq3sdhc_attach, NULL, NULL);
 
-static uint8_t
-pq3sdhc_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-	
-	KASSERT((o & -4) != SDHC_DATA);
-
-	const uint32_t v = bus_space_read_4(sc->sc_bst, h, o & -4);
-
-	return v >> ((o & 3) * 8);
-}
-
-static uint16_t
-pq3sdhc_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-
-	KASSERT((o & 1) == 0);
-	KASSERT((o & -4) != SDHC_DATA);
-
-	uint32_t v = bus_space_read_4(sc->sc_bst, h, o & -4);
-
-	if (__predict_false(o == SDHC_HOST_VER))
-		return v;
-	if (__predict_false(o == SDHC_NINTR_STATUS)) {
-		v |= SDHC_ERROR_INTERRUPT * ((v > 0x) != 0);
-		if (v != 0)
-			printf("get(INTR_STATUS)=%#x\n", v);
-	}
-	if (__predict_false(o == SDHC_EINTR_STATUS)) {
-		if (v != 0)
-			printf("get(INTR_STATUS)=%#x\n", v);
-	}
-
-	return v >> ((o & 2) * 8);
-}
-
-static uint32_t
-pq3sdhc_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-
-	KASSERT((o & 3) == 0);
-
-	uint32_t v = bus_space_read_4(sc->sc_bst, h, o & -4);
-
-	if (__predict_false(o == SDHC_DATA))
-		v = htole32(v);
-
-	return v;
-}
-
-static void
-pq3sdhc_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint8_t nv)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-	KASSERT((o & -4) != SDHC_DATA);
-	uint32_t v = bus_space_read_4(sc->sc_bst, h, o & -4);
-	const u_int shift = (o & 3) * 8;
-
-	if (o == SDHC_HOST_CTL) {
-		nv &= ~EDSHC_HOST_CTL_RES;
-	}
-
-	v &= ~(0xff << shift);
-	v |= (nv << shift);
-
-	bus_space_write_4(sc->sc_bst, h, o & -4, v);
-}
-
-static void
-pq3sdhc_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint16_t nv)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-	KASSERT((o & 1) == 0);
-	KASSERT((o & -4) != SDHC_DATA);
-	const u_int shift = (o & 2) * 8;
-	uint32_t v;
-
-	/*
-	 * Since NINTR_STATUS and EINTR_STATUS are W1C, don't bother getting
-	 * the previous value since we'd clear them.
-	 */
-	if (__predict_true((o & -4) != SDHC_NINTR_STATUS)) {
-		v = bus_space_read_4(sc->sc_bst, h, o & -4);
-		v &= ~(0x << shift);
-		v |= nv << shift;
-	} else {
-		v = nv << shift;
-		printf("put(INTR_STATUS,%#x)\n", v);
-	}
-
-	bus_space_write_4(sc->sc_bst, h, o & -4, v);
-}
-
-static void
-pq3sdhc_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, uint32_t v)
-{
-	const struct pq3sdhc_softc * const sc = (const void *) t;
-
-	KASSERT((o & 3) == 0);
-
-	if (__predict_false(o == SDHC_DATA))
-		v = le32toh(v);
-
-	bus_space_write_4(sc->sc_bst, h, o & -4, v);
-}
-
 static int
 pq3sdhc_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -194,19 +85,12 @@ pq3sdhc_attach(device_t parent, device_t
 	psc->sc_children |= cna->cna_childmask;
 	sc->sc.sc_dmat = cna->cna_dmat;
 	sc->sc.sc_dev = self;
-	//sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
-	sc->sc.sc_flags |= SDHC_FLAG_HAVE_DVS;
+	sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
+	sc->sc.sc_flags |=
+	SDHC_FLAG_HAVE_DVS | SDHC_FLAG_32BIT_ACCESS | SDHC_FLAG_ENHANCED;
 	sc->sc.sc_host = sc->sc_hosts;
 	sc->sc.sc_clkbase = board_info_get_number("bus-frequency") / 2000;
 	sc->sc_bst = cna->cna_memt;
-	sc->sc_mybst = *cna->cna_memt;
-
-	sc->sc_mybst.pbs_scalar.pbss_read_1 = pq3sdhc_read_1;
-	sc->sc_mybst.pbs_scalar.pbss_read_2 = pq3sdhc_read_2;
-	sc->sc_myb

CVS commit: src/sys/arch/powerpc/booke/dev

2012-02-20 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Feb 21 02:08:55 UTC 2012

Modified Files:
src/sys/arch/powerpc/booke/dev: pq3etsec.c

Log Message:
Don't rely on being able to allocate while in a softintr.  So preallocate
all the bus_dma maps in ifinit where we can sleep.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c
diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.9 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10
--- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.9	Thu Oct 13 19:53:30 2011
+++ src/sys/arch/powerpc/booke/dev/pq3etsec.c	Tue Feb 21 02:08:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pq3etsec.c,v 1.9 2011/10/13 19:53:30 matt Exp $	*/
+/*	$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -38,7 +38,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.9 2011/10/13 19:53:30 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $");
 
 #include 
 #include 
@@ -240,7 +240,7 @@ static void pq3etsec_ifstop(struct ifnet
 static int pq3etsec_ifioctl(struct ifnet *, u_long, void *);
 
 static int pq3etsec_mapcache_create(struct pq3etsec_softc *,
-struct pq3etsec_mapcache **, size_t, size_t, size_t, size_t);
+struct pq3etsec_mapcache **, size_t, size_t, size_t);
 static void pq3etsec_mapcache_destroy(struct pq3etsec_softc *,
 struct pq3etsec_mapcache *);
 static bus_dmamap_t pq3etsec_mapcache_get(struct pq3etsec_softc *,
@@ -544,14 +544,14 @@ pq3etsec_attach(device_t parent, device_
 	}
 
 	error = pq3etsec_mapcache_create(sc, &sc->sc_rx_mapcache, 
-	ETSEC_MAXRXMBUFS, ETSEC_MINRXMBUFS, MCLBYTES, ETSEC_NRXSEGS);
+	ETSEC_MAXRXMBUFS, MCLBYTES, ETSEC_NRXSEGS);
 	if (error) {
 		aprint_error(": failed to allocate rx dmamaps: %d\n", error);
 		return;
 	}
 
 	error = pq3etsec_mapcache_create(sc, &sc->sc_tx_mapcache, 
-	ETSEC_MAXTXMBUFS, ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS);
+	ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS);
 	if (error) {
 		aprint_error(": failed to allocate tx dmamaps: %d\n", error);
 		return;
@@ -691,6 +691,8 @@ pq3etsec_ifinit(struct ifnet *ifp)
 	struct pq3etsec_softc * const sc = ifp->if_softc;
 	int error = 0;
 
+	KASSERT(!cpu_softintr_p());
+
 	sc->sc_maxfrm = max(ifp->if_mtu + 32, MCLBYTES);
 	if (ifp->if_mtu > ETHERMTU_JUMBO)
 		return error;
@@ -715,8 +717,7 @@ pq3etsec_ifinit(struct ifnet *ifp)
 
 	if (sc->sc_tx_mapcache == NULL) {
 		error = pq3etsec_mapcache_create(sc, &sc->sc_tx_mapcache,
-		ETSEC_MAXTXMBUFS, ETSEC_MAXTXMBUFS, sc->sc_maxfrm,
-		ETSEC_NTXSEGS);
+		ETSEC_MAXTXMBUFS, sc->sc_maxfrm, ETSEC_NTXSEGS);
 		if (error)
 			return error;
 	}
@@ -1104,20 +1105,7 @@ pq3etsec_mapcache_get(
 	struct pq3etsec_softc *sc,
 	struct pq3etsec_mapcache *dmc)
 {
-	if (dmc->dmc_nmaps == 0) {
-		bus_dmamap_t map;
-		int error = bus_dmamap_create(sc->sc_dmat, dmc->dmc_maxmapsize,
-			dmc->dmc_maxseg, dmc->dmc_maxmapsize, 0,
-			BUS_DMA_WAITOK|BUS_DMA_ALLOCNOW, &map);
-		if (error) {
-			aprint_error_dev(sc->sc_dev,
-			"failed to allocate a %zuB map: %d\n",
-			dmc->dmc_maxmapsize, error);
-			return NULL;
-		}
-		return map;
-	}
-
+	KASSERT(dmc->dmc_nmaps > 0);
 	KASSERT(dmc->dmc_maps[dmc->dmc_nmaps-1] != NULL);
 	return dmc->dmc_maps[--dmc->dmc_nmaps];
 }
@@ -1152,7 +1140,6 @@ pq3etsec_mapcache_create(
 	struct pq3etsec_softc *sc,
 	struct pq3etsec_mapcache **dmc_p,
 	size_t maxmaps,
-	size_t minmaps,
 	size_t maxmapsize,
 	size_t maxseg)
 {
@@ -1161,19 +1148,19 @@ pq3etsec_mapcache_create(
 	struct pq3etsec_mapcache * const dmc = kmem_zalloc(dmc_size, KM_SLEEP);
 
 	dmc->dmc_maxmaps = maxmaps;
-	dmc->dmc_nmaps = minmaps;
+	dmc->dmc_nmaps = maxmaps;
 	dmc->dmc_maxmapsize = maxmapsize;
 	dmc->dmc_maxseg = maxseg;
 
-	for (u_int i = 0; i < minmaps; i++) {
+	for (u_int i = 0; i < maxmaps; i++) {
 		int error = bus_dmamap_create(sc->sc_dmat, dmc->dmc_maxmapsize,
 		 dmc->dmc_maxseg, dmc->dmc_maxmapsize, 0,
 		 BUS_DMA_WAITOK|BUS_DMA_ALLOCNOW, &dmc->dmc_maps[i]);
 		if (error) {
 			aprint_error_dev(sc->sc_dev,
 			"failed to creat dma map cache "
-			"entry %u of %zu (max %zu): %d\n",
-			i, minmaps, maxmaps, error);
+			"entry %u of %zu: %d\n",
+			i, maxmaps, error);
 			while (i-- > 0) {
 bus_dmamap_destroy(sc->sc_dmat,
 dmc->dmc_maps[i]);



  1   2   >