Re: Make pipes and sockets use KNOTE() instead of selwakeup()

2022-05-23 Thread Visa Hankala
On Tue, Feb 08, 2022 at 09:12:11AM +, Visa Hankala wrote: > Now that poll(2) is based on kqueue, the old, non-MP-safe poll backend > is not used any longer. Event sources can call KNOTE() directly instead > of selwakeup(). > > This diff does the KNOTE() conversion for pi

Lock kernel in nfsrv_rcv()

2022-05-13 Thread Visa Hankala
The NFS subsystem is not MP-safe yet. Take this into account in the NFS server socket upcall by locking the kernel. This might help with the NFS server hanging that was seen recently as a result of the now-reverted selwakeup()-to-KNOTE() conversion. Unfortunately, I have not been able to confirm

Remove fo_poll from struct fileops

2022-05-07 Thread Visa Hankala
Remove unused struct fileops field fo_poll and callbacks. (After this, VOP_POLL() is next in line for removal.) OK? Index: sys/dev/pci/drm/drm_linux.c === RCS file: src/sys/dev/pci/drm/drm_linux.c,v retrieving revision 1.92 diff -u

Re: pluart(4): fifo support

2022-05-01 Thread Visa Hankala
On Sat, Apr 30, 2022 at 09:40:24AM +0200, Anton Lindqvist wrote: > On Sun, Mar 13, 2022 at 04:17:07PM +0100, Mark Kettenis wrote: > > > Date: Fri, 11 Mar 2022 07:53:13 +0100 > > > From: Anton Lindqvist > > > > > > On Tue, Mar 08, 2022 at 01:44:47PM +,

EVFILT_USER and kevent(2)

2022-04-30 Thread Visa Hankala
-user.c diff -N regress/sys/kern/kqueue/kqueue-user.c --- /dev/null 1 Jan 1970 00:00:00 - +++ regress/sys/kern/kqueue/kqueue-user.c 30 Apr 2022 13:33:12 - @@ -0,0 +1,189 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2022 Visa Hankala + * + * Permission to use, copy, modify

Re: Make pipes and sockets use KNOTE() instead of selwakeup()

2022-04-25 Thread Visa Hankala
On Tue, Feb 08, 2022 at 09:12:11AM +, Visa Hankala wrote: > Now that poll(2) is based on kqueue, the old, non-MP-safe poll backend > is not used any longer. Event sources can call KNOTE() directly instead > of selwakeup(). > > This diff does the KNOTE() conversion for pi

Re: Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-04-25 Thread Visa Hankala
On Thu, Apr 21, 2022 at 11:10:40PM +0200, Mark Kettenis wrote: > > Date: Thu, 21 Apr 2022 22:17:31 +0200 > > From: Alexander Bluhm > > > > On Mon, Apr 18, 2022 at 08:33:06AM +, Visa Hankala wrote: > > > I think the sanest solution is to add

Re: Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-04-18 Thread Visa Hankala
On Mon, Mar 14, 2022 at 04:14:47PM +, Visa Hankala wrote: > On Mon, Mar 14, 2022 at 02:01:07AM -0700, Philip Guenther wrote: > > On Mon, Mar 14, 2022 at 12:47 AM Visa Hankala wrote: > > > > > On Sun, Mar 13, 2022 at 06:26:19PM -0700, Philip Guenther wrote: > >

Re: vfs: document (and correct) the protection required for manipulating v_numoutput

2022-04-12 Thread Visa Hankala
On Sun, Mar 27, 2022 at 03:36:20PM +0200, Sebastien Marie wrote: > v_numoutput is a struct member of vnode which is used to keep track the > number > of writes in progress. > > in several function comments, it is marked as "Manipulates v_numoutput. Must > be > called at splbio()". > > So I

Re: Kill selrecord()

2022-04-12 Thread Visa Hankala
On Mon, Apr 11, 2022 at 07:14:46PM +0200, Martin Pieuchot wrote: > Now that poll(2) & select(2) use the kqueue backend under the hood we > can start retiring the old machinery. > > The diff below does not touch driver definitions, however it : > > - kills selrecord() & doselwakeup() > > - make

gpio: Add missing device_unref()

2022-04-10 Thread Visa Hankala
Make gpio(4) release the device reference that device_lookup() takes. OK? Index: dev/gpio/gpio.c === RCS file: src/sys/dev/gpio/gpio.c,v retrieving revision 1.16 diff -u -p -r1.16 gpio.c --- dev/gpio/gpio.c 6 Apr 2022 18:59:28

Re: refcount btrace

2022-04-07 Thread Visa Hankala
On Thu, Apr 07, 2022 at 07:55:11PM +0200, Alexander Bluhm wrote: > On Wed, Mar 23, 2022 at 06:13:27PM +0100, Alexander Bluhm wrote: > > In my opinion tracepoints give insight at minimal cost. It is worth > > it to have it in GENERIC to make it easy to use. > > After release I want to revive the

