sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-18 01:23:47 +00:00
parent b5dda3c267
commit c78abe7784
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
59 changed files with 509 additions and 656 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: icc.c,v 1.1 2022/11/11 15:25:13 matthieu Exp $ */
/* $OpenBSD: icc.c,v 1.2 2024/08/17 15:10:00 deraadt Exp $ */
/*
* Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org>
@ -48,6 +48,7 @@ const struct cfattach icc_ca = {
sizeof(struct icc_softc),
icc_match,
icc_attach,
icc_detach
};
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwiic.c,v 1.15 2023/08/29 12:09:40 kettenis Exp $ */
/* $OpenBSD: dwiic.c,v 1.21 2024/08/17 02:35:00 deraadt Exp $ */
/*
* Synopsys DesignWare I2C controller
*
@ -21,14 +21,6 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#ifdef __HAVE_ACPI
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpidev.h>
#include <dev/acpi/amltypes.h>
#include <dev/acpi/dsdt.h>
#endif
#include <dev/i2c/i2cvar.h>
#include <dev/ic/dwiicvar.h>
@ -41,34 +33,50 @@ int
dwiic_activate(struct device *self, int act)
{
struct dwiic_softc *sc = (struct dwiic_softc *)self;
int rv;
switch (act) {
case DVACT_SUSPEND:
rv = config_activate_children(self, act);
/* disable controller */
dwiic_enable(sc, 0);
/* disable interrupts */
dwiic_write(sc, DW_IC_INTR_MASK, 0);
dwiic_read(sc, DW_IC_CLR_INTR);
#if notyet
/* power down the controller */
dwiic_acpi_power(sc, 0);
#endif
break;
case DVACT_WAKEUP:
#if notyet
/* power up the controller */
dwiic_acpi_power(sc, 1);
#endif
dwiic_init(sc);
case DVACT_RESUME:
/* if it became enabled for some reason, force it down */
dwiic_enable(sc, 0);
dwiic_write(sc, DW_IC_INTR_MASK, 0);
dwiic_read(sc, DW_IC_CLR_INTR);
/* write standard-mode SCL timing parameters */
dwiic_write(sc, DW_IC_SS_SCL_HCNT, sc->ss_hcnt);
dwiic_write(sc, DW_IC_SS_SCL_LCNT, sc->ss_lcnt);
/* and fast-mode SCL timing parameters */
dwiic_write(sc, DW_IC_FS_SCL_HCNT, sc->fs_hcnt);
dwiic_write(sc, DW_IC_FS_SCL_LCNT, sc->fs_lcnt);
/* SDA hold time */
dwiic_write(sc, DW_IC_SDA_HOLD, sc->sda_hold_time);
dwiic_write(sc, DW_IC_TX_TL, sc->tx_fifo_depth / 2);
dwiic_write(sc, DW_IC_RX_TL, 0);
/* configure as i2c master with fast speed */
sc->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
dwiic_write(sc, DW_IC_CON, sc->master_cfg);
rv = config_activate_children(self, act);
break;
default:
rv = config_activate_children(self, act);
break;
}
config_activate_children(self, act);
return 0;
return rv;
}
int
@ -489,32 +497,32 @@ dwiic_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, const void *cmdbuf,
uint32_t
dwiic_read_clear_intrbits(struct dwiic_softc *sc)
{
uint32_t stat;
uint32_t stat;
stat = dwiic_read(sc, DW_IC_INTR_STAT);
stat = dwiic_read(sc, DW_IC_INTR_STAT);
if (stat & DW_IC_INTR_RX_UNDER)
dwiic_read(sc, DW_IC_CLR_RX_UNDER);
if (stat & DW_IC_INTR_RX_OVER)
dwiic_read(sc, DW_IC_CLR_RX_OVER);
if (stat & DW_IC_INTR_TX_OVER)
dwiic_read(sc, DW_IC_CLR_TX_OVER);
if (stat & DW_IC_INTR_RD_REQ)
dwiic_read(sc, DW_IC_CLR_RD_REQ);
if (stat & DW_IC_INTR_TX_ABRT)
dwiic_read(sc, DW_IC_CLR_TX_ABRT);
if (stat & DW_IC_INTR_RX_DONE)
dwiic_read(sc, DW_IC_CLR_RX_DONE);
if (stat & DW_IC_INTR_ACTIVITY)
dwiic_read(sc, DW_IC_CLR_ACTIVITY);
if (stat & DW_IC_INTR_STOP_DET)
dwiic_read(sc, DW_IC_CLR_STOP_DET);
if (stat & DW_IC_INTR_START_DET)
dwiic_read(sc, DW_IC_CLR_START_DET);
if (stat & DW_IC_INTR_GEN_CALL)
dwiic_read(sc, DW_IC_CLR_GEN_CALL);
if (stat & DW_IC_INTR_RX_UNDER)
dwiic_read(sc, DW_IC_CLR_RX_UNDER);
if (stat & DW_IC_INTR_RX_OVER)
dwiic_read(sc, DW_IC_CLR_RX_OVER);
if (stat & DW_IC_INTR_TX_OVER)
dwiic_read(sc, DW_IC_CLR_TX_OVER);
if (stat & DW_IC_INTR_RD_REQ)
dwiic_read(sc, DW_IC_CLR_RD_REQ);
if (stat & DW_IC_INTR_TX_ABRT)
dwiic_read(sc, DW_IC_CLR_TX_ABRT);
if (stat & DW_IC_INTR_RX_DONE)
dwiic_read(sc, DW_IC_CLR_RX_DONE);
if (stat & DW_IC_INTR_ACTIVITY)
dwiic_read(sc, DW_IC_CLR_ACTIVITY);
if (stat & DW_IC_INTR_STOP_DET)
dwiic_read(sc, DW_IC_CLR_STOP_DET);
if (stat & DW_IC_INTR_START_DET)
dwiic_read(sc, DW_IC_CLR_START_DET);
if (stat & DW_IC_INTR_GEN_CALL)
dwiic_read(sc, DW_IC_CLR_GEN_CALL);
return stat;
return stat;
}
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: qwx.c,v 1.63 2024/06/11 10:06:35 stsp Exp $ */
/* $OpenBSD: qwx.c,v 1.64 2024/08/17 08:12:46 stsp Exp $ */
/*
* Copyright 2023 Stefan Sperling <stsp@openbsd.org>
@ -19836,10 +19836,7 @@ qwx_core_qmi_firmware_ready(struct qwx_softc *sc)
goto err_core_stop;
}
#if 0 /* TODO: Is this in the right spot for OpenBSD? */
sc->ops.irq_enable(sc);
#endif
#if 0
mutex_unlock(&ab->core_lock);
#endif
@ -25390,9 +25387,6 @@ qwx_run(struct qwx_softc *sc)
return ret;
}
/* Enable "ext" IRQs for datapath. */
sc->ops.irq_enable(sc);
return 0;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sti.c,v 1.83 2022/07/15 19:29:27 deraadt Exp $ */
/* $OpenBSD: sti.c,v 1.84 2024/08/17 08:45:22 miod Exp $ */
/*
* Copyright (c) 2000-2003 Michael Shalayeff
@ -110,6 +110,7 @@ void sti_describe_screen(struct sti_softc *, struct sti_screen *);
void sti_end_attach_screen(struct sti_softc *, struct sti_screen *, int);
int sti_fetchfonts(struct sti_screen *, struct sti_inqconfout *, u_int32_t,
u_int);
int32_t sti_gvid(void *, uint32_t, uint32_t *);
void sti_region_setup(struct sti_screen *);
int sti_rom_setup(struct sti_rom *, bus_space_tag_t, bus_space_tag_t,
bus_space_handle_t, bus_addr_t *, u_int);
@ -122,6 +123,10 @@ void ngle_elk_setupfb(struct sti_screen *);
void ngle_timber_setupfb(struct sti_screen *);
int ngle_putcmap(struct sti_screen *, u_int, u_int);
/*
* Helper macros to control whether the STI ROM is accessible on PCI
* devices.
*/
#if NSTI_PCI > 0
#define STI_ENABLE_ROM(sc) \
do { \
@ -301,6 +306,15 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
dd->dd_pacode[0xf]);
#endif
/*
* Take note that it will be necessary to enable the PCI ROM around
* some sti function calls if the MMAP (multiple map) bit is set in
* the bus support flags, which means the PCI ROM is only available
* through the PCI expansion ROM space and never through regular
* PCI BARs.
*/
rom->rom_enable = dd->dd_bussup & STI_BUSSUPPORT_ROMMAP;
/*
* Figure out how much bytes we need for the STI code.
* Note there could be fewer than STI_END entries pointer
@ -337,9 +351,8 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
u_int32_t addr, eaddr;
for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4;
addr < eaddr; addr += 4 )
addr < eaddr; addr += 4)
*p++ = bus_space_read_4(memt, romh, addr) & 0xff;
} else /* STI_DEVTYPE4 */
bus_space_read_raw_region_4(memt, romh,
dd->dd_pacode[STI_BEGIN], rom->rom_code, size);
@ -371,18 +384,10 @@ sti_rom_setup(struct sti_rom *rom, bus_space_tag_t iot, bus_space_tag_t memt,
(rom->rom_devtype == STI_DEVTYPE1? 4 : 1)))
rom->init = (sti_init_t)O(STI_INIT_GRAPH);
rom->mgmt = (sti_mgmt_t)O(STI_STATE_MGMT);
rom->unpmv = (sti_unpmv_t)O(STI_FONT_UNPMV);
rom->blkmv = (sti_blkmv_t)O(STI_BLOCK_MOVE);
rom->test = (sti_test_t)O(STI_SELF_TEST);
rom->exhdl = (sti_exhdl_t)O(STI_EXCEP_HDLR);
rom->inqconf = (sti_inqconf_t)O(STI_INQ_CONF);
rom->scment = (sti_scment_t)O(STI_SCM_ENT);
rom->dmac = (sti_dmac_t)O(STI_DMA_CTRL);
rom->flowc = (sti_flowc_t)O(STI_FLOW_CTRL);
rom->utiming = (sti_utiming_t)O(STI_UTIMING);
rom->pmgr = (sti_pmgr_t)O(STI_PROC_MGR);
rom->util = (sti_util_t)O(STI_UTIL);
#undef O
@ -502,6 +507,42 @@ sti_region_setup(struct sti_screen *scr)
#endif
}
/*
* ``gvid'' callback routine.
*
* The FireGL-UX board is using this interface, and will revert to direct
* PDC calls if no gvid callback is set.
* Unfortunately, under OpenBSD it is not possible to invoke PDC directly
* from its physical address once the MMU is turned on, and no documentation
* for the gvid interface (or for the particular PDC_PCI subroutines used
* by the FireGL-UX rom) has been found.
*/
int32_t
sti_gvid(void *v, uint32_t cmd, uint32_t *params)
{
struct sti_screen *scr = v;
struct sti_rom *rom = scr->scr_rom;
/* paranoia */
if (cmd != 0x000c0003)
return -1;
switch (params[0]) {
case 4:
/* register read */
params[2] =
bus_space_read_4(rom->memt, rom->regh[2], params[1]);
return 0;
case 5:
/* register write */
bus_space_write_4(rom->memt, rom->regh[2], params[1],
params[2]);
return 0;
default:
return -1;
}
}
int
sti_screen_setup(struct sti_screen *scr, int flags)
{
@ -510,8 +551,8 @@ sti_screen_setup(struct sti_screen *scr, int flags)
bus_space_handle_t romh = rom->romh;
struct sti_dd *dd = &rom->rom_dd;
struct sti_cfg *cc = &scr->scr_cfg;
struct sti_inqconfout cfg;
struct sti_einqconfout ecfg;
struct sti_inqconfout inq;
struct sti_einqconfout einq;
int error, i;
int geometry_kluge = 0;
u_int fontindex = 0;
@ -522,7 +563,7 @@ sti_screen_setup(struct sti_screen *scr, int flags)
if (dd->dd_stimemreq) {
scr->scr_ecfg.addr =
malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT);
malloc(dd->dd_stimemreq, M_DEVBUF, M_NOWAIT | M_ZERO);
if (!scr->scr_ecfg.addr) {
printf("cannot allocate %d bytes for STI\n",
dd->dd_stimemreq);
@ -530,6 +571,12 @@ sti_screen_setup(struct sti_screen *scr, int flags)
}
}
if (dd->dd_ebussup & STI_EBUSSUPPORT_GVID) {
scr->scr_ecfg.future.g.gvid_cmd_arg = scr;
scr->scr_ecfg.future.g.gvid_cmd =
(int32_t (*)(void *, ...))sti_gvid;
}
sti_region_setup(scr);
if ((error = sti_init(scr, 0))) {
@ -537,10 +584,10 @@ sti_screen_setup(struct sti_screen *scr, int flags)
goto fail;
}
bzero(&cfg, sizeof(cfg));
bzero(&ecfg, sizeof(ecfg));
cfg.ext = &ecfg;
if ((error = sti_inqcfg(scr, &cfg))) {
bzero(&inq, sizeof(inq));
bzero(&einq, sizeof(einq));
inq.ext = &einq;
if ((error = sti_inqcfg(scr, &inq))) {
printf(": error %d inquiring config\n", error);
goto fail;
}
@ -550,25 +597,24 @@ sti_screen_setup(struct sti_screen *scr, int flags)
* similar to the displayable area size, at least in m68k mode.
* Attempt to detect this and adjust here.
*/
if (cfg.owidth == cfg.width &&
cfg.oheight == cfg.height)
if (inq.owidth == inq.width && inq.oheight == inq.height)
geometry_kluge = 1;
if (geometry_kluge) {
scr->scr_cfg.oscr_width = cfg.owidth =
cfg.fbwidth - cfg.width;
scr->scr_cfg.oscr_height = cfg.oheight =
cfg.fbheight - cfg.height;
scr->scr_cfg.oscr_width = inq.owidth =
inq.fbwidth - inq.width;
scr->scr_cfg.oscr_height = inq.oheight =
inq.fbheight - inq.height;
}
/*
* Save a few fields for sti_describe_screen() later
*/
scr->fbheight = cfg.fbheight;
scr->fbwidth = cfg.fbwidth;
scr->oheight = cfg.oheight;
scr->owidth = cfg.owidth;
bcopy(cfg.name, scr->name, sizeof(scr->name));
scr->fbheight = inq.fbheight;
scr->fbwidth = inq.fbwidth;
scr->oheight = inq.oheight;
scr->owidth = inq.owidth;
bcopy(inq.name, scr->name, sizeof(scr->name));
if ((error = sti_init(scr, STI_TEXTMODE | flags))) {
printf(": can not initialize (%d)\n", error);
@ -576,12 +622,12 @@ sti_screen_setup(struct sti_screen *scr, int flags)
}
#ifdef STIDEBUG
printf("conf: bpp=%d planes=%d attr=%b\n"
"crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", cfg.bpp,
cfg.planes, cfg.attributes, STI_INQCONF_BITS,
ecfg.crt_config[0], ecfg.crt_config[1], ecfg.crt_config[2],
ecfg.crt_hw[0], ecfg.crt_hw[1], ecfg.crt_hw[2]);
"crt=0x%x:0x%x:0x%x hw=0x%x:0x%x:0x%x\n", inq.bpp,
inq.planes, inq.attributes, STI_INQCONF_BITS,
einq.crt_config[0], einq.crt_config[1], einq.crt_config[2],
einq.crt_hw[0], einq.crt_hw[1], einq.crt_hw[2]);
#endif
scr->scr_bpp = cfg.bppu;
scr->scr_bpp = inq.bppu;
/*
* Although scr->scr_ecfg.current_monitor is not filled by
@ -618,7 +664,7 @@ sti_screen_setup(struct sti_screen *scr, int flags)
#endif
}
if ((error = sti_fetchfonts(scr, &cfg, dd->dd_fntaddr, fontindex))) {
if ((error = sti_fetchfonts(scr, &inq, dd->dd_fntaddr, fontindex))) {
printf(": cannot fetch fonts (%d)\n", error);
goto fail;
}
@ -631,8 +677,8 @@ sti_screen_setup(struct sti_screen *scr, int flags)
*/
strlcpy(scr->scr_wsd.name, "std", sizeof(scr->scr_wsd.name));
scr->scr_wsd.ncols = cfg.width / scr->scr_curfont.width;
scr->scr_wsd.nrows = cfg.height / scr->scr_curfont.height;
scr->scr_wsd.ncols = inq.width / scr->scr_curfont.width;
scr->scr_wsd.nrows = inq.height / scr->scr_curfont.height;
scr->scr_wsd.textops = &sti_emulops;
scr->scr_wsd.fontwidth = scr->scr_curfont.width;
scr->scr_wsd.fontheight = scr->scr_curfont.height;
@ -699,9 +745,10 @@ sti_screen_setup(struct sti_screen *scr, int flags)
case STI_DD_3X2V:
case STI_DD_DUAL_CRX:
case STI_DD_HCRX:
case STI_DD_LEGO:
case STI_DD_SUMMIT:
case STI_DD_PINNACLE:
case STI_DD_LEGO:
case STI_DD_FIREGL:
default:
scr->setupfb = NULL;
scr->putcmap =
@ -713,7 +760,11 @@ sti_screen_setup(struct sti_screen *scr, int flags)
return (0);
fail:
/* XXX free resources */
/* free resources */
if (scr->scr_romfont != NULL) {
free(scr->scr_romfont, M_DEVBUF, 0);
scr->scr_romfont = NULL;
}
if (scr->scr_ecfg.addr != NULL) {
free(scr->scr_ecfg.addr, M_DEVBUF, 0);
scr->scr_ecfg.addr = NULL;
@ -809,7 +860,7 @@ sti_rom_size(bus_space_tag_t memt, bus_space_handle_t romh)
}
int
sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *cfg,
sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *inq,
u_int32_t baseaddr, u_int fontindex)
{
struct sti_rom *rom = scr->scr_rom;
@ -901,16 +952,16 @@ rescan:
* display all the characters there in order to display them
* faster with blkmv operations rather than unpmv later on.
*/
if (size <= cfg->fbheight *
(cfg->fbwidth - cfg->width - cfg->owidth)) {
if (size <= inq->fbheight *
(inq->fbwidth - inq->width - inq->owidth)) {
bzero(&a, sizeof(a));
a.flags.flags = STI_UNPMVF_WAIT;
a.in.fg_colour = STI_COLOUR_WHITE;
a.in.bg_colour = STI_COLOUR_BLACK;
a.in.font_addr = scr->scr_romfont;
scr->scr_fontmaxcol = cfg->fbheight / fp->height;
scr->scr_fontbase = cfg->width + cfg->owidth;
scr->scr_fontmaxcol = inq->fbheight / fp->height;
scr->scr_fontbase = inq->width + inq->owidth;
for (uc = fp->first; uc <= fp->last; uc++) {
a.in.x = ((uc - fp->first) / scr->scr_fontmaxcol) *
fp->width + scr->scr_fontbase;
@ -969,7 +1020,15 @@ sti_init(struct sti_screen *scr, int mode)
printf("sti_init,%p(%x, %p, %p, %p)\n",
rom->init, a.flags.flags, &a.in, &a.out, &scr->scr_cfg);
#endif
/*
* Make the ROM visible during initialization, some devices
* look for various data into their ROM image.
*/
if (rom->rom_enable)
STI_ENABLE_ROM(rom->rom_softc);
(*rom->init)(&a.flags, &a.in, &a.out, &scr->scr_cfg);
if (rom->rom_enable)
STI_DISABLE_ROM(rom->rom_softc);
if (a.out.text_planes != a.in.text_planes)
return (-1); /* not colliding with sti errno values */
return (a.out.errno);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $ */
/* $OpenBSD: stireg.h,v 1.15 2024/08/17 08:45:22 miod Exp $ */
/*
* Copyright (c) 2000 Michael Shalayeff
@ -29,8 +29,6 @@
#ifndef _IC_STIREG_H_
#define _IC_STIREG_H_
/* #define STIDEBUG */
#define STI_REGION_MAX 8
#define STI_MONITOR_MAX 256
#define STI_DEVNAME_LEN 32
@ -134,6 +132,7 @@ struct sti_dd {
#define STI_DD_SUMMIT 0x2FC1066B /* Visualize FX2, FX4, FX6 */
#define STI_DD_PINNACLE 0x35ACDA16 /* Visualize FXe */
#define STI_DD_LEGO 0x35ACDA30 /* Visualize FX5, FX10 */
#define STI_DD_FIREGL 0x3BA8F544 /* FireGL-UX */
u_int32_t dd_fntaddr; /* 0x10 font start address */
u_int32_t dd_maxst; /* 0x14 max state storage */
u_int32_t dd_romend; /* 0x18 rom last address */
@ -157,6 +156,7 @@ struct sti_dd {
u_int8_t dd_ebussup; /* 0x37 extended bus support */
#define STI_EBUSSUPPORT_DMA 0x01 /* supports dma */
#define STI_EBUSSUPPORT_PIOLOCK 0x02 /* no implicit locking for dma */
#define STI_EBUSSUPPORT_GVID 0x04 /* requires gvid callback */
u_int8_t dd_altcodet; /* 0x38 alternate code type */
#define STI_ALTCODE_UNKNOWN 0x00
#define STI_ALTCODE_PA64 0x01 /* alt code is in pa64 */
@ -228,7 +228,15 @@ typedef struct sti_ecfg {
u_int16_t power; /* power dissipation Watts */
u_int32_t freq_ref;
u_int32_t *addr; /* memory block of size dd_stimemreq */
void *future;
union {
struct {
int32_t (*gvid_cmd)(void *, ...);
void *gvid_cmd_arg;
u_int32_t pci_id;
void *future;
} g;
void *future;
} future;
} __packed *sti_ecfg_t;
typedef struct sti_cfg {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: stivar.h,v 1.28 2024/05/29 00:48:15 jsg Exp $ */
/* $OpenBSD: stivar.h,v 1.29 2024/08/17 08:45:22 miod Exp $ */
/*
* Copyright (c) 2000-2003 Michael Shalayeff
@ -47,22 +47,16 @@ struct sti_rom {
struct sti_dd rom_dd; /* in word format */
u_int8_t *rom_code;
int rom_enable;
/*
* ROM-provided function pointers
*/
sti_init_t init;
sti_mgmt_t mgmt;
sti_unpmv_t unpmv;
sti_blkmv_t blkmv;
sti_test_t test;
sti_exhdl_t exhdl;
sti_inqconf_t inqconf;
sti_scment_t scment;
sti_dmac_t dmac;
sti_flowc_t flowc;
sti_utiming_t utiming;
sti_pmgr_t pmgr;
sti_util_t util;
};
/*

View file

@ -1487,9 +1487,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev,
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
void amdgpu_choose_low_power_state(struct amdgpu_device *adev);
#else
static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; }
static inline void amdgpu_choose_low_power_state(struct amdgpu_device *adev) { }
#endif
#if defined(CONFIG_DRM_AMD_DC)

View file

@ -1519,6 +1519,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
if (adev->asic_type < CHIP_RAVEN)
return false;
#ifdef __linux__
/*
* If ACPI_FADT_LOW_POWER_S0 is not set in the FADT, it is generally
* risky to do any special firmware-related preparations for entering
@ -1531,6 +1532,7 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
"To use suspend-to-idle change the sleep mode in BIOS setup.\n");
return false;
}
#endif
#if !IS_ENABLED(CONFIG_AMD_PMC)
dev_err_once(adev->dev,
@ -1541,4 +1543,19 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
#endif /* CONFIG_AMD_PMC */
}
/**
* amdgpu_choose_low_power_state
*
* @adev: amdgpu_device_pointer
*
* Choose the target low power state for the GPU
*/
void amdgpu_choose_low_power_state(struct amdgpu_device *adev)
{
if (amdgpu_acpi_is_s0ix_active(adev))
adev->in_s0ix = true;
else if (amdgpu_acpi_is_s3_active(adev))
adev->in_s3 = true;
}
#endif /* CONFIG_SUSPEND */

View file

@ -4221,13 +4221,15 @@ int amdgpu_device_prepare(struct drm_device *dev)
struct amdgpu_device *adev = drm_to_adev(dev);
int i, r;
amdgpu_choose_low_power_state(adev);
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
/* Evict the majority of BOs before starting suspend sequence */
r = amdgpu_device_evict_resources(adev);
if (r)
return r;
goto unprepare;
flush_delayed_work(&adev->gfx.gfx_off_delay_work);
@ -4238,10 +4240,15 @@ int amdgpu_device_prepare(struct drm_device *dev)
continue;
r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev);
if (r)
return r;
goto unprepare;
}
return 0;
unprepare:
adev->in_s0ix = adev->in_s3 = false;
return r;
}
/**

View file

@ -2383,8 +2383,6 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work)
}
}
#ifdef notyet
static int amdgpu_pmops_prepare(struct device *dev)
{
struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2477,6 +2475,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
return 0;
}
#ifdef notyet
static int amdgpu_pmops_thaw(struct device *dev)
{
struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2491,6 +2491,8 @@ static int amdgpu_pmops_poweroff(struct device *dev)
return amdgpu_device_suspend(drm_dev, true);
}
#endif
static int amdgpu_pmops_restore(struct device *dev)
{
struct drm_device *drm_dev = dev_get_drvdata(dev);
@ -2498,6 +2500,8 @@ static int amdgpu_pmops_restore(struct device *dev)
return amdgpu_device_resume(drm_dev, true);
}
#ifdef notyet
static int amdgpu_runtime_idle_check_display(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
@ -3496,6 +3500,8 @@ amdgpu_attachhook(struct device *self)
struct drm_gem_object *obj;
struct amdgpu_bo *rbo;
dev_set_drvdata(self, dev);
r = amdgpu_driver_load_kms(adev, adev->flags);
if (r)
goto out;
@ -3671,15 +3677,23 @@ amdgpu_activate(struct device *self, int act)
switch (act) {
case DVACT_QUIESCE:
rv = config_activate_children(self, act);
amdgpu_device_prepare(dev);
amdgpu_device_suspend(dev, true);
amdgpu_pmops_prepare(self);
if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
amdgpu_pmops_freeze(self);
else
amdgpu_pmops_suspend(self);
break;
case DVACT_SUSPEND:
if (!acpi_softc || acpi_softc->sc_state != ACPI_STATE_S4)
amdgpu_pmops_suspend_noirq(self);
break;
case DVACT_RESUME:
break;
case DVACT_WAKEUP:
amdgpu_device_resume(dev, true);
if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S4)
amdgpu_pmops_restore(self);
else
amdgpu_pmops_resume(self);
rv = config_activate_children(self, act);
break;
}

View file

@ -1550,10 +1550,16 @@ drm_activate(struct device *self, int act)
switch (act) {
case DVACT_QUIESCE:
#ifdef CONFIG_ACPI
if (acpi_softc && acpi_softc->sc_state == ACPI_STATE_S3)
pm_suspend_target_state = PM_SUSPEND_MEM;
else
pm_suspend_target_state = PM_SUSPEND_TO_IDLE;
if (acpi_softc) {
switch (acpi_softc->sc_state) {
case ACPI_STATE_S0:
pm_suspend_target_state = PM_SUSPEND_TO_IDLE;
break;
case ACPI_STATE_S3:
pm_suspend_target_state = PM_SUSPEND_MEM;
break;
}
}
#else
pm_suspend_target_state = PM_SUSPEND_TO_IDLE;
#endif

View file

@ -36,6 +36,7 @@
#if NACPI > 0
#define CONFIG_ACPI 1
#define CONFIG_ACPI_SLEEP 1
#define CONFIG_AMD_PMC 1
#endif
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pci.h,v 1.16 2024/01/16 23:38:13 jsg Exp $ */
/* $OpenBSD: pci.h,v 1.17 2024/08/16 10:46:46 kettenis Exp $ */
/*
* Copyright (c) 2015 Mark Kettenis
*
@ -524,4 +524,10 @@ pci_match_id(const struct pci_device_id *ids, struct pci_dev *pdev)
#define PCI_CLASS_ACCELERATOR_PROCESSING \
(PCI_CLASS_ACCELERATOR << 8)
static inline int
pci_device_is_present(struct pci_dev *pdev)
{
return 1;
}
#endif /* _LINUX_PCI_H_ */

View file

@ -80,4 +80,10 @@ pm_runtime_get_if_active(struct device *dev, bool x)
return -EINVAL;
}
static inline int
pm_runtime_suspended(struct device *dev)
{
return 0;
}
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwiic_pci.c,v 1.27 2024/05/24 06:02:53 jsg Exp $ */
/* $OpenBSD: dwiic_pci.c,v 1.30 2024/08/17 02:31:15 deraadt Exp $ */
/*
* Synopsys DesignWare I2C controller
* PCI attachment
@ -293,15 +293,14 @@ dwiic_pci_activate(struct device *self, int act)
struct dwiic_softc *sc = (struct dwiic_softc *)self;
switch (act) {
case DVACT_WAKEUP:
case DVACT_RESUME:
DELAY(10000); /* 10 msec */
bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPSS_RESETS,
(LPSS_RESETS_I2C | LPSS_RESETS_IDMA));
DELAY(10000); /* 10 msec */
break;
}
dwiic_activate(self, act);
return 0;
return dwiic_activate(self, act);
}
void

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sti_pci.c,v 1.13 2023/04/13 15:07:43 miod Exp $ */
/* $OpenBSD: sti_pci.c,v 1.14 2024/08/17 08:45:22 miod Exp $ */
/*
* Copyright (c) 2006, 2007, 2023 Miodrag Vallat.
@ -52,6 +52,9 @@ const struct pci_matchid sti_pci_devices[] = {
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX4 },
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FX6 },
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_VISUALIZE_FXE },
#ifdef notyet
{ PCI_VENDOR_IBM, PCI_PRODUCT_IBM_FIREGL2 }
#endif
};
int sti_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int);
@ -267,6 +270,15 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa)
bus_space_read_region_1(pa->pa_memt, romh, offs, region_bars,
STI_REGION_MAX);
for (i = 0; i < STI_REGION_MAX; i++) {
/*
* Region 0 is supposed to always be the ROM. FireGL-UX
* ROM agrees so well that it will report the expansion
* ROM BAR rather than any regular BAR.
* We'll address this later after remapping the ROM.
*/
if (i == 0 && region_bars[i] == PCI_ROM_REG)
continue;
rc = sti_readbar(sc, pa, i, region_bars[i]);
if (rc != 0)
goto unmap_disable_return;
@ -297,6 +309,16 @@ sti_check_rom(struct sti_pci_softc *spc, struct pci_attach_args *pa)
goto disable_return;
}
/*
* Now set up region 0 if we had skipped it earlier.
*/
if (region_bars[0] == PCI_ROM_REG) {
sc->bases[0] =
(bus_addr_t)bus_space_vaddr(pa->pa_memt, spc->sc_romh) -
(offs - ctx.romoffs);
}
sti_pci_disable_rom(sc);
return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhci_pci.c,v 1.13 2024/05/24 06:02:58 jsg Exp $ */
/* $OpenBSD: xhci_pci.c,v 1.14 2024/08/17 01:55:03 jsg Exp $ */
/*
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -151,6 +151,11 @@ xhci_pci_attach(struct device *parent, struct device *self, void *aux)
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FRESCO_FL1400)
pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED;
break;
case PCI_VENDOR_AMD:
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_1 ||
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_17_1X_XHCI_2)
psc->sc.sc_flags |= XHCI_NOCSS;
break;
}
/* Map and establish the interrupt. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.45 2024/08/01 11:13:19 sf Exp $ */
/* $OpenBSD: if_vio.c,v 1.46 2024/08/16 13:02:44 jan Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -1133,9 +1133,6 @@ vio_rx_offload(struct mbuf *m, struct virtio_net_hdr *hdr)
ether_extract_headers(m, &ext);
if (ext.ip4)
SET(m->m_pkthdr.csum_flags, M_IPV4_CSUM_IN_OK);
if (ext.tcp) {
SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK);
if (ISSET(hdr->flags, VIRTIO_NET_HDR_F_NEEDS_CSUM))

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhci.c,v 1.133 2024/08/15 17:17:05 kettenis Exp $ */
/* $OpenBSD: xhci.c,v 1.134 2024/08/17 01:55:03 jsg Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@ -626,24 +626,25 @@ xhci_suspend(struct xhci_softc *sc)
* will prevent the SoC from reaching its lowest idle state.
* So save the state here.
*/
if ((sc->sc_flags & XHCI_NOCSS) == 0) {
XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */
hcr = XOREAD4(sc, XHCI_USBSTS);
for (i = 0; i < 100; i++) {
usb_delay_ms(&sc->sc_bus, 1);
hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS;
if (!hcr)
break;
}
XOWRITE4(sc, XHCI_USBCMD, XHCI_CMD_CSS); /* Save state */
hcr = XOREAD4(sc, XHCI_USBSTS);
for (i = 0; i < 100; i++) {
usb_delay_ms(&sc->sc_bus, 1);
hcr = XOREAD4(sc, XHCI_USBSTS) & XHCI_STS_SSS;
if (!hcr)
break;
if (hcr) {
printf("%s: save state timeout\n", DEVNAME(sc));
xhci_reset(sc);
return;
}
sc->sc_saved_state = 1;
}
if (hcr) {
printf("%s: save state timeout\n", DEVNAME(sc));
xhci_reset(sc);
return;
}
sc->sc_saved_state = 1;
/* Disable interrupts. */
XRWRITE4(sc, XHCI_IMOD(0), 0);
XRWRITE4(sc, XHCI_IMAN(0), 0);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: xhcivar.h,v 1.15 2024/08/15 17:17:05 kettenis Exp $ */
/* $OpenBSD: xhcivar.h,v 1.16 2024/08/17 01:55:03 jsg Exp $ */
/*
* Copyright (c) 2014 Martin Pieuchot
@ -121,6 +121,9 @@ struct xhci_softc {
char sc_vendor[16]; /* Vendor string for root hub */
int sc_id_vendor; /* Vendor ID for root hub */
int sc_flags;
#define XHCI_NOCSS 0x01
};
int xhci_init(struct xhci_softc *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: wsmux.c,v 1.58 2024/05/29 06:39:13 jsg Exp $ */
/* $OpenBSD: wsmux.c,v 1.59 2024/08/16 12:22:17 miod Exp $ */
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/*
@ -143,7 +143,7 @@ wsmux_getmux(int n)
struct wsmux_softc **new, **old;
int i;
if (n >= WSMUX_MAXDEV)
if (n < 0 || n >= WSMUX_MAXDEV)
return (NULL);
/* Make sure there is room for mux n in the table */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.231 2024/08/11 15:10:53 mvs Exp $ */
/* $OpenBSD: kern_exit.c,v 1.232 2024/08/16 16:19:03 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -432,7 +432,7 @@ proc_free(struct proc *p)
{
crfree(p->p_ucred);
pool_put(&proc_pool, p);
nthreads--;
atomic_dec_int(&nthreads);
}
/*
@ -471,9 +471,7 @@ reaper(void *arg)
if (p->p_flag & P_THREAD) {
/* Just a thread */
KERNEL_LOCK();
proc_free(p);
KERNEL_UNLOCK();
} else {
struct process *pr = p->p_p;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.262 2024/08/11 15:10:53 mvs Exp $ */
/* $OpenBSD: kern_fork.c,v 1.263 2024/08/16 16:19:03 mpi Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@ -65,7 +65,7 @@
#include <machine/tcb.h>
int nprocesses = 1; /* process 0 */
int nthreads = 1; /* proc 0 */
int nthreads = 1; /* [a] proc 0 */
struct forkstat forkstat;
void fork_return(void *);
@ -307,6 +307,8 @@ struct timeval fork_tfmrate = { 10, 0 };
int
fork_check_maxthread(uid_t uid)
{
int val;
/*
* Although process entries are dynamically created, we still keep
* a global limit on the maximum number we will create. We reserve
@ -316,14 +318,15 @@ fork_check_maxthread(uid_t uid)
* the variable nthreads is the current number of procs, maxthread is
* the limit.
*/
if ((nthreads >= maxthread - 5 && uid != 0) || nthreads >= maxthread) {
val = atomic_inc_int_nv(&nthreads);
if ((val > maxthread - 5 && uid != 0) || val > maxthread) {
static struct timeval lasttfm;
if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("thread");
atomic_dec_int(&nthreads);
return EAGAIN;
}
nthreads++;
return 0;
}
@ -369,7 +372,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (ratecheck(&lasttfm, &fork_tfmrate))
tablefull("process");
nthreads--;
atomic_dec_int(&nthreads);
return EAGAIN;
}
nprocesses++;
@ -382,7 +385,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (uid != 0 && count > lim_cur(RLIMIT_NPROC)) {
(void)chgproccnt(uid, -1);
nprocesses--;
nthreads--;
atomic_dec_int(&nthreads);
return EAGAIN;
}
@ -390,7 +393,7 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg,
if (uaddr == 0) {
(void)chgproccnt(uid, -1);
nprocesses--;
nthreads--;
atomic_dec_int(&nthreads);
return (ENOMEM);
}
@ -547,7 +550,7 @@ thread_fork(struct proc *curp, void *stack, void *tcb, pid_t *tidptr,
uaddr = uvm_uarea_alloc();
if (uaddr == 0) {
nthreads--;
atomic_dec_int(&nthreads);
return ENOMEM;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_domain.c,v 1.67 2024/08/14 17:52:47 mvs Exp $ */
/* $OpenBSD: uipc_domain.c,v 1.68 2024/08/16 09:20:34 mvs Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
@ -237,14 +237,18 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
protocol = name[1];
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
if (pr->pr_protocol == protocol && pr->pr_sysctl) {
size_t savelen = *oldlenp;
size_t savelen;
int error;
if ((error = sysctl_vslock(oldp, savelen)))
return (error);
if ((pr->pr_flags & PR_MPSYSCTL) == 0) {
savelen = *oldlenp;
if ((error = sysctl_vslock(oldp, savelen)))
return (error);
}
error = (*pr->pr_sysctl)(name + 2, namelen - 2,
oldp, oldlenp, newp, newlen);
sysctl_vsunlock(oldp, savelen);
if ((pr->pr_flags & PR_MPSYSCTL) == 0)
sysctl_vsunlock(oldp, savelen);
return (error);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ppp_tty.c,v 1.54 2022/01/02 22:36:04 jsg Exp $ */
/* $OpenBSD: ppp_tty.c,v 1.55 2024/08/17 09:52:11 denis Exp $ */
/* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */
/*
@ -371,6 +371,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag)
bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
m0->m_data += PPP_HDRLEN;
m0->m_len -= PPP_HDRLEN;
m0->m_pkthdr.ph_rtableid = sc->sc_if.if_rdomain;
return sc->sc_if.if_output(&sc->sc_if, m0, &dst, NULL);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_proto.c,v 1.107 2024/07/26 14:38:20 bluhm Exp $ */
/* $OpenBSD: in_proto.c,v 1.108 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@ -354,7 +354,7 @@ const struct protosw inetsw[] = {
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_DIVERT,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip_ctloutput,
.pr_usrreqs = &divert_usrreqs,
.pr_init = divert_init,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
/* $OpenBSD: ip_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -41,17 +41,22 @@
#include <net/pfvar.h>
/*
* Locks used to protect data:
* a atomic
*/
struct inpcbtable divbtable;
struct cpumem *divcounters;
#ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100)
#endif
u_int divert_sendspace = DIVERT_SENDSPACE;
u_int divert_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100)
#endif
u_int divert_recvspace = DIVERT_RECVSPACE;
u_int divert_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128
@ -271,7 +276,8 @@ divert_attach(struct socket *so, int proto, int wait)
if (error)
return error;
error = soreserve(so, divert_sendspace, divert_recvspace);
error = soreserve(so, atomic_load_int(&divert_sendspace),
atomic_load_int(&divert_recvspace));
if (error)
return error;
@ -346,8 +352,6 @@ int
divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
int error;
/* All sysctl names at this level are terminal. */
if (namelen != 1)
return (ENOTDIR);
@ -356,12 +360,9 @@ divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case DIVERTCTL_STATS:
return (divert_sysctl_divstat(oldp, oldlenp, newp));
default:
NET_LOCK();
error = sysctl_bounded_arr(divertctl_vars,
nitems(divertctl_vars), name, namelen, oldp, oldlenp, newp,
newlen);
NET_UNLOCK();
return (error);
return (sysctl_bounded_arr(divertctl_vars,
nitems(divertctl_vars), name, namelen, oldp, oldlenp,
newp, newlen));
}
/* NOTREACHED */
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6_proto.c,v 1.117 2024/07/26 14:38:20 bluhm Exp $ */
/* $OpenBSD: in6_proto.c,v 1.118 2024/08/16 09:20:35 mvs Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@ -289,7 +289,7 @@ const struct protosw inet6sw[] = {
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_DIVERT,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET,
.pr_flags = PR_ATOMIC|PR_ADDR|PR_MPSOCKET|PR_MPSYSCTL,
.pr_ctloutput = rip6_ctloutput,
.pr_usrreqs = &divert6_usrreqs,
.pr_init = divert6_init,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_divert.c,v 1.96 2024/07/12 19:50:35 bluhm Exp $ */
/* $OpenBSD: ip6_divert.c,v 1.97 2024/08/16 09:20:35 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -44,17 +44,22 @@
#include <net/pfvar.h>
/*
* Locks used to protect data:
* a atomic
*/
struct inpcbtable divb6table;
struct cpumem *div6counters;
#ifndef DIVERT_SENDSPACE
#define DIVERT_SENDSPACE (65536 + 100)
#endif
u_int divert6_sendspace = DIVERT_SENDSPACE;
u_int divert6_sendspace = DIVERT_SENDSPACE; /* [a] */
#ifndef DIVERT_RECVSPACE
#define DIVERT_RECVSPACE (65536 + 100)
#endif
u_int divert6_recvspace = DIVERT_RECVSPACE;
u_int divert6_recvspace = DIVERT_RECVSPACE; /* [a] */
#ifndef DIVERTHASHSIZE
#define DIVERTHASHSIZE 128
@ -279,7 +284,8 @@ divert6_attach(struct socket *so, int proto, int wait)
if (error)
return (error);
error = soreserve(so, divert6_sendspace, divert6_recvspace);
error = soreserve(so, atomic_load_int(&divert6_sendspace),
atomic_load_int(&divert6_recvspace));
if (error)
return (error);
@ -322,8 +328,6 @@ int
divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen)
{
int error;
/* All sysctl names at this level are terminal. */
if (namelen != 1)
return (ENOTDIR);
@ -332,12 +336,9 @@ divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
case DIVERT6CTL_STATS:
return (divert6_sysctl_div6stat(oldp, oldlenp, newp));
default:
NET_LOCK();
error = sysctl_bounded_arr(divert6ctl_vars,
return (sysctl_bounded_arr(divert6ctl_vars,
nitems(divert6ctl_vars), name, namelen, oldp, oldlenp,
newp, newlen);
NET_UNLOCK();
return (error);
newp, newlen));
}
/* NOTREACHED */
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nfs_serv.c,v 1.126 2024/05/01 13:15:59 jsg Exp $ */
/* $OpenBSD: nfs_serv.c,v 1.127 2024/08/17 07:02:13 jsg Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@ -1038,12 +1038,12 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0;
else if (error != 0)
goto nfsmout;
return error;
fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout;
return error;
if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout;
return error;
if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0;
@ -1325,12 +1325,12 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0;
else if (error != 0)
goto nfsmout;
return error;
fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout;
return error;
if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout;
return error;
if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0;
@ -1598,12 +1598,12 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0;
else if (error != 0)
goto nfsmout;
return error;
ffhp = &fnfh.fh_generic;
if (nfsm_srvmtofh2(&info, ffhp) != 0)
goto nfsmout;
return error;
if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout;
return error;
if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0;
@ -1757,12 +1757,6 @@ out1:
nfsmout:
if (fdirp)
vrele(fdirp);
if (tdirp)
vrele(tdirp);
if (tond.ni_cnd.cn_nameiop) {
vrele(tond.ni_startdir);
pool_put(&namei_pool, tond.ni_cnd.cn_pnbuf);
}
if (fromnd.ni_cnd.cn_nameiop) {
if (fromnd.ni_startdir)
vrele(fromnd.ni_startdir);
@ -1928,12 +1922,12 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0;
else if (error != 0)
goto nfsmout;
return error;
fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout;
return error;
if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout;
return error;
if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0;
@ -2088,12 +2082,12 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
if (nfsm_srvmtofh1(&info, nfsd, slp, mrq) != 0)
return 0;
else if (error != 0)
goto nfsmout;
return error;
fhp = &nfh.fh_generic;
if (nfsm_srvmtofh2(&info, fhp) != 0)
goto nfsmout;
return error;
if (nfsm_srvnamesiz(&info, &len) != 0)
goto nfsmout;
return error;
if (error) {
if (nfsm_reply(&info, nfsd, slp, mrq, error, 0) != 0)
return 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: protosw.h,v 1.67 2024/07/12 19:50:35 bluhm Exp $ */
/* $OpenBSD: protosw.h,v 1.68 2024/08/16 09:20:35 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
@ -131,6 +131,7 @@ struct protosw {
#define PR_SPLICE 0x0040 /* socket splicing is possible */
#define PR_MPINPUT 0x0080 /* input runs with shared netlock */
#define PR_MPSOCKET 0x0100 /* socket uses shared netlock */
#define PR_MPSYSCTL 0x0200 /* mp-safe sysctl(2) handler */
/*
* The arguments to usrreq are: