CVS commit: src/sys/dev/pci

2021-09-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Sep  9 02:12:48 UTC 2021

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
add some bits in the pci Link Capabilities Register, and also the similar
set in the Link Capabilities 2 Register.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/pci/pcireg.h

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

Modified files:

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.156 src/sys/dev/pci/pcireg.h:1.157
--- src/sys/dev/pci/pcireg.h:1.156	Tue Aug 17 22:00:32 2021
+++ src/sys/dev/pci/pcireg.h	Thu Sep  9 02:12:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.156 2021/08/17 22:00:32 andvar Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.157 2021/09/09 02:12:48 mrg Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1017,6 +1017,12 @@ typedef u_int8_t pci_revision_t;
 #define PCIE_DCSR_EMGPWRREDD	__BIT(6 + 16)  /* Emg. Pwr. Reduct. Detected */
 #define PCIE_LCAP	0x0c	/* Link Capabilities Register */
 #define PCIE_LCAP_MAX_SPEED	__BITS(3, 0)   /* Max Link Speed */
+#define  PCIE_LCAP_MAX_SPEED_2	__BIT(0)   /* 2.5GT/s */
+#define  PCIE_LCAP_MAX_SPEED_5	__BIT(1)   /* 5GT/s */
+#define  PCIE_LCAP_MAX_SPEED_8	__BIT(3)   /* 8GT/s */
+#define  PCIE_LCAP_MAX_SPEED_16	__BIT(4)   /* 16GT/s */
+#define  PCIE_LCAP_MAX_SPEED_32	__BIT(5)   /* 32GT/s */
+#define  PCIE_LCAP_MAX_SPEED_64	__BIT(6)   /* 64GT/s */
 #define PCIE_LCAP_MAX_WIDTH	__BITS(9, 4)   /* Maximum Link Width */
 #define PCIE_LCAP_ASPM		__BITS(11, 10) /* Active State Link PM Supp. */
 #define PCIE_LCAP_L0S_EXIT	__BITS(14, 12) /* L0s Exit Latency */
@@ -1136,6 +1142,12 @@ typedef u_int8_t pci_revision_t;
 #define PCIE_DCSR2_EETLP	__BIT(15)  /* End-End TLP Prefix Blcking */
 #define PCIE_LCAP2	0x2c	/* Link Capabilities 2 Register */
 #define PCIE_LCAP2_SUP_LNKSV	__BITS(7, 1)   /* Supported Link Speeds Vect */
+#define  PCIE_LCAP2_SUP_LNKS2	__BIT(1)   /* Supported Speed 2.5GT/ */
+#define  PCIE_LCAP2_SUP_LNKS5	__BIT(2)   /* Supported Speed 5GT/ */
+#define  PCIE_LCAP2_SUP_LNKS8	__BIT(3)   /* Supported Speed 8GT/ */
+#define  PCIE_LCAP2_SUP_LNKS16	__BIT(4)   /* Supported Speed 16GT/ */
+#define  PCIE_LCAP2_SUP_LNKS32	__BIT(5)   /* Supported Speed 32GT/ */
+#define  PCIE_LCAP2_SUP_LNKS64	__BIT(6)   /* Supported Speed 64GT/ */
 #define PCIE_LCAP2_CROSSLNK	__BIT(8)   /* Crosslink Supported */
 #define PCIE_LCAP2_LOWSKPOS_GENSUPPSV __BITS(15, 9)
   /* Lower SKP OS Generation Supp. Spd. Vect */



CVS commit: src/sys/dev/pci

2021-09-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Sep  9 02:12:48 UTC 2021

Modified Files:
src/sys/dev/pci: pcireg.h

Log Message:
add some bits in the pci Link Capabilities Register, and also the similar
set in the Link Capabilities 2 Register.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/pci/pcireg.h

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



CVS commit: src/bin/sh

2021-09-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Sep  9 01:14:04 UTC 2021

Modified Files:
src/bin/sh: parser.c

Log Message:
Fix a bug with here document processing reported on the austin group list
by oguzismailuy...@gmail.com (2021-09-08) (applies to all ash descendant
shells).

There were places in the parser where newline tokens were handled
without reading any pending here documents (leaving those until a
later newline token).

Eg: in
: << do | for x in xxx
do
do echo $x
done

The here doc text (<

CVS commit: src/bin/sh

2021-09-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Sep  9 01:14:04 UTC 2021

Modified Files:
src/bin/sh: parser.c

Log Message:
Fix a bug with here document processing reported on the austin group list
by oguzismailuy...@gmail.com (2021-09-08) (applies to all ash descendant
shells).

There were places in the parser where newline tokens were handled
without reading any pending here documents (leaving those until a
later newline token).

Eg: in
: << do | for x in xxx
do
do echo $x
done

The here doc text (nfor.args = ap;
 			if (lasttoken != TNL && lasttoken != TSEMI)
 synexpect(TSEMI, 0);
+			if (lasttoken == TNL)
+readheredocs();
 		} else {
 			static char argvars[5] = {
 			CTLVAR, VSNORMAL|VSQUOTE, '@', '=', '\0'
@@ -2506,7 +2508,7 @@ STATIC void
 linebreak(void)
 {
 	while (readtoken() == TNL)
-		;
+		readheredocs();
 }
 
 /*



CVS commit: src/tests/bin/sh

2021-09-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Sep  9 00:04:51 UTC 2021

Modified Files:
src/tests/bin/sh: t_here.sh

Log Message:
Add a new test case to check for correct parsing and execution
of a few bizarre here document usages, such as

: << do | for x in xxx
do
do echo $x
done

which should work, but never have done.  (See the source for others).

This test case will currently fail, until the bug is fixed
(already done, to be committed very soon).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_here.sh

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

Modified files:

Index: src/tests/bin/sh/t_here.sh
diff -u src/tests/bin/sh/t_here.sh:1.7 src/tests/bin/sh/t_here.sh:1.8
--- src/tests/bin/sh/t_here.sh:1.7	Tue Jan 22 14:31:53 2019
+++ src/tests/bin/sh/t_here.sh	Thu Sep  9 00:04:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_here.sh,v 1.7 2019/01/22 14:31:53 kre Exp $
+# $NetBSD: t_here.sh,v 1.8 2021/09/09 00:04:51 kre Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -530,6 +530,35 @@ side_effects_body() {
 		'
 }
 
+# The following tests a problem reported on the austin-list 2021-09-08
+# by oguzismailuy...@gmail.com ... it affected all ash derived shells
+atf_test_case hard_cases
+hard_cases_head() {
+	atf_set "descr" \
+		"Tests here docs in positions that have confised our parser"
+}
+hard_cases_body() {
+
+	atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+		: <<- do | for x in xxx
+		do
+		do echo $x
+		done'
+
+	atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+		set -- xxx
+		: <<- done | for x in xxx
+		done
+		do echo $x
+		done'
+
+	atf_check -s exit:0 -o inline:'xxx\n' -e empty ${TEST_SH} -c '
+		: <<- in | case xxx
+		in
+		in xxx) echo xxx;;
+		esac'
+}
+
 atf_test_case vicious
 vicious_head() {
 	atf_set "descr" "Tests for obscure and obnoxious uses of here docs"
@@ -600,5 +629,6 @@ atf_init_test_cases() {
 	atf_add_test_case nested	# here docs inside here docs
 	atf_add_test_case quoting	# stuff quoted inside
 	atf_add_test_case side_effects	# here docs that modify environment
+	atf_add_test_case hard_cases	# here doc bodies appearing mid command
 	atf_add_test_case vicious	# evil test from the austin-l list...
 }



CVS commit: src/tests/bin/sh

2021-09-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Sep  9 00:04:51 UTC 2021

Modified Files:
src/tests/bin/sh: t_here.sh

Log Message:
Add a new test case to check for correct parsing and execution
of a few bizarre here document usages, such as

: << do | for x in xxx
do
do echo $x
done

which should work, but never have done.  (See the source for others).

This test case will currently fail, until the bug is fixed
(already done, to be committed very soon).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_here.sh

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



Re: CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama

On 2021/09/08 20:47, Izumi Tsutsui wrote:

Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


---
-   if (kva) {
+   if (kva)
entry |= PG_V | PG_SH |
((prot & VM_PROT_WRITE) ?
(PG_PR_KRW | PG_D) : PG_PR_KRO);
-   } else {
+   else
entry |= PG_V |
((prot & VM_PROT_WRITE) ?
(PG_PR_URW | PG_D) : PG_PR_URO);
-   }
}
---

This part doesn't match KNF:
  http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58


Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


So I don't think removing existing ones per "redundant" is a valid reason.


Oops, I misread style. These and one more similar braces have been restored.
Thanks for pointing it out!

rin


CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 12:00:50 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Hmm, remove one more parentheses from return.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sh3/sh3/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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.93 src/sys/arch/sh3/sh3/pmap.c:1.94
--- src/sys/arch/sh3/sh3/pmap.c:1.93	Wed Sep  8 11:59:43 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 12:00:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.94 2021/09/08 12:00:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94 2021/09/08 12:00:50 rin Exp $");
 
 #include 
 #include 
@@ -814,7 +814,7 @@ pmap_clear_reference(struct vm_page *pg)
 	int s;
 
 	if ((pvh->pvh_flags & PVH_REFERENCED) == 0)
-		return (false);
+		return false;
 
 	pvh->pvh_flags &= ~PVH_REFERENCED;
 



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 12:00:50 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Hmm, remove one more parentheses from return.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 11:59:43 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Restore braces for if/else statements which have logically single line,
but physically multiple lines.

This is recommended by an example in style:
http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

Thanks tsutsui@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 11:59:43 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Restore braces for if/else statements which have logically single line,
but physically multiple lines.

This is recommended by an example in style:
http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

Thanks tsutsui@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sh3/sh3/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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.92 src/sys/arch/sh3/sh3/pmap.c:1.93
--- src/sys/arch/sh3/sh3/pmap.c:1.92	Wed Sep  8 07:25:55 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 11:59:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $");
 
 #include 
 #include 
@@ -371,14 +371,15 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 			panic("%s: cannot allocate pv", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva)
+		if (kva) {
 			entry |= PG_V | PG_SH |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_KRW | PG_D) : PG_PR_KRO);
-		else
+		} else {
 			entry |= PG_V |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_URW | PG_D) : PG_PR_URO);
+		}
 	}
 
 	/* Register to page table */
@@ -788,9 +789,10 @@ pmap_copy_page(paddr_t src, paddr_t dst)
 		sh_dcache_wbinv_all();
 		memcpy((void *)SH3_PHYS_TO_P2SEG(dst),
 		(void *)SH3_PHYS_TO_P2SEG(src), PAGE_SIZE);
-	} else
+	} else {
 		memcpy((void *)SH3_PHYS_TO_P1SEG(dst),
 		(void *)SH3_PHYS_TO_P1SEG(src), PAGE_SIZE);
+	}
 }
 
 bool



Re: CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Izumi Tsutsui
> Module Name:  src
> Committed By: rin
> Date: Wed Sep  8 07:22:56 UTC 2021
> 
> Modified Files:
>   src/sys/arch/sh3/sh3: pmap.c
> 
> Log Message:
> Redo a part of rev 1.89:
> 
> - Remove redundant parentheses/braces/comments.
> - Fix indents.
> 
> No binary changes confirmed this time.

---
-   if (kva) {
+   if (kva)
entry |= PG_V | PG_SH |
((prot & VM_PROT_WRITE) ?
(PG_PR_KRW | PG_D) : PG_PR_KRO);
-   } else {
+   else
entry |= PG_V |
((prot & VM_PROT_WRITE) ?
(PG_PR_URW | PG_D) : PG_PR_URO);
-   }
}
---

This part doesn't match KNF:
 http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

> Update style around single-line braces according to discussion.
> 
> https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
> https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html
> 
> Retain some examples of technically unnecessary braces that likely
> aid legibility from the previous commit.

So I don't think removing existing ones per "redundant" is a valid reason.

---
Izumi Tsutsui


CVS commit: src/distrib/evbarm/installimage

2021-09-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep  8 11:20:44 UTC 2021

Modified Files:
src/distrib/evbarm/installimage: Makefile

Log Message:
bump for clang/llvm


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/evbarm/installimage/Makefile

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



CVS commit: src/distrib/evbarm/installimage

2021-09-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep  8 11:20:44 UTC 2021

Modified Files:
src/distrib/evbarm/installimage: Makefile

Log Message:
bump for clang/llvm


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/distrib/evbarm/installimage/Makefile

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

Modified files:

Index: src/distrib/evbarm/installimage/Makefile
diff -u src/distrib/evbarm/installimage/Makefile:1.8 src/distrib/evbarm/installimage/Makefile:1.9
--- src/distrib/evbarm/installimage/Makefile:1.8	Mon Feb  8 14:11:41 2021
+++ src/distrib/evbarm/installimage/Makefile	Wed Sep  8 07:20:44 2021
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.8 2021/02/08 19:11:41 martin Exp $
+#	$NetBSD: Makefile,v 1.9 2021/09/08 11:20:44 christos Exp $
 
 .include 
 
 INSTIMGBASE=	NetBSD-${DISTRIBVER}-evbarm-${MACHINE_ARCH}-install	# gives ${IMGBASE}.img
 
-INSTIMAGEMB?=	1550			# for all installation binaries
+INSTIMAGEMB?=	1600			# for all installation binaries
 
 .if !empty(MACHINE_ARCH:Maarch64*)
 EFIBOOT=		${WORKDIR}/usr/mdec/bootaa64.efi



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

2021-09-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  8 11:02:05 UTC 2021

Modified Files:
src/sys/arch/arm/arm: bus_stubs.c

Log Message:
Consider two tags equal if they share the same cookie. For fdtbus,
we may have different tags to deal with mapping attributes and CPU vs bus
address translation, but otherwise represent the same bus space.


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

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

Modified files:

Index: src/sys/arch/arm/arm/bus_stubs.c
diff -u src/sys/arch/arm/arm/bus_stubs.c:1.1 src/sys/arch/arm/arm/bus_stubs.c:1.2
--- src/sys/arch/arm/arm/bus_stubs.c:1.1	Mon Apr 13 07:09:51 2020
+++ src/sys/arch/arm/arm/bus_stubs.c	Wed Sep  8 11:02:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_stubs.c,v 1.1 2020/04/13 07:09:51 maxv Exp $	*/
+/*	$NetBSD: bus_stubs.c,v 1.2 2021/09/08 11:02:05 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,13 +30,18 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_stubs.c,v 1.1 2020/04/13 07:09:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_stubs.c,v 1.2 2021/09/08 11:02:05 jmcneill Exp $");
 
 #include 
 #include 
+#include 
+#include 
 
-#include 
-#include 
+bool
+bus_space_is_equal(bus_space_tag_t t1, bus_space_tag_t t2)
+{
+	return t1->bs_cookie == t2->bs_cookie;
+}
 
 int
 bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,



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

2021-09-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Sep  8 11:02:05 UTC 2021

Modified Files:
src/sys/arch/arm/arm: bus_stubs.c

Log Message:
Consider two tags equal if they share the same cookie. For fdtbus,
we may have different tags to deal with mapping attributes and CPU vs bus
address translation, but otherwise represent the same bus space.


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

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



CVS commit: src/sys/dev/pci/ixgbe

2021-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep  8 09:09:47 UTC 2021

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c

Log Message:
Reduce bus_dmamap_sync() cost.

 - Don't sync whole descriptor ring but limited counts(rx_process_limit)
   descriptors.
 - Dont' sync every loop.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/ixgbe/ix_txrx.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/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.93 src/sys/dev/pci/ixgbe/ix_txrx.c:1.94
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.93	Wed Sep  8 08:46:28 2021
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Sep  8 09:09:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $ */
 
 /**
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.94 2021/09/08 09:09:47 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1804,9 +1804,11 @@ ixgbe_rxeof(struct ix_queue *que)
 	struct ixgbe_rx_buf	*rbuf, *nbuf;
 	int			i, nextp, processed = 0;
 	u32			staterr = 0;
-	u32			loopcount = 0;
+	u32			loopcount = 0, numdesc;
 	u32			limit = adapter->rx_process_limit;
 	bool			discard_multidesc = rxr->discard_multidesc;
+	bool			wraparound = false;
+	unsigned int		syncremain;
 #ifdef RSS
 	u16			pkt_info;
 #endif
@@ -1823,6 +1825,24 @@ ixgbe_rxeof(struct ix_queue *que)
 	}
 #endif /* DEV_NETMAP */
 