__read_mostly

2022-03-20 Thread Visa Hankala
Linux uses pseudo-attribute __read_mostly to tag variables that are read frequently but written seldom. These variables are grouped together at link time. This improves cache usage by reducing false sharing. __read_mostly has been adopted by FreeBSD, DragonFly BSD and NetBSD. The former two also

Re: refcount btrace

2022-03-19 Thread Visa Hankala
On Sat, Mar 19, 2022 at 12:10:11AM +0100, Alexander Bluhm wrote: > On Thu, Mar 17, 2022 at 07:25:27AM +0000, Visa Hankala wrote: > > On Thu, Mar 17, 2022 at 12:42:13AM +0100, Alexander Bluhm wrote: > > > I would like to use btrace to debug refernce counting. The idea > >

Re: refcount btrace

2022-03-18 Thread Visa Hankala
On Thu, Mar 17, 2022 at 06:16:51PM +0100, Alexander Bluhm wrote: > On Thu, Mar 17, 2022 at 07:25:27AM +0000, Visa Hankala wrote: > > On Thu, Mar 17, 2022 at 12:42:13AM +0100, Alexander Bluhm wrote: > > > I would like to use btrace to debug refernce counting. The idea > >

Use refcnt API with struct plimit

2022-03-17 Thread Visa Hankala
Use the refcnt API with struct plimit. OK? Index: kern/kern_resource.c === RCS file: src/sys/kern/kern_resource.c,v retrieving revision 1.71 diff -u -p -r1.71 kern_resource.c --- kern/kern_resource.c8 Feb 2021 10:51:01 -

Re: refcount btrace

2022-03-17 Thread Visa Hankala
On Thu, Mar 17, 2022 at 12:42:13AM +0100, Alexander Bluhm wrote: > I would like to use btrace to debug refernce counting. The idea > is to a a tracepoint for every type of refcnt we have. When it > changes, print the actual object, the current counter and the change > value. > Do we want that

Re: Remove data dependency barrier from atomic_load_*

2022-03-17 Thread Visa Hankala
On Wed, Mar 16, 2022 at 11:09:12PM +0100, Alexander Bluhm wrote: > On Tue, Mar 15, 2022 at 09:15:34AM +0000, Visa Hankala wrote: > > However, some DEC Alpha CPUs have their data caches divided into cache > > banks to improve bandwidth. These cache banks are relatively > > in

Use refcnt API with struct ucred

2022-03-16 Thread Visa Hankala
Use the refcnt API with struct ucred. OK? Index: nfs/nfs_socket.c === RCS file: src/sys/nfs/nfs_socket.c,v retrieving revision 1.139 diff -u -p -r1.139 nfs_socket.c --- nfs/nfs_socket.c22 Feb 2022 01:15:02 - 1.139 +++

Use refcnt API in bpf

2022-03-16 Thread Visa Hankala
Use the refcnt API in bpf. OK? Index: net/bpf.c === RCS file: src/sys/net/bpf.c,v retrieving revision 1.215 diff -u -p -r1.215 bpf.c --- net/bpf.c 15 Feb 2022 08:43:50 - 1.215 +++ net/bpf.c 16 Mar 2022 15:42:05 - @@

Use refcnt API in kqueue

2022-03-15 Thread Visa Hankala
Make kqueue use the refcnt API. OK? Index: sys/kern/kern_event.c === RCS file: src/sys/kern/kern_event.c,v retrieving revision 1.183 diff -u -p -r1.183 kern_event.c --- sys/kern/kern_event.c 22 Feb 2022 01:15:01 -

Re: Add refcnt_read()

2022-03-15 Thread Visa Hankala
On Tue, Mar 15, 2022 at 09:11:30AM +, Visa Hankala wrote: > This patch adds a function for getting a snapshot of a reference > counter. This will let code like crcopy() access the value in an > API-observing way. Here is a revised version. Based on input from dlg@, the patch

Remove data dependency barrier from atomic_load_*

2022-03-15 Thread Visa Hankala
This removes the data dependency consumer barrier from the atomic_load_* functions. I think the intent was to keep these functions relaxed in terms of CPU memory order. This makes these functions more agreeable in code that assertions may use, such as the suggested refcnt_read(). Removing the

Add refcnt_read()

2022-03-15 Thread Visa Hankala
This patch adds a function for getting a snapshot of a reference counter. This will let code like crcopy() access the value in an API-observing way. OK? Index: share/man/man9/refcnt_init.9 === RCS file:

Re: Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-03-14 Thread Visa Hankala
On Mon, Mar 14, 2022 at 02:01:07AM -0700, Philip Guenther wrote: > On Mon, Mar 14, 2022 at 12:47 AM Visa Hankala wrote: > > > On Sun, Mar 13, 2022 at 06:26:19PM -0700, Philip Guenther wrote: > > > On Sun, Mar 13, 2022 at 10:27 AM Visa Hankala wrote: > > > > &g

