NetBSD Problem Report #53626

From tsutsui@ceres.dti.ne.jp  Sat Sep 22 10:18:28 2018
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 8C6727A152
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 22 Sep 2018 10:18:28 +0000 (UTC)
Message-Id: <201809221018.w8MAINw6006825@ceres.dti.ne.jp>
Date: Sat, 22 Sep 2018 19:18:23 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: NetBSD/newsmips 8.0 GENERIC boot fails on NWS-5000X
X-Send-Pr-Version: 3.95

>Number:         53626
>Category:       port-newsmips
>Synopsis:       NetBSD/newsmips 8.0 GENERIC boot fails on NWS-5000X
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 22 10:20:00 +0000 2018
>Closed-Date:    Sun Nov 18 16:39:26 +0000 2018
>Last-Modified:  Sun Nov 18 16:39:26 +0000 2018
>Originator:     Izumi Tsutsui
>Release:        NetBSD 8.0
>Organization:
>Environment:
System: NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/newsmips/compile/GENERIC
Architecture: mipseb
Machine: newsmips
>Description:
NetBSD/newsmips 8.0 GENERIC and INSTALL kernel boot fails on NWS-5000X:

---
> bo scsi(0,0) netbsd-INSTALL
NetBSD/newsmips Primary Boot
NetBSD/newsmips Secondary Boot, Revision 1.7
(tsutsui@mirage, Thu Apr 16 21:31:51 JST 2009)
Booting scsi(0,0)netbsd-INSTALL
4855536+92128=0x4b8224

SONY NET WORK STATION, Model NWS-5000, Machine ID #14668
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
    2018 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 8.0 (INSTALL) #0: Tue Jul 17 14:59:51 UTC 2018
	mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/newsmips/compile/INSTALL
news5000
total memory = 127 MB
avail memory = 119 MB
mainbus0 (root)
cpu0 at mainbus0: MIPS R4400 CPU (0x450) Rev. 5.0 with MIPS R4010 FPC Rev. 0.0
cpu0: 48 TLB entries, 16MB max page size
cpu0: 16KB/16B direct-mapped L1 instruction cache
cpu0: 16KB/16B direct-mapped write-back L1 data cache
cpu0: 1024KB/64B direct-mapped write-back L2 unified cache
ap0 at mainbus0
pid 0(system): trap: cpu0, TLB miss (load or instr. fetch) in kernel mode
status=0x20040003, cause=0x10000008, epc=0x80001a0c, vaddr=0xffff8ed4
tf=0x804e2d00 ksp=0x804e2da0 ra=0x800019f8 ppl=0x804a0508
panic: trap
halted.

> 

---

> bo -s            
NetBSD/newsmips Primary Boot
NetBSD/newsmips Secondary Boot, Revision 1.7
(tsutsui@mirage, Thu Apr 16 21:31:51 JST 2009)
Booting scsi(0,0)
3814832+128304 [219600+208144]=0x42b6a4

SONY NET WORK STATION, Model NWS-5000, Machine ID #14668
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
    2018 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018
        mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/newsmips/compile/GENERIC
news5000
total memory = 127 MB
avail memory = 120 MB
mainbus0 (root)
cpu0 at mainbus0: MIPS R4400 CPU (0x450) Rev. 5.0 with MIPS R4010 FPC Rev. 0.0
cpu0: 48 TLB entries, 16MB max page size
cpu0: 16KB/16B direct-mapped L1 instruction cache
cpu0: 16KB/16B direct-mapped write-back L1 data cache
cpu0: 1024KB/64B direct-mapped write-back L2 unified cache
ap0 at mainbus0
pid 0(system): trap: cpu0, TLB miss (load or instr. fetch) in kernel mode
status=0x20040003, cause=0x8, epc=0x80001b40, vaddr=0xffff8ed4
tf=0x80456d00 ksp=0x80456da0 ra=0x80001b1c ppl=0
kernel: TLB miss (load or instr. fetch) trap
Stopped in pid 0.1 (system) at  netbsd:apbusattach+0x90:        lw      s0,84(s1
)
db> bt
0x80456da0: apbusattach+90 (0,7c,6,803949d0) ra 801f8880 sz 56
0x80456dd8: config_attach_loc+1dc (0,7c,6,803949d0) ra 801f8990 sz 48
0x80456e08: config_found_sm_loc+5c (0,7c,6,0) ra 801f8a98 sz 56
0x80456e40: config_found+20 (0,7c,0,0) ra 8000bc08 sz 32
0x80456e60: mbattach+70 (0,7c,0,0) ra 801f8880 sz 32
0x80456e80: config_attach_loc+1dc (0,7c,0,0) ra 801f8b14 sz 48
0x80456eb0: config_rootfound+44 (0,7c,0,0) ra 800094b0 sz 40
0x80456ed8: cpu_configure+30 (0,7c,0,0) ra 802fd844 sz 24
0x80456ef0: main+398 (0,7c,0,0) ra 800010e4 sz 88
0x80456f48: kernel_text+e4 (0,7c,0,0) ra 0 sz 0
User-level: pid 0.1
db> 
---

>How-To-Repeat:
Boot NetBSD/newsmips 8.0 GENERIC or INSTALL kernel on NWS-5000X

>Fix:
Something wrong in apbus configuration?

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-newsmips/53626: NetBSD/newsmips 8.0 GENERIC boot fails on
	 NWS-5000X
Date: Sat, 22 Sep 2018 22:18:49 +0900

 There was a special handling for PROM work area used by
 news5000 (newsmips + MIPS3) in NetBSD 5.x and prior:

  https://nxr.netbsd.org/xref/src/sys/arch/mips/mips/mipsX_subr.S?r=1.26.30.1#1531
 ---
    1531 #ifdef newsmips
    1532 	/* news5000 has ROM work area at 0xfff00000. */
    1533 	bne	k1, zero, 1f
    1534 	nop
    1535 	j	checkromwork
    1536 	nop					# - delay slot -
    1537 1:
    1538 #else
    1539 	beq	k1, zero, outofworld		# No. Failing beyond. . .
    1540 	nop					# - delay slot -
    1541 #endif
 ---

  https://nxr.netbsd.org/xref/src/sys/arch/newsmips/newsmips/locore_machdep.S?r=1.15#81
 ---
      81 #ifdef MIPS3
      82 	.set	mips3
      83 	.set	noat
      84 	.globl	checkromwork
      85 checkromwork:
      86 	dmfc0	k0, MIPS_COP_0_BAD_VADDR
      87 
      88 	li	k1, 0xfff00000			# NEWS5000 ROM Work: 0xFFF00000~0xFFFFFFFF (1Mbyte)
      89 	sltu	k1, k0, k1
      90 	bne	k1, zero, outofworld
      91 	nop
      92 
      93 	li	k1, 0x000fe000			# XXX (depend on 4k page)
      94 	and	k1, k0, k1			# k1 = (VADDR - 0xFFF00000) & 0xffffe000
      95 
      96 	la	k0, _C_LABEL(physmem)
      97 	lw	k0, 0(k0)			# k0 = page of physmem (tail of maxmemory - 0x00100000)
      98 	sll	k0, k0, PGSHIFT			# k0 = memory tail
      99 	add	k0, k0, k1			# 0xfff00000+? -> memory tail + ?
     100 
     101 	srl	k0, k0, 6			# MIPS3_PG_SHIFT
     102 	li	k1, 0x02|0x18|0x01		# MIPS3_PG_V|MIPS3_PG_CACHED|MIPS3_PG_G
     103 	or	k0, k0, k1
     104 
     105 	li	k1, 64				# set ODD page
     106 	add	k1, k0, k1
     107 
     108 	dsll	k0, k0, 34			# get rid of "wired" bit
     109 	dsrl	k0, k0, 34
     110 	dmtc0	k0, MIPS_COP_0_TLB_LO0		# load PTE entry
     111 	dsll	k1, k1, 34
     112 	dsrl	k1, k1, 34
     113 	dmtc0	k1, MIPS_COP_0_TLB_LO1		# load PTE entry
     114 	nop
     115 	nop					# required for QED5230
     116 	tlbwr					# write TLB
     117 	nop
     118 	nop
     119 	nop
     120 	nop
     121 	nop
     122 	eret
 ---

 It looks we should map the last 1MB of physical RAM to
 KSEG2 0xFFF00000 - 0xFFFFFFFF somewhere.

 ---
 Izumi Tsutsui