+	/* Sync the ring. The size is rx_process_limit or the first half */
+	if ((rxr->next_to_check + limit) <= rxr->num_desc) {
+		/* Non-wraparound */
+		numdesc = limit;
+		syncremain = 0;
+	} else {
+		/* Wraparound. Sync the first half. */
+		numdesc = rxr->num_desc - rxr->next_to_check;
+
+		/* Set the size of the last half */
+		syncremain = limit - numdesc;
+	}
+	bus_dmamap_sync(rxr->rxdma.dma_tag->dt_dmat,
+	rxr->rxdma.dma_map,
+	sizeof(union ixgbe_adv_rx_desc) * rxr->next_to_check,
+	sizeof(union ixgbe_adv_rx_desc) * numdesc,
+	BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+
 	/*
 	 * The max number of loop is rx_process_limit. If discard_multidesc is
 	 * true, continue processing to not to send broken packet to the upper
@@ -1839,9 +1859,22 @@ ixgbe_rxeof(struct ix_queue *que)
 		booleop;
 		booldiscard = false;
 
-		/* Sync the ring. */
-		ixgbe_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map,
-		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+		if (wraparound) {
+			/* Sync the last half. */
+			KASSERT(syncremain != 0);
+			numdesc = syncremain;
+			wraparound = false;
+		} else if (__predict_false(loopcount >= limit)) {
+			KASSERT(discard_multidesc == true);
+			numdesc = 1;
+		} else
+			numdesc = 0;
+
+		if (numdesc != 0)
+			bus_dmamap_sync(rxr->rxdma.dma_tag->dt_dmat,
+			rxr->rxdma.dma_map, 0,
+			sizeof(union ixgbe_adv_rx_desc) * numdesc,
+			BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
 		cur = >rx_base[i];
 		staterr = le32toh(cur->wb.upper.status_error);
@@ -2105,8 +2138,10 @@ next_desc:
 		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 		/* Advance our pointers to the next descriptor. */
-		if (++i == rxr->num_desc)
+		if (++i == rxr->num_desc) {
+			wraparound = true;
 			i = 0;
+		}
 		rxr->next_to_check = i;
 
 		/* Now send to the stack or do LRO */



CVS commit: src/sys/dev/pci/ixgbe

2021-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep  8 09:09:47 UTC 2021

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c

Log Message:
Reduce bus_dmamap_sync() cost.

 - Don't sync whole descriptor ring but limited counts(rx_process_limit)
   descriptors.
 - Dont' sync every loop.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/pci/ixgbe/ix_txrx.c

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



CVS commit: src/sys/dev/pci/ixgbe

2021-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep  8 08:46:29 UTC 2021

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c

Log Message:
Don't pre-allocate a cluster not to do m_freem() it on RXCOPY case.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/ixgbe/ix_txrx.c

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



CVS commit: src/sys/dev/pci/ixgbe

2021-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Sep  8 08:46:29 UTC 2021

Modified Files:
src/sys/dev/pci/ixgbe: ix_txrx.c

Log Message:
Don't pre-allocate a cluster not to do m_freem() it on RXCOPY case.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/pci/ixgbe/ix_txrx.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/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.92 src/sys/dev/pci/ixgbe/ix_txrx.c:1.93
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.92	Tue Sep  7 08:17:20 2021
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Sep  8 08:46:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.92 2021/09/07 08:17:20 msaitoh Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $ */
 
 /**
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.92 2021/09/07 08:17:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.93 2021/09/08 08:46:28 msaitoh Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1837,6 +1837,7 @@ ixgbe_rxeof(struct ix_queue *que)
 		u16 len;
 		u16 vtag = 0;
 		booleop;
+		booldiscard = false;
 
 		/* Sync the ring. */
 		ixgbe_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map,
@@ -1852,7 +1853,7 @@ ixgbe_rxeof(struct ix_queue *que)
 			break;
 
 		loopcount++;
-		sendmp = NULL;
+		sendmp = newmp = NULL;
 		nbuf = NULL;
 		rsc = 0;
 		cur->wb.upper.status_error = 0;
@@ -1876,15 +1877,30 @@ ixgbe_rxeof(struct ix_queue *que)
 			goto next_desc;
 		}
 
-		/* pre-alloc new mbuf */
-		if (!discard_multidesc) {
-			newmp = ixgbe_getcl();
-			if (__predict_false(newmp == NULL))
-rxr->no_mbuf.ev_count++;
-		} else
-			newmp = NULL;
+		if (__predict_false(discard_multidesc))
+			discard = true;
+		else {
+			/* Pre-alloc new mbuf. */
+
+			if ((rbuf->fmp == NULL) &&
+			eop && (len <= adapter->rx_copy_len)) {
+/* For short packet. See below. */
+sendmp = m_gethdr(M_NOWAIT, MT_DATA);
+if (__predict_false(sendmp == NULL)) {
+	rxr->no_mbuf.ev_count++;
+	discard = true;
+}
+			} else {
+/* For long packet. */
+newmp = ixgbe_getcl();
+if (__predict_false(newmp == NULL)) {
+	rxr->no_mbuf.ev_count++;
+	discard = true;
+}
+			}
+		}
 
-		if (__predict_false(newmp == NULL)) {
+		if (__predict_false(discard)) {
 			/*
 			 * Descriptor initialization is already done by the
 			 * above code (cur->wb.upper.status_error = 0).
@@ -1950,8 +1966,10 @@ ixgbe_rxeof(struct ix_queue *que)
 		 * See if there is a stored head
 		 * that determines what we are
 		 */
-		sendmp = rbuf->fmp;
-		if (sendmp != NULL) {  /* secondary frag */
+		if (rbuf->fmp != NULL) {
+			/* Secondary frag */
+			sendmp = rbuf->fmp;
+
 			/* Update new (used in future) mbuf */
 			newmp->m_pkthdr.len = newmp->m_len = rxr->mbuf_sz;
 			IXGBE_M_ADJ(adapter, rxr, newmp);
@@ -1971,35 +1989,20 @@ ixgbe_rxeof(struct ix_queue *que)
 			 * packet.
 			 */
 
-			/*
-			 * Optimize.  This might be a small packet, maybe just
-			 * a TCP ACK. Copy into a new mbuf, and Leave the old
-			 * mbuf+cluster for re-use.
-			 */
-			if (eop && len <= adapter->rx_copy_len) {
-sendmp = m_gethdr(M_NOWAIT, MT_DATA);
-if (sendmp != NULL) {
-	sendmp->m_data += ETHER_ALIGN;
-	memcpy(mtod(sendmp, void *),
-	mtod(mp, void *), len);
-	rxr->rx_copies.ev_count++;
-	rbuf->flags |= IXGBE_RX_COPY;
-
-	/*
-	 * Free pre-allocated mbuf anymore
-	 * because we recycle the current
-	 * buffer.
-	 */
-	m_freem(newmp);
-}
-			}
+			if (eop && (len <= adapter->rx_copy_len)) {
+/*
+ * Optimize.  This might be a small packet, may
+ * be just a TCP ACK. Copy into a new mbuf, and
+ * Leave the old mbuf+cluster for re-use.
+ */
+sendmp->m_data += ETHER_ALIGN;
+memcpy(mtod(sendmp, void *),
+mtod(mp, void *), len);
+rxr->rx_copies.ev_count++;
+rbuf->flags |= IXGBE_RX_COPY;
+			} else {
+/* Non short packet */
 
-			/*
-			 * Two cases:
-			 * a) non small packet(i.e. !IXGBE_RX_COPY).
-			 * b) a small packet but the above m_gethdr() failed.
-			 */
-			if (sendmp == NULL) {
 /* Update new (used in future) mbuf */
 newmp->m_pkthdr.len = newmp->m_len
 = rxr->mbuf_sz;



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:25:55 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sh3/sh3/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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.91 src/sys/arch/sh3/sh3/pmap.c:1.92
--- src/sys/arch/sh3/sh3/pmap.c:1.91	Wed Sep  8 07:22:56 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:25:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $");
 
 #include 
 #include 
@@ -192,7 +192,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 
 	return __pmap_kve;
  error:
-	panic("pmap_growkernel: out of memory.");
+	panic("%s: out of memory", __func__);
 	/* NOTREACHED */
 }
 
@@ -368,7 +368,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		if (__pmap_pv_enter(pmap, pg, va)) {
 			if (flags & PMAP_CANFAIL)
 return ENOMEM;
-			panic("%s: __pmap_pv_enter failed", __func__);
+			panic("%s: cannot allocate pv", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
 		if (kva)
@@ -392,7 +392,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
 			}
-			panic("%s: __pmap_pte_alloc failed", __func__);
+			panic("%s: cannot allocate pte", __func__);
 		}
 	}
 
@@ -666,7 +666,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 
 	switch (prot) {
 	default:
-		panic("pmap_protect: invalid protection mode %x", prot);
+		panic("%s: invalid protection mode %x", __func__, prot);
 		/* NOTREACHED */
 	case VM_PROT_READ:
 	case VM_PROT_READ | VM_PROT_EXECUTE:
@@ -1096,7 +1096,7 @@ __pmap_asid_alloc(void)
 		}
 	}
 
-	panic("No ASID allocated.");
+	panic("%s: no ASID allocated", __func__);
 	/* NOTREACHED */
 }
 



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:25:55 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sh3/sh3/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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.90 src/sys/arch/sh3/sh3/pmap.c:1.91
--- src/sys/arch/sh3/sh3/pmap.c:1.90	Wed Sep  8 07:13:18 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:22:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	va = SH3_PHYS_TO_P1SEG(pa);
 	memset((void *)va, 0, size);
 
-	return (va);
+	return va;
 }
 
 vaddr_t
@@ -162,7 +162,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	int i, n;
 
 	if (maxkvaddr <= __pmap_kve)
-		return (__pmap_kve);
+		return __pmap_kve;
 
 	i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
 	__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,7 +190,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		}
 	}
 
