sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-12 06:29:20 +00:00
parent b321f55ead
commit 302c0be22f
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
43 changed files with 456 additions and 132 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpi.c,v 1.436 2024/07/30 19:47:06 mglocker Exp $ */
/* $OpenBSD: acpi.c,v 1.437 2024/08/10 23:28:17 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@ -2591,8 +2591,6 @@ acpi_resume_pm(struct acpi_softc *sc, int fromstate)
acpi_disable_allgpes(sc);
acpi_enable_rungpes(sc);
acpi_indicator(sc, ACPI_SST_WAKING);
/* 2nd resume AML step: _WAK(fromstate) */
aml_node_setval(sc, sc->sc_wak, fromstate);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpi_x86.c,v 1.25 2024/08/08 07:02:38 kettenis Exp $ */
/* $OpenBSD: acpi_x86.c,v 1.29 2024/08/11 17:30:28 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@ -80,7 +80,6 @@ sleep_setstate(void *v)
if (aml_node_setval(sc, sc->sc_pts, sc->sc_state) != 0)
return (EINVAL);
}
acpi_indicator(sc, ACPI_SST_WAKING); /* blink */
return 0;
}
@ -126,6 +125,7 @@ gosleep(void *v)
if (sc->sc_pmc_resume)
sc->sc_pmc_resume(sc->sc_pmc_cookie);
acpi_indicator(sc, ACPI_SST_WAKING); /* blink */
return ret;
}
@ -143,7 +143,6 @@ sleep_resume(void *v)
if (aml_node_setval(sc, sc->sc_tts, ACPI_STATE_S0) != 0)
return (EINVAL);
}
acpi_indicator(sc, ACPI_SST_WAKING); /* blink */
return 0;
}

View file