Re: Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-03-14 Thread Visa Hankala
On Sun, Mar 13, 2022 at 06:26:19PM -0700, Philip Guenther wrote: > On Sun, Mar 13, 2022 at 10:27 AM Visa Hankala wrote: > > > On Sun, Mar 13, 2022 at 04:29:44PM +0100, Mark Kettenis wrote: > > > ... > > > > Under what circumstances does memory ordering

Re: Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-03-13 Thread Visa Hankala
On Sun, Mar 13, 2022 at 04:29:44PM +0100, Mark Kettenis wrote: > > Date: Sun, 13 Mar 2022 12:47:13 + > > From: Visa Hankala > > > > This makes the refcnt implementation issue memory barriers when > > releasing references, splitting memory activity cleanly int

Provide memory barriers in refcnt_rele() and refcnt_finalize()

2022-03-13 Thread Visa Hankala
This makes the refcnt implementation issue memory barriers when releasing references, splitting memory activity cleanly into preceding and succeeding stages around refcnt 1->0 transition. I think the while loop could be optimized a little by re-reading r->r_refs just after sleep_finish(). That

Provide memory barriers in FRELE()

2022-03-13 Thread Visa Hankala
This is a slightly tweaked version of the FRELE() memory barrier patch. The barriers aim to provide clearer memory access behaviour around the f_count 1->0 transition. With the barriers, the transition splits the memory activity into preceding and succeeding stages that do not overlap. OK?

Re: atomic read write

2022-03-11 Thread Visa Hankala
On Fri, Mar 11, 2022 at 11:51:31AM +0100, Alexander Bluhm wrote: > On Fri, Mar 11, 2022 at 05:32:11AM +0000, Visa Hankala wrote: > > On Thu, Mar 10, 2022 at 07:17:43PM +0100, Alexander Bluhm wrote: > > > On Thu, Mar 10, 2022 at 04:39:49PM +0100, Alexander Bluhm wrote: > >

Re: atomic read write