-	return (__pmap_kve);
+	return __pmap_kve;
  error:
 	panic("pmap_growkernel: out of memory.");
 	/* NOTREACHED */
@@ -248,7 +248,7 @@ pmap_create(void)
 		uvm_pagealloc(NULL, 0, NULL,
 			UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-	return (pmap);
+	return pmap;
 }
 
 void
@@ -271,7 +271,7 @@ pmap_destroy(pmap_t pmap)
 			for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
 KDASSERT(*pte == 0);
 		}
-#endif /* DEBUG */
+#endif
 		/* Purge cache entry for next use of this page. */
 		if (SH_HAS_VIRTUAL_ALIAS)
 			sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	struct vm_page *pg;
 	struct vm_page_md *pvh;
 	pt_entry_t entry, *pte;
-	bool kva = (pmap == pmap_kernel());
+	bool kva = pmap == pmap_kernel();
 
 	/* "flags" never exceed "prot" */
 	KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,7 +362,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		/* Check for existing mapping */
 		if (__pmap_map_change(pmap, va, pa, prot, entry))
-			return (0);
+			return 0;
 
 		/* Add to physical-virtual map list of this page */
 		if (__pmap_pv_enter(pmap, pg, va)) {
@@ -371,15 +371,14 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 			panic("%s: __pmap_pv_enter failed", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva) {
+		if (kva)
 			entry |= PG_V | PG_SH |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_KRW | PG_D) : PG_PR_KRO);