@ -2080,7 +2080,6 @@ inteldrm_doswitch(void *v)
{
struct inteldrm_softc *dev_priv = v;
struct rasops_info *ri = &dev_priv->ro;
struct drm_device *dev = &dev_priv->drm;
rasops_show_screen(ri, dev_priv->switchcookie, 0, NULL, NULL);
intel_fbdev_restore_mode(dev_priv);
@ -2094,7 +2093,6 @@ inteldrm_enter_ddb(void *v, void *cookie)
{
struct inteldrm_softc *dev_priv = v;
struct rasops_info *ri = &dev_priv->ro;
struct drm_device *dev = &dev_priv->drm;
if (cookie == ri->ri_active)
return;
@ -2252,11 +2250,9 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
struct drm_device *dev;
struct pci_attach_args *pa = aux;
const struct pci_device_id *id;
struct intel_device_info *info, *device_info;
struct intel_runtime_info *runtime;
struct intel_device_info *info;
extern int vga_console_attached;
int mmio_bar, mmio_size, mmio_type;
int ret;
dev_priv->pa = pa;
dev_priv->pc = pa->pa_pc;
@ -2309,8 +2305,10 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
/* uc_expand_default_options() with no GuC submission */
if (GRAPHICS_VER(dev_priv) >= 12 &&
!IS_TIGERLAKE(dev_priv) && !IS_ROCKETLAKE(dev_priv) &&
!IS_XEHPSDV(dev_priv) && !IS_PONTEVECCHIO(dev_priv))
(INTEL_INFO(dev_priv)->platform != INTEL_TIGERLAKE) &&
(INTEL_INFO(dev_priv)->platform != INTEL_ROCKETLAKE) &&
(INTEL_INFO(dev_priv)->platform != INTEL_XEHPSDV) &&
(INTEL_INFO(dev_priv)->platform != INTEL_PONTEVECCHIO))
dev_priv->params.enable_guc = ENABLE_GUC_LOAD_HUC;
mmio_bar = (GRAPHICS_VER(dev_priv) == 2) ? 0x14 : 0x10;
@ -2394,8 +2392,10 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
void
inteldrm_forcedetach(struct inteldrm_softc *dev_priv)
{
#ifdef notyet
struct pci_softc *psc = (struct pci_softc *)dev_priv->sc_dev.dv_parent;
pcitag_t tag = dev_priv->tag;
#endif
extern int vga_console_attached;
if (dev_priv->primary) {
@ -2420,7 +2420,6 @@ inteldrm_attachhook(struct device *self)
struct rasops_info *ri = &dev_priv->ro;
struct wsemuldisplaydev_attach_args aa;
const struct pci_device_id *id = dev_priv->id;
struct drm_device *dev = &dev_priv->drm;
int orientation_quirk;
if (inteldrm_refcnt == 0) {
@ -2629,7 +2628,6 @@ inteldrm_firmware_backlight(struct inteldrm_softc *dev_priv,
void
inteldrm_init_backlight(struct inteldrm_softc *dev_priv)
{
struct drm_device *dev = &dev_priv->drm;
struct wsdisplay_param dp;
dp.param = WSDISPLAYIO_PARAM_BRIGHTNESS;

View file

@ -10,6 +10,7 @@
struct resource {
u_long start;
u_long end;
const char *name;
};
static inline resource_size_t
@ -22,6 +23,7 @@ resource_size(const struct resource *r)
(struct resource) { \
.start = (_start), \
.end = (_start) + (_size) - 1, \
.name = NULL, \
}
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_igc.c,v 1.26 2024/08/08 14:58:49 jan Exp $ */
/* $OpenBSD: if_igc.c,v 1.27 2024/08/11 01:02:10 dlg Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
@ -202,6 +202,7 @@ igc_attach(struct device *parent, struct device *self, void *aux)
/* Determine hardware and mac info */
igc_identify_hardware(sc);
sc->rx_mbuf_sz = MCLBYTES;
sc->num_tx_desc = IGC_DEFAULT_TXD;
sc->num_rx_desc = IGC_DEFAULT_RXD;
@ -881,7 +882,6 @@ igc_init(void *arg)
}
igc_initialize_transmit_unit(sc);
sc->rx_mbuf_sz = MCLBYTES;
/* Prepare receive descriptors and buffers. */
if (igc_setup_receive_structures(sc)) {
printf("%s: Could not setup receive structures\n",
@ -1232,7 +1232,7 @@ igc_rxrinfo(struct igc_softc *sc, struct if_rxrinfo *ifri)
for (i = 0; i < sc->sc_nqueues; i++) {
rxr = &sc->rx_rings[i];
ifr[n].ifr_size = MCLBYTES;
ifr[n].ifr_size = sc->rx_mbuf_sz;
snprintf(ifr[n].ifr_name, sizeof(ifr[n].ifr_name), "%d", i);
ifr[n].ifr_info = rxr->rx_ring;
n++;
@ -1673,11 +1673,11 @@ igc_get_buf(struct igc_rxring *rxr, int i)
return ENOBUFS;
}
m = MCLGETL(NULL, M_DONTWAIT, sc->rx_mbuf_sz);
m = MCLGETL(NULL, M_DONTWAIT, sc->rx_mbuf_sz + ETHER_ALIGN);
if (!m)
return ENOBUFS;
m->m_data += (m->m_ext.ext_size - sc->rx_mbuf_sz);
m->m_data += ETHER_ALIGN;
m->m_len = m->m_pkthdr.len = sc->rx_mbuf_sz;
error = bus_dmamap_load_mbuf(rxr->rxdma.dma_tag, rxbuf->map, m,
@ -2159,7 +2159,7 @@ igc_allocate_receive_buffers(struct igc_rxring *rxr)
rxbuf = rxr->rx_buffers;
for (i = 0; i < sc->num_rx_desc; i++, rxbuf++) {
error = bus_dmamap_create(rxr->rxdma.dma_tag,
MAX_JUMBO_FRAME_SIZE, IGC_MAX_SCATTER, MCLBYTES, 0,
sc->rx_mbuf_sz, 1, sc->rx_mbuf_sz, 0,
BUS_DMA_NOWAIT, &rxbuf->map);
if (error) {
printf("%s: Unable to create RX DMA map\n",
@ -2223,7 +2223,8 @@ igc_setup_receive_ring(struct igc_rxring *rxr)
rxr->next_to_check = 0;
rxr->last_desc_filled = sc->num_rx_desc - 1;
if_rxr_init(&rxr->rx_ring, 2 * ((ifp->if_hardmtu / MCLBYTES) + 1),
if_rxr_init(&rxr->rx_ring,
2 * howmany(ifp->if_hardmtu, sc->rx_mbuf_sz) + 1,
sc->num_rx_desc - 1);
return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.230 2024/08/06 18:41:20 claudio Exp $ */
/* $OpenBSD: kern_exit.c,v 1.231 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -151,6 +151,9 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
PS_ISPWAIT);
wakeup(pr->ps_pptr);
}
/* Wait for concurrent `allprocess' loops */
refcnt_finalize(&pr->ps_refcnt, "psdtor");
}
/* unlink ourselves from the active threads */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.261 2024/08/06 08:44:54 claudio Exp $ */
/* $OpenBSD: kern_fork.c,v 1.262 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@ -178,6 +178,8 @@ thread_new(struct proc *parent, vaddr_t uaddr)
void
process_initialize(struct process *pr, struct proc *p)
{
refcnt_init(&pr->ps_refcnt);
/* initialize the thread links */
pr->ps_mainproc = p;
TAILQ_INIT(&pr->ps_threads);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sysctl.c,v 1.436 2024/08/08 15:02:36 bluhm Exp $ */
/* $OpenBSD: kern_sysctl.c,v 1.437 2024/08/11 15:10:53 mvs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@ -1686,6 +1686,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
/* not the pid we are looking for */
continue;
}
refcnt_take(&pr->ps_refcnt);
matched = 1;
fdp = pr->ps_fd;
if (pr->ps_textvp)
@ -1702,6 +1705,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
FILLIT(fp, fdp, i, NULL, pr);
FRELE(fp, p);
}
refcnt_rele_wake(&pr->ps_refcnt);
/* pid is unique, stop searching */
if (arg >= 0)
break;
@ -1721,6 +1727,9 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
/* not the uid we are looking for */
continue;
}
refcnt_take(&pr->ps_refcnt);
fdp = pr->ps_fd;
if (fdp->fd_cdir)
FILLIT(NULL, NULL, KERN_FILE_CDIR, fdp->fd_cdir, pr);
@ -1734,6 +1743,8 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep,
FILLIT(fp, fdp, i, NULL, pr);
FRELE(fp, p);
}
refcnt_rele_wake(&pr->ps_refcnt);
}
break;
default:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_timeout.c,v 1.98 2024/08/05 23:51:11 dlg Exp $ */
/* $OpenBSD: kern_timeout.c,v 1.99 2024/08/11 00:49:34 dlg Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
@ -332,18 +332,25 @@ timeout_add(struct timeout *new, int to_ticks)
return ret;
}
static inline int
timeout_add_ticks(struct timeout *to, uint64_t to_ticks, int notzero)
{
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
else if (to_ticks == 0 && notzero)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
}
int
timeout_add_tv(struct timeout *to, const struct timeval *tv)
{
uint64_t to_ticks;
to_ticks = (uint64_t)hz * tv->tv_sec + tv->tv_usec / tick;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && tv->tv_usec > 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, tv->tv_usec > 0);
}
int
@ -352,37 +359,28 @@ timeout_add_sec(struct timeout *to, int secs)
uint64_t to_ticks;
to_ticks = (uint64_t)hz * secs;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, 1);
}
int
timeout_add_msec(struct timeout *to, int msecs)
timeout_add_msec(struct timeout *to, uint64_t msecs)
{
uint64_t to_ticks;
to_ticks = (uint64_t)msecs * 1000 / tick;
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && msecs > 0)
to_ticks = 1;
to_ticks = msecs * 1000 / tick;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, msecs > 0);
}
int
timeout_add_usec(struct timeout *to, int usecs)
timeout_add_usec(struct timeout *to, uint64_t usecs)
{
int to_ticks = usecs / tick;
uint64_t to_ticks;
if (to_ticks == 0 && usecs > 0)
to_ticks = 1;
to_ticks = usecs / tick;
return timeout_add(to, to_ticks);
return timeout_add_ticks(to, to_ticks, usecs > 0);
}
int
@ -391,12 +389,8 @@ timeout_add_nsec(struct timeout *to, uint64_t nsecs)
uint64_t to_ticks;
to_ticks = nsecs / (tick * 1000);
if (to_ticks > INT_MAX)
to_ticks = INT_MAX;
if (to_ticks == 0 && nsecs > 0)
to_ticks = 1;
return timeout_add(to, (int)to_ticks);
return timeout_add_ticks(to, to_ticks, nsecs > 0);
}
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.342 2024/08/06 20:14:56 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.343 2024/08/11 00:19:00 jsg Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -1581,7 +1581,7 @@ sotask(void *arg)
int sockstream = (so->so_proto->pr_flags & PR_WANTRCVD);
/*
* sblock() on `so_rcv' protects sockets from beind unspliced
* sblock() on `so_rcv' protects sockets from being unspliced
* for UDP case. TCP sockets still rely on solock().
*/

View file

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.367 2024/08/06 08:44:54 claudio Exp $ */
/* $OpenBSD: proc.h,v 1.369 2024/08/11 21:07:05 mvs Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@ -50,6 +50,7 @@
#include <sys/resource.h> /* For struct rusage */
#include <sys/rwlock.h> /* For struct rwlock */
#include <sys/sigio.h> /* For struct sigio */
#include <sys/refcnt.h> /* For struct refcnt */
#ifdef _KERNEL
#include <sys/atomic.h>
@ -142,6 +143,8 @@ struct pinsyscall {
* T itimer_mtx
*/
struct process {
struct refcnt ps_refcnt;
/*
* ps_mainproc is the original thread in the process.
* It's only still special for the handling of

View file

@ -1,4 +1,4 @@
/* $OpenBSD: timeout.h,v 1.49 2024/08/05 23:51:11 dlg Exp $ */
/* $OpenBSD: timeout.h,v 1.50 2024/08/11 00:49:34 dlg Exp $ */
/*
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
* All rights reserved.
@ -108,8 +108,8 @@ void timeout_set_proc(struct timeout *, void (*)(void *), void *);
int timeout_add(struct timeout *, int);
int timeout_add_tv(struct timeout *, const struct timeval *);
int timeout_add_sec(struct timeout *, int);
int timeout_add_msec(struct timeout *, int);
int timeout_add_usec(struct timeout *, int);
int timeout_add_msec(struct timeout *, uint64_t);
int timeout_add_usec(struct timeout *, uint64_t);
int timeout_add_nsec(struct timeout *, uint64_t);
int timeout_abs_ts(struct timeout *, const struct timespec *);