Responsible-Changed-From-To: port-newsmips-maintainer->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sat, 22 Sep 2018 14:29:22 +0000
Responsible-Changed-Why:
I'll check this one.


State-Changed-From-To: open->analyzed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 22 Sep 2018 14:29:22 +0000
State-Changed-Why:
Mapping the last 1MB of physical RAM to 0xFFF00000 via wired map make
the GENERIC kernel boot, but I'm not sure if it's proper way.

Index: conf/std.newsmips
===================================================================
RCS file: /cvsroot/src/sys/arch/newsmips/conf/std.newsmips,v
retrieving revision 1.17
diff -u -p -d -r1.17 std.newsmips
--- conf/std.newsmips	11 Dec 2005 12:18:24 -0000	1.17
+++ conf/std.newsmips	22 Sep 2018 14:07:26 -0000
@@ -7,5 +7,7 @@ makeoptions	MACHINE_ARCH="mipseb"
 options 	EXEC_ELF32	# exec ELF32 binaries
 options 	EXEC_SCRIPT	# exec #! scripts

+options 	ENABLE_MIPS3_WIRED_MAP
+
 makeoptions	DEFTEXTADDR="0x80001000"
 makeoptions	LINKFORMAT="-N"
Index: newsmips/news5000.c
===================================================================
RCS file: /cvsroot/src/sys/arch/newsmips/newsmips/news5000.c,v
retrieving revision 1.21
diff -u -p -d -r1.21 news5000.c
--- newsmips/news5000.c	21 Jul 2016 19:49:59 -0000	1.21
+++ newsmips/news5000.c	22 Sep 2018 14:07:27 -0000
@@ -37,9 +37,13 @@ __KERNEL_RCSID(0, "$NetBSD: news5000.c,v
 #include <sys/cpu.h>
 #include <sys/intr.h>

+#include <uvm/uvm_extern.h>
+
 #include <mips/locore.h>
+#include <mips/pte.h>

 #include <machine/adrsmap.h>
+#include <machine/wired_map.h>

 #include <newsmips/apbus/apbusvar.h>
 #include <newsmips/newsmips/machid.h>
@@ -53,6 +57,7 @@ static void news5000_enable_timer(void);
 static void news5000_readidrom(uint8_t *);
 static void news5000_tc_init(void);
 static uint32_t news5000_getfreerun(struct timecounter *);
+static void news5000_map_promwork(void);

 /*
  * This is a mask of bits to clear in the SR when we go to a
@@ -295,4 +300,25 @@ news5000_init(void)
 #define NEWS5000_FDC_FDOUT 0xbed20000
 #define FDO_FRST 0x04
 	*(volatile uint8_t *)NEWS5000_FDC_FDOUT = FDO_FRST;
+
+	news5000_map_promwork();
+}
+
+static void
+news5000_map_promwork(void)
+{
+	vaddr_t promwork_va;
+	vsize_t promwork_sz;
+	paddr_t promwork_pa;
+
+#define NEWS5000_PROMWORK 0xfff00000
+
+	/* map PROM work RAM into VA 0xFFF00000 - 0xFFFFFFFF */
+	promwork_va = NEWS5000_PROMWORK;
+	promwork_sz = MIPS3_PG_SIZE_MASK_TO_SIZE(MIPS3_PG_SIZE_1M);
+	promwork_pa = ctob(physmem);
+	if (mips3_wired_enter_page(promwork_va, promwork_pa, promwork_sz)
+	    == false) {
+		printf("%s: cannot allocate PROM work\n", __func__);
+	}
 }


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-newsmips/53626 (NetBSD/newsmips 8.0 GENERIC boot fails on
	 NWS-5000X)