-		} else {
+		else
 			entry |= PG_V |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_URW | PG_D) : PG_PR_URO);
-		}
 	}
 
 	/* Register to page table */
@@ -410,7 +409,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		pmap->pm_stats.wired_count++;
 	pmap->pm_stats.resident_count++;
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -428,13 +427,13 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	vaddr_t eva = va + PAGE_SIZE;
 
 	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	((oentry = *pte) == 0))
-		return (false);		/* no mapping exists. */
+	(oentry = *pte) == 0)
+		return false;		/* no mapping exists. */
 
 	if (pa != (oentry & PG_PPN)) {
 		/* Enter a mapping at a mapping to another physical page. */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
 	/* Pre-existing mapping */
@@ -454,10 +453,10 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	} else if (entry & _PG_WIRED) {
 		/* unwired -> wired. make sure to reflect "flags" */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
-	return (true);	/* mapping was changed. */
+	return true;	/* mapping was changed. */
 }
 
 /*
@@ -575,7 +574,7 @@ __pmap_pv_remove(pmap_t pmap, struct vm_
 #ifdef DEBUG
 	/* Check duplicated map. */
 	SLIST_FOREACH(pv, >pvh_head, pv_link)
-	KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+		KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
 #endif
 	splx(s);
 }
@@ -638,17 +637,17 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 	if (pmap == pmap_kernel() && (va >> 30) == 2) {
 		if (pap != NULL)
 			*pap = va & SH3_PHYS_MASK;
-		return (true);
+		return true;
 	}
 
 	pte = __pmap_pte_lookup(pmap, va);
 	if (pte == NULL || *pte == 0)
-		return (false);
+		return false;
 
 	if (pap != NULL)
 		*pap = (*pte & PG_PPN) | (va & PGOFSET);
 
-	return (true);
+	return true;
 }
 
 void
@@ -670,20 +669,17 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 		panic("pmap_protect: 

CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:13:18 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/sh3/sh3/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/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.89 src/sys/arch/sh3/sh3/pmap.c:1.90
--- src/sys/arch/sh3/sh3/pmap.c:1.89	Wed Sep  8 00:35:56 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:13:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	va = SH3_PHYS_TO_P1SEG(pa);
 	memset((void *)va, 0, size);
 
-	return va;
+	return (va);
 }
 
 vaddr_t
@@ -162,7 +162,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	int i, n;
 
 	if (maxkvaddr <= __pmap_kve)
-		return __pmap_kve;
+		return (__pmap_kve);
 
 	i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
 	__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,9 +190,9 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		}
 	}
 
-	return __pmap_kve;
+	return (__pmap_kve);
  error:
-	panic("%s: out of memory", __func__);
+	panic("pmap_growkernel: out of memory.");
 	/* NOTREACHED */
 }
 
@@ -248,7 +248,7 @@ pmap_create(void)
 		uvm_pagealloc(NULL, 0, NULL,
 			UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-	return pmap;
+	return (pmap);
 }
 
 void
@@ -271,7 +271,7 @@ pmap_destroy(pmap_t pmap)
 			for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
 KDASSERT(*pte == 0);
 		}
-#endif
+#endif /* DEBUG */
 		/* Purge cache entry for next use of this page. */
 		if (SH_HAS_VIRTUAL_ALIAS)
 			sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	struct vm_page *pg;
 	struct vm_page_md *pvh;
 	pt_entry_t entry, *pte;
-	bool kva = pmap == pmap_kernel();
+	bool kva = (pmap == pmap_kernel());
 
 	/* "flags" never exceed "prot" */
 	KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,23 +362,24 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		/* Check for existing mapping */
 		if (__pmap_map_change(pmap, va, pa, prot, entry))
-			return 0;
+			return (0);
 
 		/* Add to physical-virtual map list of this page */
 		if (__pmap_pv_enter(pmap, pg, va)) {
 			if (flags & PMAP_CANFAIL)
 return ENOMEM;
-			panic("%s: cannot allocate pv", __func__);
+			panic("%s: __pmap_pv_enter failed", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva)
+		if (kva) {
 			entry |= PG_V | PG_SH |
-			(prot & VM_PROT_WRITE) ?
-			(PG_PR_KRW | PG_D) : PG_PR_KRO;
-		else
+			((prot & VM_PROT_WRITE) ?
+			(PG_PR_KRW | PG_D) : PG_PR_KRO);
+		} else {
 			entry |= PG_V |
-			(prot & VM_PROT_WRITE) ?
-			(PG_PR_URW | PG_D) : PG_PR_URO;
+			((prot & VM_PROT_WRITE) ?
+			(PG_PR_URW | PG_D) : PG_PR_URO);
+		}
 	}
 
 	/* Register to page table */
@@ -392,7 +393,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
 			}
-			panic("%s: cannot allocate pte", __func__);
+			panic("%s: __pmap_pte_alloc failed", __func__);
 		}
 	}
 
@@ -409,7 +410,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		pmap->pm_stats.wired_count++;
 	pmap->pm_stats.resident_count++;
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -427,13 +428,13 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	vaddr_t eva = va + PAGE_SIZE;
 
 	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	(oentry = *pte) == 0)
-		return false;		/* no mapping exists. */
+	((oentry = *pte) == 0))
+		return (false);		/* no mapping exists. */
 
 	if (pa != (oentry & PG_PPN)) {
 		/* Enter a mapping at a mapping to another physical page. */
 		pmap_remove(pmap, va, eva);
-		return false;
+		return (false);
 	}
 
 	/* Pre-existing mapping */
@@ -453,10 +454,10 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	} else if (entry & _PG_WIRED) {
 		/* unwired -> wired. make sure to reflect "flags" */
 		pmap_remove(pmap, va, eva);
-		return false;
+		return (false);
 	}
 
-	return true;	/* mapping was changed. */
+	return (true);	/* mapping was changed. */
 }
 
 /*
@@ -574,7 +575,7 @@ __pmap_pv_remove(pmap_t pmap, struct vm_
 #ifdef DEBUG
 	/* Check duplicated map. */
 	SLIST_FOREACH(pv, >pvh_head, pv_link)
-		

CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:13:18 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/sh3/sh3/pmap.c

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