2022-03-10 Thread Visa Hankala
On Thu, Mar 10, 2022 at 07:17:43PM +0100, Alexander Bluhm wrote: > On Thu, Mar 10, 2022 at 04:39:49PM +0100, Alexander Bluhm wrote: > > > Below is a patch that shows how to accomplish release semantics with > > > the file and refcnt APIs. (The added memory barriers ensure that the > > > CPU

Re: atomic read write

2022-03-10 Thread Visa Hankala
On Thu, Mar 10, 2022 at 10:45:47AM +, Laurence Tratt wrote: > On Thu, Mar 10, 2022 at 09:05:54AM +0000, Visa Hankala wrote: > > Hello Visa, > > > In general, atomic_* functions have not provided implicit memory > > barriers on OpenBSD. > > I've used atomi

Re: atomic read write

2022-03-10 Thread Visa Hankala
On Wed, Mar 09, 2022 at 08:45:35PM +0100, Alexander Bluhm wrote: > On Tue, Mar 08, 2022 at 04:55:56PM +0100, Alexander Bluhm wrote: > > Once we had the discussion where we need the READ_ONCE() macro. As > > modern C compiler has much freedom how to access memory, I came to > > the conclusion that

Re: Add kernel stack trace saving for riscv64

2022-03-09 Thread Visa Hankala
On Wed, Mar 09, 2022 at 08:40:50AM +0100, Jeremie Courreges-Anglas wrote: > On Tue, Mar 08 2022, Visa Hankala wrote: > > This patch adds kernel stack trace saving for riscv64, for the benefit > > of dt(4) and witness(4). > > Nice! > > > The unwinder is slow be

Add kernel stack trace saving for riscv64

2022-03-08 Thread Visa Hankala
This patch adds kernel stack trace saving for riscv64, for the benefit of dt(4) and witness(4). The unwinder is slow because of the symbol lookup, but this can be tweaked later. The limit variable prevents the unwinder from using user-controllable register values. The limit has to reflect the

Re: pluart(4): fifo support

2022-03-08 Thread Visa Hankala
On Tue, Mar 08, 2022 at 08:04:36AM +0100, Anton Lindqvist wrote: > On Mon, Mar 07, 2022 at 07:36:35AM +0000, Visa Hankala wrote: > > I still think that checking TXFF and using the same code for both > > SBSA and true PL011 UARTs would be the best choice. This would avoid > >

Re: pluart(4): fifo support

2022-03-06 Thread Visa Hankala
On Wed, Mar 02, 2022 at 07:25:36AM +0100, Anton Lindqvist wrote: > On Tue, Mar 01, 2022 at 01:41:10PM +0000, Visa Hankala wrote: > > On Tue, Mar 01, 2022 at 07:08:51AM +0100, Anton Lindqvist wrote: > > > On Sun, Feb 27, 2022 at 05:33:17PM +0100, Mark Kettenis wrote: > >

Re: Fix deadlock in cad_down()

2022-03-02 Thread Visa Hankala
On Wed, Mar 02, 2022 at 12:11:30PM +0100, Mark Kettenis wrote: > > Date: Wed, 2 Mar 2022 10:53:54 + > > From: Visa Hankala > > > > Holding NET_LOCK() while invoking a taskq barrier can result in > > a deadlock because the lock can prevent the taskq f

Fix deadlock in cad_down()

2022-03-02 Thread Visa Hankala
Holding NET_LOCK() while invoking a taskq barrier can result in a deadlock because the lock can prevent the taskq from making progress. Avoid this problem in cad_down() by serializing the driver's ioctl handler with an rwlock so that NET_LOCK() can be released temporarily. The patch additionally

Re: pluart(4): fifo support

2022-03-01 Thread Visa Hankala
On Tue, Mar 01, 2022 at 07:08:51AM +0100, Anton Lindqvist wrote: > On Sun, Feb 27, 2022 at 05:33:17PM +0100, Mark Kettenis wrote: > > > Date: Sun, 27 Feb 2022 16:01:25 +0100 > > > From: Anton Lindqvist > > > > > > r1p5 is revision 3 with a 32 bytes FIFO. My only concern is that the > > >

Re: pluart(4): fifo support

2022-02-27 Thread Visa Hankala
On Sun, Feb 27, 2022 at 09:56:38AM +0100, Anton Lindqvist wrote: > On Sun, Feb 27, 2022 at 06:19:02AM +0000, Visa Hankala wrote: > > On Sat, Feb 26, 2022 at 08:40:25AM +0100, Anton Lindqvist wrote: > > > Hi, > > > This enables fifo support in pluart(4). While here, I c

Re: pluart(4): fifo support

2022-02-26 Thread Visa Hankala
On Sat, Feb 26, 2022 at 08:40:25AM +0100, Anton Lindqvist wrote: > Hi, > This enables fifo support in pluart(4). While here, I changed the > attachment output to look more like com(4). Tested on my rpi3b which has > a 16 byte fifo. > > Comments? OK? > > diff --git sys/dev/ic/pluart.c

Re: assert "sc->sc_dev == NUM" failed in if_tun.c (2)

2022-02-24 Thread Visa Hankala
On Thu, Feb 24, 2022 at 07:39:54PM +1000, David Gwynne wrote: > claudio and i came up with the following, which is to have tun_dev_open > check the state of the vnode associated with the current open call > after all the sleeping and potential tun_clone_destroy and > tun_clone_create calls. if the

Re: Fix kernel stack alignment on riscv64

2022-02-23 Thread Visa Hankala
So far this patch has worked fine on my test system. On Tue, Feb 22, 2022 at 06:41:31PM +, Visa Hankala wrote: > Index: arch/riscv64/include/frame.h > === > RCS file: src/sys/arch/riscv64/include/frame.h,v > retriev

Re: Fix kernel stack alignment on riscv64

2022-02-22 Thread Visa Hankala
On Tue, Feb 22, 2022 at 07:04:23PM +0100, Mark Kettenis wrote: > > Date: Tue, 22 Feb 2022 17:45:26 + > > From: Visa Hankala > > > > On Tue, Feb 22, 2022 at 06:13:54PM +0100, Mark Kettenis wrote: > > > > Date: Tue, 22 Feb 2022 16:59:24 + > > >

Re: Fix kernel stack alignment on riscv64

2022-02-22 Thread Visa Hankala
On Tue, Feb 22, 2022 at 06:13:54PM +0100, Mark Kettenis wrote: > > Date: Tue, 22 Feb 2022 16:59:24 + > > From: Visa Hankala > > > > On Tue, Feb 22, 2022 at 05:31:31PM +0100, Mark Kettenis wrote: > > > > Date: Tue, 22 Feb 2022 15:58

Re: Fix kernel stack alignment on riscv64

2022-02-22 Thread Visa Hankala
On Tue, Feb 22, 2022 at 05:31:31PM +0100, Mark Kettenis wrote: > > Date: Tue, 22 Feb 2022 15:58:31 + > > From: Visa Hankala > > > > The standard RISC-V calling convention says that the stack pointer > > should be 16-byte aligned. > > > > The patch

Fix kernel stack alignment on riscv64

2022-02-22 Thread Visa Hankala
The standard RISC-V calling convention says that the stack pointer should be 16-byte aligned. The patch below corrects the alignment of the kernel stack in context switching and exception handling. OK? The diff reveals that curcpu is stored in an unnamed spot near the upper end of u-area when

Zero frame pointer in cpu_fork() on riscv64

2022-02-21 Thread Visa Hankala
When setting up the stack for a (kernel) thread on riscv64, zero the frame pointer in switchframe so that the frame chain terminates cleanly. At the moment, the unwinding of kernel thread stacks stops to "bad frame pointer" error. OK? Index: arch/riscv64/riscv64/cpuswitch.S

Improve ddb's stack trace printing on riscv64

2022-02-21 Thread Visa Hankala
On riscv64, ddb's stack unwinder performs poorly. The main problem is that the exception handlers use a frame structure (trapframe) that differs from the typical call frame. The following patch does several adjustments, including: * Detect and handle exception frames. (Alternatively, the

Use installboot(8) in armv7 install.md

2022-02-18 Thread Visa Hankala
Use installboot(8) in armv7 install.md. OK? Index: distrib/armv7/ramdisk/install.md === RCS file: src/distrib/armv7/ramdisk/install.md,v retrieving revision 1.51 diff -u -p -r1.51 install.md --- distrib/armv7/ramdisk/install.md7

Re: Driver for PolarFire SoC MSS GPIO controller

2022-02-17 Thread Visa Hankala
On Thu, Feb 17, 2022 at 09:23:14AM -0700, Theo de Raadt wrote: > I am terrified by existance of the userland gpio interface, basically > the concept that users should be able to change some pin is more than > suspect, it is crazy. It completely violates the Unix principle of > mapping hardware

Re: Driver for PolarFire SoC MSS GPIO controller

2022-02-17 Thread Visa Hankala
On Thu, Feb 17, 2022 at 03:38:05PM +0100, Mark Kettenis wrote: > > Date: Thu, 17 Feb 2022 13:52:39 + > > From: Visa Hankala > > > > This patch adds a driver for the PolarFire SoC MSS GPIO controller. > > > > The driver provides a gpio(4) interface, so

Driver for PolarFire SoC MSS GPIO controller

2022-02-17 Thread Visa Hankala
.4 MANSUBDIR=riscv64 Index: share/man/man4/man4.riscv64/mpfgpio.4 === RCS file: share/man/man4/man4.riscv64/mpfgpio.4 diff -N share/man/man4/man4.riscv64/mpfgpio.4 --- /dev/null 1 Jan 1970 00:00:00 - +++ share/man/man4/man4.riscv64/mpfgpio.4 17 Feb 2022 13:45:09 -0000 @@ -0,

Make audio(4) event filters MP-safe

2022-02-16 Thread Visa Hankala
The following patch makes audio(4) event filters MP-safe. The knote lists are already serialized by audio_lock. By adding klist init calls, the lock becomes visible to the lock assertion in knote(). The new f_modify and f_process callbacks cover the knote handling with audio_lock. This also

Re: Driver for PolarFire SoC MSS I2C controller

2022-02-16 Thread Visa Hankala
On Tue, Feb 15, 2022 at 10:58:02PM +0100, Mark Kettenis wrote: > > +int > > +mpfiic_i2c_send_stop(void *cookie, int flags) > > +{ > > + struct mpfiic_softc *sc = cookie; > > + > > + sc->sc_start_sent = 0; > > + > > + HWRITE4(sc, I2C_CTRL, sc->sc_ctrl | I2C_CTRL_STO); > > + > > + /* Let a

Re: prevent opening of dead tun/tap devices

2022-02-14 Thread Visa Hankala
On Tue, Feb 15, 2022 at 02:35:33PM +1000, David Gwynne wrote: > if an open tun (or tap) device is destroyed via ifconfig destroy, > there is a window while the open device is being revoked on the vfs > side that a third thread can come and open it again. this in turn > triggers a kassert in the

Driver for PolarFire SoC MSS I2C controller

2022-02-14 Thread Visa Hankala
-- /dev/null 1 Jan 1970 00:00:00 - +++ share/man/man4/man4.riscv64/mpfiic.414 Feb 2022 17:40:53 - @@ -0,0 +1,40 @@ +.\"$OpenBSD$ +.\" +.\" Copyright (c) 2022 Visa Hankala +.\" +.\" Permission to use, copy, modify, and distribute this software for any

Adjust bpf event filter

2022-02-14 Thread Visa Hankala
This makes bpf(4) use knote_modify_fn() and knote_process_fn(). Since the code has only one event function, it makes sense to use it directly instead of going through struct filterops f_event pointer. OK? Index: net/bpf.c === RCS

Unify f_modify and f_process event filter callbacks for FIFOs

2022-02-14 Thread Visa Hankala
This patch unifies f_modify and f_process event filter callbacks for FIFOs. This is similar to recent sys_pipe.c changes. In addition, the patch adds missing flag FILTEROP_MPSAFE to fifoexcept_filtops. OK? Index: miscfs/fifofs/fifo_vnops.c

Unify f_modify and f_process event filter callbacks for sockets

2022-02-14 Thread Visa Hankala
This patch unifies f_modify and f_process event filter callbacks for sockets. This is similar to recent sys_pipe.c changes. OK? Index: kern/uipc_socket.c === RCS file: src/sys/kern/uipc_socket.c,v retrieving revision 1.272 diff -u

Embed klist head in acpi_softc

2022-02-09 Thread Visa Hankala
This embeds klist head in struct acpi_softc so that explicit malloc is not needed. The head is initialized as part of acpi_softc allocation. OK? Index: dev/acpi/acpi.c === RCS file: src/sys/dev/acpi/acpi.c,v retrieving revision

Unify f_modify and f_process event filter callbacks for pipes

2022-02-08 Thread Visa Hankala
The current code pattern used with MP-safe event filters is verbose. I would like to find a more concise form before making more event filters MP-safe. Of struct filterops callbacks, f_modify and f_process essentially use f_event. By utilizing the f_event function pointer, a subsystem can have

Re: Increase armv7 ramdisk size

2022-02-08 Thread Visa Hankala
On Mon, Feb 07, 2022 at 09:35:21AM -0700, Theo de Raadt wrote: > Please don't do such a small increase, because it is likely we'll need to > do it again the near future. > > I suggest taking ns#600 to ns#650 or ns#700, and adjusting all the numbers. Here is a diff that uses ns#700. OK? Index:

Make pipes and sockets use KNOTE() instead of selwakeup()

2022-02-08 Thread Visa Hankala
Now that poll(2) is based on kqueue, the old, non-MP-safe poll backend is not used any longer. Event sources can call KNOTE() directly instead of selwakeup(). This diff does the KNOTE() conversion for pipes and sockets, removing a kernel-locked section from a frequently used code path. The

Adjust KNOTE() macro

2022-02-07 Thread Visa Hankala
There is a discrepancy between the KNOTE() macro and its manual page entry. KNOTE() calls knote() if the list argument non-NULL. The manual page says that knote() is called if the list is non-empty. The manual page's notion originates from NetBSD. It differs from FreeBSD. I think the call on

Increase armv7 ramdisk size

2022-02-07 Thread Visa Hankala
armv7 ramdisk is very low on space. Building the ramdisk succeeds, but the installer prints errors: uid 0 on /: file system full /: write failed, file system is full sed: stdout: No space left on device OK to increase? Index: etc/etc.armv7/disktab

Re: Use installboot(8) in install.md of riscv64

2022-02-03 Thread Visa Hankala
On Thu, Feb 03, 2022 at 03:43:00PM +0100, Mark Kettenis wrote: > > Date: Thu, 3 Feb 2022 13:58:21 + > > From: Visa Hankala > > > > On Wed, Feb 02, 2022 at 01:23:56PM -0700, Theo de Raadt wrote: > > > Miod Vallat wrote: > > > > > >

Allow GPT partitioning when installing riscv64

2022-02-03 Thread Visa Hankala
This patch allows GPT partitioning when installing a riscv64 system. Currently, the install.md insists on using MBR. The patch also adds fdisk -A when a BIOS boot partition is found. The PolarFire SoC HSS firmware uses the partition to load boot code. OK? Index: distrib/miniroot/install.sub

Re: Use installboot(8) in install.md of riscv64

2022-02-03 Thread Visa Hankala
On Wed, Feb 02, 2022 at 01:23:56PM -0700, Theo de Raadt wrote: > Miod Vallat wrote: > > > > Index: usr.sbin/installboot/armv7_installboot.c > > > === > > > RCS file: src/usr.sbin/installboot/armv7_installboot.c,v > > > retrieving

Re: Use installboot(8) in install.md of riscv64

2022-02-02 Thread Visa Hankala
On Tue, Feb 01, 2022 at 10:55:03AM -0700, Theo de Raadt wrote: > Mark Kettenis wrote: > > > Maybe we should rename the file to efi_installboot.c and/or rearrange > > the code slightly such that is becomes more obvious that the name of > > the file is indeed the only difference. > > And

Use installboot(8) in install.md of riscv64

2022-02-01 Thread Visa Hankala
This makes the installer use installboot(8) on riscv64. OK? Index: riscv64/ramdisk/install.md === RCS file: src/distrib/riscv64/ramdisk/install.md,v retrieving revision 1.3 diff -u -p -r1.3 install.md --- riscv64/ramdisk/install.md

Re: in4_cksum changes, step 1

2022-02-01 Thread Visa Hankala
On Mon, Jan 31, 2022 at 07:40:34PM +, Miod Vallat wrote: > > The register is set to -1, all bits set, and then its upper half > > is cleared. Now that the "and" has been removed, the value seems > > unused. The result of the removed "and" seemed unused too. > > Oh, indeed, you're right, that

fdisk: Preserve BIOS boot partition with -A

2022-01-31 Thread Visa Hankala
This patch makes fdisk -A preserve BIOS boot partition. When PolarFire SoC boots, the Hart Software Services (HSS) firmware loads HSS payload that contains U-Boot (and possibly OpenSBI) from eMMC or SD card. If there is a valid GPT header, the payload is loaded from GPT partition with type

Re: in4_cksum changes, step 1

2022-01-31 Thread Visa Hankala
On Sun, Jan 30, 2022 at 06:37:39PM +, Miod Vallat wrote: > > > - sum += in_cksumdata((caddr_t) , sizeof(ipov)); > > > + sum += in_cksumdata((caddr_t) + 8, sizeof(ipov) - 8); > > > > I think this would be clearer with a comment. > > Sure, added one. > > > Please remove the

Re: in4_cksum changes, step 1

2022-01-28 Thread Visa Hankala
On Tue, Jan 25, 2022 at 08:23:18PM +, Miod Vallat wrote: > in4_cksum(), used to compute packet checksums for the legacy internet > protocol, has been hand-optimized for speed on most elderly platforms, > with the most recent pieces of silicon using a portable C > implementation. > > Most of

cad(4): Disable extra queues

2022-01-24 Thread Visa Hankala
9 09:19:42 patrick Exp $ */ /* - * Copyright (c) 2021 Visa Hankala + * Copyright (c) 2021-2022 Visa Hankala * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -173,8 +173,22 @@ #define GEM

Fix cpuid bugs in plic(4)

2022-01-17 Thread Visa Hankala
This fixes two bugs in plic(4). When a particular CPU is not found, typically when running GENERIC or RAMDISK on a multiprocessor machine, plic_get_cpuid() returns -1. In that case plic_attach() should just ignore the entry and move on. The `cpu' variable should also be signed, otherwise the

Re: don't try and wakeup select/poll/kq in tun/bpf close

2022-01-15 Thread Visa Hankala
On Sun, Jan 16, 2022 at 02:41:46PM +1000, David Gwynne wrote: > if you're in bpfclose or tun/tap close, you're the last one out. this > means that there shouldn't be anything else in poll/select/kevent/etc > because you're the last one out. > > from what i can tell, tun and bpf are the only

Re: Fix a bug in sfcc_cache_wbinv_range()

2022-01-15 Thread Visa Hankala
On Sat, Jan 15, 2022 at 01:34:35PM +0100, Mark Kettenis wrote: > > Date: Sat, 15 Jan 2022 12:21:59 + > > From: Visa Hankala > > > > If the ending address in sfcc_cache_wbinv_range(), pa + len, is not > > cache-line-aligned, the function spins because len wraps a

Re: Fix a bug in sfcc_cache_wbinv_range()

2022-01-15 Thread Visa Hankala
On Sat, Jan 15, 2022 at 11:54:00PM +1100, Jonathan Gray wrote: > On Sat, Jan 15, 2022 at 12:21:59PM +0000, Visa Hankala wrote: > > If the ending address in sfcc_cache_wbinv_range(), pa + len, is not > > cache-line-aligned, the function spins because len wraps around. > > The

Fix a bug in sfcc_cache_wbinv_range()

2022-01-15 Thread Visa Hankala
If the ending address in sfcc_cache_wbinv_range(), pa + len, is not cache-line-aligned, the function spins because len wraps around. The following patch fixes this. There still is a subtle detail. If len is zero but pa is non-aligned, the function is not a no-op. However, shouldn't upper layers

Driver for Cadence SD/SDIO/eMMC host controller

2022-01-14 Thread Visa Hankala
+1,40 @@ +.\"$OpenBSD$ +.\" +.\" Copyright (c) 2022 Visa Hankala +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this per

Re: clang: compile static analyzer

2022-01-14 Thread Visa Hankala
On Fri, Jan 14, 2022 at 03:17:21PM +0100, Tobias Heider wrote: > Hi, > > clang ships with a pretty useful static analyzer to find all kinds of bugs > in C and C++ code: > > https://clang-analyzer.llvm.org/ > > I use it regularly to check my own diffs and found plenty of bugs I could > have

Avoid dead store to `f' in libsa readdir()

2022-01-10 Thread Visa Hankala
This removes a dead store to variable `f' from libsa's readdir(), which also avoids suspicious use of `fd' without validation. OK? Index: lib/libsa/readdir.c === RCS file: src/sys/lib/libsa/readdir.c,v retrieving revision 1.9 diff

Re: sdmmc: fix malloc error handling in sdmmc_mem_send_scr()

2022-01-10 Thread Visa Hankala
On Mon, Jan 10, 2022 at 04:35:41PM +0100, Tobias Heider wrote: > On Mon, Jan 10, 2022 at 04:20:36PM +0100, Stefan Sperling wrote: > > On Mon, Jan 10, 2022 at 03:50:45PM +0100, Tobias Heider wrote: > > > Makes sense. I also fixed the one in sdmmc_mem_send_cxd_data(). > > > > Doesn't build here,

Re: sdmmc: fix malloc error handling in sdmmc_mem_send_scr()

2022-01-10 Thread Visa Hankala
On Mon, Jan 10, 2022 at 03:21:49PM +0100, Tobias Heider wrote: > On Mon, Jan 10, 2022 at 01:41:53PM +0000, Visa Hankala wrote: > > On Mon, Jan 10, 2022 at 01:12:10PM +0100, Tobias Heider wrote: > > > sdmmc_mem_send_scr() tries to malloc() with M_NOWAIT and returns 0 on > &g

Re: sdmmc: fix malloc error handling in sdmmc_mem_send_scr()

2022-01-10 Thread Visa Hankala
On Mon, Jan 10, 2022 at 01:12:10PM +0100, Tobias Heider wrote: > sdmmc_mem_send_scr() tries to malloc() with M_NOWAIT and returns 0 on > error, which leads to sdmmc_mem_sd_init() passing uninitialized stack > memory to sdmmc_mem_decode_scr(). > The diff below makes sdmmc_mem_send_scr() return

Add sdhc attribute

2022-01-07 Thread Visa Hankala
This adds attribute `sdhc' to sys/conf/files so that non-glue code, such as mvpxa(4), can indicate the sdhc dependency. OK? Index: arch/armv7/marvell/files.marvell === RCS file: src/sys/arch/armv7/marvell/files.marvell,v retrieving

Re: patch: add a new ktrace facility for replacing some printf-debug

2022-01-07 Thread Visa Hankala
On Fri, Jan 07, 2022 at 10:54:54AM +0100, Sebastien Marie wrote: > Debugging some code paths is complex: for example, unveil(2) code is > involved inside VFS, and using DEBUG_UNVEIL means that the kernel is > spamming printf() for all processes using unveil(2) (a lot of > processes) instead of

Re: Driver for PolarFire SoC clock controller

2022-01-04 Thread Visa Hankala
On Mon, Jan 03, 2022 at 08:44:22PM +0100, Mark Kettenis wrote: > > Date: Mon, 3 Jan 2022 16:31:29 + > > From: Visa Hankala > > > > This adds an initial driver for the PolarFire SoC MSS clock controller. > > > > The driver also provides a reset

Driver for PolarFire SoC clock controller

2022-01-03 Thread Visa Hankala
yright (c) 2022 Visa Hankala +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" TH

Make bpf event filter MP-safe

2021-12-28 Thread Visa Hankala
This patch makes bpf(4) serialize its event filter using bd_mtx, which allows calling the filter without the kernel lock. The patch uses the same filter pattern that has been utilized with pipes and sockets. Note that bpfkqfilter() still runs with the kernel locked. I think bpfilter_lookup()

Re: Revised version of kqueue-based poll(2)

2021-12-25 Thread Visa Hankala
On Tue, Nov 30, 2021 at 03:11:16PM +, Visa Hankala wrote: > Here is a revised version of kqueue-based poll(2). > > The two most important changes to the previous version are: > > * Properly handle pollfd arrays where more than one entries refer > to the same file desc

Handle knotes whose vnodes have been revoked

2021-12-23 Thread Visa Hankala
The system revokes open files for a tty device when the device is being reused. The revoking has applied to the old poll/select implementations sort of automagically because the scan code has always (re)walked the path from file to vnode to device. With kqueue, the rewalking does not happen in

Adjust filt_solisten for poll and select

2021-12-23 Thread Visa Hankala
The listen version of EVFILT_READ for sockets differs somewhat from the code in soo_poll(). The following patch adds a poll/select branch to make the listen filter more consistent with the old code. OK? Index: kern/uipc_socket.c ===

Re: Event filter adjustments for ttys

2021-12-14 Thread Visa Hankala
On Sat, Dec 11, 2021 at 01:47:41PM +, Visa Hankala wrote: > This adds EVFILT_EXCEPT handler for ttys to let kqueue-based poll(2) > detect POLLHUP when pollfd.event == 0. > > filt_ttywrite(), and also filt_ptcwrite(), appear to lack HUP detection. > Has this been intentional?

Handle multi-port CP2108 devices in uslcom(4)

2021-12-12 Thread Visa Hankala
Silicon Labs CP2108 USB device can implement up to four COM ports. Each port appears as a separate USB virtual COM interface under the device. Currently, uslcom(4) always uses the device's first interface, which is wrong when there are multiple ports. The following patch adjusts the driver to use

Event filter adjustments for ttys

2021-12-11 Thread Visa Hankala
This adds EVFILT_EXCEPT handler for ttys to let kqueue-based poll(2) detect POLLHUP when pollfd.event == 0. filt_ttywrite(), and also filt_ptcwrite(), appear to lack HUP detection. Has this been intentional? The poll(2) emulation would need the HUP bits if feature similarity to ttpoll(), and

Re: Adjust socket and FIFO's EVFILT_EXCEPT

2021-12-11 Thread Visa Hankala
On Mon, Dec 06, 2021 at 05:17:21PM +, Visa Hankala wrote: > This patch adjusts the EVFILT_EXCEPT code of sockets and FIFOs so that > it would raise the HUP condition only when the channel has been closed > from both sides. This should match better with the POLLHUP case of &

  1   2   3   4   >