Date: Sun, 30 Sep 2018 14:03:03 +0900

 I discussed with ryo@ (the original author of initial news5000 support):

 - mapping against 0xfff00000 region was handled in (MI) TLB miss handler
   as a temporary hack
 - instead of using wired map (or dinamic allocation in the TLB miss handler)
   there was a (unused) aptokseg0() function that convert PROM work address
   to KSEG0 (the PROM work was allocated at end of RAM so it can be
   calculated from physmem)
 - to use APbus ROM calls maybe the VA region should be at original
   0xfff00000-0xffffffff area (but currently no users)
 - on the other hand 0xfff00000 region is not managed by the kernel
   so it can't be accessed from userand programs (vmstat(8) etc) via kvm(3) 

 Actually the following patch using aptokseg0() function works:
 ---
 Index: apbus/apbus.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbus.c,v
 retrieving revision 1.22
 diff -u -p -d -r1.22 apbus.c
 --- apbus/apbus.c	20 Feb 2011 07:56:31 -0000	1.22
 +++ apbus/apbus.c	30 Sep 2018 04:37:02 -0000
 @@ -49,9 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.
  static int  apbusmatch(device_t, cfdata_t, void *);
  static void apbusattach(device_t, device_t, void *);
  static int apbusprint(void *, const char *);
 -#if 0
 -static void *aptokseg0 (void *);
 -#endif
  static void apbus_dma_unmapped(bus_dma_tag_t, bus_dmamap_t);
  static int apbus_dma_mapalloc(bus_dma_tag_t, bus_dmamap_t, int);
  static void apbus_dma_mapfree(bus_dma_tag_t, bus_dmamap_t);
 @@ -116,13 +113,13 @@ apbusattach(device_t parent, device_t se
  	/*
  	 * get first ap-device
  	 */
 -	apdev = apbus_lookupdev(NULL);
 +	apdev = aptokseg0(apbus_lookupdev(NULL));

  	/*
  	 * trace device chain
  	 */
  	while (apdev) {
 -		apctl = apdev->apbd_ctl;
 +		apctl = aptokseg0(apdev->apbd_ctl);

  		/*
  		 * probe physical device only
 @@ -134,18 +131,18 @@ apbusattach(device_t parent, device_t se
  			 */
  			while (apctl) {
  				/* make apbus_attach_args for devices */
 -				child.apa_name = apdev->apbd_name;
 +				child.apa_name = aptokseg0(apdev->apbd_name);
  				child.apa_ctlnum = apctl->apbc_ctlno;
  				child.apa_slotno = apctl->apbc_sl;
  				child.apa_hwbase = apctl->apbc_hwbase;

  				config_found(self, &child, apbusprint);

 -				apctl = apctl->apbc_link;
 +				apctl = aptokseg0(apctl->apbc_link);
  			}
  		}

 -		apdev = apdev->apbd_link;
 +		apdev = aptokseg0(apdev->apbd_link);
  	}
  }

 @@ -161,22 +158,6 @@ apbusprint(void *aux, const char *pnp)
  	return UNCONF;
  }

 -#if 0
 -void *
 -aptokseg0(void *va)
 -{
 -	vaddr_t addr = (vaddr_t)va;
 -
 -	if (addr >= 0xfff00000) {
 -		addr -= 0xfff00000;
 -		addr += physmem << PGSHIFT;
 -		addr += 0x80000000;
 -		va = (void *)addr;
 -	}
 -	return va;
 -}
 -#endif
 -
  void
  apbus_wbflush(void)
  {
 Index: apbus/apbus_subr.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbus_subr.c,v
 retrieving revision 1.9
 diff -u -p -d -r1.9 apbus_subr.c
 --- apbus/apbus_subr.c	24 Mar 2014 20:05:20 -0000	1.9
 +++ apbus/apbus_subr.c	30 Sep 2018 04:37:02 -0000
 @@ -32,11 +32,26 @@ __KERNEL_RCSID(0, "$NetBSD: apbus_subr.c
  #include <sys/param.h>
  #include <sys/systm.h>

 +#include <mips/cpuregs.h>
 +
  #include <newsmips/apbus/apbusvar.h>

  static void apctl_dump(struct apbus_ctl *);

  void *
 +aptokseg0(void *va)
 +{
 +	vaddr_t addr = (vaddr_t)va;
 +
 +	if (addr >= 0xfff00000) {
 +		addr &= ~0xfff00000;
 +		addr += ctob(physmem);
 +		addr = MIPS_PHYS_TO_KSEG0(addr);
 +	}
 +	return (void *)addr;
 +}
 +
 +void *
  apbus_device_to_hwaddr(struct apbus_dev *apbus_dev)
  {
  	struct apbus_ctl *ctl;
 @@ -44,7 +59,7 @@ apbus_device_to_hwaddr(struct apbus_dev 
  	if (apbus_dev == NULL)
  		return NULL;

 -	ctl = apbus_dev->apbd_ctl;
 +	ctl = aptokseg0(apbus_dev->apbd_ctl);
  	if (ctl == NULL)
  		return NULL;

 @@ -54,7 +69,7 @@ apbus_device_to_hwaddr(struct apbus_dev 
  struct apbus_dev *
  apbus_lookupdev(char *devname)
  {
 -	struct apbus_dev *dp;
 +	struct apbus_dev *dp, *dp0;

  	dp = _sip->apbsi_dev;
  	if (devname == NULL || *devname == '\0')
 @@ -62,10 +77,11 @@ apbus_lookupdev(char *devname)

  	/* search apbus_dev named 'devname' */
  	while (dp) {
 -		if (strcmp(devname, dp->apbd_name) == 0)
 +		dp0 = aptokseg0(dp);
 +		if (strcmp(devname, dp0->apbd_name) == 0)
  			return dp;

 -		dp = dp->apbd_link;
 +		dp = dp0->apbd_link;
  	}

  	return NULL;
 @@ -74,42 +90,49 @@ apbus_lookupdev(char *devname)
  static void
  apctl_dump(struct apbus_ctl *apctl)
  {
 +	struct apbus_ctl *apctl0;
 +	
  	if (!apctl)
  		return;
 +	apctl0 = aptokseg0(apctl);

  	printf("	apbus_ctl dump (%p)\n", apctl);

 -	printf("	Num:		%d\n", apctl->apbc_ctlno);
 -	printf("	HWaddr:		0x%08x\n", apctl->apbc_hwbase);
 -	printf("	softc:		%p\n", apctl->apbc_softc);
 -	printf("	Slot:		%d\n", apctl->apbc_sl);
 +	printf("	Num:		%d\n", apctl0->apbc_ctlno);
 +	printf("	HWaddr:		0x%08x\n", apctl0->apbc_hwbase);
 +	printf("	softc:		%p\n", apctl0->apbc_softc);
 +	printf("	Slot:		%d\n", apctl0->apbc_sl);
  	printf("\n");

 -	if (apctl->apbc_link)
 -		apctl_dump(apctl->apbc_link);
 +	if (apctl0->apbc_link) {
 +		apctl_dump(apctl0->apbc_link);
 +	}
  }

  void
  apdevice_dump(struct apbus_dev *apdev)
  {
 -	struct apbus_ctl *apctl;
 +	struct apbus_dev *apdev0;
 +	struct apbus_ctl *apctl, *apctl0;

  	if (apdev == NULL)
  		return;

  	/* only no pseudo device */
 -	apctl = apdev->apbd_ctl;
 -	if (apctl == NULL || apctl->apbc_hwbase == 0)
 +	apdev0 = aptokseg0(apdev);
 +	apctl = apdev0->apbd_ctl;
 +	apctl0 = aptokseg0(apctl);
 +	if (apctl == NULL || apctl0->apbc_hwbase == 0)
  		return;

  	printf("apbus_dev dump (%p)\n", apdev);
 -	printf("name:		%s\n", apdev->apbd_name);
 -	printf("vendor:		%s\n", apdev->apbd_vendor);
 -	printf("atr:		%08x\n", apdev->apbd_atr);
 -	printf("rev:		%d\n", apdev->apbd_rev);
 -	printf("driver:		0x%08x\n", (unsigned int)apdev->apbd_driver);
 -	printf("ctl:		0x%08x\n", (unsigned int)apdev->apbd_ctl);
 -	printf("link:		0x%08x\n", (unsigned int)apdev->apbd_link);
 +	printf("name:		%s\n", apdev0->apbd_name);
 +	printf("vendor:		%s\n", apdev0->apbd_vendor);
 +	printf("atr:		%08x\n", apdev0->apbd_atr);
 +	printf("rev:		%d\n", apdev0->apbd_rev);
 +	printf("driver:		0x%08x\n", (unsigned int)apdev0->apbd_driver);
 +	printf("ctl:		0x%08x\n", (unsigned int)apdev0->apbd_ctl);
 +	printf("link:		0x%08x\n", (unsigned int)apdev0->apbd_link);
  	printf("\n");

  	apctl_dump(apctl);
 Index: apbus/apbusvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbusvar.h,v
 retrieving revision 1.9
 diff -u -p -d -r1.9 apbusvar.h
 --- apbus/apbusvar.h	17 Oct 2007 19:55:54 -0000	1.9
 +++ apbus/apbusvar.h	30 Sep 2018 04:37:02 -0000
 @@ -39,6 +39,7 @@ struct apbus_attach_args {
  	u_long	apa_hwbase;	/* hardware I/O address */
  };

 +void *aptokseg0(void *);
  void *apbus_device_to_hwaddr(struct apbus_dev *);
  struct apbus_dev *apbus_lookupdev(char *);
  void apdevice_dump(struct apbus_dev *);

 ---

 However it's a bit difficult to check there is no other invalid accesses.

 I would like to choose wired map version to avoid address translation
 confusion for now, and there is no objection from ryo@.

 I also modified wired map patch to call it from apbusattach()
 because (old, uncommitted, but forthcomming) news4000 also
 requires the similar hack for APbus devices.

 ---

 Index: apbus/apbus.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbus.c,v
 retrieving revision 1.22
 diff -u -p -d -r1.22 apbus.c
 --- apbus/apbus.c	20 Feb 2011 07:56:31 -0000	1.22
 +++ apbus/apbus.c	29 Sep 2018 19:05:05 -0000
 @@ -99,6 +99,7 @@ apbusattach(device_t parent, device_t se
  	struct newsmips_intr *ip;
  	int i;

 +	apbus_map_romwork();
  	mips_set_wbflush(apbus_wbflush);

  	*(volatile uint32_t *)(NEWS5000_APBUS_INTST) = 0xffffffff;
 Index: apbus/apbus_subr.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbus_subr.c,v
 retrieving revision 1.9
 diff -u -p -d -r1.9 apbus_subr.c
 --- apbus/apbus_subr.c	24 Mar 2014 20:05:20 -0000	1.9
 +++ apbus/apbus_subr.c	29 Sep 2018 19:05:06 -0000
 @@ -32,10 +32,42 @@ __KERNEL_RCSID(0, "$NetBSD: apbus_subr.c
  #include <sys/param.h>
  #include <sys/systm.h>

 +#include <uvm/uvm_extern.h>
 +
 +#include <mips/locore.h>
 +#include <mips/pte.h>
 +
 +#include <machine/wired_map.h>
 +
  #include <newsmips/apbus/apbusvar.h>

  static void apctl_dump(struct apbus_ctl *);

 +#define	APBUS_ROMWORK_VA	0xfff00000
 +
 +void
 +apbus_map_romwork(void)
 +{
 +	static bool mapped = false;
 +	vaddr_t apbd_work_va;
 +	vsize_t apbd_work_sz;
 +	paddr_t apbd_work_pa;
 +
 +	if (!mapped) {
 +		/* map PROM work RAM into VA 0xFFF00000 - 0xFFFFFFFF */
 +		apbd_work_va = APBUS_ROMWORK_VA;
 +		apbd_work_sz = MIPS3_PG_SIZE_MASK_TO_SIZE(MIPS3_PG_SIZE_1M);
 +		apbd_work_pa = ctob(physmem);
 +
 +		mapped = mips3_wired_enter_page(apbd_work_va, apbd_work_pa,
 +		    apbd_work_sz);
 +		if (!mapped) {
 +			printf("%s: cannot allocate APbus PROM work\n",
 +			    __func__);
 +		}
 +	}
 +}
 +
  void *
  apbus_device_to_hwaddr(struct apbus_dev *apbus_dev)
  {
 Index: apbus/apbusvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/apbus/apbusvar.h,v
 retrieving revision 1.9
 diff -u -p -d -r1.9 apbusvar.h
 --- apbus/apbusvar.h	17 Oct 2007 19:55:54 -0000	1.9
 +++ apbus/apbusvar.h	29 Sep 2018 19:05:06 -0000
 @@ -39,6 +39,7 @@ struct apbus_attach_args {
  	u_long	apa_hwbase;	/* hardware I/O address */
  };

 +void apbus_map_romwork(void);
  void *apbus_device_to_hwaddr(struct apbus_dev *);
  struct apbus_dev *apbus_lookupdev(char *);
  void apdevice_dump(struct apbus_dev *);
 Index: conf/std.newsmips
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/newsmips/conf/std.newsmips,v
 retrieving revision 1.17
 diff -u -p -d -r1.17 std.newsmips
 --- conf/std.newsmips	11 Dec 2005 12:18:24 -0000	1.17
 +++ conf/std.newsmips	29 Sep 2018 19:05:06 -0000
 @@ -7,5 +7,7 @@ makeoptions	MACHINE_ARCH="mipseb"
  options 	EXEC_ELF32	# exec ELF32 binaries
  options 	EXEC_SCRIPT	# exec #! scripts

 +options 	ENABLE_MIPS3_WIRED_MAP
 +
  makeoptions	DEFTEXTADDR="0x80001000"
  makeoptions	LINKFORMAT="-N"

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53626 CVS commit: src/sys/arch/newsmips
Date: Sun, 30 Sep 2018 06:14:23 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sun Sep 30 06:14:23 UTC 2018

 Modified Files:
 	src/sys/arch/newsmips/apbus: apbus.c apbus_subr.c apbusvar.h
 	src/sys/arch/newsmips/conf: std.newsmips

 Log Message:
 Fix news5000 panic during boot on APbus attach. PR port-newsmips/53626

 Discussed with ryo@ (the original author of news5000 support).
 Should be pulled up to netbsd-8.


 To generate a diff of this commit:
 cvs rdiff -u -r1.22 -r1.23 src/sys/arch/newsmips/apbus/apbus.c
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/newsmips/apbus/apbus_subr.c \
     src/sys/arch/newsmips/apbus/apbusvar.h
 cvs rdiff -u -r1.17 -r1.18 src/sys/arch/newsmips/conf/std.newsmips

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

State-Changed-From-To: analyzed->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Fri, 16 Nov 2018 15:23:56 +0000
State-Changed-Why:
[pullup-8 #1095]


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53626 CVS commit: [netbsd-8] src/sys/arch/newsmips
Date: Sun, 18 Nov 2018 11:54:03 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Nov 18 11:54:03 UTC 2018

 Modified Files:
 	src/sys/arch/newsmips/apbus [netbsd-8]: apbus.c apbus_subr.c apbusvar.h
 	src/sys/arch/newsmips/conf [netbsd-8]: std.newsmips

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1095):

 	sys/arch/newsmips/apbus/apbus.c: revision 1.23
 	sys/arch/newsmips/apbus/apbus_subr.c: revision 1.10
 	sys/arch/newsmips/apbus/apbusvar.h: revision 1.10
 	sys/arch/newsmips/conf/std.newsmips: revision 1.18

 Fix news5000 panic during boot on APbus attach. PR port-newsmips/53626

 Discussed with ryo@ (the original author of news5000 support).

 Should be pulled up to netbsd-8.


 To generate a diff of this commit:
 cvs rdiff -u -r1.22 -r1.22.48.1 src/sys/arch/newsmips/apbus/apbus.c
 cvs rdiff -u -r1.9 -r1.9.22.1 src/sys/arch/newsmips/apbus/apbus_subr.c
 cvs rdiff -u -r1.9 -r1.9.100.1 src/sys/arch/newsmips/apbus/apbusvar.h
 cvs rdiff -u -r1.17 -r1.17.158.1 src/sys/arch/newsmips/conf/std.newsmips

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

State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 18 Nov 2018 16:39:26 +0000
State-Changed-Why:
Pulled up.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.